From 101ca637aa676cdb42602777e599fef6ee530e04 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Sun, 19 Dec 2004 23:11:23 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'unlabeled-1.7.186'. --- .cvsignore | 33 - COPYING | 352 - ChangeLog | 1 - README | 2 - README.lustrecvs | 5 - autoMakefile.am | 1 - autogen.sh | 2 - build/.cvsignore | 9 - build/Makefile | 49 - build/Makefile.in.toplevel | 4 - build/Rules.in | 46 - build/autoMakefile.am | 8 - build/autoMakefile.am.toplevel | 60 - build/autoconf/.cvsignore | 2 - build/autoconf/Makefile.am | 2 - build/autoconf/lustre-build-darwin.m4 | 34 - build/autoconf/lustre-build-linux.m4 | 318 - build/autoconf/lustre-build.m4 | 406 - build/autogen.sh | 109 - build/branch.sh | 48 - build/buildcvs | 36 - build/land1.sh | 118 - build/land2.sh | 28 - build/lbuild | 528 - build/linux-merge-config.awk | 317 - build/linux-merge-modules.awk | 125 - build/linux-rhconfig.h | 229 - build/lmake | 658 - build/lustre-kernel-2.4.spec.in | 983 - build/lustre.spec.in | 236 - build/merge1.sh | 103 - build/merge2.sh | 29 - build/suse-functions.sh | 22 - build/suse-post.sh | 46 - build/suse-postun.sh | 43 - build/suse-trigger-script.sh.in | 9 - configure.ac | 16 - .../patches/export-ext3-2.6-suse.patch | 33 - .../patches/export_symbols-ext3-2.6-suse.patch | 17 - .../patches/ext3-ea-in-inode-2.6-suse.patch | 841 - .../patches/ext3-include-fixes-2.6-suse.patch | 20 - .../patches/ext3-map_inode_page-2.6-suse.patch | 81 - .../patches/ext3-san-jdike-2.6-suse.patch | 106 - .../patches/ext3-wantedi-2.6-suse.patch | 184 - .../kernel_patches/patches/iopen-2.6-suse.patch | 475 - .../kernel_patches/series/ldiskfs-2.6-suse.series | 10 - ldiskfs/ldiskfs/Makefile.in | 18 - ldiskfs/ldiskfs/autoMakefile.am | 77 - libsysio/AUTHORS | 1 - libsysio/COPYING | 502 - libsysio/ChangeLog | 31 - libsysio/Makefile.am | 89 - libsysio/NEWS | 0 libsysio/README | 66 - libsysio/Rules.make | 19 - libsysio/autogen.sh | 5 - libsysio/configure.in | 427 - libsysio/dev/stdfd/module.mk | 2 - libsysio/dev/stdfd/stdfd.c | 214 - libsysio/dev/stdfd/stdfd.h | 50 - libsysio/drivers/incore/README | 27 - libsysio/drivers/incore/fs_incore.c | 1697 -- libsysio/drivers/incore/fs_incore.h | 48 - libsysio/drivers/incore/module.mk | 2 - libsysio/drivers/native/fs_native.c | 1801 -- libsysio/drivers/native/fs_native.h | 48 - libsysio/drivers/native/module.mk | 2 - libsysio/drivers/sockets/module.mk | 2 - libsysio/drivers/sockets/sockets.c | 606 - libsysio/drivers/yod/fs_yod.c | 1251 -- libsysio/drivers/yod/fs_yod.h | 48 - libsysio/drivers/yod/module.mk | 10 - libsysio/include/cplant-yod.h | 69 - libsysio/include/dev.h | 153 - libsysio/include/file.h | 110 - libsysio/include/fs.h | 172 - libsysio/include/inode.h | 516 - libsysio/include/module.mk | 4 - libsysio/include/mount.h | 98 - libsysio/include/namespace.h | 30 - libsysio/include/sysio-symbols.h | 26 - libsysio/include/sysio.h | 338 - libsysio/include/xtio.h | 328 - libsysio/misc/gdb-libsysio | 127 - libsysio/misc/init-env.sh | 41 - libsysio/src/access.c | 133 - libsysio/src/chdir.c | 256 - libsysio/src/chmod.c | 118 - libsysio/src/chown.c | 127 - libsysio/src/dev.c | 172 - libsysio/src/dup.c | 97 - libsysio/src/fcntl.c | 137 - libsysio/src/file.c | 314 - libsysio/src/file_hack.c | 422 - libsysio/src/fs.c | 161 - libsysio/src/fsync.c | 81 - libsysio/src/getdirentries.c | 307 - libsysio/src/init.c | 687 - libsysio/src/inode.c | 969 - libsysio/src/ioctl.c | 90 - libsysio/src/ioctx.c | 551 - libsysio/src/iowait.c | 97 - libsysio/src/link.c | 109 - libsysio/src/lseek.c | 189 - libsysio/src/mkdir.c | 89 - libsysio/src/mknod.c | 134 - libsysio/src/module.mk | 31 - libsysio/src/mount.c | 677 - libsysio/src/namei.c | 471 - libsysio/src/open.c | 301 - libsysio/src/readlink.c | 83 - libsysio/src/rename.c | 181 - libsysio/src/rmdir.c | 97 - libsysio/src/rw.c | 1325 -- libsysio/src/stat.c | 298 - libsysio/src/stat64.c | 181 - libsysio/src/statvfs.c | 155 - libsysio/src/statvfs64.c | 107 - libsysio/src/stdlib.c | 315 - libsysio/src/symlink.c | 90 - libsysio/src/truncate.c | 157 - libsysio/src/unlink.c | 103 - libsysio/src/utime.c | 86 - libsysio/tests/Makefile.am | 114 - libsysio/tests/README | 185 - libsysio/tests/cleanup.pl | 96 - libsysio/tests/drv_init_all.c | 23 - libsysio/tests/gendrvdata.sh | 61 - libsysio/tests/help.c | 551 - libsysio/tests/helper.pm | 147 - libsysio/tests/module.mk | 2 - libsysio/tests/populator.pl | 155 - libsysio/tests/setup.pl | 104 - libsysio/tests/startup.c | 51 - libsysio/tests/sysio_stubs.c | 2706 --- libsysio/tests/sysio_tests.c | 861 - libsysio/tests/test.h | 48 - libsysio/tests/test_all.pl | 223 - libsysio/tests/test_copy.bash | 129 - libsysio/tests/test_copy.c | 191 - libsysio/tests/test_copy.pl | 218 - libsysio/tests/test_driver.c | 1085 - libsysio/tests/test_driver.h | 301 - libsysio/tests/test_getcwd.c | 170 - libsysio/tests/test_getcwd.pl | 121 - libsysio/tests/test_link.c | 136 - libsysio/tests/test_list.c | 210 - libsysio/tests/test_list.pl | 237 - libsysio/tests/test_path.c | 223 - libsysio/tests/test_path.pl | 188 - libsysio/tests/test_regions.c | 292 - libsysio/tests/test_rename.c | 130 - libsysio/tests/test_rw.pl | 537 - libsysio/tests/test_stats.c | 187 - libsysio/tests/test_stats.pl | 268 - libsysio/tests/test_stdfd.pl | 242 - libsysio/tests/test_strided.pl | 462 - libsysio/tests/test_symlink.pl | 247 - libsysio/tests/test_unlink.c | 161 - libsysio/tests/verifier.pl | 161 - lnet/.cvsignore | 11 - lnet/AUTHORS | 0 lnet/ChangeLog | 0 lnet/Kernelenv.in | 6 - lnet/Kernelenv.mk | 4 - lnet/Makefile.in | 9 - lnet/Makefile.mk | 12 - lnet/NEWS | 0 lnet/README | 0 lnet/archdep.m4 | 902 - lnet/autoMakefile.am | 9 - lnet/autoconf/.cvsignore | 2 - lnet/autoconf/Makefile.am | 1 - lnet/autoconf/lustre-lnet.m4 | 483 - lnet/autogen.sh | 5 - lnet/build.m4 | 127 - lnet/doc/.cvsignore | 4 - lnet/doc/Data-structures | 65 - lnet/doc/Makefile.am | 51 - lnet/doc/Message-life-cycle | 118 - lnet/doc/NAL-HOWTO | 293 - lnet/doc/file.fig | 111 - lnet/doc/flow_new.fig | 213 - lnet/doc/get.fig | 33 - lnet/doc/ieee.bst | 1112 - lnet/doc/mpi.fig | 117 - lnet/doc/portals.fig | 68 - lnet/doc/portals3.bib | 124 - lnet/doc/portals3.lyx | 15944 --------------- lnet/doc/put.fig | 32 - lnet/include/.cvsignore | 6 - lnet/include/Makefile.am | 3 - lnet/include/cygwin-ioctl.h | 81 - lnet/include/linux/.cvsignore | 2 - lnet/include/linux/Makefile.am | 4 - lnet/include/linux/kp30.h | 748 - lnet/include/linux/kpr.h | 176 - lnet/include/linux/libcfs.h | 410 - lnet/include/linux/lustre_list.h | 246 - lnet/include/linux/portals_compat25.h | 96 - lnet/include/linux/portals_lib.h | 90 - lnet/include/lnet/.cvsignore | 2 - lnet/include/lnet/Makefile.am | 10 - lnet/include/lnet/api-support.h | 22 - lnet/include/lnet/api.h | 138 - lnet/include/lnet/build_check.h | 8 - lnet/include/lnet/errno.h | 53 - lnet/include/lnet/internal.h | 16 - lnet/include/lnet/lib-lnet.h | 465 - lnet/include/lnet/lib-p30.h | 465 - lnet/include/lnet/lib-types.h | 359 - lnet/include/lnet/list.h | 243 - lnet/include/lnet/lltrace.h | 173 - lnet/include/lnet/lnet.h | 26 - lnet/include/lnet/lnetctl.h | 96 - lnet/include/lnet/myrnal.h | 23 - lnet/include/lnet/nal.h | 87 - lnet/include/lnet/nalids.h | 2 - lnet/include/lnet/p30.h | 26 - lnet/include/lnet/ptlctl.h | 96 - lnet/include/lnet/socklnd.h | 14 - lnet/include/lnet/stringtab.h | 3 - lnet/include/lnet/types.h | 193 - lnet/klnds/.cvsignore | 5 - lnet/klnds/Makefile.in | 9 - lnet/klnds/Makefile.mk | 5 - lnet/klnds/autoMakefile.am | 6 - lnet/klnds/gmlnd/.cvsignore | 10 - lnet/klnds/gmlnd/Makefile.in | 6 - lnet/klnds/gmlnd/Makefile.mk | 10 - lnet/klnds/gmlnd/autoMakefile.am | 15 - lnet/klnds/gmlnd/gmlnd.h | 455 - lnet/klnds/gmlnd/gmlnd_api.c | 424 - lnet/klnds/gmlnd/gmlnd_cb.c | 207 - lnet/klnds/gmlnd/gmlnd_comm.c | 1380 -- lnet/klnds/gmlnd/gmlnd_module.c | 134 - lnet/klnds/gmlnd/gmlnd_utils.c | 1075 - lnet/klnds/iiblnd/.cvsignore | 10 - lnet/klnds/iiblnd/Makefile.in | 6 - lnet/klnds/iiblnd/Makefile.mk | 10 - lnet/klnds/iiblnd/autoMakefile.am | 15 - lnet/klnds/iiblnd/iiblnd.c | 1713 -- lnet/klnds/iiblnd/iiblnd.h | 892 - lnet/klnds/iiblnd/iiblnd_cb.c | 3018 --- lnet/klnds/lolnd/.cvsignore | 10 - lnet/klnds/lolnd/Makefile.in | 4 - lnet/klnds/lolnd/autoMakefile.am | 11 - lnet/klnds/lolnd/lolnd.c | 164 - lnet/klnds/lolnd/lolnd.h | 74 - lnet/klnds/lolnd/lolnd_cb.c | 267 - lnet/klnds/openiblnd/.cvsignore | 10 - lnet/klnds/openiblnd/Makefile.in | 6 - lnet/klnds/openiblnd/Makefile.mk | 10 - lnet/klnds/openiblnd/autoMakefile.am | 15 - lnet/klnds/openiblnd/openiblnd.c | 1486 -- lnet/klnds/openiblnd/openiblnd.h | 533 - lnet/klnds/openiblnd/openiblnd_cb.c | 2597 --- lnet/klnds/qswlnd/.cvsignore | 10 - lnet/klnds/qswlnd/Makefile.in | 6 - lnet/klnds/qswlnd/autoMakefile.am | 15 - lnet/klnds/qswlnd/qswlnd.c | 800 - lnet/klnds/qswlnd/qswlnd.h | 376 - lnet/klnds/qswlnd/qswlnd_cb.c | 2008 -- lnet/klnds/ralnd/.cvsignore | 10 - lnet/klnds/ralnd/Makefile.in | 6 - lnet/klnds/ralnd/autoMakefile.am | 15 - lnet/klnds/ralnd/ralnd.c | 1983 -- lnet/klnds/ralnd/ralnd.h | 477 - lnet/klnds/ralnd/ralnd_cb.c | 1766 -- lnet/klnds/socklnd/.cvsignore | 10 - lnet/klnds/socklnd/Makefile.in | 8 - lnet/klnds/socklnd/Makefile.mk | 10 - lnet/klnds/socklnd/autoMakefile.am | 13 - lnet/klnds/socklnd/socklnd.c | 2531 --- lnet/klnds/socklnd/socklnd.h | 526 - lnet/klnds/socklnd/socklnd_cb.c | 2934 --- lnet/libcfs/.cvsignore | 11 - lnet/libcfs/Makefile.in | 4 - lnet/libcfs/Makefile.mk | 9 - lnet/libcfs/autoMakefile.am | 11 - lnet/libcfs/debug.c | 336 - lnet/libcfs/lwt.c | 268 - lnet/libcfs/module.c | 608 - lnet/libcfs/proc.c | 321 - lnet/libcfs/tracefile.c | 876 - lnet/libcfs/tracefile.h | 22 - lnet/libcfs/watchdog.c | 402 - lnet/lnet/.cvsignore | 10 - lnet/lnet/Makefile.in | 6 - lnet/lnet/Makefile.mk | 12 - lnet/lnet/api-errno.c | 48 - lnet/lnet/api-ni.c | 265 - lnet/lnet/api-wrap.c | 366 - lnet/lnet/autoMakefile.am | 26 - lnet/lnet/lib-eq.c | 265 - lnet/lnet/lib-init.c | 434 - lnet/lnet/lib-md.c | 426 - lnet/lnet/lib-me.c | 185 - lnet/lnet/lib-move.c | 1427 -- lnet/lnet/lib-msg.c | 147 - lnet/lnet/lib-ni.c | 72 - lnet/lnet/lib-pid.c | 46 - lnet/lnet/module.c | 201 - lnet/packaging/.cvsignore | 8 - lnet/packaging/Makefile.am | 6 - lnet/packaging/portals.spec.in | 116 - lnet/router/.cvsignore | 10 - lnet/router/Makefile.in | 4 - lnet/router/Makefile.mk | 9 - lnet/router/autoMakefile.am | 13 - lnet/router/proc.c | 242 - lnet/router/router.c | 824 - lnet/router/router.h | 105 - lnet/tests/.cvsignore | 10 - lnet/tests/Makefile.in | 16 - lnet/tests/Makefile.mk | 9 - lnet/tests/autoMakefile.am | 16 - lnet/tests/ping.h | 80 - lnet/tests/ping_cli.c | 303 - lnet/tests/ping_srv.c | 308 - lnet/tests/sping_cli.c | 279 - lnet/tests/sping_srv.c | 294 - lnet/tests/startclient.sh | 37 - lnet/tests/startserver.sh | 38 - lnet/tests/stopclient.sh | 14 - lnet/tests/stopserver.sh | 16 - lnet/ulnds/.cvsignore | 3 - lnet/ulnds/Makefile.am | 10 - lnet/ulnds/README | 53 - lnet/ulnds/address.c | 145 - lnet/ulnds/bridge.h | 34 - lnet/ulnds/connection.c | 508 - lnet/ulnds/connection.h | 35 - lnet/ulnds/debug.c | 119 - lnet/ulnds/dispatch.h | 46 - lnet/ulnds/ipmap.h | 38 - lnet/ulnds/pqtimer.c | 226 - lnet/ulnds/pqtimer.h | 25 - lnet/ulnds/procapi.c | 196 - lnet/ulnds/procbridge.h | 56 - lnet/ulnds/proclib.c | 137 - lnet/ulnds/select.c | 419 - lnet/ulnds/socklnd/Makefile.am | 10 - lnet/ulnds/socklnd/README | 53 - lnet/ulnds/socklnd/address.c | 145 - lnet/ulnds/socklnd/bridge.h | 34 - lnet/ulnds/socklnd/connection.c | 508 - lnet/ulnds/socklnd/connection.h | 35 - lnet/ulnds/socklnd/debug.c | 119 - lnet/ulnds/socklnd/dispatch.h | 46 - lnet/ulnds/socklnd/ipmap.h | 38 - lnet/ulnds/socklnd/pqtimer.c | 226 - lnet/ulnds/socklnd/pqtimer.h | 25 - lnet/ulnds/socklnd/procapi.c | 196 - lnet/ulnds/socklnd/procbridge.h | 56 - lnet/ulnds/socklnd/proclib.c | 137 - lnet/ulnds/socklnd/select.c | 419 - lnet/ulnds/socklnd/table.c | 264 - lnet/ulnds/socklnd/table.h | 39 - lnet/ulnds/socklnd/tcplnd.c | 256 - lnet/ulnds/socklnd/timer.h | 30 - lnet/ulnds/socklnd/utypes.h | 12 - lnet/ulnds/table.c | 264 - lnet/ulnds/table.h | 39 - lnet/ulnds/tcplnd.c | 256 - lnet/ulnds/timer.h | 30 - lnet/ulnds/utypes.h | 12 - lnet/utils/.cvsignore | 10 - lnet/utils/Makefile.am | 46 - lnet/utils/Makefile.mk | 6 - lnet/utils/acceptor.c | 249 - lnet/utils/debug.c | 833 - lnet/utils/debugctl.c | 66 - lnet/utils/gmlndnid.c | 117 - lnet/utils/l_ioctl.c | 339 - lnet/utils/parser.c | 651 - lnet/utils/parser.h | 67 - lnet/utils/portals.c | 1935 -- lnet/utils/ptlctl.c | 74 - lnet/utils/routerstat.c | 120 - lnet/utils/wirecheck.c | 207 - lustre-iokit/ior-survey/README | 3 - lustre-iokit/ior-survey/ior-survey | 294 - lustre-iokit/obdfilter-survey/README | 141 - lustre-iokit/obdfilter-survey/obdfilter-survey | 481 - lustre-iokit/sgpdd-survey/README | 64 - lustre-iokit/sgpdd-survey/sgpdd-survey | 147 - lustre/.cvsignore | 30 - lustre/BUGS | 15 - lustre/BUILDING | 30 - lustre/COPYING | 352 - lustre/ChangeLog | 737 - lustre/FDL | 355 - lustre/Makefile.in | 25 - lustre/Makefile.mk | 23 - lustre/Rules.in | 46 - lustre/autoMakefile.am | 51 - lustre/autoconf/Makefile.am | 1 - lustre/autoconf/lustre-core.m4 | 489 - lustre/autoconf/lustre-version.ac | 1 - lustre/cmobd/.cvsignore | 15 - lustre/cmobd/Makefile.in | 4 - lustre/cmobd/Makefile.mk | 11 - lustre/cmobd/autoMakefile.am | 11 - lustre/cmobd/cm_internal.h | 45 - lustre/cmobd/cm_mds_reint.c | 401 - lustre/cmobd/cm_obd.c | 340 - lustre/cmobd/cm_oss_reint.c | 338 - lustre/cmobd/cm_reint.c | 122 - lustre/cmobd/cm_write.c | 750 - lustre/cmobd/lproc_cm.c | 34 - lustre/cobd/.cvsignore | 10 - lustre/cobd/Makefile.in | 4 - lustre/cobd/autoMakefile.am | 11 - lustre/cobd/cache_obd.c | 1327 -- lustre/cobd/lproc_cache.c | 83 - lustre/conf/.cvsignore | 2 - lustre/conf/lustre.dtd | 147 - lustre/conf/lustre2ldif.xsl | 293 - lustre/conf/modules.conf | 6 - lustre/conf/slapd-lustre.conf | 11 - lustre/conf/top.ldif | 4 - lustre/doc/.cvsignore | 23 - lustre/doc/Makefile.am | 130 - lustre/doc/VERSIONING | 91 - lustre/doc/chbar.sh | 243 - lustre/doc/lconf.8 | 159 - lustre/doc/lconf.lyx | 381 - lustre/doc/lctl.8 | 391 - lustre/doc/lctl.lyx | 975 - lustre/doc/lfs.1 | 53 - lustre/doc/lfs.lyx | 309 - lustre/doc/lmc.1 | 308 - lustre/doc/lmc.lyx | 706 - lustre/doc/lwizard.1 | 84 - lustre/doc/postbar | 151 - lustre/doc/tex2pdf | 3043 --- lustre/include/.cvsignore | 13 - lustre/include/Makefile.am | 9 - lustre/include/ioctl.h | 64 - lustre/include/liblustre.h | 766 - lustre/include/linux/.cvsignore | 15 - lustre/include/linux/Makefile.am | 18 - lustre/include/linux/lprocfs_status.h | 392 - lustre/include/linux/lustre_cfg.h | 287 - lustre/include/linux/lustre_cmobd.h | 86 - lustre/include/linux/lustre_commit_confd.h | 73 - lustre/include/linux/lustre_compat25.h | 341 - lustre/include/linux/lustre_debug.h | 53 - lustre/include/linux/lustre_dlm.h | 595 - lustre/include/linux/lustre_export.h | 98 - lustre/include/linux/lustre_fsfilt.h | 731 - lustre/include/linux/lustre_ha.h | 28 - lustre/include/linux/lustre_handles.h | 39 - lustre/include/linux/lustre_idl.h | 1119 - lustre/include/linux/lustre_import.h | 128 - lustre/include/linux/lustre_lib.h | 740 - lustre/include/linux/lustre_lite.h | 186 - lustre/include/linux/lustre_log.h | 518 - lustre/include/linux/lustre_mds.h | 300 - lustre/include/linux/lustre_mgmt.h | 34 - lustre/include/linux/lustre_net.h | 868 - lustre/include/linux/lustre_smfs.h | 515 - lustre/include/linux/lustre_snap.h | 214 - lustre/include/linux/lvfs.h | 136 - lustre/include/linux/lvfs_linux.h | 36 - lustre/include/linux/obd.h | 922 - lustre/include/linux/obd_cache.h | 13 - lustre/include/linux/obd_class.h | 1594 -- lustre/include/linux/obd_echo.h | 41 - lustre/include/linux/obd_lmv.h | 10 - lustre/include/linux/obd_lov.h | 48 - lustre/include/linux/obd_ost.h | 54 - lustre/include/linux/obd_ptlbd.h | 33 - lustre/include/linux/obd_support.h | 376 - lustre/include/linux/obd_trace.h | 20 - lustre/include/lustre/.cvsignore | 2 - lustre/include/lustre/Makefile.am | 9 - lustre/include/lustre/liblustreapi.h | 42 - lustre/include/lustre/lustre_user.h | 133 - lustre/kernel-tests/.cvsignore | 5 - lustre/kernel-tests/Makefile | 24 - lustre/kernel_patches/README | 717 - .../kernel_configs/config-linux-2.6.7-uml | 493 - .../kernel_configs/kgdb_2.6.0_test1_vmware.config | 914 - .../kernel_patches/patches/dcache-fid-2.6.7.patch | 11 - .../patches/dcache-mds-num-2.6.7.patch | 22 - .../patches/dev_read_only-2.6-suse.patch | 81 - .../patches/dynamic-locks-2.6.7.patch | 278 - .../kernel_patches/patches/export-2.6-suse.patch | 24 - .../patches/export-ext3-2.6-suse.patch | 33 - .../patches/export-truncate-2.6-suse.patch | 37 - .../patches/export_symbols-2.6-suse.patch | 87 - .../patches/export_symbols-ext3-2.6-suse.patch | 17 - .../patches/ext3-ea-in-inode-2.6-suse.patch | 841 - .../patches/ext3-extents-2.6.7.patch | 2844 --- .../patches/ext3-extents-in-ea-2.6.7.patch | 361 - .../ext3-extents-in-ea-exports-symbol-2.6.7.patch | 93 - .../patches/ext3-extents-in-ea-ioctl-2.6.7.patch | 228 - lustre/kernel_patches/patches/ext3-fid-2.6.7.patch | 40 - .../patches/ext3-include-fixes-2.6-suse.patch | 20 - .../patches/ext3-init-generation-2.6-suse.patch | 12 - .../patches/ext3-inode-reuse-2.6.7.patch | 120 - .../patches/ext3-map_inode_page-2.6-suse.patch | 81 - .../patches/ext3-mds-num-2.6.7.patch | 281 - .../patches/ext3-pdirops-2.6.7.patch | 1211 -- .../patches/ext3-reserve-inode-space-2.6.7.patch | 286 - .../patches/ext3-san-jdike-2.6-suse.patch | 106 - .../kernel_patches/patches/ext3-super-ntohl.patch | 16 - .../patches/ext3-wantedi-2.6-suse.patch | 184 - .../patches/ext3-wantedi-misc-2.6-suse.patch | 16 - .../patches/ext3-xattr-header-move-2.6.suse.patch | 506 - .../patches/header-guards-2.6-suse.patch | 38 - lustre/kernel_patches/patches/iopen-2.6-suse.patch | 475 - .../kernel_patches/patches/iopen-2.6-vanilla.patch | 476 - .../patches/iopen-misc-2.6-suse.patch | 80 - .../patches/lookup_bdev_init_intent.patch | 12 - lustre/kernel_patches/patches/lustre_version.patch | 14 - .../patches/md_path_lookup-2.6-suse.patch | 25 - .../patches/nfs-cifs-intent-2.6-suse.patch | 120 - .../patches/nfs-cifs-intent-2.6-vanilla.patch | 117 - .../patches/removepage-vanilla-2.6.5.patch | 31 - .../patches/revalide-special-oops-2.6.4.suse.patch | 22 - .../kernel_patches/patches/uml-2.6.7-01-bb2.patch | 20390 ------------------- .../kernel_patches/patches/vfs-pdirops-2.6.7.patch | 264 - .../patches/vfs-wantedi-misc-2.6-suse.patch | 16 - .../patches/vfs_intent-2.6-suse.patch | 861 - .../patches/vfs_intent-2.6-vanilla.patch | 840 - .../patches/vfs_nointent-2.6-suse.patch | 494 - .../patches/vfs_nointent-2.6-vanilla.patch | 509 - .../patches/vfs_races-2.6-suse.patch | 62 - .../patches/vfs_races-2.6-vanilla.patch | 65 - lustre/kernel_patches/prepare_tree.sh | 88 - lustre/kernel_patches/scripts/added-by-patch | 14 - lustre/kernel_patches/scripts/apatch | 97 - lustre/kernel_patches/scripts/cat-series | 17 - lustre/kernel_patches/scripts/combine-applied | 45 - lustre/kernel_patches/scripts/combine-series | 43 - lustre/kernel_patches/scripts/cvs-take-patch | 78 - lustre/kernel_patches/scripts/export_patch | 55 - lustre/kernel_patches/scripts/extract_description | 87 - lustre/kernel_patches/scripts/forkpatch | 76 - lustre/kernel_patches/scripts/fpatch | 53 - lustre/kernel_patches/scripts/import_patch | 102 - lustre/kernel_patches/scripts/inpatch | 27 - lustre/kernel_patches/scripts/join-patch | 28 - lustre/kernel_patches/scripts/linus-patch | 26 - lustre/kernel_patches/scripts/mpatch | 101 - lustre/kernel_patches/scripts/new-kernel | 82 - lustre/kernel_patches/scripts/p0-2-p1 | 10 - lustre/kernel_patches/scripts/p_diff | 60 - lustre/kernel_patches/scripts/patchdesc | 21 - lustre/kernel_patches/scripts/patchfns | 256 - lustre/kernel_patches/scripts/pcpatch | 45 - lustre/kernel_patches/scripts/poppatch | 72 - lustre/kernel_patches/scripts/prep-patch | 18 - lustre/kernel_patches/scripts/pstatus | 156 - lustre/kernel_patches/scripts/ptkdiff | 46 - lustre/kernel_patches/scripts/pushpatch | 86 - lustre/kernel_patches/scripts/refpatch | 32 - lustre/kernel_patches/scripts/removed-by-patch | 14 - lustre/kernel_patches/scripts/rename-patch | 20 - lustre/kernel_patches/scripts/rolled-up-patch | 30 - lustre/kernel_patches/scripts/rpatch | 90 - lustre/kernel_patches/scripts/split-patch | 29 - lustre/kernel_patches/scripts/sum-series | 41 - lustre/kernel_patches/scripts/tag-series | 41 - lustre/kernel_patches/scripts/toppatch | 27 - lustre/kernel_patches/scripts/touched-by-patch | 32 - lustre/kernel_patches/scripts/trypatch | 72 - lustre/kernel_patches/scripts/unitdiff.py | 223 - lustre/kernel_patches/scripts/unused-patches | 39 - lustre/kernel_patches/series/2.6-suse.series | 14 - lustre/kernel_patches/series/2.6-vanilla.series | 19 - .../kernel_patches/series/ldiskfs-2.6-suse.series | 10 - .../series/ldiskfs-2.6-vanilla.series | 17 - lustre/kernel_patches/targets/2.6-suse.target | 13 - lustre/kernel_patches/targets/chaos-2.4.18.target | 13 - lustre/kernel_patches/targets/hp_pnnl-2.4.target | 13 - lustre/kernel_patches/targets/rh-2.4.target | 13 - lustre/kernel_patches/targets/suse-2.4.21-2.target | 14 - lustre/kernel_patches/txt/dev_read_only.txt | 3 - lustre/kernel_patches/txt/exports.txt | 3 - lustre/kernel_patches/txt/exports_hp.txt | 3 - lustre/kernel_patches/txt/ext3-2.4.20-fixes.txt | 3 - lustre/kernel_patches/txt/ext3-map_inode_page.txt | 3 - .../txt/ext3-map_inode_page_2.4.18.txt | 3 - lustre/kernel_patches/txt/invalidate_show.txt | 3 - lustre/kernel_patches/txt/kmem_cache_validate.txt | 3 - lustre/kernel_patches/txt/lustre_version.txt | 3 - lustre/kernel_patches/txt/uml_check_get_page.txt | 3 - lustre/kernel_patches/txt/uml_no_panic.txt | 3 - lustre/kernel_patches/which_patch | 9 - lustre/ldiskfs/.cvsignore | 19 - lustre/ldiskfs/Makefile.in | 18 - lustre/ldiskfs/autoMakefile.am | 77 - lustre/ldlm/.cvsignore | 6 - lustre/ldlm/Makefile.am | 13 - lustre/ldlm/Makefile.mk | 11 - lustre/ldlm/l_lock.c | 138 - lustre/ldlm/ldlm_extent.c | 417 - lustre/ldlm/ldlm_flock.c | 560 - lustre/ldlm/ldlm_inodebits.c | 135 - lustre/ldlm/ldlm_internal.h | 91 - lustre/ldlm/ldlm_lib.c | 1385 -- lustre/ldlm/ldlm_lock.c | 1235 -- lustre/ldlm/ldlm_lockd.c | 1605 -- lustre/ldlm/ldlm_plain.c | 128 - lustre/ldlm/ldlm_request.c | 1056 - lustre/ldlm/ldlm_resource.c | 760 - lustre/ldlm/ldlm_test.c | 648 - lustre/liblustre/.cvsignore | 9 - lustre/liblustre/Makefile.am | 61 - lustre/liblustre/dir.c | 244 - lustre/liblustre/file.c | 430 - lustre/liblustre/genlib.sh | 120 - lustre/liblustre/llite_lib.c | 368 - lustre/liblustre/llite_lib.h | 286 - lustre/liblustre/lutil.c | 353 - lustre/liblustre/lutil.h | 35 - lustre/liblustre/namei.c | 561 - lustre/liblustre/rw.c | 781 - lustre/liblustre/super.c | 1614 -- lustre/liblustre/tests/.cvsignore | 9 - lustre/liblustre/tests/Makefile.am | 56 - lustre/liblustre/tests/echo_test.c | 283 - lustre/liblustre/tests/recovery_small.c | 390 - lustre/liblustre/tests/replay_ost_single.c | 338 - lustre/liblustre/tests/replay_single.c | 421 - lustre/liblustre/tests/sanity.c | 586 - lustre/liblustre/tests/test_common.c | 328 - lustre/liblustre/tests/test_common.h | 35 - lustre/liblustre/tests/test_lock_cancel.c | 194 - lustre/llite/.cvsignore | 15 - lustre/llite/Makefile.in | 10 - lustre/llite/Makefile.mk | 11 - lustre/llite/autoMakefile.am | 11 - lustre/llite/dcache.c | 497 - lustre/llite/dir.c | 745 - lustre/llite/file.c | 1566 -- lustre/llite/llite_close.c | 273 - lustre/llite/llite_gns.c | 419 - lustre/llite/llite_internal.h | 400 - lustre/llite/llite_lib.c | 1613 -- lustre/llite/llite_mmap.c | 489 - lustre/llite/llite_nfs.c | 180 - lustre/llite/lproc_llite.c | 860 - lustre/llite/namei.c | 906 - lustre/llite/rw.c | 1079 - lustre/llite/rw24.c | 156 - lustre/llite/rw26.c | 89 - lustre/llite/special.c | 399 - lustre/llite/super.c | 161 - lustre/llite/super25.c | 195 - lustre/llite/symlink.c | 162 - lustre/lmv/.cvsignore | 7 - lustre/lmv/Makefile.in | 4 - lustre/lmv/Makefile.mk | 9 - lustre/lmv/autoMakefile.am | 18 - lustre/lmv/lmv_intent.c | 759 - lustre/lmv/lmv_internal.h | 146 - lustre/lmv/lmv_obd.c | 2042 -- lustre/lmv/lmv_objmgr.c | 408 - lustre/lmv/lproc_lmv.c | 151 - lustre/lov/.cvsignore | 10 - lustre/lov/Makefile.in | 4 - lustre/lov/Makefile.mk | 9 - lustre/lov/autoMakefile.am | 18 - lustre/lov/lov_internal.h | 59 - lustre/lov/lov_log.c | 251 - lustre/lov/lov_obd.c | 3376 --- lustre/lov/lov_pack.c | 596 - lustre/lov/lproc_lov.c | 209 - lustre/lvfs/.cvsignore | 17 - lustre/lvfs/Makefile.in | 20 - lustre/lvfs/Makefile.mk | 5 - lustre/lvfs/autoMakefile.am | 49 - lustre/lvfs/fsfilt.c | 109 - lustre/lvfs/fsfilt_ext3.c | 1455 -- lustre/lvfs/fsfilt_reiserfs.c | 246 - lustre/lvfs/fsfilt_smfs.c | 1118 - lustre/lvfs/fsfilt_snap_ext3.c | 1769 -- lustre/lvfs/fsfilt_snap_smfs.c | 444 - lustre/lvfs/llog.c | 370 - lustre/lvfs/llog_cat.c | 652 - lustre/lvfs/llog_lvfs.c | 1150 -- lustre/lvfs/lvfs_common.c | 35 - lustre/lvfs/lvfs_internal.h | 14 - lustre/lvfs/lvfs_linux.c | 445 - lustre/lvfs/lvfs_reint.c | 553 - lustre/lvfs/lvfs_undo.c | 419 - lustre/lvfs/lvfs_userfs.c | 43 - lustre/mdc/.cvsignore | 15 - lustre/mdc/Makefile.in | 4 - lustre/mdc/Makefile.mk | 9 - lustre/mdc/autoMakefile.am | 18 - lustre/mdc/lproc_mdc.c | 54 - lustre/mdc/mdc_internal.h | 77 - lustre/mdc/mdc_lib.c | 152 - lustre/mdc/mdc_locks.c | 653 - lustre/mdc/mdc_reint.c | 269 - lustre/mdc/mdc_request.c | 1479 -- lustre/mds/.cvsignore | 15 - lustre/mds/Makefile.in | 5 - lustre/mds/Makefile.mk | 11 - lustre/mds/autoMakefile.am | 11 - lustre/mds/commit_confd.c | 76 - lustre/mds/handler.c | 3530 ---- lustre/mds/lproc_mds.c | 326 - lustre/mds/mds_fs.c | 989 - lustre/mds/mds_groups.c | 451 - lustre/mds/mds_internal.h | 254 - lustre/mds/mds_lib.c | 617 - lustre/mds/mds_lmv.c | 1249 -- lustre/mds/mds_log.c | 187 - lustre/mds/mds_lov.c | 931 - lustre/mds/mds_open.c | 1541 -- lustre/mds/mds_reint.c | 3416 ---- lustre/mds/mds_unlink_open.c | 266 - lustre/mgmt/.cvsignore | 12 - lustre/mgmt/Makefile.in | 9 - lustre/mgmt/autoMakefile.am | 9 - lustre/mgmt/mgmt_cli.c | 284 - lustre/mgmt/mgmt_svc.c | 172 - lustre/nodist | 21 - lustre/obdclass/.cvsignore | 15 - lustre/obdclass/Makefile.in | 15 - lustre/obdclass/Makefile.mk | 24 - lustre/obdclass/autoMakefile.am | 18 - lustre/obdclass/class_obd.c | 662 - lustre/obdclass/debug.c | 175 - lustre/obdclass/genops.c | 894 - lustre/obdclass/llog_ioctl.c | 421 - lustre/obdclass/llog_obd.c | 239 - lustre/obdclass/llog_test.c | 716 - lustre/obdclass/lprocfs_status.c | 1024 - lustre/obdclass/lustre_handles.c | 170 - lustre/obdclass/lustre_peer.c | 158 - lustre/obdclass/mea.c | 95 - lustre/obdclass/obd_config.c | 799 - lustre/obdclass/obdo.c | 346 - lustre/obdclass/statfs_pack.c | 72 - lustre/obdclass/sysctl.c | 114 - lustre/obdclass/uuid.c | 166 - lustre/obdecho/.cvsignore | 15 - lustre/obdecho/Makefile.in | 4 - lustre/obdecho/Makefile.mk | 9 - lustre/obdecho/autoMakefile.am | 18 - lustre/obdecho/echo.c | 641 - lustre/obdecho/echo_client.c | 1471 -- lustre/obdecho/lproc_echo.c | 43 - lustre/obdfilter/.cvsignore | 15 - lustre/obdfilter/Makefile.in | 11 - lustre/obdfilter/Makefile.mk | 11 - lustre/obdfilter/autoMakefile.am | 11 - lustre/obdfilter/filter.c | 3103 --- lustre/obdfilter/filter_internal.h | 191 - lustre/obdfilter/filter_io.c | 969 - lustre/obdfilter/filter_io_24.c | 444 - lustre/obdfilter/filter_io_26.c | 393 - lustre/obdfilter/filter_log.c | 187 - lustre/obdfilter/filter_lvb.c | 213 - lustre/obdfilter/filter_san.c | 124 - lustre/obdfilter/lproc_obdfilter.c | 390 - lustre/osc/.cvsignore | 15 - lustre/osc/Makefile.in | 4 - lustre/osc/Makefile.mk | 10 - lustre/osc/autoMakefile.am | 18 - lustre/osc/lproc_osc.c | 455 - lustre/osc/osc_create.c | 378 - lustre/osc/osc_internal.h | 65 - lustre/osc/osc_lib.c | 76 - lustre/osc/osc_request.c | 3213 --- lustre/ost/.cvsignore | 15 - lustre/ost/Makefile.in | 4 - lustre/ost/Makefile.mk | 9 - lustre/ost/autoMakefile.am | 11 - lustre/ost/lproc_ost.c | 138 - lustre/ost/ost_handler.c | 1379 -- lustre/ptlbd/.cvsignore | 9 - lustre/ptlbd/Makefile.in | 4 - lustre/ptlbd/autoMakefile.am | 13 - lustre/ptlbd/blk.c | 300 - lustre/ptlbd/client.c | 255 - lustre/ptlbd/main.c | 71 - lustre/ptlbd/rpc.c | 386 - lustre/ptlbd/server.c | 138 - lustre/ptlrpc/.cvsignore | 16 - lustre/ptlrpc/Makefile.in | 28 - lustre/ptlrpc/Makefile.mk | 18 - lustre/ptlrpc/autoMakefile.am | 37 - lustre/ptlrpc/client.c | 1682 -- lustre/ptlrpc/connection.c | 181 - lustre/ptlrpc/events.c | 665 - lustre/ptlrpc/import.c | 703 - lustre/ptlrpc/llog_client.c | 286 - lustre/ptlrpc/llog_net.c | 152 - lustre/ptlrpc/llog_server.c | 626 - lustre/ptlrpc/lproc_ptlrpc.c | 208 - lustre/ptlrpc/niobuf.c | 539 - lustre/ptlrpc/pack_generic.c | 840 - lustre/ptlrpc/pers.c | 132 - lustre/ptlrpc/pinger.c | 461 - lustre/ptlrpc/ptlrpc_internal.h | 121 - lustre/ptlrpc/ptlrpc_module.c | 237 - lustre/ptlrpc/ptlrpcd.c | 290 - lustre/ptlrpc/recov_thread.c | 604 - lustre/ptlrpc/recover.c | 418 - lustre/ptlrpc/service.c | 1043 - lustre/scripts/.cvsignore | 10 - lustre/scripts/Makefile.am | 14 - lustre/scripts/bdev-io-survey.sh | 882 - lustre/scripts/branch.sh | 44 - lustre/scripts/collect-stats.sh | 180 - lustre/scripts/cvs-modified-files.pl | 47 - lustre/scripts/cvsdiffclient | 45 - lustre/scripts/cvsrc | 5 - lustre/scripts/dodiff.sh | 5 - lustre/scripts/graph-rpcs.sh | 359 - lustre/scripts/land1.sh | 110 - lustre/scripts/land2.sh | 28 - lustre/scripts/lbuild | 475 - lustre/scripts/license-status | 26 - lustre/scripts/linux-merge-config.awk | 317 - lustre/scripts/linux-merge-modules.awk | 125 - lustre/scripts/linux-rhconfig.h | 229 - lustre/scripts/llite-group.sh | 67 - lustre/scripts/lmake | 562 - lustre/scripts/lustre | 95 - lustre/scripts/lustre-kernel-2.4.spec.in | 819 - lustre/scripts/lustre.spec.in | 239 - lustre/scripts/lustrefs | 84 - lustre/scripts/maketags.sh | 8 - lustre/scripts/merge1.sh | 92 - lustre/scripts/merge2.sh | 29 - lustre/scripts/nodelustre | 46 - lustre/scripts/system-profile.sh | 233 - lustre/scripts/version_tag.pl.in | 192 - lustre/smfs/.cvsignore | 15 - lustre/smfs/Makefile.in | 6 - lustre/smfs/autoMakefile.am | 9 - lustre/smfs/cache.c | 325 - lustre/smfs/cache_space.c | 744 - lustre/smfs/dir.c | 644 - lustre/smfs/file.c | 553 - lustre/smfs/inode.c | 394 - lustre/smfs/ioctl.c | 192 - lustre/smfs/journal.c | 544 - lustre/smfs/kml.c | 839 - lustre/smfs/mds_kml.c | 278 - lustre/smfs/options.c | 126 - lustre/smfs/ost_kml.c | 193 - lustre/smfs/smfs_cow.c | 1535 -- lustre/smfs/smfs_internal.h | 342 - lustre/smfs/smfs_lib.c | 486 - lustre/smfs/smfs_llog.c | 183 - lustre/smfs/super.c | 140 - lustre/smfs/symlink.c | 93 - lustre/smfs/sysctl.c | 111 - lustre/snapfs/.cvsignore | 14 - lustre/snapfs/Makefile.in | 6 - lustre/snapfs/autoMakefile.am | 14 - lustre/snapfs/cache.c | 106 - lustre/snapfs/clonefs.c | 592 - lustre/snapfs/dcache.c | 56 - lustre/snapfs/dir.c | 699 - lustre/snapfs/dotsnap.c | 190 - lustre/snapfs/file.c | 344 - lustre/snapfs/filter.c | 413 - lustre/snapfs/inode.c | 317 - lustre/snapfs/journal_ext3.c | 78 - lustre/snapfs/options.c | 97 - lustre/snapfs/psdev.c | 145 - lustre/snapfs/snap.c | 220 - lustre/snapfs/snapfs_internal.h | 440 - lustre/snapfs/snapfs_support.h | 156 - lustre/snapfs/snaptable.c | 968 - lustre/snapfs/super.c | 512 - lustre/snapfs/symlink.c | 206 - lustre/snapfs/sysctl.c | 91 - lustre/snapfs/utils/.cvsignore | 9 - lustre/snapfs/utils/Makefile.am | 8 - lustre/snapfs/utils/parser.c | 748 - lustre/snapfs/utils/parser.h | 74 - lustre/snapfs/utils/snapconf.c | 74 - lustre/snapfs/utils/snapctl.c | 408 - lustre/snapfs/utils/snapctl.h | 23 - lustre/tests/.RC_CURRENT.tag | 1 - lustre/tests/.cvsignore | 70 - lustre/tests/Makefile.am | 46 - lustre/tests/Makefile.mk | 53 - lustre/tests/README | 85 - lustre/tests/acceptance-metadata-double.sh | 128 - lustre/tests/acceptance-metadata-parallel.sh | 105 - lustre/tests/acceptance-metadata-single.sh | 153 - lustre/tests/acceptance-small.sh | 174 - lustre/tests/busy.sh | 7 - lustre/tests/cfg/insanity-adev.sh | 37 - lustre/tests/cfg/insanity-lmv.sh | 38 - lustre/tests/cfg/insanity-local.sh | 36 - lustre/tests/cfg/insanity-ltest.sh | 75 - lustre/tests/cfg/insanity-mdev.sh | 36 - lustre/tests/cfg/lmv.sh | 38 - lustre/tests/cfg/local.sh | 38 - lustre/tests/cfg/mdev.sh | 31 - lustre/tests/checkstack.pl | 83 - lustre/tests/checkstat.c | 336 - lustre/tests/cmknod.c | 131 - lustre/tests/cmobd.sh | 122 - lustre/tests/cmobd_cobd_cleanup.sh | 69 - lustre/tests/cmobd_setup.sh | 83 - lustre/tests/cobd.sh | 79 - lustre/tests/cobd_test.sh | 96 - lustre/tests/compile.sh | 16 - lustre/tests/conf-sanity.sh | 725 - lustre/tests/copy_attr.c | 56 - lustre/tests/crash-mod.sh | 11 - lustre/tests/create.pl | 178 - lustre/tests/createdestroy.c | 227 - lustre/tests/createmany-mpi.c | 143 - lustre/tests/createmany.c | 111 - lustre/tests/createtest.c | 142 - lustre/tests/directio.c | 203 - lustre/tests/echo.sh | 65 - lustre/tests/fchdir_test.c | 41 - lustre/tests/filter_survey.sh | 262 - lustre/tests/fsx.c | 1397 -- lustre/tests/getdents.c | 31 - lustre/tests/insanity.sh | 634 - lustre/tests/iopentest1.c | 101 - lustre/tests/iopentest2.c | 186 - lustre/tests/ldaptest.c | 27 - lustre/tests/leak_finder.pl | 89 - lustre/tests/lfsck_config.sh | 47 - lustre/tests/lfscktest.sh | 125 - lustre/tests/lfscktest_config.sh | 15 - lustre/tests/liblustre_sanity_uml.sh | 82 - lustre/tests/lkcdmap | 13 - lustre/tests/ll_dirstripe_verify.c | 201 - lustre/tests/ll_sparseness_verify.c | 102 - lustre/tests/ll_sparseness_write.c | 59 - lustre/tests/llecho.sh | 23 - lustre/tests/llechocleanup.sh | 15 - lustre/tests/llmount-upcall.sh | 6 - lustre/tests/llmount.sh | 36 - lustre/tests/llmountcleanup.sh | 55 - lustre/tests/llrmount.sh | 36 - lustre/tests/lmv.sh | 58 - lustre/tests/local-large-inode.sh | 3 - lustre/tests/local.sh | 66 - lustre/tests/lockorder.sh | 79 - lustre/tests/lov-sanity.sh | 89 - lustre/tests/lov.sh | 62 - lustre/tests/lp_utils.c | 265 - lustre/tests/lp_utils.h | 103 - lustre/tests/lsmfs.sh | 5 - lustre/tests/lsnap.sh | 5 - lustre/tests/lstiming.sh | 51 - lustre/tests/mcr-individual-ost-nogw-config.sh | 46 - lustre/tests/mcr-mds-failover-config.sh | 50 - lustre/tests/mcr-routed-config.sh | 93 - lustre/tests/mcr.sh | 45 - lustre/tests/mcreate.c | 23 - lustre/tests/mcrlov.sh | 52 - lustre/tests/mdsadd.sh | 81 - lustre/tests/memhog.c | 102 - lustre/tests/mkdirdeep.c | 258 - lustre/tests/mkdirmany.c | 40 - lustre/tests/mlink.c | 25 - lustre/tests/mmap_sanity.c | 650 - lustre/tests/mount2fs.sh | 44 - lustre/tests/mrename.c | 19 - lustre/tests/multifstat.c | 63 - lustre/tests/multiop.c | 245 - lustre/tests/munlink.c | 35 - lustre/tests/o_directory.c | 51 - lustre/tests/oos.sh | 83 - lustre/tests/oos2.sh | 83 - lustre/tests/open_delay.c | 23 - lustre/tests/openclose.c | 141 - lustre/tests/opendevunlink.c | 111 - lustre/tests/opendirunlink.c | 123 - lustre/tests/openfile.c | 159 - lustre/tests/openfilleddirunlink.c | 79 - lustre/tests/openme.c | 23 - lustre/tests/openunlink.c | 155 - lustre/tests/ost_oos.sh | 41 - lustre/tests/parallel_grouplock.c | 899 - lustre/tests/recovery-cleanup.sh | 145 - lustre/tests/recovery-small-upcall.sh | 4 - lustre/tests/recovery-small.sh | 379 - lustre/tests/rename.pl | 210 - lustre/tests/rename_many.c | 262 - lustre/tests/replay-dual.sh | 459 - lustre/tests/replay-ost-single.sh | 205 - lustre/tests/replay-ost-upcall.sh | 38 - lustre/tests/replay-sanity.sh | 248 - lustre/tests/replay-single-lmv.sh | 169 - lustre/tests/replay-single-upcall.sh | 56 - lustre/tests/replay-single.sh | 1016 - lustre/tests/rmdirmany.c | 40 - lustre/tests/run-llog.sh | 33 - lustre/tests/run_lfscktest.sh | 22 - lustre/tests/runas.c | 143 - lustre/tests/rundbench | 13 - lustre/tests/runfailure-mds | 63 - lustre/tests/runfailure-net | 66 - lustre/tests/runfailure-ost | 51 - lustre/tests/runiozone | 17 - lustre/tests/runobdstat | 7 - lustre/tests/runregression-brw.sh | 111 - lustre/tests/runregression-mds.sh | 67 - lustre/tests/runregression-net.sh | 99 - lustre/tests/runslabinfo | 6 - lustre/tests/runtests | 134 - lustre/tests/runvmstat | 18 - lustre/tests/sanity-buffalo.sh | 231 - lustre/tests/sanity-cmobd.sh | 308 - lustre/tests/sanity-fid.sh | 255 - lustre/tests/sanity-ldlm.sh | 61 - lustre/tests/sanity-lmv.sh | 357 - lustre/tests/sanity-sec.sh | 272 - lustre/tests/sanity.sh | 2233 -- lustre/tests/sanityN.sh | 374 - lustre/tests/set_dates.sh | 4 - lustre/tests/sleeptest.c | 115 - lustre/tests/small_write.c | 137 - lustre/tests/smfs.sh | 53 - lustre/tests/socketclient | 12 - lustre/tests/socketserver | 29 - lustre/tests/stat.c | 905 - lustre/tests/stat_fs.h | 37 - lustre/tests/statmany.c | 220 - lustre/tests/statone.c | 60 - lustre/tests/tbox.sh | 116 - lustre/tests/tchmod.c | 18 - lustre/tests/test-framework.sh | 615 - lustre/tests/test.c | 101 - lustre/tests/test2.c | 60 - lustre/tests/test_brw.c | 226 - lustre/tests/testreq.c | 141 - lustre/tests/tmpfs-sanity.sh | 149 - lustre/tests/toexcl.c | 77 - lustre/tests/truncate.c | 24 - lustre/tests/uml.sh | 117 - lustre/tests/uml_clone.sh | 80 - lustre/tests/unlinkmany.c | 74 - lustre/tests/upcall | 12 - lustre/tests/utime.c | 103 - lustre/tests/wantedi.c | 49 - lustre/tests/write_append_truncate.c | 286 - lustre/tests/write_disjoint.c | 172 - lustre/tests/writeme.c | 46 - lustre/utils/.cvsignore | 22 - lustre/utils/Lustre/.cvsignore | 4 - lustre/utils/Lustre/Makefile.am | 5 - lustre/utils/Lustre/__init__.py | 7 - lustre/utils/Lustre/cmdline.py | 194 - lustre/utils/Lustre/error.py | 10 - lustre/utils/Lustre/lustredb.py | 457 - lustre/utils/Makefile.am | 46 - lustre/utils/Makefile.mk | 17 - lustre/utils/automatic-reconnect-sample | 34 - lustre/utils/ha_assist.sh | 5 - lustre/utils/ha_assist2.sh | 35 - lustre/utils/l_getgroups.c | 122 - lustre/utils/lactive | 120 - lustre/utils/lconf | 3675 ---- lustre/utils/lctl.c | 357 - lustre/utils/lfind | 3 - lustre/utils/lfs.c | 438 - lustre/utils/liblustreapi.c | 811 - lustre/utils/llanalyze | 367 - lustre/utils/llmount.c | 635 - lustre/utils/llobdstat.pl | 160 - lustre/utils/llstat.pl | 124 - lustre/utils/lmc | 1717 -- lustre/utils/load_ldap.sh | 50 - lustre/utils/lrun | 13 - lustre/utils/lstripe | 3 - lustre/utils/lustre_cfg.c | 708 - lustre/utils/lwizard | 413 - lustre/utils/mds-failover-sample | 20 - lustre/utils/obd.c | 2495 --- lustre/utils/obdbarrier.c | 224 - lustre/utils/obdctl.c | 105 - lustre/utils/obdctl.h | 121 - lustre/utils/obdio.c | 297 - lustre/utils/obdiolib.c | 384 - lustre/utils/obdiolib.h | 71 - lustre/utils/parser.c | 748 - lustre/utils/parser.h | 74 - lustre/utils/wirecheck.c | 898 - lustre/utils/wirehdr.c | 24 - lustre/utils/wiretest.c | 27 - lustrecvs | 80 - 1096 files changed, 323896 deletions(-) delete mode 100644 .cvsignore delete mode 100644 COPYING delete mode 100644 ChangeLog delete mode 100644 README delete mode 100644 README.lustrecvs delete mode 100644 autoMakefile.am delete mode 100644 autogen.sh delete mode 100644 build/.cvsignore delete mode 100644 build/Makefile delete mode 100644 build/Makefile.in.toplevel delete mode 100644 build/Rules.in delete mode 100644 build/autoMakefile.am delete mode 100644 build/autoMakefile.am.toplevel delete mode 100644 build/autoconf/.cvsignore delete mode 100644 build/autoconf/Makefile.am delete mode 100644 build/autoconf/lustre-build-darwin.m4 delete mode 100644 build/autoconf/lustre-build-linux.m4 delete mode 100644 build/autoconf/lustre-build.m4 delete mode 100644 build/autogen.sh delete mode 100755 build/branch.sh delete mode 100644 build/buildcvs delete mode 100755 build/land1.sh delete mode 100755 build/land2.sh delete mode 100755 build/lbuild delete mode 100644 build/linux-merge-config.awk delete mode 100644 build/linux-merge-modules.awk delete mode 100644 build/linux-rhconfig.h delete mode 100755 build/lmake delete mode 100644 build/lustre-kernel-2.4.spec.in delete mode 100644 build/lustre.spec.in delete mode 100755 build/merge1.sh delete mode 100755 build/merge2.sh delete mode 100644 build/suse-functions.sh delete mode 100644 build/suse-post.sh delete mode 100644 build/suse-postun.sh delete mode 100644 build/suse-trigger-script.sh.in delete mode 100644 configure.ac delete mode 100644 ldiskfs/kernel_patches/patches/export-ext3-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/patches/export_symbols-ext3-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/patches/ext3-include-fixes-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/patches/ext3-map_inode_page-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/patches/ext3-san-jdike-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/patches/ext3-wantedi-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/patches/iopen-2.6-suse.patch delete mode 100644 ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series delete mode 100644 ldiskfs/ldiskfs/Makefile.in delete mode 100644 ldiskfs/ldiskfs/autoMakefile.am delete mode 100644 libsysio/AUTHORS delete mode 100644 libsysio/COPYING delete mode 100644 libsysio/ChangeLog delete mode 100644 libsysio/Makefile.am delete mode 100644 libsysio/NEWS delete mode 100644 libsysio/README delete mode 100644 libsysio/Rules.make delete mode 100755 libsysio/autogen.sh delete mode 100644 libsysio/configure.in delete mode 100644 libsysio/dev/stdfd/module.mk delete mode 100644 libsysio/dev/stdfd/stdfd.c delete mode 100644 libsysio/dev/stdfd/stdfd.h delete mode 100644 libsysio/drivers/incore/README delete mode 100644 libsysio/drivers/incore/fs_incore.c delete mode 100644 libsysio/drivers/incore/fs_incore.h delete mode 100644 libsysio/drivers/incore/module.mk delete mode 100644 libsysio/drivers/native/fs_native.c delete mode 100644 libsysio/drivers/native/fs_native.h delete mode 100644 libsysio/drivers/native/module.mk delete mode 100644 libsysio/drivers/sockets/module.mk delete mode 100644 libsysio/drivers/sockets/sockets.c delete mode 100644 libsysio/drivers/yod/fs_yod.c delete mode 100644 libsysio/drivers/yod/fs_yod.h delete mode 100644 libsysio/drivers/yod/module.mk delete mode 100644 libsysio/include/cplant-yod.h delete mode 100644 libsysio/include/dev.h delete mode 100644 libsysio/include/file.h delete mode 100644 libsysio/include/fs.h delete mode 100644 libsysio/include/inode.h delete mode 100644 libsysio/include/module.mk delete mode 100644 libsysio/include/mount.h delete mode 100644 libsysio/include/namespace.h delete mode 100644 libsysio/include/sysio-symbols.h delete mode 100644 libsysio/include/sysio.h delete mode 100644 libsysio/include/xtio.h delete mode 100644 libsysio/misc/gdb-libsysio delete mode 100644 libsysio/misc/init-env.sh delete mode 100644 libsysio/src/access.c delete mode 100644 libsysio/src/chdir.c delete mode 100644 libsysio/src/chmod.c delete mode 100644 libsysio/src/chown.c delete mode 100644 libsysio/src/dev.c delete mode 100644 libsysio/src/dup.c delete mode 100644 libsysio/src/fcntl.c delete mode 100644 libsysio/src/file.c delete mode 100644 libsysio/src/file_hack.c delete mode 100644 libsysio/src/fs.c delete mode 100644 libsysio/src/fsync.c delete mode 100644 libsysio/src/getdirentries.c delete mode 100644 libsysio/src/init.c delete mode 100644 libsysio/src/inode.c delete mode 100644 libsysio/src/ioctl.c delete mode 100644 libsysio/src/ioctx.c delete mode 100644 libsysio/src/iowait.c delete mode 100644 libsysio/src/link.c delete mode 100644 libsysio/src/lseek.c delete mode 100644 libsysio/src/mkdir.c delete mode 100644 libsysio/src/mknod.c delete mode 100644 libsysio/src/module.mk delete mode 100644 libsysio/src/mount.c delete mode 100644 libsysio/src/namei.c delete mode 100644 libsysio/src/open.c delete mode 100644 libsysio/src/readlink.c delete mode 100644 libsysio/src/rename.c delete mode 100644 libsysio/src/rmdir.c delete mode 100644 libsysio/src/rw.c delete mode 100644 libsysio/src/stat.c delete mode 100644 libsysio/src/stat64.c delete mode 100644 libsysio/src/statvfs.c delete mode 100644 libsysio/src/statvfs64.c delete mode 100644 libsysio/src/stdlib.c delete mode 100644 libsysio/src/symlink.c delete mode 100644 libsysio/src/truncate.c delete mode 100644 libsysio/src/unlink.c delete mode 100644 libsysio/src/utime.c delete mode 100644 libsysio/tests/Makefile.am delete mode 100644 libsysio/tests/README delete mode 100755 libsysio/tests/cleanup.pl delete mode 100644 libsysio/tests/drv_init_all.c delete mode 100644 libsysio/tests/gendrvdata.sh delete mode 100644 libsysio/tests/help.c delete mode 100644 libsysio/tests/helper.pm delete mode 100644 libsysio/tests/module.mk delete mode 100755 libsysio/tests/populator.pl delete mode 100755 libsysio/tests/setup.pl delete mode 100644 libsysio/tests/startup.c delete mode 100644 libsysio/tests/sysio_stubs.c delete mode 100644 libsysio/tests/sysio_tests.c delete mode 100644 libsysio/tests/test.h delete mode 100755 libsysio/tests/test_all.pl delete mode 100644 libsysio/tests/test_copy.bash delete mode 100644 libsysio/tests/test_copy.c delete mode 100755 libsysio/tests/test_copy.pl delete mode 100644 libsysio/tests/test_driver.c delete mode 100644 libsysio/tests/test_driver.h delete mode 100644 libsysio/tests/test_getcwd.c delete mode 100755 libsysio/tests/test_getcwd.pl delete mode 100644 libsysio/tests/test_link.c delete mode 100644 libsysio/tests/test_list.c delete mode 100755 libsysio/tests/test_list.pl delete mode 100644 libsysio/tests/test_path.c delete mode 100755 libsysio/tests/test_path.pl delete mode 100644 libsysio/tests/test_regions.c delete mode 100644 libsysio/tests/test_rename.c delete mode 100755 libsysio/tests/test_rw.pl delete mode 100644 libsysio/tests/test_stats.c delete mode 100755 libsysio/tests/test_stats.pl delete mode 100755 libsysio/tests/test_stdfd.pl delete mode 100755 libsysio/tests/test_strided.pl delete mode 100755 libsysio/tests/test_symlink.pl delete mode 100644 libsysio/tests/test_unlink.c delete mode 100755 libsysio/tests/verifier.pl delete mode 100644 lnet/.cvsignore delete mode 100644 lnet/AUTHORS delete mode 100644 lnet/ChangeLog delete mode 100644 lnet/Kernelenv.in delete mode 100644 lnet/Kernelenv.mk delete mode 100644 lnet/Makefile.in delete mode 100644 lnet/Makefile.mk delete mode 100644 lnet/NEWS delete mode 100644 lnet/README delete mode 100644 lnet/archdep.m4 delete mode 100644 lnet/autoMakefile.am delete mode 100644 lnet/autoconf/.cvsignore delete mode 100644 lnet/autoconf/Makefile.am delete mode 100644 lnet/autoconf/lustre-lnet.m4 delete mode 100644 lnet/autogen.sh delete mode 100644 lnet/build.m4 delete mode 100644 lnet/doc/.cvsignore delete mode 100644 lnet/doc/Data-structures delete mode 100644 lnet/doc/Makefile.am delete mode 100644 lnet/doc/Message-life-cycle delete mode 100644 lnet/doc/NAL-HOWTO delete mode 100644 lnet/doc/file.fig delete mode 100644 lnet/doc/flow_new.fig delete mode 100644 lnet/doc/get.fig delete mode 100644 lnet/doc/ieee.bst delete mode 100644 lnet/doc/mpi.fig delete mode 100644 lnet/doc/portals.fig delete mode 100644 lnet/doc/portals3.bib delete mode 100644 lnet/doc/portals3.lyx delete mode 100644 lnet/doc/put.fig delete mode 100644 lnet/include/.cvsignore delete mode 100644 lnet/include/Makefile.am delete mode 100644 lnet/include/cygwin-ioctl.h delete mode 100644 lnet/include/linux/.cvsignore delete mode 100644 lnet/include/linux/Makefile.am delete mode 100644 lnet/include/linux/kp30.h delete mode 100644 lnet/include/linux/kpr.h delete mode 100644 lnet/include/linux/libcfs.h delete mode 100644 lnet/include/linux/lustre_list.h delete mode 100644 lnet/include/linux/portals_compat25.h delete mode 100644 lnet/include/linux/portals_lib.h delete mode 100644 lnet/include/lnet/.cvsignore delete mode 100644 lnet/include/lnet/Makefile.am delete mode 100644 lnet/include/lnet/api-support.h delete mode 100644 lnet/include/lnet/api.h delete mode 100644 lnet/include/lnet/build_check.h delete mode 100644 lnet/include/lnet/errno.h delete mode 100644 lnet/include/lnet/internal.h delete mode 100644 lnet/include/lnet/lib-lnet.h delete mode 100644 lnet/include/lnet/lib-p30.h delete mode 100644 lnet/include/lnet/lib-types.h delete mode 100644 lnet/include/lnet/list.h delete mode 100644 lnet/include/lnet/lltrace.h delete mode 100644 lnet/include/lnet/lnet.h delete mode 100644 lnet/include/lnet/lnetctl.h delete mode 100644 lnet/include/lnet/myrnal.h delete mode 100644 lnet/include/lnet/nal.h delete mode 100644 lnet/include/lnet/nalids.h delete mode 100644 lnet/include/lnet/p30.h delete mode 100644 lnet/include/lnet/ptlctl.h delete mode 100644 lnet/include/lnet/socklnd.h delete mode 100644 lnet/include/lnet/stringtab.h delete mode 100644 lnet/include/lnet/types.h delete mode 100644 lnet/klnds/.cvsignore delete mode 100644 lnet/klnds/Makefile.in delete mode 100644 lnet/klnds/Makefile.mk delete mode 100644 lnet/klnds/autoMakefile.am delete mode 100644 lnet/klnds/gmlnd/.cvsignore delete mode 100644 lnet/klnds/gmlnd/Makefile.in delete mode 100644 lnet/klnds/gmlnd/Makefile.mk delete mode 100644 lnet/klnds/gmlnd/autoMakefile.am delete mode 100644 lnet/klnds/gmlnd/gmlnd.h delete mode 100644 lnet/klnds/gmlnd/gmlnd_api.c delete mode 100644 lnet/klnds/gmlnd/gmlnd_cb.c delete mode 100644 lnet/klnds/gmlnd/gmlnd_comm.c delete mode 100644 lnet/klnds/gmlnd/gmlnd_module.c delete mode 100644 lnet/klnds/gmlnd/gmlnd_utils.c delete mode 100644 lnet/klnds/iiblnd/.cvsignore delete mode 100644 lnet/klnds/iiblnd/Makefile.in delete mode 100644 lnet/klnds/iiblnd/Makefile.mk delete mode 100644 lnet/klnds/iiblnd/autoMakefile.am delete mode 100644 lnet/klnds/iiblnd/iiblnd.c delete mode 100644 lnet/klnds/iiblnd/iiblnd.h delete mode 100644 lnet/klnds/iiblnd/iiblnd_cb.c delete mode 100644 lnet/klnds/lolnd/.cvsignore delete mode 100644 lnet/klnds/lolnd/Makefile.in delete mode 100644 lnet/klnds/lolnd/autoMakefile.am delete mode 100644 lnet/klnds/lolnd/lolnd.c delete mode 100644 lnet/klnds/lolnd/lolnd.h delete mode 100644 lnet/klnds/lolnd/lolnd_cb.c delete mode 100644 lnet/klnds/openiblnd/.cvsignore delete mode 100644 lnet/klnds/openiblnd/Makefile.in delete mode 100644 lnet/klnds/openiblnd/Makefile.mk delete mode 100644 lnet/klnds/openiblnd/autoMakefile.am delete mode 100644 lnet/klnds/openiblnd/openiblnd.c delete mode 100644 lnet/klnds/openiblnd/openiblnd.h delete mode 100644 lnet/klnds/openiblnd/openiblnd_cb.c delete mode 100644 lnet/klnds/qswlnd/.cvsignore delete mode 100644 lnet/klnds/qswlnd/Makefile.in delete mode 100644 lnet/klnds/qswlnd/autoMakefile.am delete mode 100644 lnet/klnds/qswlnd/qswlnd.c delete mode 100644 lnet/klnds/qswlnd/qswlnd.h delete mode 100644 lnet/klnds/qswlnd/qswlnd_cb.c delete mode 100644 lnet/klnds/ralnd/.cvsignore delete mode 100644 lnet/klnds/ralnd/Makefile.in delete mode 100644 lnet/klnds/ralnd/autoMakefile.am delete mode 100644 lnet/klnds/ralnd/ralnd.c delete mode 100644 lnet/klnds/ralnd/ralnd.h delete mode 100644 lnet/klnds/ralnd/ralnd_cb.c delete mode 100644 lnet/klnds/socklnd/.cvsignore delete mode 100644 lnet/klnds/socklnd/Makefile.in delete mode 100644 lnet/klnds/socklnd/Makefile.mk delete mode 100644 lnet/klnds/socklnd/autoMakefile.am delete mode 100644 lnet/klnds/socklnd/socklnd.c delete mode 100644 lnet/klnds/socklnd/socklnd.h delete mode 100644 lnet/klnds/socklnd/socklnd_cb.c delete mode 100644 lnet/libcfs/.cvsignore delete mode 100644 lnet/libcfs/Makefile.in delete mode 100644 lnet/libcfs/Makefile.mk delete mode 100644 lnet/libcfs/autoMakefile.am delete mode 100644 lnet/libcfs/debug.c delete mode 100644 lnet/libcfs/lwt.c delete mode 100644 lnet/libcfs/module.c delete mode 100644 lnet/libcfs/proc.c delete mode 100644 lnet/libcfs/tracefile.c delete mode 100644 lnet/libcfs/tracefile.h delete mode 100644 lnet/libcfs/watchdog.c delete mode 100644 lnet/lnet/.cvsignore delete mode 100644 lnet/lnet/Makefile.in delete mode 100644 lnet/lnet/Makefile.mk delete mode 100644 lnet/lnet/api-errno.c delete mode 100644 lnet/lnet/api-ni.c delete mode 100644 lnet/lnet/api-wrap.c delete mode 100644 lnet/lnet/autoMakefile.am delete mode 100644 lnet/lnet/lib-eq.c delete mode 100644 lnet/lnet/lib-init.c delete mode 100644 lnet/lnet/lib-md.c delete mode 100644 lnet/lnet/lib-me.c delete mode 100644 lnet/lnet/lib-move.c delete mode 100644 lnet/lnet/lib-msg.c delete mode 100644 lnet/lnet/lib-ni.c delete mode 100644 lnet/lnet/lib-pid.c delete mode 100644 lnet/lnet/module.c delete mode 100644 lnet/packaging/.cvsignore delete mode 100644 lnet/packaging/Makefile.am delete mode 100644 lnet/packaging/portals.spec.in delete mode 100644 lnet/router/.cvsignore delete mode 100644 lnet/router/Makefile.in delete mode 100644 lnet/router/Makefile.mk delete mode 100644 lnet/router/autoMakefile.am delete mode 100644 lnet/router/proc.c delete mode 100644 lnet/router/router.c delete mode 100644 lnet/router/router.h delete mode 100644 lnet/tests/.cvsignore delete mode 100644 lnet/tests/Makefile.in delete mode 100644 lnet/tests/Makefile.mk delete mode 100644 lnet/tests/autoMakefile.am delete mode 100644 lnet/tests/ping.h delete mode 100644 lnet/tests/ping_cli.c delete mode 100644 lnet/tests/ping_srv.c delete mode 100644 lnet/tests/sping_cli.c delete mode 100644 lnet/tests/sping_srv.c delete mode 100644 lnet/tests/startclient.sh delete mode 100644 lnet/tests/startserver.sh delete mode 100644 lnet/tests/stopclient.sh delete mode 100644 lnet/tests/stopserver.sh delete mode 100644 lnet/ulnds/.cvsignore delete mode 100644 lnet/ulnds/Makefile.am delete mode 100644 lnet/ulnds/README delete mode 100644 lnet/ulnds/address.c delete mode 100644 lnet/ulnds/bridge.h delete mode 100644 lnet/ulnds/connection.c delete mode 100644 lnet/ulnds/connection.h delete mode 100644 lnet/ulnds/debug.c delete mode 100644 lnet/ulnds/dispatch.h delete mode 100644 lnet/ulnds/ipmap.h delete mode 100644 lnet/ulnds/pqtimer.c delete mode 100644 lnet/ulnds/pqtimer.h delete mode 100644 lnet/ulnds/procapi.c delete mode 100644 lnet/ulnds/procbridge.h delete mode 100644 lnet/ulnds/proclib.c delete mode 100644 lnet/ulnds/select.c delete mode 100644 lnet/ulnds/socklnd/Makefile.am delete mode 100644 lnet/ulnds/socklnd/README delete mode 100644 lnet/ulnds/socklnd/address.c delete mode 100644 lnet/ulnds/socklnd/bridge.h delete mode 100644 lnet/ulnds/socklnd/connection.c delete mode 100644 lnet/ulnds/socklnd/connection.h delete mode 100644 lnet/ulnds/socklnd/debug.c delete mode 100644 lnet/ulnds/socklnd/dispatch.h delete mode 100644 lnet/ulnds/socklnd/ipmap.h delete mode 100644 lnet/ulnds/socklnd/pqtimer.c delete mode 100644 lnet/ulnds/socklnd/pqtimer.h delete mode 100644 lnet/ulnds/socklnd/procapi.c delete mode 100644 lnet/ulnds/socklnd/procbridge.h delete mode 100644 lnet/ulnds/socklnd/proclib.c delete mode 100644 lnet/ulnds/socklnd/select.c delete mode 100644 lnet/ulnds/socklnd/table.c delete mode 100644 lnet/ulnds/socklnd/table.h delete mode 100644 lnet/ulnds/socklnd/tcplnd.c delete mode 100644 lnet/ulnds/socklnd/timer.h delete mode 100644 lnet/ulnds/socklnd/utypes.h delete mode 100644 lnet/ulnds/table.c delete mode 100644 lnet/ulnds/table.h delete mode 100644 lnet/ulnds/tcplnd.c delete mode 100644 lnet/ulnds/timer.h delete mode 100644 lnet/ulnds/utypes.h delete mode 100644 lnet/utils/.cvsignore delete mode 100644 lnet/utils/Makefile.am delete mode 100644 lnet/utils/Makefile.mk delete mode 100644 lnet/utils/acceptor.c delete mode 100644 lnet/utils/debug.c delete mode 100644 lnet/utils/debugctl.c delete mode 100644 lnet/utils/gmlndnid.c delete mode 100644 lnet/utils/l_ioctl.c delete mode 100644 lnet/utils/parser.c delete mode 100644 lnet/utils/parser.h delete mode 100644 lnet/utils/portals.c delete mode 100644 lnet/utils/ptlctl.c delete mode 100644 lnet/utils/routerstat.c delete mode 100644 lnet/utils/wirecheck.c delete mode 100644 lustre-iokit/ior-survey/README delete mode 100644 lustre-iokit/ior-survey/ior-survey delete mode 100644 lustre-iokit/obdfilter-survey/README delete mode 100755 lustre-iokit/obdfilter-survey/obdfilter-survey delete mode 100644 lustre-iokit/sgpdd-survey/README delete mode 100755 lustre-iokit/sgpdd-survey/sgpdd-survey delete mode 100644 lustre/.cvsignore delete mode 100644 lustre/BUGS delete mode 100644 lustre/BUILDING delete mode 100644 lustre/COPYING delete mode 100644 lustre/ChangeLog delete mode 100644 lustre/FDL delete mode 100644 lustre/Makefile.in delete mode 100644 lustre/Makefile.mk delete mode 100644 lustre/Rules.in delete mode 100644 lustre/autoMakefile.am delete mode 100644 lustre/autoconf/Makefile.am delete mode 100644 lustre/autoconf/lustre-core.m4 delete mode 100644 lustre/autoconf/lustre-version.ac delete mode 100644 lustre/cmobd/.cvsignore delete mode 100644 lustre/cmobd/Makefile.in delete mode 100644 lustre/cmobd/Makefile.mk delete mode 100644 lustre/cmobd/autoMakefile.am delete mode 100644 lustre/cmobd/cm_internal.h delete mode 100644 lustre/cmobd/cm_mds_reint.c delete mode 100644 lustre/cmobd/cm_obd.c delete mode 100644 lustre/cmobd/cm_oss_reint.c delete mode 100644 lustre/cmobd/cm_reint.c delete mode 100644 lustre/cmobd/cm_write.c delete mode 100644 lustre/cmobd/lproc_cm.c delete mode 100644 lustre/cobd/.cvsignore delete mode 100644 lustre/cobd/Makefile.in delete mode 100644 lustre/cobd/autoMakefile.am delete mode 100644 lustre/cobd/cache_obd.c delete mode 100644 lustre/cobd/lproc_cache.c delete mode 100644 lustre/conf/.cvsignore delete mode 100644 lustre/conf/lustre.dtd delete mode 100644 lustre/conf/lustre2ldif.xsl delete mode 100644 lustre/conf/modules.conf delete mode 100644 lustre/conf/slapd-lustre.conf delete mode 100644 lustre/conf/top.ldif delete mode 100644 lustre/doc/.cvsignore delete mode 100644 lustre/doc/Makefile.am delete mode 100644 lustre/doc/VERSIONING delete mode 100755 lustre/doc/chbar.sh delete mode 100644 lustre/doc/lconf.8 delete mode 100644 lustre/doc/lconf.lyx delete mode 100644 lustre/doc/lctl.8 delete mode 100644 lustre/doc/lctl.lyx delete mode 100644 lustre/doc/lfs.1 delete mode 100644 lustre/doc/lfs.lyx delete mode 100644 lustre/doc/lmc.1 delete mode 100644 lustre/doc/lmc.lyx delete mode 100644 lustre/doc/lwizard.1 delete mode 100755 lustre/doc/postbar delete mode 100755 lustre/doc/tex2pdf delete mode 100644 lustre/include/.cvsignore delete mode 100644 lustre/include/Makefile.am delete mode 100644 lustre/include/ioctl.h delete mode 100644 lustre/include/liblustre.h delete mode 100644 lustre/include/linux/.cvsignore delete mode 100644 lustre/include/linux/Makefile.am delete mode 100644 lustre/include/linux/lprocfs_status.h delete mode 100644 lustre/include/linux/lustre_cfg.h delete mode 100644 lustre/include/linux/lustre_cmobd.h delete mode 100644 lustre/include/linux/lustre_commit_confd.h delete mode 100644 lustre/include/linux/lustre_compat25.h delete mode 100644 lustre/include/linux/lustre_debug.h delete mode 100644 lustre/include/linux/lustre_dlm.h delete mode 100644 lustre/include/linux/lustre_export.h delete mode 100644 lustre/include/linux/lustre_fsfilt.h delete mode 100644 lustre/include/linux/lustre_ha.h delete mode 100644 lustre/include/linux/lustre_handles.h delete mode 100644 lustre/include/linux/lustre_idl.h delete mode 100644 lustre/include/linux/lustre_import.h delete mode 100644 lustre/include/linux/lustre_lib.h delete mode 100644 lustre/include/linux/lustre_lite.h delete mode 100644 lustre/include/linux/lustre_log.h delete mode 100644 lustre/include/linux/lustre_mds.h delete mode 100644 lustre/include/linux/lustre_mgmt.h delete mode 100644 lustre/include/linux/lustre_net.h delete mode 100644 lustre/include/linux/lustre_smfs.h delete mode 100644 lustre/include/linux/lustre_snap.h delete mode 100644 lustre/include/linux/lvfs.h delete mode 100644 lustre/include/linux/lvfs_linux.h delete mode 100644 lustre/include/linux/obd.h delete mode 100644 lustre/include/linux/obd_cache.h delete mode 100644 lustre/include/linux/obd_class.h delete mode 100644 lustre/include/linux/obd_echo.h delete mode 100644 lustre/include/linux/obd_lmv.h delete mode 100644 lustre/include/linux/obd_lov.h delete mode 100644 lustre/include/linux/obd_ost.h delete mode 100644 lustre/include/linux/obd_ptlbd.h delete mode 100644 lustre/include/linux/obd_support.h delete mode 100644 lustre/include/linux/obd_trace.h delete mode 100644 lustre/include/lustre/.cvsignore delete mode 100644 lustre/include/lustre/Makefile.am delete mode 100644 lustre/include/lustre/liblustreapi.h delete mode 100644 lustre/include/lustre/lustre_user.h delete mode 100644 lustre/kernel-tests/.cvsignore delete mode 100644 lustre/kernel-tests/Makefile delete mode 100644 lustre/kernel_patches/README delete mode 100644 lustre/kernel_patches/kernel_configs/config-linux-2.6.7-uml delete mode 100644 lustre/kernel_patches/kernel_configs/kgdb_2.6.0_test1_vmware.config delete mode 100644 lustre/kernel_patches/patches/dcache-fid-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/dcache-mds-num-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/dev_read_only-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/dynamic-locks-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/export-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/export-ext3-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/export-truncate-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/export_symbols-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/export_symbols-ext3-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/ext3-extents-2.6.7.patch delete mode 100755 lustre/kernel_patches/patches/ext3-extents-in-ea-2.6.7.patch delete mode 100755 lustre/kernel_patches/patches/ext3-extents-in-ea-exports-symbol-2.6.7.patch delete mode 100755 lustre/kernel_patches/patches/ext3-extents-in-ea-ioctl-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/ext3-fid-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/ext3-include-fixes-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/ext3-init-generation-2.6-suse.patch delete mode 100755 lustre/kernel_patches/patches/ext3-inode-reuse-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/ext3-map_inode_page-2.6-suse.patch delete mode 100755 lustre/kernel_patches/patches/ext3-mds-num-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/ext3-pdirops-2.6.7.patch delete mode 100755 lustre/kernel_patches/patches/ext3-reserve-inode-space-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/ext3-san-jdike-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/ext3-super-ntohl.patch delete mode 100644 lustre/kernel_patches/patches/ext3-wantedi-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/ext3-wantedi-misc-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/ext3-xattr-header-move-2.6.suse.patch delete mode 100644 lustre/kernel_patches/patches/header-guards-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/iopen-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/iopen-2.6-vanilla.patch delete mode 100644 lustre/kernel_patches/patches/iopen-misc-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/lookup_bdev_init_intent.patch delete mode 100644 lustre/kernel_patches/patches/lustre_version.patch delete mode 100644 lustre/kernel_patches/patches/md_path_lookup-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/nfs-cifs-intent-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/nfs-cifs-intent-2.6-vanilla.patch delete mode 100644 lustre/kernel_patches/patches/removepage-vanilla-2.6.5.patch delete mode 100644 lustre/kernel_patches/patches/revalide-special-oops-2.6.4.suse.patch delete mode 100644 lustre/kernel_patches/patches/uml-2.6.7-01-bb2.patch delete mode 100644 lustre/kernel_patches/patches/vfs-pdirops-2.6.7.patch delete mode 100644 lustre/kernel_patches/patches/vfs-wantedi-misc-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/vfs_intent-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/vfs_intent-2.6-vanilla.patch delete mode 100644 lustre/kernel_patches/patches/vfs_nointent-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/vfs_nointent-2.6-vanilla.patch delete mode 100644 lustre/kernel_patches/patches/vfs_races-2.6-suse.patch delete mode 100644 lustre/kernel_patches/patches/vfs_races-2.6-vanilla.patch delete mode 100755 lustre/kernel_patches/prepare_tree.sh delete mode 100755 lustre/kernel_patches/scripts/added-by-patch delete mode 100755 lustre/kernel_patches/scripts/apatch delete mode 100755 lustre/kernel_patches/scripts/cat-series delete mode 100755 lustre/kernel_patches/scripts/combine-applied delete mode 100755 lustre/kernel_patches/scripts/combine-series delete mode 100755 lustre/kernel_patches/scripts/cvs-take-patch delete mode 100755 lustre/kernel_patches/scripts/export_patch delete mode 100755 lustre/kernel_patches/scripts/extract_description delete mode 100755 lustre/kernel_patches/scripts/forkpatch delete mode 100755 lustre/kernel_patches/scripts/fpatch delete mode 100755 lustre/kernel_patches/scripts/import_patch delete mode 100755 lustre/kernel_patches/scripts/inpatch delete mode 100755 lustre/kernel_patches/scripts/join-patch delete mode 100755 lustre/kernel_patches/scripts/linus-patch delete mode 100755 lustre/kernel_patches/scripts/mpatch delete mode 100755 lustre/kernel_patches/scripts/new-kernel delete mode 100755 lustre/kernel_patches/scripts/p0-2-p1 delete mode 100755 lustre/kernel_patches/scripts/p_diff delete mode 100755 lustre/kernel_patches/scripts/patchdesc delete mode 100644 lustre/kernel_patches/scripts/patchfns delete mode 100755 lustre/kernel_patches/scripts/pcpatch delete mode 100755 lustre/kernel_patches/scripts/poppatch delete mode 100755 lustre/kernel_patches/scripts/prep-patch delete mode 100755 lustre/kernel_patches/scripts/pstatus delete mode 100755 lustre/kernel_patches/scripts/ptkdiff delete mode 100755 lustre/kernel_patches/scripts/pushpatch delete mode 100755 lustre/kernel_patches/scripts/refpatch delete mode 100755 lustre/kernel_patches/scripts/removed-by-patch delete mode 100755 lustre/kernel_patches/scripts/rename-patch delete mode 100755 lustre/kernel_patches/scripts/rolled-up-patch delete mode 100755 lustre/kernel_patches/scripts/rpatch delete mode 100755 lustre/kernel_patches/scripts/split-patch delete mode 100755 lustre/kernel_patches/scripts/sum-series delete mode 100755 lustre/kernel_patches/scripts/tag-series delete mode 100755 lustre/kernel_patches/scripts/toppatch delete mode 100755 lustre/kernel_patches/scripts/touched-by-patch delete mode 100755 lustre/kernel_patches/scripts/trypatch delete mode 100755 lustre/kernel_patches/scripts/unitdiff.py delete mode 100755 lustre/kernel_patches/scripts/unused-patches delete mode 100644 lustre/kernel_patches/series/2.6-suse.series delete mode 100644 lustre/kernel_patches/series/2.6-vanilla.series delete mode 100644 lustre/kernel_patches/series/ldiskfs-2.6-suse.series delete mode 100644 lustre/kernel_patches/series/ldiskfs-2.6-vanilla.series delete mode 100644 lustre/kernel_patches/targets/2.6-suse.target delete mode 100644 lustre/kernel_patches/targets/chaos-2.4.18.target delete mode 100644 lustre/kernel_patches/targets/hp_pnnl-2.4.target delete mode 100644 lustre/kernel_patches/targets/rh-2.4.target delete mode 100644 lustre/kernel_patches/targets/suse-2.4.21-2.target delete mode 100644 lustre/kernel_patches/txt/dev_read_only.txt delete mode 100644 lustre/kernel_patches/txt/exports.txt delete mode 100644 lustre/kernel_patches/txt/exports_hp.txt delete mode 100644 lustre/kernel_patches/txt/ext3-2.4.20-fixes.txt delete mode 100644 lustre/kernel_patches/txt/ext3-map_inode_page.txt delete mode 100644 lustre/kernel_patches/txt/ext3-map_inode_page_2.4.18.txt delete mode 100644 lustre/kernel_patches/txt/invalidate_show.txt delete mode 100644 lustre/kernel_patches/txt/kmem_cache_validate.txt delete mode 100644 lustre/kernel_patches/txt/lustre_version.txt delete mode 100644 lustre/kernel_patches/txt/uml_check_get_page.txt delete mode 100644 lustre/kernel_patches/txt/uml_no_panic.txt delete mode 100644 lustre/kernel_patches/which_patch delete mode 100644 lustre/ldiskfs/.cvsignore delete mode 100644 lustre/ldiskfs/Makefile.in delete mode 100644 lustre/ldiskfs/autoMakefile.am delete mode 100644 lustre/ldlm/.cvsignore delete mode 100644 lustre/ldlm/Makefile.am delete mode 100644 lustre/ldlm/Makefile.mk delete mode 100644 lustre/ldlm/l_lock.c delete mode 100644 lustre/ldlm/ldlm_extent.c delete mode 100644 lustre/ldlm/ldlm_flock.c delete mode 100644 lustre/ldlm/ldlm_inodebits.c delete mode 100644 lustre/ldlm/ldlm_internal.h delete mode 100644 lustre/ldlm/ldlm_lib.c delete mode 100644 lustre/ldlm/ldlm_lock.c delete mode 100644 lustre/ldlm/ldlm_lockd.c delete mode 100644 lustre/ldlm/ldlm_plain.c delete mode 100644 lustre/ldlm/ldlm_request.c delete mode 100644 lustre/ldlm/ldlm_resource.c delete mode 100644 lustre/ldlm/ldlm_test.c delete mode 100644 lustre/liblustre/.cvsignore delete mode 100644 lustre/liblustre/Makefile.am delete mode 100644 lustre/liblustre/dir.c delete mode 100644 lustre/liblustre/file.c delete mode 100755 lustre/liblustre/genlib.sh delete mode 100644 lustre/liblustre/llite_lib.c delete mode 100644 lustre/liblustre/llite_lib.h delete mode 100644 lustre/liblustre/lutil.c delete mode 100644 lustre/liblustre/lutil.h delete mode 100644 lustre/liblustre/namei.c delete mode 100644 lustre/liblustre/rw.c delete mode 100644 lustre/liblustre/super.c delete mode 100644 lustre/liblustre/tests/.cvsignore delete mode 100644 lustre/liblustre/tests/Makefile.am delete mode 100644 lustre/liblustre/tests/echo_test.c delete mode 100644 lustre/liblustre/tests/recovery_small.c delete mode 100644 lustre/liblustre/tests/replay_ost_single.c delete mode 100644 lustre/liblustre/tests/replay_single.c delete mode 100644 lustre/liblustre/tests/sanity.c delete mode 100644 lustre/liblustre/tests/test_common.c delete mode 100644 lustre/liblustre/tests/test_common.h delete mode 100644 lustre/liblustre/tests/test_lock_cancel.c delete mode 100644 lustre/llite/.cvsignore delete mode 100644 lustre/llite/Makefile.in delete mode 100644 lustre/llite/Makefile.mk delete mode 100644 lustre/llite/autoMakefile.am delete mode 100644 lustre/llite/dcache.c delete mode 100644 lustre/llite/dir.c delete mode 100644 lustre/llite/file.c delete mode 100644 lustre/llite/llite_close.c delete mode 100644 lustre/llite/llite_gns.c delete mode 100644 lustre/llite/llite_internal.h delete mode 100644 lustre/llite/llite_lib.c delete mode 100644 lustre/llite/llite_mmap.c delete mode 100644 lustre/llite/llite_nfs.c delete mode 100644 lustre/llite/lproc_llite.c delete mode 100644 lustre/llite/namei.c delete mode 100644 lustre/llite/rw.c delete mode 100644 lustre/llite/rw24.c delete mode 100644 lustre/llite/rw26.c delete mode 100644 lustre/llite/special.c delete mode 100644 lustre/llite/super.c delete mode 100644 lustre/llite/super25.c delete mode 100644 lustre/llite/symlink.c delete mode 100644 lustre/lmv/.cvsignore delete mode 100644 lustre/lmv/Makefile.in delete mode 100644 lustre/lmv/Makefile.mk delete mode 100644 lustre/lmv/autoMakefile.am delete mode 100644 lustre/lmv/lmv_intent.c delete mode 100644 lustre/lmv/lmv_internal.h delete mode 100644 lustre/lmv/lmv_obd.c delete mode 100644 lustre/lmv/lmv_objmgr.c delete mode 100644 lustre/lmv/lproc_lmv.c delete mode 100644 lustre/lov/.cvsignore delete mode 100644 lustre/lov/Makefile.in delete mode 100644 lustre/lov/Makefile.mk delete mode 100644 lustre/lov/autoMakefile.am delete mode 100644 lustre/lov/lov_internal.h delete mode 100644 lustre/lov/lov_log.c delete mode 100644 lustre/lov/lov_obd.c delete mode 100644 lustre/lov/lov_pack.c delete mode 100644 lustre/lov/lproc_lov.c delete mode 100644 lustre/lvfs/.cvsignore delete mode 100644 lustre/lvfs/Makefile.in delete mode 100644 lustre/lvfs/Makefile.mk delete mode 100644 lustre/lvfs/autoMakefile.am delete mode 100644 lustre/lvfs/fsfilt.c delete mode 100644 lustre/lvfs/fsfilt_ext3.c delete mode 100644 lustre/lvfs/fsfilt_reiserfs.c delete mode 100644 lustre/lvfs/fsfilt_smfs.c delete mode 100644 lustre/lvfs/fsfilt_snap_ext3.c delete mode 100644 lustre/lvfs/fsfilt_snap_smfs.c delete mode 100644 lustre/lvfs/llog.c delete mode 100644 lustre/lvfs/llog_cat.c delete mode 100644 lustre/lvfs/llog_lvfs.c delete mode 100644 lustre/lvfs/lvfs_common.c delete mode 100644 lustre/lvfs/lvfs_internal.h delete mode 100644 lustre/lvfs/lvfs_linux.c delete mode 100644 lustre/lvfs/lvfs_reint.c delete mode 100644 lustre/lvfs/lvfs_undo.c delete mode 100644 lustre/lvfs/lvfs_userfs.c delete mode 100644 lustre/mdc/.cvsignore delete mode 100644 lustre/mdc/Makefile.in delete mode 100644 lustre/mdc/Makefile.mk delete mode 100644 lustre/mdc/autoMakefile.am delete mode 100644 lustre/mdc/lproc_mdc.c delete mode 100644 lustre/mdc/mdc_internal.h delete mode 100644 lustre/mdc/mdc_lib.c delete mode 100644 lustre/mdc/mdc_locks.c delete mode 100644 lustre/mdc/mdc_reint.c delete mode 100644 lustre/mdc/mdc_request.c delete mode 100644 lustre/mds/.cvsignore delete mode 100644 lustre/mds/Makefile.in delete mode 100644 lustre/mds/Makefile.mk delete mode 100644 lustre/mds/autoMakefile.am delete mode 100644 lustre/mds/commit_confd.c delete mode 100644 lustre/mds/handler.c delete mode 100644 lustre/mds/lproc_mds.c delete mode 100644 lustre/mds/mds_fs.c delete mode 100644 lustre/mds/mds_groups.c delete mode 100644 lustre/mds/mds_internal.h delete mode 100644 lustre/mds/mds_lib.c delete mode 100644 lustre/mds/mds_lmv.c delete mode 100644 lustre/mds/mds_log.c delete mode 100644 lustre/mds/mds_lov.c delete mode 100644 lustre/mds/mds_open.c delete mode 100644 lustre/mds/mds_reint.c delete mode 100644 lustre/mds/mds_unlink_open.c delete mode 100644 lustre/mgmt/.cvsignore delete mode 100644 lustre/mgmt/Makefile.in delete mode 100644 lustre/mgmt/autoMakefile.am delete mode 100644 lustre/mgmt/mgmt_cli.c delete mode 100644 lustre/mgmt/mgmt_svc.c delete mode 100644 lustre/nodist delete mode 100644 lustre/obdclass/.cvsignore delete mode 100644 lustre/obdclass/Makefile.in delete mode 100644 lustre/obdclass/Makefile.mk delete mode 100644 lustre/obdclass/autoMakefile.am delete mode 100644 lustre/obdclass/class_obd.c delete mode 100644 lustre/obdclass/debug.c delete mode 100644 lustre/obdclass/genops.c delete mode 100644 lustre/obdclass/llog_ioctl.c delete mode 100644 lustre/obdclass/llog_obd.c delete mode 100644 lustre/obdclass/llog_test.c delete mode 100644 lustre/obdclass/lprocfs_status.c delete mode 100644 lustre/obdclass/lustre_handles.c delete mode 100644 lustre/obdclass/lustre_peer.c delete mode 100644 lustre/obdclass/mea.c delete mode 100644 lustre/obdclass/obd_config.c delete mode 100644 lustre/obdclass/obdo.c delete mode 100644 lustre/obdclass/statfs_pack.c delete mode 100644 lustre/obdclass/sysctl.c delete mode 100644 lustre/obdclass/uuid.c delete mode 100644 lustre/obdecho/.cvsignore delete mode 100644 lustre/obdecho/Makefile.in delete mode 100644 lustre/obdecho/Makefile.mk delete mode 100644 lustre/obdecho/autoMakefile.am delete mode 100644 lustre/obdecho/echo.c delete mode 100644 lustre/obdecho/echo_client.c delete mode 100644 lustre/obdecho/lproc_echo.c delete mode 100644 lustre/obdfilter/.cvsignore delete mode 100644 lustre/obdfilter/Makefile.in delete mode 100644 lustre/obdfilter/Makefile.mk delete mode 100644 lustre/obdfilter/autoMakefile.am delete mode 100644 lustre/obdfilter/filter.c delete mode 100644 lustre/obdfilter/filter_internal.h delete mode 100644 lustre/obdfilter/filter_io.c delete mode 100644 lustre/obdfilter/filter_io_24.c delete mode 100644 lustre/obdfilter/filter_io_26.c delete mode 100644 lustre/obdfilter/filter_log.c delete mode 100644 lustre/obdfilter/filter_lvb.c delete mode 100644 lustre/obdfilter/filter_san.c delete mode 100644 lustre/obdfilter/lproc_obdfilter.c delete mode 100644 lustre/osc/.cvsignore delete mode 100644 lustre/osc/Makefile.in delete mode 100644 lustre/osc/Makefile.mk delete mode 100644 lustre/osc/autoMakefile.am delete mode 100644 lustre/osc/lproc_osc.c delete mode 100644 lustre/osc/osc_create.c delete mode 100644 lustre/osc/osc_internal.h delete mode 100644 lustre/osc/osc_lib.c delete mode 100644 lustre/osc/osc_request.c delete mode 100644 lustre/ost/.cvsignore delete mode 100644 lustre/ost/Makefile.in delete mode 100644 lustre/ost/Makefile.mk delete mode 100644 lustre/ost/autoMakefile.am delete mode 100644 lustre/ost/lproc_ost.c delete mode 100644 lustre/ost/ost_handler.c delete mode 100644 lustre/ptlbd/.cvsignore delete mode 100644 lustre/ptlbd/Makefile.in delete mode 100644 lustre/ptlbd/autoMakefile.am delete mode 100644 lustre/ptlbd/blk.c delete mode 100644 lustre/ptlbd/client.c delete mode 100644 lustre/ptlbd/main.c delete mode 100644 lustre/ptlbd/rpc.c delete mode 100644 lustre/ptlbd/server.c delete mode 100644 lustre/ptlrpc/.cvsignore delete mode 100644 lustre/ptlrpc/Makefile.in delete mode 100644 lustre/ptlrpc/Makefile.mk delete mode 100644 lustre/ptlrpc/autoMakefile.am delete mode 100644 lustre/ptlrpc/client.c delete mode 100644 lustre/ptlrpc/connection.c delete mode 100644 lustre/ptlrpc/events.c delete mode 100644 lustre/ptlrpc/import.c delete mode 100644 lustre/ptlrpc/llog_client.c delete mode 100644 lustre/ptlrpc/llog_net.c delete mode 100644 lustre/ptlrpc/llog_server.c delete mode 100644 lustre/ptlrpc/lproc_ptlrpc.c delete mode 100644 lustre/ptlrpc/niobuf.c delete mode 100644 lustre/ptlrpc/pack_generic.c delete mode 100644 lustre/ptlrpc/pers.c delete mode 100644 lustre/ptlrpc/pinger.c delete mode 100644 lustre/ptlrpc/ptlrpc_internal.h delete mode 100644 lustre/ptlrpc/ptlrpc_module.c delete mode 100644 lustre/ptlrpc/ptlrpcd.c delete mode 100644 lustre/ptlrpc/recov_thread.c delete mode 100644 lustre/ptlrpc/recover.c delete mode 100644 lustre/ptlrpc/service.c delete mode 100644 lustre/scripts/.cvsignore delete mode 100644 lustre/scripts/Makefile.am delete mode 100755 lustre/scripts/bdev-io-survey.sh delete mode 100755 lustre/scripts/branch.sh delete mode 100644 lustre/scripts/collect-stats.sh delete mode 100755 lustre/scripts/cvs-modified-files.pl delete mode 100755 lustre/scripts/cvsdiffclient delete mode 100644 lustre/scripts/cvsrc delete mode 100755 lustre/scripts/dodiff.sh delete mode 100755 lustre/scripts/graph-rpcs.sh delete mode 100755 lustre/scripts/land1.sh delete mode 100755 lustre/scripts/land2.sh delete mode 100755 lustre/scripts/lbuild delete mode 100755 lustre/scripts/license-status delete mode 100644 lustre/scripts/linux-merge-config.awk delete mode 100644 lustre/scripts/linux-merge-modules.awk delete mode 100644 lustre/scripts/linux-rhconfig.h delete mode 100644 lustre/scripts/llite-group.sh delete mode 100755 lustre/scripts/lmake delete mode 100755 lustre/scripts/lustre delete mode 100644 lustre/scripts/lustre-kernel-2.4.spec.in delete mode 100644 lustre/scripts/lustre.spec.in delete mode 100644 lustre/scripts/lustrefs delete mode 100755 lustre/scripts/maketags.sh delete mode 100755 lustre/scripts/merge1.sh delete mode 100755 lustre/scripts/merge2.sh delete mode 100755 lustre/scripts/nodelustre delete mode 100755 lustre/scripts/system-profile.sh delete mode 100644 lustre/scripts/version_tag.pl.in delete mode 100644 lustre/smfs/.cvsignore delete mode 100644 lustre/smfs/Makefile.in delete mode 100644 lustre/smfs/autoMakefile.am delete mode 100644 lustre/smfs/cache.c delete mode 100644 lustre/smfs/cache_space.c delete mode 100644 lustre/smfs/dir.c delete mode 100644 lustre/smfs/file.c delete mode 100644 lustre/smfs/inode.c delete mode 100644 lustre/smfs/ioctl.c delete mode 100644 lustre/smfs/journal.c delete mode 100644 lustre/smfs/kml.c delete mode 100644 lustre/smfs/mds_kml.c delete mode 100644 lustre/smfs/options.c delete mode 100644 lustre/smfs/ost_kml.c delete mode 100644 lustre/smfs/smfs_cow.c delete mode 100644 lustre/smfs/smfs_internal.h delete mode 100644 lustre/smfs/smfs_lib.c delete mode 100644 lustre/smfs/smfs_llog.c delete mode 100644 lustre/smfs/super.c delete mode 100644 lustre/smfs/symlink.c delete mode 100644 lustre/smfs/sysctl.c delete mode 100644 lustre/snapfs/.cvsignore delete mode 100644 lustre/snapfs/Makefile.in delete mode 100644 lustre/snapfs/autoMakefile.am delete mode 100644 lustre/snapfs/cache.c delete mode 100644 lustre/snapfs/clonefs.c delete mode 100644 lustre/snapfs/dcache.c delete mode 100644 lustre/snapfs/dir.c delete mode 100644 lustre/snapfs/dotsnap.c delete mode 100644 lustre/snapfs/file.c delete mode 100644 lustre/snapfs/filter.c delete mode 100644 lustre/snapfs/inode.c delete mode 100644 lustre/snapfs/journal_ext3.c delete mode 100644 lustre/snapfs/options.c delete mode 100644 lustre/snapfs/psdev.c delete mode 100644 lustre/snapfs/snap.c delete mode 100644 lustre/snapfs/snapfs_internal.h delete mode 100644 lustre/snapfs/snapfs_support.h delete mode 100644 lustre/snapfs/snaptable.c delete mode 100644 lustre/snapfs/super.c delete mode 100644 lustre/snapfs/symlink.c delete mode 100644 lustre/snapfs/sysctl.c delete mode 100644 lustre/snapfs/utils/.cvsignore delete mode 100644 lustre/snapfs/utils/Makefile.am delete mode 100644 lustre/snapfs/utils/parser.c delete mode 100644 lustre/snapfs/utils/parser.h delete mode 100644 lustre/snapfs/utils/snapconf.c delete mode 100644 lustre/snapfs/utils/snapctl.c delete mode 100644 lustre/snapfs/utils/snapctl.h delete mode 100644 lustre/tests/.RC_CURRENT.tag delete mode 100644 lustre/tests/.cvsignore delete mode 100644 lustre/tests/Makefile.am delete mode 100644 lustre/tests/Makefile.mk delete mode 100644 lustre/tests/README delete mode 100644 lustre/tests/acceptance-metadata-double.sh delete mode 100644 lustre/tests/acceptance-metadata-parallel.sh delete mode 100644 lustre/tests/acceptance-metadata-single.sh delete mode 100755 lustre/tests/acceptance-small.sh delete mode 100644 lustre/tests/busy.sh delete mode 100644 lustre/tests/cfg/insanity-adev.sh delete mode 100644 lustre/tests/cfg/insanity-lmv.sh delete mode 100644 lustre/tests/cfg/insanity-local.sh delete mode 100644 lustre/tests/cfg/insanity-ltest.sh delete mode 100644 lustre/tests/cfg/insanity-mdev.sh delete mode 100644 lustre/tests/cfg/lmv.sh delete mode 100644 lustre/tests/cfg/local.sh delete mode 100644 lustre/tests/cfg/mdev.sh delete mode 100644 lustre/tests/checkstack.pl delete mode 100644 lustre/tests/checkstat.c delete mode 100644 lustre/tests/cmknod.c delete mode 100644 lustre/tests/cmobd.sh delete mode 100644 lustre/tests/cmobd_cobd_cleanup.sh delete mode 100644 lustre/tests/cmobd_setup.sh delete mode 100755 lustre/tests/cobd.sh delete mode 100644 lustre/tests/cobd_test.sh delete mode 100644 lustre/tests/compile.sh delete mode 100644 lustre/tests/conf-sanity.sh delete mode 100644 lustre/tests/copy_attr.c delete mode 100644 lustre/tests/crash-mod.sh delete mode 100644 lustre/tests/create.pl delete mode 100644 lustre/tests/createdestroy.c delete mode 100644 lustre/tests/createmany-mpi.c delete mode 100644 lustre/tests/createmany.c delete mode 100644 lustre/tests/createtest.c delete mode 100644 lustre/tests/directio.c delete mode 100755 lustre/tests/echo.sh delete mode 100644 lustre/tests/fchdir_test.c delete mode 100644 lustre/tests/filter_survey.sh delete mode 100644 lustre/tests/fsx.c delete mode 100644 lustre/tests/getdents.c delete mode 100755 lustre/tests/insanity.sh delete mode 100644 lustre/tests/iopentest1.c delete mode 100644 lustre/tests/iopentest2.c delete mode 100644 lustre/tests/ldaptest.c delete mode 100644 lustre/tests/leak_finder.pl delete mode 100755 lustre/tests/lfsck_config.sh delete mode 100755 lustre/tests/lfscktest.sh delete mode 100644 lustre/tests/lfscktest_config.sh delete mode 100644 lustre/tests/liblustre_sanity_uml.sh delete mode 100755 lustre/tests/lkcdmap delete mode 100644 lustre/tests/ll_dirstripe_verify.c delete mode 100644 lustre/tests/ll_sparseness_verify.c delete mode 100644 lustre/tests/ll_sparseness_write.c delete mode 100644 lustre/tests/llecho.sh delete mode 100755 lustre/tests/llechocleanup.sh delete mode 100755 lustre/tests/llmount-upcall.sh delete mode 100755 lustre/tests/llmount.sh delete mode 100755 lustre/tests/llmountcleanup.sh delete mode 100755 lustre/tests/llrmount.sh delete mode 100755 lustre/tests/lmv.sh delete mode 100755 lustre/tests/local-large-inode.sh delete mode 100755 lustre/tests/local.sh delete mode 100644 lustre/tests/lockorder.sh delete mode 100644 lustre/tests/lov-sanity.sh delete mode 100755 lustre/tests/lov.sh delete mode 100644 lustre/tests/lp_utils.c delete mode 100644 lustre/tests/lp_utils.h delete mode 100755 lustre/tests/lsmfs.sh delete mode 100755 lustre/tests/lsnap.sh delete mode 100644 lustre/tests/lstiming.sh delete mode 100755 lustre/tests/mcr-individual-ost-nogw-config.sh delete mode 100755 lustre/tests/mcr-mds-failover-config.sh delete mode 100755 lustre/tests/mcr-routed-config.sh delete mode 100755 lustre/tests/mcr.sh delete mode 100644 lustre/tests/mcreate.c delete mode 100755 lustre/tests/mcrlov.sh delete mode 100755 lustre/tests/mdsadd.sh delete mode 100644 lustre/tests/memhog.c delete mode 100644 lustre/tests/mkdirdeep.c delete mode 100755 lustre/tests/mkdirmany.c delete mode 100755 lustre/tests/mlink.c delete mode 100644 lustre/tests/mmap_sanity.c delete mode 100644 lustre/tests/mount2fs.sh delete mode 100644 lustre/tests/mrename.c delete mode 100644 lustre/tests/multifstat.c delete mode 100755 lustre/tests/multiop.c delete mode 100755 lustre/tests/munlink.c delete mode 100644 lustre/tests/o_directory.c delete mode 100755 lustre/tests/oos.sh delete mode 100644 lustre/tests/oos2.sh delete mode 100644 lustre/tests/open_delay.c delete mode 100644 lustre/tests/openclose.c delete mode 100644 lustre/tests/opendevunlink.c delete mode 100644 lustre/tests/opendirunlink.c delete mode 100644 lustre/tests/openfile.c delete mode 100644 lustre/tests/openfilleddirunlink.c delete mode 100644 lustre/tests/openme.c delete mode 100644 lustre/tests/openunlink.c delete mode 100644 lustre/tests/ost_oos.sh delete mode 100644 lustre/tests/parallel_grouplock.c delete mode 100755 lustre/tests/recovery-cleanup.sh delete mode 100755 lustre/tests/recovery-small-upcall.sh delete mode 100755 lustre/tests/recovery-small.sh delete mode 100644 lustre/tests/rename.pl delete mode 100644 lustre/tests/rename_many.c delete mode 100755 lustre/tests/replay-dual.sh delete mode 100755 lustre/tests/replay-ost-single.sh delete mode 100755 lustre/tests/replay-ost-upcall.sh delete mode 100755 lustre/tests/replay-sanity.sh delete mode 100755 lustre/tests/replay-single-lmv.sh delete mode 100755 lustre/tests/replay-single-upcall.sh delete mode 100755 lustre/tests/replay-single.sh delete mode 100755 lustre/tests/rmdirmany.c delete mode 100644 lustre/tests/run-llog.sh delete mode 100755 lustre/tests/run_lfscktest.sh delete mode 100644 lustre/tests/runas.c delete mode 100755 lustre/tests/rundbench delete mode 100755 lustre/tests/runfailure-mds delete mode 100755 lustre/tests/runfailure-net delete mode 100755 lustre/tests/runfailure-ost delete mode 100755 lustre/tests/runiozone delete mode 100644 lustre/tests/runobdstat delete mode 100644 lustre/tests/runregression-brw.sh delete mode 100755 lustre/tests/runregression-mds.sh delete mode 100644 lustre/tests/runregression-net.sh delete mode 100755 lustre/tests/runslabinfo delete mode 100755 lustre/tests/runtests delete mode 100755 lustre/tests/runvmstat delete mode 100755 lustre/tests/sanity-buffalo.sh delete mode 100644 lustre/tests/sanity-cmobd.sh delete mode 100644 lustre/tests/sanity-fid.sh delete mode 100644 lustre/tests/sanity-ldlm.sh delete mode 100644 lustre/tests/sanity-lmv.sh delete mode 100644 lustre/tests/sanity-sec.sh delete mode 100644 lustre/tests/sanity.sh delete mode 100644 lustre/tests/sanityN.sh delete mode 100644 lustre/tests/set_dates.sh delete mode 100644 lustre/tests/sleeptest.c delete mode 100644 lustre/tests/small_write.c delete mode 100755 lustre/tests/smfs.sh delete mode 100755 lustre/tests/socketclient delete mode 100755 lustre/tests/socketserver delete mode 100644 lustre/tests/stat.c delete mode 100644 lustre/tests/stat_fs.h delete mode 100644 lustre/tests/statmany.c delete mode 100644 lustre/tests/statone.c delete mode 100644 lustre/tests/tbox.sh delete mode 100644 lustre/tests/tchmod.c delete mode 100644 lustre/tests/test-framework.sh delete mode 100755 lustre/tests/test.c delete mode 100755 lustre/tests/test2.c delete mode 100644 lustre/tests/test_brw.c delete mode 100644 lustre/tests/testreq.c delete mode 100755 lustre/tests/tmpfs-sanity.sh delete mode 100644 lustre/tests/toexcl.c delete mode 100644 lustre/tests/truncate.c delete mode 100644 lustre/tests/uml.sh delete mode 100644 lustre/tests/uml_clone.sh delete mode 100644 lustre/tests/unlinkmany.c delete mode 100755 lustre/tests/upcall delete mode 100644 lustre/tests/utime.c delete mode 100644 lustre/tests/wantedi.c delete mode 100644 lustre/tests/write_append_truncate.c delete mode 100644 lustre/tests/write_disjoint.c delete mode 100644 lustre/tests/writeme.c delete mode 100644 lustre/utils/.cvsignore delete mode 100644 lustre/utils/Lustre/.cvsignore delete mode 100644 lustre/utils/Lustre/Makefile.am delete mode 100644 lustre/utils/Lustre/__init__.py delete mode 100644 lustre/utils/Lustre/cmdline.py delete mode 100644 lustre/utils/Lustre/error.py delete mode 100644 lustre/utils/Lustre/lustredb.py delete mode 100644 lustre/utils/Makefile.am delete mode 100644 lustre/utils/Makefile.mk delete mode 100755 lustre/utils/automatic-reconnect-sample delete mode 100755 lustre/utils/ha_assist.sh delete mode 100755 lustre/utils/ha_assist2.sh delete mode 100644 lustre/utils/l_getgroups.c delete mode 100644 lustre/utils/lactive delete mode 100755 lustre/utils/lconf delete mode 100644 lustre/utils/lctl.c delete mode 100755 lustre/utils/lfind delete mode 100644 lustre/utils/lfs.c delete mode 100644 lustre/utils/liblustreapi.c delete mode 100644 lustre/utils/llanalyze delete mode 100644 lustre/utils/llmount.c delete mode 100755 lustre/utils/llobdstat.pl delete mode 100755 lustre/utils/llstat.pl delete mode 100755 lustre/utils/lmc delete mode 100755 lustre/utils/load_ldap.sh delete mode 100755 lustre/utils/lrun delete mode 100755 lustre/utils/lstripe delete mode 100644 lustre/utils/lustre_cfg.c delete mode 100755 lustre/utils/lwizard delete mode 100755 lustre/utils/mds-failover-sample delete mode 100644 lustre/utils/obd.c delete mode 100644 lustre/utils/obdbarrier.c delete mode 100644 lustre/utils/obdctl.c delete mode 100644 lustre/utils/obdctl.h delete mode 100644 lustre/utils/obdio.c delete mode 100644 lustre/utils/obdiolib.c delete mode 100644 lustre/utils/obdiolib.h delete mode 100644 lustre/utils/parser.c delete mode 100644 lustre/utils/parser.h delete mode 100644 lustre/utils/wirecheck.c delete mode 100644 lustre/utils/wirehdr.c delete mode 100644 lustre/utils/wiretest.c delete mode 100755 lustrecvs diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 386b60d..0000000 --- a/.cvsignore +++ /dev/null @@ -1,33 +0,0 @@ -.Xrefs -.Xrefs-2.5 -aclocal.m4 -config.log -config.status -config.cache -config.guess -config.sub -configure -Makefile -autoMakefile -autoMakefile.in -.deps -tags -TAGS -lustre*.tar.gz -cscope.files -cscope.out -autom4te-2.53.cache -autom4te.cache -depcomp -compile -.*.cmd -.mergeinfo-* -Rules -missing -mkinstalldirs -install-sh -.depend -.tmp_versions -config.h -config.h.in -stamp-h1 diff --git a/COPYING b/COPYING deleted file mode 100644 index c69cfd8..0000000 --- a/COPYING +++ /dev/null @@ -1,352 +0,0 @@ - - NOTE! This copyright does *not* cover user programs that use kernel - services by normal system calls - this is merely considered normal use - of the kernel, and does *not* fall under the heading of "derived work". - Also note that the GPL below is copyrighted by the Free Software - Foundation, but the instance of code that it refers to (the Linux - kernel) is copyrighted by me and others who actually wrote it. - - Linus Torvalds - ----------------------------------------- - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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 for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e50f1e3..0000000 --- a/ChangeLog +++ /dev/null @@ -1 +0,0 @@ -Please see portals/ChangeLog and lustre/ChangeLog. diff --git a/README b/README deleted file mode 100644 index c052124..0000000 --- a/README +++ /dev/null @@ -1,2 +0,0 @@ -Instructions for building, configuring and running Lustre can be found at: - http://projects.clusterfs.com/lustre/LustreHowto. diff --git a/README.lustrecvs b/README.lustrecvs deleted file mode 100644 index 88dcc12..0000000 --- a/README.lustrecvs +++ /dev/null @@ -1,5 +0,0 @@ -To check out Lustre: - -./lustrecvs co - -For a list of branches, please see the branch table in lustrecvs. diff --git a/autoMakefile.am b/autoMakefile.am deleted file mode 100644 index d9e18a8..0000000 --- a/autoMakefile.am +++ /dev/null @@ -1 +0,0 @@ -include build/autoMakefile.am.toplevel diff --git a/autogen.sh b/autogen.sh deleted file mode 100644 index 3920385..0000000 --- a/autogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec sh build/autogen.sh $@ diff --git a/build/.cvsignore b/build/.cvsignore deleted file mode 100644 index dfc9da2..0000000 --- a/build/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -.*.cmd -.*.flags -*.ko -*.c -.tmp_versions -Rules -autoMakefile.in -autoMakefile -lustre.spec diff --git a/build/Makefile b/build/Makefile deleted file mode 100644 index d13bbb7..0000000 --- a/build/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# -# There are three ways this Makefile can be called: -# -# -# 1. As a subdirectory from the toplevel, for automake -# -# 2. A wrapper around the kernel's makefile when building modules, to -# possibly override the .config file -# -# 3. At configure time, as the toplevel module dir for building -# kernel tests -# - -ifeq ($(PATCHLEVEL),) - -ifeq ($(LUSTRE_LINUX_CONFIG),) - -# case #1 -include autoMakefile - -else - -# case #2 -# Note that this comes from make -C $LINUX -f $LUSTRE/build/Makefile -# So the include Makefile includes $LINUX/Makefile, not this file -include $(LUSTRE_LINUX_CONFIG) -include Makefile - -endif # LUSTRE_LINUX_CONFIG - -else # PATCHLEVEL - -# case 3 - -ifneq ($(LUSTRE_KERNEL_TEST),) -ifeq ($(PATCHLEVEL),4) -all: $(LUSTRE_KERNEL_TEST) -else -extra-y = $(LUSTRE_KERNEL_TEST) -endif -endif - -obj-m := conftest.o - -ifeq ($(PATCHLEVEL),4) -include $(TOPDIR)/Rules.make -endif - -endif # PATCHLEVEL diff --git a/build/Makefile.in.toplevel b/build/Makefile.in.toplevel deleted file mode 100644 index 7440384..0000000 --- a/build/Makefile.in.toplevel +++ /dev/null @@ -1,4 +0,0 @@ -subdir-m += portals -subdir-m += lustre - -@INCLUDE_RULES@ diff --git a/build/Rules.in b/build/Rules.in deleted file mode 100644 index 293ff3c..0000000 --- a/build/Rules.in +++ /dev/null @@ -1,46 +0,0 @@ -# Directories building kernel modules should have two files: -# -# Makefile.in: -# -# MODULES := -# -objs := file1.o file2.o file3.o -# @INCLUDE_RULES@ -# -# and autoMakefile.am: -# -# if LIBLUSTRE -# -# endif -# -# if MODULES -# modulefs_DATA = $(KMODEXT) -# endif -# -# DIST_SOURCES = $(-objs:.o=.c) -# MOSTLYCLEANFILES = *.o *.ko *.mod.c - -ifeq ($(PATCHLEVEL),) - -include autoMakefile - -else - -include @LINUX_CONFIG@ - -EXTRA_CFLAGS := $(EXTRA_PRE_CFLAGS) -EXTRA_CFLAGS += @EXTRA_KCFLAGS@ @UML_CFLAGS@ -EXTRA_CFLAGS += $(EXTRA_POST_CFLAGS) - -obj-m := $(patsubst %,%.o,$(MODULES)) - -ifeq ($(PATCHLEVEL),4) -# 2.4 rules -O_TARGET := $(firstword $(obj-m)) -obj-y := $($(firstword $(MODULES))-objs) -export-objs := $(obj-y) $(filter-out $(O_TARGET),$(obj-m)) -include $(TOPDIR)/Rules.make -$(MODINCL)/%.ver: %.c - @true -endif # PATCHLEVEL - -endif # KERNELRELEASE diff --git a/build/autoMakefile.am b/build/autoMakefile.am deleted file mode 100644 index 95994a4..0000000 --- a/build/autoMakefile.am +++ /dev/null @@ -1,8 +0,0 @@ -EXTRA_DIST := Makefile Makefile.in.toplevel autoMakefile.am.toplevel \ - lbuild linux-merge-config.awk \ - linux-merge-modules.awk linux-rhconfig.h lmake \ - lustre-kernel-2.4.spec.in lustre.spec lustre.spec \ - suse-functions.sh suse-post.sh suse-postun.sh \ - suse-trigger-script.sh.in - -SUBDIRS := autoconf diff --git a/build/autoMakefile.am.toplevel b/build/autoMakefile.am.toplevel deleted file mode 100644 index 7bb6337..0000000 --- a/build/autoMakefile.am.toplevel +++ /dev/null @@ -1,60 +0,0 @@ -SUBDIRS := . build @LIBSYSIO_SUBDIR@ portals lustre -DIST_SUBDIRS := build @LIBSYSIO_SUBDIR@ portals lustre - -EXTRA_DIST := config.h.in - -# these empty rules are needed so that automake doesn't add its own -# recursive rules -etags-recursive: - -ctags-recursive: - -tags-recursive: - -TAGS: - -tags: - rm -f $(top_srcdir)/TAGS - ETAGSF=`etags --version | grep -iq exuberant && \ - echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \ - find $(top_srcdir) -name '*.[hc]' | xargs etags $$ETAGSF -a - - rm -f $(top_srcdir)/tags - CTAGSF=`ctags --version | grep -iq exuberant && \ - echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \ - find $(top_srcdir) -name '*.[hc]' | xargs ctags $$CTAGSF -a - -if MODULES -all-am: modules - -all-sources: - $(MAKE) sources -C portals - $(MAKE) sources -C lustre - -if !LINUX25 -DEP = dep -dep: .depend - -.depend: all-sources - $(MAKE) $(ARCH_UM) CC="$(CC)" -C $(LINUX_OBJ) \ - -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \ - -o scripts -o include/config/MARKER _sfdep_$(PWD) \ - _FASTDEP_ALL_SUB_DIRS="$(PWD)" - -CLEANFILES = .depend -endif - -modules: $(DEP) all-sources - $(MAKE) $(ARCH_UM) CC="$(CC)" -C $(LINUX_OBJ) \ - -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \ - $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \ - include/config/MARKER $@ - -endif # MODULES - -dist-hook: - find $(distdir) -name .deps | xargs rm -rf - find $(distdir) -name CVS | xargs rm -rf - -rpms: dist Makefile - rpmbuild -ta $(distdir).tar.gz diff --git a/build/autoconf/.cvsignore b/build/autoconf/.cvsignore deleted file mode 100644 index 282522d..0000000 --- a/build/autoconf/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/build/autoconf/Makefile.am b/build/autoconf/Makefile.am deleted file mode 100644 index 23729e7..0000000 --- a/build/autoconf/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -EXTRA_DIST := lustre-build.m4 lustre-build-darwin.m4 lustre-build-linux.m4 - diff --git a/build/autoconf/lustre-build-darwin.m4 b/build/autoconf/lustre-build-darwin.m4 deleted file mode 100644 index cd1704a..0000000 --- a/build/autoconf/lustre-build-darwin.m4 +++ /dev/null @@ -1,34 +0,0 @@ -# -# 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" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -x c -arch ppc -pipe -Wno-trigraphs" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fasm-blocks -g -O0 -mtune=G4" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-four-char-constants -Wmost -O0" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fmessage-length=0 -ffix-and-continue" -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 -mlong-branch" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DKERNEL -DKERNEL_PRIVATE" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DDRIVER_PRIVATE -DAPPLE -DNeXT" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -D__KERNEL__ -D__DARWIN__" -EXTRA_KLDFLAGS="-arch ppc -static -nostdlib -r" -EXTRA_KLIBS="-lkmodc++ -lkmod -lcc_kext" -KMODEXT="" -]) diff --git a/build/autoconf/lustre-build-linux.m4 b/build/autoconf/lustre-build-linux.m4 deleted file mode 100644 index 9320139..0000000 --- a/build/autoconf/lustre-build-linux.m4 +++ /dev/null @@ -1,318 +0,0 @@ -# -# LB_LINUX_VERSION -# -# Set things accordingly for a 2.5 kernel -# -AC_DEFUN([LB_LINUX_VERSION], -[AC_CHECK_FILE([$LINUX/include/linux/namei.h], - [ - linux25="yes" - KMODEXT=".ko" - ],[ - KMODEXT=".o" - linux25="no" - ]) -AC_MSG_CHECKING([if you are using Linux 2.6]) -AC_MSG_RESULT([$linux25]) - -MODULE_TARGET="SUBDIRS" -if test $linux25 = "yes" ; then - makerule="$PWD/build" - AC_MSG_CHECKING([for external module build support]) - rm -f build/conftest.i - LB_LINUX_TRY_MAKE([],[], - [$makerule LUSTRE_KERNEL_TEST=conftest.i], - [test -s build/conftest.i], - [ - AC_MSG_RESULT([no]) - ],[ - AC_MSG_RESULT([yes]) - makerule="_module_$makerule" - MODULE_TARGET="M" - ]) - -else - makerule="_dir_$PWD/build" -fi - -AC_SUBST(MODULE_TARGET) -AC_SUBST(LINUX25) -AC_SUBST(KMODEXT) -]) - -# -# LB_LINUX_RELEASE -# -# get the release version of linux -# -AC_DEFUN([LB_LINUX_RELEASE], -[LINUXRELEASE= -rm -f build/conftest.i -AC_MSG_CHECKING([for Linux release]) -LB_LINUX_TRY_MAKE([ - #include -],[ - char *LINUXRELEASE; - LINUXRELEASE=UTS_RELEASE; -],[ - $makerule LUSTRE_KERNEL_TEST=conftest.i -],[ - test -s build/conftest.i -],[ - # LINUXRELEASE="UTS_RELEASE" - eval $(grep "LINUXRELEASE=" build/conftest.i) -],[ - AC_MSG_RESULT([unknown]) - AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.]) -]) -rm -f build/conftest.i -if test x$LINUXRELEASE = x ; then - AC_MSG_RESULT([unknown]) - AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.]) -fi -AC_MSG_RESULT([$LINUXRELEASE]) -AC_SUBST(LINUXRELEASE) - -moduledir='/lib/modules/'$LINUXRELEASE/kernel -AC_SUBST(moduledir) - -modulefsdir='$(moduledir)/fs/$(PACKAGE)' -AC_SUBST(modulefsdir) - -modulenetdir='$(moduledir)/net/$(PACKAGE)' -AC_SUBST(modulenetdir) - -# ------------ RELEASE -------------------------------- -AC_MSG_CHECKING([for Lustre release]) -RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`" -AC_MSG_RESULT($RELEASE) -AC_SUBST(RELEASE) -]) - -# -# LB_LINUX_PATH -# -# Find paths for linux, handling kernel-source rpms -# -AC_DEFUN([LB_LINUX_PATH], -[AC_MSG_CHECKING([for Linux sources]) -AC_ARG_WITH([linux], - AC_HELP_STRING([--with-linux=path], - [set path to Linux source (default=/usr/src/linux)]), - [LINUX=$with_linux], - [LINUX=/usr/src/linux]) -AC_MSG_RESULT([$LINUX]) -AC_SUBST(LINUX) - -# -------- linux objects (for 2.6) -- -AC_MSG_CHECKING([for Linux objects dir]) -AC_ARG_WITH([linux-obj], - AC_HELP_STRING([--with-linux-obj=path], - [set path to Linux objects dir (default=$LINUX)]), - [LINUX_OBJ=$with_linux_obj], - [LINUX_OBJ=$LINUX]) -AC_MSG_RESULT([$LINUX_OBJ]) -AC_SUBST(LINUX_OBJ) - -# -------- check for .confg -------- -AC_ARG_WITH([linux-config], - [AC_HELP_STRING([--with-linux-config=path], - [set path to Linux .conf (default=$LINUX_OBJ/.config)])], - [LINUX_CONFIG=$with_linux_config], - [LINUX_CONFIG=$LINUX_OBJ/.config]) -AC_SUBST(LINUX_CONFIG) - -AC_CHECK_FILE([/boot/kernel.h], - [KERNEL_SOURCE_HEADER='/boot/kernel.h'], - [AC_CHECK_FILE([/var/adm/running-kernel.h]), - [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']]) - -AC_ARG_WITH([kernel-source-header], - AC_HELP_STRING([--with-kernel-source-header=path], - [Use a different kernel version header. Consult README.kernel-source for details.]), - [KERNEL_SOURCE_HEADER=$with_kernel_source_header]) - -# ------------ .config exists ---------------- -AC_CHECK_FILE([$LINUX_CONFIG],[], - [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])]) - -# ----------- make dep run? ------------------ -AC_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h - $LINUX_OBJ/include/linux/version.h - $LINUX/include/linux/config.h],[], - [AC_MSG_ERROR([Run make config in $LINUX.])]) - -# ------------ rhconfig.h includes runtime-generated bits -- -# red hat kernel-source checks - -# we know this exists after the check above. if the user -# tarred up the tree and ran make dep etc. in it, then -# version.h gets overwritten with a standard linux one. - -if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then - # This is a clean kernel-source tree, we need to - # enable extensive workarounds to get this to build - # modules - AC_CHECK_FILE([$KERNEL_SOURCE_HEADER], - [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then - AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.]) - AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.]) - AC_MSG_WARN([Consult README.kernel-source for details.]) - fi], - [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])]) - EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS" -fi - -# this is needed before we can build modules -LB_LINUX_VERSION - -# --- check that we can build modules at all -AC_MSG_CHECKING([that modules can be built at all]) -LB_LINUX_TRY_COMPILE([],[],[ - AC_MSG_RESULT([yes]) -],[ - AC_MSG_RESULT([no]) - AC_MSG_WARN([Consult config.log for details.]) - AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source]) - AC_MSG_ERROR([Kernel modules could not be built.]) -]) - -LB_LINUX_RELEASE -]) - -# -# LB_LINUX_UML -# -# check for a uml kernel -# -AC_DEFUN([LB_LINUX_UML], -[ARCH_UM= -UML_CFLAGS= - -AC_MSG_CHECKING([if you are running user mode linux for $target_cpu]) -if test -e $LINUX/include/asm-um ; then - if test X`ls -id $LINUX/include/asm/ 2>/dev/null | awk '{print [$]1}'` = X`ls -id $LINUX/include/asm-um 2>/dev/null | awk '{print [$]1}'` ; then - ARCH_UM='ARCH=um' - # see notes in Rules.in - UML_CFLAGS='-O0' - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT([no (asm doesn't point at asm-um)]) - fi -else - AC_MSG_RESULT([no (asm-um missing)]) -fi -AC_SUBST(ARCH_UM) -AC_SUBST(UML_CFLAGS) -]) - -# these are like AC_TRY_COMPILE, but try to build modules against the -# kernel, inside the build directory - -# -# LB_LINUX_CONFTEST -# -# create a conftest.c file -# -AC_DEFUN([LB_LINUX_CONFTEST], -[cat >conftest.c <<_ACEOF -$1 -_ACEOF -]) - -# -# LB_LINUX_COMPILE_IFELSE -# -# like AC_COMPILE_IFELSE -# -AC_DEFUN([LB_LINUX_COMPILE_IFELSE], -[m4_ifvaln([$1], [LB_LINUX_CONFTEST([$1])])dnl -rm -f build/conftest.o build/conftest.mod.c build/conftest.ko -AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])], - [$4], - [_AC_MSG_LOG_CONFTEST -m4_ifvaln([$5],[$5])dnl])dnl -rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl -]) - -# -# LB_LINUX_TRY_COMPILE -# -# like AC_TRY_COMPILE -# -AC_DEFUN([LB_LINUX_TRY_COMPILE], -[LB_LINUX_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[$1]], [[$2]])], - [modules], - [test -s build/conftest.o], - [$3], [$4])]) - -# -# LB_LINUX_CONFIG -# -# check if a given config option is defined -# -AC_DEFUN([LB_LINUX_CONFIG], -[AC_MSG_CHECKING([if Linux was built with CONFIG_$1]) -LB_LINUX_TRY_COMPILE([#include ],[ -#ifndef CONFIG_$1 -#error CONFIG_$1 not #defined -#endif -],[ -AC_MSG_RESULT([yes]) -$2 -],[ -AC_MSG_RESULT([no]) -$3 -]) -]) - -# -# LB_LINUX_TRY_MAKE -# -# like LB_LINUX_TRY_COMPILE, but with different arguments -# -AC_DEFUN([LB_LINUX_TRY_MAKE], -[LB_LINUX_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])]) - -# -# LB_PROG_LINUX -# -# linux tests -# -AC_DEFUN([LB_PROG_LINUX], -[LB_LINUX_PATH -LB_LINUX_UML - -LB_LINUX_CONFIG([MODULES],[],[ - AC_MSG_ERROR([module support is required to build Lustre kernel modules.]) -]) - -LB_LINUX_CONFIG([MODVERSIONS]) - -LB_LINUX_CONFIG([PREEMPT],[ - AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.]) -]) - -LB_LINUX_CONFIG([KALLSYMS],[],[ -if test "x$ARCH_UM" = "x" ; then - AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.]) -fi -]) - -# Portals tests -LP_PROG_LINUX - -# Lustre tests -LC_PROG_LINUX -]) - -# -# LB_LINUX_CONDITIONALS -# -# AM_CONDITIONALS for linux -# -AC_DEFUN([LB_LINUX_CONDITIONALS], -[AM_CONDITIONAL(INKERNEL, test x$enable_inkernel = xyes) -AM_CONDITIONAL(LINUX25, test x$linux25 = xyes) -]) diff --git a/build/autoconf/lustre-build.m4 b/build/autoconf/lustre-build.m4 deleted file mode 100644 index c20ed73..0000000 --- a/build/autoconf/lustre-build.m4 +++ /dev/null @@ -1,406 +0,0 @@ -# -# LB_CHECK_VERSION -# -# Verify that LUSTRE_VERSION was defined properly -# -AC_DEFUN([LB_CHECK_VERSION], -[if test "LUSTRE_VERSION" = "LUSTRE""_VERSION" ; then - AC_MSG_ERROR([This script was not built with a version number.]) -fi -]) - -# -# LB_PATH_LIBSYSIO -# -# Handle internal/external libsysio -# -AC_DEFUN([LB_PATH_LIBSYSIO], -[AC_ARG_WITH([sysio], - AC_HELP_STRING([--with-sysio=path], - [set path to libsysio source (default is included libsysio)]), - [],[with_sysio='yes']) -AC_MSG_CHECKING([location of libsysio]) -enable_sysio="$with_sysio" -case x$with_sysio in - xyes) - AC_MSG_RESULT([internal]) - AC_CHECK_FILE([$srcdir/libsysio/src/rmdir.c],[],[ - AC_MSG_ERROR([A complete internal libsysio was not found.]) - ]) - AC_CONFIG_SUBDIRS(libsysio) - LIBSYSIO_SUBDIR="libsysio" - SYSIO='$(top_srcdir)/libsysio' - ;; - xno) - AC_MSG_RESULT([disabled]) - ;; - *) - AC_MSG_RESULT([$with_sysio]) - AC_CHECK_FILE([$with_sysio/src/libsysio.a],[],[ - AC_MSG_ERROR([A complete (built) external libsysio was not found.]) - ]) - SYSIO=$with_sysio - enable_sysio="yes" - ;; -esac -AC_SUBST(LIBSYSIO_SUBDIR) -AC_SUBST(SYSIO) -]) - -# -# LB_PATH_CRAY_PORTALS -# -# Support for external Cray portals -# -AC_DEFUN([LB_PATH_CRAY_PORTALS], -[AC_MSG_CHECKING([for Cray portals]) -AC_ARG_WITH([cray-portals], - AC_HELP_STRING([--with-cray-portals=path], - [path to cray portals]), - [ - if test "$with_cray_portals" != no; then - CRAY_PORTALS_PATH=$with_cray_portals - CRAY_PORTALS_INCLUDES="$with_cray_portals/include" - CRAY_PORTALS_LIBS="$with_cray_portals" - fi - ],[with_cray_portals=no]) -AC_SUBST(CRAY_PORTALS_PATH) -AC_MSG_RESULT([$CRAY_PORTALS_PATH]) - -AC_MSG_CHECKING([for Cray portals includes]) -AC_ARG_WITH([cray-portals-includes], - AC_HELP_STRING([--with-cray-portals-includes=path], - [path to cray portals includes]), - [ - if test "$with_cray_portals_includes" != no; then - CRAY_PORTALS_INCLUDES="$with_cray_portals_includes" - fi - ]) -AC_SUBST(CRAY_PORTALS_INCLUDES) -AC_MSG_RESULT([$CRAY_PORTALS_INCLUDES]) - -AC_MSG_CHECKING([for Cray portals libs]) -AC_ARG_WITH([cray-portals-libs], - AC_HELP_STRING([--with-cray-portals-libs=path], - [path to cray portals libs]), - [ - if test "$with_cray_portals_libs" != no; then - CRAY_PORTALS_LIBS="$with_cray_portals_libs" - fi - ]) -AC_SUBST(CRAY_PORTALS_LIBS) -AC_MSG_RESULT([$CRAY_PORTALS_LIBS]) - -if test x$CRAY_PORTALS_INCLUDES != x ; then - if test ! -r $CRAY_PORTALS_INCLUDES/portals/api.h ; then - AC_MSG_ERROR([Cray portals headers were not found in $CRAY_PORTALS_INCLUDES. Please check the paths passed to --with-cray-portals or --with-cray-portals-includes.]) - fi -fi -if test x$CRAY_PORTALS_LIBS != x ; then - if test ! -r $CRAY_PORTALS_LIBS/libportals.a ; then - AC_MSG_ERROR([Cray portals libraries were not found in $CRAY_PORTALS_LIBS. Please check the paths passed to --with-cray-portals or --with-cray-portals-libs.]) - fi -fi - -AC_MSG_CHECKING([whether to use Cray portals]) -if test x$CRAY_PORTALS_INCLUDES != x -a x$CRAY_PORTALS_LIBS != x ; then - with_cray_portals=yes - AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals]) - CPPFLAGS="-I$CRAY_PORTALS_INCLUDES $CPPFLAGS" - EXTRA_KCFLAGS="-I-I$CRAY_PORTALS_INCLUDES $EXTRA_KCFLAGS" -else - with_cray_portals=no -fi -AC_MSG_RESULT([$with_cray_portals]) -]) - -# -# LB_CONFIG_MODULES -# -# Build kernel modules? -# -AC_DEFUN([LB_CONFIG_MODULES], -[AC_MSG_CHECKING([whether to build kernel modules]) -AC_ARG_ENABLE([modules], - AC_HELP_STRING([--disable-modules], - [disable building of Lustre kernel modules]), - [],[ - LC_TARGET_SUPPORTED([ - enable_modules='yes' - ],[ - enable_modules='no' - ]) - ]) -AC_MSG_RESULT([$enable_modules ($target_os)]) - -if test x$enable_modules = xyes ; then - case $target_os in - linux*) - LB_PROG_LINUX - ;; - darwin*) - LB_PROG_DARWIN - ;; - *) - # This is strange - Lustre supports a target we don't - AC_MSG_ERROR([Modules are not supported on $target_os]) - ;; - esac -fi -]) - -# -# LB_CONFIG_UTILS -# -# Build utils? -# -AC_DEFUN([LB_CONFIG_UTILS], -[AC_MSG_CHECKING([whether to build utilities]) -AC_ARG_ENABLE([utils], - AC_HELP_STRING([--disable-utils], - [disable building of Lustre utility programs]), - [],[enable_utils='yes']) -if test x$with_cray_portals = xyes ; then - enable_utils='no' -fi -AC_MSG_RESULT([$enable_utils]) -if test x$enable_utils = xyes ; then - LB_CONFIG_INIT_SCRIPTS -fi -]) - -# -# LB_CONFIG_TESTS -# -# Build tests? -# -AC_DEFUN([LB_CONFIG_TESTS], -[AC_MSG_CHECKING([whether to build Lustre tests]) -AC_ARG_ENABLE([tests], - AC_HELP_STRING([--disable-tests], - [disable building of Lustre tests]), - [],[enable_tests='yes']) -if test x$with_cray_portals = xyes ; then - enable_tests='no' -fi -AC_MSG_RESULT([$enable_tests]) -]) - -# -# LB_CONFIG_DOCS -# -# Build docs? -# -AC_DEFUN([LB_CONFIG_DOCS], -[AC_MSG_CHECKING([whether to build docs]) -AC_ARG_ENABLE(doc, - AC_HELP_STRING([--disable-doc], - [skip creation of pdf documentation]), - [ - if test x$enable_doc = xyes ; then - ENABLE_DOC=1 - else - ENABLE_DOC=0 - fi - ],[ - ENABLE_DOC=0 - enable_doc='no' - ]) -AC_MSG_RESULT([$enable_doc]) -AC_SUBST(ENABLE_DOC) -]) - -# -# LB_CONFIG_INIT_SCRIPTS -# -# our init scripts only work on red hat linux -# -AC_DEFUN([LB_CONFIG_INIT_SCRIPTS], -[ENABLE_INIT_SCRIPTS=0 -if test x$enable_utils = xyes ; then - AC_MSG_CHECKING([whether to install init scripts]) - # our scripts only work on red hat systems - if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then - ENABLE_INIT_SCRIPTS=1 - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi -fi -AC_SUBST(ENABLE_INIT_SCRIPTS) -]) - -# -# LB_CONFIG_HEADERS -# -# add -include config.h -# -AC_DEFUN([LB_CONFIG_HEADERS], -[AC_CONFIG_HEADERS([config.h]) -CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS" -EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS" -AC_SUBST(EXTRA_KCFLAGS) -]) - -# -# LB_INCLUDE_RULES -# -# defines for including the toplevel Rules -# -AC_DEFUN([LB_INCLUDE_RULES], -[INCLUDE_RULES="include $PWD/build/Rules" -AC_SUBST(INCLUDE_RULES) -]) - -# -# LB_PATH_DEFAULTS -# -# 'fixup' default paths -# -AC_DEFUN([LB_PATH_DEFAULTS], -[# directories for binaries -AC_PREFIX_DEFAULT([/usr]) - -sysconfdir='/etc' -AC_SUBST(sysconfdir) - -# Directories for documentation and demos. -docdir='${datadir}/doc/$(PACKAGE)' -AC_SUBST(docdir) - -LP_PATH_DEFAULTS -LC_PATH_DEFAULTS -]) - -# -# LB_PROG_CC -# -# checks on the C compiler -# -AC_DEFUN([LB_PROG_CC], -[AC_PROG_RANLIB -AC_MSG_CHECKING([for buggy compiler]) -CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"` -bad_cc() { - AC_MSG_RESULT([buggy compiler found!]) - echo - echo " '$CC_VERSION'" - echo " has been known to generate bad code, " - echo " please get an updated compiler." - AC_MSG_ERROR([sorry]) -} -case "$CC_VERSION" in - "gcc version 2.95"*) - bad_cc - ;; - # ost_pack_niobuf putting 64bit NTOH temporaries on the stack - # without "sub $0xc,%esp" to protect the stack from being - # stomped on by interrupts (bug 606) - "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)") - bad_cc - ;; - # mandrake's similar sub 0xc compiler bug - # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2 - "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)") - bad_cc - ;; - *) - AC_MSG_RESULT([no known problems]) - ;; -esac - -# --------- unsigned long long sane? ------- -AC_CHECK_SIZEOF(unsigned long long, 0) -echo "---> size SIZEOF $SIZEOF_unsigned_long_long" -echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long" -if test $ac_cv_sizeof_unsigned_long_long != 8 ; then - AC_MSG_ERROR([** we assume that sizeof(long long) == 8. Tell phil@clusterfs.com]) -fi - -CPPFLAGS="-I\$(top_srcdir)/lustre/include -I\$(top_srcdir)/portals/include $CPPFLAGS" - -LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1" -AC_SUBST(LLCPPFLAGS) - -LLCFLAGS="-g -Wall -fPIC" -AC_SUBST(LLCFLAGS) - -# everyone builds against portals and lustre -EXTRA_KCFLAGS="-g -I$PWD/portals/include -I$PWD/lustre/include" -AC_SUBST(EXTRA_KCFLAGS) -]) - -# -# LB_CONTITIONALS -# -# AM_CONDITIONAL instances for everything -# (so that portals/lustre can disable some if needed) -AC_DEFUN([LB_CONDITIONALS], -[AM_CONDITIONAL(MODULES, test x$enable_modules = xyes) -AM_CONDITIONAL(UTILS, test x$enable_utils = xyes) -AM_CONDITIONAL(TESTS, test x$enable_tests = xyes) -AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1) -AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno) -AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1") - -LB_LINUX_CONDITIONALS -LB_DARWIN_CONDITIONALS - -LP_CONDITIONALS -LC_CONDITIONALS -]) - -# -# LB_CONFIGURE -# -# main configure steps -# -AC_DEFUN([LB_CONFIGURE], -[LB_INCLUDE_RULES - -LB_PATH_DEFAULTS - -LB_PROG_CC - -LB_PATH_LIBSYSIO -LB_PATH_CRAY_PORTALS - -LB_CONFIG_DOCS -LB_CONFIG_UTILS -LB_CONFIG_TESTS - -LB_CONFIG_MODULES - -LC_CONFIG_LIBLUSTRE - -LP_CONFIGURE -LC_CONFIGURE - -LB_CONDITIONALS -LB_CONFIG_HEADERS - -AC_CONFIG_FILES( -[Makefile:build/Makefile.in.toplevel] -[autoMakefile -build/autoMakefile -build/autoconf/Makefile -build/Rules -build/lustre.spec -]) - -LP_CONFIG_FILES -LC_CONFIG_FILES - -AC_OUTPUT - -cat <<_ACEOF - -CPPFLAGS: $CPPFLAGS -LLCPPFLAGS: $LLCPPFLAGS -CFLAGS: $CFLAGS -EXTRA_KCFLAGS: $EXTRA_KCFLAGS -LLCFLAGS: $LLCFLAGS - -Type 'make' to build Lustre. -_ACEOF -]) diff --git a/build/autogen.sh b/build/autogen.sh deleted file mode 100644 index 3c3bf5f..0000000 --- a/build/autogen.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash - -# taken from gnome-common/macros2/autogen.sh -compare_versions() { - ch_min_version=$1 - ch_actual_version=$2 - ch_status=0 - IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="." - set $ch_actual_version - for ch_min in $ch_min_version; do - ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes - if [ -z "$ch_min" ]; then break; fi - if [ -z "$ch_cur" ]; then ch_status=1; break; fi - if [ $ch_cur -gt $ch_min ]; then break; fi - if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi - done - IFS="$ch_save_IFS" - return $ch_status -} - -error_msg() { - echo "$cmd is $1. version $required is required to build Lustre." - - if [ -e /usr/lib/autolustre/bin/$cmd ]; then - cat >&2 <<-EOF - You apparently already have Lustre-specific autoconf/make RPMs - installed on your system at /usr/lib/autolustre/share/$cmd. - Please set your PATH to point to those versions: - - export PATH="/usr/lib/autolustre/bin:\$PATH" - EOF - else - cat >&2 <<-EOF - CFS provides RPMs which can be installed alongside your - existing autoconf/make RPMs, if you are nervous about - upgrading. See - - ftp://ftp.lustre.org/pub/other/autolustre/README.autolustre - - You may be able to download newer version from: - - http://ftp.gnu.org/gnu/$cmd/$cmd-$required.tar.gz - EOF - fi - [ "$cmd" = "autoconf" -a "$required" = "2.57" ] && cat >&2 <&2 </dev/null ; then - error_msg "missing" - fi - version=$($cmd --version | awk "BEGIN { IGNORECASE=1 } /$tool \(GNU $tool\)/ { print \$4 }") - echo "found $version" - if ! compare_versions "$required" "$version" ; then - error_msg "too old" - fi -} - -echo "Checking for a complete tree..." -for dir in build portals lustre ; do - if [ ! -d "$dir" ] ; then - cat >&2 </dev/null - echo "Running autogen for libsysio..." - sh autogen.sh - popd >/dev/null -fi diff --git a/build/branch.sh b/build/branch.sh deleted file mode 100755 index 328aeff..0000000 --- a/build/branch.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -e -CVS=${CVS:-cvs} - -progname=${0##*/} - -if [ $# -lt 2 -o $# -gt 3 ]; then - echo "This creates a new branch in CVS. Usage: $progname parent child " - exit -fi - -parent=$1 -child=$2 -CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"` -dir=${3:-.} -module=$(<$dir/CVS/Repository) - -if [ "$module" = "lustre" ] ; then - echo >&2 "${progname}: You probably want to branch lustre or portals." - echo >&2 "${progname}: Try using ${0} $parent $child lustre" - exit 1 -fi - -case $parent in - HEAD) : ;; - b_*|b1*) : ;; - *) parent="b_$parent" ;; -esac -case $child in - HEAD) : ;; - b_*|b1*) : ;; - *) child="b_$child" -esac - -if [ "$parent" != "HEAD" -a "`cat $dir/CVS/Tag`" != "T$parent" ]; then - echo "This script must be run within the $parent branch" - exit 1 -fi - -echo parent: $parent CHILD: $CHILD child: $child date: $date - -echo -n "tagging $parent as '${CHILD}_BASE' ...." -$CVS rtag -r $parent ${CHILD}_BASE $module -echo "done" -echo -n "branching $child at ${CHILD}_BASE' ...." -$CVS rtag -b -r ${CHILD}_BASE $child $module -echo -n "updating $dir to $child ...." -$CVS update -r $child $dir -echo "done" diff --git a/build/buildcvs b/build/buildcvs deleted file mode 100644 index 9ac6ef4..0000000 --- a/build/buildcvs +++ /dev/null @@ -1,36 +0,0 @@ -# This file is sourced by lustre/lustrecvs - -portalstag="HEAD" -libsysiotag="LIBSYSIO_HEAD_20040607" - -case "$lustretag" in - '') - warn "a lustretag is required." - usage >&2 - exit 1 - ;; - --help | -h) - usage - exit 0 - ;; - - # this is the branch table - # keep this list sorted alphabetically! - - b1_4_bgl) - portalstag="b1_4_bgl" - ;; - - b_newsysio | b_sec) - libsysiotag="LIBSYSIO_HEAD_20040809" - ;; - - b_port_step) - portalstag="b_port_step" - ;; - -esac - -cvs_cmd libsysio libsysio "$libsysiotag" -cvs_cmd portals portals "$portalstag" -cvs_cmd lustre lustre-core "$lustretag" diff --git a/build/land1.sh b/build/land1.sh deleted file mode 100755 index 6b69eae..0000000 --- a/build/land1.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh -e - -progname=${0##*/} - -CONFLICTS=cvs-merge-conflicts -CVS=cvs - -if [ -f .mergeinfo ] ; then - echo ".mergeinfo exists - clean up first" - exit -fi - -if [ -f $CONFLICTS ] ; then - echo "$CONFLICTS exists - clean up first" - exit -fi - -if [ $# -lt 2 -o $# -gt 3 ]; then - echo "This is phase 1 of merging branches. Usage: $0 parent child [dir]" - exit -fi - -parent=$1 -PARENT=`echo $parent | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"` -child=$2 -CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"` -date=`date +%Y%m%d_%H%M` - -dir=${3:-.} -module=$(<$dir/CVS/Repository) - -if [ "$module" = "lustre" ] ; then - echo >&2 "${progname}: You probably want to branch lustre or portals, not the whole tree." - echo >&2 "${progname}: Try using ${0} $parent $child lustre" - exit 1 -fi - -case $parent in - HEAD) : ;; - b_*|b[1-4]*) : ;; - *) parent="b_$parent" ;; -esac -case $child in - HEAD) : ;; - b_*|b[1-4]*) : ;; - *) child="b_$child" -esac - -if [ "$parent" != "HEAD" -a "`cat $dir/CVS/Tag 2> /dev/null`" != "T$parent" ]; then - echo "${progname}: this script must be run within the $parent branch" - exit 1 -fi - -TEST_FILE=${TEST_FILE:-ChangeLog} # does this need to be smarter? -check_tag() { - [ -z "$1" ] && echo "check_tag() missing arg" && exit3 - [ "$1" = "HEAD" ] && return - $CVS log $dir/$TEST_FILE 2> /dev/null | grep -q " $1: " && return - echo "${progname}: tag $1 not found in $dir/$TEST_FILE" - exit 2 -} - -check_tag $child -check_tag ${CHILD}_BASE - -cat << EOF > ".mergeinfo" -parent=$parent -PARENT=$PARENT -child=$child -CHILD=$CHILD -date=$date -module=$module -dir=$dir -CONFLICTS=$CONFLICTS -OPERATION=Land -OPERWHERE=onto -EOF - -echo PARENT $PARENT parent $parent CHILD $CHILD child $child date $date - -# Update your tree to the PARENT branch; HEAD is not really a branch, so you -# need to update -A instead of update -r HEAD, or the commit will fail. -p -echo -n "Updating to $parent ...." -if [ $parent == "HEAD" ]; then - $CVS update -AdP $dir -else - $CVS update -r $parent -dP $dir -fi -echo "done" - -echo -n "Tagging as ${PARENT}_${CHILD}_LAND_PARENT_$date ..." -$CVS tag ${PARENT}_${CHILD}_LAND_PARENT_$date $dir -echo "done" - -echo -n "Create land point on ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date ..." -$CVS rtag -r ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date $module $dir -echo "done" - -echo -n "Preserve old base tag ${CHILD}_BASE as ${CHILD}_BASE_PREV ..." -$CVS tag -F -r ${CHILD}_BASE ${CHILD}_BASE_PREV $dir -echo "done" - -# Apply all of the changes to your local tree: -echo -n "Updating as -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date ..." -$CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date $dir -echo "done" - -echo -n "Recording conflicts in $CONFLICTS ..." -if $CVS update | grep '^C' > $CONFLICTS; then - echo "Conflicts found, fix before committing." - cat $CONFLICTS -else - echo "No conflicts found" - rm -f $CONFLICTS -fi -echo "done" - -echo "Build, test, commit and then run land2.sh (no arguments)" diff --git a/build/land2.sh b/build/land2.sh deleted file mode 100755 index 2bb9fad..0000000 --- a/build/land2.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -e - -CVS=cvs - -if [ ! -f .mergeinfo ] ; then - echo ".mergeinfo doesn't exist - exit" - exit -fi - -. .mergeinfo - -if [ -f "$CONFLICTS" ] ; then - echo "$CONFLICTS exists - clean up first" - cat $CONFLICTS - exit -fi - -#cvs update $dir 2>&1 | grep "^M" && echo "uncommitted changes" && exit 1 - -echo -n "Tagging as ${CHILD}_BASE_$date ..." -$CVS tag -F ${CHILD}_BASE_$date $dir -echo "done" -echo -n "Tagging as ${CHILD}_BASE ..." -$CVS tag -F ${CHILD}_BASE $dir - -echo "saving .mergeinfo as .mergeinfo-$date" -mv .mergeinfo .mergeinfo-$date -echo "done" diff --git a/build/lbuild b/build/lbuild deleted file mode 100755 index 846f1c1..0000000 --- a/build/lbuild +++ /dev/null @@ -1,528 +0,0 @@ -#!/bin/sh - -TOPDIR=$PWD - -# CVSROOT is inherited from the environment -KERNELDIR= -LUSTRE= -PUBLISH=0 -RELEASE=0 -DO_SRC=1 -TAG= -TARGET= -TARGET_ARCHS= -CONFIGURE_FLAGS= -EXTERNAL_PATCHES= -EXTRA_VERSION= - -# from target file -KERNEL= -SERIES= -CONFIG= -VERSION= - -RHBUILD=0 -SUSEBUILD=0 -LINUX26=0 -SUSEBUILD=0 - -BASE_ARCHS= -BIGMEM_ARCHS= -BOOT_ARCHS= -JENSEN_ARCHS= -SMP_ARCHS= -BIGSMP_ARCHS= -UP_ARCHS= - -DATE=$(date) - -USE_DATESTAMP=1 -RPMBUILD= - -cleanup() -{ - true -} - -error() -{ - [ "$1" ] && echo -e "\n${0##*/}: $1" -} - -fatal() -{ - cleanup - error "$2" - exit $1 -} - -publishing() -{ - (( $PUBLISH )) || return 0 -} - -is_release() -{ - (( $RELEASE )) || return 0 -} - -list_targets() -{ - echo -n "Available targets:" - for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do - target_file=${target##*/} - echo -n " ${target_file%%.target}" - done - echo -} - -usage() -{ - cat <] - - -d CVSROOT - Specifies the CVS Root to use when pulling files from CVS. The - environment variable \$CVSROOT is used if this option is not - present. - - --external-patches=EXTERNAL_PATCHES - Directory similar to lustre/lustre/kernel_patches/ that lbuild should - look for seres and config files in before looking in the lustre - tree. - - --extraversion=EXTRAVERSION - Text to use for the rpm release and kernel extraversion. - - --kerneldir=KERNELDIR - Directory containing Linux source tarballs referenced by target - files. - - --lustre=LUSTRE - Path to an existing lustre source tarball to use instead of - pulling from CVS. - - --nosrc - Do not build a .src.rpm, a full kernel patch, or a patched kernel - tarball. - - --publish - Publish the packages, patches, and tarballs on the ftp server. - - --release - Specifies that the files generated do not include timestamps, and - that this is an official release. - - --tag=TAG - A CVS branch/tag name to build from when pulling from CVS. - - --target=TARGET - The name of the target to build. The available targets are listed - below. - - --target-archs=TARGET_ARCHS - A (space delimited) list of architectures to build. By default, - all of the archs supported by the TARGET will be built, in - addition to a .src.rpm. This option can limit those, for machines - that can only build certain archs or if you only want a certain - arch built (for testing, or a one-off kernel). - - Also note that by using a non-"base" arch (eg, i386) only kernels - will be built - there will be no lustre-lite-utils package. - - --disable-datestamp - Prevents the datestamp flag (-D) from being passed to cvs for - checkouts. This is a workaround for a problem encountered when - using lbuild with tinderbox. - -EOF - -# list_targets - - fatal "$1" "$2" -} - -check_options() -{ - if [ "$LUSTRE" ] ; then - [ -r "$LUSTRE" ] || \ - usage 1 "Could not find Lustre source tarball '$LUSTRE'." - else - [ "$CVSROOT" ] || \ - usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre." - [ "$TAG" ] || \ - usage 1 "A branch/tag name must be specified with --tag when not building from a tarball." - fi - - [ "$KERNELDIR" ] || \ - usage 1 "A kernel directory must be specified with --kerneldir." - - [ -d "$KERNELDIR" ] || \ - usage 1 "$KERNELDIR is not a directory." - - if ! (( $RELEASE )) ; then - [ "$TAG" ] || \ - usage 1 "When building a snapshot, a tag name must be used." - fi - - TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M") - - [ "$TARGET" ] || usage 1 "A target must be specified with --target." -# TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target" -# [ -r "$TARGET_FILE" ] || \ -# usage 1 "Target '$TARGET' was not found." - - RPMBUILD=$(which rpmbuild 2>/dev/null | head -1) - if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then - RPMBUILD=$(which rpm 2>/dev/null | head -1) - if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then - usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)." - fi - fi -} - -uniqify() -{ - echo $(echo "$*" | xargs -n 1 | sort -u) -} - -load_target() -{ - EXTRA_VERSION_save="$EXTRA_VERSION" - for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do - TARGET_FILE="$patchesdir/targets/$TARGET.target" - [ -r "$TARGET_FILE" ] && break - done - [ -r "$TARGET_FILE" ] || \ - fatal 1 "Target $TARGET was not found." - - echo "Loading target config file $TARGET.target..." - - . "$TARGET_FILE" - - [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel." -# [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a kernel patch series." -# [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config." - [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version." - - if [ "$KERNELDIR" ] ; then - KERNEL_FILE="$KERNELDIR/$KERNEL" - [ -r "$KERNELDIR/$KERNEL" ] || \ - fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR." - fi - - if [ "$SERIES" ] ; then - for series in $SERIES ; do - for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do - [ -r "$patchesdir/series/$series" ] && continue 2 - done - fatal 1 "Target $TARGET's series $SERIES could not be found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n\t$TOPDIR/lustre/lustre/kernel_patches/series." - done - fi - - CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/$CONFIG" - [ -r "$CONFIG_FILE" ] || \ - fatal 1 "Target $TARGET's config file $CONFIG missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/." - - if [ "$EXTRA_VERSION_save" ] ; then - EXTRA_VERSION="$EXTRA_VERSION_save" - elif ! (( $RELEASE )) ; then - EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}" - fi - # EXTRA_VERSION=${EXTRA_VERSION//-/_} - - ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $UP_ARCHS" - - BUILD_ARCHS= - for arch in $(uniqify "$ALL_ARCHS") ; do - if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then - BUILD_ARCHS="$BUILD_ARCHS $arch" - fi - done - [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build." - echo "Building for: $BUILD_ARCHS" -} - -tarflags() -{ - case "$1" in - '') - fatal 1 "tarflags(): File name argument missing." - ;; - *.tar.gz) - echo 'zxf' - ;; - *.tar.bz2) - echo 'jxf' - ;; - *) - fatal 1 "tarflags(): Unrecognized tar extension in file: $1" - ;; - esac -} - -untar() -{ - echo "Untarring ${1##*/}..." - tar $(tarflags "$1") "$1" -} - -unpack_lustre() -{ - DIRNAME="lustre-$TAG-$TIMESTAMP" - if [ "$LUSTRE" ] ; then - untar "$LUSTRE" - [ -d lustre ] || ln -sf lustre* lustre - else - if [ "$USE_DATESTAMP" ]; then - DATESTAMP="-D '$DATE'" - else - DATESTAMP="" - fi - - cvs -d "$CVSROOT" -qz3 co $DATESTAMP -r "$TAG" -d "$DIRNAME" lustre || \ - fatal 1 "There was an error checking out Lustre from CVS." - echo "Creating lustre tarball..." - tar zcf "$DIRNAME.tar.gz" "$DIRNAME" \ - --exclude "CVS" --exclude "*~" --exclude ".cvsignore" || \ - fatal 1 "Could not create Lustre tarball." - LUSTRE="$PWD/$DIRNAME.tar.gz" - ln -sf "$DIRNAME" lustre - fi -} - -unpack_linux() -{ - untar "$KERNEL_FILE" - [ -d linux ] || ln -sf linux* linux -} - -patch_linux() -{ - [ "$SERIES" ] || return 0 - FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch" - [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH" - pushd linux >/dev/null - for series in $SERIES ; do - echo -n "Applying series $series:" - for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do - [ -r "$patchesdir/series/$series" ] || continue - SERIES_FILE="$patchesdir/series/$series" - for patch in $(<"$SERIES_FILE") ; do - echo -n " $patch" - PATCH_FILE="$patchesdir/patches/$patch" - [ -r "$PATCH_FILE" ] || \ - fatal 1 "Patch $patch does not exist in Lustre tree." - cat "$PATCH_FILE" >> "$FULL_PATCH" || \ - fatal 1 "Error adding patch $patch to full patch." - patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch." - done - break - done - echo - done - popd >/dev/null - echo "Full patch has been saved in ${FULL_PATCH##*/}." - echo "Replacing .config files..." - [ -d linux/configs ] || mkdir linux/configs || \ - fatal 1 "Error creating configs directory." - rm -f linux/configs/* - copysuccess=0 - for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do - cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1 - done - [ "$copysuccess" = "1" ] || \ - fatal 1 "Error copying in kernel configs." -} - -pack_linux() -{ - TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz" - echo "Creating patched linux tarball $TARBALL..." - tar zcf "$TARBALL" "$(readlink linux)" \ - --exclude "CVS" --exclude ".cvsignore" || \ - --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \ - fatal 1 "Error creating patched Linux tarball." -} - -clean_linux() -{ - [ -d linux ] || return 0 - echo "Cleaning linux..." - [ -L linux ] && rm -rf $(readlink linux) - rm -rf linux -} - -prep_build() -{ - # make .spec file - if [ -f /etc/init.d/functions -a -f /etc/sysconfig/network ] ; then - ENABLE_INIT_SCRIPTS="" - else - ENABLE_INIT_SCRIPTS="# " - fi - sed \ - -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \ - -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \ - -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \ - -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \ - -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \ - -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \ - -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \ - -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \ - -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \ - -e "s^@KERNEL_SOURCE@^$KERNEL^g" \ - -e "s^@KERNEL_VERSION@^$VERSION^g" \ - -e "s^@LINUX26@^$LINUX26^g" \ - -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \ - -e "s^@LUSTRE_TARGET@^$TARGET^g" \ - -e "s^@RHBUILD@^$RHBUILD^g" \ - -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \ - -e "s^@SUSEBUILD@^$SUSEBUILD^g" \ - -e "s^@SUSEBUILD@^$SUSEBUILD^g" \ - -e "s^@UP_ARCHS@^$UP_ARCHS^g" \ - < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \ - > lustre-kernel-2.4.spec - [ -d SRPMS ] || mkdir SRPMS - [ -d RPMS ] || mkdir RPMS - [ -d BUILD ] || mkdir BUILD - [ -d SOURCES ] || mkdir SOURCES - for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \ - suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} ; do - cp $TOPDIR/lustre/build/$script SOURCES - done - cp "$LUSTRE" "$KERNEL_FILE" SOURCES - if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then - tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs - else - touch SOURCES/external-patches.tar.gz - fi -} - -clean_lustre() -{ - [ -d lustre ] || return 0 - echo "Cleaning lustre..." - [ -L lustre ] && rm -rf $(readlink lustre) - rm -rf lustre -} - -build() -{ - echo "Building rpms for: $BUILD_ARCHS..." - targets= - for arch in $BUILD_ARCHS ; do - targets="--target $arch $targets" - done - - $RPMBUILD $targets -bb lustre-kernel-2.4.spec \ - --define "_topdir $TOPDIR" || \ - fatal 1 "Error building rpms for $arch." - - if (( $DO_SRC )) ; then - $RPMBUILD -bs lustre-kernel-2.4.spec \ - --define "_topdir $TOPDIR" || \ - fatal 1 "Error building .src.rpm." - fi -} - -publish() -{ - publishing || return 0 -} - -[ -r ~/.lbuildrc ] && . ~/.lbuildrc - -options=$(getopt -o d:D:h -l external-patches:,extraversion:,kerneldir:,lustre:,nosrc,publish,release,tag:,target:,target-archs:,disable-datestamp -- "$@") - -eval set -- "$options" - -while [ "$1" ] ; do - case "$1" in - '') - usage 1 - ;; - -d) - CVSROOT=$2 - shift 2 - ;; - -D) - DATE=$2 - shift 2 - ;; - --external-patches) - EXTERNAL_PATCHES=$2 - shift 2 - ;; - --extraversion) - EXTRA_VERSION=$2 - shift 2 - ;; - --help | -h) - usage 0 - ;; - --kerneldir) - KERNELDIR=$2 - shift 2 - ;; - --lustre) - LUSTRE=$2 - shift 2 - ;; - --nosrc) - DO_SRC=0 - shift 1 - ;; - --publish) - PUBLISH=1 - shift - ;; - --release) - RELEASE=1 - shift - ;; - --tag) - TAG=$2 - shift 2 - ;; - --target) - TARGET=$2 - shift 2 - ;; - --target-archs) - TARGET_ARCHS=$2 - shift 2 - ;; - --disable-datestamp) - USE_DATESTAMP= - shift - ;; - --) - shift - CONFIGURE_FLAGS=$@ - break - ;; - *) - usage 1 "Unrecognized option: $1" - ;; - esac -done - -check_options - -unpack_lustre -load_target - -if (( $DO_SRC )) ; then - unpack_linux - patch_linux - pack_linux - clean_linux -fi - -# prep_build needs the .spec.in from the lustre source -prep_build -clean_lustre - -build -publish diff --git a/build/linux-merge-config.awk b/build/linux-merge-config.awk deleted file mode 100644 index 9a9338c..0000000 --- a/build/linux-merge-config.awk +++ /dev/null @@ -1,317 +0,0 @@ -#!/bin/awk -f -BEGIN { - nsects = 0 -} -{ - ARCH = $1 - ARCHES[ARCH] = 1 - TYPE = $2 - TYPES[TYPE] = 1 - NTOTAL++ - ARCHTYPES[ARCH ":" TYPE] = 1 - NARCHES[TYPE]++ - if (NARCHES[TYPE] == 1) - NTOTALTYPES++ - NTYPES[ARCH]++ - if (NTYPES[ARCH] == 1) - NTOTALARCHES++ - FILE = $3 - cursects = nsects - while ((getline < FILE) > 0) { - if ($0 ~ /^\/\*/ || $0 ~ /^ \*\// || $0 ~ /^[ ]*$/) - continue - if ($0 ~ /^ * /) { - SECTION = gensub(/^ \* /,"",$0) - if (!(SECTION in sectno)) { - sectno[SECTION] = nsects - counts[SECTION] = 0 - nsects++ - } else if (cursects && cursects != nsects) { - no = sectno[SECTION] - diff = nsects - cursects - for (s in sectno) { - if (sectno[s] >= cursects) - sectno[s] = sectno[s] - cursects + no - else if (sectno[s] >= no) - sectno[s] += diff - } - } - cursects = nsect - cursym[SECTION] = counts[SECTION] - continue - } - if ($1 != "#define" && $1 != "#undef") - exit 1 - SYMBOL = $2 - n = index($0,SYMBOL)+length(SYMBOL) - if ($1 == "#define") { - n = index($0,SYMBOL)+length(SYMBOL) - VALUE = gensub(/^[ ]*/,"","",substr($0,n)) - if (VALUE == "") VALUE = "__novalue__" - } else - VALUE = "__undefined__" - if (values[SYMBOL]) { - if (present[SYMBOL,ARCH,TYPE]) continue - present[SYMBOL,ARCH,TYPE] = 1 - values[SYMBOL] = values[SYMBOL] SUBSEP ARCH ":" TYPE ":" VALUE - if (SECTION == sections[SYMBOL] && cursym[SECTION] && cursym[SECTION] != counts[SECTION]) { - no = pos[SYMBOL] - diff = counts[SECTION]-cursym[SECTION] - for (s in pos) - if (sections[s] == SECTION) { - if (pos[s] >= cursym[SECTION]) - pos[s] = pos[s] - cursym[SECTION] + no - else if (pos[s] >= no) - pos[s] += diff - } - cursym[SECTION] = counts[SECTION] - } - } else { - present[SYMBOL,ARCH,TYPE] = 1 - values[SYMBOL] = ARCH ":" TYPE ":" VALUE - sections[SYMBOL] = SECTION - pos[SYMBOL] = counts[SECTION] - counts[SECTION]++ - } - } - close(FILE) -} -END { - for (SECTION in sectno) - x[sectno[SECTION]] = SECTION - for (i = 0; i < nsects; i++) { - SECTION = x[i] - if (i > 0) - printf "\n" - printf "/*\n * %s\n */\n", SECTION - split("",lines) - lastelse = "" - for (SYMBOL in sections) - if (sections[SYMBOL] == SECTION) - y[pos[SYMBOL]] = SYMBOL - for (j = 0; j < counts[SECTION]; j++) { - SYMBOL = y[j] - split("",ntype) - split("",total) - split(values[SYMBOL],z,SUBSEP) - split("",val) - totalsum = 0 - for (k in z) { - split(z[k],l,":") - ARCH = l[1] - TYPE = l[2] - VALUE = substr(z[k],length(ARCH)+length(TYPE)+3) - if (val[VALUE]) - val[VALUE] = val[VALUE] " " - val[VALUE] = val[VALUE] ARCH ":" TYPE - ntype[VALUE,TYPE] += 1 - total[VALUE] += 1 - totalsum += 1 - } - split("",curlines) - append = 1 - for (VALUE in val) { - if (total[VALUE] == NTOTAL) { - if (VALUE == "__undefined__") - curlines["1"] = "#undef " SYMBOL "\n" - else if (VALUE == "__novalue__") - curlines["1"] = "#define " SYMBOL "\n" - else - curlines["1"] = "#define " SYMBOL " " VALUE "\n" - if (!lines["1"]) - append = 0 - break - } - shorteststr = "" - curcount = 0 - for (m = 0; m < 4; m++) { - str = "" - split(val[VALUE],yy) - if (total[VALUE] > 1 && total[VALUE] == NTOTAL - 1) { - found = 0 - for (arch in ARCHES) { - for (type in TYPES) { - archtype = arch ":" type - if (ARCHTYPES [archtype] == 1) { - for (n in yy) - if (yy[n] == archtype) - break - if (yy[n] != archtype) { - found = 1 - break - } - } - } - if (found) - break - } - if (NARCHES[type] > 1 && NTYPES[arch] > 1) { - str = "!defined(__module__" arch "_" type ")" - shorteststr = str - break - } - } - if (m == 0 || m == 2) { - nfull = 0 - split("",yysave) - for (type in TYPES) - if (ntype[VALUE,type] == NARCHES[type]) { - if (str) str = str " || " - str = str "defined(__module__" type ")" - for (k in yy) { - split(yy[k], z, ":") - if (z[2] == type) { - yysave[k] = yy[k] - delete yy[k] - } - } - nfull++ - } else - NOTYPE = type - if (m < 2 && nfull > 1 && nfull == NTOTALTYPES - 1) { - str = "!defined(__module__" NOTYPE ")" - for (k in yysave) - yy[k] = yysave[k] - for (k in yy) { - split(yy[k], z, ":") - if (z[2] != NOTYPE) - delete yy[k] - } - } - } - savestr = str - nfull = 0 - split("",yysave) - for (arch in ARCHES) { - narch = 0 - for (k in yy) { - split(yy[k], z, ":") - if (z[1] == arch) - narch++ - } - if (narch == NTYPES[arch]) { - if (str) str = str " || " - str = str "defined(__module__" arch ")" - for (k in yy) { - split(yy[k], z, ":") - if (z[1] == arch) { - yysave[k] = yy[k] - delete yy[k] - } - } - nfull++ - } else - NOARCH = arch - } - if (m < 2 && nfull > 1 && nfull == NTOTALARCHES - 1) { - str = savestr - for (k in yysave) - yy[k] = yysave[k] - if (str) str = str " || " - str = str "!defined(__module__" NOARCH ")" - for (k in yy) { - split(yy[k], z, ":") - if (z[1] != NOARCH) - delete yy[k] - } - } - if (m == 1 || m == 3) { - savestr = str - nfull = 0 - split("",yysave) - for (type in TYPES) { - ntypex = 0 - for (k in yy) { - split(yy[k], z, ":") - if (z[2] == type) - ntypex++ - } - if (ntypex == NARCHES[type]) { - if (str) str = str " || " - str = str "defined(__module__" type ")" - for (k in yy) { - split(yy[k], z, ":") - if (z[2] == type) { - yysave[k] = yy[k] - delete yy[k] - } - } - nfull++ - } else - NOTYPE = type - } - if (m < 2 && nfull > 1 && nfull == NTOTALTYPES - 1) { - str = savestr - for (k in yysave) - yy[k] = yysave[k] - if (str) str = str " || " - str = "!defined(__module__" NOTYPE ")" - for (k in yy) { - split(yy[k], z, ":") - if (z[2] != NOTYPE) - delete yy[k] - } - } - } - for (k in yy) { - split(yy[k], z, ":") - if (str) str = str " || " - str = str "defined(__module__" z[1] "_" z[2] ")" - } - if (m == 0 || length(str) < length(shorteststr)) - shorteststr = str - } - str = shorteststr - if (VALUE == "__undefined__") - curlines[str] = "#undef " SYMBOL "\n" - else if (VALUE == "__novalue__") - curlines[str] = "#define " SYMBOL "\n" - else - curlines[str] = "#define " SYMBOL " " VALUE "\n" - if (!lines[str]) - append = 0 - } - if (append) { - for (str in curlines) - if (curlines[str]) - lines[str] = lines[str] curlines[str] - } else { - if (lines["1"]) - printf "%s", lines["1"] - else if (j > 0) { - ifstr = "#if " - for (str in lines) - if (lines[str] && str != lastelse) { - printf "%s %s\n%s", ifstr, str, lines[str] - ifstr = "#elif " - } - if (lastelse != "") - printf "#else\n%s", lines[lastelse] - printf "#endif\n" - } - split("",lines) - lastelse = "" - for (str in curlines) - if (curlines[str]) { - lines[str] = curlines[str] - if (totalsum == NTOTAL && length(str) > length(lastelse)) { - lastelse = str - } - } - } - } - if (lines["1"]) - printf "%s", lines["1"] - else if (j > 0) { - ifstr = "#if " - for (str in lines) - if (lines[str] && str != lastelse) { - printf "%s %s\n%s", ifstr, str, lines[str] - ifstr = "#elif " - } - if (lastelse != "") - printf "#else\n%s", lines[lastelse] - printf "#endif\n" - } - } -} diff --git a/build/linux-merge-modules.awk b/build/linux-merge-modules.awk deleted file mode 100644 index babc815..0000000 --- a/build/linux-merge-modules.awk +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/awk -f -{ - # lines in input look like ARCH TYPE path/to/TYPE/ARCH/modules/foo.ver - ARCH=$1 - ARCHES[ARCH]=1 - TYPE=$2 - TYPES[TYPE]=1 - NTOTAL++ - NARCHES[TYPE]++ - NTYPES[ARCH]++ - FILE=$3 - - # read files that look like pairs of repeating - # #define __ver_foo hexstring - # #define foo _set_ver(foo) - while ((getline < FILE) > 0) { - if ($0 ~ /^[ ]*$/) - continue - if ($1 != "#define" || $2 !~ /^__ver_/) - exit 1 - - # this is a "#define __ver_foo somehex" line - SYMBOL=gensub(/^__ver_/,"","",$2) - VALUE=gensub(/^(smp_|2gig_|smp2gig_)/,"","",$3) - VALUE=gensub(/^(smp|2gig|smp2gig)/,"","",VALUE) - values[SYMBOL,ARCH,TYPE]=VALUE - - # skip the "#define foo _set_ver(foo)" line - if ((getline < FILE) <= 0) - exit 2 - if ($1 != "#define" || $2 != SYMBOL || $3 != "_set_ver(" SYMBOL ")") - exit 3 - } - close(FILE) -} -END { - count=0 - for (key in values) - if (values[key]) { - count++ - split(key,x,SUBSEP) - SYMBOL=x[1] - ARCH=x[2] - TYPE=x[3] - - # (re)initialize a few arrays to have no elements - split("",x) - split("",ntype) - split("",total) - - totalsum=0 - for (arch in ARCHES) - for (type in TYPES) - if (values[SYMBOL,arch,type]) { - VALUE = values[SYMBOL,arch,type] - values[SYMBOL,arch,type] = "" - ntype[VALUE,type] += 1 - total[VALUE] += 1 - if (x[VALUE]) - x[VALUE] = x[VALUE] " " - x[VALUE] = x[VALUE] arch ":" type - } - ifstr="#if " - for (VALUE in x) { - if (total[VALUE] == NTOTAL) { - # there is only one checksum for this symbol - printf "#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE - printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL - break - } - - totalsum += total[VALUE] - if (totalsum == NTOTAL && ifstr == "#elif") { - # this is the last unique checksum for this symbol - printf "#else\n#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE - printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL - break - } - - # there must be more than one checksum still to - # print for this symbol - str="" - split(x[VALUE],y) - for (type in TYPES) - if (ntype[VALUE,type] == NARCHES[type]) { - if (str) str = str " || " - str = str "defined(__module__" type ")" - for (k in y) { - split(y[k], z, ":") - if (z[2] == type) - delete y[k] - } - } - for (arch in ARCHES) { - narch=0 - for (k in y) { - split(y[k], z, ":") - if (z[1] == arch) - narch++ - } - if (narch == NTYPES[arch]) { - if (str) str = str " || " - str = str "defined(__module__" arch ")" - for (k in y) { - split(y[k], z, ":") - if (z[1] == arch) - delete y[k] - } - } - } - for (k in y) { - split(y[k], z, ":") - if (str) str = str " || " - str = str "defined(__module__" z[1] "_" z[2] ")" - } - printf "%s %s\n#define __ver_%s\t_ver_str(%s)\n", ifstr, str, SYMBOL, VALUE - printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL - ifstr="#elif " - } - if (ifstr == "#elif ") - printf "#endif\n" - } - if (!count) - printf "\n" -} diff --git a/build/linux-rhconfig.h b/build/linux-rhconfig.h deleted file mode 100644 index a7aa424..0000000 --- a/build/linux-rhconfig.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Try to be a little smarter about which kernel are we currently running - */ - -#ifndef __rh_config_h__ -#define __rh_config_h__ - -/* - * First, get the version string for the running kernel from - * /boot/kernel.h - initscripts should create it for us - */ - -#include "/boot/kernel.h" - -#if defined(__BOOT_KERNEL_SMP) && (__BOOT_KERNEL_SMP == 1) -#define __module__smp -#endif /* __BOOT_KERNEL_SMP */ - -#if defined(__BOOT_KERNEL_BOOT) && (__BOOT_KERNEL_BOOT == 1) -#define __module__BOOT -#endif /* __BOOT_KERNEL_BOOT */ - -#if defined(__BOOT_KERNEL_BOOTSMP) && (__BOOT_KERNEL_BOOTSMP == 1) -#define __module__BOOTsmp -#endif /* __BOOT_KERNEL_BOOTSMP */ - -#if defined(__BOOT_KERNEL_ENTERPRISE) && (__BOOT_KERNEL_ENTERPRISE == 1) -#define __module__enterprise -#endif /* __BOOT_KERNEL_ENTERPRISE */ - -#if defined(__BOOT_KERNEL_BIGMEM) && (__BOOT_KERNEL_BIGMEM == 1) -#define __module__bigmem -#endif /* __BOOT_KERNEL_BIGMEM */ - -#if defined(__BOOT_KERNEL_DEBUG) && (__BOOT_KERNEL_DEBUG == 1) -#define __module__debug -#endif /* __BOOT_KERNEL_DEBUG */ - -#if !defined(__module__smp) && !defined(__module__BOOT) && !defined(__module__BOOTsmp) && !defined(__module__enterprise) && !defined(__module__bigmem) && !defined(__module__debug) -#define __module__up -#endif /* default (BOOT_KERNEL_UP) */ - -#ifdef __i386__ -# if defined(__MODULE_KERNEL_i586) && (__MODULE_KERNEL_i586 == 1) -# define __module__i586 -# ifdef __module__up -# define __module__i586_up -# endif -# ifdef __module__smp -# define __module__i586_smp -# endif -# ifdef __module__BOOT -# define __module__i586_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__i586_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__i586_enterprise -# endif -# ifdef __module__debug -# define __module_i586_debug -# endif -# elif defined(__MODULE_KERNEL_i686) && (__MODULE_KERNEL_i686 == 1) -# define __module__i686 -# ifdef __module__up -# define __module__i686_up -# endif -# ifdef __module__smp -# define __module__i686_smp -# endif -# ifdef __module__BOOT -# define __module__i686_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__i686_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__i686_enterprise -# endif -# ifdef __module__bigmem -# define __module__i686_bigmem -# endif -# ifdef __module__debug -# define __module_i686_debug -# endif -# elif defined(__MODULE_KERNEL_athlon) && (__MODULE_KERNEL_athlon == 1) -# define __module__athlon -# ifdef __module__up -# define __module__athlon_up -# endif -# ifdef __module__smp -# define __module__athlon_smp -# endif -# ifdef __module__BOOT -# define __module__athlon_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__athlon_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__athlon_enterprise -# endif -# ifdef __module__bigmem -# define __module__athlon_bigmem -# endif -# ifdef __module__debug -# define __module__athlon_debug -# endif -# else -# define __module__i386 -# ifdef __module__up -# define __module__i386_up -# endif -# ifdef __module__smp -# define __module__i386_smp -# endif -# ifdef __module__BOOT -# define __module__i386_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__i386_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__i386_enterprise -# endif -# ifdef __module__debug -# define __module__i386_debug -# endif -# endif -#endif - -#ifdef __sparc__ -# ifdef __arch64__ -# define __module__sparc64 -# ifdef __module__up -# define __module__sparc64_up -# endif -# ifdef __module__smp -# define __module__sparc64_smp -# endif -# ifdef __module__BOOT -# define __module__sparc64_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__sparc64_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__sparc64_enterprise -# endif -# ifdef __module__debug -# define __module__sparc64_debug -# endif -# else -# define __module__sparc -# ifdef __module__up -# define __module__sparc_up -# endif -# ifdef __module__smp -# define __module__sparc_smp -# endif -# ifdef __module__BOOT -# define __module__sparc_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__sparc_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__sparc_enterprise -# endif -# ifdef __module__debug -# define __module__sparc_debug -# endif -# endif -#endif - -#ifdef __alpha__ -# define __module__alpha -# ifdef __module__up -# define __module__alpha_up -# endif -# ifdef __module__smp -# define __module__alpha_smp -# endif -# ifdef __module__BOOT -# define __module__alpha_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__alpha_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__alpha_enterprise -# endif -# ifdef __module__debug -# define __module__alpha_debug -# endif -#endif - -#ifdef __ia64__ -# define __module__ia64 -# ifdef __module__up -# define __module__ia64_up -# endif -# ifdef __module__smp -# define __module__ia64_smp -# endif -# ifdef __module__BOOT -# define __module__ia64_BOOT -# endif -# ifdef __module__BOOTsmp -# define __module__ia64_BOOTsmp -# endif -# ifdef __module__enterprise -# define __module__ia64_enterprise -# endif -# ifdef __module__debug -# define __module__ia64_debug -# endif -#endif - -#if defined(__module__smp) || defined(__module__BOOTsmp) || defined(__module__enterprise) || defined(__module__bigmem) -#define _ver_str(x) smp_ ## x -#else -#define _ver_str(x) x -#endif - -#define RED_HAT_LINUX_KERNEL 1 - -#endif /* __rh_config_h__ */ diff --git a/build/lmake b/build/lmake deleted file mode 100755 index c110acf..0000000 --- a/build/lmake +++ /dev/null @@ -1,658 +0,0 @@ -#!/bin/sh - -# option variables -DESTDIR= -KERNELDIR= -TARGET= -# Not sure what to put here -# TARGET_ARCH=$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) -TARGET_ARCH= -TARGET_CONFIG= -JOBS=1 -CONFIGURE_FLAGS= - -# commands to run -BUILD_LUSTRE=0 -BUILD_KERNEL=0 -DEPEND_KERNEL=0 -INSTALL_LUSTRE=0 -INSTALL_KERNEL=0 -SAVE_HEADERS=0 -UNPACK_KERNEL=0 - -# provided by target file -KERNEL= -SERIES= -CONFIG= -VERSION= -EXTRA_VERSION= - -BASE_ARCHS= -BIGMEM_ARCHS= -BOOT_ARCHS= -JENSEN_ARCHS= -SMP_ARCHS= -BIGSMP_ARCHS= -UP_ARCHS= - -RHBUILD=0 -SUSEBUILD=0 - -# flat-out globals -TOPDIR= -TARGET_FILE= -KERNEL_FILE= -SERIES_FILE= -CONFIG_FILE= - -canon() -{ - pushd $1 >/dev/null - echo $PWD - popd >/dev/null -} -TOPDIR=$(canon "${0%%${0##*/}}/..") - -cleanup() -{ - true -} - -fatal() -{ - cleanup - [ "$2" ] && echo - [ "$2" ] && echo "${0##*/}: $2" - exit $1 -} - -list_targets() -{ - echo -n "Available targets:" - for target in $TOPDIR/lustre/kernel_patches/targets/*.target ; do - target_file=${target##*/} - echo -n " ${target_file%%.target}" - done - echo -} - - -usage() -{ - cat <] - -Options: - - --build - same as --build-kernel --build-lustre --unpack-kernel - - --build-lustre - configure and compile lustre. Requires that --build-kernel was - already run. - - --build-kernel - configure and compile a kernel. Implies --depend-kernel. - Requires that --unpack-kernel was already run. - - --depend-kernel) - Prepares a kernel tree for building (similar to make mrproper - oldconfig dep). Requires that --unpack-kernel was already run. - - --destdir=DESTDIR - Root directory to install into (like DESTDIR with auto*). - - --extraversion=EXTRAVERSION - Overrides the target kernel\'s EXTRAVERSION text. - - -h, --help - Display this message. - - --install - same as --install-kernel --install-lustre - - --install-lustre - run make install in the Lustre tree. - - --install-kernel - install the kernel image and modules. - - -j jobs - This works just like the -j option to make, and is passed to make - when building. - - --kerneldir=KERNELDIR - Directory containing linux source tarballs. - - --target=TARGET - Name of the configuration to use. The available targets are - listed below. - - --target-arch=ARCH - Specifies an architecture to use when choosing a kernel config - file. Default is i386. - - --target-config=CONFIG - Specifies a special option (such as smp, bigsmp, bigmem, or BOOT) - to use when choosing a kernel config file. This also modifies the - kernel version and modules directory. - - --unpack-kernel - Untars and patches the kernel source. - - The order that commands (--build-lustre, --unpack-kernel) are - specified on the command line is ignored; ${0##*/} will always - execute them in the correct order (unpack, then build, then install - etc.). - -EOF - list_targets - - fatal "$1" "$2" -} - -check_options() -{ - (( $BUILD_LUSTRE || $BUILD_KERNEL || $DEPEND_KERNEL || \ - $INSTALL_LUSTRE || $INSTALL_KERNEL || $SAVE_HEADERS || \ - $UNPACK_KERNEL )) || \ - fatal 1 "No commands specified." - - if (( $UNPACK_KERNEL )) ; then - [ "$KERNELDIR" ] || \ - fatal 1 "A kernel directory must be specified with --kerneldir." - [ -d "$KERNELDIR" ] || \ - fatal 1 "$KERNELDIR is not a directory." - fi - - if (( $INSTALL_LUSTRE || $INSTALL_KERNEL || $SAVE_HEADERS )) ; then - [ -z "$DESTDIR" -o -d "$DESTDIR" ] || \ - fatal 1 "$DESTDIR is not a directory." - fi - - [ "$TARGET" ] || usage 1 "A target must be specified with --target." - TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target" - [ -r "$TARGET_FILE" ] || \ - fatal 1 "Target '$TARGET' was not found. Try --list-targets." - - if [ -z "$JOBS" -o "$JOBS" -lt "1" ] ; then - JOBS=1 - fi -} - -get_lustre_version() -{ - lustre_patch=$(grep lustre_version "$SERIES_FILE" 2>/dev/null) - [ "$lustre_patch" ] || \ - fatal 1 "Could not determine Lustre version from $SERIES series." - - awk '/^\+#define LUSTRE_KERNEL_VERSION /{ print $3 }' \ - "$TOPDIR/lustre/kernel_patches/patches/$lustre_patch" 2>/dev/null -} - -load_target() -{ - EXTRA_VERSION_save="$EXTRA_VERSION" - - . "$TARGET_FILE" - - [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel." -# Suse 2.6 has our patches in already -# [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series." -# [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config." - [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify the kernel version." - - if [ "$KERNELDIR" ] ; then - KERNEL_FILE="$KERNELDIR/$KERNEL" - [ -r "$KERNELDIR/$KERNEL" ] || \ - fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR." - fi - - if [ "$SERIES" ]; then - SERIES_FILE="$TOPDIR/lustre/kernel_patches/series/$SERIES" - [ -r "$SERIES_FILE" ] || \ - fatal 1 "Target $TARGET's series $SERIES missing from $TOPDIR/lustre/kernel_patches/series." - fi - - TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS} - CONFIG_TARGET="$TARGET-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}" - CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config" - [ -r "$CONFIG_FILE" ] || - fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/lustre/kernel_patches/configs." - - if [ "$EXTRA_VERSION_save" ] ; then - EXTRA_VERSION="$EXTRA_VERSION_save" - else - EXTRA_VERSION="${EXTRA_VERSION}_lustre.$(get_lustre_version)" - fi -} - -tarflags() -{ - case "$1" in - '') - fatal 1 "tarflags(): File name argument missing." - ;; - *.tar.gz) - echo 'zxf' - ;; - *.tar.bz2) - echo 'jxf' - ;; - *) - fatal 1 "tarflags(): Unrecognized tar extension in file: $1" - ;; - esac -} - -untar() -{ - echo "Untarring ${1##*/}..." - tar $(tarflags $1) $1 -} - - -extract_kernel() -{ - (( $UNPACK_KERNEL )) || return 0 - pushd "$TOPDIR" >/dev/null - if [ -d linux ] ; then - [ -L linux ] && rm -rf $(readlink linux) - rm -rf linux - fi - untar "$KERNEL_FILE" - [ -d linux ] || ln -sf linux* linux - popd >/dev/null -} - -patch_kernel() -{ - (( $UNPACK_KERNEL )) || return 0 - [ "$SERIES" ] || return 0 - pushd "$TOPDIR/linux" >/dev/null - echo -n "Applying patch" - for patch in $(<"$SERIES_FILE") ; do - PATCH_FILE="$TOPDIR/lustre/kernel_patches/patches/$patch" - [ -r "$PATCH_FILE" ] || \ - fatal 1 "Patch file not found: $patch" - echo -n " $patch" - patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch." - done - echo - popd >/dev/null -} - -set_make() -{ - MAKE="make -s" - if [ "$CC" ] ; then - MAKE="$MAKE CC=$CC" - fi - if [ "$ARCH" ] ; then - MAKE_ARCH="$MAKE ARCH=$ARCH" - else - case $TARGET_ARCH in - i?86) - ;; - *) - MAKE_ARCH="$MAKE ARCH=$TARGET_ARCH" - ;; - esac - fi - MAKE_J="$MAKE -j $JOBS" -} - -depend_kernel() -{ - (( $DEPEND_KERNEL )) || return 0 - # we need to override $CC at make time, since there is no - # configure - set_make - pushd "$TOPDIR/linux" >/dev/null - echo "Overriding EXTRAVERSION in kernel..." - perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${EXTRA_VERSION}${TARGET_CONFIG}/" Makefile - echo "Making depend in $PWD..." - $MAKE mrproper || fatal 1 "Error running make mrproper" - cp "$CONFIG_FILE" .config - for oc in oldconfig_nonint silentoldconfig oldconfig ; do - if grep -q "$oc" Makefile ; then - OLDCONFIG="$oc" - break - fi - done - $MAKE $OLDCONFIG || fatal 1 "Error running make oldconfig" - case "$VERSION" in - 2.6*) - SYMLINKS="include/asm" - ;; - 2.4*) - SYMLINKS="symlinks" - ;; - esac - $MAKE $SYMLINKS - $MAKE_J dep || fatal 1 "Error running make dep" - $MAKE include/linux/version.h || fatal 1 "Error making include/linux/version.h" -} - -build_kernel() -{ - (( $BUILD_KERNEL )) || return 0 - set_make - echo "Building kernel in $PWD..." - case "$TARGET_ARCH" in - i386 | i586 | i686 | athlon | x86_64) - $MAKE_J bzImage || fatal 1 "Error making bzImage." - ;; - ppc | ppc64) - $MAKE_J vmlinux || fatal 1 "Error making vmlinux." - ;; - *) - $MAKE_J boot || fatal 1 "Error making boot." - ;; - esac - $MAKE_J modules || fatal 1 "Error building modules." - - popd >/dev/null -} - -configure_lustre() -{ - (( $BUILD_LUSTRE )) || return 0 - pushd "$TOPDIR" >/dev/null - [ -f Makefile ] && make -s clean - [ -f configure ] || sh ./autogen.sh - ./configure --with-linux=$PWD/linux $CONFIGURE_FLAGS || \ - fatal 1 "Error configuring Lustre." - popd >/dev/null -} - -build_lustre() -{ - (( $BUILD_LUSTRE )) || return 0 - set_make - pushd "$TOPDIR" >/dev/null - $MAKE_J || fatal 1 "Error building Lustre." - popd >/dev/null -} - -install_kernel() -{ - (( $INSTALL_KERNEL )) || return 0 - set_make - FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" - pushd "$TOPDIR/linux" >/dev/null - mkdir -p "$DESTDIR/boot" - - install -m 644 System.map "$DESTDIR/boot/System.map-${FULL_VERSION}" - # install -m 644 module-info ... - install -m 644 "$CONFIG_FILE" "$DESTDIR/boot/config-${FULL_VERSION}" - - mkdir -p "$DESTDIR/dev/shm" - mkdir -p "$DESTDIR/lib/modules/${FULL_VERSION}" - - $MAKE INSTALL_MOD_PATH="$DESTDIR" KERNELRELEASE="$FULL_VERSION" \ - -s modules_install || \ - fatal 1 "Error installing modules." - - case "$TARGET_ARCH" in - i386 | i586 | i686 | athlon) - cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}" - cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/" - ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}" - ;; - x86_64) - cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}" - cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/" - ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}" - ;; - ppc | ppc64) - cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}" - ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" - ;; - ia64) - gzip -cfv vmlinux > vmlinuz - mkdir -p "$DESTDIR/boot/efi/redhat" - install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/" - install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}" - ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}" - ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}" - ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}" - ;; - *) - cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}" - cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" - ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}" - - ;; - esac - if [ -e init/kerntypes.o ] ; then - cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}" - fi - - popd >/dev/null -} - -install_lustre() -{ - (( $INSTALL_LUSTRE )) || return 0 - set_make - FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" - pushd "$TOPDIR" >/dev/null - $MAKE -s install "DESTDIR=$DESTDIR" KERNELRELEASE="$FULL_VERSION" || fatal 1 "Error installing Lustre." - popd >/dev/null -} - -build_kms() -{ - (( $BUILD_KERNEL )) || return 0 - (( $SUSEBUILD )) || return 0 - set_make - FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" - mkdir -p "${TOPDIR}/modules-${FULL_VERSION}" - for dir in /usr/src/kernel-modules/* ; do - # we are replacing lustre-lite, so don't include it - if [ ${dir##*/} != "lustre-lite" -a -e $dir/Makefile ]; then - build_dir="${TOPDIR}/modules-${FULL_VERSION}/${dir##*/}" - cp -a $dir $build_dir - # these modules are terrible, and don't all build - $MAKE_J -C $build_dir modules KERNEL_SOURCE="${TOPDIR}/linux" - fi - done -} - -symver() -{ - local file=$1 name=${1%.ko} - nm $file \ - | sed -ne 's,^0*\([0-9a-f]\{8\}\) A __crc_\(.*\),0x\1\t\2\t'"$name"',p' -} - -install_kms() -{ - (( $INSTALL_KERNEL )) || return 0 - (( $SUSEBUILD )) || return 0 - set_make - FULL_VERSION="${VERSION}-${EXTRA_VERSION}${TARGET_CONFIG}" - for build_dir in "${TOPDIR}/modules-${FULL_VERSION}/*" ; do - [ -d $build_dir ] || continue - # these modules are terrible, and don't all build - $MAKE -C $build_dir KERNEL_SOURCE="${TOPDIR}/linux" INSTALL_MOD_PATH="$DESTDIR" - done - ( symver vmlinux - moddir="${DESTDIR}/lib/modules/${FULL_VERSION}" - cd $moddir/kernel - for module in $(find * -name '*.ko'); do - symver $module - done - cd $moddir - for module in $(find * -path 'kernel/*' -prune -o \ - -name '*.ko' -print); do - symver $module - done - ) | sort -u -k2 \ - | gzip -c9 > "${DESTDIR}/boot/symvers-${VERSION}-${EXTRA_VERSION}-${TARGET_ARCH}${TARGET_CONFIG}.gz" -} - -save_headers() -{ - echo "Saving headers for $1 $2..." - pushd linux >/dev/null - - KVERREL="${VERSION}-${EXTRA_VERSION}" - # deal with the kernel headers that are version specific - - saveddir="$RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/$2/$1" - mkdir -p "$saveddir" - install -m 644 include/linux/autoconf.h "$saveddir/autoconf.h" - install -m 644 include/linux/version.h "$saveddir/version.h" - mv include/linux/modules "$saveddir/" - echo $2 $1 ../../savedheaders/$2/$1/ >> $RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/list - popd >/dev/null -} - -save_all_headers() -{ - (( $SAVE_HEADERS )) || return 0 - - for arch in $BIGMEM_ARCHS ; do - save_headers bigmem $arch - done - - for arch in $BOOT_ARCHS ; do - save_headers BOOT $arch - done - - for arch in $JENSEN_ARCHS ; do - save_headers jensen $arch - done - - for arch in $SMP_ARCHS ; do - save_headers smp $arch - done - - for arch in $BIGSMP_ARCHS ; do - save_headers bigsmp $arch - done - for arch in $UP_ARCHS ; do - save_headers up $arch - done -} - -longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:" -longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:" -longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel" - -options=$(getopt -o hj: -l "$longopts" -- "$@") - -eval set -- "$options" - -while [ "$1" ] ; do - case "$1" in - '') - usage 1 - ;; - --build) - BUILD_LUSTRE=1 - BUILD_KERNEL=1 - DEPEND_KERNEL=1 - UNPACK_KERNEL=1 - shift - ;; - --build-lustre) - BUILD_LUSTRE=1 - shift - ;; - --build-kernel) - BUILD_KERNEL=1 - DEPEND_KERNEL=1 - shift - ;; - --depend-kernel) - DEPEND_KERNEL=1 - shift - ;; - --destdir) - DESTDIR=$2 - shift 2 - ;; - --extraversion) - EXTRA_VERSION=$2 - shift 2 - ;; - --help | -h) - usage 0 - ;; - --install) - INSTALL_LUSTRE=1 - INSTALL_KERNEL=1 - shift - ;; - --install-lustre) - INSTALL_LUSTRE=1 - shift - ;; - --install-kernel) - INSTALL_KERNEL=1 - shift - ;; - -j) - JOBS=$2 - shift 2 - ;; - --kerneldir) - KERNELDIR=$2 - shift 2 - ;; - --save-headers) - SAVE_HEADERS=1 - shift - ;; - --target) - TARGET=$2 - shift 2 - ;; - --target-arch) - TARGET_ARCH=$2 - shift 2 - ;; - --target-config) - TARGET_CONFIG=$2 - shift 2 - ;; - --unpack-kernel) - UNPACK_KERNEL=1 - shift - ;; - --) - shift - CONFIGURE_FLAGS=$@ - break - ;; - *) - usage 1 "Unrecognized option: $1" - ;; - esac -done - -check_options -load_target - -extract_kernel -patch_kernel - -depend_kernel -build_kernel - -configure_lustre -build_lustre - -build_kms - -install_kernel -install_lustre - -install_kms - -save_all_headers - -exit 0 diff --git a/build/lustre-kernel-2.4.spec.in b/build/lustre-kernel-2.4.spec.in deleted file mode 100644 index 1c4e3af..0000000 --- a/build/lustre-kernel-2.4.spec.in +++ /dev/null @@ -1,983 +0,0 @@ -Summary: The Linux kernel (the core of the Linux operating system) - -# Versions of various parts - -# -# Polite request for people who spin their own kernel rpms: -# please modify the "release" field in a way that identifies -# that the kernel isn't the stock RHL kernel, for example by -# adding some text to the end of the version number. -# -%define kversion @KERNEL_VERSION@ -%define kextraver @KERNEL_EXTRA_VERSION@ -%define release @KERNEL_RELEASE@ -# /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL} -%define kslnk linux-2.4 - -# groups of related archs -%define all_x86 i386 i686 i586 athlon -#define all_x86 i686 i386 i586 athlon - -%define nptlarchs %{all_x86} -#define nptlarchs noarch -%define rhbuild @RHBUILD@ -%define susebuild @SUSEBUILD@ -%define linux26 @LINUX26@ - -# disable build root strip policy -%define __spec_install_post /usr/lib/rpm/brp-compress || : -# -# RPM foo magic -%define _missing_doc_files_terminate_build 0 -%define _unpackaged_files_terminate_build 0 -%define debug_package %{nil} - -# Enable this to build a board-specific kernel configuration -# some architectures have LOTS of different setups and this -# is a way to deal with that cleanly. -# -#define targetboard assabet -%define dashtargetboard %{?targetboard:-%{targetboard}} -%define withtargetboard 0 -%{?targetboard: %{expand: %%define withtargetboard 1}} - -# Override generic defaults with per-arch defaults (which can -# themselves be overridden with --with/--without). These must -# ONLY be "0", never "1" - -%define buildbase 0 -%define buildbigmem 0 -%define buildBOOT 0 -%define buildjensen 0 -%define buildsmp 0 -%define buildbigsmp 0 -%define buildup 0 -%define buildsrc 0 - -%ifarch @BASE_ARCHS@ -%define buildbase 1 -%endif - -%ifarch @BIGMEM_ARCHS@ -%define buildbigmem 1 -%endif - -%ifarch @BOOT_ARCHS@ -%define buildBOOT 1 -%endif - -%ifarch @JENSEN_ARCHS@ -%define buildjensen 1 -%endif - -%ifarch @SMP_ARCHS@ -%define buildsmp 1 -%endif - -%ifarch @BIGSMP_ARCHS@ -%define buildbigsmp 1 -%endif - -%ifarch @UP_ARCHS@ -%define buildup 1 -%endif - -# For board-specific kernels, build only the normal kernel (which may actually be smp, not up). -%if %{withtargetboard} -%define buildsmp 0 -%define buildbigsmp 0 -%define buildBOOT 0 -%define buildbigmem 0 -%define buildjensen 0 -%endif - -%if 0 -Second, per-architecture exclusions (ifarch) -%ifarch i386 -%define buildsmp 0 -%endif -%ifarch ia64 -%define buildBOOT 0 -%endif -%endif - -# we can't test values inline, only whether a macro exists -%{expand: %%define buildup_%{buildup} yadda} -%{expand: %%define buildsmp_%{buildsmp} yadda} -%{expand: %%define buildbigsmp_%{buildbigsmp} yadda} -%{expand: %%define buildBOOT_%{buildBOOT} yadda} -%{expand: %%define buildbigmem_%{buildbigmem} yadda} -%{expand: %%define buildjensen_%{buildjensen} yadda} -%{expand: %%define ikd_%{ikd} yadda} -%{expand: %%define ibcs_%{ibcs} yadda} -%{expand: %%define debuglevel_%{debugging} yadda} - -%{expand: %%define kernel_conflicts ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 0.3.1, cipe < 1.4.5, tux < 2.1.0, kudzu <= 0.92, e2fsprogs < 1.22, initscripts < 5.84, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0, oprofile < 0.4} - -%if %{rhbuild} -%define BOOT_kernel_prereq fileutils, modutils >= 2.4.18 -%define kernel_prereq %{BOOT_kernel_prereq}, initscripts >= 5.83, mkinitrd >= 3.2.6 -%endif - -%ifarch ia64 -%define initrd_dir /boot/efi/redhat -%else -%define initrd_dir /boot -%endif - -%ifarch %{all_x86} x86_64 -%define kernel_glob vmlinu?-%{KVERREL} -%endif -%ifarch ia64 -# , no GLOB_BRACE for filelists, efi needs to be done separately -%define kernel_glob vmlinuz-%{KVERREL} -%endif -%ifarch alpha -%define kernel_glob vmlinu?-%{KVERREL} -%endif - -Name: kernel -Version: %{kversion} -Release: %{release}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg} -%define KVERREL %{PACKAGE_VERSION}-%{kextraver}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg} -License: GPL -Group: System Environment/Kernel -ExclusiveArch: %{all_x86} x86_64 ia64 ppc -ExclusiveOS: Linux -Obsoletes: kernel-modules, kernel-sparc -Provides: kernel = %{version} -BuildConflicts: rhbuildsys(DiscFree) < 500Mb -%ifarch %{all_x86} ia64 x86_64 -Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3 -%endif -Autoreqprov: no -%if %{rhbuild} -Prereq: %{kernel_prereq} -Conflicts: %{kernel_conflicts} - -BuildPreReq: patch >= 2.5.4, bash >= 2.03, sh-utils, gnupg, tar -BuildPreReq: bzip2, findutils, dev, gzip, m4 -%endif - -Vendor: Cluster File Systems, Inc. -URL: http://www.kernel.org/ -Buildroot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root - -Source0: @LUSTRE_SOURCE@ -Source1: @KERNEL_SOURCE@ -Source2: external-patches.tar.gz - -Source15: linux-rhconfig.h -Source16: linux-merge-config.awk -Source17: linux-merge-modules.awk - -Source25: suse-functions.sh -Source26: suse-post.sh -Source27: suse-postun.sh -Source28: suse-trigger-script.sh.in - -%package source -Summary: The source code for the Linux kernel. -Group: Development/System -Prereq: fileutils -Requires: gawk -Requires: gcc >= 2.96-98 -Autoreqprov: 0 - -%package doc -Summary: Various documentation bits found in the kernel source. -Group: Documentation - -%description -The kernel package contains the Linux kernel (vmlinuz), the core of a -Linux operating system. The kernel handles the basic functions of the -operating system: memory allocation, process allocation, device input -and output, etc. - -%description source -The kernel-source package contains the source code files for the Linux -kernel. These source files are needed to build custom/third party device -drivers. The source files can also be used to build a custom kernel that is -better tuned to your particular hardware, if you are so inclined (and you -know what you're doing). - -%description doc -This package contains documentation files form the kernel -source. Various bits of information about the Linux kernel and the -device drivers shipped with it are documented in these files. - -You'll want to install this package if you need a reference to the -options that can be passed to Linux kernel modules at load time. - -%package smp -Summary: The Linux kernel compiled for SMP machines. -Group: System Environment/Kernel -Provides: module-info, kernel = %{version} -%ifarch %{all_x86} ia64 x86_64 -Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3 -%endif -%if %{rhbuild} -Prereq: %{kernel_prereq} -Conflicts: %{kernel_conflicts} -%endif - -%description smp -This package includes a SMP version of the Linux kernel. It is -required only on machines with two or more CPUs, although it should -work fine on single-CPU boxes. - -Install the kernel-smp package if your machine uses two or more CPUs. - -%package bigsmp -Summary: The Linux kernel compiled for SMP machines. -Group: System/Kernel -Provides: module-info, kernel = %{version}, k_smp4G -Obsoletes: k_smp4G -%ifarch %{all_x86} ia64 x86_64 -Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3 -%endif -%if %{rhbuild} -Prereq: %{kernel_prereq} -Conflicts: %{kernel_conflicts} -%endif - -%description bigsmp -This package includes a SMP version of the Linux kernel. It is -required only on machines with two or more CPUs, although it should -work fine on single-CPU boxes. - -Install the kernel-bigsmp package if your machine uses two or more CPUs. - -%package bigmem -Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory. -Group: System Environment/Kernel -Provides: module-info, kernel = %{version} -%ifarch %{all_x86} ia64 x86_64 -Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3 -%endif -%if %{rhbuild} -Prereq: %{kernel_prereq} -Conflicts: %{kernel_conflicts} -Obsoletes: kernel-enterprise <= 2.4.10 -%endif - -%description bigmem -This package includes a kernel that has appropriate configuration options -enabled for Pentium III machines with 4 Gigabyte of memory or more. - -%package BOOT -Summary: The version of the Linux kernel used on installation boot disks. -Group: System Environment/Kernel -Provides: kernel = %{version} -%if %{rhbuild} -Prereq: %{BOOT_kernel_prereq} -Conflicts: %{kernel_conflicts} -%endif - -%description BOOT -This package includes a trimmed down version of the Linux kernel. -This kernel is used on the installation boot disks only and should not -be used for an installed system, as many features in this kernel are -turned off because of the size constraints. - -%package BOOTsmp -Summary: The Linux kernel used on installation boot disks for SMP machines. -Group: System Environment/Kernel -Provides: kernel = %{version} -%if %{rhbuild} -Prereq: %{BOOT_kernel_prereq} -Conflicts: %{kernel_conflicts} -%endif - -%description BOOTsmp -This package includes a trimmed down version of the Linux kernel. This -kernel is used on the installation boot disks only and should not be used -for an installed system, as many features in this kernel are turned off -because of the size constraints. This kernel is used when booting SMP -machines that have trouble coming up to life with the uniprocessor kernel. - -%package jensen -Summary: The Linux Kernel compiled for the Alpha Jensen platform. -Group: System Environment/Kernel -Provides: kernel = %{version} -%if %{rhbuild} -Prereq: %{kernel_prereq} -Conflicts: %{kernel_conflicts} -%endif - -%description jensen -This package includes a kernel that has appropriate configuration -options enabled for use on the Alpha Jensen platform. The Jensen -platform is not supported in the normal generic alpha kernel support. - -%package -n lustre-lite-utils -Summary: Lustre utils for Linux -Group: Applications/System - -%description -n lustre-lite-utils -The Lustre Lite file system utilities. This includes the tools needed -to configure, mount, and administer a Lustre filesystem. This package -is necessary if you want to access a Lustre filesystem. - -# the lustre-doc files are just included as %doc wiht -# lustre-lite-utils - -#%package -n lustre-doc -#Summary: Sample Lustre configurations and documentation -#Group: Documentation - -#%description -n lustre-doc -#The Lustre book, sample configurations, and other documentation for -#Lustre. - -%package -n lustre-ldap -Summary: LDAP schema files for Lustre -Group: System Environment/Daemons - -%description -n lustre-ldap -LDAP schema files for Lustre. These are needed if you plan to store -your Lustre configuration in LDAP, rather than on disk. - -%prep -%setup -n lustre-kernel-%{version} -q -c -if [ ! -d lustre ] ; then - ln -sf lustre* lustre -fi -pushd lustre >/dev/null -if [ -s "%{SOURCE2}" ] ; then - tar zxf "%{SOURCE2}" -C lustre/kernel_patches -fi -sh -x ./build/lmake \ - --unpack-kernel \ - --target @LUSTRE_TARGET@ \ - --target-arch %{_target_cpu} \ - --kerneldir $RPM_SOURCE_DIR -popd >/dev/null - -# handle both SuSE and Red Hat's new-kernel-pkg bits -for flavor in "" smp bigmem bigsmp BOOT jensen ; do - for when in pre preun post postun ; do - script="${when}${flavor}.sh" - echo "if [ -f /etc/SuSE-release ] ; then" > ${script} - sed -e "s/@when@/$when/g" -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE28} >> ${script} - cat %{SOURCE25} >> ${script} - case $when in - post) - sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE26} >> ${script} - ;; - postun) - sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE27} >> ${script} - ;; - esac - echo "exit 0; fi" >> ${script} - case $when in - post) - if [ -z "${flavor}" ] ; then - cat >> ${script} <> ${script} <> ${script} </dev/null >/dev/null || : -exit 0 -EOF - ;; - preun) - cat >> ${script} < /dev/null > /dev/null || : -rm -f /lib/modules/%{KVERREL}${flavor}/modules.* -if [ -x /sbin/new-kernel-pkg ] ; then - /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}${flavor} -fi -EOF - ;; - esac - done -done - -%build -# if RPM_BUILD_NCPUS unset, set it -if [ -z "$RPM_BUILD_NCPUS" ] ; then - RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat || :) - if [ $RPM_BUILD_NCPUS -eq 0 ] ; then - RPM_BUILD_NCPUS=1 - fi - if [ $RPM_BUILD_NCPUS -gt 8 ] ; then - RPM_BUILD_NCPUS=8 - fi -fi - -rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT - -DependKernel() -{ - target_config=${1:+--target-config $1} - sh -x ./build/lmake \ - --depend-kernel \ - --target @LUSTRE_TARGET@ \ - --target-arch %{_target_cpu} \ - ${target_config} \ - --extraversion %{kextraver} \ - -j $RPM_BUILD_NCPUS -} - -BuildKernel() -{ - target_config=${1:+--target-config $1} - sh -x ./build/lmake \ - --build-kernel --build-lustre \ - --install \ - --target @LUSTRE_TARGET@ \ - --target-arch %{_target_cpu} \ - ${target_config} \ - --extraversion %{kextraver} \ - --kerneldir $RPM_SOURCE_DIR \ - -j $RPM_BUILD_NCPUS \ - --destdir $RPM_BUILD_ROOT \ - -- --enable-modules \ - --disable-doc --disable-tests \ - --disable-utils --disable-liblustre \ - --sysconfdir=%{_sysconfdir} \ - --mandir=%{_mandir} \ - @CONFIGURE_FLAGS@ -} - -BuildLustre() -{ - target_config=${1:+--target-config $1} - sh -x ./build/lmake \ - --build-lustre \ - --install-lustre \ - --target @LUSTRE_TARGET@ \ - --target-arch %{_target_cpu} \ - ${target_config} \ - --extraversion %{kextraver} \ - --kerneldir $RPM_SOURCE_DIR \ - -j $RPM_BUILD_NCPUS \ - --destdir $RPM_BUILD_ROOT \ - -- --enable-utils \ - --disable-doc --disable-tests \ - --disable-modules --disable-liblustre \ - --sysconfdir=%{_sysconfdir} \ - --mandir=%{_mandir} \ - @CONFIGURE_FLAGS@ -} - -SaveHeaders() -{ - sh -x ./build/lmake \ - --save-headers \ - --target @LUSTRE_TARGET@ \ - --target-arch %{_target_cpu} \ - --extraversion %{kextraver} \ - --destdir $RPM_BUILD_ROOT -} - -pushd lustre >/dev/null - -%if %{buildbigmem} -BuildKernel bigmem -%endif - -%if %{buildBOOT} -BuildKernel BOOT -%endif - -%if %{buildjensen} -BuildKernel jensen -%endif - -%if %{buildsmp} -BuildKernel smp -%endif - -%if %{buildbigsmp} -BuildKernel bigsmp -%endif - -%if %{buildup} -BuildKernel -%endif - -%if %{buildbase} -BuildLustre -SaveHeaders -%endif - -popd >/dev/null - -%install -pushd lustre >/dev/null -# it's already installed, so just clean up some things that are rpm -# specific -for i in $RPM_BUILD_ROOT/lib/modules/* ; do - rm -f $i/modules.* - rm -f $i/build - ln -sf ../../../usr/src/linux-%{KVERREL} $i/build -%ifarch %{ntplarchs} - # remove legacy pcmcia symlink that's no longer useful - rm -rf $i/pcmcia -%endif -done - -# mark the vmlinux* non-executable to fool strip-to-file -chmod a-x $RPM_BUILD_ROOT/boot/vmlinux* - -BuildObj () -{ - flavor=$1 - if [ $flavor = "up" ] ; then - flavext="" - else - flavext="-$flavor" - fi - c="$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}" - o="${c}-obj/%{_target_cpu}/$flavor" - mkdir -p $o - cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}${flavext}.config \ - $o/.config - for oc in oldconfig_nonint silentoldconfig oldconfig ; do - if grep -q "$oc" Makefile ; then - OLDCONFIG="$oc" - break - fi - done - MAKE="make -s O=$o -C ${c}" - $MAKE $OLDCONFIG - $MAKE prepare-all - $MAKE clean - rm -rf $o/.config.old $o/include/config - # Replace the Makefile in the object directory with a version - # that has relative path names. - read VERSION PATCHLEVEL SUBLEVEL <<-EOF -$(set -- 2.6.5 ; echo ${*//./ }) -EOF - source scripts/mkmakefile \ - ../../../linux-%{KVERREL} \ - ../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor \ - $VERSION \ - $PATCHLEVEL \ - > $o/Makefile - zcat "$RPM_BUILD_ROOT/boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz" \ - > $o/Module.symvers -} - -## -## do -source package cleanup/install -## -%if %{buildbase} - pushd linux >/dev/null - mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep - tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile - ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux - # install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - - #clean up the destination - make -s mrproper -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs - mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs - cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@*.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs - %if %{linux26} - # this only works because CFS only builds one kernel per target/arch per kernel-source rpm - objdir=$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}-obj - mkdir -p $objdir - %if %{buildbigmem} - BuildObj bigmem - %endif - %if %{buildBOOT} - BuildObj BOOT - %endif - %if %{buildjensen} - BuildObj jensen - %endif - %if %{buildsmp} - BuildObj smp - %endif - %if %{buildbigsmp} - BuildObj bigsmp - %endif - %if %{buildup} - BuildObj up - %endif - # Remove $RPM_BUILD_ROOT prefix from symlinks. - for link in $(find $objdir -type l); do - target=$(readlink $link) - rm -f $link - ln -s ${target/$RPM_BUILD_ROOT/} $link - done - %else # 2.4 rh-style - cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config - for oc in oldconfig_nonint silentoldconfig oldconfig ; do - if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then - OLDCONFIG="$oc" - break - fi - done - make -s $OLDCONFIG -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - %if %{linux26} - make -s include/asm -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - %else - make -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - %endif - make -s include/linux/version.h -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - - #this generates modversions info which we want to include and we may as - #well include the depends stuff as well, after we fix the paths - make -s depend -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} - find $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} -name ".*depend" | \ - while read file ; do - mv $file $file.old - sed -e "s|[^ ]*\(/usr/src/linux\)|\1|g" < $file.old > $file - rm -f $file.old - done - - # Try to put some smarter autoconf.h and version.h files in place - pushd $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux ; { - rm -rf modules modversions.h autoconf.h version.h - cat > modversions.h < -#include -EOF - echo '#include ' > autoconf.h - list=`find ../../savedheaders/* -name '*.ver' -exec basename '{}' \; | sort` - mkdir modules - for l in $list; do - sed 's,$,modules/'$l, ../../savedheaders/list | awk -f %{SOURCE17} > modules/$l - touch -r modules/$l modules/`basename $l .ver`.stamp - echo '#include ' >> modversions.h - done - echo '#endif' >> modversions.h - sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h - install -m 644 %{SOURCE15} rhconfig.h - echo "#include " >> version.h - keyword=if - for i in smp BOOT BOOTsmp bigmem bigsmp up ; do - # When we build in an i386, we don't have an bigmem header directory - # in savedheaders/i386/bigmem. We also don't have a BOOT directory - # anywhere except in savedheaders/i386. So, we need to use this method - # of determining if a kernel version string needs to be included in the - # version.h file - verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '` - if [ -n "$verh" -a -f "$verh" ]; then - if [ "$i" = up ]; then - if [ "$keyword" = if ]; then - echo "#if 0" >> version.h - fi - echo "#else" >> version.h - else - echo "#$keyword defined(__module__$i)" >> version.h - keyword=elif - fi - grep UTS_RELEASE $verh >> version.h - fi - done - echo "#endif" >> version.h - if [ -f ../../savedheaders/%{_target_cpu}/up/version.h ] ; then - # keep to a standard normally - HEADER_FILE=../../savedheaders/%{_target_cpu}/up/version.h - else - # test build not including uniprocessor, must get info from somewhere - HEADER_FILE=$(ls ../../savedheaders/*/*/version.h | head -n 1) - fi - grep -v UTS_RELEASE $HEADER_FILE >> version.h - rm -rf ../../savedheaders - } ; popd - touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion} - - # rm -f $RPM_BUILD_ROOT/usr/include/linux - - rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/savedheaders - - %if %{rhbuild} - # fix up the tmp_include_depends file wrt the buildroot - perl -p -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/tmp_include_depends - %endif - %endif # linux26 - popd >/dev/null -%endif # buildbase - -popd >/dev/null - -%clean -rm -rf $RPM_BUILD_ROOT - -### -### scripts -### - -# do this for upgrades...in case the old modules get removed we have -# loopback in the kernel so that mkinitrd will work. -%pre -f pre.sh - -%pre smp -f presmp.sh - -%pre bigsmp -f prebigsmp.sh - -%pre bigmem -f prebigmem.sh - -%post -f post.sh - -%post smp -f postsmp.sh - -%post bigsmp -f postbigsmp.sh - -%post bigmem -f postbigmem.sh - -%post jensen -f postjensen.sh - -%ifnarch ia64 -%post BOOT -f postBOOT.sh - -%endif - -%post -n lustre-lite-utils -if [ ! -e /dev/obd ]; then - mknod /dev/obd c 10 241 -fi -if [ ! -e /dev/portals ]; then - mknod /dev/portals c 10 240 -fi -if [ -f /etc/init.d/lustre ] ; then - /sbin/chkconfig --add lustre - /sbin/chkconfig --add lustrefs -fi - -# Allow clean removal of modules directory -%preun -f preun.sh - -%preun smp -f preunsmp.sh - -%preun bigsmp -f preunbigsmp.sh - -%preun bigmem -f preunbigmem.sh - -%preun BOOT -f preunBOOT.sh - -%preun jensen -f preunjensen.sh - -# suse needs these i guess -%postun -f postun.sh - -%postun smp -f postunsmp.sh - -%postun bigsmp -f postunbigsmp.sh - -%postun bigmem -f postunbigmem.sh - -%postun BOOT -f postunBOOT.sh - -%postun jensen -f postunjensen.sh - -# We need this here because we don't prereq kudzu; it could be -# installed after the kernel -%triggerin -- kudzu -[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || : - -%triggerin smp -- kudzu -[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || : - -%triggerin bigsmp -- kudzu -[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || : - -%triggerin bigmem -- kudzu -[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || : - -%triggerin BOOT -- kudzu -[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || : - -%triggerin jensen -- kudzu -[ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || : - - -# Old kernel-headers packages owned include symlinks; new -# ones just make them so that we can have multiple kernel-headers -# packages installed. - -%triggerpostun source -- kernel-headers < 2.2.16 -cd /usr/src -rm -f %{kslnk} -ln -snf linux-%{KVERREL} %{kslnk} -exit 0 - -%post source -cd /usr/src -rm -f %{kslnk} -ln -snf linux-%{KVERREL} %{kslnk} - -%postun source -if [ -L /usr/src/%{kslnk} ]; then - if [ -L /usr/src/%{kslnk} -a `ls -ld /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then - [ $1 = 0 ] && rm -f /usr/src/%{kslnk} - fi -fi -exit 0 - -%preun -n lustre-lite-utils -if [ $1 = 0 -a -f /etc/init.d/lustre ]; then - /sbin/chkconfig --del lustre - /sbin/chkconfig --del lustrefs -fi - -### -### file lists -### - -%if %{buildup} -%files -%defattr(-, root, root) -/boot/%{kernel_glob} -%ifarch ia64 -/boot/efi/redhat/%{kernel_glob} -%endif -/boot/System.map-%{KVERREL} -/boot/config-%{KVERREL} -%dir /lib/modules -%dir /dev/shm -/lib/modules/%{KVERREL} -%if %{linux26} -/boot/Kerntypes-%{KVERREL} -/boot/symvers-%{KVERREL}-%{_target_cpu}.gz -%endif # linux26 -%endif - -%if %{buildsmp} -%files smp -%defattr(-, root, root) -/boot/%{kernel_glob}smp -%ifarch ia64 -/boot/efi/redhat/%{kernel_glob}smp -%endif -/boot/System.map-%{KVERREL}smp -/boot/config-%{KVERREL}smp -%dir /lib/modules -%dir /dev/shm -/lib/modules/%{KVERREL}smp -%if %{linux26} -/boot/Kerntypes-%{KVERREL}smp -/boot/symvers-%{KVERREL}-%{_target_cpu}smp.gz -%endif # linux26 -%endif - -%if %{buildbigsmp} -%files bigsmp -%defattr(-, root, root) -/boot/%{kernel_glob}bigsmp -%ifarch ia64 -/boot/efi/redhat/%{kernel_glob}bigsmp -%endif -/boot/System.map-%{KVERREL}bigsmp -/boot/config-%{KVERREL}bigsmp -%dir /lib/modules -%dir /dev/shm -/lib/modules/%{KVERREL}bigsmp -%if %{linux26} -/boot/Kerntypes-%{KVERREL}bigsmp -/boot/symvers-%{KVERREL}-%{_target_cpu}bigsmp.gz -%endif # linux26 -%endif - -%if %{buildbigmem} -%files bigmem -%defattr(-, root, root) -/boot/%{kernel_glob}bigmem -%ifarch ia64 -/boot/efi/redhat/%{kernel_glob}bigmem -%endif -/boot/System.map-%{KVERREL}bigmem -/boot/config-%{KVERREL}bigmem -%dir /lib/modules -%dir /dev/shm -/lib/modules/%{KVERREL}bigmem -%if %{linux26} -/boot/Kerntypes-%{KVERREL}bigmem -/boot/symvers-%{KVERREL}-%{_target_cpu}bigmem.gz -%endif # linux26 -%endif - -%if %{buildBOOT} -%files BOOT -%defattr(-, root, root) -/boot/%{kernel_glob}BOOT -%ifarch ia64 -/boot/efi/redhat/%{kernel_glob}BOOT -%endif -/boot/System.map-%{KVERREL}BOOT -/boot/config-%{KVERREL}BOOT -%dir /lib/modules -%dir /dev/shm -/lib/modules/%{KVERREL}BOOT -%if %{linux26} -/boot/Kerntypes-%{KVERREL}BOOT -/boot/symvers-%{KVERREL}-%{_target_cpu}BOOT.gz -%endif # linux26 -%endif - -%if %{buildbase} - -%if 1 -%files source -%defattr(-,root,root) -%dir /usr/src/linux-%{KVERREL} -/usr/src/linux-%{KVERREL}/* -%if %{linux26} -%dir /usr/src/linux-%{KVERREL}-obj -/usr/src/linux-%{KVERREL}-obj/* -%endif # linux26 -%endif - -%files doc -%defattr(-,root,root) -%doc lustre/linux/Documentation/* - -%files -n lustre-lite-utils -%defattr(-, root, root) -%doc lustre/COPYING lustre/BUGS lustre/ChangeLog lustre/README lustre/doc/lustre.pdf -/sbin/* -/usr/sbin/* -/usr/bin/* -/usr/lib/lustre/python -@ENABLE_INIT_SCRIPTS@/etc/init.d/lustre -@ENABLE_INIT_SCRIPTS@/etc/init.d/lustrefs -/usr/include/lustre/* -/usr/include/portals/* -/usr/include/linux/* -/usr/lib/lib*.a -/usr/share/man/man?/* - -#%files -n lustre-doc -#%defattr(-, root, root) -#/usr/share/doc/lustre/COPYING -#/usr/share/doc/lustre/lustre.pdf -#/usr/share/doc/lustre/COPYING - -/usr/share/lustre/examples - -%files -n lustre-ldap -%defattr(-, root, root) -/etc/openldap/slapd-lustre.conf -/etc/openldap/schema/lustre.schema -/usr/lib/lustre/lustre2ldif.xsl -/usr/lib/lustre/top.ldif - -%endif # %{buildbase} diff --git a/build/lustre.spec.in b/build/lustre.spec.in deleted file mode 100644 index c10e8e9..0000000 --- a/build/lustre.spec.in +++ /dev/null @@ -1,236 +0,0 @@ -# lustre.spec -%define version @VERSION@ -%define kversion @LINUXRELEASE@ -%define linuxdir @LINUX@ -%define enable_doc @ENABLE_DOC@ - -Summary: Lustre Lite File System -Name: lustre-lite -Version: %{version} -Release: @RELEASE@ -Copyright: GPL -Group: Utilities/System -Requires: lustre-modules, PyXML -Source: ftp://ftp.lustre.com/pub/lustre/lustre-%{version}.tar.gz -BuildRoot: /var/tmp/lustre-%{version}-root - -%description -The Lustre Lite Cluster File System: kernel drivers for file system, -servers and utilities. - -%package -n lustre-modules -Summary: Kernel Lustre drivers for Linux %{kversion} -Requires: modutils >= 2.4.10 -Group: Development/Kernel - -%description -n lustre-modules -Lustre file System, server and network drivers for Linux %{kversion}. - -%package -n lustre-source -Summary: Object-Based Disk storage driver source -Group: Development/Kernel - -%description -n lustre-source -Lustre Lite Source for further development - -%package -n lustre-doc -Summary: Documentation and sample configuration files -Group: Documentation -# FIXME: BuildArch overrides all the packages in rpm 4.0.4-7x -#BuildArch: noarch - -%description -n lustre-doc -Documentation and sample configuration files for Lustre - -%package -n lustre-ldap -Summary: Configures openldap server for LDAP Lustre config database -Group: Configuration -Requires: openldap-servers, openldap-clients, python-ldap, 4Suite - -%description -n lustre-ldap -Configures openldap server for LDAP Lustre config database - - -#%package -n liblustre -#Summary: Lustre Lib -#Group: Development/Kernel - -#%description -n liblustre -#Lustre lib binary package. - -%prep -%setup -qn lustre-%{version} -#%setup -c -n lustre-%{version}-lib -%if %{enable_doc} - %define disable_doc '' -%else - %define disable_doc --disable-doc -%endif - -%build -# if RPM_BUILD_NCPUS unset, set it -if [ -z "$RPM_BUILD_NCPUS" ] ; then - RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat || :) - if [ $RPM_BUILD_NCPUS -eq 0 ] ; then - RPM_BUILD_NCPUS=1 - fi - if [ $RPM_BUILD_NCPUS -gt 8 ] ; then - RPM_BUILD_NCPUS=8 - fi -fi - -rm -rf $RPM_BUILD_ROOT - -# Set an explicit path to our Linux tree, if we can. -cd $RPM_BUILD_DIR/lustre-%{version} -./configure \ - --with-linux='%{linuxdir}' \ - --with-linux-obj='@LINUX_OBJ@' \ - %{disable_doc} --disable-liblustre \ - --sysconfdir=%{_sysconfdir} \ - --mandir=%{_mandir} -make -j $RPM_BUILD_NCPUS -s - -%install -cd $RPM_BUILD_DIR/lustre-%{version} -make install DESTDIR=$RPM_BUILD_ROOT - -%ifarch alpha -# this hurts me - conf_flag= - linuxdir=%{linuxdir} - test -d $linuxdir && conf_flag=--with-linux=$linuxdir - make clean - ./configure --enable-rtscts-myrinet $conf_flag %{disable_doc} - make - cp linux/rtscts/rtscts.o $RPM_BUILD_ROOT/lib/modules/%{kversion}/kernel/net/lustre/rtscts_myrinet.o - cp user/myrinet_utils/mcpload $RPM_BUILD_ROOT/usr/sbin/mcpload -%endif - -# Create the pristine source directory. -cd $RPM_BUILD_DIR/lustre-%{version} -mkdir -p $RPM_BUILD_ROOT/usr/src -rm -f lustre-source -ln -s $RPM_BUILD_ROOT/usr/src lustre-source -make distdir distdir=lustre-source/lustre-%{version} - -# ldap database directory -mkdir -p $RPM_BUILD_ROOT/var/lib/ldap/lustre - -%files -%attr(-, root, root) /sbin/mount.lustre -%attr(-, root, root) /usr/sbin/lmc -%attr(-, root, root) /usr/sbin/lctl -%attr(-, root, root) /usr/sbin/lconf -%attr(-, root, root) /usr/sbin/lrun -%attr(-, root, root) /usr/sbin/llmount -%attr(-, root, root) /usr/sbin/lwizard -%attr(-, root, root) /usr/sbin/wiretest -%attr(-, root, root) /usr/sbin/lactive -%attr(-, root, root) /usr/sbin/llanalyze -%attr(-, root, root) /usr/sbin/gmnalnid -%attr(-, root, root) /usr/sbin/llstat.pl -%attr(-, root, root) /usr/sbin/llobdstat.pl -%attr(-, root, root) /usr/sbin/load_ldap.sh -%attr(-, root, root) /usr/sbin/acceptor -%attr(-, root, root) /usr/sbin/ptlctl -%attr(-, root, root) /usr/sbin/debugctl -%attr(-, root, root) /usr/sbin/lload -%attr(-, root, root) /usr/sbin/obdbarrier -%attr(-, root, root) /usr/sbin/obdio -%attr(-, root, root) /usr/sbin/routerstat -%attr(-, root, root) /usr/sbin/wirecheck -%attr(-, root, root) /usr/bin/lfs -%attr(-, root, root) /usr/bin/lfind -%attr(-, root, root) /usr/bin/lstripe -%attr(-, root, root) /usr/bin/mcreate -%attr(-, root, root) /usr/bin/munlink -%attr(-, root, root) /usr/lib/lustre/python -%attr(-, root, root) /usr/share/lustre/examples - -%attr(-, root, root) /etc/init.d/lustre -%attr(-, root, root) /etc/init.d/lustrefs -%attr(-, root, root) /usr/lib/libptlctl.a -%attr(-, root, root) /usr/lib/liblustreapi.a -%attr(-, root, root) /usr/include/lustre -%attr(-, root, root) /usr/include/portals -%attr(-, root, root) /usr/include/linux/lustre_idl.h - -%attr(-, root, root) /usr/share/man/man?/* - -%ifarch alpha -%attr(-, root, root) /usr/sbin/mcpload -%endif - -%files -n lustre-doc -%attr(-, root, root) %doc COPYING FDL -%if %{enable_doc} -%attr(-, root, root) %doc doc/lustre.pdf doc/lustre-HOWTO.txt -%endif -#%attr(-, root, root) %doc tests/client-echo.cfg tests/client-mount.cfg -#%attr(-, root, root) %doc tests/client-mount2.cfg -#%attr(-, root, root) %doc tests/elan-client.cfg tests/elan-server.cfg -#%attr(-, root, root) %doc tests/ldlm.cfg tests/lustre.cfg -#%attr(-, root, root) %doc tests/mds.cfg tests/net-client.cfg -#%attr(-, root, root) %doc tests/net-local.cfg tests/net-server.cfg -#%attr(-, root, root) %doc tests/obdecho.cfg tests/obdfilter.cfg - -%files -n lustre-modules -%attr(-, root, root) %doc COPYING -%attr(-, root, root) /lib/modules/%{kversion}/kernel/fs/lustre -#portals modules -%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/lustre - -%files -n lustre-source -%attr(-, root, root) /usr/src/lustre-%{version} - -#%ifarch i386 -#%files -n liblustre -#%attr(-, root, root) /lib/lustre -#%attr(-, root, root) /usr/sbin/lctl -#%attr(-, root, root) /usr/sbin/lfind -#%attr(-, root, root) /usr/sbin/lstripe -#%attr(-, root, root) /usr/sbin/obdio -#%attr(-, root, root) /usr/sbin/obdbarrier -#%attr(-, root, root) /usr/sbin/obdstat -#%attr(-, root, root) /usr/sbin/lload -#%attr(-, root, root) /usr/sbin/lconf -#%attr(-, root, root) /usr/sbin/lmc -#%attr(-, root, root) /usr/sbin/llanalyze -#%endif - - -%files -n lustre-ldap -%attr(-, root, root) /etc/openldap/slapd-lustre.conf -%attr(-, root, root) /etc/openldap/schema/lustre.schema -%attr(-, root, root) /usr/share/lustre/lustre2ldif.xsl -%attr(-, root, root) /usr/share/lustre/top.ldif -#%dir /var/lib/ldap/lustre -%attr(700, ldap, ldap) /var/lib/ldap/lustre - -%post -/sbin/chkconfig --add lustre -/sbin/chkconfig --add lustrefs - -%preun -if [ $1 = 0 ]; then - /sbin/chkconfig --del lustre - /sbin/chkconfig --del lustrefs -fi - -%post -n lustre-modules -if [ ! -e /dev/obd ]; then - mknod /dev/obd c 10 241 -fi -if [ ! -e /dev/portals ]; then - mknod /dev/portals c 10 240 -fi -depmod -ae || exit 0 - -%postun -n lustre-modules -depmod -ae || exit 0 - -%clean -#rm -rf $RPM_BUILD_ROOT - -# end of file diff --git a/build/merge1.sh b/build/merge1.sh deleted file mode 100755 index 29130fa..0000000 --- a/build/merge1.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh -e - -CONFLICTS=cvs-merge-conflicts -CVS="cvs -z3" - -if [ -f .mergeinfo ] ; then - echo ".mergeinfo exists - clean up first" - exit -fi - -if [ -f $CONFLICTS ] ; then - echo "$CONFLICTS exists - clean up first" - exit -fi - -if [ $# -lt 2 -o $# -gt 3 ]; then - echo "This is phase 1 of merging branches. Usage: $0 parent child [dir]" - exit -fi - -parent=$1 -PARENT=`echo $parent | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"` -child=$2 -CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"` -date=`date +%Y%m%d_%H%M` - -dir=${3:-.} -module=$(<$dir/CVS/Repository) - -if [ "$module" = "lustre" ] ; then - echo >&2 "${progname}: You probably want to branch lustre or portals, not the whole tree." - echo >&2 "${progname}: Try using ${0} $parent $child lustre" - exit 1 -fi - - -case $parent in - HEAD) : ;; - b_*|b[1-4]*) : ;; - *) parent="b_$parent" ;; -esac -case $child in - HEAD) : ;; - b_*|b[1-4]*) : ;; - *) child="b_$child" -esac - -if [ "$child" != "HEAD" -a "`cat $dir/CVS/Tag 2> /dev/null`" != "T$child" ]; then - echo "This script must be run within the $child branch" - exit 1 -fi - -TEST_FILE=${TEST_FILE:-ChangeLog} # does this need to be smarter? -check_tag() { - [ -z "$1" ] && echo "check_tag() missing arg" && exit3 - [ "$1" = "HEAD" ] && return - $CVS log $dir/$TEST_FILE 2> /dev/null | grep -q " $1: " && return - echo "$0: tag $1 not found in $dir/$TEST_FILE" - exit 2 -} - -check_tag $parent -check_tag ${CHILD}_BASE - -cat << EOF > .mergeinfo -parent=$parent -PARENT=$PARENT -child=$child -CHILD=$CHILD -date=$date -dir=$dir -module=$module -CONFLICTS=$CONFLICTS -OPERATION=Merge -OPERWHERE=from -EOF - -echo PARENT: $PARENT parent: $parent CHILD: $CHILD child: $child date: $date - -echo -n "tagging $parent as '${PARENT}_${CHILD}_UPDATE_PARENT_$date' ...." -$CVS rtag -r $parent ${PARENT}_${CHILD}_UPDATE_PARENT_$date $module -echo "done" -echo -n "tagging $child as '${PARENT}_${CHILD}_UPDATE_CHILD_$date' ...." -$CVS rtag -r $child ${PARENT}_${CHILD}_UPDATE_CHILD_$date $module -echo "done" - -# Apply all of the changes to your local tree: -echo "Updating: -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date ...." -$CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date -dP $dir -echo "done" - -echo -n "Recording conflicts in $CONFLICTS ..." -$CVS update | awk '/^C/ { print $2 }' > $CONFLICTS -if [ -s $CONFLICTS ] ; then - echo "Conflicts found, fix before committing." - cat $CONFLICTS -else - echo "No conflicts found" - rm -f $CONFLICTS -fi -echo "done" - -echo "Build, test, commit and then run merge2.sh (no arguments)" diff --git a/build/merge2.sh b/build/merge2.sh deleted file mode 100755 index 43586f0..0000000 --- a/build/merge2.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -e - -if [ ! -f .mergeinfo ] ; then - echo ".mergeinfo doesn't exist - exit" - exit -fi - -. .mergeinfo - -if [ -f $CONFLICTS ] ; then - echo "$CONFLICTS exists - clean up first" - cat $CONFLICTS - exit -fi - -cvs update $dir 2>&1 | grep "^M" && echo "uncommitted changes" && exit 1 - -echo -n "Tagging ${PARENT}_${CHILD}_UPDATE_PARENT_$date as ${CHILD}_BASE_$date ..." -cvs rtag -r ${PARENT}_${CHILD}_UPDATE_PARENT_$date ${CHILD}_BASE_$date $module -echo "done" -echo -n "Tagging ${CHILD}_BASE as ${CHILD}_BASE_PREV ...." -cvs rtag -F -r ${CHILD}_BASE ${CHILD}_BASE_PREV $module -echo "done" -echo "${CHILD}_BASE_$date as ${CHILD}_BASE ..." -cvs rtag -F -r ${CHILD}_BASE_$date ${CHILD}_BASE $module - -echo "saving .mergeinfo as .mergeinfo-$date" -mv .mergeinfo .mergeinfo-$date -echo "done" diff --git a/build/suse-functions.sh b/build/suse-functions.sh deleted file mode 100644 index a7e421d..0000000 --- a/build/suse-functions.sh +++ /dev/null @@ -1,22 +0,0 @@ -# Readlink is not present on some older distributions: emulate it. -readlink() { - local path=$1 ll - - if [ -L "$path" ]; then - ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" && - echo "${ll/* -> }" - else - return 1 - fi -} -relink() { - if [ -h "$2" ]; then - local old=$(readlink "$2") - [ "$old" = "$1" ] && return 0 - echo "Changing symlink $2 from $old to $1" - elif [ -e "$2" ]; then - echo "Replacing file $2 with symlink to $1" - fi - rm -f "$2" \ - && ln -s "$1" "$2" -} diff --git a/build/suse-post.sh b/build/suse-post.sh deleted file mode 100644 index ec38664..0000000 --- a/build/suse-post.sh +++ /dev/null @@ -1,46 +0,0 @@ -if [ -f /boot/vmlinuz-%ver_str ]; then - image=vmlinuz -elif [ -f /boot/image-%ver_str ]; then - image=image -elif [ -f /boot/vmlinux-%ver_str ]; then - image=vmlinux -else - # nothing to do (UML kernels for example). - exit 0 -fi - -# If we have old symlinks, rename them to *.previous -if [ -L /boot/$image -a -L /boot/initrd -a \ - "$(readlink /boot/$image)" != $image-%ver_str -a \ - "$(readlink /boot/initrd)" != initrd-%ver_str ]; then - mv /boot/$image /boot/$image.previous - mv /boot/initrd /boot/initrd.previous -fi - -# update /boot/vmlinuz symlink -relink $image-%ver_str /boot/$image - -if test "$YAST_IS_RUNNING" != instsys ; then - if [ -f /etc/fstab ]; then - echo Setting up /lib/modules/%ver_str - /sbin/update-modules.dep -v %ver_str - cd /boot - /sbin/mkinitrd -k $image-%ver_str -i initrd-%ver_str - - if [ -e /boot/initrd-%ver_str ]; then - relink initrd-%ver_str /boot/initrd - else - rm -f /boot/initrd - fi - else - echo "please run mkinitrd as soon as your system is complete" - fi -fi - -if [ "$YAST_IS_RUNNING" != instsys -a -x /sbin/new-kernel-pkg ]; then - # Notify boot loader that a new kernel image has been installed. - # (during initial installation the boot loader configuration does not - # yet exist when the kernel is installed, but yast kicks the boot - # loader itself later.) - /sbin/new-kernel-pkg %ver_str -fi diff --git a/build/suse-postun.sh b/build/suse-postun.sh deleted file mode 100644 index eb86d03..0000000 --- a/build/suse-postun.sh +++ /dev/null @@ -1,43 +0,0 @@ -if [ -L /boot/vmlinux ]; then - image=vmlinux -elif [ -L /boot/vmlinuz ]; then - image=vmlinuz -elif [ -L /boot/image ]; then - image=image -else - # nothing to do (UML kernels for example). - exit 0 -fi - -if [ "$(readlink /boot/$image)" = $image-%ver_str ]; then - # This may be the last kernel RPM on the system, or it may - # be an update. In both of those cases the symlinks will - # eventually be correct. Only if this kernel - # is removed and other kernel rpms remain installed, - # find the most recent of the remaining kernels, and make - # the symlinks point to it. This makes sure that the boot - # manager will always have a kernel to boot in its default - # configuration. - shopt -s nullglob - for image in $(cd /boot ; ls -dt $image-*); do - initrd=initrd-${image#*-} - if [ -f /boot/$image -a -f /boot/$initrd ]; then - relink $image /boot/${image%%%%-*} - relink $initrd /boot/${initrd%%%%-*} - break - fi - done - shopt -u nullglob -fi - -# Created in the other kernel's %post -case "$(readlink /boot/$image.previous)" in -$image-%ver_str|$(readlink /boot/$image)) - rm -f /boot/$image.previous ;; -esac -case "$(readlink /boot/initrd.previous)" in -initrd-%ver_str|$(readlink /boot/initrd)) - rm -f /boot/initrd.previous ;; -esac -# created in %post -rm -f /boot/initrd-%ver_str diff --git a/build/suse-trigger-script.sh.in b/build/suse-trigger-script.sh.in deleted file mode 100644 index 0ead9e8..0000000 --- a/build/suse-trigger-script.sh.in +++ /dev/null @@ -1,9 +0,0 @@ -old_shopt=$(shopt -p nullglob || :) -shopt -s nullglob -for script in /lib/modules/scripts/* ; do - if [ -f "$script" -a -x "$script" ] \ - && ! "$script" --@when@ %ver_str $1 ; then - echo "$script failed." - fi -done -eval $old_shopt diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 5ce60d7..0000000 --- a/configure.ac +++ /dev/null @@ -1,16 +0,0 @@ -sinclude(lustre/autoconf/lustre-version.ac) - -AC_INIT([Lustre], [LUSTRE_VERSION], [https://bugzilla.lustre.org/], [lustre]) - -LB_CHECK_VERSION - -LC_CONFIG_SRCDIR - -AC_CANONICAL_SYSTEM - -AM_INIT_AUTOMAKE -# AM_MAINTAINER_MODE - -AC_PROG_CC - -LB_CONFIGURE diff --git a/ldiskfs/kernel_patches/patches/export-ext3-2.6-suse.patch b/ldiskfs/kernel_patches/patches/export-ext3-2.6-suse.patch deleted file mode 100644 index 638b4bf..0000000 --- a/ldiskfs/kernel_patches/patches/export-ext3-2.6-suse.patch +++ /dev/null @@ -1,33 +0,0 @@ -Index: linux-stage/fs/ext3/super.c -=================================================================== ---- linux-stage.orig/fs/ext3/super.c 2004-04-02 16:40:18.000000000 -0500 -+++ linux-stage/fs/ext3/super.c 2004-04-02 16:40:18.000000000 -0500 -@@ -115,6 +115,8 @@ - handle->h_err = err; - } - -+EXPORT_SYMBOL(ext3_journal_abort_handle); -+ - static char error_buf[1024]; - - /* Deal with the reporting of failure conditions on a filesystem such as -@@ -1774,6 +1776,8 @@ - return ret; - } - -+EXPORT_SYMBOL(ext3_force_commit); -+ - /* - * Ext3 always journals updates to the superblock itself, so we don't - * have to propagate any other updates to the superblock on disk at this -@@ -2088,6 +2092,10 @@ - unsigned long *blocks, int *created, int create); - EXPORT_SYMBOL(ext3_map_inode_page); - -+EXPORT_SYMBOL(ext3_xattr_get); -+EXPORT_SYMBOL(ext3_xattr_set_handle); -+EXPORT_SYMBOL(ext3_bread); -+ - MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); - MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions"); - MODULE_LICENSE("GPL"); diff --git a/ldiskfs/kernel_patches/patches/export_symbols-ext3-2.6-suse.patch b/ldiskfs/kernel_patches/patches/export_symbols-ext3-2.6-suse.patch deleted file mode 100644 index 2327263..0000000 --- a/ldiskfs/kernel_patches/patches/export_symbols-ext3-2.6-suse.patch +++ /dev/null @@ -1,17 +0,0 @@ -Index: linux-2.6.0/include/linux/ext3_fs_sb.h -=================================================================== ---- linux-2.6.0.orig/include/linux/ext3_fs_sb.h 2003-06-24 18:05:26.000000000 +0400 -+++ linux-2.6.0/include/linux/ext3_fs_sb.h 2003-12-31 01:09:26.000000000 +0300 -@@ -19,9 +19,12 @@ - #ifdef __KERNEL__ - #include - #include -+#ifndef EXT_INCLUDE -+#define EXT_INCLUDE - #include - #include - #endif -+#endif - - /* - * third extended-fs super-block data in memory diff --git a/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch b/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch deleted file mode 100644 index 92897b6..0000000 --- a/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch +++ /dev/null @@ -1,841 +0,0 @@ -%patch -Index: linux-2.6.7/fs/ext3/ialloc.c -=================================================================== ---- linux-2.6.7.orig/fs/ext3/ialloc.c 2004-09-06 20:01:18.000000000 +0800 -+++ linux-2.6.7/fs/ext3/ialloc.c 2004-09-06 20:04:42.000000000 +0800 -@@ -629,6 +629,11 @@ - spin_unlock(&sbi->s_next_gen_lock); - - ei->i_state = EXT3_STATE_NEW; -+ if (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) { -+ ei->i_extra_isize = sizeof(__u16) /* i_extra_isize */ -+ + sizeof(__u16); /* i_pad1 */ -+ } else -+ ei->i_extra_isize = 0; - - ret = inode; - if(DQUOT_ALLOC_INODE(inode)) { -Index: linux-2.6.7/fs/ext3/inode.c -=================================================================== ---- linux-2.6.7.orig/fs/ext3/inode.c 2004-09-06 20:01:20.000000000 +0800 -+++ linux-2.6.7/fs/ext3/inode.c 2004-09-06 20:04:42.000000000 +0800 -@@ -2349,7 +2349,7 @@ - * trying to determine the inode's location on-disk and no read need be - * performed. - */ --static int ext3_get_inode_loc(struct inode *inode, -+int ext3_get_inode_loc(struct inode *inode, - struct ext3_iloc *iloc, int in_mem) - { - unsigned long block; -@@ -2558,6 +2558,11 @@ - ei->i_data[block] = raw_inode->i_block[block]; - INIT_LIST_HEAD(&ei->i_orphan); - -+ if (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) -+ ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize); -+ else -+ ei->i_extra_isize = 0; -+ - if (S_ISREG(inode->i_mode)) { - inode->i_op = &ext3_file_inode_operations; - inode->i_fop = &ext3_file_operations; -@@ -2693,6 +2698,9 @@ - } else for (block = 0; block < EXT3_N_BLOCKS; block++) - raw_inode->i_block[block] = ei->i_data[block]; - -+ if (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) -+ raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize); -+ - BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); - rc = ext3_journal_dirty_metadata(handle, bh); - if (!err) -Index: linux-2.6.7/fs/ext3/xattr.c -=================================================================== ---- linux-2.6.7.orig/fs/ext3/xattr.c 2004-06-16 13:19:36.000000000 +0800 -+++ linux-2.6.7/fs/ext3/xattr.c 2004-09-06 20:05:40.000000000 +0800 -@@ -246,17 +246,12 @@ - } - - /* -- * ext3_xattr_get() -- * -- * Copy an extended attribute into the buffer -- * provided, or compute the buffer size required. -- * Buffer is NULL to compute the size of the buffer required. -+ * ext3_xattr_block_get() - * -- * Returns a negative error number on failure, or the number of bytes -- * used / required on success. -+ * routine looks for attribute in EA block and returns it's value and size - */ - int --ext3_xattr_get(struct inode *inode, int name_index, const char *name, -+ext3_xattr_block_get(struct inode *inode, int name_index, const char *name, - void *buffer, size_t buffer_size) - { - struct buffer_head *bh = NULL; -@@ -270,7 +265,6 @@ - - if (name == NULL) - return -EINVAL; -- down_read(&EXT3_I(inode)->xattr_sem); - error = -ENODATA; - if (!EXT3_I(inode)->i_file_acl) - goto cleanup; -@@ -343,15 +337,87 @@ - - cleanup: - brelse(bh); -- up_read(&EXT3_I(inode)->xattr_sem); - - return error; - } - - /* -- * ext3_xattr_list() -+ * ext3_xattr_ibode_get() - * -- * Copy a list of attribute names into the buffer -+ * routine looks for attribute in inode body and returns it's value and size -+ */ -+int -+ext3_xattr_ibody_get(struct inode *inode, int name_index, const char *name, -+ void *buffer, size_t buffer_size) -+{ -+ int size, name_len = strlen(name), storage_size; -+ struct ext3_xattr_entry *last; -+ struct ext3_inode *raw_inode; -+ struct ext3_iloc iloc; -+ char *start, *end; -+ int ret = -ENOENT; -+ -+ if (EXT3_SB(inode->i_sb)->s_inode_size <= EXT3_GOOD_OLD_INODE_SIZE) -+ return -ENOENT; -+ -+ ret = ext3_get_inode_loc(inode, &iloc, 1); -+ if (ret) -+ return ret; -+ raw_inode = ext3_raw_inode(&iloc); -+ -+ storage_size = EXT3_SB(inode->i_sb)->s_inode_size - -+ EXT3_GOOD_OLD_INODE_SIZE - -+ EXT3_I(inode)->i_extra_isize - -+ sizeof(__u32); -+ start = (char *) raw_inode + EXT3_GOOD_OLD_INODE_SIZE + -+ EXT3_I(inode)->i_extra_isize; -+ if (le32_to_cpu((*(__u32*) start)) != EXT3_XATTR_MAGIC) { -+ brelse(iloc.bh); -+ return -ENOENT; -+ } -+ start += sizeof(__u32); -+ end = (char *) raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; -+ -+ last = (struct ext3_xattr_entry *) start; -+ while (!IS_LAST_ENTRY(last)) { -+ struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last); -+ if (le32_to_cpu(last->e_value_size) > storage_size || -+ (char *) next >= end) { -+ ext3_error(inode->i_sb, "ext3_xattr_ibody_get", -+ "inode %ld", inode->i_ino); -+ brelse(iloc.bh); -+ return -EIO; -+ } -+ if (name_index == last->e_name_index && -+ name_len == last->e_name_len && -+ !memcmp(name, last->e_name, name_len)) -+ goto found; -+ last = next; -+ } -+ -+ /* can't find EA */ -+ brelse(iloc.bh); -+ return -ENOENT; -+ -+found: -+ size = le32_to_cpu(last->e_value_size); -+ if (buffer) { -+ ret = -ERANGE; -+ if (buffer_size >= size) { -+ memcpy(buffer, start + le16_to_cpu(last->e_value_offs), -+ size); -+ ret = size; -+ } -+ } else -+ ret = size; -+ brelse(iloc.bh); -+ return ret; -+} -+ -+/* -+ * ext3_xattr_get() -+ * -+ * Copy an extended attribute into the buffer - * provided, or compute the buffer size required. - * Buffer is NULL to compute the size of the buffer required. - * -@@ -359,7 +425,31 @@ - * used / required on success. - */ - int --ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) -+ext3_xattr_get(struct inode *inode, int name_index, const char *name, -+ void *buffer, size_t buffer_size) -+{ -+ int err; -+ -+ down_read(&EXT3_I(inode)->xattr_sem); -+ -+ /* try to find attribute in inode body */ -+ err = ext3_xattr_ibody_get(inode, name_index, name, -+ buffer, buffer_size); -+ if (err < 0) -+ /* search was unsuccessful, try to find EA in dedicated block */ -+ err = ext3_xattr_block_get(inode, name_index, name, -+ buffer, buffer_size); -+ up_read(&EXT3_I(inode)->xattr_sem); -+ -+ return err; -+} -+ -+/* ext3_xattr_ibody_list() -+ * -+ * generate list of attributes stored in EA block -+ */ -+int -+ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) - { - struct buffer_head *bh = NULL; - struct ext3_xattr_entry *entry; -@@ -370,7 +460,6 @@ - ea_idebug(inode, "buffer=%p, buffer_size=%ld", - buffer, (long)buffer_size); - -- down_read(&EXT3_I(inode)->xattr_sem); - error = 0; - if (!EXT3_I(inode)->i_file_acl) - goto cleanup; -@@ -380,7 +469,7 @@ - if (!bh) - goto cleanup; - ea_bdebug(bh, "b_count=%d, refcount=%d", -- atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount)); -+ (int) atomic_read(&(bh->b_count)), (int) le32_to_cpu(HDR(bh)->h_refcount)); - end = bh->b_data + bh->b_size; - if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) || - HDR(bh)->h_blocks != cpu_to_le32(1)) { -@@ -431,11 +520,138 @@ - - cleanup: - brelse(bh); -- up_read(&EXT3_I(inode)->xattr_sem); - - return error; - } - -+/* ext3_xattr_ibody_list() -+ * -+ * generate list of attributes stored in inode body -+ */ -+int -+ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) -+{ -+ struct ext3_xattr_entry *last; -+ struct ext3_inode *raw_inode; -+ char *start, *end, *buf; -+ struct ext3_iloc iloc; -+ int storage_size; -+ int ret; -+ int size = 0; -+ -+ if (EXT3_SB(inode->i_sb)->s_inode_size <= EXT3_GOOD_OLD_INODE_SIZE) -+ return 0; -+ -+ ret = ext3_get_inode_loc(inode, &iloc, 1); -+ if (ret) -+ return ret; -+ raw_inode = ext3_raw_inode(&iloc); -+ -+ storage_size = EXT3_SB(inode->i_sb)->s_inode_size - -+ EXT3_GOOD_OLD_INODE_SIZE - -+ EXT3_I(inode)->i_extra_isize - -+ sizeof(__u32); -+ start = (char *) raw_inode + EXT3_GOOD_OLD_INODE_SIZE + -+ EXT3_I(inode)->i_extra_isize; -+ if (le32_to_cpu((*(__u32*) start)) != EXT3_XATTR_MAGIC) { -+ brelse(iloc.bh); -+ return 0; -+ } -+ start += sizeof(__u32); -+ end = (char *) raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; -+ -+ last = (struct ext3_xattr_entry *) start; -+ while (!IS_LAST_ENTRY(last)) { -+ struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last); -+ struct ext3_xattr_handler *handler; -+ if (le32_to_cpu(last->e_value_size) > storage_size || -+ (char *) next >= end) { -+ ext3_error(inode->i_sb, "ext3_xattr_ibody_list", -+ "inode %ld", inode->i_ino); -+ brelse(iloc.bh); -+ return -EIO; -+ } -+ handler = ext3_xattr_handler(last->e_name_index); -+ if (handler) -+ size += handler->list(NULL, inode, last->e_name, -+ last->e_name_len); -+ last = next; -+ } -+ -+ if (!buffer) { -+ ret = size; -+ goto cleanup; -+ } else { -+ ret = -ERANGE; -+ if (size > buffer_size) -+ goto cleanup; -+ } -+ -+ last = (struct ext3_xattr_entry *) start; -+ buf = buffer; -+ while (!IS_LAST_ENTRY(last)) { -+ struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last); -+ struct ext3_xattr_handler *handler; -+ handler = ext3_xattr_handler(last->e_name_index); -+ if (handler) -+ buf += handler->list(buf, inode, last->e_name, -+ last->e_name_len); -+ last = next; -+ } -+ ret = size; -+cleanup: -+ brelse(iloc.bh); -+ return ret; -+} -+ -+/* -+ * ext3_xattr_list() -+ * -+ * Copy a list of attribute names into the buffer -+ * provided, or compute the buffer size required. -+ * Buffer is NULL to compute the size of the buffer required. -+ * -+ * Returns a negative error number on failure, or the number of bytes -+ * used / required on success. -+ */ -+int -+ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) -+{ -+ int error; -+ int size = buffer_size; -+ -+ down_read(&EXT3_I(inode)->xattr_sem); -+ -+ /* get list of attributes stored in inode body */ -+ error = ext3_xattr_ibody_list(inode, buffer, buffer_size); -+ if (error < 0) { -+ /* some error occured while collecting -+ * attributes in inode body */ -+ size = 0; -+ goto cleanup; -+ } -+ size = error; -+ -+ /* get list of attributes stored in dedicated block */ -+ if (buffer) { -+ buffer_size -= error; -+ if (buffer_size <= 0) { -+ buffer = NULL; -+ buffer_size = 0; -+ } else -+ buffer += error; -+ } -+ -+ error = ext3_xattr_block_list(inode, buffer, buffer_size); -+ if (error < 0) -+ /* listing was successful, so we return len */ -+ size = 0; -+ -+cleanup: -+ up_read(&EXT3_I(inode)->xattr_sem); -+ return error + size; -+} -+ - /* - * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is - * not set, set it. -@@ -457,6 +673,279 @@ - } - - /* -+ * ext3_xattr_ibody_find() -+ * -+ * search attribute and calculate free space in inode body -+ * NOTE: free space includes space our attribute hold -+ */ -+int -+ext3_xattr_ibody_find(struct inode *inode, int name_index, -+ const char *name, struct ext3_xattr_entry *rentry, int *free) -+{ -+ struct ext3_xattr_entry *last; -+ struct ext3_inode *raw_inode; -+ int name_len = strlen(name); -+ int err, storage_size; -+ struct ext3_iloc iloc; -+ char *start, *end; -+ int ret = -ENOENT; -+ -+ if (EXT3_SB(inode->i_sb)->s_inode_size <= EXT3_GOOD_OLD_INODE_SIZE) -+ return ret; -+ -+ err = ext3_get_inode_loc(inode, &iloc, 1); -+ if (err) -+ return -EIO; -+ raw_inode = ext3_raw_inode(&iloc); -+ -+ storage_size = EXT3_SB(inode->i_sb)->s_inode_size - -+ EXT3_GOOD_OLD_INODE_SIZE - -+ EXT3_I(inode)->i_extra_isize - -+ sizeof(__u32); -+ *free = storage_size - sizeof(__u32); -+ start = (char *) raw_inode + EXT3_GOOD_OLD_INODE_SIZE + -+ EXT3_I(inode)->i_extra_isize; -+ if (le32_to_cpu((*(__u32*) start)) != EXT3_XATTR_MAGIC) { -+ brelse(iloc.bh); -+ return -ENOENT; -+ } -+ start += sizeof(__u32); -+ end = (char *) raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; -+ -+ last = (struct ext3_xattr_entry *) start; -+ while (!IS_LAST_ENTRY(last)) { -+ struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last); -+ if (le32_to_cpu(last->e_value_size) > storage_size || -+ (char *) next >= end) { -+ ext3_error(inode->i_sb, "ext3_xattr_ibody_find", -+ "inode %ld", inode->i_ino); -+ brelse(iloc.bh); -+ return -EIO; -+ } -+ -+ if (name_index == last->e_name_index && -+ name_len == last->e_name_len && -+ !memcmp(name, last->e_name, name_len)) { -+ memcpy(rentry, last, sizeof(struct ext3_xattr_entry)); -+ ret = 0; -+ } else { -+ *free -= EXT3_XATTR_LEN(last->e_name_len); -+ *free -= le32_to_cpu(last->e_value_size); -+ } -+ last = next; -+ } -+ -+ brelse(iloc.bh); -+ return ret; -+} -+ -+/* -+ * ext3_xattr_block_find() -+ * -+ * search attribute and calculate free space in EA block (if it allocated) -+ * NOTE: free space includes space our attribute hold -+ */ -+int -+ext3_xattr_block_find(struct inode *inode, int name_index, const char *name, -+ struct ext3_xattr_entry *rentry, int *free) -+{ -+ struct buffer_head *bh = NULL; -+ struct ext3_xattr_entry *entry; -+ char *end; -+ int name_len, error = -ENOENT; -+ -+ if (!EXT3_I(inode)->i_file_acl) { -+ *free = inode->i_sb->s_blocksize - -+ sizeof(struct ext3_xattr_header) - -+ sizeof(__u32); -+ return -ENOENT; -+ } -+ ea_idebug(inode, "reading block %d", EXT3_I(inode)->i_file_acl); -+ bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl); -+ if (!bh) -+ return -EIO; -+ ea_bdebug(bh, "b_count=%d, refcount=%d", -+ atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount)); -+ end = bh->b_data + bh->b_size; -+ if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) || -+ HDR(bh)->h_blocks != cpu_to_le32(1)) { -+bad_block: ext3_error(inode->i_sb, "ext3_xattr_get", -+ "inode %ld: bad block %d", inode->i_ino, -+ EXT3_I(inode)->i_file_acl); -+ brelse(bh); -+ return -EIO; -+ } -+ /* find named attribute */ -+ name_len = strlen(name); -+ *free = bh->b_size - sizeof(__u32); -+ -+ entry = FIRST_ENTRY(bh); -+ while (!IS_LAST_ENTRY(entry)) { -+ struct ext3_xattr_entry *next = -+ EXT3_XATTR_NEXT(entry); -+ if ((char *)next >= end) -+ goto bad_block; -+ if (name_index == entry->e_name_index && -+ name_len == entry->e_name_len && -+ memcmp(name, entry->e_name, name_len) == 0) { -+ memcpy(rentry, entry, sizeof(struct ext3_xattr_entry)); -+ error = 0; -+ } else { -+ *free -= EXT3_XATTR_LEN(entry->e_name_len); -+ *free -= le32_to_cpu(entry->e_value_size); -+ } -+ entry = next; -+ } -+ brelse(bh); -+ -+ return error; -+} -+ -+/* -+ * ext3_xattr_inode_set() -+ * -+ * this routine add/remove/replace attribute in inode body -+ */ -+int -+ext3_xattr_ibody_set(handle_t *handle, struct inode *inode, int name_index, -+ const char *name, const void *value, size_t value_len, -+ int flags) -+{ -+ struct ext3_xattr_entry *last, *next, *here = NULL; -+ struct ext3_inode *raw_inode; -+ int name_len = strlen(name); -+ int esize = EXT3_XATTR_LEN(name_len); -+ struct buffer_head *bh; -+ int err, storage_size; -+ struct ext3_iloc iloc; -+ int free, min_offs; -+ char *start, *end; -+ -+ if (EXT3_SB(inode->i_sb)->s_inode_size <= EXT3_GOOD_OLD_INODE_SIZE) -+ return -ENOSPC; -+ -+ err = ext3_get_inode_loc(inode, &iloc, 1); -+ if (err) -+ return err; -+ raw_inode = ext3_raw_inode(&iloc); -+ bh = iloc.bh; -+ -+ storage_size = EXT3_SB(inode->i_sb)->s_inode_size - -+ EXT3_GOOD_OLD_INODE_SIZE - -+ EXT3_I(inode)->i_extra_isize - -+ sizeof(__u32); -+ start = (char *) raw_inode + EXT3_GOOD_OLD_INODE_SIZE + -+ EXT3_I(inode)->i_extra_isize; -+ if ((*(__u32*) start) != EXT3_XATTR_MAGIC) { -+ /* inode had no attributes before */ -+ *((__u32*) start) = cpu_to_le32(EXT3_XATTR_MAGIC); -+ } -+ start += sizeof(__u32); -+ end = (char *) raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; -+ min_offs = storage_size; -+ free = storage_size - sizeof(__u32); -+ -+ last = (struct ext3_xattr_entry *) start; -+ while (!IS_LAST_ENTRY(last)) { -+ next = EXT3_XATTR_NEXT(last); -+ if (le32_to_cpu(last->e_value_size) > storage_size || -+ (char *) next >= end) { -+ ext3_error(inode->i_sb, "ext3_xattr_ibody_set", -+ "inode %ld", inode->i_ino); -+ brelse(bh); -+ return -EIO; -+ } -+ -+ if (last->e_value_size) { -+ int offs = le16_to_cpu(last->e_value_offs); -+ if (offs < min_offs) -+ min_offs = offs; -+ } -+ if (name_index == last->e_name_index && -+ name_len == last->e_name_len && -+ !memcmp(name, last->e_name, name_len)) -+ here = last; -+ else { -+ /* we calculate all but our attribute -+ * because it will be removed before changing */ -+ free -= EXT3_XATTR_LEN(last->e_name_len); -+ free -= le32_to_cpu(last->e_value_size); -+ } -+ last = next; -+ } -+ -+ if (value && (esize + value_len > free)) { -+ brelse(bh); -+ return -ENOSPC; -+ } -+ -+ err = ext3_reserve_inode_write(handle, inode, &iloc); -+ if (err) { -+ brelse(bh); -+ return err; -+ } -+ -+ if (here) { -+ /* time to remove old value */ -+ struct ext3_xattr_entry *e; -+ int size = le32_to_cpu(here->e_value_size); -+ int border = le16_to_cpu(here->e_value_offs); -+ char *src; -+ -+ /* move tail */ -+ memmove(start + min_offs + size, start + min_offs, -+ border - min_offs); -+ -+ /* recalculate offsets */ -+ e = (struct ext3_xattr_entry *) start; -+ while (!IS_LAST_ENTRY(e)) { -+ struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(e); -+ int offs = le16_to_cpu(e->e_value_offs); -+ if (offs < border) -+ e->e_value_offs = -+ cpu_to_le16(offs + size); -+ e = next; -+ } -+ min_offs += size; -+ -+ /* remove entry */ -+ border = EXT3_XATTR_LEN(here->e_name_len); -+ src = (char *) here + EXT3_XATTR_LEN(here->e_name_len); -+ size = (char *) last - src; -+ if ((char *) here + size > end) -+ printk("ALERT at %s:%d: 0x%p + %d > 0x%p\n", -+ __FILE__, __LINE__, here, size, end); -+ memmove(here, src, size); -+ last = (struct ext3_xattr_entry *) ((char *) last - border); -+ *((__u32 *) last) = 0; -+ } -+ -+ if (value) { -+ int offs = min_offs - value_len; -+ /* use last to create new entry */ -+ last->e_name_len = strlen(name); -+ last->e_name_index = name_index; -+ last->e_value_offs = cpu_to_le16(offs); -+ last->e_value_size = cpu_to_le32(value_len); -+ last->e_hash = last->e_value_block = 0; -+ memset(last->e_name, 0, esize); -+ memcpy(last->e_name, name, last->e_name_len); -+ if (start + offs + value_len > end) -+ printk("ALERT at %s:%d: 0x%p + %d + %d > 0x%p\n", -+ __FILE__, __LINE__, start, offs, -+ value_len, end); -+ memcpy(start + offs, value, value_len); -+ last = EXT3_XATTR_NEXT(last); -+ *((__u32 *) last) = 0; -+ } -+ -+ ext3_mark_iloc_dirty(handle, inode, &iloc); -+ brelse(bh); -+ -+ return 0; -+} -+ -+/* - * ext3_xattr_set_handle() - * - * Create, replace or remove an extended attribute for this inode. Buffer -@@ -470,6 +959,104 @@ - */ - int - ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, -+ const char *name, const void *value, size_t value_len, -+ int flags) -+{ -+ struct ext3_xattr_entry entry; -+ int err, where = 0, found = 0, total; -+ int free1 = -1, free2 = -1; -+ int name_len; -+ -+ ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld", -+ name_index, name, value, (long)value_len); -+ -+ if (IS_RDONLY(inode)) -+ return -EROFS; -+ if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) -+ return -EPERM; -+ if (value == NULL) -+ value_len = 0; -+ if (name == NULL) -+ return -EINVAL; -+ name_len = strlen(name); -+ if (name_len > 255 || value_len > inode->i_sb->s_blocksize) -+ return -ERANGE; -+ down_write(&EXT3_I(inode)->xattr_sem); -+ -+ /* try to find attribute in inode body */ -+ err = ext3_xattr_ibody_find(inode, name_index, name, &entry, &free1); -+ if (err == 0) { -+ /* found EA in inode */ -+ found = 1; -+ where = 0; -+ } else if (err == -ENOENT) { -+ /* there is no such attribute in inode body */ -+ /* try to find attribute in dedicated block */ -+ err = ext3_xattr_block_find(inode, name_index, name, -+ &entry, &free2); -+ if (err != 0 && err != -ENOENT) { -+ /* not found EA in block */ -+ goto finish; -+ } else if (err == 0) { -+ /* found EA in block */ -+ where = 1; -+ found = 1; -+ } -+ } else -+ goto finish; -+ -+ /* check flags: may replace? may create ? */ -+ if (found && (flags & XATTR_CREATE)) { -+ err = -EEXIST; -+ goto finish; -+ } else if (!found && (flags & XATTR_REPLACE)) { -+ err = -ENODATA; -+ goto finish; -+ } -+ -+ /* check if we have enough space to store attribute */ -+ total = EXT3_XATTR_LEN(strlen(name)) + value_len; -+ if (free1 >= 0 && total > free1 && free2 >= 0 && total > free2) { -+ /* have no enough space */ -+ err = -ENOSPC; -+ goto finish; -+ } -+ -+ /* time to remove attribute */ -+ if (found) { -+ if (where == 0) { -+ /* EA is stored in inode body */ -+ ext3_xattr_ibody_set(handle, inode, name_index, name, -+ NULL, 0, flags); -+ } else { -+ /* EA is stored in separated block */ -+ ext3_xattr_block_set(handle, inode, name_index, name, -+ NULL, 0, flags); -+ } -+ } -+ -+ /* try to store EA in inode body */ -+ err = ext3_xattr_ibody_set(handle, inode, name_index, name, -+ value, value_len, flags); -+ if (err) { -+ /* can't store EA in inode body */ -+ /* try to store in block */ -+ err = ext3_xattr_block_set(handle, inode, name_index, -+ name, value, value_len, flags); -+ } -+ -+finish: -+ up_write(&EXT3_I(inode)->xattr_sem); -+ return err; -+} -+ -+/* -+ * ext3_xattr_block_set() -+ * -+ * this routine add/remove/replace attribute in EA block -+ */ -+int -+ext3_xattr_block_set(handle_t *handle, struct inode *inode, int name_index, - const char *name, const void *value, size_t value_len, - int flags) - { -@@ -492,22 +1079,7 @@ - * towards the end of the block). - * end -- Points right after the block pointed to by header. - */ -- -- ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld", -- name_index, name, value, (long)value_len); -- -- if (IS_RDONLY(inode)) -- return -EROFS; -- if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) -- return -EPERM; -- if (value == NULL) -- value_len = 0; -- if (name == NULL) -- return -EINVAL; - name_len = strlen(name); -- if (name_len > 255 || value_len > sb->s_blocksize) -- return -ERANGE; -- down_write(&EXT3_I(inode)->xattr_sem); - if (EXT3_I(inode)->i_file_acl) { - /* The inode already has an extended attribute block. */ - bh = sb_bread(sb, EXT3_I(inode)->i_file_acl); -@@ -733,7 +1305,6 @@ - brelse(bh); - if (!(bh && header == HDR(bh))) - kfree(header); -- up_write(&EXT3_I(inode)->xattr_sem); - - return error; - } -Index: linux-2.6.7/fs/ext3/xattr.h -=================================================================== ---- linux-2.6.7.orig/fs/ext3/xattr.h 2004-06-16 13:20:04.000000000 +0800 -+++ linux-2.6.7/fs/ext3/xattr.h 2004-09-06 20:04:42.000000000 +0800 -@@ -77,7 +77,8 @@ - extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t); - extern int ext3_xattr_list(struct inode *, char *, size_t); - extern int ext3_xattr_set(struct inode *, int, const char *, const void *, size_t, int); --extern int ext3_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int); -+extern int ext3_xattr_set_handle(handle_t *, struct inode *, int, const char *,const void *,size_t,int); -+extern int ext3_xattr_block_set(handle_t *, struct inode *, int, const char *,const void *,size_t,int); - - extern void ext3_xattr_delete_inode(handle_t *, struct inode *); - extern void ext3_xattr_put_super(struct super_block *); -Index: linux-2.6.7/include/linux/ext3_fs.h -=================================================================== ---- linux-2.6.7.orig/include/linux/ext3_fs.h 2004-09-06 20:01:19.000000000 +0800 -+++ linux-2.6.7/include/linux/ext3_fs.h 2004-09-06 20:04:42.000000000 +0800 -@@ -265,6 +265,8 @@ - __u32 m_i_reserved2[2]; - } masix2; - } osd2; /* OS dependent 2 */ -+ __u16 i_extra_isize; -+ __u16 i_pad1; - }; - - #define i_size_high i_dir_acl -@@ -725,6 +727,7 @@ - extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *); - extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *); - -+extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *, int); - extern void ext3_read_inode (struct inode *); - extern void ext3_write_inode (struct inode *, int); - extern int ext3_setattr (struct dentry *, struct iattr *); -Index: linux-2.6.7/include/linux/ext3_fs_i.h -=================================================================== ---- linux-2.6.7.orig/include/linux/ext3_fs_i.h 2004-06-16 13:18:52.000000000 +0800 -+++ linux-2.6.7/include/linux/ext3_fs_i.h 2004-09-06 20:04:42.000000000 +0800 -@@ -96,6 +96,9 @@ - */ - loff_t i_disksize; - -+ /* on-disk additional length */ -+ __u16 i_extra_isize; -+ - /* - * truncate_sem is for serialising ext3_truncate() against - * ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's - -%diffstat - fs/ext3/ialloc.c | 5 - fs/ext3/inode.c | 10 - fs/ext3/xattr.c | 635 +++++++++++++++++++++++++++++++++++++++++++--- - fs/ext3/xattr.h | 3 - include/linux/ext3_fs.h | 3 - include/linux/ext3_fs_i.h | 3 - 6 files changed, 625 insertions(+), 34 deletions(-) - diff --git a/ldiskfs/kernel_patches/patches/ext3-include-fixes-2.6-suse.patch b/ldiskfs/kernel_patches/patches/ext3-include-fixes-2.6-suse.patch deleted file mode 100644 index 28e3587..0000000 --- a/ldiskfs/kernel_patches/patches/ext3-include-fixes-2.6-suse.patch +++ /dev/null @@ -1,20 +0,0 @@ -Index: linux-stage/include/linux/ext3_fs.h -=================================================================== ---- linux-stage.orig/include/linux/ext3_fs.h 2004-04-02 16:43:37.000000000 -0500 -+++ linux-stage/include/linux/ext3_fs.h 2004-04-02 16:43:37.000000000 -0500 -@@ -331,12 +331,13 @@ - #define EXT3_MOUNT_IOPEN_NOPRIV 0x20000 /* Make iopen world-readable */ - - /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */ --#ifndef _LINUX_EXT2_FS_H -+#ifndef clear_opt - #define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt - #define set_opt(o, opt) o |= EXT3_MOUNT_##opt - #define test_opt(sb, opt) (EXT3_SB(sb)->s_mount_opt & \ - EXT3_MOUNT_##opt) --#else -+#endif -+#ifndef EXT2_MOUNT_NOLOAD - #define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD - #define EXT2_MOUNT_ABORT EXT3_MOUNT_ABORT - #define EXT2_MOUNT_DATA_FLAGS EXT3_MOUNT_DATA_FLAGS diff --git a/ldiskfs/kernel_patches/patches/ext3-map_inode_page-2.6-suse.patch b/ldiskfs/kernel_patches/patches/ext3-map_inode_page-2.6-suse.patch deleted file mode 100644 index 91063b3..0000000 --- a/ldiskfs/kernel_patches/patches/ext3-map_inode_page-2.6-suse.patch +++ /dev/null @@ -1,81 +0,0 @@ - fs/ext3/inode.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - fs/ext3/super.c | 3 +++ - 2 files changed, 55 insertions(+) - -Index: linux-2.6.0/fs/ext3/inode.c -=================================================================== ---- linux-2.6.0.orig/fs/ext3/inode.c 2003-12-31 00:33:49.000000000 +0300 -+++ linux-2.6.0/fs/ext3/inode.c 2003-12-31 01:14:17.000000000 +0300 -@@ -3136,3 +3136,58 @@ - ret = ret2; - return ret; - } -+ -+int ext3_map_inode_page(struct inode *inode, struct page *page, -+ unsigned long *blocks, int *created, int create) -+{ -+ unsigned int blocksize, blocks_per_page; -+ unsigned long iblock; -+ struct buffer_head dummy; -+ void *handle; -+ int i, rc = 0, failed = 0, needed_blocks; -+ -+ blocksize = inode->i_sb->s_blocksize; -+ blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits; -+ iblock = page->index * blocks_per_page; -+ -+ for (i = 0; i < blocks_per_page; i++, iblock++) { -+ blocks[i] = ext3_bmap(inode->i_mapping, iblock); -+ if (blocks[i] == 0) { -+ failed++; -+ created[i] = -1; -+ } else { -+ created[i] = 0; -+ } -+ } -+ -+ if (failed == 0 || create == 0) -+ return 0; -+ -+ needed_blocks = ext3_writepage_trans_blocks(inode); -+ handle = ext3_journal_start(inode, needed_blocks); -+ if (IS_ERR(handle)) -+ return PTR_ERR(handle); -+ -+ iblock = page->index * blocks_per_page; -+ for (i = 0; i < blocks_per_page; i++, iblock++) { -+ if (blocks[i] != 0) -+ continue; -+ -+ rc = ext3_get_block_handle(handle, inode, iblock, &dummy, 1, 1); -+ if (rc) { -+ printk(KERN_INFO "ext3_map_inode_page: error reading " -+ "block %ld\n", iblock); -+ goto out; -+ } -+ if (buffer_new(&dummy)) -+ unmap_underlying_metadata(dummy.b_bdev, -+ dummy.b_blocknr); -+ blocks[i] = dummy.b_blocknr; -+ created[i] = 1; -+ } -+ -+ out: -+ ext3_journal_stop(handle); -+ return rc; -+} -+ -Index: linux-2.6.0/fs/ext3/super.c -=================================================================== ---- linux-2.6.0.orig/fs/ext3/super.c 2003-12-31 00:33:49.000000000 +0300 -+++ linux-2.6.0/fs/ext3/super.c 2003-12-31 01:10:40.000000000 +0300 -@@ -2051,6 +2051,9 @@ - int ext3_prep_san_write(struct inode *inode, long *blocks, - int nblocks, loff_t newsize); - EXPORT_SYMBOL(ext3_prep_san_write); -+int ext3_map_inode_page(struct inode *inode, struct page *page, -+ unsigned long *blocks, int *created, int create); -+EXPORT_SYMBOL(ext3_map_inode_page); - - MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); - MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions"); diff --git a/ldiskfs/kernel_patches/patches/ext3-san-jdike-2.6-suse.patch b/ldiskfs/kernel_patches/patches/ext3-san-jdike-2.6-suse.patch deleted file mode 100644 index afda0bd..0000000 --- a/ldiskfs/kernel_patches/patches/ext3-san-jdike-2.6-suse.patch +++ /dev/null @@ -1,106 +0,0 @@ - fs/ext3/inode.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - fs/ext3/super.c | 4 ++ - 2 files changed, 85 insertions(+) - ---- linux-2.5.73/fs/ext3/inode.c~ext3-san-jdike-2.5.73 2003-06-22 12:32:58.000000000 -0600 -+++ linux-2.5.73-braam/fs/ext3/inode.c 2003-06-30 12:19:21.000000000 -0600 -@@ -2945,3 +2945,84 @@ int ext3_change_inode_journal_flag(struc - - return err; - } -+ -+/* for each block: 1 ind + 1 dind + 1 tind -+ * for each block: 3 bitmap blocks -+ * for each block: 3 group descriptor blocks -+ * i inode block -+ * 1 superblock -+ * 2 * EXT3_SINGLEDATA_TRANS_BLOCKS for the quote files -+ * ((1+1+1) * 3 * nblocks) + 1 + 1 + 2 * EXT3_SINGLEDATA_TRANS_BLOCKS -+ * -+ * XXX assuming: -+ * (1) fs logic block size == page size -+ * (2) ext3 in writeback mode -+ */ -+static inline int ext3_san_write_trans_blocks(int nblocks) -+{ -+ int ret; -+ -+ ret = (1 + 1 + 1) * 3 * nblocks + 1 + 1; -+ -+#ifdef CONFIG_QUOTA -+ ret += 2 * EXT3_SINGLEDATA_TRANS_BLOCKS; -+#endif -+ -+ return ret; -+} -+ -+/* Alloc blocks for an inode, while don't create any buffer/page -+ * for data I/O; set the inode size if file is extended. -+ * -+ * @inode: target inode -+ * @blocks: array of logic block number -+ * @nblocks: how many blocks need be alloced -+ * @newsize: new filesize we should set -+ * -+ * return: 0 success, otherwise failed -+ * (*blocks) contains physical block number alloced -+ * -+ * XXX this assume the fs block size == page size -+ */ -+int ext3_prep_san_write(struct inode *inode, long *blocks, -+ int nblocks, loff_t newsize) -+{ -+ handle_t *handle; -+ struct buffer_head bh_tmp; -+ int needed_blocks; -+ int i, ret = 0, ret2; -+ -+ needed_blocks = ext3_san_write_trans_blocks(nblocks); -+ -+ lock_kernel(); -+ handle = ext3_journal_start(inode, needed_blocks); -+ if (IS_ERR(handle)) { -+ unlock_kernel(); -+ return PTR_ERR(handle); -+ } -+ unlock_kernel(); -+ -+ /* alloc blocks one by one */ -+ for (i = 0; i < nblocks; i++) { -+ ret = ext3_get_block_handle(handle, inode, blocks[i], -+ &bh_tmp, 1, 1); -+ if (ret) -+ break; -+ -+ blocks[i] = bh_tmp.b_blocknr; -+ } -+ -+ /* set inode size if needed */ -+ if (!ret && (newsize > inode->i_size)) { -+ inode->i_size = newsize; -+ ext3_mark_inode_dirty(handle, inode); -+ } -+ -+ lock_kernel(); -+ ret2 = ext3_journal_stop(handle); -+ unlock_kernel(); -+ -+ if (!ret) -+ ret = ret2; -+ return ret; -+} ---- linux-2.5.73/fs/ext3/super.c~ext3-san-jdike-2.5.73 2003-06-22 12:33:16.000000000 -0600 -+++ linux-2.5.73-braam/fs/ext3/super.c 2003-06-30 12:16:36.000000000 -0600 -@@ -2080,6 +2080,10 @@ static void __exit exit_ext3_fs(void) - exit_ext3_xattr(); - } - -+int ext3_prep_san_write(struct inode *inode, long *blocks, -+ int nblocks, loff_t newsize); -+EXPORT_SYMBOL(ext3_prep_san_write); -+ - MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); - MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions"); - MODULE_LICENSE("GPL"); - -_ diff --git a/ldiskfs/kernel_patches/patches/ext3-wantedi-2.6-suse.patch b/ldiskfs/kernel_patches/patches/ext3-wantedi-2.6-suse.patch deleted file mode 100644 index a4867a5..0000000 --- a/ldiskfs/kernel_patches/patches/ext3-wantedi-2.6-suse.patch +++ /dev/null @@ -1,184 +0,0 @@ - fs/ext3/ialloc.c | 35 ++++++++++++++++++++++++++++++++++- - fs/ext3/ioctl.c | 25 +++++++++++++++++++++++++ - fs/ext3/namei.c | 21 +++++++++++++++++---- - include/linux/dcache.h | 5 +++++ - include/linux/ext3_fs.h | 5 ++++- - 5 files changed, 85 insertions(+), 6 deletions(-) - -Index: uml-2.6.3/fs/ext3/ialloc.c -=================================================================== ---- uml-2.6.3.orig/fs/ext3/ialloc.c 2004-02-20 15:00:48.000000000 +0800 -+++ uml-2.6.3/fs/ext3/ialloc.c 2004-02-21 00:24:45.202693776 +0800 -@@ -420,7 +420,8 @@ - * For other inodes, search forward from the parent directory's block - * group to find a free inode. - */ --struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) -+struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode, -+ unsigned long goal) - { - struct super_block *sb; - struct buffer_head *bitmap_bh = NULL; -@@ -448,6 +449,38 @@ - - sbi = EXT3_SB(sb); - es = sbi->s_es; -+ if (goal) { -+ group = (goal - 1) / EXT3_INODES_PER_GROUP(sb); -+ ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb); -+ gdp = ext3_get_group_desc(sb, group, &bh2); -+ -+ err = -EIO; -+ bitmap_bh = read_inode_bitmap (sb, group); -+ if (!bitmap_bh) -+ goto fail; -+ -+ BUFFER_TRACE(bh, "get_write_access"); -+ err = ext3_journal_get_write_access(handle, bitmap_bh); -+ if (err) goto fail; -+ -+ if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group), -+ ino, bitmap_bh->b_data)) { -+ printk(KERN_ERR "goal inode %lu unavailable\n", goal); -+ /* Oh well, we tried. */ -+ goto continue_allocation; -+ } -+ -+ BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); -+ err = ext3_journal_dirty_metadata(handle, bitmap_bh); -+ if (err) goto fail; -+ -+ /* We've shortcircuited the allocation system successfully, -+ * now finish filling in the inode. -+ */ -+ goto got; -+ } -+ -+continue_allocation: - if (S_ISDIR(mode)) { - if (test_opt (sb, OLDALLOC)) - group = find_group_dir(sb, dir); -Index: uml-2.6.3/fs/ext3/ioctl.c -=================================================================== ---- uml-2.6.3.orig/fs/ext3/ioctl.c 2004-01-09 14:59:26.000000000 +0800 -+++ uml-2.6.3/fs/ext3/ioctl.c 2004-02-21 00:21:04.541239416 +0800 -@@ -24,6 +24,31 @@ - ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg); - - switch (cmd) { -+ case EXT3_IOC_CREATE_INUM: { -+ char name[32]; -+ struct dentry *dchild, *dparent; -+ int rc = 0; -+ -+ dparent = list_entry(inode->i_dentry.next, struct dentry, -+ d_alias); -+ snprintf(name, sizeof name, "%lu", arg); -+ dchild = lookup_one_len(name, dparent, strlen(name)); -+ if (dchild->d_inode) { -+ printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n", -+ dparent->d_name.len, dparent->d_name.name, arg, -+ dchild->d_inode->i_ino); -+ rc = -EEXIST; -+ } else { -+ dchild->d_fsdata = (void *)arg; -+ rc = vfs_create(inode, dchild, 0644, NULL); -+ if (rc) -+ printk(KERN_ERR "vfs_create: %d\n", rc); -+ else if (dchild->d_inode->i_ino != arg) -+ rc = -EEXIST; -+ } -+ dput(dchild); -+ return rc; -+ } - case EXT3_IOC_GETFLAGS: - flags = ei->i_flags & EXT3_FL_USER_VISIBLE; - return put_user(flags, (int *) arg); -Index: uml-2.6.3/fs/ext3/namei.c -=================================================================== ---- uml-2.6.3.orig/fs/ext3/namei.c 2004-02-20 15:01:27.000000000 +0800 -+++ uml-2.6.3/fs/ext3/namei.c 2004-02-21 00:21:04.611228776 +0800 -@@ -1617,6 +1617,19 @@ - return err; - } - -+static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir, -+ int mode, struct dentry *dentry) -+{ -+ unsigned long inum = 0; -+ -+ if (dentry->d_fsdata != NULL) { -+ struct dentry_params *param = -+ (struct dentry_params *) dentry->d_fsdata; -+ inum = param->p_inum; -+ } -+ return ext3_new_inode(handle, dir, mode, inum); -+} -+ - /* - * By the time this is called, we already have created - * the directory cache entry for the new file, but it -@@ -1640,7 +1653,7 @@ - if (IS_DIRSYNC(dir)) - handle->h_sync = 1; - -- inode = ext3_new_inode (handle, dir, mode); -+ inode = ext3_new_inode_wantedi (handle, dir, mode, dentry); - err = PTR_ERR(inode); - if (!IS_ERR(inode)) { - inode->i_op = &ext3_file_inode_operations; -@@ -1670,7 +1683,7 @@ - if (IS_DIRSYNC(dir)) - handle->h_sync = 1; - -- inode = ext3_new_inode (handle, dir, mode); -+ inode = ext3_new_inode_wantedi (handle, dir, mode, dentry); - err = PTR_ERR(inode); - if (!IS_ERR(inode)) { - init_special_inode(inode, inode->i_mode, rdev); -@@ -1702,7 +1715,7 @@ - if (IS_DIRSYNC(dir)) - handle->h_sync = 1; - -- inode = ext3_new_inode (handle, dir, S_IFDIR | mode); -+ inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry); - err = PTR_ERR(inode); - if (IS_ERR(inode)) - goto out_stop; -@@ -2094,7 +2107,7 @@ - if (IS_DIRSYNC(dir)) - handle->h_sync = 1; - -- inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO); -+ inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry); - err = PTR_ERR(inode); - if (IS_ERR(inode)) - goto out_stop; -Index: uml-2.6.3/include/linux/ext3_fs.h -=================================================================== ---- uml-2.6.3.orig/include/linux/ext3_fs.h 2004-01-09 14:59:44.000000000 +0800 -+++ uml-2.6.3/include/linux/ext3_fs.h 2004-02-21 00:21:04.613228472 +0800 -@@ -203,6 +203,7 @@ - #define EXT3_IOC_SETFLAGS _IOW('f', 2, long) - #define EXT3_IOC_GETVERSION _IOR('f', 3, long) - #define EXT3_IOC_SETVERSION _IOW('f', 4, long) -+/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */ - #define EXT3_IOC_GETVERSION_OLD _IOR('v', 1, long) - #define EXT3_IOC_SETVERSION_OLD _IOW('v', 2, long) - #ifdef CONFIG_JBD_DEBUG -@@ -707,7 +708,8 @@ - dx_hash_info *hinfo); - - /* ialloc.c */ --extern struct inode * ext3_new_inode (handle_t *, struct inode *, int); -+extern struct inode * ext3_new_inode (handle_t *, struct inode *, int, -+ unsigned long); - extern void ext3_free_inode (handle_t *, struct inode *); - extern struct inode * ext3_orphan_get (struct super_block *, unsigned long); - extern unsigned long ext3_count_free_inodes (struct super_block *); -@@ -792,4 +794,5 @@ - - #endif /* __KERNEL__ */ - -+#define EXT3_IOC_CREATE_INUM _IOW('f', 5, long) - #endif /* _LINUX_EXT3_FS_H */ diff --git a/ldiskfs/kernel_patches/patches/iopen-2.6-suse.patch b/ldiskfs/kernel_patches/patches/iopen-2.6-suse.patch deleted file mode 100644 index 8a8d115..0000000 --- a/ldiskfs/kernel_patches/patches/iopen-2.6-suse.patch +++ /dev/null @@ -1,475 +0,0 @@ - fs/ext3/inode.c | 3 - fs/ext3/iopen.c | 239 +++++++++++++++++++++++++++++++++++++ - fs/ext3/iopen.h | 15 ++ - fs/ext3/namei.c | 13 ++ - fs/ext3/super.c | 17 ++ - include/linux/ext3_fs.h | 2 - 7 files changed, 304 insertions(+), 1 deletion(-) - -Index: linux-stage/fs/ext3/Makefile -=================================================================== ---- linux-stage.orig/fs/ext3/Makefile 2004-05-11 17:21:20.000000000 -0400 -+++ linux-stage/fs/ext3/Makefile 2004-05-11 17:21:21.000000000 -0400 -@@ -4,7 +4,7 @@ - - obj-$(CONFIG_EXT3_FS) += ext3.o - --ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ -+ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ - ioctl.o namei.o super.o symlink.o hash.o - - ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o -Index: linux-stage/fs/ext3/inode.c -=================================================================== ---- linux-stage.orig/fs/ext3/inode.c 2004-05-11 17:21:21.000000000 -0400 -+++ linux-stage/fs/ext3/inode.c 2004-05-11 17:21:21.000000000 -0400 -@@ -37,6 +37,7 @@ - #include - #include - #include "xattr.h" -+#include "iopen.h" - #include "acl.h" - - /* -@@ -2472,6 +2473,9 @@ - ei->i_acl = EXT3_ACL_NOT_CACHED; - ei->i_default_acl = EXT3_ACL_NOT_CACHED; - #endif -+ if (ext3_iopen_get_inode(inode)) -+ return; -+ - if (ext3_get_inode_loc(inode, &iloc, 0)) - goto bad_inode; - bh = iloc.bh; -Index: linux-stage/fs/ext3/iopen.c -=================================================================== ---- linux-stage.orig/fs/ext3/iopen.c 1969-12-31 19:00:00.000000000 -0500 -+++ linux-stage/fs/ext3/iopen.c 2004-05-11 17:21:21.000000000 -0400 -@@ -0,0 +1,272 @@ -+/* -+ * linux/fs/ext3/iopen.c -+ * -+ * Special support for open by inode number -+ * -+ * Copyright (C) 2001 by Theodore Ts'o (tytso@alum.mit.edu). -+ * -+ * This file may be redistributed under the terms of the GNU General -+ * Public License. -+ * -+ * -+ * Invariants: -+ * - there is only ever a single DCACHE_NFSD_DISCONNECTED dentry alias -+ * for an inode at one time. -+ * - there are never both connected and DCACHE_NFSD_DISCONNECTED dentry -+ * aliases on an inode at the same time. -+ * -+ * If we have any connected dentry aliases for an inode, use one of those -+ * in iopen_lookup(). Otherwise, we instantiate a single NFSD_DISCONNECTED -+ * dentry for this inode, which thereafter will be found by the dcache -+ * when looking up this inode number in __iopen__, so we don't return here -+ * until it is gone. -+ * -+ * If we get an inode via a regular name lookup, then we "rename" the -+ * NFSD_DISCONNECTED dentry to the proper name and parent. This ensures -+ * existing users of the disconnected dentry will continue to use the same -+ * dentry as the connected users, and there will never be both kinds of -+ * dentry aliases at one time. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "iopen.h" -+ -+#ifndef assert -+#define assert(test) J_ASSERT(test) -+#endif -+ -+#define IOPEN_NAME_LEN 32 -+ -+/* -+ * This implements looking up an inode by number. -+ */ -+static struct dentry *iopen_lookup(struct inode * dir, struct dentry *dentry, -+ struct nameidata *nd) -+{ -+ struct inode *inode; -+ unsigned long ino; -+ struct list_head *lp; -+ struct dentry *alternate; -+ char buf[IOPEN_NAME_LEN]; -+ -+ if (dentry->d_name.len >= IOPEN_NAME_LEN) -+ return ERR_PTR(-ENAMETOOLONG); -+ -+ memcpy(buf, dentry->d_name.name, dentry->d_name.len); -+ buf[dentry->d_name.len] = 0; -+ -+ if (strcmp(buf, ".") == 0) -+ ino = dir->i_ino; -+ else if (strcmp(buf, "..") == 0) -+ ino = EXT3_ROOT_INO; -+ else -+ ino = simple_strtoul(buf, 0, 0); -+ -+ if ((ino != EXT3_ROOT_INO && -+ //ino != EXT3_ACL_IDX_INO && -+ //ino != EXT3_ACL_DATA_INO && -+ ino < EXT3_FIRST_INO(dir->i_sb)) || -+ ino > le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count)) -+ return ERR_PTR(-ENOENT); -+ -+ inode = iget(dir->i_sb, ino); -+ if (!inode) -+ return ERR_PTR(-EACCES); -+ if (is_bad_inode(inode)) { -+ iput(inode); -+ return ERR_PTR(-ENOENT); -+ } -+ -+ assert(list_empty(&dentry->d_alias)); /* d_instantiate */ -+ assert(d_unhashed(dentry)); /* d_rehash */ -+ -+ /* preferrably return a connected dentry */ -+ spin_lock(&dcache_lock); -+ list_for_each(lp, &inode->i_dentry) { -+ alternate = list_entry(lp, struct dentry, d_alias); -+ assert(!(alternate->d_flags & DCACHE_DISCONNECTED)); -+ } -+ -+ if (!list_empty(&inode->i_dentry)) { -+ alternate = list_entry(inode->i_dentry.next, -+ struct dentry, d_alias); -+ dget_locked(alternate); -+ alternate->d_vfs_flags |= DCACHE_REFERENCED; -+ iput(inode); -+ spin_unlock(&dcache_lock); -+ return alternate; -+ } -+ dentry->d_flags |= DCACHE_DISCONNECTED; -+ -+ /* d_add(), but don't drop dcache_lock before adding dentry to inode */ -+ list_add(&dentry->d_alias, &inode->i_dentry); /* d_instantiate */ -+ dentry->d_inode = inode; -+ -+ __d_rehash(dentry, 0); /* d_rehash */ -+ spin_unlock(&dcache_lock); -+ -+ return NULL; -+} -+ -+#define do_switch(x,y) do { \ -+ __typeof__ (x) __tmp = x; \ -+ x = y; y = __tmp; } while (0) -+ -+static inline void switch_names(struct dentry *dentry, struct dentry *target) -+{ -+ const unsigned char *old_name, *new_name; -+ -+ memcpy(dentry->d_iname, target->d_iname, DNAME_INLINE_LEN); -+ old_name = target->d_name.name; -+ new_name = dentry->d_name.name; -+ if (old_name == target->d_iname) -+ old_name = dentry->d_iname; -+ if (new_name == dentry->d_iname) -+ new_name = target->d_iname; -+ target->d_name.name = new_name; -+ dentry->d_name.name = old_name; -+} -+ -+/* This function is spliced into ext3_lookup and does the move of a -+ * disconnected dentry (if it exists) to a connected dentry. -+ */ -+struct dentry *iopen_connect_dentry(struct dentry *dentry, struct inode *inode, -+ int rehash) -+{ -+ struct dentry *tmp, *goal = NULL; -+ struct list_head *lp; -+ -+ /* verify this dentry is really new */ -+ assert(dentry->d_inode == NULL); -+ assert(list_empty(&dentry->d_alias)); /* d_instantiate */ -+ if (rehash) -+ assert(d_unhashed(dentry)); /* d_rehash */ -+ assert(list_empty(&dentry->d_subdirs)); -+ -+ spin_lock(&dcache_lock); -+ if (!inode) -+ goto do_rehash; -+ -+ /* preferrably return a connected dentry */ -+ list_for_each(lp, &inode->i_dentry) { -+ tmp = list_entry(lp, struct dentry, d_alias); -+ if (tmp->d_flags & DCACHE_DISCONNECTED) { -+ assert(tmp->d_alias.next == &inode->i_dentry); -+ assert(tmp->d_alias.prev == &inode->i_dentry); -+ goal = tmp; -+ dget_locked(goal); -+ break; -+ } -+ } -+ -+ if (!goal) -+ goto do_instantiate; -+ -+ /* Move the goal to the de hash queue */ -+ goal->d_flags &= ~ DCACHE_DISCONNECTED; -+ security_d_instantiate(goal, inode); -+ __d_rehash(dentry, 0); -+ __d_move(goal, dentry); -+ spin_unlock(&dcache_lock); -+ iput(inode); -+ -+ return goal; -+ -+ /* d_add(), but don't drop dcache_lock before adding dentry to inode */ -+do_instantiate: -+ list_add(&dentry->d_alias, &inode->i_dentry); /* d_instantiate */ -+ dentry->d_inode = inode; -+do_rehash: -+ if (rehash) -+ __d_rehash(dentry, 0); /* d_rehash */ -+ spin_unlock(&dcache_lock); -+ -+ return NULL; -+} -+ -+/* -+ * These are the special structures for the iopen pseudo directory. -+ */ -+ -+static struct inode_operations iopen_inode_operations = { -+ lookup: iopen_lookup, /* BKL held */ -+}; -+ -+static struct file_operations iopen_file_operations = { -+ read: generic_read_dir, -+}; -+ -+static int match_dentry(struct dentry *dentry, const char *name) -+{ -+ int len; -+ -+ len = strlen(name); -+ if (dentry->d_name.len != len) -+ return 0; -+ if (strncmp(dentry->d_name.name, name, len)) -+ return 0; -+ return 1; -+} -+ -+/* -+ * This function is spliced into ext3_lookup and returns 1 the file -+ * name is __iopen__ and dentry has been filled in appropriately. -+ */ -+int ext3_check_for_iopen(struct inode *dir, struct dentry *dentry) -+{ -+ struct inode *inode; -+ -+ if (dir->i_ino != EXT3_ROOT_INO || -+ !test_opt(dir->i_sb, IOPEN) || -+ !match_dentry(dentry, "__iopen__")) -+ return 0; -+ -+ inode = iget(dir->i_sb, EXT3_BAD_INO); -+ -+ if (!inode) -+ return 0; -+ d_add(dentry, inode); -+ return 1; -+} -+ -+/* -+ * This function is spliced into read_inode; it returns 1 if inode -+ * number is the one for /__iopen__, in which case the inode is filled -+ * in appropriately. Otherwise, this fuction returns 0. -+ */ -+int ext3_iopen_get_inode(struct inode *inode) -+{ -+ if (inode->i_ino != EXT3_BAD_INO) -+ return 0; -+ -+ inode->i_mode = S_IFDIR | S_IRUSR | S_IXUSR; -+ if (test_opt(inode->i_sb, IOPEN_NOPRIV)) -+ inode->i_mode |= 0777; -+ inode->i_uid = 0; -+ inode->i_gid = 0; -+ inode->i_nlink = 1; -+ inode->i_size = 4096; -+ inode->i_atime = CURRENT_TIME; -+ inode->i_ctime = CURRENT_TIME; -+ inode->i_mtime = CURRENT_TIME; -+ EXT3_I(inode)->i_dtime = 0; -+ inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size -+ * (for stat), not the fs block -+ * size */ -+ inode->i_blocks = 0; -+ inode->i_version = 1; -+ inode->i_generation = 0; -+ -+ inode->i_op = &iopen_inode_operations; -+ inode->i_fop = &iopen_file_operations; -+ inode->i_mapping->a_ops = 0; -+ -+ return 1; -+} -Index: linux-stage/fs/ext3/iopen.h -=================================================================== ---- linux-stage.orig/fs/ext3/iopen.h 1969-12-31 19:00:00.000000000 -0500 -+++ linux-stage/fs/ext3/iopen.h 2004-05-11 17:21:21.000000000 -0400 -@@ -0,0 +1,15 @@ -+/* -+ * iopen.h -+ * -+ * Special support for opening files by inode number. -+ * -+ * Copyright (C) 2001 by Theodore Ts'o (tytso@alum.mit.edu). -+ * -+ * This file may be redistributed under the terms of the GNU General -+ * Public License. -+ */ -+ -+extern int ext3_check_for_iopen(struct inode *dir, struct dentry *dentry); -+extern int ext3_iopen_get_inode(struct inode *inode); -+extern struct dentry *iopen_connect_dentry(struct dentry *dentry, -+ struct inode *inode, int rehash); -Index: linux-stage/fs/ext3/namei.c -=================================================================== ---- linux-stage.orig/fs/ext3/namei.c 2004-05-11 17:21:20.000000000 -0400 -+++ linux-stage/fs/ext3/namei.c 2004-05-11 17:21:21.000000000 -0400 -@@ -37,6 +37,7 @@ - #include - #include - #include "xattr.h" -+#include "iopen.h" - #include "acl.h" - - /* -@@ -979,6 +980,9 @@ - if (dentry->d_name.len > EXT3_NAME_LEN) - return ERR_PTR(-ENAMETOOLONG); - -+ if (ext3_check_for_iopen(dir, dentry)) -+ return NULL; -+ - bh = ext3_find_entry(dentry, &de); - inode = NULL; - if (bh) { -@@ -989,10 +993,8 @@ - if (!inode) - return ERR_PTR(-EACCES); - } -- if (inode) -- return d_splice_alias(inode, dentry); -- d_add(dentry, inode); -- return NULL; -+ -+ return iopen_connect_dentry(dentry, inode, 1); - } - - -@@ -2019,10 +2021,6 @@ - inode->i_nlink); - inode->i_version++; - inode->i_nlink = 0; -- /* There's no need to set i_disksize: the fact that i_nlink is -- * zero will ensure that the right thing happens during any -- * recovery. */ -- inode->i_size = 0; - ext3_orphan_add(handle, inode); - inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; - ext3_mark_inode_dirty(handle, inode); -@@ -2139,6 +2137,23 @@ - return err; - } - -+/* Like ext3_add_nondir() except for call to iopen_connect_dentry */ -+static int ext3_add_link(handle_t *handle, struct dentry *dentry, -+ struct inode *inode) -+{ -+ int err = ext3_add_entry(handle, dentry, inode); -+ if (!err) { -+ err = ext3_mark_inode_dirty(handle, inode); -+ if (err == 0) { -+ (void)iopen_connect_dentry(dentry, inode, 0); -+ return 0; -+ } -+ } -+ ext3_dec_count(handle, inode); -+ iput(inode); -+ return err; -+} -+ - static int ext3_link (struct dentry * old_dentry, - struct inode * dir, struct dentry *dentry) - { -@@ -2161,7 +2176,8 @@ - ext3_inc_count(handle, inode); - atomic_inc(&inode->i_count); - -- err = ext3_add_nondir(handle, dentry, inode); -+ err = ext3_add_link(handle, dentry, inode); -+ ext3_orphan_del(handle,inode); - ext3_journal_stop(handle); - return err; - } -Index: linux-stage/fs/ext3/super.c -=================================================================== ---- linux-stage.orig/fs/ext3/super.c 2004-05-11 17:21:21.000000000 -0400 -+++ linux-stage/fs/ext3/super.c 2004-05-11 17:44:53.000000000 -0400 -@@ -536,7 +536,7 @@ - Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_noload, - Opt_commit, Opt_journal_update, Opt_journal_inum, - Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, -- Opt_ignore, Opt_barrier, -+ Opt_ignore, Opt_barrier, Opt_iopen, Opt_noiopen, Opt_iopen_nopriv, - Opt_err, - }; - -@@ -577,6 +577,9 @@ - {Opt_ignore, "quota"}, - {Opt_ignore, "usrquota"}, - {Opt_barrier, "barrier=%u"}, -+ {Opt_iopen, "iopen"}, -+ {Opt_noiopen, "noiopen"}, -+ {Opt_iopen_nopriv, "iopen_nopriv"}, - {Opt_err, NULL} - }; - -@@ -772,6 +775,18 @@ - else - clear_opt(sbi->s_mount_opt, BARRIER); - break; -+ case Opt_iopen: -+ set_opt (sbi->s_mount_opt, IOPEN); -+ clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV); -+ break; -+ case Opt_noiopen: -+ clear_opt (sbi->s_mount_opt, IOPEN); -+ clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV); -+ break; -+ case Opt_iopen_nopriv: -+ set_opt (sbi->s_mount_opt, IOPEN); -+ set_opt (sbi->s_mount_opt, IOPEN_NOPRIV); -+ break; - case Opt_ignore: - break; - default: -Index: linux-stage/include/linux/ext3_fs.h -=================================================================== ---- linux-stage.orig/include/linux/ext3_fs.h 2004-05-11 17:21:20.000000000 -0400 -+++ linux-stage/include/linux/ext3_fs.h 2004-05-11 17:21:21.000000000 -0400 -@@ -326,6 +326,8 @@ - #define EXT3_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */ - #define EXT3_MOUNT_POSIX_ACL 0x8000 /* POSIX Access Control Lists */ - #define EXT3_MOUNT_BARRIER 0x10000 /* Use block barriers */ -+#define EXT3_MOUNT_IOPEN 0x20000 /* Allow access via iopen */ -+#define EXT3_MOUNT_IOPEN_NOPRIV 0x40000 /* Make iopen world-readable */ - - /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */ - #ifndef _LINUX_EXT2_FS_H diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series deleted file mode 100644 index d27088e..0000000 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series +++ /dev/null @@ -1,10 +0,0 @@ -ext3-wantedi-2.6-suse.patch -ext3-san-jdike-2.6-suse.patch -iopen-2.6-suse.patch -export_symbols-ext3-2.6-suse.patch -ext3-map_inode_page-2.6-suse.patch -ext3-init-generation-2.6-suse.patch -ext3-ea-in-inode-2.6-suse.patch -export-ext3-2.6-suse.patch -ext3-include-fixes-2.6-suse.patch -ext3-htree-rename_fix.patch diff --git a/ldiskfs/ldiskfs/Makefile.in b/ldiskfs/ldiskfs/Makefile.in deleted file mode 100644 index 80d9efb..0000000 --- a/ldiskfs/ldiskfs/Makefile.in +++ /dev/null @@ -1,18 +0,0 @@ -default: all - -MODULES := ldiskfs - -# copy makefile over to not break patches -ext3_extra := $(wildcard @LINUX@/fs/ext3/Makefile) - -ext3_headers := $(wildcard @LINUX@/fs/ext3/*.h) -linux_headers := $(wildcard @LINUX@/include/linux/ext3*.h) -new_linux_hearders := ext3_extents.h -ext3_sources := $(filter-out %.mod.c,$(wildcard @LINUX@/fs/ext3/*.c)) -new_sources := iopen.c iopen.h extents.c extents-in-ea.c -ldiskfs_sources := $(notdir $(ext3_sources) $(ext3_headers)) $(new_sources) -ldiskfs-objs := $(filter %.o,$(ldiskfs_sources:.c=.o)) - -EXTRA_PRE_CFLAGS := -I@LINUX@/fs -I@LUSTRE@ -I@LUSTRE@/ldiskfs - -@INCLUDE_RULES@ diff --git a/ldiskfs/ldiskfs/autoMakefile.am b/ldiskfs/ldiskfs/autoMakefile.am deleted file mode 100644 index 4fd32d4..0000000 --- a/ldiskfs/ldiskfs/autoMakefile.am +++ /dev/null @@ -1,77 +0,0 @@ -if MODULES -if LDISKFS -modulefs_DATA = ldiskfs$(KMODEXT) -endif -endif - -ldiskfs_linux_headers := $(addprefix linux/,$(subst ext3,ldiskfs,$(notdir $(linux_headers)))) - -$(filter %.c,$(ldiskfs_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_sources)) - -ldiskfs_sed_flags = \ - -e "s/dx_hash_info/ext3_dx_hash_info/g" \ - -e "s/dir_private_info/ext3_dir_private_info/g" \ - -e "s/DX_HASH/EXT3_DX_HASH/g" \ - -e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g" - -%.c: linux-stage/fs/ext3/%.c - sed $(strip $(ldiskfs_sed_flags)) $< > $@ - -%.h: linux-stage/fs/ext3/%.h - sed $(strip $(ldiskfs_sed_flags)) $< > $@ - -linux/ldiskfs%.h: linux-stage/include/linux/ext3%.h - sed $(strip $(ldiskfs_sed_flags)) $< > $@ - -# -# FIXME: we need to grab the series in configure somehow -# (see bug 1679) -# -series := @top_srcdir@/lustre/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES) -patches := @top_srcdir@/lustre/kernel_patches/patches - -sources: $(ext3_sources) $(ext3_headers) $(linux_headers) $(series) - rm -rf linux-stage linux sources $(ldiskfs_SOURCES) - mkdir -p linux-stage/fs/ext3 linux-stage/include/linux - cp $(ext3_sources) $(ext3_headers) $(ext3_extra) linux-stage/fs/ext3 - cp $(linux_headers) linux-stage/include/linux - cd linux-stage && quilt push -a -q -if USE_QUILT - cd linux-stage && quilt setup -l ../$(series) -d ../$(patches) - cd linux-stage && quilt push -a -q -else - @cd linux-stage && for i in $$(<../$(series)) ; do \ - echo "patch -p1 < ../$(patches)/$$i" ; \ - patch -p1 < ../$(patches)/$$i || exit 1 ; \ - done -endif - - mkdir linux - @echo -n "Replacing 'ext3' with 'ldiskfs':" - @for i in $(notdir $(ext3_headers) $(ext3_sources)) $(new_sources) ; do \ - echo -n " $$i" ; \ - sed $(strip $(ldiskfs_sed_flags)) \ - linux-stage/fs/ext3/$$i > $$i ; \ - done - @for i in $(subst ext3,,$(notdir $(linux_headers)) $(new_linux_hearders)) ; do \ - echo -n " ext3$$i" ; \ - sed $(strip $(ldiskfs_sed_flags)) \ - linux-stage/include/linux/ext3$$i \ - > linux/ldiskfs$$i ; \ - done - @echo - touch sources - -foo-check: - @echo "ldiskfs_sources: $(ldiskfs_sources)" - @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)" - @echo "ldiskfs_headers: $(ldiskfs_headers)" - @echo "ldiskfs_objects: $(ldiskfs_objects)" - @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)" - @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)" - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -CLEANFILES = sources *.c *.h - -clean: clean-am - rm -rf linux linux-stage diff --git a/libsysio/AUTHORS b/libsysio/AUTHORS deleted file mode 100644 index 7293307..0000000 --- a/libsysio/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Lee Ward diff --git a/libsysio/COPYING b/libsysio/COPYING deleted file mode 100644 index 2bb5b6e..0000000 --- a/libsysio/COPYING +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/libsysio/ChangeLog b/libsysio/ChangeLog deleted file mode 100644 index 126c27f..0000000 --- a/libsysio/ChangeLog +++ /dev/null @@ -1,31 +0,0 @@ -Sat Feb 22 10:32:10 EST 2003 - Created ---- - -*Added mount() api call to support sub-mounts. - -*Added rudimentary automounts per the namespace chapter in the "Lustre -Architecture Reference". Note, full URI support is not implemented. See -the README for details. - -Think I have it going for simultaneous 32/64 bit support. Together with -the nagging build for test_stat. - -*Miscellaneous bugs fixed. - ---- -Lee -- Sat Mar 22 15:01:45 EST 2003 - -*Added "incore" file system. An in-memory file system solving boot-strap -and other annoying little chicken-and-the-egg problems. - -*Added support for devices - -*Added support for accessing the pre-opened standard file descriptors 0, 1, -and 2 via the stdfd device driver (major number 0, minor 0, 1, and 2). - ---- -Lee -- Mon Jan 26 11:26:14 EST 2004 - -*Altered the internal interface to pass the xtvec (see .../include/xtio.h) in -order to support strided-io. diff --git a/libsysio/Makefile.am b/libsysio/Makefile.am deleted file mode 100644 index dfa4f9e..0000000 --- a/libsysio/Makefile.am +++ /dev/null @@ -1,89 +0,0 @@ -AUTOMAKE_OPTIONS=1.6 - -if WITH_TESTS -TESTDIR = tests -else -TESTDIR = -endif - -include $(top_srcdir)/src/module.mk -include $(top_srcdir)/include/module.mk -include $(top_srcdir)/tests/module.mk -include $(top_srcdir)/dev/stdfd/module.mk -include $(top_srcdir)/drivers/incore/module.mk -include $(top_srcdir)/drivers/native/module.mk -include $(top_srcdir)/drivers/yod/module.mk -include $(top_srcdir)/drivers/sockets/module.mk - -lib_LIBRARIES = ${LIBBUILD_DIR}/libsysio.a - -if WITH_STDFD_DEV -OPTIONAL_STDFD_SRCS = $(STDFD_SRCS) -else -OPTIONAL_STDFD_SRCS = -endif - -if WITH_INCORE_DRIVER -OPTIONAL_INCORE_SRCS = $(INCORE_SRCS) -else -OPTIONAL_INCORE_SRCS = -endif - -if WITH_NATIVE_DRIVER -OPTIONAL_NATIVE_SRCS = $(NATIVE_SRCS) -else -OPTIONAL_NATIVE_SRCS = -endif - -if WITH_SOCKETS_DRIVER -OPTIONAL_SOCKETS_SRCS = $(SOCKETS_SRCS) -else -OPTIONAL_SOCKETS_SRCS = -endif - -if WITH_CPLANT_YOD -OPTIONAL_YOD_SRCS = $(YOD_SRCS) -else -OPTIONAL_YOD_SRCS = -endif - -if WITH_LUSTRE_HACK -# it would be better that let configure script check this -OPTIONAL_LUSTRE_CFLAGS = -fPIC -endif - -AM_CFLAGS = $(OPTIONAL_LUSTRE_CFLAGS) - -__LIBBUILD_DIR__libsysio_a_SOURCES = \ - $(SRCDIR_SRCS) \ - $(OPTIONAL_STDFD_SRCS) \ - $(OPTIONAL_INCORE_SRCS) \ - $(OPTIONAL_SOCKETS_SRCS) \ - $(OPTIONAL_NATIVE_SRCS) \ - $(OPTIONAL_YOD_SRCS) - -include $(top_srcdir)/Rules.make - -EXTRA_DIST = Rules.make misc/init-env.sh $(TESTS_EXTRA) $(SRCDIR_EXTRA) \ - $(INCLUDE_EXTRA) $(STDFD_EXTRA) $(INCORE_EXTRA) \ - $(SOCKETS_EXTRA) $(NATIVE_EXTRA) $(YOD_EXTRA) - -AM_CPPFLAGS += ${YOD_DRIVER_FLAGS} - -really-clean: testsclean maintainer-clean - -rm -rf autom4te-2.53.cache - -rm -rf .deps - -rm -f Makefile.in - -rm -f compile depcomp INSTALL install-sh missing mkinstalldirs \ - configure aclocal.m4 - -rm -f config.guess config.sub - -rm -rf $(LIBBUILD_DIR) - -rm -f libsysio*.tar.gz - cd $(TESTDIR); rm -rf Makefile Makefile.in .deps - -tests: $(lib_LIBRARIES) FORCE - cd $(TESTDIR); make -testsclean: FORCE - cd $(TESTDIR); make clean -clean: testsclean clean-am -FORCE: diff --git a/libsysio/NEWS b/libsysio/NEWS deleted file mode 100644 index e69de29..0000000 diff --git a/libsysio/README b/libsysio/README deleted file mode 100644 index 76b9b97..0000000 --- a/libsysio/README +++ /dev/null @@ -1,66 +0,0 @@ -Build ------ - -To bootstrap configuration: - -sh autogen.sh -./configure [options] - -Without the supported "--with" options only the core sysio library is -built. - -Option --with-native-driver=yes will cause the "native" host name space test -driver to be enabled and made available in drivers/native/libsysio_native.a -when built. This is set by default; Use "no" to disable. - -Option --with-tests=yes will cause the test programs in the tests directory -to be enabled. This is set by default; Use "no" to disable. - -Option --with-automount= will cause automount support -to be included. If is not supplied, a default value -of ".mount" will be used, matching the Lustre documentation. - -To build: - -Just `make' it. - -Automounts ----------- - -For a full description of this see the "Lustre Book" at: - - -In short, though, whenever a component is being looked up in a directory and -that directory has the "set-UID" bit set, then the directory is -searched for a special file. By default, that file is called ".mount" but -you may set it to any name using the --with-automount option described -earlier. - -If the content of that file has something formatted, exactly: - -: - -Then the description is mounted on the directory containing the -special automount file and being used as the parent in the lookup. If the -mount is successful, the parent is replaced with the newly mounted directory -and processing continues. If the mount fails, or the automount file -does not exist or cannot be read, everything continues as though the operation -had never been attempted. - -File systems, or volumes, or file-sets, or whatever they are called, that -have been automounted may also be automatically unmounted when resource -is required. They are not on a timer, unless the file system driver implements -one for them. They just disappear as resource is needed elsewhere. As they -were automatically mounted to begin with, they should re-establish as needed, -transparently. - -REDSTORM --------- - -The following works for me: - -#!/bin/sh - -export CFLAGS="-DREDSTORM -nostdinc -isystem /home/lee/REDSTORM/catamount/computeincs/i386 -isystem /home/lee/REDSTORM/catamount/include -g -W -Wall -ansi" - -sh configure --with-autmount=".mount" --with-native=yes --with-incore-yes --with-stdfd=yes --with-tests=yes diff --git a/libsysio/Rules.make b/libsysio/Rules.make deleted file mode 100644 index 057611b..0000000 --- a/libsysio/Rules.make +++ /dev/null @@ -1,19 +0,0 @@ - -if WITH_STDFD_DEV -STDFD_DEV_CPPFLAGS =-DSTDFD_DEV=1 -I$(top_srcdir)/dev/stdfd -else -STFD_DEV_CPPFLAGS = -endif - -if WITH_SOCKETS_DRIVER -SOCKETS_CPPFLAGS=-DWITH_SOCKETS=1 -else -SOCKETS_CPPFLAGS= -endif - -DEV_CPPFLAGS = $(STDFD_DEV_CPPFLAGS) - -AM_CPPFLAGS = \ - -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=600 \ - $(AUTOMOUNT) $(ZERO_SUM_MEMORY) $(DEV_CPPFLAGS) $(SOCKETS_CPPFLAGS) \ - -I$(top_srcdir)/include diff --git a/libsysio/autogen.sh b/libsysio/autogen.sh deleted file mode 100755 index 81ad5b6..0000000 --- a/libsysio/autogen.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -aclocal && -automake --add-missing --copy && -${AUTOCONF:-autoconf} diff --git a/libsysio/configure.in b/libsysio/configure.in deleted file mode 100644 index 9f83269..0000000 --- a/libsysio/configure.in +++ /dev/null @@ -1,427 +0,0 @@ -AC_INIT(libsysio, 0.1) - -AC_CANONICAL_HOST - -case "$host_os" in - linux*) - ;; - *) - AC_MSG_WARN('***' ${host_os}: Unsupported OS target) - ;; -esac - -AM_INIT_AUTOMAKE([subdir-objects]) -AM_PROG_CC_C_O - -AC_PROG_CC -AC_PROG_RANLIB -AC_PROG_MAKE_SET -AC_HEADER_STDC -AC_HEADER_STAT -AC_HEADER_TIME - -have_lib_dir=yes; -AC_ARG_WITH(lib-dir, - AC_HELP_STRING([--with-lib-dir=], - [directory for sysio library]), - [ case "${withval}" in - "yes"|"no"|"") have_lib_dir=no ;; - *) LIBBUILD_DIR=${withval}; - test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} || - have_lib_dir=no;; - esac;], - [ LIBBUILD_DIR=`pwd`/lib; - test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} || have_lib_dir=no;]) -if test x${have_lib_dir} = xyes; then - echo "Using sysio library directory ${LIBBUILD_DIR}" -else - AC_MSG_ERROR(Need writeable path to sysio library directory ${LIBBUILD_DIR}) -fi -AC_SUBST(LIBBUILD_DIR) - -AC_ARG_WITH(native_driver, - AC_HELP_STRING([--with-native-driver],[build native test driver]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-native-driver) ;; - esac;], - [with_native_driver=yes;]) -AM_CONDITIONAL(WITH_NATIVE_DRIVER, test x$with_native_driver = xyes) - -AC_ARG_WITH(incore-driver, - AC_HELP_STRING([--with-incore-driver],[build incore test driver]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-incore-driver) ;; - esac], - [with_incore_driver=yes]) -AM_CONDITIONAL(WITH_INCORE_DRIVER, test x$with_incore_driver = xyes) - -AC_ARG_WITH(tests, - AC_HELP_STRING([--with-tests],[build tests]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-tests) ;; - esac], - [with_tests=yes]) -AM_CONDITIONAL(WITH_TESTS, test x$with_tests = xyes) - -AC_ARG_WITH(automount, - AC_HELP_STRING([--with-automount@<:@=@:>@], - [with automounts @<:@=.mount@:>@]), - [ if test x${withval} = xyes; then - AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\".mount\\\"" - elif test x${withval} != x; then - AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\"${withval}\\\"" - fi]) -AC_SUBST(AUTOMOUNT) - -AC_ARG_WITH(stdfd-dev, - AC_HELP_STRING([--with-stdfd-dev], - [build standard file descriptors pseudo-driver]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-stdfd-dev) ;; - esac], - [with_stdfd_dev=yes]) -AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes) - -AC_ARG_WITH(zero-sum-memory, - AC_HELP_STRING([--with-zero-sum-memory], - [free all dynamically allocated memory at the end -- useful for debugging]), - [ case "${withval}" in - yes) ZERO_SUM_MEMORY=-DZERO_SUM_MEMORY=1 ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-zero-sum-memory) ;; - esac], - [with_zero_sum_memory=no]) -AC_SUBST(ZERO_SUM_MEMORY) - -AC_ARG_WITH(cplant_yod, - AC_HELP_STRING([--with-cplant-yod],[build cplant yod I/O driver]), - [ case "${withval}" in - yes) if test x${with_stdfd_dev} != xyes; then - with_stdfd_dev=yes - AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes) - fi ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-cplant-yod);; - esac], - [with_cplant_yod=no]) -AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes) - -AC_ARG_WITH(cplant_tests, - AC_HELP_STRING([--with-cplant-tests=], - [build libsysio tests for cplant platform]), - [ case "${withval}" in - yes) AC_MSG_ERROR(need path to compiler for --with-cplant-tests);; - no) with_cplant_tests=no;; - *) CC=${withval} - CCDEPMODE=${CC} - CPP="${CC} -E" - AC_CHECK_FILE(${CC}, - [ if test x${with_cplant_yod} != xyes; then - with_cplant_yod=yes - AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes) - fi], - [ AC_MSG_ERROR(path not found ${CC} for --with-cplant-tests) ]);; - esac], - [with_cplant_tests=no]) -AM_CONDITIONAL(WITH_CPLANT_TESTS, test x$with_cplant_tests != xno) - -AC_ARG_WITH(sockets, - AC_HELP_STRING([--with-sockets], - [build sockets interface driver (EXPERIMENTAL)]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-sockets) ;; - esac], - [with_sockets=no]) -AM_CONDITIONAL(WITH_SOCKETS_DRIVER, test x$with_sockets = xyes) - -AC_ARG_WITH(lustre-hack, - AC_HELP_STRING([--with-lustre-hack], - [have hacking code which needed to support liblustre driver (EXPERIMENTAL)]), - [ case "${withval}" in - yes) ;; - no) ;; - *) AC_MSG_ERROR(bad value ${withval} for --with-lustre-hack) ;; - esac], - [with_lustre_hack=no]) -AM_CONDITIONAL(WITH_LUSTRE_HACK, test x$with_lustre_hack = xyes) -if test x$with_lustre_hack = xyes; then - AC_DEFINE(HAVE_LUSTRE_HACK) -fi - -# We keep the original values in `$config_*' and never modify them, so we -# can write them unchanged into config.make. Everything else uses -# $machine, $vendor, and $os, and changes them whenever convenient. -config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os - -# Don't allow vendor == "unknown" -test "$config_vendor" = unknown && config_vendor= -config_os="`echo $config_os | sed 's/^unknown-//'`" - -# Some configurations imply other options. -case "$host_os" in - gnu* | linux* | bsd4.4* | netbsd* | freebsd*) - # These systems always use GNU tools. - gnu_ld=yes gnu_as=yes ;; -esac -case "$host_os" in - # i586-linuxaout is mangled into i586-pc-linux-gnuaout - linux*ecoff* | linux*aout* | gnu*aout* | gnu*ecoff*) - ;; - gnu* | linux* | freebsd* | netbsd* | sysv4* | solaris2* | irix6*) - # These systems (almost) always use the ELF format. - elf=yes - ;; - aix*) - # These systems are always xcoff - xcoff=yes - elf=no - ;; -esac - -machine=$config_machine -vendor=$config_vendor -os=$config_os - -# config.guess on some IBM machines says `rs6000' instead of `powerpc'. -# Unify this here. -if test "$machine" = rs6000; then - machine="powerpc" -fi - -# If we can't provoke the declaration of stat64 then we assume the -# environment supports 64-bit file support naturally. Beware! -AC_MSG_CHECKING(whether _LARGEFILE64_SOURCE definition is required) -AC_TRY_COMPILE([ -#include -#include -#include ], [ -struct stat64 st64;], -sysio_largefile64_source_required=no, -sysio_largefile64_source_required=maybe) -if test x$sysio_largefile64_source_required = xmaybe; then - AC_TRY_COMPILE([ -#define _LARGEFILE64_SOURCE -#include -#include -#include ], [ -struct stat64 st64;], - sysio_largefile64_source_required=yes, - sysio_largefile64_source_required=no) -fi -AC_MSG_RESULT($sysio_largefile64_source_required) -if test x$sysio_largefile64_source_required = xyes; then - AC_DEFINE(_LARGEFILE64_SOURCE) -fi - -# Alpha linux defines -# -AC_MSG_CHECKING(for alpha linux) -alpha_linux_env=no -if test `expr ${machine} : "alpha"` = 5 && \ - test `expr ${os} : "linux"` = 5; then - alpha_linux_env=yes - AC_DEFINE(ALPHA_LINUX) -fi -AC_MSG_RESULT($alpha_linux_env) -AM_CONDITIONAL(TEST_ALPHA_ARG, test x$alpha_linux_env = xyes) - -# check for 64 bit stat, fstat, truncate, ftruncate syscalls -# -AC_MSG_CHECKING(for 64 bit stat and truncate syscalls) -AC_TRY_COMPILE([ -#include -#include -extern int syscall();], -[char path[] = "/"; -int fd = 0; -struct stat buf; -syscall(SYS_stat64,path,&buf); -syscall(SYS_fstat64,fd,&buf); -syscall(SYS_truncate64, path, buf.st_size); -syscall(SYS_ftruncate64, fd, buf.st_size); -], - sysstat64_exists=yes, - sysstat64_exists=no) -AC_MSG_RESULT($sysstat64_exists) -if test x$sysstat64_exists = xno; then - AC_DEFINE(USE_NATIVE_STAT) -fi - -# Check for fdatasync syscall -# -AC_MSG_CHECKING(for fdatasync system call) -if test x$alpha_linux_env = xyes; then - _syscallnum=SYS_osf_fdatasync -else - _syscallnum=SYS_fdatasync -fi -AC_TRY_COMPILE([ -#include -extern int syscall();], -[int fd = 0; -syscall(SYS_fdatasync, fd);], - syscall_fdatasync_exists=yes, - syscall_fdatasync_exists=no) -AC_MSG_RESULT($syscall_fdatasync_exists) -if test x$syscall_fdatasync_exists = xyes; then - AC_DEFINE_UNQUOTED(NATIVE_FDATASYNC, $_syscallnum) -fi - -# Check for SYS_utime -# -AC_MSG_CHECKING(for utime system call) -AC_TRY_COMPILE([ -#include -extern int syscall();], -[syscall(SYS_utime);], - syscall_utime_exists=yes, - syscall_utime_exists=no) -AC_MSG_RESULT($syscall_utime_exists) -if test x$syscall_utime_exists = xno; then - AC_DEFINE(USE_NATIVE_UTIME) -fi -# Check for __st_ino -# -AC_MSG_CHECKING(for __st_ino) -AC_TRY_COMPILE([ -#include ], -[struct stat st; -st.__st_ino = 0;], - have__st_ino=yes, - have__st_ino=no) -AC_MSG_RESULT($have__st_ino) -if test x$have__st_ino = xyes; then - AC_DEFINE(HAVE__ST_INO) -fi - -# Check for st_gen -# -AC_MSG_CHECKING(for st_gen) -AC_TRY_COMPILE([ -#include ], -[struct stat st; -st.st_gen = 0;], - have_st_gen=yes, - have_st_gen=no) -AC_MSG_RESULT($have_st_gen) -if test x$have_st_gen = xyes; then - AC_DEFINE(HAVE_GENERATION) -fi - -AC_MSG_CHECKING(whether .text pseudo-op must be used) -AC_CACHE_VAL(sysio_asm_dot_text, [dnl -cat > conftest.s </dev/null; then - sysio_asm_dot_text=.text - fi - rm -f conftest*]) -if test -z "$sysio_dot_text"; then - AC_MSG_RESULT(no) -else - AC_MSG_RESULT(yes) -fi - -AC_CACHE_CHECK(for assembler global-symbol directive, - sysio_asm_global_directive, [dnl -sysio_asm_global_directive=UNKNOWN -for ac_globl in .globl .global .EXPORT; do - cat > conftest.s </dev/null; then - sysio_asm_global_directive=${ac_globl} - fi - rm -f conftest* - test $sysio_asm_global_directive != UNKNOWN && break -done]) -if test $sysio_asm_global_directive = UNKNOWN; then - AC_MSG_ERROR(cannot determine asm global directive) -#else -# AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${sysio_asm_global_directive}) -fi - -AC_CACHE_CHECK(for .set assembler directive, - sysio_asm_set_directive, [dnl -cat > conftest.s< conftest1.c <&AC_FD_CC 2>&AC_FD_CC; then - sysio_asm_set_directive=yes - else - sysio_asm_set_directive=no - fi - rm -f conftest*]) -#if test $sysio_asm_set_directive = yes; then -# AC_DEFINE(HAVE_ASM_SET_DIRECTIVE) -#fi - -AC_CACHE_CHECK(for assembler .weak directive, sysio_asm_weak_directive, - [dnl -cat > conftest.s </dev/null; then - sysio_asm_weak_directive=yes - else - sysio_asm_weak_directive=no - fi - rm -f conftest*]) - -if test $sysio_asm_weak_directive = no; then - AC_CACHE_CHECK(for assembler .weakext directive, - sysio_asm_weakext_directive, [dnl -cat > conftest.s </dev/null; then - sysio_asm_weakext_directive=yes - else - sysio_asm_weakext_directive=no - fi - rm -f conftest*]) -fi # no .weak - -if test x$sysio_asm_weak_directive = xyes; then - AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE) -fi -if test x$sysio_asm_weakext_directive = xyes; then - AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE) -fi - -AC_OUTPUT( - Makefile - tests/Makefile) - diff --git a/libsysio/dev/stdfd/module.mk b/libsysio/dev/stdfd/module.mk deleted file mode 100644 index ad034fb..0000000 --- a/libsysio/dev/stdfd/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -STDFD_SRCS = dev/stdfd/stdfd.c -STDFD_EXTRA = dev/stdfd/stdfd.h dev/stdfd/module.mk diff --git a/libsysio/dev/stdfd/stdfd.c b/libsysio/dev/stdfd/stdfd.c deleted file mode 100644 index aa6bf85..0000000 --- a/libsysio/dev/stdfd/stdfd.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "inode.h" -#include "dev.h" - -#include "stdfd.h" - -#ifdef CPLANT_YOD -#include -#include "cplant-yod.h" -#define dowrite(f, b, n) write_yod(f, b, n) -#define doread(f, b, n) read_yod(f, b, n) -#else -#define dowrite(f, b, n) syscall(SYS_write, f, b, n) -#define doread(f, b, n) syscall(SYS_read, f, b, n) -#endif - -/* - * Pre-opened standard file descriptors driver. - */ - -static int stdfd_open(struct pnode *pno, int flags, mode_t mode); -static int stdfd_close(struct inode *ino); -static int stdfd_read(struct inode *ino, struct ioctx *ioctx); -static int stdfd_write(struct inode *ino, struct ioctx *ioctx); -static int stdfd_iodone(struct ioctx *ioctx); -static int stdfd_datasync(struct inode *ino); -static int stdfd_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); - -int -_sysio_stdfd_init() -{ - struct inode_ops stdfd_operations; - - stdfd_operations = _sysio_nodev_ops; - stdfd_operations.inop_open = stdfd_open; - stdfd_operations.inop_close = stdfd_close; - stdfd_operations.inop_read = stdfd_read; - stdfd_operations.inop_write = stdfd_write; - stdfd_operations.inop_iodone = stdfd_iodone; - stdfd_operations.inop_datasync = stdfd_datasync; - stdfd_operations.inop_ioctl = stdfd_ioctl; - - return _sysio_char_dev_register(SYSIO_C_STDFD_MAJOR, - "stdfd", - &stdfd_operations); -} - -static int -stdfd_open(struct pnode *pno __IS_UNUSED, - int flags __IS_UNUSED, - mode_t mode __IS_UNUSED) -{ - - return 0; -} - -static int -stdfd_close(struct inode *ino __IS_UNUSED) -{ - - return 0; -} - -static int -doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct inode *), - struct inode *ino, - struct ioctx *ioctx) -{ - - if (ioctx->ioctx_xtvlen != 1) { - /* - * No scatter/gather to "file" address space (we're not - * seekable) and "nowhere" makes no sense. - */ - return -EINVAL; - } - ioctx->ioctx_cc = - _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(void *, size_t, _SYSIO_OFF_T, void *))f, - ino); - if (ioctx->ioctx_cc < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - } - return 0; -} - -static ssize_t -stdfd_read_simple(void *buf, - size_t nbytes, - _SYSIO_OFF_T off __IS_UNUSED, - struct inode *ino) -{ - - int fd = SYSIO_MINOR_DEV(ino->i_rdev); - - return doread(fd, buf, nbytes); -} - -static int -stdfd_read(struct inode *ino, struct ioctx *ioctx) -{ - - return doio(stdfd_read_simple, ino, ioctx); -} - -static ssize_t -stdfd_write_simple(const void *buf, - size_t nbytes, - _SYSIO_OFF_T off __IS_UNUSED, - struct inode *ino) -{ - int fd = SYSIO_MINOR_DEV(ino->i_rdev); - - return dowrite(fd, buf, nbytes); -} - -static int -stdfd_write(struct inode *ino, struct ioctx *ioctx) -{ - - return doio((ssize_t (*)(void *, - size_t, - _SYSIO_OFF_T, - struct inode *))stdfd_write_simple, - ino, - ioctx); -} - -static int -stdfd_iodone(struct ioctx *iocp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -stdfd_datasync(struct inode *ino __IS_UNUSED) -{ - - /* - * We don't buffer, so nothing to do. - */ - return 0; -} - -static int -stdfd_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - return -ENOTTY; -} diff --git a/libsysio/dev/stdfd/stdfd.h b/libsysio/dev/stdfd/stdfd.h deleted file mode 100644 index 3bac7c1..0000000 --- a/libsysio/dev/stdfd/stdfd.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Std{in,out,err} pseudo-device-driver support. - */ - -#define SYSIO_C_STDFD_MAJOR 0 - -extern int _sysio_stdfd_init(void); diff --git a/libsysio/drivers/incore/README b/libsysio/drivers/incore/README deleted file mode 100644 index 2f8c4b8..0000000 --- a/libsysio/drivers/incore/README +++ /dev/null @@ -1,27 +0,0 @@ -This "incore" file system driver is a self-contained file system. It does -not use any resource external to the node. - -It is primarily intended for enabling an efficient compute-node bootstrap. It -might also be useful for a very small scratch file system, holding device -files, and the like. - -The root directory i-node is manufactured on the fly. The source specification -for the mount() call should be something like: - - ++ - -Where: - are the directory permissions masked by 0777 - Note -- no umask is applied. - should be the owner's uid - should be the owner's gid - -Most operations are supported, with the notable exception of symbolic -links. - -In the implementation, the driver is really set up to export most -useful symbols without polluting the name space or contending with -other public symbols. However, the symbols are not yet exported. If -we ever require a proc-fs style file system, this could be very useful -provided a little extra work is done to allow other drivers to overload -some operations. Particularly the file ops, I would think. diff --git a/libsysio/drivers/incore/fs_incore.c b/libsysio/drivers/incore/fs_incore.c deleted file mode 100644 index ca10b4f..0000000 --- a/libsysio/drivers/incore/fs_incore.c +++ /dev/null @@ -1,1697 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _HAVE_STATVFS -#include -#endif -#include - -#include "xtio.h" -#include "sysio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" -#include "dev.h" - -#include "fs_incore.h" - - -/* - * In-core file system pseudo-driver. - */ - -/* - * Pseudo-blocksize. - */ -#define INCORE_BLKSIZE (8192) - -/* - * Format of an incore inode. - */ -struct incore_inode { - LIST_ENTRY(incore_inode) ici_link; /* i-nodes list link */ - unsigned ici_revalidate : 1; /* synch sys inode? */ - struct intnl_stat ici_st; /* attrs */ - struct file_identifier ici_fileid; /* file ID */ - void *ici_data; /* file data */ -}; - -/* - * Given pointer to inode, return pointer to incore-inode. - */ -#define I2IC(ino) ((struct incore_inode *)(ino)->i_private) - -struct incore_filesys { - LIST_HEAD(, incore_inode) icfs_icinodes; /* all i-nodes list */ -}; - -/* - * Given pointer to filesys, return pointer to incore-filesys. - */ -#define FS2ICFS(fs) ((struct incore_filesys *)(fs)->fs_private) - -static int _sysio_incore_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); - -static struct fssw_ops incore_fssw_ops = { - _sysio_incore_fsswop_mount -}; - -static void _sysio_incore_fsop_gone(struct filesys *fs); - -static struct filesys_ops incore_fs_ops = { - _sysio_incore_fsop_gone, -}; - -static int _sysio_incore_dirop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); -static int _sysio_incore_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); -static int _sysio_incore_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -static ssize_t _sysio_incore_dirop_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - _SYSIO_OFF_T *basep); -static int _sysio_incore_dirop_mkdir(struct pnode *pno, mode_t mode); -static int _sysio_incore_dirop_rmdir(struct pnode *pno); -static int _sysio_incore_inop_open(struct pnode *pno, int flags, mode_t mode); -static int _sysio_incore_inop_close(struct inode *ino); -static int _sysio_incore_dirop_link(struct pnode *old, struct pnode *new); -static int _sysio_incore_dirop_unlink(struct pnode *pno); -static int _sysio_incore_dirop_rename(struct pnode *old, struct pnode *new); -static int _sysio_incore_filop_read(struct inode *ino, struct ioctx *ioctx); -static int _sysio_incore_filop_write(struct inode *ino, struct ioctx *ioctx); -static _SYSIO_OFF_T _sysio_incore_filop_pos(struct inode *ino, - _SYSIO_OFF_T off); -static int _sysio_incore_filop_iodone(struct ioctx *ioctx); -static int _sysio_incore_filop_fcntl(struct inode *ino, - int cmd, va_list ap, int *rtn); -static int _sysio_incore_inop_sync(struct inode *ino); -static int _sysio_incore_filop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static int _sysio_incore_dirop_mknod(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS -static int _sysio_incore_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif -static void _sysio_incore_inop_gone(struct inode *ino); - -#define _sysio_incore_dirop_symlink \ - (int (*)(struct pnode *, const char *))_sysio_do_enosys -#define _sysio_incore_dirop_readlink \ - (int (*)(struct pnode *, char *, size_t))_sysio_do_einval -#define _sysio_incore_dirop_read \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_eisdir -#define _sysio_incore_dirop_write \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_eisdir -#define _sysio_incore_dirop_pos \ - (_SYSIO_OFF_T (*)(struct inode *, \ - _SYSIO_OFF_T))_sysio_do_eisdir -#define _sysio_incore_dirop_iodone \ - (int (*)(struct ioctx *))_sysio_do_illop -#define _sysio_incore_dirop_fcntl \ - (int (*)(struct inode *, int, va_list, int *))_sysio_do_eisdir -#define _sysio_incore_dirop_ioctl \ - (int (*)(struct inode *, \ - unsigned long int, \ - va_list))_sysio_do_eisdir - -static struct inode_ops _sysio_incore_dir_ops = { - _sysio_incore_dirop_lookup, - _sysio_incore_inop_getattr, - _sysio_incore_inop_setattr, - _sysio_incore_dirop_getdirentries, - _sysio_incore_dirop_mkdir, - _sysio_incore_dirop_rmdir, - _sysio_incore_dirop_symlink, - _sysio_incore_dirop_readlink, - _sysio_incore_inop_open, - _sysio_incore_inop_close, - _sysio_incore_dirop_link, - _sysio_incore_dirop_unlink, - _sysio_incore_dirop_rename, - _sysio_incore_dirop_read, - _sysio_incore_dirop_write, - _sysio_incore_dirop_pos, - _sysio_incore_dirop_iodone, - _sysio_incore_dirop_fcntl, - _sysio_incore_inop_sync, - _sysio_incore_inop_sync, - _sysio_incore_dirop_ioctl, - _sysio_incore_dirop_mknod, -#ifdef _HAVE_STATVFS - _sysio_incore_inop_statvfs, -#endif - _sysio_incore_inop_gone -}; - -#define _sysio_incore_filop_lookup \ - (int (*)(struct pnode *, \ - struct inode **, \ - struct intent *, \ - const char *))_sysio_do_illop -#define _sysio_incore_filop_getdirentries \ - (ssize_t (*)(struct inode *, \ - char *, \ - size_t, \ - _SYSIO_OFF_T *))_sysio_do_illop -#define _sysio_incore_filop_mkdir \ - (int (*)(struct pnode *, mode_t))_sysio_do_illop -#define _sysio_incore_filop_rmdir \ - (int (*)(struct pnode *))_sysio_do_illop -#define _sysio_incore_filop_symlink \ - (int (*)(struct pnode *, const char *))_sysio_do_illop -#define _sysio_incore_symlinkop_readlink \ - (int (*)(struct pnode *, char *, size_t))_sysio_do_illop -#define _sysio_incore_filop_link \ - (int (*)(struct pnode *old, struct pnode *new))_sysio_do_illop -#define _sysio_incore_filop_unlink \ - (int (*)(struct pnode *pno))_sysio_do_illop -#define _sysio_incore_filop_rename \ - (int (*)(struct pnode *old, struct pnode *new))_sysio_do_illop -#define _sysio_incore_filop_mknod \ - (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_do_illop - -static struct inode_ops _sysio_incore_file_ops = { - _sysio_incore_filop_lookup, - _sysio_incore_inop_getattr, - _sysio_incore_inop_setattr, - _sysio_incore_filop_getdirentries, - _sysio_incore_filop_mkdir, - _sysio_incore_filop_rmdir, - _sysio_incore_filop_symlink, - _sysio_incore_symlinkop_readlink, - _sysio_incore_inop_open, - _sysio_incore_inop_close, - _sysio_incore_filop_link, - _sysio_incore_filop_unlink, - _sysio_incore_filop_rename, - _sysio_incore_filop_read, - _sysio_incore_filop_write, - _sysio_incore_filop_pos, - _sysio_incore_filop_iodone, - _sysio_incore_filop_fcntl, - _sysio_incore_inop_sync, - _sysio_incore_inop_sync, - _sysio_incore_filop_ioctl, - _sysio_incore_filop_mknod, -#ifdef _HAVE_STATVFS - _sysio_incore_inop_statvfs, -#endif - _sysio_incore_inop_gone -}; - -static struct inode_ops _sysio_incore_dev_ops = { - _sysio_incore_filop_lookup, - _sysio_incore_inop_getattr, - _sysio_incore_inop_setattr, - _sysio_incore_filop_getdirentries, - _sysio_incore_filop_mkdir, - _sysio_incore_filop_rmdir, - _sysio_incore_filop_symlink, - _sysio_incore_symlinkop_readlink, - _sysio_nodev_inop_open, - _sysio_nodev_inop_close, - _sysio_incore_filop_link, - _sysio_incore_filop_unlink, - _sysio_incore_filop_rename, - _sysio_nodev_inop_read, - _sysio_nodev_inop_write, - _sysio_nodev_inop_pos, - _sysio_nodev_inop_iodone, - _sysio_incore_filop_fcntl, - _sysio_incore_inop_sync, - _sysio_nodev_inop_sync, - _sysio_nodev_inop_ioctl, - _sysio_incore_filop_mknod, -#ifdef _HAVE_STATVFS - _sysio_incore_inop_statvfs, -#endif - _sysio_incore_inop_gone -}; - -typedef void *(*probe_ty)(void *data, size_t len, void *arg); - -/* - * Lookup data argument bundle record. - */ -struct lookup_data { - struct qstr *name; /* desired entry name */ - struct intnl_dirent *de; /* last dirent */ - size_t minsiz; /* min hole needed */ - struct { - void *p; /* best hole */ - size_t len; /* best hole len */ - } hole; -}; - -/* - * Initialize lookup data argument bundle. - */ -#define INCORE_LD_INIT(ld, minsz, qs) \ - do { \ - (ld)->name = (qs); \ - (ld)->de = NULL; \ - (ld)->minsiz = (minsz); \ - (ld)->hole.p = NULL; \ - (ld)->hole.len = 0; \ - } while (0) - -/* - * Calculate size of a directory entry given length of the entry name. - */ -#define INCORE_D_RECLEN(namlen) \ - (((size_t )&((struct intnl_dirent *)0)->d_name + \ - (namlen) + 1 + sizeof(void *)) & \ - ~(sizeof(void *) - 1)) - -/* - * Given mode bits, return directory entry type code. - */ -#define INCORE_D_TYPEOF(m) (((m) & S_IFMT) >> 12) - -static char incore_dir_template[INCORE_D_RECLEN(1) + INCORE_D_RECLEN(2)]; -#if 0 -static struct intnl_dirent incore_dir_template[] = { - { - 0, - INCORE_D_RECLEN(1), - INCORE_D_RECLEN(1), - INCORE_D_TYPEOF(S_IFDIR), - { '.', '\0' } - }, - { - 0, - INCORE_D_RECLEN(1) + INCORE_D_RECLEN(2), - INCORE_D_RECLEN(2), - INCORE_D_TYPEOF(S_IFDIR), - { '.', '.', '\0' } - } -}; -#endif - -/* - * Initialize this driver. - */ -int -_sysio_incore_init() -{ - struct intnl_dirent *de; - off_t off; - - /* - * Fill in the directory template. - */ - de = (struct intnl_dirent *)incore_dir_template; -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = -#endif - off = de->d_reclen = INCORE_D_RECLEN(1); - de->d_type = INCORE_D_TYPEOF(S_IFDIR); - de->d_name[0] = '.'; -#ifdef _DIRENT_HAVE_D_NAMLEN - de->d_namlen = 1; -#endif - /* - * Move to entry for `..' - */ - de = (struct intnl_dirent *)((char *)de + off); - de->d_reclen = INCORE_D_RECLEN(2); -#ifdef _DIRENT_HAVE_D_NAMLEN - de->d_namlen = 2; -#endif -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = -#endif - off += de->d_reclen; - de->d_type = INCORE_D_TYPEOF(S_IFDIR); - de->d_name[0] = de->d_name[1] = '.'; - de->d_name[2] = ' '; - - return _sysio_fssw_register("incore", &incore_fssw_ops); -} - -static ino_t -incore_inum_alloc() -{ - static ino_t nxtnum = 1; - - assert(nxtnum); - return nxtnum++; -} - -static struct incore_inode * -incore_i_alloc(struct incore_filesys *icfs, struct intnl_stat *st) -{ - struct incore_inode *icino; - - assert(st->st_ino); - assert(!st->st_size); - - icino = malloc(sizeof(struct incore_inode)); - if (!icino) - return NULL; - icino->ici_revalidate = 0; - icino->ici_st = *st; - icino->ici_fileid.fid_data = &icino->ici_st.st_ino; - icino->ici_fileid.fid_len = sizeof(icino->ici_st.st_ino); - icino->ici_data = NULL; - - LIST_INSERT_HEAD(&icfs->icfs_icinodes, icino, ici_link); - - return icino; -} - -static int -incore_trunc(struct incore_inode *icino, _SYSIO_OFF_T size, int clear) -{ - _SYSIO_OFF_T n; - void *p; - - if (size < 0) - return -EINVAL; - n = size; - if (!size) { - if (icino->ici_data) { - free(icino->ici_data); - icino->ici_data = NULL; - } - n = 0; - goto out; - } - p = realloc(icino->ici_data, (size_t )n); - if (!p) - return -ENOSPC; - icino->ici_data = p; - if (clear && n > icino->ici_st.st_size) - (void )memset((char *)icino->ici_data + icino->ici_st.st_size, - 0, - (size_t )(n - icino->ici_st.st_size)); -out: - icino->ici_st.st_size = n; - icino->ici_st.st_blocks = - (n + icino->ici_st.st_blksize - 1) / icino->ici_st.st_blksize; - icino->ici_st.st_mtime = time(NULL); - return 0; -} - -static void -incore_i_destroy(struct incore_inode *icino) -{ - - LIST_REMOVE(icino, ici_link); - (void )incore_trunc(icino, 0, 0); - free(icino); -} - -static struct incore_inode * -incore_directory_new(struct incore_filesys *icfs, - struct incore_inode *parent, - struct intnl_stat *st) -{ - struct incore_inode *icino; - int err; - struct intnl_dirent *de; - - icino = incore_i_alloc(icfs, st); - if (!icino) - return NULL; - - if (!parent) - parent = icino; /* root */ - - /* - * Allocate and init directory data. - */ - err = incore_trunc(icino, sizeof(incore_dir_template), 1); - if (err) { - incore_i_destroy(icino); - return NULL; - } - (void )memcpy(icino->ici_data, - &incore_dir_template, - sizeof(incore_dir_template)); - de = icino->ici_data; - de->d_ino = st->st_ino; - de = - (struct intnl_dirent *)((char *)de + -#ifdef _DIRENT_HAVE_D_OFF - de->d_off -#else - de->d_reclen -#endif - ); - de->d_ino = parent->ici_st.st_ino; - - /* - * Set creation time to modify time set by truncate. - */ - st->st_ctime = st->st_mtime; - - return icino; -} - -static int -_sysio_incore_fsswop_mount(const char *source, - unsigned flags, - const void *data __IS_UNUSED, - struct pnode *tocover, - struct mount **mntp) -{ - char *cp; - unsigned long ul; - long l; - mode_t mode; - uid_t uid; - gid_t gid; - int err; - dev_t dev; - struct intnl_stat stat; - struct incore_filesys *icfs; - ino_t inum; - struct incore_inode *icino; - struct filesys *fs; - struct inode *rooti; - struct pnode_base *rootpb; - struct mount *mnt; - static struct qstr noname = { NULL, 0, 0 }; - - /* - * Source is a specification for the root attributes of this - * new file system in the format: - * - * ++ - */ - ul = strtoul(source, &cp, 0); - mode = (mode_t )ul & 07777; - if (*cp != '+' || - (ul == ULONG_MAX && errno == ERANGE) || - (unsigned long)mode != ul || - mode > 07777) - return -EINVAL; - source = cp; - l = strtol(source, &cp, 0); - uid = (uid_t )l; - if (*cp != '+' || - ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || - (long )uid != l) - return -EINVAL; - source = cp; - l = strtol(source, &cp, 0); - gid = (gid_t )l; - if (*cp || - ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || - (long )gid != l) - return -EINVAL; - - err = 0; - - dev = _sysio_dev_alloc(); - - mnt = NULL; - rootpb = NULL; - rooti = NULL; - fs = NULL; - icino = NULL; - icfs = NULL; - - /* - * Create new FS. - */ - icfs = malloc(sizeof(struct incore_filesys)); - if (!icfs) { - err = -ENOMEM; - goto error; - } - (void )memset(icfs, 0, sizeof(struct incore_filesys)); - LIST_INIT(&icfs->icfs_icinodes); - - /* - * Create root i-node. - */ - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = S_IFDIR | (mode & 07777); - stat.st_nlink = 2; - stat.st_uid = uid; - stat.st_gid = gid; - stat.st_size = 0; - stat.st_blksize = INCORE_BLKSIZE; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - icino = incore_directory_new(icfs, NULL, &stat); - if (!icino) - return -ENOSPC; - icino->ici_st.st_atime = icino->ici_st.st_mtime; - - fs = - _sysio_fs_new(&incore_fs_ops, - (flags & MOUNT_F_RO) ? FS_F_RO : 0, - icfs); - if (!fs) { - err = -ENOMEM; - goto error; - } - - /* - * Create root for system. - * - * Persistent across remounts because we ask for immunity. - */ - rooti = - _sysio_i_new(fs, - &icino->ici_fileid, - icino->ici_st.st_mode, - 0, - 1, - &_sysio_incore_dir_ops, - icino); - if (!rooti) { - err = -ENOMEM; - goto error; - } - rootpb = _sysio_pb_new(&noname, NULL, rooti); - if (!rootpb) { - err = -ENOMEM; - goto error; - } - - /* - * Have path-node specified by the given source argument. Let the - * system finish the job, now. - */ - mnt = NULL; - err = - _sysio_do_mount(fs, - rootpb, - flags, - tocover, - &mnt); - if (err) - goto error; - - *mntp = mnt; - - goto out; - -error: - if (mnt && _sysio_do_unmount(mnt) != 0) - abort(); - if (rootpb) { - _sysio_pb_gone(rootpb); - rooti = NULL; - } - if (rooti) - I_RELE(rooti); - if (fs) { - FS_RELE(fs); - goto out; - } - if (icino) { - incore_i_destroy(icino); - goto out; - } - if (icfs) { - free(icfs); - goto out; - } - -out: - return err; -} - -static void -_sysio_incore_fsop_gone(struct filesys *fs) -{ - struct incore_filesys *icfs; - struct incore_inode *icino, *oicino; - - icfs = FS2ICFS(fs); - - /* - * Free up i-node resource associated with this file system. - */ - icino = icfs->icfs_icinodes.lh_first; - while (icino) { - oicino = icino; - icino = icino->ici_link.le_next; - incore_i_destroy(oicino); - } - - /* - * Free the FS record. - */ - free(icfs); -} - -/* - * A directory search engine. Various functions are carried out by - * supplying appropriate callback functions. - * - * The two arguments, entry and hole, are called, if not null, for each - * directory entry and hole, respectively. - */ -static void * -incore_directory_probe(void *data, - size_t siz, - _SYSIO_OFF_T origin -#ifndef _DIRENT_HAVE_D_OFF - __IS_UNUSED -#endif - , - probe_ty entry, - probe_ty hole, - void *arg) -{ - struct intnl_dirent *de; - void *p; - size_t n; - - de = data; - for (;;) { -#ifdef _DIRENT_HAVE_D_OFF - assert(de->d_off); -#else - assert(de->d_reclen); -#endif - if (entry && (p = (*entry)(de, de->d_reclen, arg))) - return p; - n = -#ifdef _DIRENT_HAVE_D_OFF - de->d_off - origin; -#else - ((void *)de - data) + de->d_reclen; -#endif - if (hole) { - p = (*hole)((void *)de, de->d_reclen, arg); - if (p) - return p; - } - if (n >= siz) - break; - de = (struct intnl_dirent *)((char *)data + n); - } - - return NULL; -} - -static struct intnl_dirent * -incore_directory_match(struct intnl_dirent *de, - size_t reclen __IS_UNUSED, - struct lookup_data *ld) -{ - -#if defined(BSD) || defined(REDSTORM) - if (IFTODT(de->d_type) == DT_WHT) - return NULL; -#endif - if ( -#ifdef _DIRENT_HAVE_D_NAMLEN - ld->name->len == de->d_namlen && -#endif - strncmp(de->d_name, ld->name->name, ld->name->len) == 0) - return de; - ld->de = de; - return NULL; -} - -static int -_sysio_incore_dirop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt __IS_UNUSED, - const char *path __IS_UNUSED) -{ - struct inode *ino; - struct intnl_dirent *de; - struct incore_inode *icino; - struct lookup_data lookup_data; - struct file_identifier fileid; -#ifdef notdef - struct inode_ops *ops; -#endif - - /* - * Revalidate? - */ - if (*inop) { - icino = I2IC(*inop); - assert(icino); - if (icino->ici_revalidate) { - (*inop)->i_mode = icino->ici_st.st_mode; - icino->ici_revalidate = 0; - } - return 0; - } - - ino = pno->p_parent->p_base->pb_ino; - icino = I2IC(ino); - INCORE_LD_INIT(&lookup_data, - ULONG_MAX, - &pno->p_base->pb_name); - de = - incore_directory_probe(icino->ici_data, - icino->ici_st.st_size, - 0, - (probe_ty )incore_directory_match, - NULL, - &lookup_data); - if (!de) - return -ENOENT; - - fileid.fid_data = &de->d_ino; - fileid.fid_len = sizeof(de->d_ino); - ino = - _sysio_i_find(ino->i_fs, &fileid); -#ifdef notdef - if (ino) - goto out; - icino->ici_fileid.fid_data = &icino->ici_st.st_ino; - icino->ici_fileid.fid_len = sizeof(icino->ici_st.st_ino); - ops = NULL; - switch (icino->ici_st.st_mode & S_IFMT) { - case S_IFDIR: - ops = &_sysio_incore_dir_ops; - break; - case S_IFREG: - ops = &_sysio_incore_file_ops; - break; - default: - break; - } - if (!ops) - abort(); - ino = - _sysio_i_new(ino->i_fs, - &icino->ici_fileid, - icino->ici_st.st_mode, - 0, - 1, - ops, - icino); -#endif - if (!ino) - return -ENOMEM; - -#ifdef notdef -out: -#endif - *inop = ino; - return 0; -} - -static int -_sysio_incore_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf) -{ - struct incore_inode *icino; - - if (!ino) - ino = pno->p_base->pb_ino; - icino = I2IC(ino); - *stbuf = icino->ici_st; - return 0; -} - -static int -_sysio_incore_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - struct incore_inode *icino; - int err; - - if (!ino) - ino = pno->p_base->pb_ino; - if (!ino) - return -EBADF; - icino = I2IC(ino); - - err = 0; - if (mask & SETATTR_LEN) { - err = incore_trunc(icino, stbuf->st_size, 1); - if (err) - goto out; - mask &= ~SETATTR_LEN; - } - if (mask & SETATTR_MODE) { - icino->ici_st.st_mode = - (icino->ici_st.st_mode & S_IFMT) | (stbuf->st_mode & 07777); - icino->ici_revalidate = 1; - } - if (mask & SETATTR_MTIME) - icino->ici_st.st_mtime = stbuf->st_mtime; - if (mask & SETATTR_ATIME) - icino->ici_st.st_atime = stbuf->st_atime; - if (mask & SETATTR_UID) - icino->ici_st.st_uid = stbuf->st_uid; - if (mask & SETATTR_GID) - icino->ici_st.st_gid = stbuf->st_gid; - icino->ici_st.st_ctime = time(NULL); - -out: - return err; -} - -static void * -incore_directory_position(struct intnl_dirent *de, - size_t reclen __IS_UNUSED, - void *p) -{ - - return (void *)de >= p ? de : NULL; -} - -struct copy_info { - void *data; - size_t nbytes; -}; - -/* - * Eumeration callback. - * - * Note: - * On those systems supporting white-out entries, they are returned. On - * systems without, they are not. - */ -static void * -incore_directory_enumerate(struct intnl_dirent *de, - size_t reclen, - struct copy_info *cinfo) { - - if (reclen > cinfo->nbytes) - return de; - (void *)memcpy(cinfo->data, de, reclen); - cinfo->data = (char *)cinfo->data + reclen; - cinfo->nbytes -= reclen; - return NULL; -} - -static ssize_t -_sysio_incore_dirop_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - _SYSIO_OFF_T *basep) -{ - struct incore_inode *icino = I2IC(ino); - off_t off; - struct intnl_dirent *de; - struct copy_info copy_info; - - if (*basep > icino->ici_st.st_size) - return 0; - - de = - incore_directory_probe(icino->ici_data, - icino->ici_st.st_size, - *basep, - (probe_ty )incore_directory_position, - NULL, - (char *)icino->ici_data + *basep); - if (!de) { - /* - * Past EOF. - */ - *basep = 0; - return 0; - } - - copy_info.data = buf; - copy_info.nbytes = nbytes; - off = (char *)de - (char *)icino->ici_data; - de = - incore_directory_probe(de, - icino->ici_st.st_size - off, - off, - (probe_ty )incore_directory_enumerate, - NULL, - ©_info); - nbytes -= copy_info.nbytes; - icino->ici_st.st_atime = time(NULL); - if (!nbytes) - return -EOVERFLOW; - *basep = nbytes; - return (ssize_t )nbytes; -} - -static struct intnl_dirent * -incore_directory_best_fit(void *data, size_t len, struct lookup_data *ld) -{ - - if (!ld->hole.len || len < ld->hole.len) { - ld->hole.p = data; - ld->hole.len = len; - } - - return NULL; -} - -static int -incore_directory_insert(struct incore_inode *parent, - struct qstr *name, - ino_t inum, - unsigned char type) -{ - size_t reclen; - struct lookup_data lookup_data; - struct intnl_dirent *de; - size_t xt; - size_t n; - size_t r; - - reclen = INCORE_D_RECLEN(name->len); - INCORE_LD_INIT(&lookup_data, reclen, name); - de = - incore_directory_probe(parent->ici_data, - parent->ici_st.st_size, - 0, - (probe_ty )incore_directory_match, - (probe_ty )incore_directory_best_fit, - &lookup_data); - if (de) - return -EEXIST; - de = lookup_data.de; - xt = (char *)lookup_data.de - (char *)parent->ici_data; - n = -#ifdef _DIRENT_HAVE_D_OFF - de->d_off; -#else - xt + de->d_reclen; -#endif - r = -#ifdef _DIRENT_HAVE_D_OFF - de->d_reclen; -#else - INCORE_D_RECLEN(de->d_namlen); -#endif - if (!parent->ici_st.st_size || - xt + r + reclen > (size_t )parent->ici_st.st_size) { - int err; - - err = incore_trunc(parent, xt + r + reclen, 1); - if (err) - return err; - de = (struct intnl_dirent *)((char *)parent->ici_data + xt); - n = parent->ici_st.st_size; - } - -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = xt + r; /* trim */ -#else - de->d_reclen = r; -#endif - de = (struct intnl_dirent *)((char *)de + r); /* reposition */ - xt += r; - -#ifndef _DIRENT_HAVE_D_OFF - /* - * Will we split this hole or use all of it? - */ - if (lookup_data.hole.len - reclen && - lookup_data.hole.len - reclen <= INCORE_D_RECLEN(1)) - reclen = lookup_data.hole.len; -#endif - - /* - * Insert new. - */ - de->d_ino = inum; -#ifdef _DIRENT_HAVE_D_OFF - de->d_off = n; -#endif - de->d_reclen = reclen; - de->d_type = type; - (void )memcpy(de->d_name, name->name, name->len); -#ifdef _DIRENT_HAVE_D_NAMLEN - de->d_namlen = name->len; -#endif - -#ifndef _DIRENT_HAVE_D_OFF - xt += reclen; - if (n - xt) { - /* - * White-out remaining part of the hole. - */ - (void *)de += reclen; - de->d_ino = 0; - de->d_reclen = n - xt; - de->d_type = DT_WHT; - de->d_namlen = 0; - } -#endif - - /* - * Update attributes to reflect the new entry. - */ - parent->ici_st.st_nlink++; - assert(parent->ici_st.st_nlink); - parent->ici_st.st_atime = parent->ici_st.st_mtime = time(NULL); - - return 0; -} - -static int -_sysio_incore_dirop_mkdir(struct pnode *pno, mode_t mode) -{ - struct intnl_stat stat; - struct incore_inode *icino, *parent; - ino_t inum; - int err; - struct intnl_dirent *de = NULL; - struct inode *ino; - - ino = pno->p_parent->p_base->pb_ino; - parent = I2IC(ino); - - if (!S_ISDIR(parent->ici_st.st_mode)) - return -ENOTDIR; - - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = S_IFDIR | (mode & 07777); - stat.st_nlink = 2; - stat.st_uid = getuid(); - stat.st_gid = getgid(); - stat.st_size = 0; - stat.st_blksize = 4096; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - icino = incore_directory_new(FS2ICFS(ino->i_fs), parent, &stat); - if (!icino) - return -ENOSPC; - - /* - * Tell the system about the new inode. - * - * Persistent across remounts because we ask for immunity. - */ - ino = - _sysio_i_new(pno->p_parent->p_base->pb_ino->i_fs, - &icino->ici_fileid, - stat.st_mode, - 0, - 1, - &_sysio_incore_dir_ops, - icino); - if (!ino) { - incore_i_destroy(icino); - return -ENOMEM; - } - - /* - * Insert into parent. - */ - err = - incore_directory_insert(parent, - &pno->p_base->pb_name, - stat.st_ino, - INCORE_D_TYPEOF(S_IFDIR)); - - if (err) { - de->d_ino = 0; /* bad parent */ - I_RELE(ino); - _sysio_i_gone(ino); - return err; - } - - pno->p_base->pb_ino = ino; - return 0; -} - -static int -incore_unlink_entry(struct incore_inode *icino, - struct qstr *name) -{ - struct lookup_data lookup_data; - struct intnl_dirent *de; - size_t reclen; -#ifdef _DIRENT_HAVE_D_OFF - size_t off; -#endif - - if (!S_ISDIR(icino->ici_st.st_mode)) - return -ENOTDIR; - - INCORE_LD_INIT(&lookup_data, 0, name); - de = - incore_directory_probe(icino->ici_data, - icino->ici_st.st_size, - 0, - (probe_ty )incore_directory_match, - NULL, - &lookup_data); - if (!de) - return -ENOENT; - assert((size_t )((char *)de - (char *)icino->ici_data) >= - sizeof(incore_dir_template)); -#ifndef _DIRENT_HAVE_D_OFF - reclen = de->d_reclen; -#else - off = de->d_off; - reclen = off - ((char *)de - (char *)icino->ici_data); -#endif - (void )memset(de, 0, reclen); -#ifndef _DIRENT_HAVE_D_OFF - de->d_type = (__uint8_t )DTTOIF(DT_WHT); - de->d_reclen = reclen; -#else - lookup_data.de->d_off = off; -#endif - - /* - * Adjust link count. - */ - assert(icino->ici_st.st_nlink > 2); - icino->ici_st.st_nlink--; - - return 0; -} - -static int -_sysio_incore_dirop_rmdir(struct pnode *pno) -{ - struct inode *ino = pno->p_base->pb_ino; - struct incore_inode *icino = I2IC(ino); - int err; - - if (!pno->p_base->pb_name.len || - (pno->p_base->pb_name.name[0] == '.' && - (pno->p_base->pb_name.len == 1 || - (pno->p_base->pb_name.len == 2 && - pno->p_base->pb_name.name[1] == '.')))) - return -EINVAL; - - if (!S_ISDIR(icino->ici_st.st_mode)) - return -ENOTDIR; - - if (icino->ici_st.st_nlink > 2) - return -ENOTEMPTY; - - pno->p_base->pb_ino = NULL; - err = - incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), - &pno->p_base->pb_name); - return err; -} - -static int -incore_create(struct pnode *pno, struct intnl_stat *st) -{ - struct inode *dino, *ino; - struct incore_inode *icino; - int err; - - dino = pno->p_parent->p_base->pb_ino; - assert(dino); - - icino = incore_i_alloc(FS2ICFS(dino->i_fs), st); - if (!icino) - return -ENOSPC; - - /* - * Tell the system about the new inode. - */ - ino = - _sysio_i_new(dino->i_fs, - &icino->ici_fileid, - st->st_mode, - st->st_rdev, - 1, - S_ISREG(st->st_mode) - ? &_sysio_incore_file_ops - : &_sysio_incore_dev_ops, - icino); - if (!ino) { - incore_i_destroy(icino); - return -ENOMEM; - } - - /* - * Insert into parent. - */ - err = - incore_directory_insert(I2IC(dino), - &pno->p_base->pb_name, - st->st_ino, - INCORE_D_TYPEOF(icino->ici_st.st_mode)); - if (err) { - I_RELE(ino); - _sysio_i_gone(ino); - return err; - } - - pno->p_base->pb_ino = ino; - return 0; -} - -static int -_sysio_incore_inop_open(struct pnode *pno, int flags __IS_UNUSED, mode_t mode) -{ - struct intnl_stat stat; - ino_t inum; - - /* - * File exists. Nothing to do. - */ - if (pno->p_base->pb_ino) - return 0; - - /* - * Must create a new, regular, file. - */ - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = S_IFREG | (mode & 07777); - stat.st_nlink = 1; - stat.st_uid = getuid(); - stat.st_gid = getgid(); - stat.st_rdev = 0; - stat.st_size = 0; - stat.st_blksize = 4096; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - - return incore_create(pno, &stat); -} - -static int -_sysio_incore_inop_close(struct inode *ino __IS_UNUSED) -{ - - return 0; -} - -static int -_sysio_incore_dirop_link(struct pnode *old, struct pnode *new) -{ - struct incore_inode *icino = I2IC(old->p_base->pb_ino); - int err; - - assert(!new->p_base->pb_ino); - assert(!S_ISDIR(old->p_base->pb_ino->i_mode)); - - /* - * Can bump the link count? - */ - if (!(icino->ici_st.st_nlink + 1)) - return -EMLINK; - /* - * Insert into parent. - */ - err = - incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name, - icino->ici_st.st_ino, - INCORE_D_TYPEOF(icino->ici_st.st_mode)); - if (err) - return err; - /* - * Bump the link count. - */ - icino->ici_st.st_nlink++; - - return 0; -} - -static int -_sysio_incore_dirop_rename(struct pnode *old, struct pnode *new) -{ - int err; - struct incore_inode *icino = I2IC(old->p_base->pb_ino); - - if (new->p_base->pb_ino) { - /* - * Have to kill off the target first. - */ - if (S_ISDIR(I2IC(new->p_base->pb_ino)->ici_st.st_mode) && - I2IC(new->p_base->pb_ino)->ici_st.st_nlink > 2) - return -ENOTEMPTY; - err = - incore_unlink_entry(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name); - if (err) - return err; - } - - /* - * Insert into new parent. - */ - err = - incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name, - icino->ici_st.st_ino, - INCORE_D_TYPEOF(icino->ici_st.st_mode)); - if (err) - abort(); - /* - * Remove from the old parent. - */ - err = - incore_unlink_entry(I2IC(old->p_parent->p_base->pb_ino), - &old->p_base->pb_name); - if (err) - abort(); - - if (S_ISDIR(icino->ici_st.st_mode)) { - struct intnl_dirent *de; - - /* - * We moved a directory. The entry for `..' must be corrected. - */ - de = icino->ici_data; - de++; - assert(strcmp(de->d_name, "..") == 0); - de->d_ino = I2IC(new->p_parent->p_base->pb_ino)->ici_st.st_ino; - } - return 0; -} - -static int -_sysio_incore_dirop_unlink(struct pnode *pno) -{ - struct inode *ino = pno->p_base->pb_ino; - struct incore_inode *icino = I2IC(ino); - int err; - - if (S_ISDIR(icino->ici_st.st_mode)) - return -EISDIR; - - err = - incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), - &pno->p_base->pb_name); - return err; -} - -static int -doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct incore_inode *), - struct inode *ino, - struct ioctx *ioctx) -{ - - ioctx->ioctx_cc = - _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(void *, size_t, _SYSIO_OFF_T, void *))f, - I2IC(ino)); - if (ioctx->ioctx_cc < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - } - ioctx->ioctx_done = 1; - - return 0; -} - -static ssize_t -incore_read(void *buf, size_t nbytes, - _SYSIO_OFF_T off, - struct incore_inode *icino) -{ - size_t n; - - if (off < 0) - return -EINVAL; - if (!nbytes || off > icino->ici_st.st_size) - return 0; - n = icino->ici_st.st_size - (size_t )off; - if (n > nbytes) - n = nbytes; - (void )memcpy(buf, (char *)icino->ici_data + off, (size_t )n); - - return (ssize_t )n; -} - -static int -_sysio_incore_filop_read(struct inode *ino, struct ioctx *ioctx) -{ - - - return doio(incore_read, ino, ioctx); -} - -static ssize_t -incore_write(const void *buf, size_t nbytes, - _SYSIO_OFF_T off, - struct incore_inode *icino) -{ - _SYSIO_OFF_T pos; - - if (off < 0) - return -EINVAL; - if (!nbytes || off > icino->ici_st.st_size) - return 0; - pos = off + nbytes; - if (off && pos <= off) { - /* - * It's all or nothing. We won't write just part of - * the buffer. - */ - return -EFBIG; - } - if (pos > icino->ici_st.st_size) { - int err; - - err = incore_trunc(icino, (size_t )pos, 0); - if (err) - return err; - } - (void )memcpy((char *)icino->ici_data + off, buf, nbytes); - - return (ssize_t )nbytes; -} - -static int -_sysio_incore_filop_write(struct inode *ino, struct ioctx *ioctx) -{ - - return doio((ssize_t (*)(void *, size_t, - _SYSIO_OFF_T, - struct incore_inode *))incore_write, - ino, - ioctx); -} - -static _SYSIO_OFF_T -_sysio_incore_filop_pos(struct inode *ino __IS_UNUSED, _SYSIO_OFF_T off) -{ - - return off; -} - -static int -_sysio_incore_filop_iodone(struct ioctx *iocp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -_sysio_incore_filop_fcntl(struct inode *ino __IS_UNUSED, - int cmd __IS_UNUSED, - va_list ap __IS_UNUSED, - int *rtn) -{ - - /* - * No fcntl's supported. - */ - *rtn = -1; - return -ENOTTY; -} - -static int -_sysio_incore_inop_sync(struct inode *ino __IS_UNUSED) -{ - - /* - * With what? - */ - return 0; -} - -static int -_sysio_incore_filop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - /* - * No ioctl's supported. - */ - return -ENOTTY; -} - -static int -_sysio_incore_dirop_mknod(struct pnode *pno, mode_t mode, dev_t dev) -{ - mode_t m; - struct intnl_stat stat; - ino_t inum; - - assert(!pno->p_base->pb_ino); - - m = mode & S_IFMT; - if (S_ISCHR(m)) - m &= ~S_IFCHR; - else if (S_ISFIFO(m)) - m &= ~S_IFIFO; - else if (S_ISBLK(m)) - m &= ~S_IFCHR; - else - return -EINVAL; - if (m) - return -EINVAL; - - /* - * Initialize attributes. - */ - (void )memset(&stat, 0, sizeof(stat)); - stat.st_dev = pno->p_parent->p_base->pb_ino->i_fs->fs_dev; - inum = incore_inum_alloc(); -#ifdef HAVE__ST_INO - stat.__st_ino = inum; -#endif - stat.st_mode = mode; - stat.st_nlink = 1; - stat.st_uid = getuid(); - stat.st_gid = getgid(); - stat.st_rdev = dev; - stat.st_size = 0; - stat.st_blksize = 4096; - stat.st_blocks = 0; - stat.st_ctime = stat.st_mtime = stat.st_atime = 0; - stat.st_ino = inum; - - return incore_create(pno, &stat); -} - -#ifdef _HAVE_STATVFS -static int -_sysio_incore_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf) -{ - struct filesys *fs; - - if (!ino) - ino = pno->p_base->pb_ino; - assert(ino); - - fs = pno->p_base->pb_ino->i_fs; - - (void )memset(buf, 0, sizeof(struct intnl_statvfs)); - - /* - * Mostly, we lie. - */ - buf->f_bsize = fs->fs_bsize; - buf->f_frsize = buf->f_bsize; - buf->f_blocks = ~0; - buf->f_blocks /= buf->f_bsize; - buf->f_bfree = buf->f_blocks - 1; - buf->f_bavail = buf->f_bfree; - buf->f_files = buf->f_blocks; - buf->f_ffree = buf->f_files - 1; - buf->f_favail = buf->f_ffree; - buf->f_fsid = fs->fs_id; - buf->f_flag = 0; - buf->f_namemax = ULONG_MAX; - - return 0; -} -#endif - -void -_sysio_incore_inop_gone(struct inode *ino) -{ - struct incore_inode *icino = I2IC(ino); - - incore_i_destroy(icino); -} diff --git a/libsysio/drivers/incore/fs_incore.h b/libsysio/drivers/incore/fs_incore.h deleted file mode 100644 index 84fa631..0000000 --- a/libsysio/drivers/incore/fs_incore.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Native file system driver support. - */ - -extern int _sysio_incore_init(void); diff --git a/libsysio/drivers/incore/module.mk b/libsysio/drivers/incore/module.mk deleted file mode 100644 index 140d69b..0000000 --- a/libsysio/drivers/incore/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -INCORE_SRCS = drivers/incore/fs_incore.c -INCORE_EXTRA = drivers/incore/fs_incore.h drivers/incore/module.mk diff --git a/libsysio/drivers/native/fs_native.c b/libsysio/drivers/native/fs_native.c deleted file mode 100644 index 446d61e..0000000 --- a/libsysio/drivers/native/fs_native.c +++ /dev/null @@ -1,1801 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include /* for NULL */ -#include -#ifdef __linux__ -#include -#endif -#include -#if !(defined(REDSTORM) || defined(MAX_IOVEC)) -#include -#endif -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#ifdef _HAVE_STATVFS -#include -#include -#endif -#include -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" - -#include "fs_native.h" - -#ifdef REDSTORM -#include -#endif - -#if defined(SYS_getdirentries) -#define DIR_STREAMED 0 -#define DIR_CVT_64 0 -#elif defined(SYS_getdents64) -#define DIR_STREAMED 1 -#define DIR_CVT_64 0 -#elif defined(SYS_getdents) -#define DIR_STREAMED 1 -#if defined(_LARGEFILE64_SOURCE) -#define DIR_CVT_64 1 -/* - * Kernel version of directory entry. - */ -struct linux_dirent { - unsigned long ld_ino; - unsigned long ld_off; - unsigned short ld_reclen; - char ld_name[1]; -}; -#include -#else /* !defined(_LARGEFILE64_SOURCE) */ -#define DIR_CVT_64 0 -#endif /* defined(_LARGEFILE64_SOURCE) */ -#else /* catch-none */ -#error No usable directory fill entries interface available -#endif - -/* - * Local host file system driver. - */ - -#if defined(ALPHA_LINUX) - -/* stat struct from asm/stat.h, as returned - * by alpha linux kernel - */ -struct __native_stat { - unsigned int st_dev; - unsigned int st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_rdev; - long st_size; - unsigned long st_atime; - unsigned long st_mtime; - unsigned long st_ctime; - unsigned int st_blksize; - int st_blocks; - unsigned int st_flags; - unsigned int st_gen; -}; - -#define COPY_STAT(src, dest) \ -do { \ - memset((dest), 0, sizeof((*dest))); \ - (dest)->st_dev = (src)->st_dev; \ - (dest)->st_ino = (src)->st_ino; \ - (dest)->st_mode = (src)->st_mode; \ - (dest)->st_nlink = (src)->st_nlink; \ - (dest)->st_uid = (src)->st_uid; \ - (dest)->st_gid = (src)->st_gid; \ - (dest)->st_rdev = (src)->st_rdev; \ - (dest)->st_size = (src)->st_size; \ - (dest)->st_atime = (src)->st_atime; \ - (dest)->st_mtime = (src)->st_mtime; \ - (dest)->st_ctime = (src)->st_ctime; \ - (dest)->st_blksize = (src)->st_blksize; \ - (dest)->st_blocks = (src)->st_blocks; \ - (dest)->st_flags = (src)->st_flags; \ - (dest)->st_gen = (src)->st_gen; \ -} while (0); - -#else -#define __native_stat intnl_stat -#define COPY_STAT(src, dest) *(dest) = *(src) -#endif - -#if defined(USE_NATIVE_STAT) -#define __SYS_STAT SYS_lstat -#define __SYS_FSTAT SYS_fstat -#define __SYS_TRUNCATE SYS_truncate -#define __SYS_FTRUNCATE SYS_ftruncate -#else -#define __SYS_STAT SYS_lstat64 -#define __SYS_FSTAT SYS_fstat64 -#define __SYS_TRUNCATE SYS_truncate64 -#define __SYS_FTRUNCATE SYS_ftruncate64 -#endif - -#if defined(USE_NATIVE_FDATASYNC) -#define __SYS_FDATASYNC SYS_osf_fdatasync -#else -#define __SYS_FDATASYNC SYS_fdatasync -#endif - -#if defined(USE_NATIVE_UTIME) -#define __SYS_UTIME SYS_utimes -#else -#define __SYS_UTIME SYS_utime -#endif - -/* - * Native file identifiers format. - */ -struct native_inode_identifier { - dev_t dev; /* device number */ - ino_t ino; /* i-number */ -#ifdef HAVE_GENERATION - unsigned int gen; /* generation number */ -#endif -}; - -/* - * Driver-private i-node information we keep about local host file - * system objects. - */ -struct native_inode { - unsigned - ni_seekok : 1; /* can seek? */ - struct native_inode_identifier ni_ident; /* unique identifier */ - struct file_identifier ni_fileid; /* ditto */ - int ni_fd; /* host fildes */ - int ni_oflags; /* flags, from open */ - unsigned ni_nopens; /* soft ref count */ - _SYSIO_OFF_T ni_fpos; /* current pos */ - struct intnl_stat ni_stat; /* cached attrs */ -}; - -/* - * Native IO path arguments. - */ -struct native_io { - char nio_op; /* 'r' or 'w' */ - struct native_inode *nio_nino; /* native ino */ -}; - -static int native_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); -static int native_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); -static int native_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -static ssize_t native_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - _SYSIO_OFF_T *basep); -static int native_inop_mkdir(struct pnode *pno, mode_t mode); -static int native_inop_rmdir(struct pnode *pno); -static int native_inop_symlink(struct pnode *pno, const char *data); -static int native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); -static int native_inop_open(struct pnode *pno, int flags, mode_t mode); -static int native_inop_close(struct inode *ino); -static int native_inop_link(struct pnode *old, struct pnode *new); -static int native_inop_unlink(struct pnode *pno); -static int native_inop_rename(struct pnode *old, struct pnode *new); -static int native_inop_read(struct inode *ino, struct ioctx *ioctx); -static int native_inop_write(struct inode *ino, struct ioctx *ioctx); -static _SYSIO_OFF_T native_inop_pos(struct inode *ino, _SYSIO_OFF_T off); -static int native_inop_iodone(struct ioctx *ioctx); -static int native_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int native_inop_sync(struct inode *ino); -static int native_inop_datasync(struct inode *ino); -static int native_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static int native_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS -static int native_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif -static void native_inop_gone(struct inode *ino); - -static struct inode_ops native_i_ops = { - native_inop_lookup, - native_inop_getattr, - native_inop_setattr, - native_getdirentries, - native_inop_mkdir, - native_inop_rmdir, - native_inop_symlink, - native_inop_readlink, - native_inop_open, - native_inop_close, - native_inop_link, - native_inop_unlink, - native_inop_rename, - native_inop_read, - native_inop_write, - native_inop_pos, - native_inop_iodone, - native_inop_fcntl, - native_inop_sync, - native_inop_datasync, - native_inop_ioctl, - native_inop_mknod, -#ifdef _HAVE_STATVFS - native_inop_statvfs, -#endif - native_inop_gone -}; - -static int native_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); - -static struct fssw_ops native_fssw_ops = { - native_fsswop_mount -}; - -static void native_fsop_gone(struct filesys *fs); - -static struct filesys_ops native_inodesys_ops = { - native_fsop_gone, -}; - -/* - * This example driver plays a strange game. It maintains a private, - * internal mount -- It's own separate, rooted, name space. The local - * file system's entire name space is available via this tree. - * - * This simplifies the implementation. At mount time, we need to generate - * a path-node to be used as a root. This allows us to look up the needed - * node in the host name space and leverage a whole lot of support from - * the system. - */ -static struct mount *native_internal_mount = NULL; - -/* - * Given i-node, return driver private part. - */ -#define I2NI(ino) ((struct native_inode *)((ino)->i_private)) - -/* - * stat -- by path. - */ -static int -native_stat(const char *path, struct native_inode *nino, struct intnl_stat *buf) -{ - int err; - struct __native_stat stbuf; - - err = syscall(__SYS_STAT, path, &stbuf); - if (err) { - err = -errno; - goto out; - } - if (!nino) { - COPY_STAT(&stbuf, buf); - goto out; - } - COPY_STAT(&stbuf, &nino->ni_stat); - if (&nino->ni_stat != buf) - (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); - -out: - return err; -} - -/* - * stat -- by fildes - */ -static int -native_fstat(int fd, struct native_inode *nino, struct intnl_stat *buf) -{ - int err; - struct __native_stat stbuf; - - err = syscall(__SYS_FSTAT, fd, &stbuf); - if (err) { - err = -errno; - goto out; - } - if (!nino) { - COPY_STAT(&stbuf, buf); - goto out; - } - COPY_STAT(&stbuf, &nino->ni_stat); - if (&nino->ni_stat != buf) - (void )memcpy(buf, &nino->ni_stat, sizeof(struct intnl_stat)); - -out: - return err; -} - -/* - * Introduce an i-node to the system. - */ -static struct inode * -native_i_new(struct filesys *fs, struct intnl_stat *buf) -{ - struct native_inode *nino; - struct inode *ino; - - nino = malloc(sizeof(struct native_inode)); - if (!nino) - return NULL; - bzero(&nino->ni_ident, sizeof(nino->ni_ident)); - nino->ni_ident.dev = buf->st_dev; - nino->ni_ident.ino = buf->st_ino; -#ifdef HAVE_GENERATION - nino->ni_ident.gen = buf->st_gen; -#endif - nino->ni_fileid.fid_data = &nino->ni_ident; - nino->ni_fileid.fid_len = sizeof(nino->ni_ident); - nino->ni_fd = -1; - nino->ni_oflags = 0; - nino->ni_nopens = 0; - nino->ni_fpos = 0; - (void )memcpy(&nino->ni_stat, buf, sizeof(struct intnl_stat)); - ino = - _sysio_i_new(fs, - &nino->ni_fileid, -#ifndef AUTOMOUNT_FILE_NAME - buf->st_mode & S_IFMT, -#else - buf->st_mode, /* all of the bits! */ -#endif - buf->st_rdev, - 0, - &native_i_ops, - nino); - if (!ino) - free(nino); - return ino; -} - -/* - * Initialize this driver. - */ -int -_sysio_native_init() -{ - - /* - * Capture current process umask and reset our process umask to - * zero. All permission bits to open/creat/setattr are absolute -- - * They've already had a umask applied, when appropriate. - */ - _sysio_umask = syscall(SYS_umask, 0); - - return _sysio_fssw_register("native", &native_fssw_ops); -} - -/* - * Create private, internal, view of the hosts name space. - */ -static int -create_internal_namespace() -{ - int err; - struct mount *mnt; - struct inode *rootino; - struct pnode_base *rootpb; - static struct qstr noname = { NULL, 0, 0 }; - struct filesys *fs; - struct intnl_stat stbuf; - - if (native_internal_mount) { - /* - * Reentered! - */ - abort(); - } - - /* - * We maintain an artificial, internal, name space in order to - * have access to fully qualified path names in the various routines. - * Initialize that name space now. - */ - mnt = NULL; - rootino = NULL; - rootpb = NULL; - fs = _sysio_fs_new(&native_inodesys_ops, 0, NULL); - if (!fs) { - err = -ENOMEM; - goto error; - } - - /* - * Get root i-node. - */ - err = native_stat("/", NULL, &stbuf); - if (err) - goto error; - rootino = native_i_new(fs, &stbuf); - if (!rootino) { - err = -ENOMEM; - goto error; - } - - /* - * Generate base path-node for root. - */ - rootpb = _sysio_pb_new(&noname, NULL, rootino); - if (!rootpb) { - err = -ENOMEM; - goto error; - } - - /* - * Mount it. This name space is disconnected from the - * rest of the system -- Only available within this driver. - */ - err = _sysio_do_mount(fs, rootpb, 0, NULL, &mnt); - if (err) - goto error; - - native_internal_mount = mnt; - return 0; -error: - if (mnt) { - if (_sysio_do_unmount(mnt) != 0) - abort(); - fs = NULL; - rootpb = NULL; - rootino = NULL; - } - if (rootpb) - _sysio_pb_gone(rootpb); - if (fs) { - FS_RELE(fs); - _sysio_fs_gone(fs); - } - - return err; -} - -static int -native_fsswop_mount(const char *source, - unsigned flags, - const void *data __IS_UNUSED, - struct pnode *tocover, - struct mount **mntp) -{ - int err; - struct nameidata nameidata; - struct mount *mnt; - - /* - * Caller must use fully qualified path names when specifying - * the source. - */ - if (*source != '/') - return -ENOENT; - - if (!native_internal_mount) { - err = create_internal_namespace(); - if (err) - return err; - } - - /* - * Lookup the source in the internally maintained name space. - */ - ND_INIT(&nameidata, 0, source, native_internal_mount->mnt_root, NULL); - err = _sysio_path_walk(native_internal_mount->mnt_root, &nameidata); - if (err) - return err; - - /* - * Have path-node specified by the given source argument. Let the - * system finish the job, now. - */ - err = - _sysio_do_mount(native_internal_mount->mnt_fs, - nameidata.nd_pno->p_base, - flags, - tocover, - &mnt); - /* - * Release the internal name space pnode and clean up any - * aliases we might have generated. We really don't need to cache them - * as they are only used at mount time.. - */ - P_RELE(nameidata.nd_pno); - (void )_sysio_p_prune(native_internal_mount->mnt_root); - - if (!err) { - FS_REF(native_internal_mount->mnt_fs); - *mntp = mnt; - } - return err; -} - -static int -native_i_invalid(struct inode *inop, struct intnl_stat stbuf) -{ - /* - * Validate passed in inode against stat struct info - */ - struct native_inode *nino = I2NI(inop); - - if ((nino->ni_ident.dev != stbuf.st_dev || - nino->ni_ident.ino != stbuf.st_ino || -#ifdef HAVE_GENERATION - nino->ni_ident.gen != stbuf.st_gen || -#endif - ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) || - (((inop)->i_rdev != stbuf.st_rdev) && - (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)))) - return 1; - - return 0; -} - -/* - * Find, and validate, or create i-node by host-relative path. Returned i-node - * is referenced. - */ -static int -native_iget(struct filesys *fs, - const char *path, - struct inode **inop, - int forced) -{ - int err; - struct inode *ino; - struct intnl_stat stbuf; - struct native_inode_identifier ident; - struct file_identifier fileid; - - /* - * Get file status. - */ - err = native_stat(path, *inop ? I2NI(*inop) : NULL, &stbuf); - if (err) { - *inop = NULL; - return err; - } - - /* - * Validate? - */ - if (*inop) { - if (!native_i_invalid(*inop, stbuf)) - return 0; - /* - * Invalidate. - */ - *inop = NULL; - } - - /* - * I-node is not already known. Find or create it. - */ - bzero(&ident, sizeof(ident)); - ident.dev = stbuf.st_dev; - ident.ino = stbuf.st_ino; -#ifdef HAVE_GENERATION - ident.gen = stbuf.st_gen; -#endif - fileid.fid_data = &ident; - fileid.fid_len = sizeof(ident); - ino = _sysio_i_find(fs, &fileid); - if (ino && - (forced || (ino->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT))) { - /* - * Insertion was forced or dup inum but it's already present! - */ - if (native_i_invalid(ino, stbuf)) { - /* - * Cached inode has stale attrs - * make way for the new one - */ - I_GONE(ino); - ino = NULL; - } else - /* - * OK to reuse cached inode - */ - goto out; - } - - if (!ino) { - ino = native_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } -out: - if (!err) - *inop = ino; - return err; -} - -/* - * Look up named object in host's name space by path. - */ -static int -native_path_lookup(struct filesys *fs, const char *path, struct inode **inop) -{ - - return native_iget(fs, path, inop, 0); -} - -/* - * Look up object by it's path node. - */ -static int -native_i_lookup(struct filesys *fs, struct pnode_base *pb, struct inode **inop) -{ - int err; - char *path; - - path = _sysio_pb_path(pb, '/'); - if (!path) - return -ENOMEM; - err = native_path_lookup(fs, path, inop); - free(path); - return err; -} - -static int -native_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt __IS_UNUSED, - const char *path __IS_UNUSED) -{ - int err; - - *inop = pno->p_base->pb_ino; - - /* - * Don't have an inode yet. Because we translate everything back to - * a single name space for the host, we will assume the object the - * caller is looking for has no existing alias in our internal - * name space. We don't see the same file on different mounts in the - * underlying host FS as the same file. - * - * The file identifier *will* be unique. It's got to have a different - * dev. - */ - err = native_i_lookup(pno->p_mount->mnt_fs, pno->p_base, inop); - if (err) - *inop = NULL; - return err; -} - -static int -native_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf) -{ - char *path; - struct native_inode *nino; - int err; - - nino = ino ? I2NI(ino) : NULL; - err = 0; /* compiler cookie */ - if (!ino) { - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - err = native_stat(path, nino, stbuf); - free(path); - } else if (nino->ni_fd >= 0) - err = native_fstat(nino->ni_fd, nino, stbuf); - else { - /* - * Dev inodes don't open in this driver. We won't have - * a file descriptor with which to do the deed then. Satisfy - * the request from the cached copy of the attributes. - */ - (void )memcpy(stbuf, - &nino->ni_stat, - sizeof(struct intnl_stat)); - err = 0; - } - - return err; -} - -static int -native_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - char *path; - struct native_inode *nino; - int fd; - struct intnl_stat *stbp, _stbuf; - int err; - - path = NULL; - nino = ino ? I2NI(ino) : NULL; - fd = -1; - stbp = &_stbuf; - if (nino) { - fd = nino->ni_fd; - stbp = &nino->ni_stat; - } - if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { - if (!pno) - return -EEXIST; - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * Get current status for undo. - */ - err = - fd < 0 - ? native_stat(path, nino, stbp) - : native_fstat(fd, nino, stbp); - if (err) - goto out; - - if (mask & SETATTR_MODE) { - mode_t mode; - - /* - * Alter permissions attribute. - */ - mode = stbuf->st_mode & 07777; - err = - fd < 0 - ? syscall(SYS_chmod, path, mode) - : syscall(SYS_fchmod, fd, mode); - if (err) - err = -errno; - } - if (err) - mask &= ~SETATTR_MODE; - else if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { - struct utimbuf ut; - - /* - * Alter access and/or modify time attributes. - */ - ut.actime = stbuf->st_atime; - ut.modtime = stbuf->st_mtime; - if (mask & SETATTR_MTIME) - ut.modtime = stbuf->st_mtime; - if (mask & SETATTR_ATIME) - ut.actime = stbuf->st_atime; - err = syscall(__SYS_UTIME, path, &ut); - if (err) - err = -errno; - } - if (err) - mask &= ~(SETATTR_MTIME|SETATTR_ATIME); - else if (mask & (SETATTR_UID|SETATTR_GID)) { - - /* - * Alter owner and/or group identifiers. - */ - err = - fd < 0 - ? syscall(SYS_chown, - path, - mask & SETATTR_UID - ? stbuf->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stbuf->st_gid - : (gid_t )-1) - : syscall(SYS_fchown, - fd, - mask & SETATTR_UID - ? stbuf->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stbuf->st_gid - : (gid_t )-1); - if (err) - err = -errno; - } - if (err) - mask &= ~(SETATTR_UID|SETATTR_GID); - else if (mask & SETATTR_LEN) { - /* - * Do the truncate last. It can't be undone. - */ - (void )(fd < 0 - ? syscall(__SYS_TRUNCATE, path, stbuf->st_size) - : syscall(__SYS_FTRUNCATE, fd, stbuf->st_size)); - } - if (!err) - goto out; - /* - * Undo after error. Some or all of this might not work... We - * can but try. - */ - if (mask & (SETATTR_UID|SETATTR_GID)) { - (void )(fd < 0 - ? syscall(SYS_chown, - path, - mask & SETATTR_UID - ? stbp->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stbp->st_gid - : (gid_t )-1) - : syscall(SYS_fchown, - fd, - mask & SETATTR_UID - ? stbp->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stbp->st_gid - : (gid_t )-1)); - } - if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { - struct utimbuf ut; - - ut.actime = stbp->st_atime; - ut.modtime = stbp->st_mtime; - (void )syscall(__SYS_UTIME, path, &ut); - } - if (mask & SETATTR_MODE) { - fd < 0 - ? syscall(SYS_chmod, path, stbp->st_mode & 07777) - : syscall(SYS_fchmod, stbp->st_mode & 07777); - } -out: - /* - * We must refresh the cached attributes on success. - */ - if (!err && (fd < 0 - ? native_stat(path, nino, stbp) - : native_fstat(fd, nino, stbp)) != 0) - abort(); - if (path) - free(path); - return err; -} - -static int -native_pos(int fd, _SYSIO_OFF_T *offset, int whence) -{ - _SYSIO_OFF_T off; - - assert(fd >= 0); - assert(*offset >= 0); - - off = *offset; -#if _LARGEFILE64_SOURCE && defined(SYS__llseek) - { - int err; - err = - syscall(SYS__llseek, - (unsigned int)fd, - (unsigned int)(off >> 32), - (unsigned int)off, - &off, - whence); - if (err == -1) - return -errno; - } -#else - off = - syscall(SYS_lseek, - fd, - off, - whence); - if (off == -1) - return -errno; -#endif - *offset = off; - - return 0; -} - -static ssize_t -native_filldirentries(struct native_inode *nino, - char *buf, - size_t nbytes, - _SYSIO_OFF_T *basep) -{ - int err; - ssize_t cc; - - if (*basep < 0) - return -EINVAL; - -#if DIR_STREAMED - /* - * Stream-oriented access requires that we reposition prior to the - * fill call. - */ - if ((err = native_pos(nino->ni_fd, basep, SEEK_SET)) != 0) - return err; -#endif - nino->ni_fpos = *basep; - - cc = -#if defined(SYS_getdirentries) - syscall(SYS_getdirentries, - nino->ni_fd, - buf, - nbytes, - basep); -#elif defined(SYS_getdents64) - syscall(SYS_getdents64, nino->ni_fd, buf, nbytes); -#elif defined(SYS_getdents) - syscall(SYS_getdents, nino->ni_fd, buf, nbytes); -#endif - - if (cc < 0) - return -errno; -#if DIR_STREAMED - /* - * Stream-oriented access requires that we discover where we are - * after the call. - */ - *basep = 0; - if ((err = native_pos(nino->ni_fd, basep, SEEK_CUR)) != 0) - return err; -#endif - nino->ni_fpos = *basep; - return cc; -} - -static ssize_t -native_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - _SYSIO_OFF_T *basep) -{ - struct native_inode *nino = I2NI(ino); -#if DIR_CVT_64 - char *bp; - size_t count; - struct linux_dirent *ldp; - struct dirent64 *d64p; - size_t namlen; - size_t reclen; -#else -#define bp buf -#define count nbytes -#endif - ssize_t cc; - - assert(nino->ni_fd >= 0); - -#if DIR_CVT_64 - count = nbytes; - while (!(bp = malloc(count))) { - count /= 2; - if (count < sizeof(struct dirent)) - return -ENOMEM; - } -#endif - cc = native_filldirentries(nino, bp, count, basep); - if (cc < 0) { -#if DIR_CVT_64 - free(bp); -#endif - return cc; - } -#if DIR_CVT_64 - ldp = (struct linux_dirent *)bp; - d64p = (struct dirent64 *)buf; - for (;;) { - if (cc < 0 || (size_t )cc <= sizeof(*ldp)) - break; - namlen = strlen(ldp->ld_name); - reclen = sizeof(*d64p) - sizeof(d64p->d_name) + namlen + 1; - if (nbytes < reclen) - break; - d64p->d_ino = ldp->ld_ino; - d64p->d_off = ldp->ld_off; - d64p->d_reclen = - (((reclen + sizeof(long) - 1)) / sizeof(long)) * - sizeof(long); - if (nbytes < d64p->d_reclen) - d64p->d_reclen = reclen; - d64p->d_type = DT_UNKNOWN; /* you lose -- sorry. */ - (void )strncpy(d64p->d_name, ldp->ld_name, namlen); - *(d64p->d_name + namlen) = '\0'; - cc -= ldp->ld_reclen; - ldp = (struct linux_dirent *)((char *)ldp + ldp->ld_reclen); - nbytes -= d64p->d_reclen; - d64p = (struct dirent64 *)((char *)d64p + d64p->d_reclen); - } - free(bp); - if (d64p == (struct dirent64 *)buf && cc) - cc = -EINVAL; /* buf too small */ - cc = (char *)d64p - buf; -#else -#undef bp -#undef count -#endif - return cc; -} - -static int -native_inop_mkdir(struct pnode *pno, mode_t mode) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = syscall(SYS_mkdir, path, mode); - if (err != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_rmdir(struct pnode *pno) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = syscall(SYS_rmdir, path); - if (err != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_symlink(struct pnode *pno, const char *data) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = syscall(SYS_symlink, data, path); - if (err != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz) -{ - char *path; - int i; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - i = syscall(SYS_readlink, path, buf, bufsiz); - if (i < 0) - i = -errno; - free(path); - return i; -} - -static int -native_inop_open(struct pnode *pno, int flags, mode_t mode) -{ - struct native_inode *nino; - char *path; - int fd; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * Whether the file is already open, or not, makes no difference. - * Want to always give the host OS a chance to authorize in case - * something has changed underneath us. - */ - if (flags & O_WRONLY) { - /* - * Promote write-only attempt to RW. - */ - flags &= ~O_WRONLY; - flags |= O_RDWR; - } -#ifdef O_LARGEFILE - flags |= O_LARGEFILE; -#endif - fd = syscall(SYS_open, path, flags, mode); - if (!pno->p_base->pb_ino && fd >= 0) { - int err; - - /* - * Success but we need to return an i-node. - */ - err = - native_iget(pno->p_mount->mnt_fs, - path, - &pno->p_base->pb_ino, - 1); - if (err) { - (void )syscall(SYS_close, fd); - if (err == -EEXIST) - abort(); - fd = err; - } - } - free(path); - if (fd < 0) - return -errno; - - /* - * Remember this new open. - */ - nino = I2NI(pno->p_base->pb_ino); - nino->ni_nopens++; - assert(nino->ni_nopens); - - if (nino->ni_fd >= 0) { - if ((nino->ni_oflags & O_RDWR) || - (flags & (O_RDONLY|O_WRONLY|O_RDWR)) == O_RDONLY) { - /* - * Keep existing. - */ - (void )syscall(SYS_close, fd); - return 0; - } - (void )syscall(SYS_close, nino->ni_fd); - } - /* - * Invariant; First open. Must init. - */ - nino->ni_fpos = 0; - nino->ni_fd = fd; - /* - * Need to know whether we can seek on this - * descriptor. - */ - nino->ni_seekok = - native_pos(nino->ni_fd, &nino->ni_fpos, SEEK_CUR) != 0 ? 0 : 1; - - return 0; -} - -static int -native_inop_close(struct inode *ino) -{ - struct native_inode *nino = I2NI(ino); - int err; - - if (nino->ni_fd < 0) - abort(); - - assert(nino->ni_nopens); - if (--nino->ni_nopens) { - /* - * Hmmm. We really don't need anything else. However, some - * filesystems try to implement a sync-on-close semantic. - * As this appears now, that is lost. Might want to change - * it somehow in the future? - */ - return 0; - } - - err = syscall(SYS_close, nino->ni_fd); - if (err) - return -errno; - - nino->ni_fd = -1; - nino->ni_fpos = 0; - return 0; -} - -static int -native_inop_link(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - err = 0; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = syscall(SYS_link, opath, npath); - if (err != 0) - err = -errno; - -out: - if (opath) - free(opath); - if (npath) - free(npath); - - return err; -} - -static int -native_inop_unlink(struct pnode *pno) -{ - char *path; - int err = 0; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * For this driver, unlink is easy with open files. Since the - * file remains open to the system, too, the descriptors are still - * valid. - * - * Other drivers will have some difficulty here as the entry in the - * file system name space must be removed without sacrificing access - * to the file itself. In NFS this is done with a mechanism referred - * to as a `silly delete'. The file is moved to a temporary name - * (usually .NFSXXXXXX, where the X's are replaced by the PID and some - * unique characters) in order to simulate the proper semantic. - */ - if (syscall(SYS_unlink, path) != 0) - err = -errno; - free(path); - return err; -} - -static int -native_inop_rename(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = syscall(SYS_rename, opath, npath); - if (err != 0) - err = -errno; - -out: - if (opath) - free(opath); - if (npath) - free(npath); - - return err; -} - -static ssize_t -dopio(void *buf, size_t count, _SYSIO_OFF_T off, struct native_io *nio) -{ -#if defined(_LARGEFILE64_SOURCE) && \ - defined(SYS_pread64) && \ - defined(SYS_pwrite64) -#define _NATIVE_SYSCALL_PREAD SYS_pread64 -#define _NATIVE_SYSCALL_PWRITE SYS_pwrite64 -#else -#define _NATIVE_SYSCALL_PREAD SYS_pread -#define _NATIVE_SYSCALL_PWRITE SYS_pwrite -#endif - ssize_t cc; - - if (!(off == nio->nio_nino->ni_fpos || nio->nio_nino->ni_seekok)) - return -ESPIPE; - - if (!nio->nio_nino->ni_seekok) { - if (off != nio->nio_nino->ni_fpos) { - /* - * They've done a p{read,write} or somesuch. Can't - * seek on this descriptor so we err out now. - */ - errno = ESPIPE; - return -1; - } - cc = - syscall(nio->nio_op == 'r' ? SYS_read : SYS_write, - nio->nio_nino->ni_fd, - buf, - count); - if (cc > 0) - nio->nio_nino->ni_fpos += cc; - } else - cc = - syscall((nio->nio_op == 'r' - ? _NATIVE_SYSCALL_PREAD - : _NATIVE_SYSCALL_PWRITE), - nio->nio_nino->ni_fd, - buf, - count, - off); - - return cc; -#undef _NATIVE_SYSCALL_PREAD -#undef _NATIVE_SYSCALL_PWRITE -} - -static ssize_t -doiov(const struct iovec *iov, - int count, - _SYSIO_OFF_T off, - ssize_t limit, - struct native_io *nio) -{ - ssize_t cc; - -#if !(defined(REDSTORM) || defined(MAX_IOVEC)) -#define MAX_IOVEC INT_MAX -#endif - - if (count <= 0) - return -EINVAL; - - /* - * Avoid the reposition call if we're already at the right place. - * Allows us to access pipes and fifos. - */ - if (off != nio->nio_nino->ni_fpos) { - int err; - - err = native_pos(nio->nio_nino->ni_fd, &off, SEEK_SET); - if (err) - return err; - nio->nio_nino->ni_fpos = off; - } - - /* - * The {read,write}v is safe as this routine is only ever called - * by _sysio_enumerate_extents() and that routine is exact. It never - * passes iovectors including tails. - */ - cc = -#ifndef REDSTORM - count <= MAX_IOVEC - ? syscall(nio->nio_op == 'r' ? SYS_readv : SYS_writev, - nio->nio_nino->ni_fd, - iov, - count) - : -#endif - _sysio_enumerate_iovec(iov, - count, - off, - limit, - (ssize_t (*)(void *, - size_t, - _SYSIO_OFF_T, - void *))dopio, - nio); - if (cc < 0) - cc = -errno; - else - nio->nio_nino->ni_fpos += cc; - return cc; - -#if !(defined(REDSTORM) || defined(MAX_IOVEC)) -#undef MAX_IOVEC -#endif -} - -#if 0 -static int -lockop_all(struct native_inode *nino, - struct intnl_xtvec *xtv, - size_t count, - short op) -{ - struct flock flock; - int err; - - if (!count) - return -EINVAL; - flock.l_type = op; - flock.l_whence = SEEK_SET; - while (count--) { - flock.l_start = xtv->xtv_off; - flock.l_len = xtv->xtv_len; - xtv++; - err = - syscall( -#if !_LARGEFILE64_SOURCE - SYS_fcntl64 -#else - SYS_fcntl -#endif - , - nino->ni_fd, - F_SETLK, - &flock); - if (err != 0) - return -errno; - } - return 0; -} - -static int -order_xtv(const struct intnl_xtvec *xtv1, const struct intnl_xtvec *xtv2) -{ - - if (xtv1->xtv_off < xtv2->xtv_off) - return -1; - if (xtv1->xtv_off > xtv2->xtv_off) - return 1; - return 0; -} -#endif - -static int -doio(char op, struct ioctx *ioctx) -{ - struct native_inode *nino; -#if 0 - int dolocks; - struct intnl_xtvec *oxtv; - int err; -#endif - struct native_io arguments; - ssize_t cc; -#if 0 - struct intnl_xtvec *front, *rear, tmp; -#endif - - nino = I2NI(ioctx->ioctx_ino); -#if 0 - dolocks = ioctx->ioctx_xtvlen > 1 && nino->ni_seekok; - if (dolocks) { - /* - * Must lock the regions (in order!) since we can't do - * strided-IO as a single atomic operation. - */ - oxtv = malloc(ioctx->ioctx_xtvlen * sizeof(struct intnl_xtvec)); - if (!oxtv) - return -ENOMEM; - (void )memcpy(oxtv, - ioctx->ioctx_xtv, - ioctx->ioctx_xtvlen * sizeof(struct intnl_xtvec)); - qsort(oxtv, - ioctx->ioctx_xtvlen, - sizeof(struct intnl_xtvec), - (int (*)(const void *, const void *))order_xtv); - err = - lockop_all(nino, - oxtv, ioctx->ioctx_xtvlen, - op == 'r' ? F_RDLCK : F_WRLCK); - if (err) { - free(oxtv); - return err; - } - } -#endif - arguments.nio_op = op; - arguments.nio_nino = nino; - cc = - _sysio_enumerate_extents(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(const struct iovec *, - int, - _SYSIO_OFF_T, - ssize_t, - void *))doiov, - &arguments); -#if 0 - if (dolocks) { - /* - * Must unlock in reverse order. - */ - front = oxtv; - rear = front + ioctx->ioctx_xtvlen - 1; - while (front < rear) { - tmp = *front; - *front++ = *rear; - *rear-- = tmp; - } - if (lockop_all(nino, oxtv, ioctx->ioctx_xtvlen, F_UNLCK) != 0) - abort(); - free(oxtv); - } -#endif - if ((ioctx->ioctx_cc = cc) < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - } - return 0; -} - -static int -native_inop_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio('r', ioctx); -} - -static int -native_inop_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio('w', ioctx); -} - -static _SYSIO_OFF_T -native_inop_pos(struct inode *ino, _SYSIO_OFF_T off) -{ - struct native_inode *nino = I2NI(ino); - int err; - - err = native_pos(nino->ni_fd, &off, SEEK_SET); - return err < 0 ? err : off; -} - -static int -native_inop_iodone(struct ioctx *ioctxp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -native_inop_fcntl(struct inode *ino, - int cmd, - va_list ap, - int *rtn) -{ - struct native_inode *nino = I2NI(ino); - long arg; - int err; - - if (nino->ni_fd < 0) - abort(); - - err = 0; - switch (cmd) { - case F_GETFD: - case F_GETFL: -#ifdef F_GETOWN - case F_GETOWN: -#endif - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd); - if (*rtn == -1) - err = -errno; - break; - case F_DUPFD: - case F_SETFD: - case F_SETFL: - case F_GETLK: - case F_SETLK: - case F_SETLKW: -#ifdef F_SETOWN - case F_SETOWN: -#endif - arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd, arg); - if (*rtn == -1) - err = -errno; - break; - default: - *rtn = -1; - err = -EINVAL; - } - return err; -} - -static int -native_inop_mknod(struct pnode *pno __IS_UNUSED, - mode_t mode __IS_UNUSED, - dev_t dev __IS_UNUSED) -{ - - return -ENOSYS; -} - -#ifdef _HAVE_STATVFS -static int -native_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf) -{ - char *path; - int rc; - struct statfs fs; - - path = NULL; - if (!ino || I2NI(ino)->ni_fd < 0) { - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * The syscall interface does not support SYS_fstatvfs. - * Should possibly return ENOSYS, but thought it - * better to use SYS_fstatfs and fill in as much of - * the statvfs structure as possible. This allows - * for more of a test of the sysio user interface. - */ - rc = - path - ? syscall(SYS_statfs, path, &fs) - : syscall(SYS_fstatfs, I2NI(ino)->ni_fd, &fs); - if (path) - free(path); - if (rc < 0) - return -errno; - - buf->f_bsize = fs.f_bsize; /* file system block size */ - buf->f_frsize = fs.f_bsize; /* file system fundamental block size */ - buf->f_blocks = fs.f_blocks; - buf->f_bfree = fs.f_bfree; - buf->f_bavail = fs.f_bavail; - buf->f_files = fs.f_files; /* Total number serial numbers */ - buf->f_ffree = fs.f_ffree; /* Number free serial numbers */ - buf->f_favail = fs.f_ffree; /* Number free ser num for non-privileged*/ - buf->f_fsid = fs.f_fsid.__val[1]; - buf->f_flag = 0; /* No equiv in statfs; maybe use type? */ - buf->f_namemax = fs.f_namelen; - return 0; -} -#endif - -static int -native_inop_sync(struct inode *ino) -{ - int err; - - assert(I2NI(ino)->ni_fd >= 0); - - err = syscall(SYS_fsync, I2NI(ino)->ni_fd); - if (err) - err = -errno; - return err; -} - -static int -native_inop_datasync(struct inode *ino) -{ - int err; - - assert(I2NI(ino)->ni_fd >= 0); - -#ifdef NATIVE_FDATASYNC - err = syscall(NATIVE_FDATASYNC, I2NI(ino)->ni_fd); -#else -#if 0 -#warning No fdatasync system call -- Using fsync instead! -#endif - err = syscall(SYS_fsync, I2NI(ino)->ni_fd); -#endif - if (err) - err = -errno; - return err; -} - -#ifdef HAVE_LUSTRE_HACK -static int -native_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap) -{ - long arg1, arg2, arg3, arg4; - - assert(I2NI(ino)->ni_fd >= 0); - - arg1 = va_arg(ap, long); - arg2 = va_arg(ap, long); - arg3 = va_arg(ap, long); - arg4 = va_arg(ap, long); - - return syscall(SYS_ioctl, I2NI(ino)->ni_fd, request, - arg1, arg2, arg3, arg4); -} -#else -static int -native_inop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - /* - * I'm lazy. Maybe implemented later. - */ - errno = ENOTTY; - return -1; -} -#endif - -static void -native_inop_gone(struct inode *ino) -{ - struct native_inode *nino = I2NI(ino); - - if (nino->ni_fd >= 0) - (void )syscall(SYS_close, nino->ni_fd); - - free(ino->i_private); -} - -static void -native_fsop_gone(struct filesys *fs __IS_UNUSED) -{ - - /* - * Do nothing. There is no private part maintained for the - * native file interface. - */ -} diff --git a/libsysio/drivers/native/fs_native.h b/libsysio/drivers/native/fs_native.h deleted file mode 100644 index 1590379..0000000 --- a/libsysio/drivers/native/fs_native.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Native file system driver support. - */ - -extern int _sysio_native_init(void); diff --git a/libsysio/drivers/native/module.mk b/libsysio/drivers/native/module.mk deleted file mode 100644 index 8cada8a..0000000 --- a/libsysio/drivers/native/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -NATIVE_SRCS = drivers/native/fs_native.c -NATIVE_EXTRA = drivers/native/fs_native.h drivers/native/module.mk diff --git a/libsysio/drivers/sockets/module.mk b/libsysio/drivers/sockets/module.mk deleted file mode 100644 index 261fcfa..0000000 --- a/libsysio/drivers/sockets/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -SOCKETS_SRCS = drivers/sockets/sockets.c -SOCKETS_EXTRA = drivers/sockets/module.mk diff --git a/libsysio/drivers/sockets/sockets.c b/libsysio/drivers/sockets/sockets.c deleted file mode 100644 index b037e60..0000000 --- a/libsysio/drivers/sockets/sockets.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include /* for NULL */ -#include -#ifdef __linux__ -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "fs.h" -#include "inode.h" -#include "file.h" -#include "dev.h" /* _sysio_nodev_ops */ - -/* - * Sockets interface driver - */ - -/* - * Sockets file identifiers format. - */ -struct sockets_ino_identifier { - ino_t inum; /* i-number */ -}; - -/* - * Driver-private i-node information we keep about in-use sockets. - */ -struct socket_info { - struct sockets_ino_identifier ski_ident; /* unique identifier */ - struct file_identifier ski_fileid; /* ditto */ - int ski_fd; /* host fildes */ -}; - -static int sockets_inop_close(struct inode *ino); -static int sockets_inop_read(struct inode *ino, - struct ioctx *ioctx); -static int sockets_inop_write(struct inode *ino, - struct ioctx *ioctxp); -static _SYSIO_OFF_T sockets_inop_pos(struct inode *ino, - _SYSIO_OFF_T off); -static int sockets_inop_iodone(struct ioctx *ioctx); -static int sockets_inop_sync(struct inode *ino); -static int sockets_inop_datasync(struct inode *ino); -static int sockets_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int sockets_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static void sockets_inop_gone(struct inode *ino); -static void sockets_illop(void); - -/* - * Given i-node, return driver private part. - */ -#define I2SKI(ino) ((struct socket_info *)((ino)->i_private)) - -struct filesys_ops sockets_filesys_ops = { - (void (*)(struct filesys *))sockets_illop -}; - -static struct filesys *sockets_fs; - -static struct inode_ops sockets_i_ops; - -/* - * Initialize this driver. - */ -int -_sysio_sockets_init() -{ - - sockets_i_ops = _sysio_nodev_ops; - sockets_i_ops.inop_close = sockets_inop_close; - sockets_i_ops.inop_read = sockets_inop_read; - sockets_i_ops.inop_write = sockets_inop_write; - sockets_i_ops.inop_pos = sockets_inop_pos; - sockets_i_ops.inop_iodone = sockets_inop_iodone; - sockets_i_ops.inop_fcntl = sockets_inop_fcntl; - sockets_i_ops.inop_sync = sockets_inop_sync; - sockets_i_ops.inop_datasync = sockets_inop_datasync; - sockets_i_ops.inop_ioctl = sockets_inop_ioctl; - sockets_i_ops.inop_gone = sockets_inop_gone; - - sockets_fs = _sysio_fs_new(&sockets_filesys_ops, 0, NULL); - if (!sockets_fs) - return -ENOMEM; - - return 0; -} - -static int -sockets_inop_close(struct inode *ino) -{ - struct socket_info *ski = I2SKI(ino); - int err; - - if (ski->ski_fd < 0) - return -EBADF; - - err = syscall(SYS_close, ski->ski_fd); - if (err) - return -errno; - ski->ski_fd = -1; - return 0; -} - -/* - * A helper function performing the real IO operation work. - * - * We don't really have async IO. We'll just perform the function - * now. - */ -static int -doio(ssize_t (*f)(int, const struct iovec *, int), - struct inode *ino, - struct ioctx *ioctx) -{ - struct socket_info *ski = I2SKI(ino); - - assert(ski->ski_fd >= 0); - - /* XXX there's no way to check the position - * here we only could ingore the extends - */ - if (ioctx->ioctx_xtvlen != 1) - return -EINVAL; - - if (ioctx->ioctx_iovlen && (int) ioctx->ioctx_iovlen < 0) - return -EINVAL; - - /* - * Call the appropriate (read/write) IO function to - * transfer the data now. - */ - ioctx->ioctx_cc = - (*f)(ski->ski_fd, ioctx->ioctx_iov, ioctx->ioctx_iovlen); - if (ioctx->ioctx_cc < 0) - ioctx->ioctx_errno = errno; - - ioctx->ioctx_done = 1; - return 0; -} - -/* - * Helper function passed to doio(), above, to accomplish a real readv. - */ -static ssize_t -_readv(int fd, const struct iovec *vector, int count) -{ - - return syscall(SYS_readv, fd, vector, count); -} - -static int -sockets_inop_read(struct inode *ino, - struct ioctx *ioctx) -{ - - return doio(_readv, ino, ioctx); -} - -/* - * Helper function passed to doio(), above, to accomplish a real writev. - */ -static ssize_t -_writev(int fd, const struct iovec *vector, int count) -{ - - return syscall(SYS_writev, fd, vector, count); -} - -static int -sockets_inop_write(struct inode *ino, - struct ioctx *ioctx) -{ - - return doio(_writev, ino, ioctx); -} - -static _SYSIO_OFF_T -sockets_inop_pos(struct inode *ino __IS_UNUSED, _SYSIO_OFF_T off __IS_UNUSED) -{ - return -EINVAL; -} - -static int -sockets_inop_iodone(struct ioctx *ioctxp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -sockets_inop_fcntl(struct inode *ino __IS_UNUSED, - int cmd __IS_UNUSED, - va_list ap __IS_UNUSED, - int *rtn) -{ - long arg; - - assert(I2SKI(ino)->ski_fd >= 0); - - switch (cmd) { - case F_GETFD: - case F_GETFL: - case F_GETOWN: - *rtn = syscall(SYS_fcntl, I2SKI(ino)->ski_fd, cmd); - break; - case F_DUPFD: - case F_SETFD: - case F_SETFL: - case F_GETLK: - case F_SETLK: - case F_SETLKW: - case F_SETOWN: - arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, I2SKI(ino)->ski_fd, cmd, arg); - break; - default: - *rtn = -1; - errno = EINVAL; - } - return *rtn == -1 ? -errno : 0; -} - -static int -sockets_inop_sync(struct inode *ino) -{ - - assert(I2SKI(ino)->ski_fd >= 0); - - return syscall(SYS_fsync, I2SKI(ino)->ski_fd); -} - -static int -sockets_inop_datasync(struct inode *ino) -{ - - assert(I2SKI(ino)->ski_fd >= 0); - - return syscall(SYS_fdatasync, I2SKI(ino)->ski_fd); -} - -#ifdef HAVE_LUSTRE_HACK -/* - * we blindly extract 4 params and pass to host kernel, the stack - * should be ok. hope no ioctl will consume more then 4 params... - */ -static int -sockets_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap) -{ - long arg1, arg2, arg3, arg4; - - assert(I2SKI(ino)->ski_fd >= 0); - - arg1 = va_arg(ap, long); - arg2 = va_arg(ap, long); - arg3 = va_arg(ap, long); - arg4 = va_arg(ap, long); - - return syscall(SYS_ioctl, I2SKI(ino)->ski_fd, request, - arg1, arg2, arg3, arg4); -} -#else -static int -sockets_inop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - /* - * I'm lazy. Maybe implemented later. - */ - return -ENOTTY; -} -#endif - -static void -sockets_inop_gone(struct inode *ino) -{ - - (void )sockets_inop_close(ino); - free(ino->i_private); -} - -static void -sockets_illop(void) -{ - - abort(); -} - -static struct inode * -_sysio_sockets_inew() -{ - static ino_t inum = 1; - struct socket_info *ski; - struct inode *ino; - - ski = malloc(sizeof(struct socket_info)); - if (!ski) - return NULL; - ski->ski_ident.inum = inum++; - ski->ski_fileid.fid_data = &ski->ski_ident; - ski->ski_fileid.fid_len = sizeof(ski->ski_ident); - ski->ski_fd = -1; - - ino = - _sysio_i_new(sockets_fs, - &ski->ski_fileid, - 0, - 0, - 0, - &sockets_i_ops, - ski); - if (!ino) - free(ski); - - return ino; -} - -int -socket(int domain, int type, int protocol) -{ - int err; - struct inode *ino; - struct socket_info *ski; - struct file *fil; - - err = 0; - fil = NULL; - - ino = _sysio_sockets_inew(); - if (!ino) { - err = -ENOMEM; - goto error; - } - - ski = I2SKI(ino); -#ifndef SYS_socketcall - ski->ski_fd = syscall(SYS_socket, domain, type, protocol); -#else - { - unsigned long avec[3] = {domain, type, protocol}; - ski->ski_fd = syscall(SYS_socketcall, SYS_SOCKET, avec); - } -#endif - if (ski->ski_fd < 0) { - err = -errno; - goto error; - } - - fil = _sysio_fnew(ino, O_RDWR); - if (!fil) { - err = -ENOMEM; - goto error; - } - -#ifdef HAVE_LUSTRE_HACK - err = _sysio_fd_set(fil, ski->ski_fd, 1); -#else - err = _sysio_fd_set(fil, -1, 0); -#endif - if (err < 0) - goto error; - - return err; - -error: - if (fil) - F_RELE(fil); - if (ino) - I_RELE(ino); - - errno = -err; - return -1; -} - -int -accept(int s, struct sockaddr *addr, socklen_t *addrlen) -{ - int err; - struct inode *ino; - struct socket_info *ski; - struct file *ofil, *nfil; - - err = 0; - nfil = NULL; - ino = NULL; - - ofil = _sysio_fd_find(s); - if (!ofil) { - err = -EBADF; - goto error; - } - - ino = _sysio_sockets_inew(); - if (!ino) { - err = -ENOMEM; - goto error; - } - - nfil = _sysio_fnew(ino, O_RDWR); - if (!nfil) { - err = -ENOMEM; - goto error; - } - - ski = I2SKI(ino); -#ifndef SYS_socketcall - ski->ski_fd = syscall(SYS_accept, I2SKI(ofil->f_ino)->ski_fd, - addr, addrlen); -#else - { - unsigned long avec[3] = { - (unsigned long) I2SKI(ofil->f_ino)->ski_fd, - (unsigned long) addr, - (unsigned long) addrlen}; - ski->ski_fd = syscall(SYS_socketcall, SYS_ACCEPT, avec); - } -#endif - if (ski->ski_fd < 0) { - err = -errno; - goto error; - } - -#ifdef HAVE_LUSTRE_HACK - err = _sysio_fd_set(nfil, ski->ski_fd, 1); -#else - err = _sysio_fd_set(nfil, -1, 0); -#endif - if (err < 0) - goto error; - - return err; - -error: - if (nfil) - F_RELE(nfil); - if (ino) - I_RELE(ino); - - errno = -err; - return -1; -} - -int -bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen) -{ - int err; - struct file *fil; - unsigned long avec[3]; - - err = 0; - - fil = _sysio_fd_find(sockfd); - if (!fil) { - err = -EBADF; - goto out; - } - -#ifndef SYS_socketcall - if (syscall(SYS_bind, I2SKI(fil->f_ino)->ski_fd, my_addr, addrlen)) { -#else - avec[0] = I2SKI(fil->f_ino)->ski_fd; - avec[1] = (unsigned long )my_addr; - avec[2] = addrlen; - if (syscall(SYS_socketcall, SYS_BIND, avec) != 0) { -#endif - err = -errno; - goto out; - } - - return 0; -out: - errno = -err; - return -1; -} - -int -listen(int s, int backlog) -{ - int err; - struct file *fil; - unsigned long avec[2]; - - err = 0; - - fil = _sysio_fd_find(s); - if (!fil) { - err = -EBADF; - goto out; - } - -#ifndef SYS_socketcall - if (syscall(SYS_listen, I2SKI(fil->f_ino)->ski_fd, backlog) != 0) { -#else - avec[0] = I2SKI(fil->f_ino)->ski_fd; - avec[1] = backlog; - if (syscall(SYS_socketcall, SYS_LISTEN, avec) != 0) { -#endif - err = -errno; - goto out; - } - - return 0; -out: - errno = -err; - return -1; -} - -int -connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) -{ - int err; - struct file *fil; - unsigned long avec[3]; - - err = 0; - - fil = _sysio_fd_find(sockfd); - if (!fil) { - err = -EBADF; - goto out; - } - -#ifndef SYS_socketcall - if (syscall(SYS_connect, I2SKI(fil->f_ino)->ski_fd, - serv_addr, addrlen) != 0) { -#else - avec[0] = I2SKI(fil->f_ino)->ski_fd; - avec[1] = (unsigned long )serv_addr; - avec[2] = addrlen; - if (syscall(SYS_socketcall, SYS_CONNECT, avec) != 0) { -#endif - err = -errno; - goto out; - } - - return 0; -out: - errno = -err; - return -1; -} diff --git a/libsysio/drivers/yod/fs_yod.c b/libsysio/drivers/yod/fs_yod.c deleted file mode 100644 index 62eb9f2..0000000 --- a/libsysio/drivers/yod/fs_yod.c +++ /dev/null @@ -1,1251 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#include /* for NULL */ -#include -#ifdef __linux__ -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#ifdef _HAVE_STATVFS -#include -#endif -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" - -#include "fs_yod.h" - -/* - * Remote file system driver - * calls are re-directed to the initiating yod - */ -#include "cplant-yod.h" - -/* stat struct used by yod, which - * is not compiled with __USE_FILE_OFFSET64 - */ -#define __yod_stat stat -#ifdef ALPHA_LINUX -#define COPY_STAT(src, dest) \ -do { \ - memset((dest), 0, sizeof((*dest))); \ - (dest)->st_dev = (src)->st_dev; \ - (dest)->st_ino = (src)->st_ino; \ - (dest)->st_mode = (src)->st_mode; \ - (dest)->st_nlink = (src)->st_nlink; \ - (dest)->st_uid = (src)->st_uid; \ - (dest)->st_gid = (src)->st_gid; \ - (dest)->st_rdev = (src)->st_rdev; \ - (dest)->st_size = (src)->st_size; \ - (dest)->st_atime = (src)->st_atime; \ - (dest)->st_mtime = (src)->st_mtime; \ - (dest)->st_ctime = (src)->st_ctime; \ - (dest)->st_blksize = (src)->st_blksize; \ - (dest)->st_blocks = (src)->st_blocks; \ - (dest)->st_flags = (src)->st_flags; \ - (dest)->st_gen = (src)->st_gen; \ -} while (0); -#else -#define COPY_STAT(src, dest) \ -do { \ - memset((dest), 0, sizeof((*dest))); \ - (dest)->st_dev = (src)->st_dev; \ - (dest)->st_ino = (src)->st_ino; \ - (dest)->st_mode = (src)->st_mode; \ - (dest)->st_nlink = (src)->st_nlink; \ - (dest)->st_uid = (src)->st_uid; \ - (dest)->st_gid = (src)->st_gid; \ - (dest)->st_rdev = (src)->st_rdev; \ - (dest)->st_size = (src)->st_size; \ - (dest)->st_atime = (src)->st_atime; \ - (dest)->st_mtime = (src)->st_mtime; \ - (dest)->st_ctime = (src)->st_ctime; \ - (dest)->st_blksize = (src)->st_blksize; \ - (dest)->st_blocks = (src)->st_blocks; \ -} while (0); -#endif - -/* - * Yod file identifiers format. - */ -struct yod_inode_identifier { - dev_t dev; /* device number */ - ino_t ino; /* i-number */ -#ifdef HAVE_GENERATION - unsigned int gen; /* generation number */ -#endif -}; - -/* - * Driver-private i-node information we keep about local host file - * system objects. - */ -struct yod_inode { - unsigned ni_seekok : 1; /* can seek? */ - struct yod_inode_identifier ni_ident; /* unique identifier */ - struct file_identifier ni_fileid; /* ditto */ - int ni_fd; /* host fildes */ - int ni_oflags; /* flags, from open */ - unsigned ni_nopens; /* soft ref count */ - _SYSIO_OFF_T ni_fpos; /* current pos */ -}; - -static int yod_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); -static int yod_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); -static int yod_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -static ssize_t yod_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - off64_t *basep); -static int yod_inop_mkdir(struct pnode *pno, mode_t mode); -static int yod_inop_rmdir(struct pnode *pno); -static int yod_inop_symlink(struct pnode *pno, const char *data); -static int yod_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); -static int yod_inop_open(struct pnode *pno, int flags, mode_t mode); -static int yod_inop_close(struct inode *ino); -static int yod_inop_link(struct pnode *old, struct pnode *new); -static int yod_inop_unlink(struct pnode *pno); -static int yod_inop_rename(struct pnode *old, struct pnode *new); -static _SYSIO_OFF_T yod_inop_pos (struct inode *ino, _SYSIO_OFF_T off); -static int yod_inop_read(struct inode *ino, struct ioctx *ioctx); -static int yod_inop_write(struct inode *ino, struct ioctx *ioctx); -static int yod_inop_iodone(struct ioctx *ioctx); -static int yod_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int yod_inop_sync(struct inode *ino); -static int yod_inop_datasync(struct inode *ino); -static int yod_inop_ioctl(struct inode *ino, - unsigned long int request, - va_list ap); -static int yod_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS -static int yod_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif -static void yod_inop_gone(struct inode *ino); - -static struct inode_ops yod_i_ops = { - yod_inop_lookup, - yod_inop_getattr, - yod_inop_setattr, - yod_getdirentries, - yod_inop_mkdir, - yod_inop_rmdir, - yod_inop_symlink, - yod_inop_readlink, - yod_inop_open, - yod_inop_close, - yod_inop_link, - yod_inop_unlink, - yod_inop_rename, - yod_inop_read, - yod_inop_write, - yod_inop_pos, - yod_inop_iodone, - yod_inop_fcntl, - yod_inop_sync, - yod_inop_datasync, - yod_inop_ioctl, - yod_inop_mknod, -#ifdef _HAVE_STATVFS - yod_inop_statvfs, -#endif - yod_inop_gone -}; - -static int yod_fsswop_mount(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); - -static struct fssw_ops yod_fssw_ops = { - yod_fsswop_mount -}; - -static void yod_fsop_gone(struct filesys *fs); - -static struct filesys_ops yod_inodesys_ops = { - yod_fsop_gone -}; - -/* - * Placeholder internal mount as in native driver - */ -static struct mount *yod_internal_mount = NULL; - -/* - * Given i-node, return driver private part. - */ -#define I2NI(ino) ((struct yod_inode *)((ino)->i_private)) - -/* - * stat -- by path. - */ -static int -yod_stat(const char *path, struct intnl_stat *buf) -{ - int err; - struct __yod_stat stbuf; - - err = stat_yod(path, &stbuf); - if (err) - err = -errno; - COPY_STAT(&stbuf, buf); - - return err; -} - -/* - * stat -- by fildes - */ -static int -yod_fstat(int fd, struct intnl_stat *buf) -{ - int err; - struct __yod_stat stbuf; - - err = fstat_yod(fd, &stbuf); - if (err) - err = -errno; - COPY_STAT(&stbuf, buf); - - return err; -} - -/* - * Introduce an i-node to the system. - */ -static struct inode * -yod_i_new(struct filesys *fs, struct intnl_stat *buf) -{ - struct yod_inode *nino; - struct inode *ino; - - nino = malloc(sizeof(struct yod_inode)); - if (!nino) - return NULL; - bzero(&nino->ni_ident, sizeof(nino->ni_ident)); - nino->ni_ident.dev = buf->st_dev; - nino->ni_ident.ino = buf->st_ino; -#ifdef HAVE_GENERATION - nino->ni_ident.gen = buf->st_gen; -#endif - nino->ni_fileid.fid_data = &nino->ni_ident; - nino->ni_fileid.fid_len = sizeof(nino->ni_ident); - nino->ni_fd = -1; - nino->ni_oflags = 0; - nino->ni_nopens = 0; - nino->ni_fpos = 0; - ino = - _sysio_i_new(fs, - &nino->ni_fileid, -#ifndef AUTOMOUNT_FILE_NAME - buf->st_mode & S_IFMT, -#else - buf->st_mode, /* all of the bits! */ -#endif - 0, - 0, - &yod_i_ops, - nino); - if (!ino) - free(nino); - return ino; -} - -/* - * Initialize this driver. - */ -int -_sysio_yod_init() -{ - - /* - * Capture current process umask and reset our process umask to - * zero. All permission bits to open/creat/setattr are absolute -- - * They've already had a umask applied, when appropriate. - */ - _sysio_umask = syscall(SYS_umask, 0); - - return _sysio_fssw_register("yod", &yod_fssw_ops); -} - -/* - * Create private, internal, view of the hosts name space. - */ -static int -create_internal_namespace() -{ - int err; - struct mount *mnt; - struct inode *rootino; - struct pnode_base *rootpb; - static struct qstr noname = { NULL, 0, 0 }; - struct filesys *fs; - struct intnl_stat stbuf; - - if (yod_internal_mount) { - /* - * Reentered! - */ - abort(); - } - - /* - * We maintain an artificial, internal, name space in order to - * have access to fully qualified path names in the various routines. - * Initialize that name space now. - */ - mnt = NULL; - rootino = NULL; - rootpb = NULL; - fs = _sysio_fs_new(&yod_inodesys_ops, 0, NULL); - if (!fs) { - err = -ENOMEM; - goto error; - } - - /* - * Get root i-node. - */ - err = yod_stat("/", &stbuf); - if (err) - goto error; - rootino = yod_i_new(fs, &stbuf); - if (!rootino) { - err = -ENOMEM; - goto error; - } - - /* - * Generate base path-node for root. - */ - rootpb = _sysio_pb_new(&noname, NULL, rootino); - if (!rootpb) { - err = -ENOMEM; - goto error; - } - - /* - * Mount it. This name space is disconnected from the - * rest of the system -- Only available within this driver. - */ - err = _sysio_do_mount(fs, rootpb, 0, NULL, &mnt); - if (err) - goto error; - - yod_internal_mount = mnt; - return 0; -error: - if (mnt) { - if (_sysio_do_unmount(mnt) != 0) - abort(); - fs = NULL; - rootpb = NULL; - rootino = NULL; - } - if (rootpb) - _sysio_pb_gone(rootpb); - if (fs) { - FS_RELE(fs); - _sysio_fs_gone(fs); - } - - return err; -} - -static int -yod_fsswop_mount(const char *source, - unsigned flags, - const void *data __IS_UNUSED, - struct pnode *tocover, - struct mount **mntp) -{ - int err; - struct nameidata nameidata; - struct mount *mnt; - - /* - * Caller must use fully qualified path names when specifying - * the source. - */ - if (*source != '/') - return -ENOENT; - - if (!yod_internal_mount) { - err = create_internal_namespace(); - if (err) - return err; - } - - /* - * Lookup the source in the internally maintained name space. - */ - ND_INIT(&nameidata, 0, source, yod_internal_mount->mnt_root, NULL); - err = _sysio_path_walk(yod_internal_mount->mnt_root, &nameidata); - if (err) - return err; - - /* - * Have path-node specified by the given source argument. Let the - * system finish the job, now. - */ - err = - _sysio_do_mount(yod_internal_mount->mnt_fs, - nameidata.nd_pno->p_base, - flags, - tocover, - &mnt); - /* - * Release the internal name space pnode and clean up any - * aliases we might have generated. We really don't need to cache them - * as they are only used at mount time.. - */ - P_RELE(nameidata.nd_pno); - (void )_sysio_p_prune(yod_internal_mount->mnt_root); - - if (!err) { - FS_REF(yod_internal_mount->mnt_fs); - *mntp = mnt; - } - return err; -} - -static int -yod_i_invalid(struct inode *inop, struct intnl_stat stbuf) -{ - /* - * Validate passed in inode against stat struct info - */ - struct yod_inode *nino = I2NI(inop); - - if ((nino->ni_ident.dev != stbuf.st_dev || - nino->ni_ident.ino != stbuf.st_ino || -#ifdef HAVE_GENERATION - nino->ni_ident.gen != stbuf.st_gen || -#endif - ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) || - (((inop)->i_rdev != stbuf.st_rdev) && - (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)))) - return 1; - - return 0; -} - -/* - * Find, and validate, or create i-node by host-relative path. Returned i-node - * is referenced. - */ -static int -yod_iget(struct filesys *fs, - const char *path, - struct inode **inop, - int forced) -{ - int err; - struct inode *ino; - struct intnl_stat stbuf; - struct yod_inode_identifier ident; - struct file_identifier fileid; - - /* - * Get file status. - */ - err = yod_stat(path, &stbuf); - if (err) { - *inop = NULL; - return err; - } - - /* - * Validate? - */ - if (*inop) { - if (!yod_i_invalid(*inop, stbuf)) - return 0; - /* - * Invalidate. - */ - *inop = NULL; - } - - /* - * I-node is not already known. Find or create it. - */ - bzero(&ident, sizeof(ident)); - ident.dev = stbuf.st_dev; - ident.ino = stbuf.st_ino; -#ifdef HAVE_GENERATION - ident.gen = stbuf.st_gen; -#endif - fileid.fid_data = &ident; - fileid.fid_len = sizeof(ident); - ino = _sysio_i_find(fs, &fileid); - if (ino && forced) { - /* - * Insertion was forced but it's already present! - */ - if (yod_i_invalid(ino, stbuf)) { - /* - * Cached inode has stale attrs - * make way for the new one - */ - I_RELE(ino); - _sysio_i_undead(ino); - ino = NULL; - } else - /* - * OK to reuse cached inode - */ - goto out; - } - - if (!ino) { - ino = yod_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } -out: - if (!err) - *inop = ino; - return err; -} - -/* - * Look up named object in host's name space by path. - */ -static int -yod_path_lookup(struct filesys *fs, const char *path, struct inode **inop) -{ - - return yod_iget(fs, path, inop, 0); -} - -/* - * Look up object by it's path node. - */ -static int -yod_i_lookup(struct filesys *fs, struct pnode_base *pb, struct inode **inop) -{ - int err; - char *path; - - path = _sysio_pb_path(pb, '/'); - if (!path) - return -ENOMEM; - err = yod_path_lookup(fs, path, inop); - free(path); - return err; -} - -static int -yod_inop_lookup(struct pnode *pno, - struct inode **inop, - struct intent *intnt __IS_UNUSED, - const char *path __IS_UNUSED) -{ - int err; - - *inop = pno->p_base->pb_ino; - - /* - * Don't have an inode yet. Because we translate everything back to - * a single name space for the host, we will assume the object the - * caller is looking for has no existing alias in our internal - * name space. We don't see the same file on different mounts in the - * underlying host FS as the same file. - * - * The file identifier *will* be unique. It's got to have a different - * dev. - */ - err = yod_i_lookup(pno->p_mount->mnt_fs, pno->p_base, inop); - if (err) - *inop = NULL; - return err; -} - -static int -yod_inop_getattr(struct pnode *pno, struct inode *ino, struct intnl_stat *stbuf) -{ - char *path; - int err; - - path = NULL; - if (!ino || I2NI(ino)->ni_fd < 0) { - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - err = - path - ? yod_stat(path, stbuf) - : yod_fstat(I2NI(ino)->ni_fd, stbuf); - if (path) - free(path); - return err; -} - -static int -yod_inop_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - char *path; - int fd; - struct intnl_stat st; - int err; - - path = NULL; - fd = ino ? I2NI(ino)->ni_fd : -1; - if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { - if (!pno) - return -EEXIST; - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * Get current status for undo. - */ - err = - fd < 0 - ? yod_stat(path, &st) - : yod_fstat(fd, &st); - if (err) - goto out; - - if (mask & SETATTR_MODE) { - mode_t mode; - - /* - * Alter permissions attribute. - */ - mode = stbuf->st_mode & 07777; - err = chmod_yod(path, mode); - } - if (err) - mask &= ~SETATTR_MODE; - - if (mask & (SETATTR_UID|SETATTR_GID)) { - - /* - * Alter owner and/or group identifiers. - */ - err = chown_yod(path, - mask & SETATTR_UID - ? stbuf->st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? stbuf->st_gid - : (gid_t )-1); - } - if (err) - mask &= ~(SETATTR_UID|SETATTR_GID); - else if (mask & SETATTR_LEN) { - /* - * Do the truncate last. It can't be undone. - */ - (void )(fd < 0 - ? truncate_yod(path, stbuf->st_size) - : ftruncate_yod(fd, stbuf->st_size)); - } - if (!err) - goto out; - /* - * Undo after error. Some or all of this might not work... We - * can but try. - */ - if (mask & (SETATTR_UID|SETATTR_GID)) { - (void )chown_yod(path, - mask & SETATTR_UID - ? st.st_uid - : (uid_t )-1, - mask & SETATTR_GID - ? st.st_gid - : (gid_t )-1); - } - if (mask & SETATTR_MODE) { - chmod_yod(path, st.st_mode & 07777); - } -out: - if (path) - free(path); - return err; -} - -static ssize_t -yod_getdirentries(struct inode *ino, - char *buf, - size_t nbytes, - off64_t *basep) -{ - struct yod_inode *nino = I2NI(ino); - loff_t result; - ssize_t cc; - - assert(nino->ni_fd >= 0); - - result = *basep; - if (*basep != nino->ni_fpos && - (result = lseek_yod(nino->ni_fd, - *basep, - SEEK_SET) == -1)) - return -errno; - nino->ni_fpos = result; - cc = getdirentries_yod(nino->ni_fd, buf, nbytes, &result); - if (cc < 0) - return -errno; - nino->ni_fpos += cc; - return cc; -} - -static int -yod_inop_mkdir(struct pnode *pno, mode_t mode) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = mkdir_yod(path, mode); - free(path); - return err; -} - -static int -yod_inop_rmdir(struct pnode *pno) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = rmdir_yod(path); - free(path); - return err; -} - -static int -yod_inop_symlink(struct pnode *pno, const char *data) -{ - char *path; - int err; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - err = symlink_yod(data, path); - free(path); - return err; -} - -static int -yod_inop_readlink(struct pnode *pno __IS_UNUSED, - char *buf __IS_UNUSED, - size_t bufsiz __IS_UNUSED) -{ - - return -ENOSYS; -} - -static int -yod_inop_open(struct pnode *pno, int flags, mode_t mode) -{ - struct yod_inode *nino; - char *path; - int fd; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * Whether the file is already open, or not, makes no difference. - * Want to always give the host OS a chance to authorize in case - * something has changed underneath us. - */ - if (flags & O_WRONLY) { - /* - * Promote write-only attempt to RW. - */ - flags &= ~O_WRONLY; - flags |= O_RDWR; - } - fd = open_yod(path, flags, mode); - if (!pno->p_base->pb_ino && fd >= 0) { - int err; - - /* - * Success but we need to return an i-node. - */ - err = - yod_iget(pno->p_mount->mnt_fs, - path, - &pno->p_base->pb_ino, - 1); - if (err) { - (void )close_yod(fd); - if (err == -EEXIST) - abort(); - fd = err; - } - } - free(path); - if (fd < 0) - return -errno; - - /* - * Remember this new open. - */ - nino = I2NI(pno->p_base->pb_ino); - nino->ni_nopens++; - assert(nino->ni_nopens); - - if (nino->ni_fd >= 0) { - if ((nino->ni_oflags & O_RDWR) || - (flags & (O_RDONLY|O_WRONLY|O_RDWR)) == O_RDONLY) { - /* - * Keep existing. - */ - (void )close_yod(fd); - return 0; - } - (void )close_yod(nino->ni_fd); - } - /* - * Invariant; First open. Must init. - */ - nino->ni_fpos = 0; - nino->ni_fd = fd; - - /* - * Need to know whether we can seek on this - * descriptor. - */ - nino->ni_seekok = - lseek_yod(nino->ni_fd, 0, SEEK_CUR) != 0 ? 0 : 1; - - return 0; -} - -static int -yod_inop_close(struct inode *ino) -{ - struct yod_inode *nino = I2NI(ino); - int err; - - if (nino->ni_fd < 0) - abort(); - - assert(nino->ni_nopens); - if (--nino->ni_nopens) - return 0; - - err = close_yod(nino->ni_fd); - if (err) - return -errno; - - nino->ni_fd = -1; - nino->ni_fpos = 0; - return 0; -} - -static int -yod_inop_link(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - err = 0; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = link_yod(opath, npath); - -out: - if (opath) - free(opath); - if (npath) - free(npath); - - return err; -} - -static int -yod_inop_unlink(struct pnode *pno) -{ - char *path; - int err = 0; - - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - - /* - * For this driver, unlink is easy with open files. Since the - * file remains open to the system, too, the descriptors are still - * valid. - * - * Other drivers will have some difficulty here as the entry in the - * file system name space must be removed without sacrificing access - * to the file itself. In NFS this is done with a mechanism referred - * to as a `silly delete'. The file is moved to a temporary name - * (usually .NFSXXXXXX, where the X's are replaced by the PID and some - * unique characters) in order to simulate the proper semantic. - */ - if (unlink_yod(path) != 0) - err = -errno; - free(path); - return err; -} - -/* - * A helper function performing the real IO operation work. - * - * We don't really have async IO. We'll just perform the function - * now. - */ -static int -doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct yod_inode *), - struct ioctx *ioctx) -{ - struct yod_inode *nino = I2NI(ioctx->ioctx_ino); - - ioctx->ioctx_cc = - _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, - ioctx->ioctx_iov, ioctx->ioctx_iovlen, - (ssize_t (*)(void *, size_t, - _SYSIO_OFF_T, void *))f, - nino); - if (ioctx->ioctx_cc < 0) { - ioctx->ioctx_errno = -ioctx->ioctx_cc; - ioctx->ioctx_cc = -1; - return -1; - } - nino->ni_fpos += ioctx->ioctx_cc; - ioctx->ioctx_done = 1; - return 0; -} - -static ssize_t -yod_read_simple(void *buf, - size_t nbytes, - _SYSIO_OFF_T off, - struct yod_inode *nino) -{ - if (off != nino->ni_fpos) { - _SYSIO_OFF_T rtn; - - rtn = lseek_yod(nino->ni_fd, off, SEEK_SET); - if (rtn < 0) - return -1; - nino->ni_fpos = rtn; - } - return read_yod(nino->ni_fd, buf, nbytes); -} - -static int -yod_inop_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio(yod_read_simple, ioctx); -} - -static int -yod_inop_rename(struct pnode *old, struct pnode *new) -{ - int err; - char *opath, *npath; - - opath = _sysio_pb_path(old->p_base, '/'); - npath = _sysio_pb_path(new->p_base, '/'); - if (!(opath && npath)) { - err = -ENOMEM; - goto out; - } - - err = rename_yod(opath, npath); - -out: - if (opath) - free(opath); - if (npath) - free(npath); - - return err; -} - -static ssize_t -yod_write_simple(void *buf, - size_t nbytes, - _SYSIO_OFF_T off, - struct yod_inode *nino) -{ - - if (off != nino->ni_fpos) { - _SYSIO_OFF_T rtn; - - rtn = lseek_yod(nino->ni_fd, off, SEEK_SET); - if (rtn < 0) - return -1; - nino->ni_fpos = rtn; - } - return write_yod(nino->ni_fd, buf, nbytes); -} - -static int -yod_inop_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) -{ - - return doio(yod_write_simple, ioctx); -} - -static _SYSIO_OFF_T -yod_inop_pos(struct inode *ino, _SYSIO_OFF_T off) -{ - struct yod_inode *nino = I2NI(ino); - int err; - - err = lseek_yod(nino->ni_fd, off, SEEK_SET); - return err < 0 ? err : off; -} - -static int -yod_inop_iodone(struct ioctx *ioctxp __IS_UNUSED) -{ - - /* - * It's always done in this driver. It completed when posted. - */ - return 1; -} - -static int -yod_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn) -{ - struct yod_inode *nino = I2NI(ino); - long arg; - int err; - - if (nino->ni_fd < 0) - abort(); - - err = 0; - switch (cmd) { - case F_GETFD: - case F_GETFL: -#ifdef F_GETOWN - case F_GETOWN: -#endif - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd); - if (*rtn == -1) - err = -errno; - break; - case F_DUPFD: - case F_SETFD: - case F_SETFL: - case F_GETLK: - case F_SETLK: - case F_SETLKW: -#ifdef F_SETOWN - case F_SETOWN: -#endif - arg = va_arg(ap, long); - *rtn = syscall(SYS_fcntl, nino->ni_fd, cmd, arg); - if (*rtn == -1) - err = -errno; - break; - default: - *rtn = -1; - err = -EINVAL; - } - return err; -} - -static int -yod_inop_mknod(struct pnode *pno __IS_UNUSED, - mode_t mode __IS_UNUSED, - dev_t dev __IS_UNUSED) -{ - - return -ENOSYS; -} - -#ifdef _HAVE_STATVFS -static int -yod_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf) -{ - char *path; - int rc; - struct statfs fs; - - path = NULL; - if (!ino || I2NI(ino)->ni_fd < 0) { - path = _sysio_pb_path(pno->p_base, '/'); - if (!path) - return -ENOMEM; - } - - /* - * The syscall interface does not support SYS_fstatvfs. - * Should possibly return ENOSYS, but thought it - * better to use SYS_fstatfs and fill in as much of - * the statvfs structure as possible. This allows - * for more of a test of the sysio user interface. - */ - rc = - path - ? statfs_yod(path, &fs) - : fstatfs_yod(I2NI(ino)->ni_fd, &fs); - if (path) - free(path); - if (rc < 0) - return -errno; - - buf->f_bsize = fs.f_bsize; /* file system block size */ - buf->f_frsize = fs.f_bsize; /* file system fundamental block size */ - buf->f_blocks = fs.f_blocks; - buf->f_bfree = fs.f_bfree; - buf->f_bavail = fs.f_bavail; - buf->f_files = fs.f_files; /* Total number serial numbers */ - buf->f_ffree = fs.f_ffree; /* Number free serial numbers */ - buf->f_favail = fs.f_ffree; /* Number free ser num for non-privileged*/ - buf->f_fsid = fs.f_fsid.__val[1]; - buf->f_flag = 0; /* No equiv in statfs; maybe use type? */ - buf->f_namemax = fs.f_namelen; - return 0; -} -#endif - -static int -yod_inop_sync(struct inode *ino) -{ - - assert(I2NI(ino)->ni_fd >= 0); - - return fsync_yod(I2NI(ino)->ni_fd); -} - -static int -yod_inop_datasync(struct inode *ino) -{ - - assert(I2NI(ino)->ni_fd >= 0); - - return fsync_yod(I2NI(ino)->ni_fd); -} - -static int -yod_inop_ioctl(struct inode *ino __IS_UNUSED, - unsigned long int request __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - /* - * I'm lazy. Maybe implemented later. - */ - errno = ENOTTY; - return -1; -} - -static void -yod_inop_gone(struct inode *ino) -{ - struct yod_inode *nino = I2NI(ino); - - if (nino->ni_fd) - (void )close(nino->ni_fd); - free(ino->i_private); -} - -static void -yod_fsop_gone(struct filesys *fs __IS_UNUSED) -{ - - /* - * Do nothing. There is no private part maintained for the - * yod file interface. - */ -} diff --git a/libsysio/drivers/yod/fs_yod.h b/libsysio/drivers/yod/fs_yod.h deleted file mode 100644 index 174b82d..0000000 --- a/libsysio/drivers/yod/fs_yod.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Remote file system driver support. - */ - -extern int _sysio_yod_init(); diff --git a/libsysio/drivers/yod/module.mk b/libsysio/drivers/yod/module.mk deleted file mode 100644 index 1c2cc91..0000000 --- a/libsysio/drivers/yod/module.mk +++ /dev/null @@ -1,10 +0,0 @@ -if WITH_CPLANT_YOD -YOD_SRCS = drivers/yod/fs_yod.c -YOD_DRIVER_FLAGS = -DCPLANT_YOD -else -YOD_SRCS = -YOD_DRIVER_FLAGS = -endif - -# Bring yod files along in the distribution regardless -YOD_EXTRA = include/cplant-yod.h drivers/yod/fs_yod.h drivers/yod/module.mk diff --git a/libsysio/include/cplant-yod.h b/libsysio/include/cplant-yod.h deleted file mode 100644 index 8aa4b50..0000000 --- a/libsysio/include/cplant-yod.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * cplant yod I/O functions - */ -extern int chmod_yod(const char* path, mode_t); -extern int chown_yod(const char* path, uid_t, gid_t); -extern int stat_yod(const char *path, struct stat *sbuf); -extern int fstat_yod(int fd, struct stat *buf); -#ifdef _HAVE_STATVFS -extern int statfs_yod(const char *path, struct statfs *sbuf); -extern int fstatfs_yod(int fd, struct statfs *buf); -#endif -extern int mkdir_yod(const char *path, mode_t mode); -extern int rmdir_yod(const char *path); -extern int getdirentries_yod(int fd, char *buf, size_t nbytes, loff_t *basep); -extern int link_yod(const char *path1, const char *path2); -extern int unlink_yod(const char *path); -extern int symlink_yod(const char *path1, const char *path2 ); -extern int rename_yod( const char *path1, const char *path2 ); -extern int open_yod(const char *fname, int flags, mode_t mode); -extern int close_yod(int); -extern ssize_t write_yod(int fd, const void *buff, size_t nbytes); -extern ssize_t read_yod(int fd, void *buff, size_t nbytes); -extern int fsync_yod(int fd); -extern int truncate_yod(const char *path, off_t length); -extern int ftruncate_yod(int fd, long length); -extern off_t lseek_yod(int fd, off_t offset, int whence); diff --git a/libsysio/include/dev.h b/libsysio/include/dev.h deleted file mode 100644 index a62f581..0000000 --- a/libsysio/include/dev.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Device support. - */ - -/* - * Make a device number, composed of major and minor parts. We *assume* that - * the system version of a dev_t is 16 bits or more. - */ -#define SYSIO_MKDEV(major, minor) \ - ((((major) & 0xff) << 8) | ((minor) & 0xff)) - -/* - * Return major unit given dev number. - */ -#define SYSIO_MAJOR_DEV(dev) \ - (((dev) >> 8) & 0xff) - -/* - * Return minor unit given dev number. - */ -#define SYSIO_MINOR_DEV(dev) \ - ((dev) & 0xff) - -extern const struct inode_ops _sysio_nodev_ops; - -#define _sysio_nodev_inop_lookup \ - (int (*)(struct pnode *, \ - struct inode **, \ - struct intent *, \ - const char *))_sysio_do_illop -#define _sysio_nodev_inop_getattr \ - (int (*)(struct pnode *, \ - struct inode *, \ - struct intnl_stat *))_sysio_do_ebadf -#define _sysio_nodev_inop_setattr \ - (int (*)(struct pnode *, \ - struct inode *, \ - unsigned , \ - struct intnl_stat *))_sysio_do_ebadf -#define _sysio_nodev_getdirentries \ - (ssize_t (*)(struct inode *, \ - char *, \ - size_t , \ - _SYSIO_OFF_T *))_sysio_do_illop -#define _sysio_nodev_inop_mkdir \ - (int (*)(struct pnode *, \ - mode_t))_sysio_do_illop -#define _sysio_nodev_inop_rmdir \ - (int (*)(struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_symlink \ - (int (*)(struct pnode *, \ - const char *))_sysio_do_illop -#define _sysio_nodev_inop_readlink \ - (int (*)(struct pnode *, \ - char *, \ - size_t))_sysio_do_illop -#define _sysio_nodev_inop_open \ - (int (*)(struct pnode *, \ - int, \ - mode_t))_sysio_do_enodev -#define _sysio_nodev_inop_close \ - (int (*)(struct inode *))_sysio_do_ebadf -#define _sysio_nodev_inop_link \ - (int (*)(struct pnode *, struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_unlink \ - (int (*)(struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_rename \ - (int (*)(struct pnode *, struct pnode *))_sysio_do_illop -#define _sysio_nodev_inop_read \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_ebadf -#define _sysio_nodev_inop_write \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_ebadf -#define _sysio_nodev_inop_pos \ - (_SYSIO_OFF_T (*)(struct inode *, _SYSIO_OFF_T))_sysio_do_ebadf -#define _sysio_nodev_inop_iodone \ - (int (*)(struct ioctx *))_sysio_do_einval -#define _sysio_nodev_inop_fcntl \ - (int (*)(struct inode *, \ - int, \ - va_list, \ - int *))_sysio_do_ebadf -#define _sysio_nodev_inop_sync \ - (int (*)(struct inode *))_sysio_do_ebadf -#define _sysio_nodev_inop_datasync \ - (int (*)(struct inode *))_sysio_do_ebadf -#define _sysio_nodev_inop_ioctl \ - (int (*)(struct inode *, \ - unsigned long int, \ - va_list))_sysio_do_ebadf -#define _sysio_nodev_inop_mknod \ - (int (*)(struct pnode *, \ - mode_t, \ - dev_t))_sysio_do_illop -#ifdef _HAVE_STATVFS -#define _sysio_nodev_inop_statvfs \ - (int (*)(struct pnode *, \ - struct inode *, \ - struct intnl_statvfs *))_sysio_do_illop -#endif -#define _sysio_nodev_inop_gone \ - (void (*)(struct inode *ino))_sysio_do_noop - -extern int _sysio_dev_init(void); -extern dev_t _sysio_dev_alloc(void); -extern struct inode_ops *_sysio_dev_lookup(mode_t mode, dev_t dev); -extern int _sysio_char_dev_register(int major, - const char *name, - struct inode_ops *ops); diff --git a/libsysio/include/file.h b/libsysio/include/file.h deleted file mode 100644 index 82317d5..0000000 --- a/libsysio/include/file.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Open file support. - */ - -/* - * A file record is maintained for each open file in the system. It holds - * all the info necessary to track the context and parameters for the - * operations that may be performed. - */ -struct file { - struct inode *f_ino; /* path node */ - _SYSIO_OFF_T f_pos; /* current stream pos */ - unsigned f_ref; /* ref count */ - int f_flags; /* open/fcntl flags */ -}; - -/* - * Reference a file record. - */ -#define F_REF(fil) \ - do { \ - (fil)->f_ref++; \ - assert((fil)->f_ref); \ - I_REF((fil)->f_ino); \ - } while (0) - -/* - * Release reference to a file record. - */ -#define F_RELE(fil) \ - do { \ - struct inode *ino; \ - \ - assert((fil)->f_ref); \ - (fil)->f_ref--; \ - ino = (fil)->f_ino; \ - if (!(fil)->f_ref) \ - _sysio_fgone(fil); \ - I_RELE(ino); \ - } while (0) - -/* - * Init file record. - * - * NB: Don't forget to take a reference to the inode too! - */ -#define _SYSIO_FINIT(fil, ino, flags) \ - do { \ - (fil)->f_ino = (ino); \ - (fil)->f_pos = 0; \ - (fil)->f_ref = 1; \ - (fil)->f_flags = (flags); \ - } while (0) - -struct ioctx; - -extern struct file *_sysio_fnew(struct inode *ino, int flags); -extern void _sysio_fgone(struct file *fil); -extern void _sysio_fcompletio(struct ioctx *ioctx, struct file *fil); -extern int _sysio_fd_close(int fd); -extern struct file *_sysio_fd_find(int fd); -extern int _sysio_fd_set(struct file *fil, int fd, int force); -extern int _sysio_fd_dup(int oldfd, int newfd, int force); -extern int _sysio_fd_close_all(void); -#if ZERO_SUM_MEMORY -extern void _sysio_fd_shutdown(void); -#endif diff --git a/libsysio/include/fs.h b/libsysio/include/fs.h deleted file mode 100644 index 8c7e782..0000000 --- a/libsysio/include/fs.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * File system or volume support. - */ - -struct filesys; - -struct pnode; -struct mount; - -/* - * File system switch operations. - */ -struct fssw_ops { - int (*fsswop_mount)(const char *source, - unsigned flags, - const void *data, - struct pnode *tocover, - struct mount **mntp); -}; - -/* - * File system switch entry record. - * - * Each available file system or volume access driver is represented by - * one of these switch entries in the switch. - */ -struct fsswent { - const char *fssw_name; /* entry name */ - LIST_ENTRY(fsswent) fssw_link; /* link to next */ - struct fssw_ops fssw_ops; /* operations */ -}; - -/* - * Init file system switch entry record. - */ -#define FSSWENT_INIT(fsswent, name, ops) \ - do { \ - (fsswent)->fssw_name = (name); \ - (fsswent)->fssw_ops = (ops); \ - } while (0) - -struct inode; - -/* - * File system operations. - */ -struct filesys_ops { - void (*fsop_gone)(struct filesys *); -}; - -/* - * Define the desired size of the file system record's inode table. This should - * probably be something fancy that tries to use up a system page, or the - * like. I'm not feeling adventurous right now though. It is prime though. - * That should help out the hash. - */ -#ifndef FS_ITBLSIZ -#define FS_ITBLSIZ 503 -#endif - -/* - * Inode list head record. - */ -LIST_HEAD(itable_entry, inode); - -/* - * A filesys record is maintained for each active file system or volume. - */ -struct filesys { - dev_t fs_dev; /* device ID */ - unsigned fs_ref; /* soft ref count */ - unsigned fs_flags; /* flags (see below) */ - struct filesys_ops fs_ops; /* operations */ - void *fs_private; /* driver data */ - struct itable_entry fs_itbl[FS_ITBLSIZ]; /* inodes hash */ - unsigned long fs_id; /* ID */ - size_t fs_bsize; /* block size */ -}; - -#define FS_F_RO 0x01 /* read-only */ - -/* - * Init file system record. - */ -#define FS_INIT(fs, flags, ops, private) \ - do { \ - size_t __i; \ - struct itable_entry *__head; \ - \ - (fs)->fs_ref = 1; \ - (fs)->fs_flags = (flags); \ - (fs)->fs_ops = *(ops); \ - (fs)->fs_private = (private); \ - __i = FS_ITBLSIZ; \ - __head = (fs)->fs_itbl; \ - do { \ - LIST_INIT(__head); \ - __head++; \ - } while (--__i); \ - } while (0) - -/* - * Reference file system record. - */ -#define FS_REF(fs) \ - do { \ - ++(fs)->fs_ref; \ - assert((fs)->fs_ref); \ - } while (0) - -/* - * Release reference to file system record. - */ -#define FS_RELE(fs) \ - do { \ - assert((fs)->fs_ref); \ - if (!--(fs)->fs_ref) \ - _sysio_fs_gone(fs); \ - } while (0) - -extern struct fsswent *_sysio_fssw_lookup(const char *name); -extern int _sysio_fssw_register(const char *name, struct fssw_ops *ops); -extern struct filesys * _sysio_fs_new(struct filesys_ops *ops, - unsigned mask, - void *private); -extern void _sysio_fs_gone(struct filesys *fs); -#if ZERO_SUM_MEMORY -extern void _sysio_fssw_shutdown(void); -#endif diff --git a/libsysio/include/inode.h b/libsysio/include/inode.h deleted file mode 100644 index 9431734..0000000 --- a/libsysio/include/inode.h +++ /dev/null @@ -1,516 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#if defined(AUTOMOUNT_FILE_NAME) && !defined(MAX_MOUNT_DEPTH) -/* - * Maximum number of automounts to attempt in path traversal. - */ -#define MAX_MOUNT_DEPTH 64 -#endif - -/* - * Each i-node is uniquely identified by a file identifier, supplied by - * the relevant file system driver. The i-node number returned in the getattrs - * call is not always enough. - */ -struct file_identifier { - void *fid_data; - size_t fid_len; -}; - -struct pnode; -struct inode; -struct intent; -struct intnl_dirent; -struct intnl_stat; -#ifdef _HAVE_STATVFS -struct intnl_statvfs; -#endif -struct io_arguments; -struct ioctx; - -/* - * Operations on i-nodes. - * - * Should this be split up into file and name space operations? - */ -struct inode_ops { - int (*inop_lookup)(struct pnode *pno, - struct inode **inop, - struct intent *intnt, - const char *path); - int (*inop_getattr)(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); - int (*inop_setattr)(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); - ssize_t (*inop_getdirentries)(struct inode *ino, - char *buf, - size_t nbytes, - _SYSIO_OFF_T *basep); - int (*inop_mkdir)(struct pnode *pno, mode_t mode); - int (*inop_rmdir)(struct pnode *pno); - int (*inop_symlink)(struct pnode *pno, const char *data); - int (*inop_readlink)(struct pnode *pno, char *buf, size_t bufsiz); - int (*inop_open)(struct pnode *pno, int flags, mode_t mode); - int (*inop_close)(struct inode *ino); - int (*inop_link)(struct pnode *old, struct pnode *new); - int (*inop_unlink)(struct pnode *pno); - int (*inop_rename)(struct pnode *old, struct pnode *new); - int (*inop_read)(struct inode *ino, struct ioctx *ioctx); - int (*inop_write)(struct inode *ino, struct ioctx *ioctx); - _SYSIO_OFF_T (*inop_pos)(struct inode *ino, _SYSIO_OFF_T off); - int (*inop_iodone)(struct ioctx *iocp); - int (*inop_fcntl)(struct inode *ino, int cmd, va_list ap, int *rtn); - int (*inop_sync)(struct inode *ino); - int (*inop_datasync)(struct inode *ino); - int (*inop_ioctl)(struct inode *ino, unsigned long int request, va_list ap); - int (*inop_mknod)(struct pnode *pno, mode_t mode, dev_t dev); -#ifdef _HAVE_STATVFS - int (*inop_statvfs)(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); -#endif - void (*inop_gone)(struct inode *ino); -}; - -/* - * Values for the mask to inop_setattr. - */ -#define SETATTR_MODE 0x01 -#define SETATTR_MTIME 0x02 -#define SETATTR_ATIME 0x04 -#define SETATTR_UID 0x08 -#define SETATTR_GID 0x10 -#define SETATTR_LEN 0x20 - -/* - * An i-node record is maintained for each file object in the system. - */ -struct inode { - LIST_ENTRY(inode) i_link; /* FS i-nodes link */ - unsigned - i_immune : 1, /* immune from GC */ - i_zombie : 1; /* stale inode */ - unsigned i_ref; /* soft ref counter */ - mode_t i_mode; /* mode (see stat.h) */ - dev_t i_rdev; /* dev (if device) */ - struct inode_ops i_ops; /* operations */ - struct filesys *i_fs; /* file system ptr */ - struct file_identifier *i_fid; /* file ident */ - void *i_private; /* driver data */ - TAILQ_ENTRY(inode) i_nodes; /* all i-nodes link */ -}; - -/* - * Init an i-node record. - */ -#define I_INIT(ino, fs, mode, rdev, ops, fid, immunity, private) \ - do { \ - (ino)->i_immune = (immunity) ? 1 : 0; \ - (ino)->i_zombie = 0; \ - (ino)->i_ref = 0; \ - (ino)->i_mode = (mode); \ - (ino)->i_rdev = (rdev); \ - (ino)->i_ops = *(ops); \ - (ino)->i_fs = (fs); \ - (ino)->i_fid = (fid); \ - (ino)->i_private = (private); \ - } while (0) - -/* - * Take soft reference to i-node. - */ -#define I_REF(ino) \ - do { \ - TAILQ_REMOVE(&_sysio_inodes, (ino), i_nodes); \ - TAILQ_INSERT_TAIL(&_sysio_inodes, (ino), i_nodes); \ - (ino)->i_ref++; \ - assert((ino)->i_ref); \ - } while (0) - -/* - * Release soft reference to i-node. - */ -#define I_RELE(ino) \ - do { \ - assert((ino)->i_ref); \ - if (!--(ino)->i_ref && (ino)->i_zombie) \ - _sysio_i_gone(ino); \ - } while (0) - -/* - * Attempt to kill an inode. - */ -#define I_GONE(ino) \ - do { \ - _sysio_i_undead(ino); \ - I_RELE(ino); \ - } while (0) - -/* - * The "quick string" record (inspired by the structure of the same name - * from Linux) is used to pass a string without delimiters as well as useful - * information about the string. - */ -struct qstr { - const char *name; - size_t len; - unsigned hashval; -}; - -/* - * A path node is an entry in a directory. It may have many aliases, one - * for each name space in which it occurs. This record holds the - * common information. - */ -struct pnode_base { - struct qstr pb_name; /* entry name */ - struct inode *pb_ino; /* inode */ - LIST_HEAD(, pnode_base) pb_children; /* children if a dir */ - LIST_ENTRY(pnode_base) pb_sibs; /* links to siblings */ - LIST_ENTRY(pnode_base) pb_names; /* near names links */ - LIST_HEAD(, pnode) pb_aliases; /* aliases */ - struct pnode_base *pb_parent; /* parent */ -}; - -/* - * Since a file system may be multiply mounted, in different parts of the local - * tree, a file system object may appear in different places. We handle that - * with aliases. There is one pnode for every alias the system is tracking. - * - * Name space traversal depends heavily on the interpretation of many - * of the fields in this structure. For that reason a detailed discussion - * of the various fields is given. - * - * The reference field records soft references to the record. For instance, - * it tracks file and directory opens. It does not track sibling references, - * though, as those are hard references and can be found by examining the - * aliases list in the base part of the node. - * - * The parent value points to the parent directory for this entry, in the - * *system* name space -- Not the mounted volumes. If you want to examine - * the moutned volume name space, use the base record. - * - * The base value points to the base path node information. It is info common - * to all of the aliases. - * - * The mount value points to the mount record for the rooted name space in - * which the alias is found. Notably, if a node is the root of a sub-tree then - * the mount record, among other things, indicates another node - * (in another sub-tree) that is covered by this one. - * - * Another sub-tree, mounted on this node, is indicated by a non-null cover. - * The pnode pointed to, then, is the root of the mounted sub-tree. - * - * The links list entry holds pointers to other aliases for the base path - * node entry. - * - * The nodes link is bookkeeping. - */ -struct pnode { - unsigned p_ref; /* soft ref count */ - struct pnode *p_parent; /* parent */ - struct pnode_base *p_base; /* base part */ - struct mount *p_mount; /* mount info */ - struct pnode *p_cover; /* covering pnode */ - LIST_ENTRY(pnode) p_links; /* other aliases */ - TAILQ_ENTRY(pnode) p_nodes; /* all nodes links */ -}; - -/* - * Reference path-tree node. - */ -#define P_REF(pno) \ - do { \ - TAILQ_REMOVE(&_sysio_pnodes, (pno), p_nodes); \ - TAILQ_INSERT_TAIL(&_sysio_pnodes, (pno), p_nodes); \ - (pno)->p_ref++; \ - assert((pno)->p_ref); \ - } while (0) - -/* - * Release reference to path-tree node. - */ -#define P_RELE(pno) \ - do { \ - assert((pno)->p_ref); \ - --(pno)->p_ref; \ - } while (0) - -/* - * An intent record allows callers of namei and lookup to pass some information - * about what they want to accomplish in the end. - */ -struct intent { - unsigned int_opmask; - void *int_arg1; - void *int_arg2; -}; - -/* - * Intent operations. - */ -#define INT_GETATTR 0x01 /* get attrs */ -#define INT_SETATTR 0x02 /* set attrs */ -#define INT_UPDPARENT 0x04 /* insert/delete */ -#define INT_OPEN 0x08 /* open */ -#define INT_CREAT (INT_UPDPARENT|0x10) /* insert */ -#define INT_READLINK 0x12 /* readlink */ - -#define INTENT_INIT(intnt, mask, arg1, arg2) \ - do { \ - (intnt)->int_opmask = (mask); \ - (intnt)->int_arg1 = (arg1); \ - (intnt)->int_arg2 = (arg2); \ - } while (0) - -/* - * Bundled up arguments to _sysio_path_walk. - */ -struct nameidata { - unsigned nd_flags; /* flags (see below) */ - const char *nd_path; /* path arg */ - struct pnode *nd_pno; /* returned pnode */ - struct pnode *nd_root; /* system/user root */ - struct intent *nd_intent; /* intent (NULL ok) */ - unsigned nd_slicnt; /* symlink indirects */ -#ifdef AUTOMOUNT_FILE_NAME - unsigned nd_amcnt; /* automounts */ -#endif -}; - -/* - * Values for nameidata flags field. - */ -#define ND_NOFOLLOW 0x01 /* no follow symlinks */ -#define ND_NEGOK 0x02 /* last missing is ok */ - -#ifdef AUTOMOUNT_FILE_NAME -#define _ND_INIT_AUTOMOUNT(nd) ((nd)->nd_amcnt = 0) -#else -#define _ND_INIT_AUTOMOUNT(nd) -#endif - -#define _ND_INIT_OTHERS(nd) \ - _ND_INIT_AUTOMOUNT(nd) - -/* - * Init nameidata record. - */ -#define ND_INIT(nd, flags, path, root, intnt) \ - do { \ - (nd)->nd_flags = (flags); \ - (nd)->nd_path = (path); \ - (nd)->nd_pno = NULL; \ - (nd)->nd_root = (root); \ - (nd)->nd_intent = (intnt); \ - (nd)->nd_slicnt = 0; \ - _ND_INIT_OTHERS(nd); \ - } while (0) - -/* - * IO completion callback record. - */ -struct ioctx_callback { - TAILQ_ENTRY(ioctx_callback) iocb_next; /* list link */ - void (*iocb_f)(struct ioctx *, void *); /* cb func */ - void *iocb_data; /* cb data */ -}; - -/* - * All IO internally is done with an asynchronous mechanism. This record - * holds the completion information. It's too big :-( - */ -struct ioctx { - LIST_ENTRY(ioctx) ioctx_link; /* AIO list link */ - unsigned - ioctx_fast : 1, /* from stack space */ - ioctx_done : 1, /* transfer complete */ - ioctx_write : 1; /* op is a write */ - struct inode *ioctx_ino; /* i-node */ - const struct iovec *ioctx_iov; /* scatter/gather vec */ - size_t ioctx_iovlen; /* iovec length */ - const struct intnl_xtvec *ioctx_xtv; /* extents */ - size_t ioctx_xtvlen; /* xtv length */ - ssize_t ioctx_cc; /* rtn char count */ - int ioctx_errno; /* error number */ - TAILQ_HEAD(, ioctx_callback) ioctx_cbq; /* callback queue */ - void *ioctx_private; /* driver data */ -}; - -/* - * Init IO context record. - */ -#define IOCTX_INIT(ioctx, fast, wr, ino, iov, iovlen, xtv, xtvlen) \ - do { \ - (ioctx)->ioctx_fast = (fast); \ - (ioctx)->ioctx_done = 0; \ - (ioctx)->ioctx_write = (wr) ? 1 : 0; \ - (ioctx)->ioctx_ino = (ino); \ - (ioctx)->ioctx_iov = (iov); \ - (ioctx)->ioctx_iovlen = (iovlen); \ - (ioctx)->ioctx_xtv = (xtv); \ - (ioctx)->ioctx_xtvlen = (xtvlen); \ - (ioctx)->ioctx_cc = 0; \ - (ioctx)->ioctx_errno = 0; \ - TAILQ_INIT(&(ioctx)->ioctx_cbq); \ - (ioctx)->ioctx_private = NULL; \ - } while (0) - -/* - * Return whether a pnode/inode is on a read-only mount or file system. - */ -#define IS_RDONLY(pno, ino) \ - ((((struct pnode *)(pno)) && \ - ((((struct pnode *)(pno))->p_mount->mnt_flags & MOUNT_F_RO) || \ - (((struct pnode *)(pno))->p_base->pb_ino && \ - (((struct pnode *)(pno))->p_base->pb_ino->i_fs->fs_flags & \ - FS_F_RO)))) || \ - (((struct inode *)(ino)) && \ - (((struct inode *)(ino))->i_fs->fs_flags & FS_F_RO))) - -extern struct pnode *_sysio_root; - -extern TAILQ_HEAD(inodes_head, inode) _sysio_inodes; -extern TAILQ_HEAD(pnodes_head, pnode) _sysio_pnodes; - -extern int _sysio_i_init(void); -#if ZERO_SUM_MEMORY -extern void _sysio_i_shutdown(void); -#endif -extern struct inode *_sysio_i_new(struct filesys *fs, - struct file_identifier *fid, - mode_t type, - dev_t rdev, - unsigned immunity, - struct inode_ops *ops, - void *private); -extern struct inode *_sysio_i_find(struct filesys *fs, - struct file_identifier *fid); -extern void _sysio_i_gone(struct inode *ino); -extern void _sysio_i_undead(struct inode *ino); -extern int _sysio_p_find_alias(struct pnode *parent, - struct qstr *name, - struct pnode **pnop); -extern int _sysio_p_validate(struct pnode *pno, - struct intent *intnt, - const char *path); -extern struct pnode_base *_sysio_pb_new(struct qstr *name, - struct pnode_base *parent, - struct inode *ino); -extern void _sysio_pb_gone(struct pnode_base *pb); -extern struct pnode *_sysio_p_new_alias(struct pnode *parent, - struct pnode_base *pb, - struct mount *mnt); -extern void _sysio_p_gone(struct pnode *pno); -extern size_t _sysio_p_prune(struct pnode *root); -extern int _sysio_p_kill_all(struct pnode *root); -extern char *_sysio_pb_path(struct pnode_base *pb, char separator); -extern int _sysio_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf); -extern void _sysio_do_noop(void); -extern void _sysio_do_illop(void); -extern int _sysio_do_ebadf(void); -extern int _sysio_do_einval(void); -extern int _sysio_do_enoent(void); -extern int _sysio_do_enodev(void); -extern int _sysio_do_espipe(void); -extern int _sysio_do_eisdir(void); -extern int _sysio_do_enosys(void); -extern int _sysio_path_walk(struct pnode *parent, struct nameidata *nd); -#ifdef AUTOMOUNT_FILE_NAME -extern void _sysio_next_component(const char *path, struct qstr *name); -#endif -extern int _sysio_namei(struct pnode *pno, - const char *path, - unsigned flags, - struct intent *intnt, - struct pnode **pnop); -extern int _sysio_p_chdir(struct pnode *pno); -extern int _sysio_ioctx_init(void); -extern void _sysio_ioctx_enter(struct ioctx *ioctx); -extern struct ioctx *_sysio_ioctx_new(struct inode *ino, - int wr, - const struct iovec *iov, - size_t iovlen, - const struct intnl_xtvec *xtv, - size_t xtvlen); -extern int _sysio_ioctx_cb(struct ioctx *ioctx, - void (*f)(struct ioctx *, void *), - void *data); -extern void _sysio_ioctx_cb_free(struct ioctx_callback *cb); -extern struct ioctx *_sysio_ioctx_find(void *id); -extern ssize_t _sysio_ioctx_wait(struct ioctx *ioctx); -extern void _sysio_ioctx_complete(struct ioctx *ioctx); -extern ssize_t _sysio_validx(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - _SYSIO_OFF_T limit); -extern ssize_t _sysio_enumerate_extents(const struct intnl_xtvec *xtv, - size_t xtvlen, - const struct iovec *iov, - size_t iovlen, - ssize_t (*f)(const struct iovec *, - int, - _SYSIO_OFF_T, - ssize_t, - void *), - void *arg); -extern ssize_t _sysio_enumerate_iovec(const struct iovec *iov, - size_t count, - _SYSIO_OFF_T off, - ssize_t limit, - ssize_t (*f)(void *, - size_t, - _SYSIO_OFF_T, - void *), - void *arg); -extern ssize_t _sysio_doio(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), - void *arg); -extern int _sysio_open(struct pnode *pno, int flags, mode_t mode); diff --git a/libsysio/include/module.mk b/libsysio/include/module.mk deleted file mode 100644 index ce1c427..0000000 --- a/libsysio/include/module.mk +++ /dev/null @@ -1,4 +0,0 @@ -INCLUDE_EXTRA = include/dev.h include/file.h include/fs.h \ - include/inode.h include/mount.h include/sysio.h \ - include/sysio-symbols.h include/cplant-yod.h \ - include/module.mk include/xtio.h diff --git a/libsysio/include/mount.h b/libsysio/include/mount.h deleted file mode 100644 index 24f631d..0000000 --- a/libsysio/include/mount.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Mount support. - */ - -struct filesys; -struct pnode; - -/* - * Each file system may be mounted multiple times and in various places - * in the name space. The mount record maintains the binding information - * between the system name space and the file system's. - */ -struct mount { - struct filesys *mnt_fs; /* file system */ - unsigned mnt_flags; /* flags (see below) */ - struct pnode *mnt_root; /* fs sub-tree root */ - struct pnode *mnt_covers; /* covered pnode */ - LIST_ENTRY(mount) mnt_link; /* link to next */ -}; - -/* - * Mount flags definitions. - */ -#define MOUNT_F_RO 0x01 /* read-only */ -#ifdef AUTOMOUNT_FILE_NAME -#define MOUNT_F_AUTO 0x02 /* automount enabled */ -#endif - -#ifdef AUTOMOUNT_FILE_NAME -extern struct qstr _sysio_mount_file_name; -#endif - -struct pnode_base; - -extern int _sysio_mount_init(void); -extern int _sysio_do_mount(struct filesys *fs, - struct pnode_base *rootpb, - unsigned flags, - struct pnode *tocover, - struct mount **mntp); -extern int _sysio_do_unmount(struct mount *fs); -extern int _sysio_mount_root(const char *source, - const char *type, - unsigned flags, - const void *data); -extern int _sysio_mount(struct pnode *cwd, - const char *source, - const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data); -extern int _sysio_unmount_all(void); -#ifdef AUTOMOUNT_FILE_NAME -extern int _sysio_automount(struct pnode *mntpno); -#endif diff --git a/libsysio/include/namespace.h b/libsysio/include/namespace.h deleted file mode 100644 index 23c1f78..0000000 --- a/libsysio/include/namespace.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Boot time namespace assembly function - */ -extern int run_cmds(char *buf); - diff --git a/libsysio/include/sysio-symbols.h b/libsysio/include/sysio-symbols.h deleted file mode 100644 index 4b7cf56..0000000 --- a/libsysio/include/sysio-symbols.h +++ /dev/null @@ -1,26 +0,0 @@ -#if defined(HAVE_ASM_WEAK_DIRECTIVE) || defined(HAVE_ASM_WEAKEXT_DIRECTIVE) -#define HAVE_WEAK_SYMBOLS -#endif - -#define STRINGOF(x) #x - -/* - * Define alias, asym, as a strong alias for symbol, sym. - */ -#define sysio_sym_strong_alias(sym, asym) \ - extern __typeof(sym) asym __attribute__((alias(STRINGOF(sym)))); - -#ifdef HAVE_WEAK_SYMBOLS - -/* - * Define alias, asym, as a strong alias for symbol, sym. - */ -#define sysio_sym_weak_alias(sym, asym) \ - extern __typeof(sym) asym __attribute__((weak, alias(STRINGOF(sym)))); -#else /* !defined(HAVE_ASM_WEAK_DIRECTIVE) */ - -/* - * Weak symbols not supported. Make it a strong alias then. - */ -#define sysio_sym_weak_alias(sym, asym) sysio_sym_strong_alias(sym, asym) -#endif diff --git a/libsysio/include/sysio.h b/libsysio/include/sysio.h deleted file mode 100644 index bd31365..0000000 --- a/libsysio/include/sysio.h +++ /dev/null @@ -1,338 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * System IO common information. - */ - -#include -#include - -#if !defined(__IS_UNUSED) && defined(__GNUC__) -#define __IS_UNUSED __attribute__ ((unused)) -#else -#define __IS_UNUSED -#endif - -#ifndef PATH_SEPARATOR -/* - * Path separator. - */ -#define PATH_SEPARATOR '/' -#endif - -#ifndef MAX_SYMLINK -/* - * Max recursion depth allowed when resoving symbolic links. - */ -#define MAX_SYMLINK 250 -#endif - -#ifndef _LARGEFILE64_SOURCE -/* - * Not glibc I guess. Define this ourselves. - */ -#define _LARGEFILE64_SOURCE 0 -#endif - -/* - * Define internal file-offset type and it's maximum value. - */ -#if _LARGEFILE64_SOURCE -#define _SYSIO_OFF_T off64_t -#ifdef LLONG_MAX -#define _SYSIO_OFF_T_MAX (LLONG_MAX) -#else -/* - * Don't have LLONG_MAX before C99. We'll need to define it ourselves. - */ -#define _SYSIO_OFF_T_MAX (9223372036854775807LL) -#endif -#else -#define _SYSIO_OFF_T off_t -#define _SYSIO_OFF_T_MAX LONG_MAX -#endif - -/* - * Internally, all directory entries are carried in the 64-bit capable - * structure. - */ -#if _LARGEFILE64_SOURCE -#define intnl_dirent dirent64 -#else -#define intnl_dirent dirent -#endif -struct dirent; - -/* - * Internally, all file status is carried in the 64-bit capable - * structure. - */ -#if _LARGEFILE64_SOURCE -#define intnl_stat stat64 -#else -#define intnl_stat stat -#endif -struct stat; - -#ifdef _HAVE_STATVFS -#if _LARGEFILE64_SOURCE -#define intnl_statvfs statvfs64 -#else -#define intnl_statvfs statvfs -#define INTNL_STATVFS_IS_NATURAL 1 -#endif -struct statvfs; -struct intnl_statvfs; -#endif - -/* - * Internally, all file status is carried in the 64-bit capable - * structure. - */ -#if _LARGEFILE64_SOURCE -#define intnl_xtvec xtvec64 -#else -#define intnl_xtvec xtvec -#endif -struct intnl_xtvec; - -struct iovec; - -struct utimbuf; - -struct intnl_stat; - -struct pnode; - -extern struct pnode *_sysio_cwd; - -extern mode_t _sysio_umask; - -extern int _sysio_init(void); -extern void _sysio_shutdown(void); -extern int _sysio_boot(const char *buf); - -/* - * SYSIO name label macros - */ -#define XPREPEND(p,x) p ## x -#define PREPEND(p,x) XPREPEND(p,x) -#define SYSIO_LABEL_NAMES 0 -#if SYSIO_LABEL_NAMES -#define SYSIO_INTERFACE_NAME(x) PREPEND(sysio__, x) -#else -#define SYSIO_INTERFACE_NAME(x) x -#endif - -/* - * The following should be defined by the system includes, and probably are, - * but it's not illegal to have multiple externs, so long as they are the - * same. It helps when building the library in a standalone fashion. - */ -extern int SYSIO_INTERFACE_NAME(access)(const char *path, int amode); -extern int SYSIO_INTERFACE_NAME(chdir)(const char *path); -extern int SYSIO_INTERFACE_NAME(chmod)(const char *path, mode_t mode); -extern int SYSIO_INTERFACE_NAME(fchmod)(int fd, mode_t mode); -extern int SYSIO_INTERFACE_NAME(chown)(const char *path, uid_t owner, - gid_t group); -extern int SYSIO_INTERFACE_NAME(fchown)(int fd, uid_t owner, gid_t group); -extern int SYSIO_INTERFACE_NAME(close)(int d); -extern int SYSIO_INTERFACE_NAME(dup)(int oldfd); -extern int SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd); -extern int SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...); -extern int SYSIO_INTERFACE_NAME(fstat)(int fd, struct stat *buf); -extern int SYSIO_INTERFACE_NAME(fsync)(int fd); -extern char *SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size); -extern off_t SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence); -#if _LARGEFILE64_SOURCE -extern off64_t SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, - int whence); -#endif -extern int SYSIO_INTERFACE_NAME(lstat)(const char *path, struct stat *buf); -#ifdef BSD -extern int SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, int nbytes , - long *basep); -#else -extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, - size_t nbytes, off_t *basep); -#if _LARGEFILE64_SOURCE -extern ssize_t SYSIO_INTERFACE_NAME(getdirentries64)(int fd, - char *buf, - size_t nbytes, - off64_t *basep); -#endif -#endif -extern int SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode); -extern int SYSIO_INTERFACE_NAME(open)(const char *path, int flag, ...); -#if _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(open64)(const char *path, int flag, ...); -#endif -extern int SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode); -#if _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(creat64)(const char *path, mode_t mode); -#endif -extern int SYSIO_INTERFACE_NAME(stat)(const char *path, struct stat *buf); -#if _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(stat64)(const char *path, struct stat64 *buf); -#endif -#ifdef _HAVE_STATVFS -extern int SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf); -#if _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(statvfs64)(const char *path, - struct statvfs64 *buf); -#endif -extern int SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf); -#if _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf); -#endif -#endif -extern int SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length); -#if _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(truncate64)(const char *path, off64_t length); -#endif -extern int SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length); -#if _LARGEFILE64_SOURCE -extern int SYSIO_INTERFACE_NAME(ftruncate64)(int fd, off64_t length); -#endif -extern int SYSIO_INTERFACE_NAME(rmdir)(const char *path); -extern int SYSIO_INTERFACE_NAME(symlink)(const char *path1, const char *path2); -extern int SYSIO_INTERFACE_NAME(readlink)(const char *path, - char *buf, - size_t bufsiz); -extern int SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath); -extern int SYSIO_INTERFACE_NAME(unlink)(const char *path); -extern int SYSIO_INTERFACE_NAME(rename)(const char *oldpath, - const char *newpath); -extern int SYSIO_INTERFACE_NAME(fdatasync)(int fd); -extern int SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...); -extern mode_t SYSIO_INTERFACE_NAME(umask)(mode_t mask); -extern int SYSIO_INTERFACE_NAME(mknod)(const char *path, - mode_t mode, dev_t dev); -extern int SYSIO_INTERFACE_NAME(utime)(const char *path, - const struct utimbuf *buf); -extern int SYSIO_INTERFACE_NAME(mount)(const char *source, const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data); -extern int SYSIO_INTERFACE_NAME(umount)(const char *target); - -/* for debugging */ -#if 0 -#define ASSERT(cond) \ - if (!(cond)) { \ - printf("ASSERTION(" #cond ") failed: " __FILE__ ":" \ - __FUNCTION__ ":%d\n", __LINE__); \ - abort(); \ - } - -#define ERROR(fmt, a...) \ - do { \ - printf("ERROR(" __FILE__ ":%d):" fmt, __LINE__, ##a); \ - while(0) - -#else -#define ERROR(fmt) do{}while(0) -#define ASSERT do{}while(0) -#endif - -/* - * SYSIO interface frame macros - * - * + DISPLAY_BLOCK; Allocates storage on the stack for use by the set of - * macros. - * + ENTER; Performs entry point work - * + RETURN; Returns a value and performs exit point work - * - * NB: For RETURN, the arguments are the return value and value for errno. - * If the value for errno is non-zero then that value, *negated*, is set - * into errno. - */ -#define SYSIO_INTERFACE_DISPLAY_BLOCK \ - int _saved_errno; -#define SYSIO_INTERFACE_ENTER \ - do { \ - _saved_errno = errno; \ - SYSIO_ENTER; \ - } while (0) -#define SYSIO_INTERFACE_RETURN(rtn, err) \ - do { \ - SYSIO_LEAVE; \ - errno = (err) ? -(err) : _saved_errno; \ - return (rtn); \ - } while(0) - -/* syscall enter/leave hook functions */ -#if 0 -extern void _sysio_sysenter(); -extern void _sysio_sysleave(); - -#define SYSIO_ENTER \ - do { \ - _sysio_sysenter(); \ - } while(0) - -#define SYSIO_LEAVE \ - do { \ - _sysio_sysleave(); \ - } while(0) -#else -#define SYSIO_ENTER -#define SYSIO_LEAVE - -#endif - -/* accounting for IO stats read and write char count */ -#if defined(REDSTORM) -#define _SYSIO_UPDACCT(w, cc) \ - do { \ - if ((cc) < 0) \ - break; \ - if (!w) \ - _add_iostats(0, (size_t )(cc)); \ - else \ - _add_iostats((size_t )(cc), 0); \ - } while(0) -#else -#define _SYSIO_UPDACCT(w, cc) -#endif diff --git a/libsysio/include/xtio.h b/libsysio/include/xtio.h deleted file mode 100644 index 87cf981..0000000 --- a/libsysio/include/xtio.h +++ /dev/null @@ -1,328 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Extended application programmers interface for IO as found on Cray RedStorm - * and the other current SUNMos/Puma/Cougar/Catamount systems. - */ - -#ifndef _XTIO_H_ -#define _XTIO_H_ - -#ifndef _IOID_T_DEFINED -#define _IOID_T_DEFINED -typedef void *ioid_t; - -#define IOID_FAIL 0 -#endif - -/* - * Structure for strided I/O. - */ -struct xtvec { -#ifndef __USE_FILE_OFFSET64 - __off_t xtv_off; /* Stride/Extent offset. */ -#else - __off64_t xtv_off; /* Stride/Extent offset. */ -#endif - size_t xtv_len; /* Stride/Extent length. */ -}; - -#ifdef __USE_LARGEFILE64 -struct xtvec64 { - __off64_t xtv_off; /* Stride/Extent offset. */ - size_t xtv_len; /* Stride/Extent length. */ -}; -#endif - -struct iovec; - -/* - * Get status of previously posted async file IO operation. - */ -extern int iodone(ioid_t ioid); - -/* - * Wait for completion of a previously posted asynch file IO request. - */ -extern ssize_t iowait(ioid_t ioid); - -/* - * Post asynch read into buffers mapped by an iovec from file at given offset. - */ -extern ioid_t ipreadv(int fd, - const struct iovec *iov, - size_t count, - off_t offset); - -#if _LARGEFILE64_SOURCE -/* - * Post asynch read into buffers mapped by an iovec from file at given offset. - */ -extern ioid_t ipread64v(int fd, - const struct iovec *iov, - size_t count, - off64_t offset); -#endif - -/* - * Post asynch read into buffer from file at given offset. - */ -extern ioid_t ipread(int fd, - void *buf, - size_t count, - off_t offset); - -#if _LARGEFILE64_SOURCE -/* - * Post asynch read into buffer from file at given offset. - */ -extern ioid_t ipread64(int fd, - void *buf, - size_t count, - off64_t offset); -#endif - -/* - * Read into buffers mapped by an iovec from file at given offset. - */ -extern ssize_t preadv(int fd, - const struct iovec *iov, - size_t count, - off_t offset); - -#if _LARGEFILE64_SOURCE -/* - * Read into buffers mapped by an iovec from file at given offset. - */ -extern ssize_t pread64v(int fd, - const struct iovec *iov, - size_t count, - off64_t offset); -#endif - -/* - * Post asynch read into buffers mapped by an iovec. - */ -extern ioid_t ireadv(int fd, - const struct iovec *iov, - int count); - -/* - * Read into buffer. - */ -extern ioid_t iread(int fd, - void *buf, - size_t count); - -/* - * Post async read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t ireadx(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Post async read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t iread64x(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif - -/* - * Read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t readx(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Read into buffers mapped by iovec from regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t read64x(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif - -/* - * Post asynch write from buffers mapped by an iovec to file at given offset. - */ -extern ioid_t ipwritev(int fd, - const struct iovec *iov, - size_t count, - off_t offset); -#if _LARGEFILE64_SOURCE -/* - * Post asynch write from buffers mapped by an iovec to file at given offset. - */ -extern ioid_t ipwrite64v(int fd, - const struct iovec *iov, - size_t count, - off64_t offset); -#endif - -/* - * Post asynch write from buffer to file at given offset. - */ -extern ioid_t ipwrite(int fd, - const void *buf, - size_t count, - off_t offset); - -#if _LARGEFILE64_SOURCE -/* - * Post asynch write from buffer to file at given offset. - */ -extern ioid_t ipwrite64(int fd, - const void *buf, - size_t count, - off64_t offset); -#endif - -/* - * Write from buffers mapped by an iovec to file at given offset. - */ -extern ssize_t pwritev(int fd, - const struct iovec *iov, - size_t count, - off_t offset); - -#if _LARGEFILE64_SOURCE -/* - * Write from buffers mapped by an iovec to file at given offset. - */ -extern ssize_t pwrite64v(int fd, - const struct iovec *iov, - size_t count, - off64_t offset); -#endif - -/* - * Post asynch write from buffer to file at given offset. - */ -extern ioid_t iwritev(int fd, - const struct iovec *iov, - int count); - -/* - * Write from buffer to file at given offset. - */ -extern ioid_t iwrite(int fd, - const void *buf, - size_t count); - -/* - * Post async write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t iwritex(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Post async write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ioid_t iwrite64x(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif - -/* - * Write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t writex(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec *xtv, - size_t xtv_count); - -#ifdef __USE_LARGEFILE64 -/* - * Write from buffers mapped by iovec to regions mapped - * by xtvec. - * - * NB: An adaptation of "listio" from Argonne's PVFS. - */ -extern ssize_t write64x(int fd, - const struct iovec *iov, - size_t iov_count, - const struct xtvec64 *xtv, - size_t xtv_count); -#endif -#endif /* ! _XTIO_H_ */ diff --git a/libsysio/misc/gdb-libsysio b/libsysio/misc/gdb-libsysio deleted file mode 100644 index dd3f613..0000000 --- a/libsysio/misc/gdb-libsysio +++ /dev/null @@ -1,127 +0,0 @@ -# This Cplant(TM) source code is the property of Sandia National -# Laboratories. -# -# This Cplant(TM) source code is copyrighted by Sandia National -# Laboratories. -# -# The redistribution of this Cplant(TM) source code is subject to the -# terms of the GNU Lesser General Public License -# (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) -# -# Cplant(TM) Copyright 1998-2003 Sandia Corporation. -# Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive -# license for use of this work by or on behalf of the US Government. -# Export of this program may require a license from the United States -# Government. - -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Questions or comments about this library should be sent to: -# -# Lee Ward -# Sandia National Laboratories, New Mexico -# P.O. Box 5800 -# Albuquerque, NM 87185-1110 -# -# lee@sandia.gov - -# -# Useful commands for debugging libsysio in gdb -# - -define x_dump_pbnode - printf "%p: ", $arg0 - if $arg0->pb_name.name - printf " \"%s\"", \ - $arg0->pb_name.name - else - printf " " - end - printf " aliases:[" - set $x_p = $arg0->pb_aliases.lh_first - while $x_p - printf "<%p r:%d mnt:%p>", \ - $x_p, \ - $x_p->p_ref, \ - $x_p->p_mount - set $x_p = $x_p->p_links.le_next - end - printf "]\n" -end -document x_dump_pbnode -Dump path-base node and it's aliases - -Usage: x_dump_pbnode -end - -define __x_dump_pnode - printf "%spnode %p, mount %p, base: ", $arg0, $arg1, $arg1->p_mount - x_dump_pbnode $arg1->p_base -end - -define x_dump_pnode - __x_dump_pnode "" $arg0 -end -document x_dump_pnode -Dump path node information - -Usage: x_dump_pnode -end - -define x_dump_mount - printf "MOUNT %p: root pnode %p, covers %p\n", \ - $arg0, $arg0->mnt_root, $arg0->mnt_covers - set $_x_dump_mount_var_pno = _sysio_pnodes->tqh_first - while $_x_dump_mount_var_pno != 0 -printf "%p, %p\n", $_x_dump_mount_var_pno, $arg0 - if $_x_dump_mount_var_pno->p_mount == $arg0 - __x_dump_pnode " " $_x_dump_mount_var_pno - end - set $_x_dump_mount_var_pno = \ - $_x_dump_mount_var_pno->p_nodes.tqe_next - end -end -document x_dump_mount -Dump single mount record information - -Usage: x_dump_mount -end - -define x_dump_mounts - set $__x_dump_mounts_var_mnt = mounts.lh_first - while $__x_dump_mounts_var_mnt - x_dump_mount $__x_dump_mounts_var_mnt - set $__x_dump_mounts_var_mnt = \ - $__x_dump_mounts_var_mnt->mnt_link.le_next - end -end -document x_dump_mounts -Dump the contents of the libsysio mount table - -Usage: x_dump_mounts -end - -define x_dump_pnodes - set $_x_dump_pnodes_var_pno = _sysio_pnodes.tqh_first - while $_x_dump_pnodes_var_pno - x_dump_pnode $_x_dump_pnodes_var_pno - set $_x_dump_pnodes_var_pno = \ - $_x_dump_pnodes_var_pno->p_nodes.tqe_next - end -end - -br _sysio_unmount_all -run -r /tmp/lee foo bar -x_dump_pnodes diff --git a/libsysio/misc/init-env.sh b/libsysio/misc/init-env.sh deleted file mode 100644 index 3e9861e..0000000 --- a/libsysio/misc/init-env.sh +++ /dev/null @@ -1,41 +0,0 @@ -# -# Source this file. It will craft a usable name space for your testing. -# -# Lee; Sun Feb 8 18:02:16 EST 2004 -# -# Note: We really should support symlinks someday. -# -unset _root_flags -unset _extras -if [ "x${SYSIO_AUTOMOUNT}" == "xyes" ]; then - _root_flags="2" - # - # Add a /auto directory for automounted file systems. We - # craft one automount that mounts /usr/home from the native - # file system. Further automounts in the sub-mounts are not enabled. - # - _extras=" \ - {mnt, dev=\"incore:0755+0+0\",dir=\"/mnt\",fl=2} \ - {creat, ft=dir,nm=\"/mnt/home\",pm=04755,ow=0,gr=0} \ - {creat, ft=file,nm=\"/mnt/home/.mount\",pm=0600, \ - str=\"native:/home\"} \ - " -fi -export SYSIO_NAMESPACE="\ - {mnt, dev=\"native:/\",dir=/,fl=${_root_flags:-0}} \ - {mnt, dev=\"incore:0755+0+0\",dir=\"/dev\"} \ - {creat, ft=chr,nm=\"/dev/stdin\",pm=0400,mm=0+0} \ - {creat, ft=chr,nm=\"/dev/stdout\",pm=0200,mm=0+1} \ - {creat, ft=chr,nm=\"/dev/stderr\",pm=0200,mm=0+2} \ - {creat, ft=dir,nm=\"/dev/fd\",pm=0755,ow=0,gr=0} \ - {creat, ft=chr,nm=\"/dev/fd/0\",pm=0400,mm=0+0} \ - {open, nm=\"/dev/fd/0\",fd=0,m=0} \ - {creat, ft=chr,nm=\"/dev/fd/1\",pm=0200,mm=0+1} \ - {open, nm=\"/dev/fd/1\",fd=1,m=1} \ - {creat, ft=chr,nm=\"/dev/fd/2\",pm=0200,mm=0+2} \ - {open, nm=\"/dev/fd/2\",fd=2,m=1} \ - {cd, dir=\"$HOME\"} \ - ${_extras} \ -" -unset _root_flags -unset _extras diff --git a/libsysio/src/access.c b/libsysio/src/access.c deleted file mode 100644 index 9d2664f..0000000 --- a/libsysio/src/access.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(access)(const char *path, int amode) -{ - gid_t *list, *entry; - size_t n; - int err = 0; - unsigned mask, mode; - struct stat stbuf; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - - /* - * Check amode. - */ - if ((amode & (R_OK|W_OK|X_OK)) != amode) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); - - n = getgroups(0, NULL); - list = NULL; - if (n) { - list = malloc(n * sizeof(gid_t)); - if (!list) { - err = -ENOMEM; - goto out; - } - } - err = getgroups(n, list); - if (err != (int ) n) - goto out; - - err = SYSIO_INTERFACE_NAME(stat)(path, &stbuf); - if (err) { - err = -errno; - goto out; - } - if (!amode) - SYSIO_INTERFACE_RETURN(0, 0); - - - mask = 0; - if (amode & R_OK) - mask |= S_IRUSR; - if (amode & W_OK) - mask |= S_IWUSR; - if (amode & X_OK) - mask |= S_IXUSR; - - mode = stbuf.st_mode; - if (stbuf.st_uid == getuid() && (mode & mask) == mask) - goto out; - - mask >>= 3; - if (stbuf.st_gid == getgid() && (mode & mask) == mask) - goto out; - - entry = list; - while (n--) - if (stbuf.st_gid == *entry++ && (mode & mask) == mask) - goto out; - - mask >>= 3; - if ((mode & mask) == mask) - goto out; - - err = -EACCES; - -out: - if (list) - free(list); - - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __access -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(access), - PREPEND(__, SYSIO_INTERFACE_NAME(access))) -#endif diff --git a/libsysio/src/chdir.c b/libsysio/src/chdir.c deleted file mode 100644 index 36c4757..0000000 --- a/libsysio/src/chdir.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * ############################################################################# - * # - * # This Cplant(TM) source code is the property of Sandia National - * # Laboratories. - * # - * # This Cplant(TM) source code is copyrighted by Sandia National - * # Laboratories. - * # - * # The redistribution of this Cplant(TM) source code is subject to the - * # terms of the GNU Lesser General Public License - * # (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * # - * # Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * # Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * # license for use of this work by or on behalf of the US Government. - * # Export of this program may require a license from the United States - * # Government. - * # - * ############################################################################# - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "mount.h" -#include "file.h" -#include "sysio-symbols.h" - -struct pnode *_sysio_cwd = NULL; - -/* - * Change to directory specified by the given pnode. - */ -int -_sysio_p_chdir(struct pnode *pno) -{ - int err; - - /* - * Revalidate the pnode, and ensure it's a directory - */ - err = _sysio_p_validate(pno, NULL, NULL); - if (err) - return err; - - if (!(pno->p_base->pb_ino && - S_ISDIR(pno->p_base->pb_ino->i_mode))) - return -ENOTDIR; - /* - * Release old if set. - */ - if (_sysio_cwd) - P_RELE(_sysio_cwd); - - /* - * Finally, change to the new. - */ - _sysio_cwd = pno; - - return 0; -} - -int -SYSIO_INTERFACE_NAME(chdir)(const char *path) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - SYSIO_INTERFACE_RETURN(-1, err); - - err = _sysio_p_chdir(pno); - if (err) - P_RELE(pno); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __chdir -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(chdir), - PREPEND(__, SYSIO_INTERFACE_NAME(chdir))) -#endif - -/* - * Return path tracked by the path ancestor chain. - * - * If the buf pointer is NULL, a buffer large enough to hold the path - * is allocated from the heap. - */ - -static int -_sysio_p_path(struct pnode *pno, char **buf, size_t size) -{ - struct pnode *cur; - size_t len; - size_t n; - char *cp; - - cur = pno; - - /* - * Walk up the tree to the root, summing the component name - * lengths and counting the vertices. - */ - len = 0; - n = 0; - do { - /* - * If this is a covering path-node then the name should be - * the *covered* nodes name, not this one unless we are at - * the root of the name-space. - */ - while (pno == pno->p_mount->mnt_root && pno != pno->p_parent ) - pno = pno->p_mount->mnt_covers; - - /* - * Add length of this component to running sum and - * account for this vertex. - */ - assert((len >= pno->p_base->pb_name.len && - (size_t )~0 - pno->p_base->pb_name.len > len) || - (size_t )~0 - len > pno->p_base->pb_name.len); - len += pno->p_base->pb_name.len; - n++; - assert(n); - pno = pno->p_parent; - } while (pno != pno->p_parent); - - if (!*buf) - size = len + n + 1; - if (len >= size || n >= size - len) - return -ERANGE; - if (!*buf) { - /* - * Allocate path buffer from the heap. - */ - *buf = malloc(size * sizeof(char)); - if (!*buf) - return -ENOMEM; - } - - /* - * Fill in the path buffer. - */ - pno = cur; - cp = *buf + len + n; - *cp = '\0'; /* NUL terminate */ - do { - /* - * If this is a covering path-node then the name should be - * the *covered* nodes name, not this one unless we are at - * the root of the name-space. - */ - while (pno == pno->p_mount->mnt_root && pno != pno->p_parent ) - pno = pno->p_mount->mnt_covers; - - /* - * Add component and separator. - */ - cp -= pno->p_base->pb_name.len; - (void )memcpy(cp, pno->p_base->pb_name.name, - pno->p_base->pb_name.len); - - *--cp = PATH_SEPARATOR; - pno = pno->p_parent; - } while (pno != pno->p_parent); - - return 0; -} - -char * -SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size) -{ - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_p_path(_sysio_cwd, &buf, buf ? size : 0); - SYSIO_INTERFACE_RETURN(err ? NULL : buf, err); -} - -#ifdef __GLIBC__ -#undef __getcwd -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(getcwd), - PREPEND(__, SYSIO_INTERFACE_NAME(getcwd))) -#endif - -#if defined(PATH_MAX) && !(defined(REDSTORM)) -char * -SYSIO_INTERFACE_NAME(getwd)(char *buf) -{ - - if (!buf) { - errno = EFAULT; - return NULL; - } - - return SYSIO_INTERFACE_NAME(getcwd)(buf, PATH_MAX); -} -#endif diff --git a/libsysio/src/chmod.c b/libsysio/src/chmod.c deleted file mode 100644 index 936dec4..0000000 --- a/libsysio/src/chmod.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -static int -do_chmod(struct pnode *pno, struct inode *ino, mode_t mode) -{ - int err; - struct intnl_stat stbuf; - unsigned mask; - - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - stbuf.st_mode = mode & 07777; - mask = SETATTR_MODE; - err = _sysio_setattr(pno, ino, mask, &stbuf); - return err; -} - -int -SYSIO_INTERFACE_NAME(chmod)(const char *path, mode_t mode) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - err = do_chmod(pno, pno->p_base->pb_ino, mode); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __chmod -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(chmod), - PREPEND(__, SYSIO_INTERFACE_NAME(chmod))) -#endif - -int -SYSIO_INTERFACE_NAME(fchmod)(int fd, mode_t mode) -{ - int err; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - - err = do_chmod(NULL, fil->f_ino, mode); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fchmod -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fchmod), - PREPEND(__, SYSIO_INTERFACE_NAME(fchmod))) -#endif diff --git a/libsysio/src/chown.c b/libsysio/src/chown.c deleted file mode 100644 index 827a815..0000000 --- a/libsysio/src/chown.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -static int -_do_chown(struct pnode *pno, struct inode *ino, uid_t owner, gid_t group) -{ - int err; - struct intnl_stat stbuf; - unsigned mask; - - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - mask = 0; - if (owner != (uid_t )-1) { - stbuf.st_uid = owner; - mask |= SETATTR_UID; - } - if (group != (gid_t )-1) { - stbuf.st_gid = group; - mask |= SETATTR_GID; - } - err = _sysio_setattr(pno, ino, mask, &stbuf); - return err; -} - -int -SYSIO_INTERFACE_NAME(chown)(const char *path, uid_t owner, gid_t group) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - - err = _do_chown(pno, pno->p_base->pb_ino, owner, group); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __chown -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(chown), - PREPEND(__, SYSIO_INTERFACE_NAME(chown))) -#endif - -int -SYSIO_INTERFACE_NAME(fchown)(int fd, uid_t owner, gid_t group) -{ - int err; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - - err = _do_chown(NULL, fil->f_ino, owner, group); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fchown -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fchown), - PREPEND(__, SYSIO_INTERFACE_NAME(fchown))) -#endif - diff --git a/libsysio/src/dev.c b/libsysio/src/dev.c deleted file mode 100644 index 046e35f..0000000 --- a/libsysio/src/dev.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "dev.h" - -const struct inode_ops _sysio_nodev_ops = { - _sysio_nodev_inop_lookup, - _sysio_nodev_inop_getattr, - _sysio_nodev_inop_setattr, - _sysio_nodev_getdirentries, - _sysio_nodev_inop_mkdir, - _sysio_nodev_inop_rmdir, - _sysio_nodev_inop_symlink, - _sysio_nodev_inop_readlink, - _sysio_nodev_inop_open, - _sysio_nodev_inop_close, - _sysio_nodev_inop_link, - _sysio_nodev_inop_unlink, - _sysio_nodev_inop_rename, - _sysio_nodev_inop_read, - _sysio_nodev_inop_write, - _sysio_nodev_inop_pos, - _sysio_nodev_inop_iodone, - _sysio_nodev_inop_fcntl, - _sysio_nodev_inop_sync, - _sysio_nodev_inop_datasync, - _sysio_nodev_inop_ioctl, - _sysio_nodev_inop_mknod, -#ifdef _HAVE_STATVFS - _sysio_nodev_inop_statvfs, -#endif - _sysio_nodev_inop_gone -}; - -/* - * Support for pseudo-devices. - */ - -struct device { - const char *dev_name; - struct inode_ops dev_ops; -}; - -static struct device cdev[128]; - -int -_sysio_dev_init() -{ - unsigned major; - - major = 0; - do { - cdev[major].dev_name = NULL; - cdev[major].dev_ops = _sysio_nodev_ops; - } while (++major < sizeof(cdev) / sizeof(struct device)); - - return 0; -} - -/* - * Allocate major dev number in the dynamic range [128-255]. - */ -dev_t -_sysio_dev_alloc() -{ - unsigned short major; - static unsigned char c_major = 128; - - assert(c_major); - major = c_major++; - return SYSIO_MKDEV(major, 0); -} - -static int -dev_register(struct device devtbl[], - int major, - const char *name, - struct inode_ops *ops) -{ - - assert(major < 128); - - if (major < 0) { - major = sizeof(cdev) / sizeof(struct device); - while (major--) { - if (!devtbl[major].dev_name) - break; - } - } - if (major < 0) - return -ENXIO; /* I dunno, what? */ - if (devtbl[major].dev_name) - return -EEXIST; - devtbl[major].dev_name = name; - devtbl[major].dev_ops = *ops; - - return major; -} - -int -_sysio_char_dev_register(int major, const char *name, struct inode_ops *ops) -{ - - return dev_register(cdev, major, name, ops); -} - -struct inode_ops * -_sysio_dev_lookup(mode_t mode, dev_t dev) -{ - struct device *devtbl; - dev_t major; - - if (S_ISCHR(mode) || S_ISFIFO(mode)) - devtbl = cdev; - else - return (struct inode_ops *)&_sysio_nodev_ops; - - major = SYSIO_MAJOR_DEV(dev); - if (!(major < 128) || !devtbl[major].dev_name) - return (struct inode_ops *)&_sysio_nodev_ops; - - return &devtbl[major].dev_ops; -} diff --git a/libsysio/src/dup.c b/libsysio/src/dup.c deleted file mode 100644 index 947d7f0..0000000 --- a/libsysio/src/dup.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd) -{ - int fd; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (newfd < 0) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - if (oldfd == newfd) { - struct file *fil; - - fil = _sysio_fd_find(oldfd); - if (!(fil && fil->f_ino)) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - SYSIO_INTERFACE_RETURN(newfd, 0); - } - - fd = _sysio_fd_dup(oldfd, newfd, 1); - SYSIO_INTERFACE_RETURN(fd < 0 ? -1 : fd, fd < 0 ? fd : 0); -} - -#ifdef REDSTORM -#undef __dup2 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(dup2), - PREPEND(__, SYSIO_INTERFACE_NAME(dup2))) -#endif - -int -SYSIO_INTERFACE_NAME(dup)(int oldfd) -{ - int fd; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fd = _sysio_fd_dup(oldfd, -1, 0); - SYSIO_INTERFACE_RETURN(fd < 0 ? -1 : fd, fd < 0 ? fd : 0); -} - -#ifdef __GLIBC__ -#undef __dup -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(dup), - PREPEND(__, SYSIO_INTERFACE_NAME(dup))) -#endif diff --git a/libsysio/src/fcntl.c b/libsysio/src/fcntl.c deleted file mode 100644 index c8a801a..0000000 --- a/libsysio/src/fcntl.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -#ifdef HAVE_LUSTRE_HACK -#include - -static int -_sysio_fcntl(int fd, int cmd, va_list ap, int *rtn) -{ - long arg = va_arg(ap, long); - - *rtn = syscall(SYS_fcntl, fd, cmd, arg); - return *rtn == -1 ? -errno : 0; -} -#endif - -int -SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...) -{ - int err; - int rtn; - struct file *fil; - va_list ap; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { -#ifdef HAVE_LUSTRE_HACK - va_start(ap, cmd); - err = _sysio_fcntl(fd, cmd, ap, &rtn); - va_end(ap); - goto out; -#else - - rtn = -1; - err = -EBADF; - goto out; -#endif - } - - switch (cmd) { - - case F_DUPFD: - { - long newfd; - - va_start(ap, cmd); - newfd = va_arg(ap, long); - va_end(ap); - if (newfd != (int )newfd || newfd < 0) { - rtn = -1; - err = -EBADF; - goto out; - } - rtn = _sysio_fd_dup(fd, (int )newfd, 0); - if (rtn < 0) { - err = rtn; - rtn = -1; - } - } - break; - default: - va_start(ap, cmd); - err = fil->f_ino->i_ops.inop_fcntl(fil->f_ino, cmd, ap, &rtn); - va_end(ap); - break; - } - -out: - SYSIO_INTERFACE_RETURN(rtn, err); -} - -#ifdef __GLIBC__ -#undef __fcntl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fcntl), - PREPEND(__, SYSIO_INTERFACE_NAME(fcntl))) -#endif - -#ifdef BSD -#undef _fcntl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fcntl), - PREPEND(_, SYSIO_INTERFACE_NAME(fcntl))) -#endif diff --git a/libsysio/src/file.c b/libsysio/src/file.c deleted file mode 100644 index bffc3fd..0000000 --- a/libsysio/src/file.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "inode.h" - -/* - * Support for file IO. - */ - -/* - * The open files table and it's size. - */ -static struct file **_sysio_oftab = NULL; -static size_t _sysio_oftab_size = 0; - -/* - * Create and initialize open file record. - */ -struct file * -_sysio_fnew(struct inode *ino, int flags) -{ - struct file *fil; - - fil = malloc(sizeof(struct file)); - if (!fil) - return NULL; - - _SYSIO_FINIT(fil, ino, flags); - I_REF(ino); - - return fil; -} - -/* - * Destroy open file record. - */ -void -_sysio_fgone(struct file *fil) -{ - int err; - - assert(!fil->f_ref); - assert(fil->f_ino); - err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino); - assert(!err); - free(fil); -} - -/* - * IO operation completion handler. - */ -void -_sysio_fcompletio(struct ioctx *ioctx, struct file *fil) -{ - _SYSIO_OFF_T off; - - if (ioctx->ioctx_cc <= 0) - return; - - assert(ioctx->ioctx_ino == fil->f_ino); - off = fil->f_pos + ioctx->ioctx_cc; - if (fil->f_pos && off <= fil->f_pos) - abort(); - fil->f_pos = off; -} - -/* - * Grow (or truncate) the file descriptor table. - */ -static int -fd_grow(size_t n) -{ - size_t count; - struct file **noftab, **filp; - - /* - * Sanity check the new size. - */ - if ((int )n < 0) - return -EMFILE; - - /* - * We never shrink the table. - */ - if (n <= _sysio_oftab_size) - return 0; - - noftab = realloc(_sysio_oftab, n * sizeof(struct file *)); - if (!noftab) - return -ENOMEM; - _sysio_oftab = noftab; - count = _sysio_oftab_size; - _sysio_oftab_size = n; - filp = _sysio_oftab + count; - n -= count; - while (n--) - *filp++ = NULL; - return 0; -} - -#if ZERO_SUM_MEMORY -void -_sysio_fd_shutdown() -{ - - free(_sysio_oftab); - _sysio_oftab_size = 0; -} -#endif - -/* - * Find a free slot in the open files table greater than or equal to the - * argument. - */ -static int -find_free_fildes(int low) -{ - int n; - int err; - struct file **filp; - - for (n = low, filp = _sysio_oftab + low; - n >= 0 && (unsigned )n < _sysio_oftab_size && *filp; - n++, filp++) - ; - if (n < 0) - return -ENFILE; - if ((unsigned )n >= _sysio_oftab_size) { - err = fd_grow((unsigned )n + 1); - if (err) - return err; - filp = &_sysio_oftab[n]; - assert(!*filp); - } - - return n; -} - -/* - * Find open file record from file descriptor. - */ -struct file * -_sysio_fd_find(int fd) -{ - if (fd < 0 || (unsigned )fd >= _sysio_oftab_size) - return NULL; - - return _sysio_oftab[fd]; -} - -/* - * Close an open descriptor. - */ -int -_sysio_fd_close(int fd) -{ - struct file *fil; - - fil = _sysio_fd_find(fd); - if (!fil) - return -EBADF; - - _sysio_oftab[fd] = NULL; - - F_RELE(fil); - - return 0; -} - -/* - * Associate open file record with given file descriptor (if forced), or any - * available file descriptor if less than zero, or any available descriptor - * greater than or equal to the given one if not forced. - */ -int -_sysio_fd_set(struct file *fil, int fd, int force) -{ - int err; - struct file *ofil; - - /* - * Search for a free descriptor if needed. - */ - if (fd < 0 || !force) { - if (fd < 0) - fd = 0; - fd = find_free_fildes(fd); - if (fd < 0) - return fd; - } - - if ((unsigned )fd >= _sysio_oftab_size) { - err = fd_grow((unsigned )fd + 1); - if (err) - return err; - } - - /* - * Remember old. - */ - ofil = _sysio_fd_find(fd); - /* - * Take the entry. - */ - _sysio_oftab[fd] = fil; - if (ofil) - F_RELE(ofil); - - return fd; -} - -/* - * Duplicate old file descriptor. - * - * If the new file descriptor is less than zero, the new file descriptor - * is chosen freely. Otherwise, choose an available descriptor greater - * than or equal to the new, if not forced. Otherwise, if forced, (re)use - * the new. - */ -int -_sysio_fd_dup(int oldfd, int newfd, int force) -{ - struct file *fil; - int fd; - - if (oldfd == newfd) - return newfd; - - fil = _sysio_fd_find(oldfd); - if (!fil) - return -EBADF; - - fd = _sysio_fd_set(fil, newfd, force); - if (fd >= 0) - F_REF(fil); - return fd; -} - -int -_sysio_fd_close_all() -{ - int fd; - struct file **filp; - - /* - * Close all open descriptors. - */ - for (fd = 0, filp = _sysio_oftab; - (size_t )fd < _sysio_oftab_size; - fd++, filp++) { - if (!*filp) - continue; - F_RELE(*filp); - *filp = NULL; - } - - /* - * Release current working directory. - */ - if (_sysio_cwd) { - P_RELE(_sysio_cwd); - _sysio_cwd = NULL; - } - - return 0; -} diff --git a/libsysio/src/file_hack.c b/libsysio/src/file_hack.c deleted file mode 100644 index 524fb55..0000000 --- a/libsysio/src/file_hack.c +++ /dev/null @@ -1,422 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "inode.h" - -/* - * Support for file IO. - */ - -/* - * The open files table - */ -typedef struct oftab { - struct file **table; /* table array */ - size_t size; /* current table size */ - int offset; /* base fd number */ - int max; /* max size */ -} oftab_t; - -#define OFTAB_NATIVE (0) -#define OFTAB_VIRTUAL (1) - -static oftab_t _sysio_oftab[2] = { - {NULL, 0, 0, 0}, - {NULL, 0, 0, 1024*1024}, -}; - -static int native_max_fds = 0; - -static inline void init_oftab() -{ - if (!native_max_fds) { - native_max_fds = sysconf(_SC_OPEN_MAX); - if (native_max_fds <= 0) - abort(); - _sysio_oftab[OFTAB_NATIVE].max = native_max_fds - 1; - _sysio_oftab[OFTAB_VIRTUAL].offset = native_max_fds; - } -} - -static inline oftab_t *select_oftab(int fd) -{ - return & _sysio_oftab[fd >= native_max_fds || fd < 0]; -} - -/* - * Create and initialize open file record. - */ -struct file * -_sysio_fnew(struct inode *ino, int flags) -{ - struct file *fil; - - fil = malloc(sizeof(struct file)); - if (!fil) - return NULL; - - _SYSIO_FINIT(fil, ino, flags); - I_REF(ino); - - return fil; -} - -/* - * Destroy open file record. - */ -void -_sysio_fgone(struct file *fil) -{ - int err; - - assert(!fil->f_ref); - assert(fil->f_ino); - err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino); - assert(!err); - free(fil); -} - -/* - * IO operation completion handler. - */ -void -_sysio_fcompletio(struct ioctx *ioctx, struct file *fil) -{ - _SYSIO_OFF_T off; - - if (ioctx->ioctx_cc <= 0) - return; - - assert(ioctx->ioctx_ino == fil->f_ino); - off = fil->f_pos + ioctx->ioctx_cc; - if (fil->f_pos && off <= fil->f_pos) - abort(); - fil->f_pos = off; -} - -/* - * Grow (or truncate) the file descriptor table. - */ -static int -fd_grow(oftab_t *oftab, size_t n) -{ - int fd; - size_t count; - struct file **noftab, **filp; - - /* - * Sanity check the new size. - */ - fd = (int )n; - if ((size_t )fd != n) - return -EMFILE; - - n++; /* index -> size */ - assert(n > oftab->size); - - if (n > oftab->max) - return -ERANGE; - - if (n < 8) - n = 8; - if (n - oftab->size < oftab->size) - n = (n + 1) * 2; - noftab = realloc(oftab->table, n * sizeof(struct file *)); - if (!noftab) - return -ENOMEM; - oftab->table = noftab; - count = oftab->size; - oftab->size = n; - if (n < count) - return 0; - filp = oftab->table + count; - n -= count; - while (n--) - *filp++ = NULL; - return 0; -} - -#if ZERO_SUM_MEMORY -static void free_oftab(oftab_t *ot) -{ - if (ot->table) { - free(ot->table); - ot->size = 0; - } -} - -void -_sysio_fd_shutdown() -{ - free_oftab(&_sysio_oftab[OFTAB_NATIVE]); - free_oftab(&_sysio_oftab[OFTAB_VIRTUAL]); -} -#endif - -/* - * Find a free slot in the open files table which >= @low - * low < 0 means any - */ -static int -find_free_fildes(oftab_t *oftab, int low) - { - int n; - int err; - struct file **filp; - - if (low < 0) - low = oftab->offset; - - n = low - oftab->offset; - if (n < 0) - return -ENFILE; - - for (filp = oftab->table + n; - n < oftab->size && *filp; - n++, filp++) - ; - - if (n >= oftab->size) { - err = fd_grow(oftab, n); - if (err) - return err; - filp = &oftab->table[n]; - assert(!*filp); - } - - return oftab->offset + n; -} - -/* - * Find open file record from file descriptor. - * clear this entry if 'clear' is non-zero - */ -static struct file * -__sysio_fd_get(int fd, int clear) -{ - oftab_t *oftab; - struct file *file; - - init_oftab(); - - if (fd < 0) - return NULL; - - oftab = select_oftab(fd); - if (!oftab->table || fd >= oftab->offset + oftab->size) - return NULL; - - file = oftab->table[fd - oftab->offset]; - if (clear) - oftab->table[fd - oftab->offset] = NULL; - - return file; -} - -/* - * Find open file record from file descriptor. - */ -struct file * -_sysio_fd_find(int fd) -{ - return __sysio_fd_get(fd, 0); -} - -/* - * Close an open descriptor. - */ -int -_sysio_fd_close(int fd) -{ - struct file *fil; - - fil = fil = __sysio_fd_get(fd, 1); - if (!fil) - return -EBADF; - - F_RELE(fil); - - return 0; -} - -/* - * Associate open file record with given file descriptor (if forced), or any - * available file descriptor if less than zero, or any available descriptor - * greater than or equal to the given one if not forced. - */ -int -_sysio_fd_set(struct file *fil, int fd, int force) -{ - int err; - struct file *ofil; - oftab_t *oftab; - - if (force && fd < 0) - abort(); - - init_oftab(); - - oftab = select_oftab(fd); - - /* - * Search for a free descriptor if needed. - */ - if (!force) { - fd = find_free_fildes(oftab, fd); - if (fd < 0) - return fd; - } - - if (fd - oftab->offset >= oftab->size) { - err = fd_grow(oftab, fd - oftab->offset); - if (err) - return err; - } - - /* - * Remember old. - */ - ofil = __sysio_fd_get(fd, 1); - if (ofil) { - /* FIXME sometimes we could intercept open/socket to create - * a fd, but missing close()? currently we have this problem - * with resolv lib. as a workaround simply destroy the file - * struct here. And this hack will break the behavior of - * DUPFD. - */ - if (fd >= 0 && oftab == &_sysio_oftab[0]) - free(ofil); - else - F_RELE(ofil); - } - - oftab->table[fd - oftab->offset] = fil; - - return fd; -} - -/* - * Duplicate old file descriptor. - * - * If the new file descriptor is less than zero, the new file descriptor - * is chosen freely. Otherwise, choose an available descriptor greater - * than or equal to the new, if not forced. Otherwise, if forced, (re)use - * the new. - */ -int -_sysio_fd_dup(int oldfd, int newfd, int force) -{ - struct file *fil; - int fd; - - init_oftab(); - - if (oldfd == newfd) - return 0; - - fil = _sysio_fd_find(oldfd); - if (!fil) - return -EBADF; - - /* old & new must belong to the same oftab */ - if (select_oftab(oldfd) != select_oftab(newfd)) - return -EINVAL; - - fd = _sysio_fd_set(fil, newfd, force); - if (fd >= 0) - F_REF(fil); - return fd; -} - -void -_sysio_oftable_close_all(oftab_t *oftab) -{ - struct file **filp; - int fd; - - for (fd = 0, filp = oftab->table; - (size_t )fd < oftab->size; - fd++, filp++) { - if (!*filp) - continue; - F_RELE(*filp); - *filp = NULL; - } -} - -int -_sysio_fd_close_all() -{ - int fd; - struct file **filp; - oftab_t *oftab; - int i; - - /* - * Close all open descriptors. - */ - _sysio_oftable_close_all(&_sysio_oftab[OFTAB_VIRTUAL]); - /* XXX see liblustre/llite_lib.c for explaination */ -#if 0 - _sysio_oftable_close_all(&_sysio_oftab[OFTAB_NATIVE]); -#endif - - /* - * Release current working directory. - */ - if (_sysio_cwd) { - P_RELE(_sysio_cwd); - _sysio_cwd = NULL; - } - - return 0; -} diff --git a/libsysio/src/fs.c b/libsysio/src/fs.c deleted file mode 100644 index 29abe4f..0000000 --- a/libsysio/src/fs.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "fs.h" -#include "inode.h" - -/* - * File system abstractipon support. - */ - -/* - * The "file system switch". - */ -static LIST_HEAD(, fsswent) fsswitch = { NULL }; - -/* - * Lookup named entry in the switch. - */ -struct fsswent * -_sysio_fssw_lookup(const char *name) -{ - struct fsswent *fssw; - - if (!fsswitch.lh_first) - return NULL; - - fssw = fsswitch.lh_first; - do { - if (strcmp(fssw->fssw_name, name) == 0) - return fssw; - fssw = fssw->fssw_link.le_next; - } while (fssw); - return NULL; -} - -/* - * Register driver. - */ -int -_sysio_fssw_register(const char *name, struct fssw_ops *ops) -{ - struct fsswent *fssw; - - fssw = _sysio_fssw_lookup(name); - if (fssw) - return -EEXIST; - - fssw = malloc(sizeof(struct fsswent) + strlen(name) + 1); - if (!fssw) - return -ENOMEM; - fssw->fssw_name = (char *)fssw + sizeof(struct fsswent); - (void )strcpy((char *)fssw->fssw_name, name); - fssw->fssw_ops = *ops; - - LIST_INSERT_HEAD(&fsswitch, fssw, fssw_link); - - return 0; -} - -#if ZERO_SUM_MEMORY -/* - * Shutdown - */ -void -_sysio_fssw_shutdown() -{ - struct fsswent *fssw; - - while ((fssw = fsswitch.lh_first)) { - LIST_REMOVE(fssw, fssw_link); - free(fssw); - } -} -#endif - -/* - * Allocate and initialize a new file system record. - */ -struct filesys * -_sysio_fs_new(struct filesys_ops *ops, unsigned flags, void *private) -{ - struct filesys *fs; - - fs = malloc(sizeof(struct filesys)); - if (!fs) - return NULL; - FS_INIT(fs, flags, ops, private); - return fs; -} - -/* - * Dispose of given file system record. - */ -void -_sysio_fs_gone(struct filesys *fs) -{ - size_t n; - struct itable_entry *head; - - if (fs->fs_ref) - abort(); - n = FS_ITBLSIZ; - do { - head = &fs->fs_itbl[--n]; - while (head->lh_first) - _sysio_i_gone(head->lh_first); - } while (n); - if (n) - abort(); - - (*fs->fs_ops.fsop_gone)(fs); - free(fs); -} diff --git a/libsysio/src/fsync.c b/libsysio/src/fsync.c deleted file mode 100644 index 988cb507..0000000 --- a/libsysio/src/fsync.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include - -#include "sysio.h" -#include "file.h" -#include "inode.h" - -int -SYSIO_INTERFACE_NAME(fsync)(int fd) -{ - struct file *fil; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - err = (*fil->f_ino->i_ops.inop_sync)(fil->f_ino); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -int -SYSIO_INTERFACE_NAME(fdatasync)(int fd) -{ - struct file *fil; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - err = (*fil->f_ino->i_ops.inop_datasync)(fil->f_ino); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} diff --git a/libsysio/src/getdirentries.c b/libsysio/src/getdirentries.c deleted file mode 100644 index 7e1a81f..0000000 --- a/libsysio/src/getdirentries.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * ############################################################################# - * # - * # This Cplant(TM) source code is the property of Sandia National - * # Laboratories. - * # - * # This Cplant(TM) source code is copyrighted by Sandia National - * # Laboratories. - * # - * # The redistribution of this Cplant(TM) source code is subject to the - * # terms of the GNU Lesser General Public License - * # (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * # - * # Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * # Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * # license for use of this work by or on behalf of the US Government. - * # Export of this program may require a license from the United States - * # Government. - * # - * ############################################################################# - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#ifdef __GLIBC__ -#include -#endif -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -#ifndef __GNUC__ -#define __restrict -#endif - -static ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64))(int fd, - char *buf, - size_t nbytes, - _SYSIO_OFF_T * __restrict - basep) -{ - struct file *fil; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - - fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - if (!S_ISDIR(fil->f_ino->i_mode)) - SYSIO_INTERFACE_RETURN(-1, -ENOTDIR); - - cc = - (*fil->f_ino->i_ops.inop_getdirentries)(fil->f_ino, - buf, - nbytes, - basep); - SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); -} - -#if _LARGEFILE64_SOURCE -#undef getdirentries64 -sysio_sym_strong_alias(PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64)), - SYSIO_INTERFACE_NAME(getdirentries64)) -#endif - -#undef getdirentries - -#ifndef DIRENT64_IS_NATURAL - -#ifndef EOVERFLOW -#define EOVERFLOW ERANGE -#endif - -#ifdef _DIRENT_HAVE_D_NAMLEN -#define _namlen(dp) ((dp)->d_namlen) -#else -#define _namlen(dp) (strlen((dp)->d_name)) -#endif - -#ifndef _rndup -#define _rndup(n, boundary) \ - ((((n) + (boundary) - 1 ) / (boundary)) * (boundary)) -#endif - -#ifndef BSD -ssize_t -SYSIO_INTERFACE_NAME(getdirentries)(int fd, - char *buf, - size_t nbytes, - off_t * __restrict basep) -#else -int -SYSIO_INTERFACE_NAME(getdirentries)(int fd, - char *buf, - int nbytes, - long * __restrict basep) -#endif -{ - size_t inbytes; - void *ibuf; - _SYSIO_OFF_T ibase; - ssize_t cc; - struct dirent *dp, *nxtdp; -#if defined(BSD) - int off; -#endif - struct intnl_dirent *od64p, *d64p; - size_t n; - size_t reclen; - char *cp; - SYSIO_INTERFACE_DISPLAY_BLOCK; - -#define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) - -#ifdef __GLIBC__ -#define _dreclen(namlen) \ - ((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \ - ~(__alignof__ (struct dirent) - 1)) -#else /* !defined(__GLIBC__) */ -#define _dreclen(namlen) \ - _rndup(_dbaselen + (namlen) + 1, sizeof(int)) -#endif - -#if defined(__GLIBC__) -#define _fast_alloc(n) alloca(n) -#define _fast_free(p) -#else /* !defined(__GLIBC__) */ -#define _fast_alloc(n) malloc(n) -#define _fast_free(p) free(p) -#endif - - SYSIO_INTERFACE_ENTER; -#if defined(BSD) - if (nbytes < 0) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); -#endif - - inbytes = nbytes; - if (inbytes > 8 * 1024) { - /* - * Limit stack use. - */ - inbytes = 8 * 1024; - } - ibuf = _fast_alloc(inbytes); - if (!ibuf) - SYSIO_INTERFACE_RETURN(-1, -ENOMEM); - - dp = (struct dirent *)buf; - - ibase = *basep; - cc = - PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64))(fd, - ibuf, - inbytes, - &ibase); - if (cc < 0) { - cc = -errno; - goto out; - } - *basep = (off_t )ibase; - if (sizeof(*basep) != sizeof(ibase) && *basep != ibase) { - cc = -EOVERFLOW; - goto out; - } - -#if defined(BSD) - off = *basep; -#endif - od64p = NULL; - d64p = ibuf; - for (;;) { - if (!cc) - break; -#ifdef HAVE_D_NAMLEN - n = d64p->d_namlen; -#else - n = strlen(d64p->d_name); -#endif - reclen = _dreclen(n); - if (reclen >= (unsigned )nbytes) - break; - dp->d_ino = (ino_t )d64p->d_ino; -#if !(defined(BSD)) - dp->d_off = (off_t )d64p->d_off; -#endif - if ((sizeof(dp->d_ino) != sizeof(d64p->d_ino) && - dp->d_ino != d64p->d_ino) - || -#if !(defined(BSD)) - (sizeof(dp->d_off) != sizeof(d64p->d_off) && - dp->d_off != d64p->d_off) -#else - (off + (int )reclen < off) -#endif - ) { - cc = -EOVERFLOW; - break; - } - dp->d_type = d64p->d_type; - dp->d_reclen = reclen; - nxtdp = (struct dirent *)((char *)dp + dp->d_reclen); - (void )memcpy(dp->d_name, d64p->d_name, n); - for (cp = dp->d_name + n; cp < (char *)nxtdp; *cp++ = '\0') - ; - cc -= d64p->d_reclen; - od64p = d64p; - d64p = (struct dirent64 *)((char *)d64p + d64p->d_reclen); - nbytes -= reclen; -#if defined(BSD) - off += reclen; -#endif - dp = nxtdp; - } - -out: - _fast_free(ibuf); - - if (dp == (struct dirent *)buf && cc < 0) - SYSIO_INTERFACE_RETURN(-1, (int )cc); - cc = (char *)dp - buf; - if (cc) - *basep = -#if !(defined(BSD)) - od64p->d_off; -#else - off; -#endif - SYSIO_INTERFACE_RETURN(cc, 0); - -#ifdef __GLIBC__ -#undef _fast_alloc -#undef _fast_free -#endif -#undef _dreclen -#undef _dbaselen -} -#else /* !defined(DIRENT64_IS_NATURAL) */ -sysio_sym_strong_alias(PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries64), - SYSIO_INTERFACE_NAME(getdirentries))) -#endif - -#ifdef REDSTORM -#undef __getdirentries -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(getdirentries), - PREPEND(__, SYSIO_INTERFACE_NAME(getdirentries))) -#endif -#if defined(BSD) || defined(REDSTORM) -#undef _getdirentries -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(getdirentries), - PREPEND(_, SYSIO_INTERFACE_NAME(getdirentries))) -#endif diff --git a/libsysio/src/init.c b/libsysio/src/init.c deleted file mode 100644 index 5e3e793..0000000 --- a/libsysio/src/init.c +++ /dev/null @@ -1,687 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "file.h" -#include "dev.h" - -#ifdef STDFD_DEV -#include "stdfd.h" -#endif - -/* - * The namespace assembly buffer passes args with a `name'=`value' - * syntax. We use the following to record that in various - * routines below. - */ -struct named_argument { - const char *name; /* arg name */ - char *value; /* arg value */ -}; - -/* - * White space characters. - */ -#define IGNORE_WHITE " \t\r\n" - -/* - * Sysio library initialization. Must be called before anything else in the - * library. - */ -int -_sysio_init() -{ - int err; -#ifdef WITH_SOCKETS - int _sysio_sockets_init(void); -#endif - - err = _sysio_ioctx_init(); - if (err) - goto error; - err = _sysio_i_init(); - if (err) - goto error; - err = _sysio_mount_init(); - if (err) - goto error; - - err = _sysio_dev_init(); - if (err) - goto error; -#ifdef STDFD_DEV - err = _sysio_stdfd_init(); - if (err) - goto error; -#endif -#ifdef WITH_SOCKETS - err = _sysio_sockets_init(); - if (err) - goto error; -#endif - - goto out; -error: - errno = -err; -out: - /* - * Unlike all other _sysio routines, this one returns with errno - * set. It also returns the error, as usual. - */ - return err; -} - -/* - * Sysio library shutdown. - */ -void -_sysio_shutdown() -{ - - if (!(_sysio_fd_close_all() == 0 && - _sysio_unmount_all() == 0)) - abort(); - -#if ZERO_SUM_MEMORY - _sysio_fd_shutdown(); - _sysio_i_shutdown(); - _sysio_fssw_shutdown(); -#endif -} - -/* - * (kind of)Duplicates strtok function. - * - * Given a buffer, returns the longest string - * that does not contain any delim characters. Will - * remove ws and any characters in the ignore string. - * Returns the token. - * - * The parameter controlling acceptance controls whether a positive - * match for some delimiter be made or not. If set, then either a delimiter - * or NUL character is success. - * - */ -static const char * -get_token(const char *buf, - int accepts, - const char *delim, - const char *ignore, - char *tbuf) -{ - char c; - int escape, quote; - - /* - * Find the first occurance of delim, recording how many - * characters lead up to it. Ignore indicated characters. - */ - escape = quote = 0; - while ((c = *buf) != '\0') { - buf++; - if (!escape) { - if (c == '\\') { - escape = 1; - continue; - } - if (c == '\"') { - quote ^= 1; - continue; - } - if (!quote) { - if (strchr(delim, c) != NULL) { - accepts = 1; - break; - } - if (strchr(ignore, c) != NULL) - continue; - } - } else - escape = 0; - *tbuf++ = c; - } - if (!accepts) - return NULL; - *tbuf = '\0'; /* NUL term */ - return buf; -} - -/* - * Parse and record named arguments given as `name = value', comma-separated - * pairs. - * - * NB: Alters the passed buffer. - */ -static char * -get_args(char *buf, struct named_argument *vec) -{ - char *nxt; - char *name, *value; - struct named_argument *v; - - for (;;) { - nxt = (char *)get_token(buf, 1, "=,", IGNORE_WHITE, name = buf); - if (!nxt || - (nxt != buf && *name == '\0' && buf + strlen(buf) == nxt)) { - buf = NULL; - break; - } - if (*name == '\0') - break; - buf = (char *)get_token(nxt, 1, ",", IGNORE_WHITE, value = nxt); - if (*value == '\0') - value = NULL; - for (v = vec; v->name; v++) - if (strcmp(v->name, name) == 0) - break; - if (!v->name) - return NULL; - v->value = value; - } - - return buf; -} - -static int -parse_mm(const char *s, dev_t *devp) -{ - unsigned long ul; - char *cp; - dev_t dev; - - ul = strtoul(s, &cp, 0); - if (*cp != '+' || ul > USHRT_MAX) - return -EINVAL; - dev = ul << 16; - s = (const char *)++cp; - ul = strtoul(s, &cp, 0); - if (*cp != '\0' || ul > USHRT_MAX) - return -EINVAL; - dev |= ul & 0xffff; - *devp = dev; - return 0; -} - -/* - * Performs the creat command for the namespace assembly - * - * NB: Alters the passed buffer. - */ -static int -do_creat(char *args) -{ - size_t len; - struct named_argument v[] = { - { "ft", NULL }, /* file type */ - { "nm", NULL }, /* name */ - { "pm", NULL }, /* permissions */ - { "ow", NULL }, /* owner */ - { "gr", NULL }, /* group */ - { "mm", NULL }, /* major + minor */ - { "str", NULL }, /* file data */ - { NULL, NULL } - }; - const char *cp; - long perms; - long owner, group; - struct pnode *dir, *pno; - mode_t mode; - struct intent intent; - dev_t dev; - int err; - - len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && - v[1].value && - v[2].value)) - return -EINVAL; - perms = strtol(v[2].value, (char **)&cp, 0); - if (*cp || - perms < 0 || - (perms == LONG_MAX && errno == ERANGE) || - ((unsigned)perms & ~07777)) - return -EINVAL; - if (v[3].value) { - owner = strtol(v[3].value, (char **)&cp, 0); - if (*cp || - ((owner == LONG_MIN || owner == LONG_MAX) - && errno == ERANGE)) - return -EINVAL; - } else - owner = getuid(); - if (v[4].value) { - group = strtol(v[4].value, (char **)&cp, 0); - if (*cp || - ((group == LONG_MIN || group == LONG_MAX) && - errno == ERANGE)) - return -EINVAL; - } else - group = getegid(); - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - err = 0; - mode = perms; - if (strcmp(v[0].value, "dir") == 0) { - INTENT_INIT(&intent, INT_CREAT, &mode, 0); - err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); - if (err) - return err; - if (pno->p_base->pb_ino) - err = -EEXIST; - else if (IS_RDONLY(pno->p_parent, - pno->p_parent->p_base->pb_ino)) - err = -EROFS; - else { - struct inode *ino; - - ino = pno->p_parent->p_base->pb_ino; - err = (*ino->i_ops.inop_mkdir)(pno, mode); - } - P_RELE(pno); - } else if (strcmp(v[0].value, "chr") == 0) { - if (!(v[5].value && parse_mm(v[5].value, &dev) == 0)) - return -EINVAL; - mode |= S_IFCHR; - INTENT_INIT(&intent, INT_CREAT, &mode, 0); - err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); - if (err) - return err; - if (pno->p_base->pb_ino) - err = -EEXIST; - else if (IS_RDONLY(pno->p_parent, - pno->p_parent->p_base->pb_ino)) - err = -EROFS; - else { - struct inode *ino; - - ino = pno->p_parent->p_base->pb_ino; - err = (*ino->i_ops.inop_mknod)(pno, mode, dev); - } - P_RELE(pno); - } else if (strcmp(v[0].value, "blk") == 0) { - /* - * We don't support block special files yet. - */ - return -EINVAL; - } else if (strcmp(v[0].value, "file") == 0) { - int i; - struct inode *ino; - - i = O_CREAT|O_EXCL; - INTENT_INIT(&intent, INT_CREAT, &mode, &i); - err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); - if (err) - return err; - err = _sysio_open(pno, O_CREAT|O_EXCL, mode); - if (err) { - P_RELE(pno); - return err; - } - ino = pno->p_base->pb_ino; - if (!err && v[6].value) { - struct iovec iovec; - struct intnl_xtvec xtvec; - struct ioctx io_context; - - /* - * Deposit optional file content. - */ - iovec.iov_base = v[6].value; - iovec.iov_len = strlen(v[6].value); - xtvec.xtv_off = 0; - xtvec.xtv_len = iovec.iov_len; - IOCTX_INIT(&io_context, - 1, - 1, - ino, - &iovec, 1, - &xtvec, 1); - _sysio_ioctx_enter(&io_context); - err = - (*ino->i_ops.inop_write)(pno->p_base->pb_ino, - &io_context); - if (!err) { - ssize_t cc; - - cc = _sysio_ioctx_wait(&io_context); - if (cc < 0) - err = cc; - else if ((size_t )cc != iovec.iov_len) - err = -EIO; /* huh? */ - } else - _sysio_ioctx_complete(&io_context); - } - i = (*ino->i_ops.inop_close)(ino); - if (!err) - err = i; - P_RELE(pno); - } else - err = -EINVAL; - - return err; -} - -/* - * Do mount. - * - * NB: The passed buffer is altered. - */ -static int -do_mnt(char *args) -{ - size_t len; - struct named_argument v[] = { - { "dev", NULL }, /* source (type:dev) */ - { "dir", NULL }, /* target dir */ - { "fl", NULL }, /* flags */ - { "da", NULL }, /* mount data */ - { NULL, NULL } - }; - char *ty, *name; - unsigned long flags; - struct pnode *dir; - - len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && v[1].value)) - return -EINVAL; - ty = (char *)get_token(v[0].value, 1, ":", "", name = v[0].value); - flags = 0; - if (v[2].value) { - char *cp; - - /* - * Optional flags. - */ - flags = strtoul(v[2].value, &cp, 0); - if (*cp || (flags == ULONG_MAX && errno == ERANGE)) - return -EINVAL; - } - - if (strlen(v[1].value) == 1 && v[1].value[0] == PATH_SEPARATOR) { - /* - * Aha! It's root they want. Have to do that special. - */ - return _sysio_mount_root(ty, name, flags, v[3].value); - } - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - return _sysio_mount(dir, ty, v[1].value, name, flags, v[3].value); -} - - -/* - * Chdir - * - * NB: Alters the passed buffer. - */ -static int -do_cd(char *args) -{ - size_t len; - struct named_argument v[] = { - { "dir", NULL }, /* directory */ - { NULL, NULL } - }; - int err; - struct pnode *dir, *pno; - - len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || !v[0].value) - return -EINVAL; - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - err = _sysio_namei(dir, v[0].value, 0, NULL, &pno); - if (err) - return err; - err = _sysio_p_chdir(pno); - if (err) - P_RELE(pno); - return err; -} - -/* - * Does a chmod - * - * NB: Alters passed buffer. - */ -static int -do_chmd(char *args) -{ - size_t len; - struct named_argument v[] = { - { "src", NULL }, /* path */ - { "pm", NULL }, /* perms */ - { NULL, NULL } - }; - long perms; - char *cp; - struct intnl_stat stbuf; - int err; - struct pnode *dir, *pno; - - len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && v[1].value)) - return -EINVAL; - perms = strtol(v[1].value, &cp, 0); - if (*cp || - perms < 0 || - (perms == LONG_MAX && errno == ERANGE) || - ((unsigned)perms & ~07777)) - return -EINVAL; - (void )memset(&stbuf, 0, sizeof(stbuf)); - stbuf.st_mode = (mode_t)perms; - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - err = _sysio_namei(dir, v[0].value, 0, NULL, &pno); - if (err) - return err; - err = _sysio_setattr(pno, pno->p_base->pb_ino, SETATTR_MODE, &stbuf); - P_RELE(pno); - - return err; -} - -static int -do_open(char *args) -{ - size_t len; - struct named_argument v[] = { - { "nm", NULL }, /* path */ - { "fd", NULL }, /* fildes */ - { "m", NULL }, /* mode */ - { NULL, NULL } - }; - char *cp; - int fd; - mode_t m; - struct pnode *dir, *pno; - struct intent intent; - int err; - struct file *fil; - - len = strlen(args); - if (get_args(args, v) - args != (ssize_t )len || - !(v[0].value && v[1].value && v[2].value)) - return -EINVAL; - fd = strtol(v[1].value, (char **)&cp, 0); - if (*cp || - (((fd == LONG_MIN || fd == LONG_MAX) && errno == ERANGE)) || - fd < 0) - return -EINVAL; - m = strtoul(v[1].value, (char **)&cp, 0); - if (*cp || - (m == LONG_MAX && errno == ERANGE)) - return -EINVAL; - m &= O_RDONLY|O_WRONLY|O_RDWR; - - if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) - return -ENOENT; - INTENT_INIT(&intent, INT_OPEN, &m, NULL); - pno = NULL; - err = _sysio_namei(dir, v[0].value, 0, &intent, &pno); - if (err) - return err; - fil = NULL; - do { - err = _sysio_open(pno, m, 0); - if (err) - break; - fil = _sysio_fnew(pno->p_base->pb_ino, m); - if (!fil) { - err = -ENOMEM; - break; - } - err = _sysio_fd_set(fil, fd, 1); - if (err < 0) - break; - P_RELE(pno); - return 0; - } while (0); - if (fil) - F_RELE(fil); - if (pno) - P_RELE(pno); - return err; -} - -/* - * Execute the given cmd. - * - * NB: Buf is altered. - */ -static int -do_command(char *buf) -{ - size_t len; - char *args, *cmd; - - len = strlen(buf); - args = (char *)get_token(buf, 1, ",", IGNORE_WHITE, cmd = buf); - if (args) { - if (strcmp("creat", cmd) == 0) - return do_creat(args); - if (strcmp("mnt", cmd) == 0) - return do_mnt(args); - if (strcmp("cd", cmd) == 0) - return do_cd(args); - if (strcmp("chmd", cmd) == 0) - return do_chmd(args); - if (strcmp("open", cmd) == 0) - return do_open(args); - } - return -EINVAL; -} - -/* - * Given a command sequence buffer, parse it and run the given - * commands - */ -int -_sysio_boot(const char *buf) -{ - char c, *tok; - int err; - - /* - * Allocate token buffer. - */ - tok = malloc(strlen(buf)); - if (!tok) - return -ENOMEM; - err = 0; - while (1) { - /* - * Discard leading white space. - */ - while ((c = *buf) != '\0' && - !(c == '{' || strchr(IGNORE_WHITE, c) == NULL)) - buf++; - if (c == '\0') - break; - if (c != '{') { - err = -EINVAL; - break; - } - /* - * Get the command. - */ - buf = (char *)get_token(buf + 1, 0, "}", IGNORE_WHITE, tok); - if (!buf) { - err = -EINVAL; - break; - } - /* - * Perform. - */ - err = do_command(tok); - if (err) - break; - } - free(tok); - return err; -} diff --git a/libsysio/src/inode.c b/libsysio/src/inode.c deleted file mode 100644 index 0fa2cd0..0000000 --- a/libsysio/src/inode.c +++ /dev/null @@ -1,969 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" -#include "dev.h" - -/* - * Support for path and index nodes. - */ - -/* - * Size of all names bucket-hash table. - */ -#ifndef NAMES_TABLE_LEN -#define NAMES_TABLE_LEN 251 -#endif - -/* - * Desired i-nodes cache size is MAX_INODES_MULTIPLIER times the number - * of slots in the names hash table. - */ -#define MAX_INODES_MULTIPLIER 3 - -/* - * Active i-nodes in the system and the number of same. - */ -struct inodes_head _sysio_inodes; -static size_t n_inodes = 0; -/* - * Desired number of active i-nodes. - */ -static size_t max_inodes = (MAX_INODES_MULTIPLIER * NAMES_TABLE_LEN); - -/* - * System table for rapid access to component names. - */ -static LIST_HEAD(, pnode_base) names[NAMES_TABLE_LEN]; -/* - * Number of names tracked by the system. - */ -static size_t n_names = 0; -/* - * Desired number of base path nodes to maintain. - */ -static size_t max_names = (2 * NAMES_TABLE_LEN); - -/* - * Number of pnodes to grab per memory allocation when filling the - * free list. - */ -#define PNODES_PER_CHUNK ((8 * 1024) / sizeof(struct pnode) - 2) - -#if ZERO_SUM_MEMORY -/* - * Allocation information for pnodes bulk allocation. - */ -struct pnodes_block { - LIST_ENTRY(pnodes_block) pnblk_links; - struct pnode pnblk_nodes[PNODES_PER_CHUNK]; -}; - -static LIST_HEAD( ,pnodes_block) pnblocks; -#endif - -/* - * List of all path-nodes (aliases) referenced by any tree. - */ -struct pnodes_head _sysio_pnodes; - -/* - * Free path-nodes -- Not referenced by any tree for fas reuse. - */ -static LIST_HEAD( ,pnode) free_pnodes; - -/* - * The system root -- Aka `/'. - */ -struct pnode *_sysio_root = NULL; - -/* - * Initialize path and i-node support. Must be called before any other - * routine in this module. - */ -int -_sysio_i_init() -{ - unsigned i; - - TAILQ_INIT(&_sysio_inodes); - - for (i = 0; i < NAMES_TABLE_LEN; i++) - LIST_INIT(&names[i]); - -#if ZERO_SUM_MEMORY - LIST_INIT(&pnblocks); -#endif - TAILQ_INIT(&_sysio_pnodes); - LIST_INIT(&free_pnodes); - - return 0; -} - -/* - * Garbage-collect idle i-nodes. We try to keep resource use limited to - * MAX_INODES_MULTIPLIER * max_names. - */ -static void -i_reclaim() -{ - struct inode *next, *ino; - size_t t; - - /* - * I just can't figure out a good way to reclaim these well without - * getting really fancy and using complex algorithms. The - * base nodes hold references on them for a long time and then - * release them. Those will age to the front of the queue and - * we have to skip over them. Oh well... - */ - t = MAX_INODES_MULTIPLIER * max_names; - if (max_inodes < t) { - /* - * Oops. Nope. We want more inodes than names entries. - */ - max_inodes = t; - return; - } - next = _sysio_inodes.tqh_first; - if (!next) - return; - t = max_inodes / 2; - do { - ino = next; - next = ino->i_nodes.tqe_next; - if (ino->i_ref || ino->i_immune) - continue; - _sysio_i_gone(ino); - } while (next && n_inodes > t); - - if (n_inodes > t) - max_inodes += t; -} - -static unsigned -hash(struct file_identifier *fid) -{ - size_t n; - unsigned char *ucp; - unsigned hkey; - - n = fid->fid_len; - ucp = fid->fid_data; - hkey = 0; - do { - hkey <<= 1; - hkey += *ucp++; - } while (--n); - return hkey; -} - -/* - * Allocate and initialize a new i-node. Returned i-node is referenced. - * - * NB: The passed file identifier is not copied. It is, therefor, up to the - * caller to assure that the value is static until the inode is destroyed. - */ -struct inode * -_sysio_i_new(struct filesys *fs, - struct file_identifier *fid, - mode_t type, - dev_t rdev, - unsigned immunity, - struct inode_ops *ops, - void *private) -{ - struct inode *ino; - struct itable_entry *head; - struct inode_ops operations; - - if (n_inodes > max_inodes) { - /* - * Try to limit growth. - */ - i_reclaim(); - } - - ino = malloc(sizeof(struct inode)); - if (!ino) - return NULL; - ino->i_ops = *ops; - operations = *ops; - if (S_ISBLK(type) || S_ISCHR(type) || S_ISFIFO(type)) { - struct inode_ops *o; - - /* - * Replace some operations sent with - * those from the device table. - */ - o = _sysio_dev_lookup(type, rdev); - operations.inop_open = o->inop_open; - operations.inop_close = o->inop_close; - operations.inop_read = o->inop_read; - operations.inop_write = o->inop_write; - operations.inop_pos = o->inop_pos; - operations.inop_iodone = o->inop_iodone; - operations.inop_datasync = o->inop_datasync; - operations.inop_ioctl = o->inop_ioctl; - } - I_INIT(ino, fs, type, rdev, &operations, fid, immunity, private); - ino->i_ref = 1; - TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes); - head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; - LIST_INSERT_HEAD(head, ino, i_link); - - n_inodes++; - assert(n_inodes); - - return ino; -} - -/* - * Find existing i-node given i-number and pointers to FS record - * and identifier. - */ -struct inode * -_sysio_i_find(struct filesys *fs, struct file_identifier *fid) -{ - struct inode *ino; - struct itable_entry *head; - - head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; - /* - * Look for existing. - */ - for (ino = head->lh_first; ino; ino = ino->i_link.le_next) - if (ino->i_fid->fid_len == fid->fid_len && - memcmp(ino->i_fid->fid_data, - fid->fid_data, - fid->fid_len) == 0) { - I_REF(ino); - break; - } - - return ino; -} - -/* - * Force reclaim of idle i-node. - */ -void -_sysio_i_gone(struct inode *ino) -{ - - if (ino->i_ref) - abort(); - if (!ino->i_zombie) - LIST_REMOVE(ino, i_link); - TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); - (*ino->i_ops.inop_gone)(ino); - free(ino); - - assert(n_inodes); - n_inodes--; -} - -/* - * Stale inode, zombie it and move it out of the way - */ -void -_sysio_i_undead(struct inode *ino) -{ - - LIST_REMOVE(ino, i_link); - ino->i_zombie = 1; -} - -/* - * Garbage collect idle path (and base path) nodes tracked by the system. - */ -static void -p_reclaim() -{ - struct pnode *next, *pno; - size_t t; - - next = _sysio_pnodes.tqh_first; - if (!next) - return; - t = max_names / 2; - do { - pno = next; - if (pno->p_ref) { - next = pno->p_nodes.tqe_next; - continue; - } - pno->p_ref++; - assert(pno->p_ref); - (void )_sysio_p_prune(pno); - next = pno->p_nodes.tqe_next; - assert(pno->p_ref); - pno->p_ref--; - if (pno->p_ref) - continue; - (void )_sysio_p_prune(pno); - } while (n_names > t && next); - - if (n_names > t) - max_names += t; -} - -/* - * Allocate and initialize a new base path node. - */ -struct pnode_base * -_sysio_pb_new(struct qstr *name, struct pnode_base *parent, struct inode *ino) -{ - struct pnode_base *pb; - - if (n_names > max_names) { - /* - * Try to limit growth. - */ - p_reclaim(); - } - - pb = malloc(sizeof(struct pnode_base) + name->len); - if (!pb) - return NULL; - - pb->pb_name.name = NULL; - pb->pb_name.len = name->len; - if (pb->pb_name.len) { - char *cp; - - /* - * Copy the passed name. - * - * We have put the space for the name immediately behind - * the record in order to maximize spatial locality. - */ - cp = (char *)pb + sizeof(struct pnode_base); - (void )strncpy(cp, name->name, name->len); - pb->pb_name.name = cp; - assert(name->hashval); - pb->pb_name.hashval = name->hashval; - LIST_INSERT_HEAD(&names[name->hashval % NAMES_TABLE_LEN], - pb, - pb_names); - } - pb->pb_ino = ino; - LIST_INIT(&pb->pb_children); - LIST_INIT(&pb->pb_aliases); - if (parent) - LIST_INSERT_HEAD(&parent->pb_children, pb, pb_sibs); - pb->pb_parent = parent; - - n_names++; - assert(n_names); - - return pb; -} - -/* - * Destroy base path node, releasing resources back to the system. - * - * NB: Caller must release the inode referenced by the record. - */ -static void -pb_destroy(struct pnode_base *pb) -{ - - assert(n_names); - n_names--; - - assert(!pb->pb_aliases.lh_first); - assert(!pb->pb_children.lh_first); - assert(!pb->pb_ino); - if (pb->pb_name.len) - LIST_REMOVE(pb, pb_names); - if (pb->pb_parent) - LIST_REMOVE(pb, pb_sibs); - -#ifndef NDEBUG - /* - * This can help us catch pb-nodes that are free'd redundantly. - */ - pb->pb_name.hashval = 0; -#endif - free(pb); -} - -/* - * Force reclaim of idle base path node. - */ -void -_sysio_pb_gone(struct pnode_base *pb) -{ - - if (pb->pb_ino) - I_RELE(pb->pb_ino); - pb->pb_ino = NULL; - - pb_destroy(pb); -} - -/* - * Generate more path (alias) nodes for the fast allocator. - */ -static void -more_pnodes() -{ - size_t n; -#if ZERO_SUM_MEMORY - struct pnodes_block *pnblk; -#endif - struct pnode *pno; - -#if ZERO_SUM_MEMORY - pnblk = malloc(sizeof(struct pnodes_block)); - pno = NULL; - if (pnblk) { - LIST_INSERT_HEAD(&pnblocks, pnblk, pnblk_links); - pno = pnblk->pnblk_nodes; - } -#else - pno = malloc(PNODES_PER_CHUNK * sizeof(struct pnode)); -#endif - if (!pno) - return; - n = PNODES_PER_CHUNK; - do { - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); - pno++; - } while (--n); -} - -#if ZERO_SUM_MEMORY -/* - * Shutdown - */ -void -_sysio_i_shutdown() -{ - struct pnodes_block *pnblk; - - while ((pnblk = pnblocks.lh_first)) { - LIST_REMOVE(pnblk, pnblk_links); - free(pnblk); - } -} -#endif - -/* - * Allocate, initialize and establish appropriate links for new path (alias) - * node. - */ -struct pnode * -_sysio_p_new_alias(struct pnode *parent, - struct pnode_base *pb, - struct mount *mnt) -{ - struct pnode *pno; - - assert(!pb->pb_name.name || pb->pb_name.hashval); - - pno = free_pnodes.lh_first; - if (!pno) { - more_pnodes(); - pno = free_pnodes.lh_first; - } - if (!pno) - return NULL; - LIST_REMOVE(pno, p_links); - - pno->p_ref = 1; - pno->p_parent = parent; - if (!pno->p_parent) - pno->p_parent = pno; - pno->p_base = pb; - pno->p_mount = mnt; - pno->p_cover = NULL; - LIST_INSERT_HEAD(&pb->pb_aliases, pno, p_links); - TAILQ_INSERT_TAIL(&_sysio_pnodes, pno, p_nodes); - - return pno; -} - -/* - * For reclamation of idle path (alias) node. - */ -void -_sysio_p_gone(struct pnode *pno) -{ - struct pnode_base *pb; - - assert(!pno->p_ref); - assert(!pno->p_cover); - - TAILQ_REMOVE(&_sysio_pnodes, pno, p_nodes); - LIST_REMOVE(pno, p_links); - - pb = pno->p_base; - if (!(pb->pb_aliases.lh_first || pb->pb_children.lh_first)) - _sysio_pb_gone(pb); - - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); -} - -/* - * (Re)Validate passed path node. - */ -int -_sysio_p_validate(struct pnode *pno, struct intent *intnt, const char *path) -{ - struct inode *ino; - struct pnode_base *rootpb; - int err; - - ino = pno->p_base->pb_ino; - /* - * An invalid pnode will not have an associated inode. We'll use - * the FS root inode, then -- It *must* be valid. - */ - rootpb = pno->p_mount->mnt_root->p_base; - assert(rootpb->pb_ino); - err = - rootpb->pb_ino->i_ops.inop_lookup(pno, - &ino, - intnt, - path); - /* - * If the inode lookup returns a different inode, release the old if - * present and point to the new. - */ - if (err || pno->p_base->pb_ino != ino) { - if (pno->p_base->pb_ino) - I_RELE(pno->p_base->pb_ino); - pno->p_base->pb_ino = ino; - } - return err; -} - -/* - * Find (or create!) an alias for the given parent and name. A misnomer, - * really -- This is a "get". Returned path node is referenced. - */ -int -_sysio_p_find_alias(struct pnode *parent, - struct qstr *name, - struct pnode **pnop) -{ - struct pnode_base *pb; - int err; - struct pnode *pno; - - /* - * Find the named child. - */ - if (name->len) { - /* - * Try the names table. - */ - pb = names[name->hashval % NAMES_TABLE_LEN].lh_first; - while (pb) { - if (pb->pb_parent == parent->p_base && - pb->pb_name.len == name->len && - strncmp(pb->pb_name.name, - name->name, - name->len) == 0) - break; - pb = pb->pb_names.le_next; - } - } else { - /* - * Brute force through the parent's list of children. - */ - pb = parent->p_base->pb_children.lh_first; - while (pb) { - if (pb->pb_parent == parent->p_base && - pb->pb_name.len == name->len && - strncmp(pb->pb_name.name, - name->name, - name->len) == 0) - break; - pb = pb->pb_sibs.le_next; - } - } - if (!pb) { - /* - * None found, create new child. - */ - pb = _sysio_pb_new(name, parent->p_base, NULL); - if (!pb) - return -ENOMEM; - } - /* - * Now find the proper alias. It's the one with the passed - * parent. - */ - err = 0; - pno = pb->pb_aliases.lh_first; - while (pno) { - if (pno->p_parent == parent) { - P_REF(pno); - break; - } - pno = pno->p_links.le_next; - } - if (!pno) { - /* - * Hmm. No alias. Just create an invalid one, to be - * validated later. - */ - pno = _sysio_p_new_alias(parent, pb, parent->p_mount); - if (!pno) - err = -ENOMEM; - } - if (!err) - *pnop = pno; - return err; -} - -/* - * Prune idle path base nodes freom the passed sub-tree, including the root. - */ -static void -_sysio_prune(struct pnode_base *rpb) -{ - struct pnode_base *nxtpb, *pb; - - nxtpb = rpb->pb_children.lh_first; - while ((pb = nxtpb)) { - nxtpb = pb->pb_sibs.le_next; - if (pb->pb_aliases.lh_first) - continue; - if (pb->pb_children.lh_first) { - _sysio_prune(pb); - continue; - } - _sysio_pb_gone(pb); - } - if (rpb->pb_children.lh_first) - return; - _sysio_pb_gone(rpb); -} - -/* - * Prune idle nodes from the passed sub-tree, including the root. - * - * Returns the number of aliases on the same mount that could not be pruned. - * i.e. a zero return means the entire sub-tree is gone. - */ -size_t -_sysio_p_prune(struct pnode *root) -{ - size_t count; - struct pnode_base *nxtpb, *pb; - struct pnode *nxtpno, *pno; - - count = 0; - nxtpb = root->p_base->pb_children.lh_first; - while ((pb = nxtpb)) { - nxtpb = pb->pb_sibs.le_next; - nxtpno = pb->pb_aliases.lh_first; - if (!nxtpno) { - _sysio_prune(pb); - continue; - } - while ((pno = nxtpno)) { - nxtpno = pno->p_links.le_next; - if (pno->p_mount != root->p_mount) { - /* - * Not the alias we were looking for. - */ - continue; - } - if (pno->p_base->pb_children.lh_first) { - /* - * Node is interior. Recurse. - */ - count += _sysio_p_prune(pno); - continue; - } - if (pno->p_ref) { - /* - * Can't prune; It's active. - */ - count++; - continue; - } - assert(!pno->p_cover); /* covered => ref'd! */ - assert(!pno->p_base->pb_name.name || - pno->p_base->pb_name.hashval); - /* - * Ok to prune. - */ - if (pno->p_mount->mnt_root == pno) { -#ifndef AUTOMOUNT_FILE_NAME - count++; - continue; -#else - /* - * This is an automount-point. Must - * unmount before relcaim. - */ - P_REF(pno); - if (_sysio_do_unmount(pno->p_mount) != 0) { - P_RELE(pno); - count++; - } - continue; -#endif - } - _sysio_p_gone(pno); - } - } - - if (count) { - /* - * Can't get the root or we disconnect the sub-trees. - */ - return count + (root->p_ref ? 1 : 0); - } - - /* - * All that is left is the root. Try for it too. - */ - if (root->p_ref) { - count++; - } else if (root->p_mount->mnt_root == root) { -#ifndef AUTOMOUNT_FILE_NAME - count++; -#else - /* - * This is an automount-point. Must - * unmount before relcaim. - */ - P_REF(root); - if (_sysio_do_unmount(root->p_mount) != 0) { - P_RELE(root); - count++; - } -#endif - } else - _sysio_p_gone(root); - - return count; -} - -/* - * Return path tracked by the base path node ancestor chain. - * - * Remember, base path nodes track the path relative to the file system and - * path (alias) nodes track path relative to our name space -- They cross - * mount points. - */ -char * -_sysio_pb_path(struct pnode_base *pb, const char separator) -{ - char *buf; - size_t len, n; - struct pnode_base *tmp; - char *cp; - - /* - * First pass: Traverse to the root of the sub-tree, remembering - * lengths. - */ - len = 0; - tmp = pb; - do { - n = tmp->pb_name.len; - len += tmp->pb_name.len; - if (n) - len++; - tmp = tmp->pb_parent; - } while (tmp); - if (!len) - len++; - /* - * Alloc space. - */ - buf = malloc(len + 1); - if (!buf) - return NULL; - /* - * Fill in the path buffer -- Backwards, since we're starting - * from the end. - */ - cp = buf; - *cp = separator; - cp += len; - *cp = '\0'; /* NUL term */ - tmp = pb; - do { - cp -= tmp->pb_name.len; - n = tmp->pb_name.len; - if (n) { - (void )strncpy(cp, tmp->pb_name.name, n); - *--cp = separator; - } - tmp = tmp->pb_parent; - } while (tmp); - - return buf; -} - -/* - * Common set attributes routine. - */ -int -_sysio_setattr(struct pnode *pno, - struct inode *ino, - unsigned mask, - struct intnl_stat *stbuf) -{ - /* It is possible that pno is null (for ftruncate call). */ - - if (pno) { - assert(!(pno->p_base->pb_ino && ino) || pno->p_base->pb_ino == ino); - if (IS_RDONLY(pno, ino)) - return -EROFS; - } - if (!ino && pno->p_base->pb_ino) - ino = pno->p_base->pb_ino; - return (*ino->i_ops.inop_setattr)(pno, ino, mask, stbuf); -} - -/* - * Do nothing. - */ -void -_sysio_do_noop() -{ - - return; -} - -/* - * Abort. - */ -void -_sysio_do_illop() -{ - - abort(); -} - -/* - * Return -EBADF - */ -int -_sysio_do_ebadf() -{ - - return -EBADF; -} - -/* - * Return -EINVAL - */ -int -_sysio_do_einval() -{ - - return -EINVAL; -} - -/* - * Return -ENOENT - */ -int -_sysio_do_enoent() -{ - - return -ENOENT; -} - -/* - * Return -ESPIPE - */ -int -_sysio_do_espipe() -{ - - return -ESPIPE; -} - -/* - * Return -EISDIR - */ -int -_sysio_do_eisdir() -{ - - return -EISDIR; -} - -/* - * Return -ENOSYS - */ -int -_sysio_do_enosys() -{ - - return -ENOSYS; -} - - -/* - * Return -ENODEV - */ -int -_sysio_do_enodev() -{ - - return -ENODEV; -} diff --git a/libsysio/src/ioctl.c b/libsysio/src/ioctl.c deleted file mode 100644 index d157c9b..0000000 --- a/libsysio/src/ioctl.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...) -{ - int err; - struct file *fil; - va_list ap; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - - va_start(ap, request); - err = fil->f_ino->i_ops.inop_ioctl(fil->f_ino, request, ap); - va_end(ap); - -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - - -#ifdef __GLIBC__ -#undef __ioctl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(ioctl), - PREPEND(__, SYSIO_INTERFACE_NAME(ioctl))) -#endif - -#ifdef BSD -#undef _ioctl -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(ioctl), - PREPEND(_, SYSIO_INTERFACE_NAME(ioctl))) -#endif diff --git a/libsysio/src/ioctx.c b/libsysio/src/ioctx.c deleted file mode 100644 index 4daaf32..0000000 --- a/libsysio/src/ioctx.c +++ /dev/null @@ -1,551 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "inode.h" - - -#if defined(REDSTORM) -#include -#endif - - -/* - * Asynchronous IO context support. - */ - -/* - * Arguments to IO vector enumerator callback when used by _sysio_doio(). - */ -struct doio_helper_args { - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *); /* base func */ - void *arg; /* caller arg */ -}; - -/* - * List of all outstanding (in-flight) asynch IO requests tracked - * by the system. - */ -static LIST_HEAD( ,ioctx) aioq; - -/* - * Free callback entry. - */ -#define cb_free(cb) free(cb) - -/* - * Initialization. Must be called before using any other routine in this - * module. - */ -int -_sysio_ioctx_init() -{ - - LIST_INIT(&aioq); - return 0; -} - -/* - * Enter an IO context onto the async IO events queue. - */ -void -_sysio_ioctx_enter(struct ioctx *ioctx) -{ - - LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); -} - -/* - * Allocate and initialize a new IO context. - */ -struct ioctx * -_sysio_ioctx_new(struct inode *ino, - int wr, - const struct iovec *iov, - size_t iovlen, - const struct intnl_xtvec *xtv, - size_t xtvlen) -{ - struct ioctx *ioctx; - - ioctx = malloc(sizeof(struct ioctx)); - if (!ioctx) - return NULL; - - I_REF(ino); - - IOCTX_INIT(ioctx, - 0, - wr, - ino, - iov, iovlen, - xtv, xtvlen); - - /* - * Link request onto the outstanding requests queue. - */ - _sysio_ioctx_enter(ioctx); - - return ioctx; -} - -/* - * Add an IO completion call-back to the end of the context call-back queue. - * These are called in iowait() as the last thing, right before the context - * is destroyed. - * - * They are called in order. Beware. - */ -int -_sysio_ioctx_cb(struct ioctx *ioctx, - void (*f)(struct ioctx *, void *), - void *data) -{ - struct ioctx_callback *entry; - - entry = malloc(sizeof(struct ioctx_callback)); - if (!entry) - return -ENOMEM; - - entry->iocb_f = f; - entry->iocb_data = data; - - TAILQ_INSERT_TAIL(&ioctx->ioctx_cbq, entry, iocb_next); - - return 0; -} - -/* - * Find an IO context given it's identifier. - * - * NB: This is dog-slow. If there are alot of these, we will need to change - * this implementation. - */ -struct ioctx * -_sysio_ioctx_find(void *id) -{ - struct ioctx *ioctx; - - for (ioctx = aioq.lh_first; ioctx; ioctx = ioctx->ioctx_link.le_next) - if (ioctx == id) - return ioctx; - - return NULL; -} - -/* - * Wait for asynchronous IO operation to complete, return status - * and dispose of the context. - * - * Note: - * The context is no longer valid after return. - */ -ssize_t -_sysio_ioctx_wait(struct ioctx *ioctx) -{ - ssize_t cc; - - /* - * Wait for async operation to complete. - */ - while (!(ioctx->ioctx_done || - (*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx))) - ; - - /* - * Get status. - */ - cc = ioctx->ioctx_cc; - if (cc < 0) - cc = -ioctx->ioctx_errno; - - /* - * Dispose. - */ - _sysio_ioctx_complete(ioctx); - - return cc; -} - -/* - * Free callback entry. - */ -void -_sysio_ioctx_cb_free(struct ioctx_callback *cb) -{ - - cb_free(cb); -} - -/* - * Complete an asynchronous IO request. - */ -void -_sysio_ioctx_complete(struct ioctx *ioctx) -{ - struct ioctx_callback *entry; - - - /* update IO stats */ - _SYSIO_UPDACCT(ioctx->ioctx_write, ioctx); - - /* - * Run the call-back queue. - */ - while ((entry = ioctx->ioctx_cbq.tqh_first)) { - TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next); - (*entry->iocb_f)(ioctx, entry->iocb_data); - cb_free(entry); - } - - /* - * Unlink from the file record's outstanding request queue. - */ - LIST_REMOVE(ioctx, ioctx_link); - - if (ioctx->ioctx_fast) - return; - - I_RELE(ioctx->ioctx_ino); - - free(ioctx); -} - -/* - * General help validating strided-IO vectors. - * - * A driver may call this to make sure underflow/overflow of an off_t can't - * occur and overflow of a ssize_t can't occur when writing. The sum - * of the reconciled transfer length is returned or some appropriate - * error depending on underflow/overflow. - * - * The following algorithm assumes: - * - * a) sizeof(size_t) >= sizeof(ssize_t) - * b) 2's complement arithmetic - * c) The compiler won't optimize away code because it's developers - * believed that something with an undefined result in `C' can't happen. - */ -ssize_t -_sysio_validx(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - _SYSIO_OFF_T limit) -{ - ssize_t acc, cc; - struct iovec iovec; - struct intnl_xtvec xtvec; - _SYSIO_OFF_T off; - - if (!(xtvlen && iovlen)) - return -EINVAL; - - acc = 0; - xtvec.xtv_len = iovec.iov_len = 0; - do { - while (!xtvec.xtv_len) { - if (!xtvlen--) - break; - if (!xtv->xtv_len) { - xtv++; - continue; - } - xtvec = *xtv++; - if (xtvec.xtv_off < 0) - return -EINVAL; - } - if (!xtvec.xtv_len) - break; - do { - while (!iovec.iov_len) { - if (!iovlen--) - break; - if (!iov->iov_len) { - iov++; - continue; - } - iovec = *iov++; - } - if (!iovec.iov_len) - break; - cc = iovec.iov_len; - if (cc < 0) - return -EINVAL; - if ((size_t )cc > xtvec.xtv_len) - cc = xtvec.xtv_len; - xtvec.xtv_len -= cc; - iovec.iov_len -= cc; - off = xtvec.xtv_off + cc; - if (xtvec.xtv_off && off <= xtvec.xtv_off) - return off < 0 ? -EINVAL : -EOVERFLOW; - if (off > limit) - return -EFBIG; - xtvec.xtv_off = off; - cc += acc; - if (acc && (cc <= acc)) - return -EINVAL; - acc = cc; - } while (xtvec.xtv_len && iovlen); - } while ((xtvlen || xtvec.xtv_len) && iovlen); - return acc; -} - -/* - */ -ssize_t -_sysio_enumerate_extents(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - ssize_t (*f)(const struct iovec *, int, - _SYSIO_OFF_T, - ssize_t, - void *), - void *arg) -{ - ssize_t acc, tmp, cc; - struct iovec iovec; - struct intnl_xtvec xtvec; - const struct iovec *start; - _SYSIO_OFF_T off; - size_t n; - size_t remain; - - acc = 0; - iovec.iov_len = 0; - while (xtvlen) { - /* - * Coalesce contiguous extent vector entries. - */ - off = xtvec.xtv_off = xtv->xtv_off; - off += xtvec.xtv_len = xtv->xtv_len; - while (++xtv, --xtvlen) { - if (off != xtv->xtv_off) { - /* - * Not contiguous. - */ - break; - } - if (!xtv->xtv_len) { - /* - * Zero length. - */ - continue; - } - off += xtv->xtv_len; - xtvec.xtv_len += xtv->xtv_len; - } - while (xtvec.xtv_len) { - if (iovec.iov_len) { - tmp = iovec.iov_len; - if (iovec.iov_len > xtvec.xtv_len) - iovec.iov_len = xtvec.xtv_len; - cc = - (*f)(&iovec, 1, - xtvec.xtv_off, - xtvec.xtv_len, - arg); - if (cc <= 0) { - if (acc) - return acc; - return cc; - } - iovec.iov_base = (char *)iovec.iov_base + cc; - iovec.iov_len = tmp - cc; - tmp = cc + acc; - if (acc && tmp <= acc) - abort(); /* paranoia */ - acc = tmp; - } else if (iovlen) { - start = iov; - n = xtvec.xtv_len; - do { - if (iov->iov_len > n) { - /* - * That'll do. - */ - break; - } - n -= iov->iov_len; - iov++; - } while (--iovlen); - if (iov == start) { - iovec = *iov++; - iovlen--; - continue; - } - remain = xtvec.xtv_len - n; - cc = - (*f)(start, iov - start, - xtvec.xtv_off, - remain, - arg); - if (cc <= 0) { - if (acc) - return acc; - return cc; - } - - tmp = cc + acc; - if (acc && tmp <= acc) - abort(); /* paranoia */ - acc = tmp; - - remain -= cc; - if (remain) - return acc; /* short */ - } else - return acc; /* short out */ - xtvec.xtv_off += cc; - xtvec.xtv_len -= cc; - } - } - return acc; -} - -ssize_t -_sysio_enumerate_iovec(const struct iovec *iov, size_t count, - _SYSIO_OFF_T off, - ssize_t limit, - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), - void *arg) -{ - ssize_t acc, cc; - size_t n; - unsigned indx; - size_t remain; - - if (!count) - return -EINVAL; - assert(limit >= 0); - acc = 0; - n = limit; - for (indx = 0; n && indx < count; indx++) { - if (iov[indx].iov_len < n) { - cc = (ssize_t )iov[indx].iov_len; - if (cc < 0) - return -EINVAL; - } else - cc = (ssize_t )n; - if (!cc) - continue; - n -= cc; - cc += acc; - if (acc && cc <= acc) - return -EINVAL; - acc = cc; - } - if (!acc) - return 0; - acc = 0; - do { - if (!iov->iov_len) { - iov++; - continue; - } - n = - iov->iov_len < (size_t )limit - ? iov->iov_len - : (size_t )limit; - cc = (*f)(iov->iov_base, n, off, arg); - if (cc <= 0) { - if (acc) - return acc; - return cc; - } - off += cc; - limit -= cc; - remain = iov->iov_len - cc; - cc += acc; - if (acc && cc <= acc) - abort(); /* bad driver! */ - acc = cc; - if (remain || !limit) - break; /* short/limited read */ - iov++; - } while (--count); - return acc; -} - -static ssize_t -_sysio_doio_helper(const struct iovec *iov, int count, - _SYSIO_OFF_T off, - ssize_t limit, - struct doio_helper_args *args) -{ - - return _sysio_enumerate_iovec(iov, count, - off, limit, - args->f, - args->arg); -} - -/* - * A meta-driver for the whole strided-io process. Appropriate when - * the driver can't handle anything but simple p{read,write}-like - * interface. - */ -ssize_t -_sysio_doio(const struct intnl_xtvec *xtv, size_t xtvlen, - const struct iovec *iov, size_t iovlen, - ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), - void *arg) -{ - struct doio_helper_args arguments; - - arguments.f = f; - arguments.arg = arg; - return _sysio_enumerate_extents(xtv, xtvlen, - iov, iovlen, - (ssize_t (*)(const struct iovec *, int, - _SYSIO_OFF_T, - ssize_t, - void *))_sysio_doio_helper, - &arguments); -} diff --git a/libsysio/src/iowait.c b/libsysio/src/iowait.c deleted file mode 100644 index e52ec2f..0000000 --- a/libsysio/src/iowait.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include - -#include "sysio.h" -#include "inode.h" - -/* - * Asynch IO support for the API. - */ - -/* - * Poll status of asynch IO request. - */ -int -SYSIO_INTERFACE_NAME(iodone)(void *ioid) -{ - struct ioctx *ioctx; - int rc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - ioctx = _sysio_ioctx_find(ioid); - if (!ioctx) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); - - rc = - (ioctx->ioctx_done || - (*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx)); - - SYSIO_INTERFACE_RETURN(rc < 0 ? -1 : rc, rc < 0 ? rc : 0); -} - -/* - * Wait for completion of and return results from identified asynch IO - * request. - * - * The identifier is no longer valid after return. - */ -ssize_t -SYSIO_INTERFACE_NAME(iowait)(void *ioid) -{ - struct ioctx *ioctx; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - ioctx = _sysio_ioctx_find(ioid); - if (!ioctx) - SYSIO_INTERFACE_RETURN(-1, -EINVAL); - - cc = _sysio_ioctx_wait(ioctx); - SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); -} diff --git a/libsysio/src/link.c b/libsysio/src/link.c deleted file mode 100644 index 4c278b5..0000000 --- a/libsysio/src/link.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "mount.h" -#include "inode.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath) -{ - struct intent intent; - int err; - struct pnode *old, *new; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, 0, NULL, NULL); - err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); - if (err) - goto out; - if (S_ISDIR(old->p_base->pb_ino->i_mode)) { - err = -EPERM; - goto error1; - } - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - new = NULL; - err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); - if (err) - goto error1; - if (new->p_base->pb_ino) { - err = -EEXIST; - goto error2; - } - if (old->p_mount->mnt_root != new->p_mount->mnt_root) { - err = -EXDEV; - goto error2; - } - err = old->p_base->pb_ino->i_ops.inop_link(old, new); - if (err) - goto error2; - /* - * The new p-node must be pointed at the inode referenced by the old. - */ - assert(!new->p_base->pb_ino && old->p_base->pb_ino); - new->p_base->pb_ino = old->p_base->pb_ino; - I_REF(new->p_base->pb_ino); - -error2: - P_RELE(new); -error1: - P_RELE(old); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __link -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(link), - PREPEND(__, SYSIO_INTERFACE_NAME(link))) -#endif diff --git a/libsysio/src/lseek.c b/libsysio/src/lseek.c deleted file mode 100644 index b046ec4..0000000 --- a/libsysio/src/lseek.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -static _SYSIO_OFF_T -_sysio_lseek(int fd, _SYSIO_OFF_T offset, int whence) -{ - struct file *fil; - _SYSIO_OFF_T off, pos; - struct intnl_stat stbuf; - - fil = _sysio_fd_find(fd); - if (!fil) - return -EBADF; - - off = -1; - switch (whence) { - - case SEEK_SET: - off = 0; - break; - case SEEK_CUR: - off = fil->f_pos; - break; - case SEEK_END: - { - int err; - - err = - (*fil->f_ino->i_ops.inop_getattr)(NULL, - fil->f_ino, - &stbuf); - if (err) - return err; - - } - off = stbuf.st_size; - break; - default: - return -EINVAL; - } - pos = off + offset; - if ((offset < 0 && -offset > off) || (offset > 0 && pos <= off)) - return -EINVAL; - -#ifdef O_LARGEFILE - if (pos >= ((fil->f_flags & O_LARGEFILE) ? _SYSIO_OFF_T_MAX : LONG_MAX)) - return -EOVERFLOW; -#else - if (pos >= _SYSIO_OFF_T_MAX) - return -EOVERFLOW; -#endif - pos = (fil->f_ino->i_ops.inop_pos)(fil->f_ino, pos); - if (pos < 0) - return pos; - fil->f_pos = pos; - return pos; -} - -#if _LARGEFILE64_SOURCE -#undef lseek64 - -extern off64_t -SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, int whence) -{ - _SYSIO_OFF_T off; - off_t rtn; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - off = _sysio_lseek(fd, offset, whence); - if (off < 0) - SYSIO_INTERFACE_RETURN((off_t )-1, (int )off); - rtn = (off64_t )off; - assert(rtn == off); - SYSIO_INTERFACE_RETURN(rtn, 0); -} -#ifdef __GLIBC__ -#undef __lseek64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(lseek64), - PREPEND(__, SYSIO_INTERFACE_NAME(lseek64))) -#endif -#ifdef REDSTORM -#undef __libc_lseek64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(lseek64), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_lseek64))) -#endif -#endif - -#undef lseek - -extern off_t -SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence) -{ - _SYSIO_OFF_T off; - off_t rtn; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - off = _sysio_lseek(fd, offset, whence); - if (off < 0) - SYSIO_INTERFACE_RETURN((off_t )-1, (int )off); - rtn = (off_t )off; - assert(rtn == off); - SYSIO_INTERFACE_RETURN(rtn, 0); -} - -#ifdef __GLIBC__ -#undef __lseek -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(lseek), - PREPEND(__, SYSIO_INTERFACE_NAME(lseek))) -#endif - -#if 0 -#ifdef __linux__ -#undef llseek -int -SYSIO_INTERFACE_NAME(llseek)(unsigned int fd __IS_UNUSED, - unsigned long offset_high __IS_UNUSED, - unsigned long offset_low __IS_UNUSED, - loff_t *result __IS_UNUSED, - unsigned int whence __IS_UNUSED) -{ - SYSIO_INTERFACE_DISPLAY_BLOCK; - - /* - * Something is very wrong if this was called. - */ - SYSIO_INTERFACE_ENTER; - SYSIO_INTERFACE_RETURN(-1, -ENOTSUP); -} - -#undef __llseek -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(llseek), - PREPEND(__, SYSIO_INTERFACE_NAME(llseek))) -#endif -#endif diff --git a/libsysio/src/mkdir.c b/libsysio/src/mkdir.c deleted file mode 100644 index c4c6cb5..0000000 --- a/libsysio/src/mkdir.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode) -{ - int err; - struct intent intent; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno); - if (err) - goto out; - if (pno->p_base->pb_ino) { - err = -EEXIST; - goto error; - } - - if (IS_RDONLY(pno, pno->p_base->pb_ino)) { - err = -EROFS; - goto error; - } - err = (*pno->p_parent->p_base->pb_ino->i_ops.inop_mkdir)(pno, mode); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __mkdir -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(mkdir), - PREPEND(__, SYSIO_INTERFACE_NAME(mkdir))) -#endif diff --git a/libsysio/src/mknod.c b/libsysio/src/mknod.c deleted file mode 100644 index 4c947d2..0000000 --- a/libsysio/src/mknod.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#if defined(__linux__) -#define _BSD_SOURCE -#endif - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" - -#include "sysio-symbols.h" - -#undef mknod -#undef __xmknod - -#if defined(BSD) || defined(REDSTORM) -#define _MKNOD_VER 0 -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(xmknod))(int __ver, - const char *path, - mode_t mode, - dev_t *dev) -{ - int err; - struct intent intent; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _MKNOD_VER) { - err = -ENOSYS; - goto out; - } - - /* - * Support only character-special and fifos right now. - */ - if (!(S_ISCHR(mode) || S_ISFIFO(mode))) { - err = -EINVAL; - goto out; - } - - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno); - if (err) - goto out; - if (pno->p_base->pb_ino) { - err = -EEXIST; - goto error; - } - - if (IS_RDONLY(pno, pno->p_base->pb_ino)) { - err = -EROFS; - goto error; - } - err = - (*pno->p_parent->p_base->pb_ino->i_ops.inop_mknod)(pno, mode, *dev); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _xmknod -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(xmknod)), - PREPEND(_, SYSIO_INTERFACE_NAME(xmknod))) -#endif - -static int -PREPEND(__, SYSIO_INTERFACE_NAME(mknod))(const char *path, - mode_t mode, - dev_t dev) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(xmknod))(_MKNOD_VER, - path, - mode, - &dev); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(mknod)), - SYSIO_INTERFACE_NAME(mknod)) diff --git a/libsysio/src/module.mk b/libsysio/src/module.mk deleted file mode 100644 index fc3208b..0000000 --- a/libsysio/src/module.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Note; Remove statvfs{,64}.c until we decide what to do with them. -# Lee; Tue Feb 24 09:37:32 EST 2004 -# - -if WITH_LUSTRE_HACK -FILE_SUPPORT = src/file_hack.c -else -FILE_SUPPORT = src/file.c -endif - -if WITH_LUSTRE_HACK -LUSTRE_SRCDIR_SRCS = src/stdlib.c -else -LUSTRE_SRCDIR_SRCS = -endif - -SRCDIR_SRCS = src/access.c src/chdir.c src/chmod.c \ - src/chown.c src/dev.c src/dup.c src/fcntl.c \ - src/fs.c src/fsync.c \ - src/getdirentries.c src/init.c src/inode.c \ - src/ioctl.c src/ioctx.c src/iowait.c \ - src/link.c src/lseek.c src/mkdir.c \ - src/mknod.c src/mount.c src/namei.c \ - src/open.c src/rw.c src/rename.c \ - src/rmdir.c src/stat64.c src/stat.c \ - src/symlink.c src/readlink.c \ - src/truncate.c src/unlink.c src/utime.c \ - $(FILE_SUPPORT) $(LUSTRE_SRCDIR_SRCS) - -SRCDIR_EXTRA = src/module.mk diff --git a/libsysio/src/mount.c b/libsysio/src/mount.c deleted file mode 100644 index 8785bb0..0000000 --- a/libsysio/src/mount.c +++ /dev/null @@ -1,677 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#ifdef AUTOMOUNT_FILE_NAME -#include -#include -#endif -#include - -#include "xtio.h" -#include "sysio.h" -#include "fs.h" -#include "mount.h" -#include "inode.h" - -/* - * File system and volume mount support. - */ - -#ifdef AUTOMOUNT_FILE_NAME -/* - * Name of autmount specification file in a directory with - * the sticky-bit set. - */ -struct qstr _sysio_mount_file_name = { "", 0, 0 }; -#endif - -/* - * Active mounts. - */ -static LIST_HEAD(, mount) mounts; - -/* - * Initialization. Must be called before any other routine in this module. - */ -int -_sysio_mount_init() -{ - - LIST_INIT(&mounts); -#ifdef AUTOMOUNT_FILE_NAME - _sysio_next_component(AUTOMOUNT_FILE_NAME, &_sysio_mount_file_name); -#endif - - return 0; -} - -/* - * Mount rooted sub-tree somewhere in the existing name space. - */ -int -_sysio_do_mount(struct filesys *fs, - struct pnode_base *rootpb, - unsigned flags, - struct pnode *tocover, - struct mount **mntp) -{ - struct mount *mnt; - int err; - - /* - * It's really poor form to allow the new root to be a - * descendant of the pnode being covered. - */ - if (tocover) { - struct pnode_base *pb; - - for (pb = rootpb; - pb && pb != tocover->p_base; - pb = pb->pb_parent) - ; - if (pb == tocover->p_base) - return -EBUSY; - } - - /* - * Alloc - */ - mnt = malloc(sizeof(struct mount)); - if (!mnt) - return -ENOMEM; - err = 0; - /* - * Init enough to make the mount record usable to the path node - * generation routines. - */ - mnt->mnt_fs = fs; - if (fs->fs_flags & FS_F_RO) { - /* - * Propagate the read-only flag -- Whether they set it or not. - */ - flags |= MOUNT_F_RO; - } - mnt->mnt_flags = flags; - /* - * Get alias for the new root. - */ - mnt->mnt_root = - _sysio_p_new_alias(tocover ? tocover->p_parent : NULL, rootpb, mnt); - if (!mnt->mnt_root) { - err = -ENOMEM; - goto error; - } - /* - * It may have been a while since the root inode was validated; - * better validate again. And it better be a directory! - */ - err = _sysio_p_validate(mnt->mnt_root, NULL, NULL); - if (err) - goto error; - - if (!S_ISDIR(mnt->mnt_root->p_base->pb_ino->i_mode)) { - err = -ENOTDIR; - goto error; - } - /* - * Cover up the mount point. - */ - mnt->mnt_covers = tocover; - if (!mnt->mnt_covers) { - /* - * New graph; It covers itself. - */ - mnt->mnt_covers = tocover = mnt->mnt_root; - } - tocover->p_cover = mnt->mnt_root; - - LIST_INSERT_HEAD(&mounts, mnt, mnt_link); - - *mntp = mnt; - return 0; - -error: - if (mnt->mnt_root) { - P_RELE(mnt->mnt_root); - _sysio_p_prune(mnt->mnt_root); - } - free(mnt); - return err; -} - -/* - * Remove mounted sub-tree from the system. - */ -int -_sysio_do_unmount(struct mount *mnt) -{ - struct pnode *root; - struct filesys *fs; - - root = mnt->mnt_root; - if (root->p_cover && root->p_cover != root) { - /* - * Active mount. - */ - return -EBUSY; - } - assert(mnt->mnt_covers->p_cover == root); - if (_sysio_p_prune(root) != 1) { - /* - * Active aliases. - */ - return -EBUSY; - } - /* - * We're committed. - * - * Drop ref of covered pnode and break linkage in name space. - */ - if (root->p_cover != root) - P_RELE(mnt->mnt_covers); - mnt->mnt_covers->p_cover = NULL; - LIST_REMOVE(mnt, mnt_link); - /* - * Kill the root. - */ - P_RELE(root); - root->p_cover = NULL; - _sysio_p_gone(root); - /* - * Release mount record resource. - */ - fs = mnt->mnt_fs; - free(mnt); - FS_RELE(fs); - - return 0; -} - -/* - * Establish the system name space. - */ -int -_sysio_mount_root(const char *source, - const char *fstype, - unsigned flags, - const void *data) -{ - struct fsswent *fssw; - int err; - struct mount *mnt; - - if (_sysio_root) - return -EBUSY; - - fssw = _sysio_fssw_lookup(fstype); - if (!fssw) - return -ENODEV; - - err = (*fssw->fssw_ops.fsswop_mount)(source, flags, data, NULL, &mnt); - if (err) - return err; - - _sysio_root = mnt->mnt_root; - /* - * It is very annoying to have to set the current working directory. - * So... If it isn't set, make it the root now. - */ - if (!_sysio_cwd) { - _sysio_cwd = _sysio_root; - P_REF(_sysio_cwd); - } - - return 0; -} - -int -_sysio_mount(struct pnode *cwd, - const char *source, - const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data) -{ - int err; - struct fsswent *fssw; - struct intent intent; - struct pnode *tgt; - struct mount *mnt; - - /* - * Find the file system switch entry specified. - */ - fssw = _sysio_fssw_lookup(filesystemtype); - if (!fssw) - return -ENODEV; - - /* - * Look up the target path node. - */ - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(cwd, target, 0, &intent, &tgt); - if (err) - return err; - - if (tgt == _sysio_root) { - /* - * Attempting to mount over root. - */ - err = -EBUSY; - } else { - /* - * Do the deed. - */ - err = - (*fssw->fssw_ops.fsswop_mount)(source, - mountflags, - data, - tgt, - &mnt); - } - if (err) - P_RELE(tgt); - return err; -} - -int -SYSIO_INTERFACE_NAME(mount)(const char *source, - const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data) -{ - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = - _sysio_mount(_sysio_cwd, - source, - target, - filesystemtype, - mountflags, - data); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -int -SYSIO_INTERFACE_NAME(umount)(const char *target) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - /* - * Look up the target path node. - */ - err = _sysio_namei(_sysio_cwd, target, 0, NULL, &pno); - if (err) - goto out; - P_RELE(pno); /* was ref'd */ - - /* - * Do the deed. - */ -#if 0 - if (!pno->p_cover) { - err = -EINVAL; - goto error; - } -#endif - assert(pno->p_mount); - err = _sysio_do_unmount(pno->p_mount); - -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -/* - * Unmount all file systems -- Usually as part of shutting everything down. - */ -int -_sysio_unmount_all() -{ - int err; - struct mount *mnt, *nxt; - struct pnode *pno; - - err = 0; - nxt = mounts.lh_first; - while ((mnt = nxt)) { - nxt = mnt->mnt_link.le_next; - pno = mnt->mnt_root; - /* - * If this is an automount generated mount, the root - * has no reference. We can cause the dismount with a - * simple prune. - */ - if (!_sysio_p_prune(pno)) - continue; -#ifdef notdef - /* - * Need a ref but only if this is not the root of a - * disconnected graph. If it is, then it is covered by itself - * and, so, already referenced. - */ - if (pno->p_cover != pno) - P_REF(pno); -#endif - err = _sysio_do_unmount(mnt); - if (err) { -#ifdef notdef - if (pno->p_cover != pno) - P_RELE(pno); -#endif - break; - } - if (pno == _sysio_root) - _sysio_root = NULL; - } - - return err; -} - -#ifdef AUTOMOUNT_FILE_NAME -/* - * Parse automount specification formatted as: - * - * :[[ \t]+] - * - * NB: - * The buffer sent is (almost) always modified. - */ -static int -parse_automount_spec(char *s, char **fstyp, char **srcp, char **optsp) -{ - int err; - char *cp; - char *fsty, *src, *opts; - - err = 0; - - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get fstype. - */ - fsty = cp = s; - while (*cp && - *cp != ':' && - *cp != ' ' && - *cp != '\t' && - *cp != '\r' && - *cp != '\n') - cp++; - if (fsty == cp || *cp != ':') - goto error; - *cp++ = '\0'; - - s = cp; - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get source. - */ - src = cp = s; - while (*cp && - *cp != ' ' && - *cp != '\t' && - *cp != '\r' && - *cp != '\n') - cp++; - if (src == cp) - goto error; - if (*cp) - *cp++ = '\0'; - - s = cp; - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get opts. - */ - opts = cp = s; - while (*cp && - *cp != ' ' && - *cp != '\t' && - *cp != '\r' && - *cp != '\n') - cp++; - if (opts == cp) - opts = NULL; - if (*cp) - *cp++ = '\0'; - - if (*cp) - goto error; - - *fstyp = fsty; - *srcp = src; - *optsp = opts; - return 0; - -error: - return -EINVAL; -} - -/* - * Parse (and strip) system mount options. - */ -static char * -parse_opts(char *opts, unsigned *flagsp) -{ - unsigned flags; - char *src, *dst; - char *cp; - - flags = 0; - src = dst = opts; - for (;;) { - cp = src; - while (*cp && *cp != ',') - cp++; - if (src + 2 == cp && strncmp(src, "rw", 2) == 0) { - /* - * Do nothing. This is the default. - */ - src += 2; - } else if (src + 2 == cp && strncmp(src, "ro", 2) == 0) { - /* - * Read-only. - */ - flags |= MOUNT_F_RO; - src += 2; - } - else if (src + 4 == cp && strncmp(src, "auto", 4) == 0) { - /* - * Enable automounts. - */ - flags |= MOUNT_F_AUTO; - src += 4; - } - if (src < cp) { - /* - * Copy what we didn't consume. - */ - if (dst != opts) - *dst++ = ','; - do - *dst++ = *src++; - while (src != cp); - } - if (!*src) - break; - *dst = '\0'; - src++; /* skip comma */ - } - *dst = '\0'; - - *flagsp = flags; - return opts; -} - -/* - * Attempt automount over the given directory. - */ -int -_sysio_automount(struct pnode *mntpno) -{ - int err; - struct inode *ino; - struct intnl_stat stbuf; - struct iovec iovec; - struct ioctx iocontext; - struct intnl_xtvec xtvec; - ssize_t cc; - char *fstype, *source, *opts; - unsigned flags; - struct fsswent *fssw; - struct mount *mnt; - - /* - * Revalidate -- Paranoia. - */ - err = _sysio_p_validate(mntpno, NULL, NULL); - if (err) - return err; - - /* - * Read file content. - */ - ino = mntpno->p_base->pb_ino; - err = (*ino->i_ops.inop_getattr)(mntpno, ino, &stbuf); - if (err) - return err; - if (stbuf.st_size > 64 * 1024) { - /* - * Let's be reasonable. - */ - return -EINVAL; - } - iovec.iov_base = malloc(stbuf.st_size + 1); - if (!iovec.iov_base) - return -ENOMEM; - iovec.iov_len = stbuf.st_size; - err = _sysio_open(mntpno, O_RDONLY, 0); - if (err) - goto out; - xtvec.xtv_off = 0; - xtvec.xtv_len = stbuf.st_size; - IOCTX_INIT(&iocontext, - 1, - 0, - ino, - &iovec, 1, - &xtvec, 1); - _sysio_ioctx_enter(&iocontext); - err = (*ino->i_ops.inop_read)(ino, &iocontext); - if (err) { - _sysio_ioctx_complete(&iocontext); - (void )(*ino->i_ops.inop_close)(ino); - goto out; - } - cc = _sysio_ioctx_wait(&iocontext); - err = (*ino->i_ops.inop_close)(ino); - if (err) - goto out; - if (cc < 0) { - err = (int )cc; - goto out; - } - ((char *)iovec.iov_base)[cc] = '\0'; - - /* - * Parse. - */ - err = parse_automount_spec(iovec.iov_base, &fstype, &source, &opts); - if (err) - goto out; - flags = 0; - if (opts) - opts = parse_opts(opts, &flags); - - /* - * Find the file system switch entry specified. - */ - fssw = _sysio_fssw_lookup(fstype); - if (!fssw) { - err = -ENODEV; - goto out; - } - - /* - * Do the deed. - */ - P_REF(mntpno->p_parent); - err = - (*fssw->fssw_ops.fsswop_mount)(source, - flags, - opts, - mntpno->p_parent, - &mnt); - if (err) - P_RELE(mntpno->p_parent); - -out: - if (iovec.iov_base) - free(iovec.iov_base); - return err; -} -#endif diff --git a/libsysio/src/namei.c b/libsysio/src/namei.c deleted file mode 100644 index b4d8569..0000000 --- a/libsysio/src/namei.c +++ /dev/null @@ -1,471 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#if defined(AUTOMOUNT_FILE_NAME) && defined(__linux__) -#define _BSD_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "mount.h" -#include "inode.h" - -/* - * Parse next component in path. - */ -#ifndef AUTOMOUNT_FILE_NAME -static -#endif -void -_sysio_next_component(const char *path, struct qstr *name) -{ - while (*path == PATH_SEPARATOR) - path++; - name->name = path; - name->len = 0; - name->hashval = 0; - while (*path && *path != PATH_SEPARATOR) { - name->hashval = - 37 * name->hashval + *path++; - name->len++; - } -} - -/* - * Given parent, look up component. - */ -static int -lookup(struct pnode *parent, - struct qstr *name, - struct pnode **pnop, - struct intent *intnt, - const char *path) -{ - struct pnode *pno; - int err; - - if (!parent->p_base->pb_ino) - return -ENOTDIR; - - /* - * Short-circuit `.' and `..'; We don't cache those. - */ - pno = NULL; - if (name->len == 1 && name->name[0] == '.') - pno = parent; - else if (name->len == 2 && name->name[0] == '.' && name->name[1] == '.') - pno = parent->p_parent; - if (pno) - P_REF(pno); - else { - /* - * Get cache entry then. - */ - err = _sysio_p_find_alias(parent, name, &pno); - if (err) - return err; - } - - /* - * While covered, move to the covering node. - */ - while (pno->p_cover && pno->p_cover != pno) { - struct pnode *cover; - - cover = pno->p_cover; - P_REF(cover); - P_RELE(pno); - pno = cover; - } - - *pnop = pno; - - /* - * (Re)validate the pnode. - */ - err = _sysio_p_validate(pno, intnt, path); - if (err) - return err; - - return 0; -} - -/* - * The meat. Walk an absolute or relative path, looking up each - * component. Various flags in the nameidata argument govern actions - * and return values/state. They are: - * - * ND_NOFOLLOW symbolic links are not followed - * ND_NEGOK if terminal/leaf does not exist, return - * path node (alias) anyway. - */ -int -_sysio_path_walk(struct pnode *parent, struct nameidata *nd) -{ - int err; - const char *path; - struct qstr this, next; - struct inode *ino; - - /* - * NULL path? - */ - if (!nd->nd_path) - return -EFAULT; - - /* - * Empty path? - */ - if (!*nd->nd_path) - return -ENOENT; - - /* - * Leading slash? - */ - if (*nd->nd_path == PATH_SEPARATOR) { - /* - * Make parent the root of the name space. - */ - parent = nd->nd_root; - } - - /* - * (Re)Validate the parent. - */ - err = _sysio_p_validate(parent, NULL, NULL); - if (err) - return err; - - /* - * Prime everything for the loop. Will need another reference to the - * initial directory. It'll be dropped later. - */ - nd->nd_pno = parent; - P_REF(nd->nd_pno); - _sysio_next_component(nd->nd_path, &next); - path = next.name; - parent = NULL; - err = 0; - - /* - * Derecurse the path tree-walk. - */ - for (;;) { - ino = nd->nd_pno->p_base->pb_ino; - if (S_ISLNK(ino->i_mode) && - (next.len || !(nd->nd_flags & ND_NOFOLLOW))) { - char *lpath; - ssize_t cc; - struct nameidata nameidata; - - if (nd->nd_slicnt >= MAX_SYMLINK) { - err = -ELOOP; - break; - } - - /* - * Follow symbolic link. - */ - lpath = malloc(MAXPATHLEN + 1); - if (!lpath) { - err = -ENOMEM; - break; - } - cc = - ino->i_ops.inop_readlink(nd->nd_pno, - lpath, - MAXPATHLEN); - if (cc < 0) { - free(lpath); - err = (int )cc; - break; - } - lpath[cc] = '\0'; /* NUL term */ - /* - * Handle symbolic links with recursion. Yuck! - */ - ND_INIT(&nameidata, - (nd->nd_flags | ND_NEGOK), - lpath, - nd->nd_root, - nd->nd_intent); - nameidata.nd_slicnt = nd->nd_slicnt + 1; - err = - _sysio_path_walk(nd->nd_pno->p_parent, &nameidata); - free(lpath); - if (err) - break; - P_RELE(nd->nd_pno); - nd->nd_pno = nameidata.nd_pno; - ino = nd->nd_pno->p_base->pb_ino; - } -#ifdef AUTOMOUNT_FILE_NAME - else if (ino && - S_ISDIR(ino->i_mode) && - (nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO) && - nd->nd_amcnt < MAX_MOUNT_DEPTH && - ino->i_mode & S_ISUID) { - struct pnode *pno; - - /* - * We're committed to a lookup. It's time to see if - * we're going to do it in an automount-point and - * arrange the mount if so. - */ - assert(!nd->nd_pno->p_cover); - err = - lookup(nd->nd_pno, - &_sysio_mount_file_name, - &pno, - NULL, - NULL); - if (pno) - P_RELE(pno); - if (!err && _sysio_automount(pno) == 0) { - struct pnode *root; - - /* - * All went well. Need to switch - * parent pno and ino to the - * root of the newly mounted sub-tree. - * - * NB: - * We don't recurseively retry these - * things. It's OK to have the new root - * be an automount-point but it's going - * to take another lookup to accomplish it. - * The alternative could get us into an - * infinite loop. - */ - root = nd->nd_pno->p_cover; - assert(root); - P_RELE(nd->nd_pno); - nd->nd_pno = root; -#if 0 - P_REF(nd->nd_pno); -#endif - ino = nd->nd_pno->p_base->pb_ino; - assert(ino); - - /* - * Must send the intent-path again. - */ - path = nd->nd_path; - nd->nd_amcnt++; - - /* - * Must go back top and retry with this - * new pnode as parent. - */ - continue; - } - err = 0; /* it never happened */ - } -#endif - - /* - * Set up for next component. - */ - this = next; - if (path) - path = this.name; - if (!this.len) - break; - if (!ino) { - /* - * Should only be here if final component was - * target of a symlink. - */ - nd->nd_path = this.name + this.len; - err = -ENOENT; - break; - } - nd->nd_path = this.name + this.len; - _sysio_next_component(nd->nd_path, &next); - parent = nd->nd_pno; - nd->nd_pno = NULL; - - /* - * Parent must be a directory. - */ - if (ino && !S_ISDIR(ino->i_mode)) { - err = -ENOTDIR; - break; - } - - /* - * The extra path arg is passed only on the first lookup in the - * walk as we cross into each file system, anew. The intent is - * passed both on the first lookup and when trying to look up - * the final component -- Of the original path, not on the - * file system. - * - * Confused? Me too and I came up with this weirdness. It's - * hints to the file system drivers. Read on. - * - * The first lookup will give everything one needs to ready - * everything for the entire operation before the path is - * walked. The file system driver knows it's the first lookup - * in the walk because it has both the path and the intent. - * - * Alternatively, one could split the duties; The first lookup - * can be used to prime the file system inode cache with the - * interior nodes we'll want in the path-walk. Then, when - * looking up the last component, ready everything for the - * operations(s) to come. The file system driver knows it's - * the last lookup in the walk because it has the intent, - * again, but without the path. - * - * One special case; If we were asked to look up a single - * component, we treat it as the last component. The file - * system driver never sees the extra path argument. It should - * be noted that the driver always has the fully qualified - * path, on the target file system, available to it for any - * node it is looking up, including the last, via the base - * path node and it's ancestor chain. - */ - err = - lookup(parent, - &this, - &nd->nd_pno, - (path || !next.len) - ? nd->nd_intent - : NULL, - (path && next.len) ? path : NULL); - if (err) { - if (err == -ENOENT && - !next.len && - (nd->nd_flags & ND_NEGOK)) - err = 0; - break; - } - path = NULL; /* Stop that! */ - if ((parent->p_mount->mnt_fs != - nd->nd_pno->p_mount->mnt_fs)) { - /* - * Crossed into a new fs. We'll want the next lookup - * to include the path again. - */ - path = nd->nd_path; - } - - /* - * Release the parent. - */ - P_RELE(parent); - parent = NULL; - } - - /* - * Trailing separators cause us to break from the loop with - * a parent set but no pnode. Check for that. - */ - if (!nd->nd_pno) { - nd->nd_pno = parent; - parent = NULL; - /* - * Make sure the last processed component was a directory. The - * trailing slashes are illegal behind anything else. - */ - if (!(err || S_ISDIR(nd->nd_pno->p_base->pb_ino->i_mode))) - err = -ENOTDIR; - } - - /* - * Drop reference to parent if set. Either we have a dup of the original - * parent or an intermediate reference. - */ - if (parent) - P_RELE(parent); - - /* - * On error, we will want to drop our reference to the current - * path node if at end. - */ - if (err && nd->nd_pno) { - P_RELE(nd->nd_pno); - nd->nd_pno = NULL; - } - - return err; -} - -#ifdef CPLANT_YOD -/* - * for backward compatibility w/protocol switch - * remove everything up to the first ':' - * fortran libs prepend cwd to path, so not much choice - */ -#define STRIP_PREFIX(p) strchr(p,':') ? strchr(p,':')+1 : p -#else -#define STRIP_PREFIX(p) p -#endif - -/* - * Expanded form of the path-walk routine, with the common arguments, builds - * the nameidata bundle and calls path-walk. - */ -int -_sysio_namei(struct pnode *parent, - const char *path, - unsigned flags, - struct intent *intnt, - struct pnode **pnop) -{ - struct nameidata nameidata; - int err; - - ND_INIT(&nameidata, flags, STRIP_PREFIX(path), _sysio_root, intnt); - err = _sysio_path_walk(parent, &nameidata); - if (!err) - *pnop = nameidata.nd_pno; - return err; -} diff --git a/libsysio/src/open.c b/libsysio/src/open.c deleted file mode 100644 index 5845009..0000000 --- a/libsysio/src/open.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -/* - * Incorporate the GNU flags for open if we can. - */ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -/* - * Open file support. - */ - -mode_t _sysio_umask = 0; /* process umask. */ - -/* - * Internal form of open. - */ -int -_sysio_open(struct pnode *pno, int flags, mode_t mode) -{ - int ro; - int w; - int err; - struct inode *ino; - - ro = IS_RDONLY(pno, pno->p_base->pb_ino); - w = flags & (O_WRONLY|O_RDWR); - if (w == (O_WRONLY|O_RDWR)) { - /* - * Huh? - */ - return -EINVAL; - } - if (w && ro) - return -EROFS; - ino = pno->p_base->pb_ino; - if ((flags & O_CREAT) && !ino) { - struct pnode *parent; - - /* - * Must create it. - */ - if (ro) - return -EROFS; - parent = pno->p_parent; - err = _sysio_p_validate(parent, NULL, NULL); - if (!err) { - ino = parent->p_base->pb_ino; - assert(ino); - err = - !IS_RDONLY(parent, ino) - ? (*ino->i_ops.inop_open)(pno, flags, mode) - : -EROFS; - } - } else if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) - err = -EEXIST; - else if (!ino) - err = _sysio_p_validate(pno, NULL, NULL); - else { - /* - * Simple open of pre-existing file. - */ - err = (*ino->i_ops.inop_open)(pno, flags, mode); - } - - return err; -} - -#undef open - -int -SYSIO_INTERFACE_NAME(open)(const char *path, int flags, ...) -{ - mode_t mode; - unsigned ndflags; - struct intent intent; - int rtn; - struct pnode *pno; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - /* - * Get mode argument and determine parameters for namei - */ - mode = 0; - ndflags = 0; - intent.int_opmask = INT_OPEN; - if (flags & O_CREAT) { - va_list ap; - - /* - * Set ndflags to indicate return of negative alias is OK. - */ - ndflags |= ND_NEGOK; - - /* - * Will need mode too. - */ - va_start(ap, flags); - mode = -#ifndef REDSTORM - va_arg(ap, mode_t); -#else - va_arg(ap, int); -#endif - va_end(ap); - mode &= ~(_sysio_umask & 0777) | 07000; /* apply umask */ - - if (flags & O_EXCL) { - /* - * Tell others we intend to create this file. - */ - intent.int_opmask |= INT_CREAT; - } - } -#ifdef O_NOFOLLOW - if (flags & O_NOFOLLOW) - ndflags |= ND_NOFOLLOW; -#endif - - /* - * Find the file. - */ - fil = NULL; - INTENT_INIT(&intent, intent.int_opmask, &mode, &flags); - pno = NULL; - rtn = _sysio_namei(_sysio_cwd, path, ndflags, &intent, &pno); - if (rtn) - goto error; - /* - * Ask for the open/creat. - */ - rtn = _sysio_open(pno, flags, mode); - if (rtn) - goto error; - /* - * Get a file descriptor. - */ - fil = _sysio_fnew(pno->p_base->pb_ino, flags); - if (!fil) { - rtn = -ENOMEM; - goto error; - } - rtn = _sysio_fd_set(fil, -1, 0); - if (rtn < 0) - goto error; - - P_RELE(pno); - - SYSIO_INTERFACE_RETURN(rtn, 0); - -error: - if (fil) - F_RELE(fil); - if (pno) - P_RELE(pno); - SYSIO_INTERFACE_RETURN(-1, rtn); -} - -#ifdef __GLIBC__ -#undef __open -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), __open) -#undef open64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), SYSIO_INTERFACE_NAME(open64)) -#undef __open64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), __open64) -#endif - -#ifdef REDSTORM -#undef __libc_open64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), __libc_open64) -#endif - -#ifdef BSD -#undef _open -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(open), _open) -#endif - -int -SYSIO_INTERFACE_NAME(close)(int fd) -{ - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_fd_close(fd); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef __GLIBC__ -#undef __close -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(close), __close) -#endif - -#ifdef BSD -#undef _close -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(close), _close) -#endif - -int -SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode) -{ - - return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); -} - -#ifdef __GLIBC__ -#undef __creat -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), __creat) -#undef creat64 -#ifndef HAVE_LUSTRE_HACK -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), SYSIO_INTERFACE_NAME(creat64)) -#else -/* XXX workaround SuSE SLES 8, glibc-2.2.5 */ -sysio_sym_strong_alias(SYSIO_INTERFACE_NAME(creat), SYSIO_INTERFACE_NAME(creat64)) -#endif -#undef __creat64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), __creat64) -#endif - -#ifdef REDSTORM -#undef __libc_creat -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), __libc_creat) -#endif - -#ifdef BSD -#undef _creat -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), _creat) -#endif - -mode_t -SYSIO_INTERFACE_NAME(umask)(mode_t mask) -{ - mode_t omask; - - omask = _sysio_umask; - _sysio_umask = mask & 0777; - return omask; -} - -#ifdef REDSTORM -#undef __umask -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(umask), __umask) -#endif diff --git a/libsysio/src/readlink.c b/libsysio/src/readlink.c deleted file mode 100644 index 7053c62..0000000 --- a/libsysio/src/readlink.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(readlink)(const char *path, char *buf, size_t bufsiz) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - ino = pno->p_base->pb_ino; - err = (*ino->i_ops.inop_readlink)(pno, buf, bufsiz); - if (err) - goto error; - -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err, err >= 0 ? 0 : err); -} - -#ifdef REDSTORM -#undef __readlink -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readlink), - PREPEND(__, SYSIO_INTERFACE_NAME(readlink))) -#endif diff --git a/libsysio/src/rename.c b/libsysio/src/rename.c deleted file mode 100644 index 23e97b1..0000000 --- a/libsysio/src/rename.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "mount.h" -#include "inode.h" - -int -SYSIO_INTERFACE_NAME(rename)(const char *oldpath, const char *newpath) -{ - struct intent intent; - int err; - struct pnode *old, *new; - struct pnode_base *nxtpb, *pb; - struct intnl_stat ostbuf, nstbuf; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - /* - * Resolve oldpath to a path node. - */ - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); - if (err) - goto error3; - /* - * Resolve newpath to a path node. - */ - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); - if (err) - goto error2; - - if (old->p_mount->mnt_root == old || old->p_cover || - new->p_mount->mnt_root == new) { - err = -EBUSY; - goto error1; - } - - if (old->p_mount->mnt_fs != new->p_mount->mnt_fs) { - /* - * Oops. They're trying to move it across file systems. - */ - err = -EXDEV; - goto error1; - } - - /* - * Make sure the old pnode can't be found in the ancestor chain - * for the new. If it can, they are trying to move into a subdirectory - * of the old. - */ - nxtpb = new->p_base; - do { - pb = nxtpb; - nxtpb = pb->pb_parent; - if (pb == old->p_base) { - err = -EINVAL; - goto error1; - } - } while (nxtpb); - - while (new->p_base->pb_ino) { - /* - * Existing entry. We're replacing the new. Make sure that's - * ok. - */ - err = - old->p_base->pb_ino->i_ops.inop_getattr(old, NULL, &ostbuf); - if (err) - goto error1; - err = - new->p_base->pb_ino->i_ops.inop_getattr(new, NULL, &nstbuf); - if (err) { - if (err != ENOENT) - goto error1; - /* - * Rats! It disappeared beneath us. - */ - (void )_sysio_p_validate(new, NULL, NULL); - continue; - } - if (S_ISDIR(ostbuf.st_mode)) { - if (!S_ISDIR(nstbuf.st_mode)) { - err = -ENOTDIR; - goto error1; - } - if (nstbuf.st_nlink > 2) { - err = -ENOTEMPTY; - goto error1; - } - } else if (S_ISDIR(nstbuf.st_mode)) { - err = -EEXIST; - goto error1; - } - break; - } - - /* - * It's not impossible to clean up the altered name space after - * a rename. However, it is onerous and I don't want to do it right - * now. If it becomes an issue, we can do it later. For now, I've - * elected to use the semantic that says, basically, the entire - * sub-tree must be unreferenced. That's per POSIX, but it's a nasty - * this to do to the caller. - */ - if (_sysio_p_prune(new) != 1) { - err = -EBUSY; - goto error1; - } - err = old->p_base->pb_ino->i_ops.inop_rename(old, new); - if (err) - goto error1; - /* - * Reflect the successful rename in the active name space graph. - */ - if (new->p_base->pb_ino) - I_GONE(new->p_base->pb_ino); - new->p_base->pb_ino = old->p_base->pb_ino; - I_REF(new->p_base->pb_ino); - -error1: - P_RELE(new); -error2: - P_RELE(old); -error3: - if (err) - goto out; - _sysio_p_gone(old); /* kill it! */ -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} diff --git a/libsysio/src/rmdir.c b/libsysio/src/rmdir.c deleted file mode 100644 index cbc7632..0000000 --- a/libsysio/src/rmdir.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(rmdir)(const char *path) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); - if (err) - goto out; - if (IS_RDONLY(pno, pno->p_base->pb_ino)) { - err = -EROFS; - goto error; - } - if (pno->p_ref > 1) { - err = -EBUSY; - goto error; - } - err = pno->p_base->pb_ino->i_ops.inop_rmdir(pno); - if (err) - goto error; - /* - * Invalidate the path-base node and kill the i-node. - */ - ino = pno->p_base->pb_ino; - pno->p_base->pb_ino = NULL; - I_GONE(ino); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __rmdir -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(rmdir), - PREPEND(__, SYSIO_INTERFACE_NAME(rmdir))) -#endif diff --git a/libsysio/src/rw.c b/libsysio/src/rw.c deleted file mode 100644 index edc308b..0000000 --- a/libsysio/src/rw.c +++ /dev/null @@ -1,1325 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "file.h" -#include "inode.h" - -#include "sysio-symbols.h" - -#define IIOXOP_READ(ino) (ino)->i_ops.inop_read, 0 -#define IIOXOP_WRITE(ino) (ino)->i_ops.inop_write, 1 - -/* - * Decoding the interface routine names: - * - * Much of this carries legacy from the POSIX world and the Intel ASCI - * Red programming environment. Routine names are composed of prefix, - * basic POSIX names, and postfix. The basic POSIX names are read and write. - * Prefixes, left-to-right: - * - * - 'i' -- asynchronous operation (from ASCI Red) - * - 'p' -- positional (POSIX) - * Posfixes, only one: - * - 'v' -- vectored (POSIX) - * - 'x' -- extent-based (new for Red Storm) - * - * All valid combinations are available and symmetric. - */ - -/* - * Post op using iovec with regions specified by the passed extent vector. - * - * NOTE: There are enough parameters that we should really consider - * passing them in a structure. - */ -static int -_sysio_iiox(int (*f)(struct inode *, struct ioctx *), - int wr, - struct file *fil, - const struct iovec *iov, - size_t iov_count, - void (*iov_free)(struct ioctx *), - const struct intnl_xtvec *xtv, - size_t xtv_count, - void (*xtv_free)(struct ioctx *), - void (*completio)(struct ioctx *, void *), - struct ioctx **ioctxp) -{ - struct inode *ino; - ssize_t cc; - struct ioctx *ioctx; - int err; - struct ioctx_callback *cb; - - /* - * Check that it was opened with flags supporting the operation. - */ - if (!(wr - ? (fil->f_flags & (O_RDWR | O_WRONLY)) - : !(fil->f_flags & O_WRONLY))) - return -EBADF; - - ino = fil->f_ino; - if (!ino) { - /* - * Huh? It's dead. - */ - return -EBADF; - } - cc = - _sysio_validx(xtv, xtv_count, - iov, iov_count, -#if _LARGEFILE64_SOURCE && defined(O_LARGEFILE) - (fil->f_flags & O_LARGEFILE) == 0 - ? LONG_MAX - : -#endif - _SYSIO_OFF_T_MAX); - if (cc < 0) - return cc; - ioctx = _sysio_ioctx_new(ino, wr, iov, iov_count, xtv, xtv_count); - if (!ioctx) - return -ENOMEM; - if ((iov_free && - (err = _sysio_ioctx_cb(ioctx, - (void (*)(struct ioctx *, - void *))iov_free, - NULL))) || - (xtv_free && - (err = _sysio_ioctx_cb(ioctx, - (void (*)(struct ioctx *, - void *))xtv_free, - NULL))) || - (completio && - (err = _sysio_ioctx_cb(ioctx, - (void (*)(struct ioctx *, - void *))completio, - fil))) || - (err = (*f)(ino, ioctx))) { - /* - * Release the callback queue. Don't want it run after all. - */ - while ((cb = ioctx->ioctx_cbq.tqh_first)) { - TAILQ_REMOVE(&ioctx->ioctx_cbq, - cb, - iocb_next); - _sysio_ioctx_cb_free(cb); - } - _sysio_ioctx_complete(ioctx); - return err; - } - *ioctxp = ioctx; - return 0; -} - -/* - * Sum iovec entries, returning total found or error if range of ssize_t would - * be exceeded. - */ -static ssize_t -_sysio_sum_iovec(const struct iovec *iov, int count) -{ - ssize_t tmp, cc; - - if (count <= 0) - return -EINVAL; - - cc = 0; - while (count--) { - tmp = cc; - cc += iov->iov_len; - if (tmp && iov->iov_len && cc <= tmp) - return -EINVAL; - iov++; - } - return cc; -} - -/* - * Asynch IO from/to iovec from/to current file offset. - */ -static int -_sysio_iiov(int (*f)(struct inode *, struct ioctx *), - int wr, - struct file *fil, - const struct iovec *iov, - int count, - void (*iov_free)(struct ioctx *), - struct intnl_xtvec *xtv, - void (*xtv_free)(struct ioctx *), - struct ioctx **ioctxp) -{ - ssize_t cc; - _SYSIO_OFF_T off; - int err; - - cc = _sysio_sum_iovec(iov, count); - if (cc < 0) - return (int )cc; - xtv->xtv_off = fil->f_pos; - xtv->xtv_len = cc; - off = xtv->xtv_off + xtv->xtv_len; - if (xtv->xtv_off && off <= xtv->xtv_off) { - /* - * Ouch! The IO vector specifies more bytes than - * are addressable. Trim the region to limit how - * much of the IO vector is finally transferred. - */ - xtv->xtv_len = _SYSIO_OFF_T_MAX - xtv->xtv_off; - } - err = - _sysio_iiox(f, - wr, - fil, - iov, count, iov_free, - xtv, 1, xtv_free, - (void (*)(struct ioctx *, void *))_sysio_fcompletio, - ioctxp); - if (err) - return err; - return 0; -} - -static void -free_xtv(struct ioctx *ioctx) -{ - - free((struct iovec *)ioctx->ioctx_xtv); - ioctx->ioctx_iov = NULL; -} - -ioid_t -SYSIO_INTERFACE_NAME(ireadv)(int fd, const struct iovec *iov, int count) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(readv)(int fd, const struct iovec *iov, int count) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#if defined(__GLIBC__) -#undef __readv -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv), - PREPEND(__, SYSIO_INTERFACE_NAME(readv))) -#undef __libc_readv -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_readv))) -#endif - -static void -free_iov(struct ioctx *ioctx) -{ - - free((struct iovec *)ioctx->ioctx_iov); - ioctx->ioctx_iov = NULL; -} - -ioid_t -SYSIO_INTERFACE_NAME(iread)(int fd, void *buf, size_t count) -{ - struct iovec *iov; - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - iov = malloc(sizeof(struct iovec)); - if (!iov) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - iov->iov_base = buf; - iov->iov_len = count; - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) { - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - } - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - iov, 1, free_iov, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count) -{ - struct file *fil; - struct iovec iovector; - struct intnl_xtvec xtvector; - int err; - struct ioctx *ioctx; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - iovector.iov_base = buf; - iovector.iov_len = count; - err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), - fil, - &iovector, 1, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#ifdef __GLIBC__ -#undef __read -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read), - PREPEND(__, SYSIO_INTERFACE_NAME(read))) -#undef __libc_read -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_read))) -#endif - -/* - * Asynch IO between iovec and data at the given offset. - */ -static int -_sysio_ipiov(int (*f)(struct inode *, struct ioctx *), - int wr, - struct file *fil, - const struct iovec *iov, - int count, - void (*iov_free)(struct ioctx *), - _SYSIO_OFF_T off, - struct intnl_xtvec *xtv, - void (*xtv_free)(struct ioctx *), - struct ioctx **ioctxp) -{ - ssize_t cc; - int err; - - SYSIO_ENTER; - cc = _sysio_sum_iovec(iov, count); - if (cc < 0) { - SYSIO_LEAVE; - return (int )cc; - } - xtv->xtv_off = off, - xtv->xtv_len = cc; - err = - _sysio_iiox(f, - wr, - fil, - iov, count, iov_free, - xtv, 1, xtv_free, - NULL, - ioctxp); - SYSIO_LEAVE; - if (err) - return err; - return 0; -} - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(int fd, - const struct iovec *iov, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - offset, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#if _LARGEFILE64_SOURCE -#undef ipread64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv)), - SYSIO_INTERFACE_NAME(ipread64v)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipreadv)(int fd, - const struct iovec *iov, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(fd, - iov, - count, - offset); -} - -static ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(int fd, - const struct iovec *iov, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - iov, count, NULL, - offset, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#if _LARGEFILE64_SOURCE -#undef pread64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(preadv)), - SYSIO_INTERFACE_NAME(pread64v)) -#endif - -ssize_t -SYSIO_INTERFACE_NAME(preadv)(int fd, - const struct iovec *iov, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(fd, - iov, - count, - offset); -} - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(int fd, - void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct iovec *iov; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - iov = malloc(sizeof(struct iovec)); - if (!(xtv && iov)) { - err = -ENOMEM; - goto error; - } - xtv->xtv_off = offset; - iov->iov_base = buf; - xtv->xtv_len = iov->iov_len = count; - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - iov, 1, free_iov, - offset, - xtv, free_xtv, - &ioctx); -error: - if (err) { - if (iov) - free(iov); - if (xtv) - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#if _LARGEFILE64_SOURCE -#undef ipread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipread)), - SYSIO_INTERFACE_NAME(ipread64)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipread)(int fd, - void *buf, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(fd, - buf, - count, - offset); -} - -ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(pread))(int fd, - void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvec; - struct iovec iovec; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtvec.xtv_off = offset; - iovec.iov_base = buf; - xtvec.xtv_len = iovec.iov_len = count; - err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), - fil, - &iovec, 1, NULL, - offset, - &xtvec, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#if _LARGEFILE64_SOURCE -#undef pread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)), - SYSIO_INTERFACE_NAME(pread64)) -#if __GLIBC__ -#undef __pread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)), - PREPEND(__, SYSIO_INTERFACE_NAME(pread64))) -#undef __libc_pread64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread64))) -#endif -#endif - -ssize_t -SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count, off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(pread))(fd, - buf, - count, - offset); -} - -#if __GLIBC__ -#undef __pread -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread), - PREPEND(__, SYSIO_INTERFACE_NAME(pread))) -#undef __libc_pread -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread))) -#endif - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ireadx))(int fd, - const struct iovec *iov, - size_t iov_count, - const struct intnl_xtvec *xtv, - size_t xtv_count) -{ - struct file *fil; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - err = - _sysio_iiox(IIOXOP_READ(fil->f_ino), - fil, - iov, iov_count, NULL, - xtv, xtv_count, NULL, - NULL, - &ioctx); - - SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err); -} - -#if _LARGEFILE64_SOURCE -#undef iread64x -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)), - SYSIO_INTERFACE_NAME(iread64x)) -#endif - -#if _LARGEFILE64_SOURCE -ioid_t -SYSIO_INTERFACE_NAME(ireadx)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - struct file *fil; - struct intnl_xtvec *ixtv, *ixtvent; - size_t count; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec)); - if (!ixtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - count = xtv_count; - while (count--) { - ixtvent->xtv_off = xtv->xtv_off; - ixtvent->xtv_len = xtv->xtv_len; - ixtvent++; - xtv++; - } - - err = - _sysio_iiox(IIOXOP_READ(fil->f_ino), - fil, - iov, iov_count, NULL, - ixtv, xtv_count, free_xtv, - NULL, - &ioctx); - if (err) { - free(ixtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} -#else -#undef ireadx -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)), - SYSIO_INTERFACE_NAME(ireadx)) -#endif - -ssize_t -SYSIO_INTERFACE_NAME(readx)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = SYSIO_INTERFACE_NAME(ireadx)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return iowait(ioid); -} - -#if _LARGEFILE64_SOURCE -#undef iread64x -ssize_t -SYSIO_INTERFACE_NAME(read64x)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec64 *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = SYSIO_INTERFACE_NAME(iread64x)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return iowait(ioid); -} -#endif - -#ifdef notdef -int -read_list(int fd, - int mem_list_count, - char *mem_offsets[], - int mem_lengths[], - int file_list_count, - int64_t file_offsets[], - int32_t file_lengths[]) -{ - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - SYSIO_INTERFACE_RETURN(-1, -ENOSYS); -} -#endif - -ioid_t -SYSIO_INTERFACE_NAME(iwritev)(int fd, - const struct iovec *iov, - int count) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(writev)(int fd, const struct iovec *iov, int count) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err); -} - -#ifdef __GLIBC__ -#undef __writev -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev), - PREPEND(__, SYSIO_INTERFACE_NAME(writev))) -#undef __libc_writev -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_writev))) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(iwrite)(int fd, const void *buf, size_t count) -{ - struct iovec *iov; - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - iov = malloc(sizeof(struct iovec)); - if (!iov) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - iov->iov_base = (void *)buf; - iov->iov_len = count; - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) { - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - } - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, 1, free_iov, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - free(iov); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -ssize_t -SYSIO_INTERFACE_NAME(write)(int fd, const void *buf, size_t count) -{ - struct file *fil; - struct iovec iovector; - struct intnl_xtvec xtvector; - int err; - struct ioctx *ioctx; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - iovector.iov_base = (void *)buf; - iovector.iov_len = count; - err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), - fil, - &iovector, 1, NULL, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err); -} - -#ifdef __GLIBC__ -#undef __write -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write), - PREPEND(__, SYSIO_INTERFACE_NAME(write))) -#undef __libc_write -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_write))) -#endif - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(int fd, - const struct iovec *iov, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - if (!xtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - offset, - xtv, free_xtv, - &ioctx); - if (err) { - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#if _LARGEFILE64_SOURCE -#undef ipwrite64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev)), - SYSIO_INTERFACE_NAME(ipwrite64v)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipwritev)(int fd, - const struct iovec *iov, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(fd, - iov, - count, - offset); -} - -static ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(int fd, - const struct iovec *iov, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvector; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, count, NULL, - offset, - &xtvector, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#if _LARGEFILE64_SOURCE -#undef pwrite64v -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwritev)), - SYSIO_INTERFACE_NAME(pwrite64v)) -#endif - -ssize_t -SYSIO_INTERFACE_NAME(pwritev)(int fd, - const struct iovec *iov, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(fd, - iov, - count, - offset); -} - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(int fd, - const void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec *xtv; - struct iovec *iov; - struct ioctx *ioctx; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - xtv = malloc(sizeof(struct intnl_xtvec)); - iov = malloc(sizeof(struct iovec)); - if (!(xtv && iov)) { - err = -errno; - goto error; - } - xtv->xtv_off = offset; - iov->iov_base = (void *)buf; - xtv->xtv_len = iov->iov_len = count; - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - iov, 1, free_iov, - offset, - xtv, free_xtv, - &ioctx); -error: - if (err) { - if (iov) - free(iov); - if (xtv) - free(xtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} - -#if _LARGEFILE64_SOURCE -#undef ipwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite)), - SYSIO_INTERFACE_NAME(ipwrite64)) -#endif - -ioid_t -SYSIO_INTERFACE_NAME(ipwrite)(int fd, - const void *buf, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(fd, - buf, - count, - offset); -} - -ssize_t -PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(int fd, - const void *buf, - size_t count, - _SYSIO_OFF_T offset) -{ - struct file *fil; - struct intnl_xtvec xtvec; - struct iovec iovec; - struct ioctx *ioctx; - int err; - ssize_t cc; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!fil) - SYSIO_INTERFACE_RETURN(-1, -EBADF); - - xtvec.xtv_off = offset; - iovec.iov_base = (void *)buf; - xtvec.xtv_len = iovec.iov_len = count; - err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), - fil, - &iovec, 1, NULL, - offset, - &xtvec, NULL, - &ioctx); - if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) - err = (int )cc; - - SYSIO_INTERFACE_RETURN(err ? -1 : cc, err); -} - -#if _LARGEFILE64_SOURCE -#undef pwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)), - SYSIO_INTERFACE_NAME(pwrite64)) -#ifdef __GLIBC -#undef __pwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)), - PREPEND(__, SYSIO_INTERFACE_NAME(pwrite64))) -#undef __libc_pwrite64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)), - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite64))) -#endif -#endif - -ssize_t -SYSIO_INTERFACE_NAME(pwrite)(int fd, - const void *buf, - size_t count, - off_t offset) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(fd, - buf, - count, - offset); -} - -#ifdef __GLIBC -#undef __libc_pwrite -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pwrite), __libc_pwrite) - PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite))) -#endif - -static ioid_t -PREPEND(_, SYSIO_INTERFACE_NAME(iwritex))(int fd, - const struct iovec *iov, - size_t iov_count, - const struct intnl_xtvec *xtv, - size_t xtv_count) -{ - struct file *fil; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - err = - _sysio_iiox(IIOXOP_WRITE(fil->f_ino), - fil, - iov, iov_count, NULL, - xtv, xtv_count, NULL, - NULL, - &ioctx); - - SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err); -} - -#if _LARGEFILE64_SOURCE -#undef iwrite64x -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)), - SYSIO_INTERFACE_NAME(iwrite64x)) -#endif - -#if _LARGEFILE64_SOURCE -ioid_t -SYSIO_INTERFACE_NAME(iwritex)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - struct file *fil; - struct intnl_xtvec *ixtv, *ixtvent; - size_t count; - int err; - struct ioctx *ioctx; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); - - ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec)); - if (!ixtv) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); - - count = xtv_count; - while (count--) { - ixtvent->xtv_off = xtv->xtv_off; - ixtvent->xtv_len = xtv->xtv_len; - ixtvent++; - xtv++; - } - - err = - _sysio_iiox(IIOXOP_WRITE(fil->f_ino), - fil, - iov, iov_count, NULL, - ixtv, xtv_count, free_xtv, - NULL, - &ioctx); - if (err) { - free(ixtv); - SYSIO_INTERFACE_RETURN(IOID_FAIL, err); - } - SYSIO_INTERFACE_RETURN(ioctx, 0); -} -#else -#undef iwritex -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)), - SYSIO_INTERFACE_NAME(iwritex)) -#endif - -#undef writex -ssize_t -SYSIO_INTERFACE_NAME(writex)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = - SYSIO_INTERFACE_NAME(iwritex)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return iowait(ioid); -} - -#if _LARGEFILE64_SOURCE -#undef write64x -ssize_t -SYSIO_INTERFACE_NAME(write64x)(int fd, - const struct iovec *iov, size_t iov_count, - const struct xtvec64 *xtv, size_t xtv_count) -{ - ioid_t ioid; - - if ((ioid = SYSIO_INTERFACE_NAME(iwrite64x)(fd, - iov, - iov_count, - xtv, - xtv_count)) == IOID_FAIL) - return -1; - return iowait(ioid); -} -#endif - -#ifdef notdef -int -write_list(int fd, - int mem_list_count, - char *mem_offsets[], - int mem_lengths[], - int file_list_count, - int64_t file_offsets[], - int32_t file_lengths[]) -{ - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - SYSIO_INTERFACE_RETURN(-1, -ENOSYS); -} -#endif diff --git a/libsysio/src/stat.c b/libsysio/src/stat.c deleted file mode 100644 index 4fec1f1..0000000 --- a/libsysio/src/stat.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -#ifndef REDSTORM -#undef fstat -#undef stat -#undef lstat -#endif - -#undef __fxstat -#undef __xstat -#undef __lxstat - -#if !defined(_STAT_VER) -#define _STAT_VER 0 -#endif - -#if _LARGEFILE64_SOURCE -static void -convstat(struct stat64 *st64_buf, struct stat *st_buf) -{ - - st_buf->st_dev = st64_buf->st_dev; - st_buf->st_ino = st64_buf->st_ino; - st_buf->st_mode = st64_buf->st_mode; - st_buf->st_nlink = st64_buf->st_nlink; - st_buf->st_uid = st64_buf->st_uid; - st_buf->st_gid = st64_buf->st_gid; - st_buf->st_rdev = st64_buf->st_rdev; - st_buf->st_size = st64_buf->st_size; - st_buf->st_blksize = st64_buf->st_blksize; - st_buf->st_blocks = st64_buf->st_blocks; - st_buf->st_atime = st64_buf->st_atime; - st_buf->st_mtime = st64_buf->st_mtime; - st_buf->st_ctime = st64_buf->st_ctime; -} -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(fxstat))(int __ver, - int __fildes, - struct stat *__stat_buf) -{ - struct file *fil; - int err; - struct intnl_stat *buf; -#if _LARGEFILE64_SOURCE - struct stat64 st64; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - err = 0; - fil = _sysio_fd_find(__fildes); - if (!fil) { - err = -EBADF; - goto out; - } -#if _LARGEFILE64_SOURCE - buf = &st64; -#else - buf = __stat_buf; -#endif - err = - fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, buf); -#if _LARGEFILE64_SOURCE - if (!err) - convstat(buf, __stat_buf); -#endif -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _fxstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(fxstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(fxstat))) -#endif - -#ifndef REDSTORM -static int -PREPEND(__, SYSIO_INTERFACE_NAME(fstat))(int fd, struct stat *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(fxstat))(_STAT_VER, - fd, - buf); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(fstat)), - SYSIO_INTERFACE_NAME(fstat)) - -#ifdef BSD -#undef _fstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(fstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(fstat))) -#endif -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(xstat))(int __ver, - const char *__filename, - struct stat *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - struct intnl_stat *buf; -#if _LARGEFILE64_SOURCE - struct stat64 st64; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, 0, &intent, &pno); - if (err) - goto out; - ino = pno->p_base->pb_ino; -#if _LARGEFILE64_SOURCE - buf = &st64; -#else - buf = __stat_buf; -#endif - err = - ino->i_ops.inop_getattr(pno, - pno->p_base->pb_ino, - buf); - - P_RELE(pno); -#if _LARGEFILE64_SOURCE - if (!err) - convstat(buf, __stat_buf); -#endif -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _xstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(xstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(xstat))) -#endif - -#ifndef REDSTORM -static int -PREPEND(__, SYSIO_INTERFACE_NAME(stat))(const char *filename, - struct stat *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(xstat))(_STAT_VER, - filename, - buf); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(stat)), - SYSIO_INTERFACE_NAME(stat)) - -#ifdef BSD -#undef _stat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(stat)), - PREPEND(_, SYSIO_INTERFACE_NAME(stat))) -#endif -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(lxstat))(int __ver, - const char *__filename, - struct stat *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - struct intnl_stat *buf; -#if _LARGEFILE64_SOURCE - struct stat64 st64; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; -#if _LARGEFILE64_SOURCE - buf = &st64; -#else - buf = __stat_buf; -#endif - ino = pno->p_base->pb_ino; - err = - ino->i_ops.inop_getattr(pno, - pno->p_base->pb_ino, - buf); - - P_RELE(pno); -#if _LARGEFILE64_SOURCE - if (!err) - convstat(buf, __stat_buf); -#endif -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef _lxstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(lxstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(lxstat))) -#endif - -#ifndef REDSTORM -static int -PREPEND(__, SYSIO_INTERFACE_NAME(lstat))(const char *filename, struct stat *buf) -{ - return PREPEND(__, SYSIO_INTERFACE_NAME(lxstat))(_STAT_VER, - filename, - buf); -} - -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(lstat)), - SYSIO_INTERFACE_NAME(lstat)) - -#ifdef BSD -#undef _lstat -sysio_sym_weak_alias(PREPEND(__, SYSIO_INTERFACE_NAME(lstat)), - PREPEND(_, SYSIO_INTERFACE_NAME(lstat))) -#endif -#endif diff --git a/libsysio/src/stat64.c b/libsysio/src/stat64.c deleted file mode 100644 index 377e2dc..0000000 --- a/libsysio/src/stat64.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifdef _LARGEFILE64_SOURCE - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#ifndef REDSTORM -#undef fstat64 -#undef stat64 -#undef lstat64 -#endif - -#undef __fxstat64 -#undef __xstat64 -#undef __lxstat64 - -int -PREPEND(__, SYSIO_INTERFACE_NAME(fxstat64))(int __ver, - int __fildes, - struct stat64 *__stat_buf) -{ - struct file *fil; - int err; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - err = 0; - fil = _sysio_fd_find(__fildes); - if (!fil) { - err = -EBADF; - goto out; - } - err = fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, __stat_buf); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifndef REDSTORM -int -SYSIO_INTERFACE_NAME(fstat64)(int fd, struct stat64 *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(fxstat64))(_STAT_VER, fd, buf); -} -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(xstat64))(int __ver, - const char *__filename, - struct stat64 *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, 0, &intent, &pno); - if (err) - goto out; - err = - pno->p_base->pb_ino->i_ops.inop_getattr(pno, - pno->p_base->pb_ino, - __stat_buf); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifndef REDSTORM -int -SYSIO_INTERFACE_NAME(stat64)(const char *filename, struct stat64 *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(xstat64))(_STAT_VER, - filename, - buf); -} -#endif - -int -PREPEND(__, SYSIO_INTERFACE_NAME(lxstat64))(int __ver, - const char *__filename, - struct stat64 *__stat_buf) -{ - struct intent intent; - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - err = - pno->p_base->pb_ino->i_ops.inop_getattr(pno, - pno->p_base->pb_ino, - __stat_buf); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifndef REDSTORM -int -SYSIO_INTERFACE_NAME(lstat64)(const char *filename, struct stat64 *buf) -{ - - return PREPEND(__, SYSIO_INTERFACE_NAME(lxstat64))(_STAT_VER, - filename, - buf); -} -#endif -#endif /* !_LARGEFILE64_SOURCE */ diff --git a/libsysio/src/statvfs.c b/libsysio/src/statvfs.c deleted file mode 100644 index 5f07387..0000000 --- a/libsysio/src/statvfs.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifndef BSD - -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -#undef statvfs -#undef fstatvfs - -#ifndef INTNL_STATVFS_IS_NATURAL -static void -convstatvfs(struct statvfs *stvfsbuf, struct intnl_statvfs *istvfsbuf) -{ - stvfsbuf->f_bsize = istvfsbuf->f_bsize; - stvfsbuf->f_frsize = istvfsbuf->f_frsize; - stvfsbuf->f_blocks = (unsigned long )istvfsbuf->f_blocks; - stvfsbuf->f_bfree = (unsigned long )istvfsbuf->f_bfree; - stvfsbuf->f_bavail = (unsigned long )istvfsbuf->f_bavail; - stvfsbuf->f_files = (unsigned long )istvfsbuf->f_files; - stvfsbuf->f_ffree = (unsigned long )istvfsbuf->f_ffree; - stvfsbuf->f_favail = (unsigned long )istvfsbuf->f_favail; - stvfsbuf->f_fsid = istvfsbuf->f_fsid; - stvfsbuf->f_flag = istvfsbuf->f_flag; - stvfsbuf->f_namemax = istvfsbuf->f_namemax; -} -#endif - -int -SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf) -{ - int err; - struct pnode *pno; -#ifdef INTNL_STATVFS_IS_NATURAL -#define _call_buf buf -#else - struct intnl_statvfs _call_buffer; - struct intnl_statvfs *_call_buf = &_call_buffer; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - - err = pno->p_base->pb_ino->i_ops.inop_statvfs(pno, NULL, _call_buf); - P_RELE(pno); - if (err) - goto err; -#ifndef INTNL_STATVFS_IS_NATURAL - convstatvfs(buf, _call_buf); -#endif - goto out; -err: -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __statvfs -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(statvfs), - PREPEND(__, SYSIO_INTERFACE_NAME(statvfs))) -#endif - -int -SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf) -{ - int err; - struct file *filp; -#ifdef INTNL_STATVFS_IS_NATURAL -#define _call_buf buf -#else - struct intnl_statvfs _call_buffer; - struct intnl_statvfs *_call_buf = &_call_buffer; -#endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - filp = _sysio_fd_find(fd); - if (!filp) { - err = -EBADF; - goto out; - } - - err = filp->f_ino->i_ops.inop_statvfs(NULL, filp->f_ino, _call_buf); - if (err) - goto err; -#ifndef INTNL_STATVFS_IS_NATURAL - convstatvfs(buf, _call_buf); -#endif - goto out; -err: -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fstatvfs -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fstatvfs), - PREPEND(__, SYSIO_INTERFACE_NAME(fstatvfs))) -#endif - -#endif /* ifndef BSD */ diff --git a/libsysio/src/statvfs64.c b/libsysio/src/statvfs64.c deleted file mode 100644 index c89c969..0000000 --- a/libsysio/src/statvfs64.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#ifndef BSD -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(statvfs64)(const char *path, struct statvfs64 *buf) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - - err = pno->p_base->pb_ino->i_ops.inop_statvfs(pno, NULL, buf); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __statvfs64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(statvfs64), - PREPEND(__, SYSIO_INTERFACE_NAME(statvfs64))) -#endif - -int -SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf) -{ - int err; - struct file *filp; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - filp = _sysio_fd_find(fd); - if (!filp) { - err = -EBADF; - goto out; - } - - err = filp->f_ino->i_ops.inop_statvfs(NULL, filp->f_ino, buf); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __fstatvfs64 -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(fstatvfs64), - PREPEND(__, SYSIO_INTERFACE_NAME(fstatvfs64))) -#endif - -#endif /* ifndef BSD */ diff --git a/libsysio/src/stdlib.c b/libsysio/src/stdlib.c deleted file mode 100644 index fcd463a..0000000 --- a/libsysio/src/stdlib.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/* - * stdlib.c - * - * The only purpose of this file is help liblustre adaptive to more - * applications, and specifically for running on Linux. The ideal - * final solution would be remove this completely and only rely on - * system call interception. Unfortunately we failed to find that - * way at the moment. - * - * Initially we try the simplest implementation here, just get a confidence - * it could work. - * - */ -#if !(defined(BSD) || defined(REDSTORM)) - -#include -#include -#include -#include - -#include - -#include "sysio-symbols.h" - -#if !defined(__USE_LARGEFILE64) -#error "__LARGEFILE64_SOURCE must be defined" -#endif - - -/*********************************************************** - * dir series functions * - ***********************************************************/ - -#undef BUFSIZE -#define BUFSIZE 4096 - -struct __dirstream { - int fd; - loff_t base; - loff_t filepos; /* current pos in dir file stream */ - struct dirent *curent; /* current dirent pointer */ - struct dirent64 *curent64; /* current dirent64 pointer */ - struct dirent *retent; /* ent returned to caller */ - struct dirent64 *retent64; /* ent64 returned to caller */ - unsigned int effective; /* effective data size in buffer */ - char buf[BUFSIZE]; -}; - -DIR* opendir(const char *name) -{ - DIR *dir; - - dir = (DIR *) malloc(sizeof(*dir)); - if (!dir) { - errno = ENOMEM; - return NULL; - } - -#if __USE_LARGEFILE64 - dir->fd = open64(name, O_RDONLY); -#else - dir->fd = open(name, O_RDONLY); -#endif - if (dir->fd < 0) - goto err_out; - - dir->base = 0; - dir->filepos = 0; - dir->curent = (struct dirent *) dir->buf; - dir->curent64 = (struct dirent64 *) dir->buf; - dir->retent = NULL; - dir->retent64 = NULL; - dir->effective = 0; - - return dir; -err_out: - free(dir); - return NULL; -} - -sysio_sym_weak_alias(opendir, __opendir); - -struct dirent64 *readdir64(DIR *dir) -{ - int rc, reclen; - - /* need to read new data? */ - if ((char*)dir->curent64 - dir->buf >= dir->effective) { - rc = getdirentries64(dir->fd, dir->buf, BUFSIZE, &dir->base); - /* error or end-of-file */ - if (rc <= 0) - return NULL; - - dir->curent64 = (struct dirent64 *) dir->buf; - dir->effective = rc; - } - - dir->retent64 = dir->curent64; - dir->curent64 = (struct dirent64*) ((char *)(dir->curent64) + - dir->curent64->d_reclen); -#ifdef _DIRENT_HAVE_D_OFF - dir->filepos = dir->curent64->d_off; -#else - dir->filepos += dir->curent64->d_reclen; -#endif - return dir->retent64; -} - -sysio_sym_weak_alias(readdir64, __readdir64); - -/* XXX probably the following assumption is not true */ -#if __WORDSIZE == 64 -#define NATURAL_READDIR64 -#else -#undef NATURAL_READDIR64 -#endif - -#ifndef NATURAL_READDIR64 - -struct dirent *readdir(DIR *dir) -{ - int rc, reclen; - - /* need to read new data? */ - if ((char*)dir->curent - dir->buf >= dir->effective) { - rc = getdirentries(dir->fd, dir->buf, BUFSIZE, (off_t*) &dir->base); - /* error or end-of-file */ - if (rc <= 0) - return NULL; - - dir->curent = (struct dirent *) dir->buf; - dir->effective = rc; - } - - dir->retent = dir->curent; - dir->curent = (struct dirent*) ((char *)(dir->curent) + - dir->curent->d_reclen); -#ifdef _DIRENT_HAVE_D_OFF - dir->filepos = dir->curent->d_off; -#else - dir->filepos += dir->curent->d_reclen; -#endif - return dir->retent; -} -sysio_sym_weak_alias(readdir, __readdir); - -#else /* NATURAL_READDIR64 */ - -struct dirent *readdir(DIR *dir) { - return (struct dirent *) readdir64(dir); -} -sysio_sym_weak_alias(readdir, __readdir); - -#endif /* NATURAL_READDIR64 */ - -int closedir(DIR *dir) -{ - int rc; - - rc = close(dir->fd); - - free(dir); - return rc; -} - -sysio_sym_weak_alias(closedir, __closedir); - -int dirfd(DIR *dir) -{ - return dir->fd; -} - -off_t telldir(DIR *dir) -{ - return (dir->filepos); -} - -void seekdir(DIR *dir, off_t offset) -{ - dir->filepos = offset; - - dir->base = offset; - dir->curent64 = (struct dirent64 *) dir->buf; - dir->retent64 = NULL; - dir->effective = 0; - dir->curent = (struct dirent *) dir->buf; - dir->retent = NULL; -} - -void rewinddir(DIR *dir) -{ - dir->base = 0; - dir->filepos = 0; - dir->curent64 = (struct dirent64 *) dir->buf; - dir->retent64 = NULL; - dir->curent = (struct dirent *) dir->buf; - dir->retent = NULL; - dir->effective = 0; -} - -#if 0 -int scandir(const char *dir, struct dirent ***namelist, - int(*select)(const struct dirent *), - int(*compar)(const void *, const void *)) -{ - errno = ENOSYS; - return -1; -} - -int scandir64(const char *dir, struct dirent64 ***namelist, - int(*select)(const struct dirent64 *), - int(*compar)(const void *, const void *)) -{ - errno = ENOSYS; - return -1; -} -#endif - -/*********************************************************** - * FIXME workaround for linux only * - ***********************************************************/ - -#define LINUX -#if defined(LINUX) -ssize_t getxattr(char *path, char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} - -ssize_t lgetxattr(char *path, char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} - -ssize_t fgetxattr(int fd, char *name, void *value, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long setxattr(char *path, char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} - -long lsetxattr(char *path, char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} - -long fsetxattr(int fd, char *name, void *value, size_t size, int flags) -{ - errno = ENOSYS; - return -1; -} - -long listxattr(char *path, char *list, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long llistxattr(char *path, char *list, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long flistxattr(int fd, char *list, size_t size) -{ - errno = ENOSYS; - return -1; -} - -long removexattr(char *path, char *name) -{ - errno = ENOSYS; - return -1; -} - -long lremovexattr(char *path, char *name) -{ - errno = ENOSYS; - return -1; -} - -long fremovexattr(int fd, char *name) -{ - errno = ENOSYS; - return -1; -} -#endif - -#endif diff --git a/libsysio/src/symlink.c b/libsysio/src/symlink.c deleted file mode 100644 index 1142432..0000000 --- a/libsysio/src/symlink.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(symlink)(const char *oldpath, const char *newpath) -{ - int err; - struct intent intent; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_CREAT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &pno); - if (err) - goto out; - if (pno->p_base->pb_ino) { - err = -EEXIST; - goto error; - } - - if (IS_RDONLY(pno, pno->p_base->pb_ino)) { - err = -EROFS; - goto error; - } - err = - (*pno->p_parent->p_base->pb_ino->i_ops.inop_symlink)(pno, oldpath); -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __symlink -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(symlink), - PREPEND(__, SYSIO_INTERFACE_NAME(symlink))) -#endif diff --git a/libsysio/src/truncate.c b/libsysio/src/truncate.c deleted file mode 100644 index 718f0af..0000000 --- a/libsysio/src/truncate.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -#include "sysio-symbols.h" - -/* - * Truncate file, given path (alias) or index node. - */ -static int -do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length) -{ - struct intnl_stat stbuf; - unsigned mask; - - if (length < 0) - return -EINVAL; - - if (!ino && pno->p_base->pb_ino) - ino = pno->p_base->pb_ino; - if (!ino) - return -EBADF; - if (S_ISDIR(ino->i_mode)) /* for others too? */ - return -EISDIR; - if (!S_ISREG(ino->i_mode)) - return -EINVAL; - - (void )memset(&stbuf, 0, sizeof(stbuf)); - stbuf.st_size = length; - mask = SETATTR_LEN; - return _sysio_setattr(pno, ino, mask, &stbuf); -} - -static int -PREPEND(_, SYSIO_INTERFACE_NAME(truncate))(const char *path, - _SYSIO_OFF_T length) -{ - int err; - struct pnode *pno; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - err = do_truncate(pno, pno->p_base->pb_ino, length); - P_RELE(pno); - -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#if _LARGEFILE64_SOURCE -#undef truncate64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(truncate)), - SYSIO_INTERFACE_NAME(truncate64)) - -#undef truncate -int -SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(truncate))(path, length); -} -#else -#undef truncate -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(truncate)), - SYSIO_INTERFACE_NAME(truncate)) -#endif - -static int -PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate))(int fd, _SYSIO_OFF_T length) -{ - int err; - struct file *fil; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = 0; - fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } - err = do_truncate(NULL, fil->f_ino, length); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#if _LARGEFILE64_SOURCE -#undef ftruncate64 -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate)), - SYSIO_INTERFACE_NAME(ftruncate64)) - -#undef ftruncate -int -SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length) -{ - - return PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate))(fd, length); -} -#else -#undef ftruncate -sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ftruncate)), - SYSIO_INTERFACE_NAME(ftruncate)) -#endif diff --git a/libsysio/src/unlink.c b/libsysio/src/unlink.c deleted file mode 100644 index c584fcc..0000000 --- a/libsysio/src/unlink.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "fs.h" -#include "mount.h" -#include "sysio-symbols.h" - -int -SYSIO_INTERFACE_NAME(unlink)(const char *path) -{ - struct intent intent; - int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - ino = pno->p_base->pb_ino; - if (IS_RDONLY(pno, ino)) { - err = -EROFS; - goto error; - } - err = (*ino->i_ops.inop_unlink)(pno); - if (err) - goto error; - assert(pno->p_base->pb_ino); - /* - * Invalidate the path node. - */ - ino = pno->p_base->pb_ino; - pno->p_base->pb_ino = NULL; - /* - * Kill the i-node. I've thought and thought about this. We - * can't allow it to be found via namei any longer because we - * can't count on generation numbers support and have no - * clue why there might be other soft-references -- Could - * be an open file. - */ - I_GONE(ino); - -error: - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} - -#ifdef REDSTORM -#undef __unlink -sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(unlink), - PREPEND(__, SYSIO_INTERFACE_NAME(unlink))) -#endif diff --git a/libsysio/src/utime.c b/libsysio/src/utime.c deleted file mode 100644 index 1124663..0000000 --- a/libsysio/src/utime.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysio.h" -#include "inode.h" -#include "file.h" - -int -SYSIO_INTERFACE_NAME(utime)(const char *path, const struct utimbuf *buf) -{ - int err; - struct pnode *pno; - struct utimbuf _utbuffer; - struct intnl_stat stbuf; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; - if (!buf) { - _utbuffer.actime = _utbuffer.modtime = time(NULL); - buf = &_utbuffer; - } - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - stbuf.st_atime = buf->actime; - stbuf.st_mtime = buf->modtime; - err = - _sysio_setattr(pno, - pno->p_base->pb_ino, - SETATTR_ATIME | SETATTR_MTIME, - &stbuf); - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); -} diff --git a/libsysio/tests/Makefile.am b/libsysio/tests/Makefile.am deleted file mode 100644 index 85c4304..0000000 --- a/libsysio/tests/Makefile.am +++ /dev/null @@ -1,114 +0,0 @@ -noinst_PROGRAMS = test_copy test_stats test_path test_list \ - test_getcwd test_link test_unlink test_rename \ - test_regions test_driver - -CLEANFILES=drv_data.c - -if WITH_NATIVE_DRIVER -NATIVE_DRIVER_NAME=native -NATIVE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/native -else -NATIVE_DRIVER_NAME= -NATIVE_DRIVER_CFLAGS= -endif - -if WITH_INCORE_DRIVER -INCORE_DRIVER_NAME=incore -INCORE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/incore -else -INCORE_DRIVER_NAME= -INCORE_DRIVER_CFLAGS= -endif - -if WITH_CPLANT_YOD -YOD_DRIVER_NAME=yod -YOD_DRIVER_CFLAGS= -DCPLANT_YOD -else -YOD_DRIVER_NAME= -YOD_DRIVER_CFLAGS= -endif - -if WITH_SOCKETS_DRIVER -SOCKETS_DRIVER_NAME=sockets -SOCKETS_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/sockets -else -SOCKETS_DRIVER_NAME= -SOCKETS_DRIVER_CFLAGS= -endif - -DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_DRIVER_NAME) $(YOD_DRIVER_NAME) \ - $(STFD_DEV_NAME) $(SOCKETS_DRIVER_NAME) - -CMNSRC=startup.c drv_init_all.c drv_data.c - -BUILT_SOURCES=drv_data.c -check_PROGRAMS=test_driver -if TEST_ALPHA_ARG -TESTS_ENVIRONMENT=IS_ALPHA=yes -else -TESTS_ENVIRONMENT=IS_ALPHA=no -endif -TESTS=test_all.pl - -CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \ - $(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \ - $(STDFD_DEV_CFLAGS) $(YOD_DRIVER_CFLAGS) - -LIBS=$(LIBBUILD_DIR)/libsysio.a - -test_copy_SOURCES=test_copy.c $(CMNSRC) -test_copy_CFLAGS=$(CFL) -test_copy_LDADD=$(LIBS) -test_copy_DEPENDENCIES=$(LIBS) - -test_stats_SOURCES=test_stats.c $(CMNSRC) -test_stats_CFLAGS=$(CFL) -test_stats_LDADD=$(LIBS) -test_stats_DEPENDENCIES=$(LIBS) - -test_path_SOURCES=test_path.c $(CMNSRC) -test_path_CFLAGS=$(CFL) -test_path_LDADD=$(LIBS) -test_path_DEPENDENCIES=$(LIBS) - -test_list_SOURCES=test_list.c $(CMNSRC) -test_list_CFLAGS=$(CFL) -test_list_LDADD=$(LIBS) -test_list_DEPENDENCIES=$(LIBS) - -test_getcwd_SOURCES=test_getcwd.c $(CMNSRC) -test_getcwd_CFLAGS=$(CFL) -test_getcwd_LDADD=$(LIBS) -test_getcwd_DEPENDENCIES=$(LIBS) - -test_link_SOURCES=test_link.c $(CMNSRC) -test_link_CFLAGS=$(CFL) -test_link_LDADD=$(LIBS) -test_link_DEPENDENCIES=$(LIBS) - -test_unlink_SOURCES=test_unlink.c $(CMNSRC) -test_unlink_CFLAGS=$(CFL) -test_unlink_LDADD=$(LIBS) -test_unlink_DEPENDENCIES=$(LIBS) - -test_rename_SOURCES=test_rename.c $(CMNSRC) -test_rename_CFLAGS=$(CFL) -test_rename_LDADD=$(LIBS) -test_rename_DEPENDENCIES=$(LIBS) - -test_regions_SOURCES=test_regions.c $(CMNSRC) -test_regions_CFLAGS=$(CFL) -test_regions_LDADD=$(LIBS) -test_regions_DEPENDENCIES=$(LIBS) - -test_driver_SOURCES=test_driver.c sysio_tests.c sysio_stubs.c help.c $(CMNSRC) -test_driver_CFLAGS=$(CFL) -test_driver_LDADD=$(LIBS) -test_driver_DEPENDENCIES=$(LIBS) - -drv_data.c: $(CONFIG_DEPENDENCIES) $(top_srcdir)/tests/gendrvdata.sh - test -z "drv_data.c" && rm -f drv_data.c; \ - $(SHELL) $(top_srcdir)/tests/gendrvdata.sh $(DRIVERS) > drv_data.c - -AM_CFLAGS = -L$(LIBBUILD_DIR) -include $(top_srcdir)/Rules.make diff --git a/libsysio/tests/README b/libsysio/tests/README deleted file mode 100644 index a8cb7a8..0000000 --- a/libsysio/tests/README +++ /dev/null @@ -1,185 +0,0 @@ -To run the tests, just do a "make check" in the tests subdirectory. -On the CPlant alpha systems, 3 of the 7 tests in test_all.pl are excluded -due to known problems (problems as of the date of writing this; they -may have since been fixed). You can also manually run the individual -tests or ./test_all.pl. If you are running on CPlant, you need to -run test_all.pl with a -alpha argument. Either "make check" or -test_all.pl will run the 7 basic functionality tests (explained -below) and report the total number of passes and failures. -number of passes and failures. - ------------------------SCRIPTS--------------------------------- - -There are a total of 8 scripts: test_copy.pl, test_list.pl, -test_getcwd.pl, test_stats.pl, test_stdfd.pl, test_path.pl, -populator.pl, and verifier.pl. All but the last two scripts -are ran with the test_all.pl script. Here is an explanation -of the scripts. All scripts take an optional "-alpha" arg -for running the scripts in an alpha/cplant environment. The -alpha arg makes certain assumptions about the running of the -environment; for example, it does not initilization and it -starts off the test driver with yod. - -test_copy.pl : This copies a file from src to dest. - : It runs a system cmp to verify that - : the two files are equivalent - -test_list.pl [-p] : This comes in two forms. -test_list.pl [-p] : In the first form, it will - : parse through the getdirentries - : result in order to generate a - : a listing. If the -p option is - : given, it will print out the - : listing. In the second form, it - : mounts mdir into dir and then does - : the listing - -test_getcwd.pl : Tests getcwd by verifying that setting the current - : working directory to dir and then calling getcwd - : returns dir - -test_stats.pl : Verifies that the set of stat calls (stat, fstat, - : fstatvfs, statvfs) return the same set of stats for file - : and that the calls return the same items as Perl's stat - : call (which would use a native library and not libsysio) - -test_stdfd.pl : Verified that stdin, stdout, and stderr can be opened and - : either written to or read from - -test_path.pl ... : Print each path listed and its type. - : If no paths are given, paths are read - : from stdin until a "quit" is given - -populator.pl [-seed seed] : Create a file and populate with random numbers. - [-file filename] : Will use the given seed for the random number - [-bytes bytes] : generator if it is given, otherwise it uses the - : the current time as a seed. The seed used is - : returned. If no filename is given, the file - : will be named randfile.seed.procnum, where seed - : is the seed used and procnum is the process number - : of the script. If no bytes are given, 1024 bytes - : are written. All write commands use libsysio - - -verifier.pl <-seed seed> <-file fname> : Verifies that all bytes in the file fname - : (which was created with populator) match the - : random numbers which would have been used with - : the populator, using the given seed. - - - ------------------------------TEST DRIVER--------------------------------- - - -There are 6 basic commands for the test driver, CALL, PRINT, -ALLOC, FREE, HELP, and exit (EXIT, quit, or QUIT will also work). - -CALL is the main command for running libsysio calls. The format -will depend on the particular libsysio command being ran. -Basically, the format is CALL cmd args. The available commands -used with CALL are (in no particular order): - -fstat iwrite read chdir -fstatvfs iwritev readv chmod -fsync list rmdir chown -ftruncate lseek sizeof close -getcwd lstat stat cmpstr -getdirentries mkdir statvfs creat -init mknod symlink debug -ioctl mount truncate dup -iodone open umask dup2 -iowait umount endian ipread -printline unlink ipreadv pread -write fcntl ipwrite preadv -writev fdatasync ipwritev pwritev -fill iread pwrite ireadv - -The specifics of the commands are explained later. - -The return value from a command can be saved and referenced later -by using a syntax similar to $foo = x. Commands can be combined, such -as: - -CALL fstat ( $fd = CALL open foo ) ( $buf = ALLOC 128 ), - -with some cautionary notes. First, everything needs to be -seperated by a space. File names with spaces in them need to be quoted, -as in: - -$fd = CALL open "file with spaces" O_RDONLY - -Second, any value that is used needs to be identified with an identifier. -In other words, the command: - -$buf = ALLOC ( CALL sizeof stat ) - -will not work, but the command - -$buf = ALLOC ( $size = CALL sizeof stat ) - -will. - - -All commands return a 4 digit status code. The codes are: - -0000 : Success. This does NOT necessarily mean that the libsysio - : command returned success, only that there were no errors - : in issuing the command to libsysio. To get the result of - : the libsysio command, use PRINT $$ . PRINT $errno will return - : the last error code. -0x001 : Invalid arguments given to command -0x002 : Invalid command issued -0x004 : Invalid variable identifier given - - -ALLOC takes a size argument and an optional alignment argument. -FREE takes the variable to free as an argument. -HELP without any arguments displays the list of commands. -HELP will give information on the specific command - -PRINT take several forms. To just print out a variable, type -PRINT $var-name. If the variable is an integer, it will return -the integer. If it is a string, it will print out the string. -If it is a buffer, it will print out the buffer as a series of -hex digits. Note for most buffers, the test driver will not -know what it contains--just because it should contain a string -does not mean that the driver will know that. - -The other form of PRINT is: - -PRINT $var_name - -which will print out length units of the given type starting at -the given offset. The length is the total length in bytes, so -for an integer, a length of 4 would only print out one integer. -The length argument is ignored for strings. Allowable types are -INT SHORT CHAR and LONG. - -For most of the CALL commands, their format is similar to the -related sysio call. The ones that do not have a corresponding -sysio call are listed below: - -init: This MUST be called prior to any sysio calls. It initilizes - : libsysio - -printline: If debugging is turned on, this will print a line number - : with any debug lines - -fill : Fills buffer buf with size - : bytes of val starting at - : buf+offset. The type of val - : can be UINT. STR, or PTR and - : is given by the type arg - -list : Lists contents of dir. If no dir is given, uses cwd - -debug : Sets debug level to num - -sizeof : Gives the size of the obj. Valid objs are char, int, - : long, flock, stat, and statvfs - -endian: returns 0 if the machine is little endian, one otherwise - -cmpstr : Issues a strcmp call on the two buffers to - : see if they are the same. Returns 0 for a - : match diff --git a/libsysio/tests/cleanup.pl b/libsysio/tests/cleanup.pl deleted file mode 100755 index 029286d..0000000 --- a/libsysio/tests/cleanup.pl +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/perl -w - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage: ./cleanup.pl : Remove system directories used for test\n"; - exit(-1); -} - -sub do_remove -{ - my ($cmdfh, $outfh, $type, $cwd, $lastdir) = @_; - my $cmd; - if ($type eq "dir") { - $cmd = "rmdir"; - } else { - $cmd = "unlink"; - } - my $cmdstr = "CALL $cmd $cwd/$lastdir\n"; - - # Now remove the file/dir - helper::send_cmd($cmdfh, $outfh, $cmd, $cmdstr); - - # Verify the directory was made correctly - helper::verify_cmd($cmdfh, $outfh, $cmd); - } - - -my $currarg = 0; -my $is_alpha = 0; -my $alpha_arg = ""; -if (@ARGV == 0) { - usage(); -} -if ((@ARGV > 1) && ($ARGV[$currarg++] eq "-alpha")){ - $is_alpha = 1; - $alpha_arg = $ARGV[$currarg-1]; -} - -my $cwd = $ARGV[$currarg]; - -# Get tests directory -my $testdir = $FindBin::Bin; - -eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -batch -quiet -sz 1 $testdir/test_driver --np"); - } -}; - -if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; -} - -my $outfh = \*OUTFILE; -my $cmdfh = \*CMDFILE; - -if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); -} - -# Remove the helper.pms -do_remove($cmdfh, $outfh, "file", $cwd, "tmp_dir/helper.pm"); -do_remove($cmdfh, $outfh, "file", $cwd, "tmp_dir/test1/helper.pm"); - -# Remove directories -do_remove($cmdfh, $outfh, "dir", $cwd, "tmp_dir/test1"); -do_remove($cmdfh, $outfh, "dir", $cwd, "tmp_dir/test2"); -do_remove($cmdfh, $outfh, "dir", $cwd, "tmp_dir"); - -print $cmdfh "exit\n"; -close $outfh; - -# Give test_driver time to finish -sleep 0.000001; - -print STDOUT "cleanup successful\n"; - -exit 0; - - - - diff --git a/libsysio/tests/drv_init_all.c b/libsysio/tests/drv_init_all.c deleted file mode 100644 index 6a3ad2b..0000000 --- a/libsysio/tests/drv_init_all.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern int (*drvinits[])(void); - -/* - * Init all the drivers we know about. - */ -int -drv_init_all() -{ - int (**f)(void); - int err; - - err = 0; - f = drvinits; - while (*f) { - err = (**f++)(); - if (err) - return err; - } - - return 0; -} diff --git a/libsysio/tests/gendrvdata.sh b/libsysio/tests/gendrvdata.sh deleted file mode 100644 index 8b84d82..0000000 --- a/libsysio/tests/gendrvdata.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -# This Cplant(TM) source code is the property of Sandia National -# Laboratories. -# -# This Cplant(TM) source code is copyrighted by Sandia National -# Laboratories. -# -# The redistribution of this Cplant(TM) source code is subject to the -# terms of the GNU Lesser General Public License -# (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) -# -# Cplant(TM) Copyright 1998-2003 Sandia Corporation. -# Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive -# license for use of this work by or on behalf of the US Government. -# Export of this program may require a license from the United States -# Government. - -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Questions or comments about this library should be sent to: -# -# Lee Ward -# Sandia National Laboratories, New Mexico -# P.O. Box 5800 -# Albuquerque, NM 87185-1110 -# -# lee@sandia.gov - -echo '/*' -echo ' * This file automatically generated by gendrvdata.sh. All changes' -echo ' * will be lost!' -echo ' */' -echo -echo '#include ' -echo -echo '#include "test.h"' -echo -for i in $@; do - echo "extern int _sysio_${i}_init(void);" -done -echo -echo 'int (*drvinits[])(void) = {' - -for i in $@; do - echo " _sysio_${i}_init," -done -echo " NULL" -echo "};" diff --git a/libsysio/tests/help.c b/libsysio/tests/help.c deleted file mode 100644 index ad5a769..0000000 --- a/libsysio/tests/help.c +++ /dev/null @@ -1,551 +0,0 @@ -#include -#include "test_driver.h" - -void do_help() { - int i, d, count = 0; - - fprintf(outfp, "libsysio test harness\n"); - fprintf(outfp, "To get help on a specific command, use HELP \n"); - fprintf(outfp, "To exit, type exit or quit\n"); - - fprintf(outfp, "\nTo save the result from a function, use \"$res = CALL command\"\n"); - fprintf(outfp, "To later use that res, do \"comm $res\"\n"); - - fprintf(outfp, "\n\nAvailable commands are (always preceded by CALL):\n\n"); - - /* Get total number of commands */ - while (cmd_list[count].cmd) - count++; - - d = count/4; - if (count % 4) - d++; - for (i=0; i < d; i++) { - - if ( (i+d) < count ) { - if ( (i + 2*d) < count) { - if ( (i+3*d) < count) - fprintf(outfp, "%-15s %-15s %-15s %-15s\n", - cmd_list[i].cmd, cmd_list[i+d].cmd, cmd_list[i+2*d].cmd, - cmd_list[i+3*d].cmd); - else - fprintf(outfp, "%-15s %-15s %-15s\n", - cmd_list[i].cmd, cmd_list[i+d].cmd, cmd_list[i+2*d].cmd); - } else - fprintf(outfp, "%-15s %-15s\n", - cmd_list[i].cmd, cmd_list[i+d].cmd); - } else - fprintf(outfp, "%-15s\n", - cmd_list[i].cmd); - } - fprintf(outfp, "\n"); -} - -void usage_setdebug() -{ - fprintf(outfp, "setdebug [level]: Set debugging level to level\n"); -} - -void usage_setbuf() -{ - fprintf(outfp, "setbuf [val] [size] [buf] [off]: fill size bytes of buf with byte val\n"); -} - - -void usage_clear() -{ - fprintf(outfp, "clear buf: zero out the buffer\n"); -} - -void usage_printline() -{ - fprintf(outfp, "printline [0|1]: Turn off (0) or on (1) the printing of line number\n"); - fprintf(outfp, " : and file name with debug output\n"); -} - -void usage_endian() -{ - fprintf(outfp, "endian: returns 1 for bigendian machines and 0 for little endian machines\n"); -} - - -void usage_sizeof() -{ - fprintf(outfp, "sizeof [type]: returns the size of the data type. Currently \n"); - fprintf(outfp, " : supported types are char, int, long, flock, stat and \n"); - fprintf(outfp, " : statvfs\n"); -} - - -void usage_get_buffer() -{ - fprintf(outfp, "alloc [size] : allocates a buffer of size bytes aligned to align\n"); - fprintf(outfp, " : align is optional. If not there, buffer will be aligned on\n"); - fprintf(outfp, " : a one-byte boundary. returns an index into an array that \n"); - fprintf(outfp, " : holds the buffer\n"); -} - - - -void usage_free_buffer() -{ - fprintf(outfp, "free [bufidx]: frees buffer at bufidx. Returns 0 on success, -1 on failure\n"); -} - -void usage_do_fillbuff() -{ - fprintf(outfp, "fill [val] [type] [size] [offset] [buf] : Fills the buffer buf with size \n"); - fprintf(outfp, " : bytes of val starting at buf+offset\n"); - fprintf(outfp, " : The type of val is specified by type,\n"); - fprintf(outfp, " : which can be UINT, STR, or PTR\n"); -} - -void usage_do_printbuf() -{ - fprintf(outfp, "printbuf [buf] : print out contents of the buffer stored in buf\n"); - fprintf(outfp, " : Always returns 0\n"); -} - -void usage_cmpbufs() -{ - fprintf(outfp, "cmpstr [buf1] [buf2]: Compare the contents of buf1 with buf2 by issuing a \n"); - fprintf(outfp, " strcmp call. Returns 0 if the buffers match\n"); -} - - -void usage_init() -{ - fprintf(outfp, "init : Without any arguments, initilizes libsysio\n"); - fprintf(outfp, " : to default values for root directory and\n"); - fprintf(outfp, " : current directory. Accepts optional\n"); - fprintf(outfp, " : arguments for the root driver, the mount\n"); - fprintf(outfp, " : path, and the mount flags. Must be called\n"); - fprintf(outfp, " : before any other libsysio calls. Returns\n"); - fprintf(outfp," : 0 on success, -1 on failure\n"); -} - -void usage_list() -{ - fprintf(outfp, "list : lists contents of dir. If dir is ommitted, will list contents\n"); - fprintf(outfp, " : of the current working directory\n"); - fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); -} - -void usage_chdir() -{ - fprintf(outfp, "chdir [dir]: change the current working directory to dir\n"); - fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); -} - -void usage_chmod() -{ - fprintf(outfp, "chmod [newmode] [file]: change mode of file to newmode. newmode can be \n"); - fprintf(outfp, " : specifed symbolically (eg, a+x), numerically \n"); - fprintf(outfp, " : (eg, 0777), or using system defines \n"); - fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP)\n"); - fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); - -} - -void usage_chown() -{ - fprintf(outfp, "chown [newown[:newgrp]] [file]: change the owner of file to newown, the group\n"); - fprintf(outfp, " : of file to newgrp, or both\n"); - fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); -} - -void usage_open() -{ - fprintf(outfp, "open [file] [flags] : open file with given flags. The mode is optional\n"); - fprintf(outfp, " : can use defines for open, (eg, open foo O_RDONLY)\n"); - fprintf(outfp, " : If flags are 0, file will be opened with O_RDWR\n"); - fprintf(outfp, " : Returns the file descriptor for the opened file\n"); -} - -void usage_close() -{ - fprintf(outfp, "close [file]: closes the file. Returns 0 on success, -1 on failure\n"); -} - -void usage_mount() -{ - fprintf(outfp, "mount [fstype:source] [target]: mount source (which has fstype as its file\n"); - fprintf(outfp, " : system type) onto target.\n"); - fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); -} - -void usage_dup() -{ - fprintf(outfp, "dup [oldfd]: Duplicate oldfd. Returns the duplicated file descriptor\n"); - fprintf(outfp, " : Returns -1 on failure\n"); -} - -void usage_dup2() -{ - fprintf(outfp, "dup2 [oldfd] [newfd]: Make newfd be a copy of oldfd. Returns newfd on \n"); - fprintf(outfp, " : success and -1 on failure\n"); -} - -void usage_fcntl() -{ - fprintf(outfp, "fcntl [fd] [cmd] : execute fcntl cmd on file with file descriptor fd\n"); - fprintf(outfp, " : using (optional) args. Accepted (but not \n"); - fprintf(outfp, " : necesarily working) commands are F_DUPFD, \n"); - fprintf(outfp, " : F_GETFD, F_GETFL, F_GETOWN, F_SETFD, F_SETFL,\n"); - fprintf(outfp, " : F_SETOWN, F_SETLK, F_SETLKW, and F_GETLK. \n"); -} - -void usage_fstat() -{ - fprintf(outfp, "fstat [fd] [buf]: Get the stat structure for file descriptor fd and place it\n"); - fprintf(outfp, " : in buf. Returns 0 on success, -1 on failure\n"); -} - -void usage_fsync() -{ - fprintf(outfp, "fsync [fd]: ensure all parts of file with file descriptor fd are output to\n"); - fprintf(outfp, " : stable storage. Returns 0 on success, -1 on failure\n"); -} - -void usage_fdatasync() -{ - fprintf(outfp, "fdatasync [fd]: ensure all parts of file with file descriptor fd except the \n"); - fprintf(outfp, " : metadata are output to stable storage. Returns 0 on \n"); - fprintf(outfp, " : success, -1 on failure\n"); -} - -void usage_ftruncate() -{ - fprintf(outfp, "ftruncate [fd] [len]: truncate file with file descriptor fd to have be \n"); - fprintf(outfp, " : len bytes in length. Returns 0 on success, -1 on \n"); - fprintf(outfp, " : failure\n"); -} - -void usage_getcwd() -{ - fprintf(outfp, "getcwd [buf] [size]: get the current working directory and store it in buf\n"); - fprintf(outfp, " : buf is size bytes in length. If buf is too short, an \n"); - fprintf(outfp, " : error of ERANGE is returned. Returns 0 on success, -1\n"); - fprintf(outfp, " : on failure\n"); -} - -void usage_lseek() -{ - fprintf(outfp, "lseek [fd] [offset] [whence]: Sets the offset of the file descriptor fd to\n"); - fprintf(outfp, " : either offset if whence is SEEK_SET or offset\n"); - fprintf(outfp, " : plus the current location if whence is SEEK_CUR\n"); - fprintf(outfp, " : or offset plus the size of the file if whence\n"); - fprintf(outfp, " : is SEEK_END. Returns 0 on success and -1 on \n"); - fprintf(outfp, " : failure\n"); -} - -void usage_lstat() -{ - fprintf(outfp, "lstat [filename] [buf]: Get the stat structure for filename and return it in\n"); - fprintf(outfp, " : buf. Returns 0 on success and -1 on failure\n"); -} - -void usage_getdirentries() -{ - fprintf(outfp, "getdirentries [fd] [buf] [nbytes] [basep]: Read dir entries from directory\n"); - fprintf(outfp, " : with file descriptor fd into buf\n"); - fprintf(outfp, " : At most nbytes are read. Reading\n"); - fprintf(outfp, " : starts at basep, and basep is set\n"); - fprintf(outfp, " : to new pos. Returns the number of \n"); - fprintf(outfp, " : bytes read on success or 0 on\n"); - fprintf(outfp, " : failure\n"); - fprintf(outfp, "Note that basep does not have to be pre-allocated. Executing cmd: \n"); - fprintf(outfp, "\"getdirentries $fd $buf 4096 $basep\", where $fd is the result of an open\n"); - fprintf(outfp, "and $buf is the result of an alloc (but $basep is totally new) will work\n"); - fprintf(outfp, "After the execution of the command, $basep holds the new offset and can be\n"); - fprintf(outfp, "used again for any further getdirentries calls\n"); -} - -void usage_mkdir() -{ - fprintf(outfp, "mkdir [newdir] [mode]: make a new directory, newdir, with the permissions \n"); - fprintf(outfp, " : specified in mode. Permissions can be symbolic \n"); - fprintf(outfp, " : (eg, a+x), numeric (eg, 0777), or can use defines\n"); - fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP). Returns 0 on success \n"); - fprintf(outfp, " : -1 on failure.\n"); -} - - -void usage_creat() -{ - fprintf(outfp, "creat [newfile] [mode]: create a new file, newfile, with the permissions \n"); - fprintf(outfp, " : specified in mode. Permissions can be symbolic \n"); - fprintf(outfp, " : (eg, a+x), numeric (eg, 0777), or can use defines\n"); - fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP). Returns 0 on success \n"); - fprintf(outfp, " : -1 on failure.\n"); -} - -void usage_stat() -{ - fprintf(outfp, "stat [filename] [buf]: Get the stat structure for filename and return it in\n"); - fprintf(outfp, " : buf. Returns 0 on success and -1 on failure\n"); -} - -void usage_statvfs() -{ - fprintf(outfp, "statvfs [filename] [buf]: Get the statvfs structure for filename and return\n"); - fprintf(outfp, " : it in buf. Returns 0 on success and -1 on failure\n"); -} - -void usage_fstatvfs() -{ - fprintf(outfp, "fstatvfs [fd] [buf]: Get the stat structure for file with file descriptor fd\n"); - fprintf(outfp, " : and return it in buf. Returns 0 on success and -1 on\n"); - fprintf(outfp, " : failure\n"); -} - -void usage_truncate() -{ - fprintf(outfp, "truncate [fname] [len]: truncate file with name fname to be exactly \n"); - fprintf(outfp, " : len bytes in length. Returns 0 on success, -1 on \n"); - fprintf(outfp, " : failure\n"); -} - -void usage_rmdir() -{ - fprintf(outfp, "rmdir [dirname]: Remove directory at dirname. Returns 0 on success, -1 on\n"); - fprintf(outfp, " : failure.\n"); -} - -void usage_symlink() -{ - fprintf(outfp, "symlink [path1] [path2]: Make a symbolic link from path1 to path2. Returns\n"); - fprintf(outfp, " : 0 on success, -1 on failure\n"); -} - -void usage_unlink() -{ - fprintf(outfp, "unlink [path]: Unlink path. If path is the last name to a file, the file is \n"); - fprintf(outfp, " : is removed. If it was a symbolic link, the link is removed. \n"); - fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); -} - -void usage_ioctl() -{ - fprintf(outfp, "ioctl [fd] [cmd] : Issue the ioctl command cmd on the file with file\n"); - fprintf(outfp, " : descriptor fd. Any arguments are placed in args\n"); - fprintf(outfp, " : At the moment, the only commands understand are the \n"); - fprintf(outfp, " : ioctl commands found in /usr/include/linux/fs.h\n"); -} - -void usage_umask() -{ - fprintf(outfp, "ioctl [mask] : Sets the umask used by open to set initial file permissions on\n"); - fprintf(outfp, " : a newly created file. Returnds the previous value of the mask\n"); -} - -void usage_iodone() -{ - fprintf(outfp, "iodone [ioid] : Poll for completion of the asynchronous request identifed by\n"); - fprintf(outfp, " : ioid. Returns 1 if request finished\n"); -} - -void usage_iowait() -{ - fprintf(outfp, "iowait [ioid] : Wait for completion of the asynchronous request identifed by\n"); - fprintf(outfp, " : ioid. Returns result of asynchronous request \n"); -} - -void usage_ipreadv() -{ - fprintf(outfp, "ipreadv [fd] [buf] [count] [off]: Reads data asynchrously to file descriptor fd \n"); - fprintf(outfp, " : starting at offset off. Data comes from \n"); - fprintf(outfp, " : buffer described by buf, which is a pointer to\n"); - fprintf(outfp, " : an iovec strucutre. Number of buffers is \n"); - fprintf(outfp, " : specified by count. Returns an iod_t on \n"); - fprintf(outfp, " : success and -1 on failure\n"); -} - -void usage_ipread() -{ - fprintf(outfp, "ipread [fd] [buf] [count] [off]: Read asynchrously up to count bytes from file\n"); - fprintf(outfp, " : with file descriptor fd starting at offset off\n"); - fprintf(outfp, " : Read into buffer pointed at by buf. Returns\n"); - fprintf(outfp, " : an iod_t on success and -1 on failure\n"); -} - -void usage_preadv() -{ - fprintf(outfp, "preadv [fd] [buf] [count] [off]: Reads data from file descriptor fd starting at\n"); - fprintf(outfp, " : offset off. Data goes into buffer described\n"); - fprintf(outfp, " : by buf, which is a pointer to an iovec \n"); - fprintf(outfp, " : structure. Number of buffers is specified by\n"); - fprintf(outfp, " : count. Returns the number of bytes read\n"); -} - -void usage_pread() -{ - fprintf(outfp, "preadv [fd] [buf] [count] [off]: Reads count bytes of data from file descriptor\n"); - fprintf(outfp, " : fd starting at offset off. Data goes into buf.\n"); - fprintf(outfp, " : Returns number of bytes read or -1 on failure\n"); -} - -void usage_ireadv() -{ - fprintf(outfp, "ireadv [fd] [buf] [count] : Reads data asynchrously to file descriptor fd \n"); - fprintf(outfp, " : Data comes from buffer described by buf, which is \n"); - fprintf(outfp, " : an pointer to an iovec structure. Number of\n"); - fprintf(outfp, " : buffers is specified by count. Returns an iod_t\n"); - fprintf(outfp, " : on success and -1 on failure\n"); -} - -void usage_iread() -{ - fprintf(outfp, "iread [fd] [buf] [count]: Read asynchrously up to count bytes from file with\n"); - fprintf(outfp, " : file descriptor fd into buffer pointed at by buf\n"); - fprintf(outfp, " : Returns an iod_t on success and -1 on failure\n"); -} - -void usage_readv() -{ - fprintf(outfp, "readv [fd] [buf] [count] : Reads data from file descriptor fd. Data comes from\n"); - fprintf(outfp, " : the buffer described by buf, which is a pointer to an\n"); - fprintf(outfp, " : an iovec structure. Number of buffers is specified\n"); - fprintf(outfp, " : by count. Returns the number of bytes read on \n"); - fprintf(outfp, " : on success and -1 on failure\n"); -} - -void usage_read() -{ - fprintf(outfp, "read [fd] [buf] [count]: Read up to count bytes from file with file \n"); - fprintf(outfp, " : descriptor fd into buffer pointed at by buf\n"); - fprintf(outfp, " : Returns number of bytes read on success or 0 on \n"); - fprintf(outfp, " : on failure\n"); -} - -void usage_ipwritev() -{ - fprintf(outfp, "ipwritev [fd] [buf] [count] [off]: writes data asynchronously to file with file\n"); - fprintf(outfp, " : descriptor fd starting at offset off. Data \n"); - fprintf(outfp, " : comes from buffers described by buf, which\n"); - fprintf(outfp, " : is a pointer to an iovec structure. Number \n"); - fprintf(outfp, " : of buffers is specified by count. Returns\n"); - fprintf(outfp, " : an iod_t on success and -1 on failure\n"); -} - -void usage_ipwrite() -{ - fprintf(outfp, "ipwrite [fd] [buf] [count] [off]: writes count bytes of data asynchronously to\n"); - fprintf(outfp, " : file with file descriptor fd starting at \n"); - fprintf(outfp, " : offset off. Data comes from buf. Returns an\n"); - fprintf(outfp, " : iod_t on success and -1 on failure\n"); -} - -void usage_pwritev() -{ - fprintf(outfp, "pwritev [fd] [buf] [count] [off]: writes data to file with file descriptor fd\n"); - fprintf(outfp, " : starting at offset off. Data comes from \n"); - fprintf(outfp, " : buffers described by buf, which is a pointer\n"); - fprintf(outfp, " : to an iovec structure. Number of buffers is\n"); - fprintf(outfp, " : by count. Returns number of bytes read on \n"); - fprintf(outfp, " : success and -1 on failure\n"); -} - -void usage_pwrite() -{ - fprintf(outfp, "pwrite [fd] [buf] [count] [off]: writes count bytes of data to file with file \n"); - fprintf(outfp, " : descriptor fd starting at offset off. Data\n"); - fprintf(outfp, " : Data comes from buf. Returns number of bytes\n"); - fprintf(outfp, " : written on success and -1 on failure\n"); -} - -void usage_iwritev() -{ - fprintf(outfp, "iwritev [fd] [buf] [count] : writes data asynchronously to file with file\n"); - fprintf(outfp, " : descriptor fd. Data comes from buffers described\n"); - fprintf(outfp, " : by buf, which is a pointer to an iovec structure.\n"); - fprintf(outfp, " : Number of buffers is specified by count. Returns\n"); - fprintf(outfp, " : an iod_t on success and -1 on failure\n"); -} - -void usage_iwrite() -{ - fprintf(outfp, "iwrite [fd] [buf] [count] : writes count bytes of data asynchronously to\n"); - fprintf(outfp, " : file with file descriptor fd. Data comes from buf.\n"); - fprintf(outfp, " : Returns an iod_t on success and -1 on failure.\n"); -} - -void usage_writev() -{ - fprintf(outfp, "writev [fd] [buf] [count]: writes data to file descriptor fd. Data comes from\n"); - fprintf(outfp, " : buffers described by buf, which is a pointer to a \n"); - fprintf(outfp, " : iovec strucutre. Number of buffers is specified by \n"); - fprintf(outfp, " : count \n"); -} - -void usage_write() -{ - fprintf(outfp, "write [fd] [buf] [count] : writes count bytes of data to file with file \n"); - fprintf(outfp, " : descriptor fd. Data comes from buf. Returns number\n"); - fprintf(outfp, " : of bytes written on success and -1 on failure.\n"); -} - -void usage_mknod() -{ - fprintf(outfp, "mknod [path] [mode] [dev] : creates a filesystem node named path with \n"); - fprintf(outfp, " : specified mode using device special file dev\n"); - fprintf(outfp, " : Returns 0 on sucess and -1 on failure\n"); -} - - -void usage_umount() -{ - fprintf(outfp, "umount [path] : Umount file at path. Returns 0 on success and -1 on failure\n"); -} - -void usage_init_iovec() -{ - fprintf(outfp, "init_iovec buf offset len num iov_buf: Init iovector. iov_uf points to an array of\n"); - fprintf(outfp, " iovecs, num is the number of the iovec, \n"); - fprintf(outfp, " buf is the buffer to be used, offset \n"); - fprintf(outfp, " specifies how far into the buffer the iovec\n"); - fprintf(outfp, " should point and len is the iov length\n"); -} - -void usage_init_xtvec() -{ - fprintf(outfp, "init_xtvec offset len num buf: Init xtvector. Buf points to an array of\n"); - fprintf(outfp, " xtvecs, num is the number of the xtvec, offset\n"); - fprintf(outfp, " is xtv_off and len is the iov lenghth\n"); - fprintf(outfp, " the iov length\n"); -} - -void usage_writex() -{ - fprintf(outfp, "writex fd iovs iov_cnt xtvs xtvcnt: Write iov_cnt iovecs out to file using\n"); - fprintf(outfp, " xtvcnt xtvecs\n"); -} - -void usage_iwritex() -{ - fprintf(outfp, "iwritex fd iovs iov_cnt xtvs xtvcnt: Write iov_cnt iovecs out to file using\n"); - fprintf(outfp, " xtvcnt xtvecs\n"); -} - -void usage_readx() -{ - fprintf(outfp, "readx fd iovs iov_cnt xtvs xtvcnt: Read iov_cnt iovecs out from file using\n"); - fprintf(outfp, " xtvcnt xtvecs\n"); -} - -void usage_ireadx() -{ - fprintf(outfp, "ireadx fd iovs iov_cnt xtvs xtvcnt: Read iov_cnt iovecs out from file using\n"); - fprintf(outfp, " xtvcnt xtvecs\n"); -} - - -void usage_checkbuf() -{ - fprintf(outfp, "checkbuf [buf] [size] [val] [off]: Staring at offset off, checks to see\n"); - fprintf(outfp, " if val is in first size bytes of buf\n"); -} - -void usage_exit() -{ -} diff --git a/libsysio/tests/helper.pm b/libsysio/tests/helper.pm deleted file mode 100644 index f656867..0000000 --- a/libsysio/tests/helper.pm +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/perl -w - -# -# Provides a set of helper routines for use in the Perl -# test scripts -# - -package helper; -use strict; -use POSIX; - -BEGIN{} - -# Print out a given error message, close the command file -# and exit -sub print_and_exit -{ - my ($cmdfh, $outfh, $exit_num, $exit_str) = @_; - - print STDOUT "$exit_str"; - - # Clean up - my $cmdstr = 'FREE $buf'; - $cmdstr = $cmdstr."\n"; - - print $cmdfh $cmdstr; - - my $res = <$outfh>; - if (defined $res) { - chop($res); - } - - - print $cmdfh "exit\n"; - close $outfh; - - # Give test_driver time to finish - sleep 0.000001; - - exit $exit_num; -} - - -# Output the given command and make sure that the exit -# code for the command was valid -sub send_cmd -{ - my ($cmdfh, $outfh, $cmd, $cmdstr) = @_; - - print $cmdfh $cmdstr; - - my $res = <$outfh>; - if (defined $res) { - chop($res); - } else { - print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n"); - } - - if ($res ne "0000 ") { - print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n"); - } -} - -# Check the return value from the last libsysio call -sub verify_cmd -{ - - my ($cmdfh, $outfh, $cmd) = @_; - - # Verify the system call's output - my $cmdstr = 'PRINT $$'; - $cmdstr .= "\n"; - send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - my $res = <$outfh>; - if (defined $res) { - chop($res); - } else { - print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n"); - } - - if ($res eq "0xffffffff") { - - # Get the errno - $cmdstr = 'PRINT $errno'; - $cmdstr .= "\n"; - send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - my $err = <$outfh>; - if (defined $err) { - chop($err); - } else { - print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n"); - } - - print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $err\n"); - } - return $res; -} - -# Compares two numbers. Output error message and exit if -# they differ -sub cmp_nums -{ - my ($cmdfh, $outfh, $ionum, $pnum, $desc) = @_; - - my $str; - if (!defined($ionum)) { - print_and_exit($cmdfh, $outfh, 1, "ERROR! ionum for $desc undefined"); - } elsif (!defined($pnum)) { - print_and_exit($cmdfh, $outfh, 1, "ERROR! pnum for $desc undefined"); - } - if ($ionum != $pnum) { - my $str = sprintf("ERROR! Sysio's number %x does not match Perl's (%x)\n", - $ionum, $pnum); - $str = sprintf("%s Numbers were %s\n", $str, $desc); - print_and_exit($cmdfh, $outfh, 1, $str); - } -} - -sub get_type -{ - my $mode = $_[0]; - my $t = '?'; - - if (S_ISDIR($mode)) { - $t = 'd'; - } elsif (S_ISCHR($mode)) { - $t = 'c'; - } elsif (S_ISBLK($mode)) { - $t = 'b'; - } elsif (S_ISREG($mode)) { - $t = 'f'; - } elsif (S_ISFIFO($mode)) { - $t = 'p'; - } elsif (S_ISLNK($mode)) { - $t = 'S'; - } elsif (S_ISSOCK($mode)) { - $t = 's'; - } - - return $t; -} - -END{} - -1; diff --git a/libsysio/tests/module.mk b/libsysio/tests/module.mk deleted file mode 100644 index b6ed491..0000000 --- a/libsysio/tests/module.mk +++ /dev/null @@ -1,2 +0,0 @@ -TESTS_EXTRA = $(shell ls tests/*.[ch] tests/*.sh tests/*.p[lm]) \ - tests/Makefile.am tests/Makefile.in tests/module.mk diff --git a/libsysio/tests/populator.pl b/libsysio/tests/populator.pl deleted file mode 100755 index b218519..0000000 --- a/libsysio/tests/populator.pl +++ /dev/null @@ -1,155 +0,0 @@ -#!/usr/bin/perl -w - -use IPC::Open2; - -use strict; -use helper; - -sub usage -{ - print "Usage: ./populator.pl <-seed seed> :\n"; - print " <-file filename> :\n"; - print " <-bytes bytes> : Create a file, filename, that\n"; - print " : is bytes long and populate with\n"; - print " : random numbers using the given\n"; - print " : seed. Will use defaults if args\n"; - print " : not given\n"; - exit(-1); -} - -sub get_buf -{ - my $MAX_SIZE = 2147483648; - - my $str; - my $num; - my $len = 0; - - while ($len < 512) { - $num = rand $MAX_SIZE; - my $tmpstr = sprintf("%d", $num); - $str .= $tmpstr; - $len += length $tmpstr; - } - - return ($len, $str); -} - -sub write_file -{ - my ($cmdfh, $outfh, $filename, $bytes) = @_; - - - # Allocate the read buffer - my $cmd = '$buf = ALLOC 1024'."\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmd); - - # Open (create) the new file - $cmd = '$fd = CALL open '."$filename O_RDWR|O_CREAT S_IRWXU\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmd); - - # Verify the system call's output - helper::verify_cmd($cmdfh, $outfh, "open"); - - my $left_bytes = $bytes; - while ($left_bytes > 0) { - # Get a buffer filled with random numbers - # Buffer will be no less than 512 bytes - my ($len, $buf) = get_buf; - if ($len > $left_bytes) { - $len = $left_bytes; - } - - # Need to fill $buf with the buffer - $cmd = "CALL fill $buf STR $len 0 ".'$buf'."\n"; - helper::send_cmd($cmdfh, $outfh, "fill", $cmd); - - # Write out $len bytes to $filename - $cmd = 'CALL write $fd $buf '."$len\n"; - - helper::send_cmd($cmdfh, $outfh, "write", $cmd); - - my $written_bytes = helper::verify_cmd($cmdfh, $outfh, "write"); - $written_bytes = oct($written_bytes); - if ($written_bytes != $len) { - helper::print_and_exit($cmdfh, $outfh, 1, - "ERROR! Meant to print out $len but only printed $written_bytes\n"); - } - - $left_bytes -= $len; - } -} - -sub populate_file -{ - my ($filename, $bytes, $is_alpha) = @_; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -batch -quiet -sz 1 ./test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - # Now write the file - write_file($cmdfh, $outfh, $filename, $bytes); - - # Close the file - my $cmd = 'CALL close $fd'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmd); - - helper::verify_cmd($cmdfh, $outfh, "close"); - - # All done - helper::print_and_exit($cmdfh, $outfh, 0, "File $filename successfully created\n"); -} - - -my $is_alpha = 0; -my $seed = time; -my $filename = "randfile.$seed.$$"; -my $bytes = 1024; -for (my $i = 0; $i < @ARGV; $i++) -{ - if ($ARGV[$i] eq "-file") { - $i++; - $filename = $ARGV[$i]; - } elsif ($ARGV[$i] eq "-seed") { - $i++; - $seed = $ARGV[$i]; - } elsif ($ARGV[$i] eq "-alpha") { - $is_alpha = 1; - } elsif ($ARGV[$i] eq "-bytes") { - $i++; - $bytes = $ARGV[$i]; - } -} - -# seed the randome number generator -srand $seed; - -populate_file($filename, $bytes, $is_alpha); - -exit $seed; - - - - diff --git a/libsysio/tests/setup.pl b/libsysio/tests/setup.pl deleted file mode 100755 index 4270f59..0000000 --- a/libsysio/tests/setup.pl +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/perl -w - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage: ./setup.pl : Setup initial system directories for test\n"; - exit(-1); -} - -sub do_makedir -{ - my ($cmdfh, $outfh, $cwd, $lastdir) = @_; - my $cmd = "CALL mkdir $cwd/$lastdir 0777\n"; - - # Now create newdir - helper::send_cmd($cmdfh, $outfh, "mkdir", $cmd); - - # Verify the directory was made correctly - helper::verify_cmd($cmdfh, $outfh, "mkdir"); - } - - -my $currarg = 0; -my $is_alpha = 0; -my $alpha_arg = ""; -if (@ARGV == 0) { - usage(); -} -if ((@ARGV > 1) && ($ARGV[$currarg++] eq "-alpha")){ - $is_alpha = 1; - $alpha_arg = $ARGV[$currarg-1]; -} - -my $cwd = $ARGV[$currarg]; - -# Get tests directory -my $testdir = $FindBin::Bin; - -eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -batch -quiet -sz 1 $testdir/test_driver --np"); - } -}; - -if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; -} - -my $outfh = \*OUTFILE; -my $cmdfh = \*CMDFILE; - -if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); -} - - -# Create tmp_dir -do_makedir($cmdfh, $outfh, $cwd, "tmp_dir"); -do_makedir($cmdfh, $outfh, $cwd, "tmp_dir/test1"); -do_makedir($cmdfh, $outfh, $cwd, "tmp_dir/test2"); - -# Copy helper.pm -print STDERR "Copying $testdir/helper.pm to $cwd/tmp_dir/test1/helper.pm\n"; -my $res = `perl $testdir/test_copy.pl $alpha_arg $testdir/helper.pm $cwd/tmp_dir/test1/helper.pm`; -chop($res); - -if ($res ne "copy test successful") { - print STDERR "setup (copy test) failed with message: $res\n"; - print $cmdfh "exit\n"; - close $outfh; - - # Give test_driver time to finish - sleep 0.000001; - - print STDOUT "Copying of helper.pm failed\n"; - exit 1; -} - - print $cmdfh "exit\n"; -close $outfh; - -# Give test_driver time to finish -sleep 0.000001; - -print STDOUT "setup successful\n"; - -exit 0; - - - - diff --git a/libsysio/tests/startup.c b/libsysio/tests/startup.c deleted file mode 100644 index 82a92cb..0000000 --- a/libsysio/tests/startup.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "test.h" - -#include "sysio.h" - -int -_test_sysio_startup() -{ - int err; - const char *s; - - err = _sysio_init(); - if (err) - return err; - err = drv_init_all(); - if (err) - return err; - s = getenv("SYSIO_NAMESPACE"); - if (s) - err = _sysio_boot(s); - else if (!(s = getenv("SYSIO_MANUAL"))) { - /* - * Assume a native mount at root. - */ - err = _sysio_boot("{mnt,dev=\"native:/\",dir=/,fl=0}"); - } - if (err) - return err; - - s = getenv("SYSIO_CWD"); - if (s) { - err = chdir(s); - if (err) - return err; - } - - return 0; -} - -void -_test_sysio_shutdown() -{ - - _sysio_shutdown(); -} diff --git a/libsysio/tests/sysio_stubs.c b/libsysio/tests/sysio_stubs.c deleted file mode 100644 index 439804d..0000000 --- a/libsysio/tests/sysio_stubs.c +++ /dev/null @@ -1,2706 +0,0 @@ -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "sysio.h" -#include "test_driver.h" - -/* - * ################################################ - * # Function stubs # - * # These allow all of the different commands # - * # to be called with the same format # - * ################################################ - */ - -int test_do_setdebug(int argc, char **argv) -{ - int level; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for setdebug\n", - argc)); - return INVALID_ARGS; - } - - level = atoi(argv[0]); - - if (level < 0) { - DBG(2, fprintf(outfp, "Invalid debug level %d\n", level)); - return INVALID_ARGS; - } - - debug_level = level; - return SUCCESS; -} - -int test_do_printline(int argc, char **argv) -{ - int on; - - - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for printline\n", - argc)); - return INVALID_ARGS; - } - - on = atoi(argv[0]); - if (on) - print_line = 1; - else - print_line = 0; - - return SUCCESS; -} - -/* -int test_do_setoutput(int argc, char **argv) -{ - FILE *newfp; - - if (argc != 1) { - fprintf(outfp, "Invalid number of args (%d) for setoutput\n", - argc); - return -1; - } - - newfp = fopen(argv[0], "w"); - if (!newfp) { - fprintf(outfp, "Unable to open new output file %s\n", argv[0]); - return -1; - } - - outfp = newfp; - - return 0; -} - -*/ - - -int test_do_fillbuff(int argc, char **argv) -{ - char *typestr, *buf; - void *valptr; - int size, type, index, offset; - - if (argc != 5) { - DBG(2, - fprintf(outfp, - "fillbuff requires a value, a type, a size, an offset, and the target buffer\n")); - fprintf(stderr, "fillbuff requires 5 args, you gave %d\n", argc); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Do not understand offset %s\n", argv[3])); - return INVALID_VAR; - } - - index = get_obj(argv[4]); - if (index < 0) { - DBG(2, fprintf(outfp, "Can't find buffer at %s\n", argv[4])); - return INVALID_VAR; - } - buf = (char *)(buflist[index]->buf)+offset; - - DBG(4, fprintf(outfp, "Buffer start is at %p\n", (void *)buflist[index])); - - typestr = argv[1]; - size = get_obj(argv[2]); - if (size < 0) { - DBG(2, fprintf(outfp, "Unable to understand size %s\n", argv[2])); - return INVALID_VAR; - } - - if ( (!strcmp(typestr, "UINT")) || (!strcmp(typestr, "SINT")) ){ - int val = get_obj(argv[0]); - valptr = &val; - type = UINT; - if (val < 0) { /* FIX THIS */ - DBG(2, fprintf(outfp, "Can't understand value %s\n", argv[0])); - return INVALID_VAR; - } - DBG(4, fprintf(outfp, "Copying %d bytes from %p. Val is %x\n", - size, buf, *((int *)valptr))); - memcpy(buf, valptr, size); - - } else if (!strcmp(typestr,"STR")) { - type = STR; - valptr = argv[0]; - DBG(4, fprintf(outfp, "Copying %d bytes from %p. Val is %s\n", - size, buf, (char *)valptr)); - memcpy(buf, valptr, size); - } else if (!strcmp(typestr, "PTR")) { - unsigned long val; - int index = get_obj(argv[0]); - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", argv[0])); - return INVALID_VAR; - } - - val = (unsigned long)buflist[index]->buf; - valptr = &val; - DBG(4, fprintf(outfp, "Copying %d bytes from %p. Val is %p\n", - size, buf, valptr)); - memcpy(buf, valptr, size); - } else { - DBG(2, fprintf(outfp, "Unknown type %s. Valid types are UINT, STR, and PTR\n", - typestr)); - fprintf(stderr, "Unknown type %s. Valid types are UINT, STR, and PTR\n", - typestr); - return INVALID_ARGS; - } - - return SUCCESS; -} - - -#define STR_TYPE 1 -#define INT_TYPE 2 -#define SHORT_TYPE 3 -#define CHAR_TYPE 4 -#define LONG_TYPE 5 - -void print_partial(char *buf, int offset, int len, int type) -{ - int i; - - if (type == STR_TYPE) { - sprintf(output, "%s%s", output, (char *)(buf+offset)); - DBG(4, fprintf(outfp, "Printing str %s\n", (char *)(buf+offset))); - } else { - if (type == SHORT_TYPE) { - for (i = 0; i < len; i+= 2) { - short *ibuf = (short *)(buf + offset + i); - sprintf(output, "%s%#04x ", output, *ibuf); - DBG(4, fprintf(outfp, "Printing short %#04x\n", *ibuf)); - } - } else if (type == CHAR_TYPE) { - for (i = 0; i < len; i++) { - short *ibuf = (short *)(buf+offset+i); - sprintf(output, "%s%#02x ", output, (*ibuf & 0x00ff)); - DBG(4, fprintf(outfp, "Printing char %c\n", (*ibuf & 0x00ff))); - } - } else if (type == INT_TYPE) { - for (i = 0; i < len; i+= 4) { - int *ibuf = (int *)(buf + offset + i); - sprintf(output, "%s%#08x ", output, *ibuf); - DBG(4, fprintf(outfp, "Printing int %#08x\n", *ibuf)); - } - } else { - for (i = 0; i < len; i += 8) { - unsigned long *lbuf = (unsigned long *)(buf + offset +i); - sprintf(output, "%s%#08lx ", output, *lbuf); - DBG(4, fprintf(outfp, "Printing int %#016lx\n", *lbuf)); - } - } - } -} - -int test_do_printbuf(int argc, char **argv) -{ - int index, i, type, offset, len; - struct buf_t *buf_st; - void *buf; - char *typestr; - struct var_mapping *mobj; - - if (argv[0][0] == '$') { - if (argv[0][1] == '$') { - sprintf(output, "\n%#010x", (unsigned int)last_ret_val); - return SUCCESS; - } else if (!strcmp("errno", &argv[0][1])) { - sprintf(output, "\n%#010x", my_errno); - return SUCCESS; - } - } - - mobj = get_map(argv[0]); - if (mobj == NULL) { - DBG(2, fprintf(outfp, "Can't get var at %s\n", argv[0])); - return INVALID_VAR; - } - - if (mobj->type == UINT) - sprintf(output, "\n%#010x", mobj->obj); - else if (mobj->type == SINT) - sprintf(output, "%d", mobj->obj); - else if ((mobj->type == STR) || (mobj->type == PTR)) { - index = mobj->obj; - - buf_st = buflist[index]; - DBG(2, fprintf(outfp, "buf_st is %p:\n", (void *)buf_st)); - buf = buf_st->buf; - DBG(2, fprintf(outfp, "buf %s:\n", argv[0])); - if (mobj->type == STR) { - sprintf(output, "\n%s", (char *)buf); - } else { - sprintf(output,"%s\n", output); - DBG(2, fprintf(outfp, "buf_st->len is %d, buf is %p\n", buf_st->len, buf)); - if (argc == 1) { - for (i = 0; i < buf_st->len/4; i++) - DBG(2, fprintf(outfp, "%#x ", ((int *)buf)[i])); - sprintf(output, "%s%#x ", output, ((int *)buf)[i]); - - } - - for (i = 1; i < argc; i++) { - offset = get_obj(argv[i++]); - len = get_obj(argv[i++]); - if ((offset < 0) || (len < 0)) { - DBG(2, fprintf(outfp, "Invalid offset (%s) or len (%s)\n", - argv[i-2], argv[i-1])); - return INVALID_VAR; - } - typestr = argv[i]; - if (!strcmp("STR", typestr)) - type = STR_TYPE; - else if (!strcmp("INT", typestr)) - type = INT_TYPE; - else if (!strcmp("SHORT", typestr)) - type = SHORT_TYPE; - else if (!strcmp("CHAR", typestr)) - type = CHAR_TYPE; - else if (!strcmp("LONG", typestr)) - type = LONG_TYPE; - else { - DBG(2, fprintf(outfp, "Unable to understand type %s\n", - typestr)); - return INVALID_ARGS; - } - print_partial(buf, offset, len, type); - } - } - } - DBG(3, fprintf(outfp, "output: %s \n", output)); - return SUCCESS; -} - -int test_do_mount(int argc, char **argv) -{ - if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for test_do_mount\n", - argc)); - return INVALID_ARGS; - } - - DBG(4, fprintf(outfp, "Calling mount with from %s and to %s\n", - argv[0], argv[1])); - last_ret_val = sysio_mount(argv[0], argv[1]); - my_errno = errno; - last_type = SINT; - return SUCCESS; -} - -int test_do_clear(int argc, char **argv) -{ - int index; - struct buf_t *buf; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for clear\n", - argc)); - return INVALID_ARGS; - } - index = get_obj(argv[0]); - if (index < 0) { - fprintf(outfp, "Unable to locate buffer %s\n", - argv[0]); - return -1; - } - buf = buflist[index]; - bzero(buf->buf, buf->len); - - return SUCCESS; -} - -int test_do_list(int argc, char **argv) -{ - char *buf; - - if ((argc) && (argc != 1)) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for list\n", - argc)); - return INVALID_ARGS; - } - - DBG(5,fprintf(outfp, "In test_do_list with args %p\n", (void *)argv)); - if (!argv) { - buf = getcwd(NULL, 0); - DBG(4, fprintf(outfp, "Calling list with dir of %s\n", buf)); - last_ret_val = sysio_list(buf); - my_errno = errno; - free(buf); - return SUCCESS; - } - - last_type = SINT; - return sysio_list(*argv); -} - -/* - * Initlizes sysio library. Will use default initlization - * unless arguments are given - */ -int test_do_init(int argc, char **argv) -{ - if (argc > 0) { - char *rdriver; - char *mpath; - int mflags, rsize, msize; - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for init\n", - argc)); - return INVALID_ARGS; - } - - rdriver = get_str(argv[0]); - rsize = strlen(rdriver)+1; - if (rsize > 75) { - DBG(2, fprintf(outfp, "%s too long for root driver\n", rdriver)); - return INVALID_ARGS; - } - bzero(root_driver, 75); - memcpy(root_driver, rdriver, rsize); - - mpath = get_str(argv[1]); - msize = strlen(mpath)+1; - if (msize > 250) { - DBG(2, fprintf(outfp, "%s too long for mount path\n", mpath)); - return INVALID_ARGS; - } - bzero(mntpath, 250); - memcpy(mntpath, mpath, msize); - - mflags = get_obj(argv[2]); - if (mflags == -1) { - DBG(2, fprintf(outfp, "Invalid flags argument %s\n", argv[2])); - return INVALID_ARGS; - } - } - - DBG(5, fprintf(outfp, "In test_do_init\n")); - last_type = SINT; - DBG(3, fprintf(outfp, "initializing\n")); - return initilize_sysio(); -} - - -/* - * Returns 1 if the machine is big-endian, 0 - * otherwise - */ -int get_endian(int argc, char **argv) -{ - int x = 1; - - if ((argc) || (argv)) { - DBG(2, fprintf(outfp, "Expected no args for test_do_endian\n")); - return INVALID_ARGS; - } - - if(*(char *)&x == 1) { - /* little-endian, return 0 */ - last_ret_val= 0; - } else { - /* big endian, return 1 */ - last_ret_val= 1; - } - last_type = UINT; - return SUCCESS; -} - -int do_setbuf(int argc, char **argv) -{ - int val, size, index, offset; - void *buf; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Need val, size, buffer, and offset for setbuf\n")); - return INVALID_ARGS; - } - val = get_obj(argv[0]); - if (val < 0) { - DBG(2, fprintf(outfp, "Unable to understand val of %s\n", - argv[0])); - return INVALID_VAR; - } - - size = get_obj(argv[1]); - if( size <=0 ) { - DBG(2, fprintf(outfp, "Size of %s is invalid\n", argv[1])); - return INVALID_VAR; - } - - index = get_obj(argv[2]); - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[2])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - offset = get_obj(argv[3]); - - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[3])); - return INVALID_ARGS; - } - - buf = (void *)((char *)buf +offset); - - memset(buf, val, size); - - return SUCCESS; -} - - -int get_sizeof(int argc, char **argv) -{ - char *type; - int size; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for sizeof\n", - argc)); - return INVALID_ARGS; - } - - type = argv[0]; - - if (!strcmp(type, "char")) - size = sizeof(char); - else if (!strcmp(type, "int")) - size = sizeof(int); - else if (!strcmp(type, "long")) - size = sizeof(long); - else if (!strcmp(type, "flock")) - size = sizeof(struct flock); - else if (!strcmp(type, "stat")) - size = sizeof(struct stat); - else if (!strcmp(type, "statvfs")) - size = sizeof(struct statvfs); - else if (!strcmp(type, "iovec")) - size = sizeof(struct iovec); - else if (!strcmp(type, "xtvec")) - size = sizeof(struct xtvec); - else - return INVALID_ARGS; - - DBG(2, fprintf(outfp, "Size is %d\n", size)); - - last_type = UINT; - last_ret_val = size; - return SUCCESS; -} - -int test_do_exit(int argc, char **argv) -{ - int val = 0; - - if (argc) { - /* - * If argc is given, need to return the value of - * the passed in variable - */ - val = get_obj(argv[0]); - } - - /* - * Clean up. - */ - _sysio_shutdown(); - - if (argc) - DBG(3, printf("Exiting with %d from %s\n", val, argv[0])); - - exit(val); - - return 0; -} - -int get_buffer(int argc, char **argv) -{ - int size, align; - struct buf_t *buf; - - if (argc == 1) /* Just put size, not alignment */ - align = 16; - else if (argc == 2) - align = get_obj(argv[1]); - else { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for alloc\n", - argc)); - return INVALID_ARGS; - } - - size = get_obj(argv[0]); - if (size < 0) { - DBG(2, fprintf(outfp, "Invalid size %s\n", argv[0])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "Getting buffer of size %d and aligned at %d\n", - size, align)); - buf = (struct buf_t *)malloc(sizeof(struct buf_t)); - buf->buf = alloc_buff32(size, align); - buf->len = size; - buflist[next] = buf; - DBG(3, fprintf(outfp, "Your buffer (%p) (%p) is at index %d\n", - (void *)buf, buf->buf, next)); - next++; - - last_type = PTR; - last_ret_val = next-1; - return SUCCESS; -} - -int free_buffer(int argc, char **argv) -{ - int index; - char *name = argv[0]; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for free\n", - argc)); - return INVALID_ARGS; - } - - /* - * Assume that there is one arg and it - * is a variable name which maps to an - * index into the buffer array - */ - index = get_obj(name); - if (index < 0) { - DBG(2, fprintf(outfp, "Can't find buffer %s\n", - name)); - return INVALID_VAR; - } - DBG(4, fprintf(outfp, "Freeing buffer at index %d\n", index)); - free(buflist[index]); - - free_obj(name); - return SUCCESS; -} - -int cmp_bufs(int argc, char **argv) -{ - int res, index1, index2; - char *buf1, *buf2; - - if (argc != 2) { - fprintf(outfp, "Need two buffers to compare\n"); - return INVALID_ARGS; - } - - index1 = get_obj(argv[0]); - if (index1 < 0) { - fprintf(outfp, "Unable to locate buffer %s\n", - argv[0]); - return INVALID_VAR; - } - buf1 = buflist[index1]->buf; - - index2 = get_obj(argv[1]); - if (index2 < 0) { - fprintf(outfp, "Unable to locate buffer %s\n", - argv[1]); - return INVALID_VAR; - } - - buf2 = buflist[index2]->buf; - last_ret_val = strcmp(buf1, buf2); - - DBG(3, fprintf(outfp, "strcmp returned %d\n", res)); - return SUCCESS; -} - -int test_do_chdir(int argc, char **argv) -{ - if (argc != 1) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for chdir\n", - argc)); - return INVALID_ARGS; - } - last_type = SINT; - return sysio_chdir(argv[0]); -} - - -int test_do_chmod(int argc, char **argv) -{ - if (argc != 2) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for chmod\n", - argc)); - return INVALID_ARGS; - } - last_type = SINT; - return sysio_chmod(argv[0], argv[1]); -} - -int test_do_chown(int argc, char **argv) -{ - if (argc != 2) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for chown\n", - argc)); - return INVALID_ARGS; - } - last_type = SINT; - return sysio_chown(argv[0], argv[1]); -} - -int test_do_open(int argc, char **argv) -{ - char *name = argv[0]; - int flags = O_RDWR; - - if (argc > 1) - flags = get_obj(argv[1]); - - if (name[0] == '$') { - int index = get_obj(name); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", - name)); - return INVALID_VAR; - } - - name = buflist[index]->buf; - } - - DBG(4, fprintf(outfp, "Opening file %s with flags %d\n", name, flags)); - if (argc == 2) - return sysio_open(name, flags); - else if (argc == 3) - return sysio_open3(name, flags, argv[2]); - else { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d)\n", argc)); - return INVALID_ARGS; - } - last_type = UINT; - return SUCCESS; -} - -int test_do_close(int argc, char **argv) -{ - int fd; - char *name = argv[0]; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for close\n", - argc)); - return INVALID_ARGS; - } - - /* - * Assume that there is one arg and it - * is a variable name which maps to a file - * descriptor - */ - fd = get_obj(name); - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to map var %s to anything\n", name)); - return INVALID_VAR; - } - sysio_close(fd); - free_obj(name); - return SUCCESS; -} - -int test_do_dup(int argc, char **argv) -{ - int fd; - char *var_name = argv[0]; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for dup\n", - argc)); - return INVALID_ARGS; - } - - - fd = get_obj(var_name); - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to map var %s to any file\n", var_name)); - return INVALID_VAR; - } - - last_ret_val = dup(fd); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_dup2(int argc, char **argv) -{ - int fd1, fd2; - char *var_name1 = argv[0]; - char *var_name2 = argv[1]; - - if (argc != 2) { - DBG(2, fprintf(outfp, "Number of args (%d) invalid for dup2\n", - argc)); - return INVALID_ARGS; - } - - fd1 = get_obj(var_name1); - if (fd1 < 0) { - DBG(2, fprintf(outfp, "Unable to map var %s to any file\n", var_name1)); - return INVALID_VAR; - } - - fd2 = get_obj(var_name2); - if (fd2 < 0) { - DBG(2, fprintf(outfp, "Unable to map var %s to any file\n", var_name2)); - return INVALID_VAR; - } - - last_ret_val = dup2(fd1, fd2); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -struct cmd_map fcntl_cmds[] = { - { "F_DUPFD", F_DUPFD, 3 }, - { "F_GETFD", F_GETFD, 2 }, - { "F_SETFD", F_SETFD, 3 }, - { "F_GETFL", F_GETFL, 2 }, - { "F_SETFL", F_SETFL, 3 }, - { "F_SETLK", F_SETLK, 3 }, - { "F_SETLKW", F_SETLKW, 3 }, - { "F_GETLK", F_GETLK, 3 }, -#if defined __USE_BSD || defined __USE_XOPEN2K - { "F_GETOWN", F_GETOWN, 2 }, - { "F_SETOWN", F_SETOWN, 3 }, -#endif -#ifdef __USE_GNU - { "F_GETSIG", F_GETSIG, 2 }, - { "F_SETSIG", F_SETSIG, 3 }, - { "F_SETLEASE", F_SETLEASE, 3}, - { "F_GETLEASE", F_GETLEASE, 2}, - { "F_NOTIFY", F_NOTIFY, 3} , -#endif - { NULL, -1, 0 } -}; - -struct cmd_map* get_cmd(char *cmd_name, int argc) -{ - int i =0; - - while (fcntl_cmds[i].cmd_name) { - if (!strcmp(fcntl_cmds[i].cmd_name, cmd_name)) { - if (fcntl_cmds[i].num_args == argc) - return &fcntl_cmds[i]; - else - return NULL; - } - i++; - } - return NULL; -} - -int test_do_fcntl(int argc, char **argv) -{ - - struct cmd_map *cmd; - int fd; - - /* - * get_cmd translates a symbolic command into - * into its numerical equivalent. It also - * verifies that the number of args is the - * correct number for the command. It returns - * NULL on failure - */ - cmd = get_cmd(argv[1], argc); - if (!cmd) { - DBG(2, fprintf(outfp, "Unable to get command %s\n", argv[1])); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to map %s to file descriptor \n", argv[0])); - return INVALID_VAR; - } - - if (argc > 2) - last_ret_val = sysio_fcntl(fd, cmd, argv[2]); - else - last_ret_val = sysio_fcntl(fd, cmd, NULL); - DBG(4, fprintf(outfp, "Got return value of %d\n", (int)last_ret_val)); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_fstat(int argc, char **argv) -{ - int fd, index; - void *buf; - - if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) for fstat\n", - argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - last_ret_val = sysio_fstat(fd, buf); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_lstat(int argc, char **argv) -{ - char *name = argv[0]; - int index; - void *buf; - - if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) for lstat\n", - argc)); - return INVALID_ARGS; - } - - index = get_obj(argv[1]); - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - last_type = SINT; - - return sysio_lstat(name, buf); -} - -int test_do_fsync(int argc, char **argv) -{ - int fd; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to fsync\n", argc)); - return INVALID_ARGS; - } - - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - last_ret_val = fsync(fd); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_fdatasync(int argc, char **argv) -{ - int fd; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to fdatasync\n", argc)); - return INVALID_ARGS; - } - - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - last_ret_val = fdatasync(fd); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_ftruncate(int argc, char **argv) -{ - int fd; - off_t length; - - if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ftruncate\n", argc)); - return INVALID_ARGS; - } - - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - length = (off_t)get_obj(argv[1]); - - DBG(3, fprintf(outfp, "Setting file %d to %d\n", fd, (int) length)); - - last_ret_val = ftruncate(fd, length); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_getcwd(int argc, char **argv) -{ - char *buf; - int size, index; - - if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to getcwd\n", argc)); - return INVALID_ARGS; - } - - index = get_obj(argv[0]); - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - size = get_obj(argv[1]); - - DBG(4, fprintf(outfp, "Getting cwd with buffer size of %d\n", size)); - - last_ret_val = 0; - if (!getcwd(buf, size)) { - last_ret_val = -1; - if (errno == ERANGE) { - DBG(2, fprintf(outfp, "Need a bigger buffer!\n")); - } - } - - my_errno = errno; - - - DBG(3, fprintf(outfp, "cwd: %s\n", buf)); - last_type = SINT; - - return SUCCESS; -} - -int test_do_lseek(int argc, char **argv) -{ - int fd, whence; - off_t offset; - - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to lseek\n", argc)); - return INVALID_ARGS; - } - - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - offset = (off_t)get_obj(argv[1]); - whence = get_obj(argv[2]); - - if (whence < 0 ) { - DBG(2, fprintf(outfp, "Not familiar with whence of %s\n", - argv[2])); - return INVALID_ARGS; - } - - last_ret_val = lseek(fd, offset, whence); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_getdirentries(int argc, char **argv) -{ - int fd, nbytes; - int bufindex; - off_t basep; - char *buf; - struct var_mapping *base_map; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to getdirentries\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - bufindex = get_obj(argv[1]); - - if (bufindex < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1])); - return INVALID_VAR; - } - - buf = buflist[bufindex]->buf; - - nbytes = get_obj(argv[2]); - - if (nbytes < 0) { - DBG(2, fprintf(outfp, "I don't understand %s\n", - argv[2])); - return INVALID_ARGS; - } - - base_map = get_map(argv[3]); - if (!base_map) { - DBG(3, fprintf(outfp, "Resetting basep\n")); - /* - * Assume that this is the first getdirentries call - * and we need to setup the base pointer - */ - basep = 0; - } else - basep = base_map->obj; - - DBG(3, fprintf(outfp, "basep is (starting) %d\n", (int) basep)); - last_ret_val = sysio_getdirentries(fd, buf, nbytes, &basep); - if (base_map) - base_map->obj = basep; - else - store_result(argv[3]+1, basep); - DBG(3, fprintf(outfp, "basep is (ending) %d\n", (int) basep)); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_mkdir(int argc, char **argv) -{ - if (argc !=2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to mkdir\n", argc)); - return INVALID_ARGS; - } - - last_type = SINT; - return sysio_mkdir(argv[0], argv[1]); -} - -int test_do_creat(int argc, char **argv) -{ - if (argc !=2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to creat\n", argc)); - return INVALID_ARGS; - } - - last_type = UINT; - return sysio_creat(argv[0], argv[1]); -} - -int test_do_stat(int argc, char **argv) -{ - int index; - void *buf; - char *str; - - if (argc != 2) { - fprintf(outfp, "Invalid number of arguments (%d) for stat\n", - argc); - return -1; - } - - - index = get_obj(argv[1]); - if (index < 0) { - fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1]); - } - - buf = buflist[index]->buf; - last_type = SINT; - - str = get_str(argv[0]); - return sysio_stat(str, buf); -} - -int test_do_statvfs(int argc, char **argv) -{ - int index; - void *buf; - - if (argc != 2) { - fprintf(outfp, "Invalid number of arguments (%d) for statvfs\n", - argc); - return -1; - } - - - index = get_obj(argv[1]); - if (index < 0) { - fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1]); - } - - buf = buflist[index]->buf; - last_type = SINT; - - return sysio_statvfs(argv[0], buf); -} - -int test_do_fstatvfs(int argc, char **argv) -{ - int index, fd; - void *buf; - - if (argc != 2) { - fprintf(outfp, "Invalid number of arguments (%d) for fstatvfs\n", - argc); - return -1; - } - - - fd = get_obj(argv[0]); - - if (fd < 0) { - fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0]); - } - - - index = get_obj(argv[1]); - if (index < 0) { - fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1]); - } - - buf = buflist[index]->buf; - last_type = SINT; - - return sysio_fstatvfs(fd, buf); -} - -int test_do_truncate(int argc, char **argv) -{ - off_t length; - - if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to truncate\n", argc)); - return INVALID_ARGS; - } - - length = (off_t)get_obj(argv[1]); - - DBG(3, fprintf(outfp, "Setting file %s to %d\n", argv[0], (int) length)); - - last_ret_val = truncate(argv[0], length); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_rmdir(int argc, char **argv) -{ - - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to rmdir\n", argc)); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "Removing dir %s\n", argv[0])); - - last_ret_val = rmdir(argv[0]); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_symlink(int argc, char **argv) -{ - if (argc != 2) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to symlink\n", argc)); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "Linking %s to %s\n", argv[0], argv[1])); - - last_ret_val = symlink(argv[0], argv[1]); - if (last_ret_val) { - if (errno < 0) - errno = errno*-1; - my_perror("symlink"); - } - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -struct cmd_map ioctl_cmds[] = { -#if 0 - { "BLKROSET", BLKROSET, 3 }, - { "BLKROGET", BLKROGET, 3 }, - { "BLKRRPART", BLKRRPART, 3 }, - { "BLKGETSIZE", BLKGETSIZE, 3 }, - { "BLKRASET", BLKRASET, 3 }, - { "BLKRAGET", BLKRAGET, 3 }, - { "BLKSECTSET", BLKSECTSET, 3 }, - { "BLKSECTGET", BLKSECTGET, 3 }, - { "BLKSSZGET", BLKSSZGET, 3 }, - { "BLKGETLASTSECT", BLKGETLASTSECT, 3 }, - { "BLKSETLASTSECT", BLKSETLASTSECT, 3 }, - { "BLKBSZGET", BLKBSZGET, 3 }, - { "BLKBSZSET", BLKBSZSET, 3 }, - { "FIBMAP", FIBMAP, 3 }, - { "FIGETBSZ", FIGETBSZ, 3}, -#endif - { NULL, -1, 0 } -}; - -int get_ioctl_cmd(char *cmd) -{ - int i = 0; - - while (ioctl_cmds[i].cmd_name != NULL) { - if (strcmp(ioctl_cmds[i].cmd_name, cmd)) - i++; - else - return ioctl_cmds[i].cmd; - } - - return -1; -} - -int test_do_ioctl(int argc, char **argv) -{ - int fd, cmd; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ioctl\n", argc)); - return INVALID_ARGS; - } - - - fd = get_obj(argv[0]); - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file %s\n", argv[0])); - return INVALID_VAR; - } - - cmd = get_ioctl_cmd(argv[1]); - if (cmd == -1) { - DBG(2, fprintf(outfp, "Do not understand command %s\n", argv[1])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "Executing command %s\n", argv[1])); - - last_ret_val = ioctl(fd, cmd, argv[2]); - my_errno = errno; - if (last_ret_val) - my_perror("ioctl"); - last_type = SINT; - - return SUCCESS; -} - -int test_do_unlink(int argc, char **argv) -{ - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to unlink\n", argc)); - return INVALID_ARGS; - } - - DBG(4, fprintf(outfp, "Unlinking %s\n", argv[0])); - - last_ret_val = unlink(argv[0]); - my_errno = errno; - if (last_ret_val) - my_perror("unlink"); - last_type = SINT; - - return SUCCESS; -} - -int test_do_umask(int argc, char **argv) -{ - mode_t old_mask; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Incorrect number of args (%d) for umask\n", argc)); - return INVALID_ARGS; - } - - last_ret_val = old_mask = sysio_umask(argv[0]); - my_errno = errno; - DBG(3, fprintf(outfp, "Previous umask was %o\n", old_mask)); - last_type = UINT; - - return SUCCESS; -} - -int test_do_iowait(int argc, char **argv) -{ - long err; - ioid_t ioid; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Incorrect amount of args (%d) for iowait\n", argc)); - return INVALID_ARGS; - } - - err = get_obj(argv[0]); - if (err < 0) { - DBG(2, fprintf(outfp, "Cannot find ioid at %s\n", argv[0])); - return INVALID_VAR; - } - - ioid = (ioid_t)err; - - last_ret_val = iowait(ioid); - my_errno = errno; - if (last_ret_val < 0) { - my_perror("iowait"); - } - last_type = SINT; - - return SUCCESS; -} - -int test_do_iodone(int argc, char **argv) -{ - long err; - ioid_t ioid; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Incorrect amount of args (%d) for iodone\n", argc)); - return INVALID_ARGS; - } - - err = get_obj(argv[0]); - if (err < 0) { - DBG(2, fprintf(outfp, "Cannot find ioid at %s\n", argv[0])); - return INVALID_VAR; - } - ioid = (ioid_t)err; - - last_ret_val = iowait(ioid); - if (last_ret_val < 0) { - my_perror("iodone"); - } - my_errno = errno; - last_type = SINT; - - return SUCCESS; - -} - -int test_do_ipread(int argc, char **argv) -{ - int fd, index, count, offset; - char *buf; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipread\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file at %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Do not understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset of %s\n", argv[3])); - return INVALID_ARGS; - } - - last_ret_val = (long)ipread(fd, buf, count, offset); - if (last_ret_val < 0) { - my_perror("ipread"); - } - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_iread(int argc, char **argv) -{ - int fd, index, count; - char *buf; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iread\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file at %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Do not understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - last_ret_val = (long) iread(fd, buf, count); - if (last_ret_val < 0) { - my_perror("iread"); - } - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_ipreadv(int argc, char **argv) -{ - int fd, count, index; - off_t offset; - char *buf; - struct iovec *iov; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipreadv\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - count = get_obj(argv[2]); - - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset value %s\n", argv[3])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "ipreadv(fd: %d vector:{iov_base: %p iov_len %d} count: %d offset: %d\n", - fd, iov->iov_base, (int)iov->iov_len, count, (int) offset)); - - last_ret_val = (long) ipreadv(fd, iov, count, offset); - if (last_ret_val < 0) - my_perror("ipreadv"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_preadv(int argc, char **argv) -{ - int fd, count, index; - off_t offset; - char *buf; - struct iovec *iov; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to preadv\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - count = get_obj(argv[2]); - - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset value %s\n", argv[3])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "preadv(fd: %d vector:{iov_base: %p iov_len %d} count: %d offset: %d\n", - fd, iov->iov_base, (int) iov->iov_len, count, (int) offset)); - - last_ret_val = preadv(fd, iov, count, offset); - my_errno = errno; - if (last_ret_val < 0) - my_perror("preadv"); - last_type = SINT; - - return SUCCESS; -} - - -int test_do_pread(int argc, char **argv) -{ - int fd, count, index, numbytes, offset; - char *buf; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to pread\n", argc)); - return INVALID_ARGS; - } - - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count of %s\n", argv[1])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset of %s\n", argv[2])); - return INVALID_ARGS; - } - - - last_ret_val = numbytes = (int) pread(fd, buf, count, offset); - my_errno = errno; - DBG(4, fprintf(outfp, "Read %d bytes out of %d starting at offset %x\n", - numbytes, count, offset)); - DBG(3, fprintf(outfp, "Got %s\n", buf)); - last_type = SINT; - - return SUCCESS; -} - - -int test_do_ireadv(int argc, char **argv) -{ - int fd, count, index; - char *buf; - struct iovec *iov; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ireadv\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - count = get_obj(argv[2]); - - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "ireadv (fd: %d, vector:{ iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, (int)iov->iov_len, count)); - - last_ret_val = (long) ireadv(fd, iov, count); - if (last_ret_val < 0) - my_perror("ireadv"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_readv(int argc, char **argv) -{ - int fd, count, index; - char *buf; - struct iovec *iov; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to readv\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - count = get_obj(argv[2]); - - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "ireadv (fd: %d, vector:{ iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, (int)iov->iov_len, count)); - - last_ret_val = readv(fd, iov, count); - if (last_ret_val < 0) - my_perror("readv"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_read(int argc, char **argv) -{ - int fd, count, index, numbytes=0; - char *buf; - - if (argc < 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to read\n", argc)); - return INVALID_ARGS; - } - - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n", - argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", - argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - - if ( (argc == 4) && (!strcmp(argv[3], "delay")) ){ - int i; - /* Wait a little while for input */ - for (i=0; i < count; i++) { - sleep(0.005); - numbytes += (int) read(fd, buf, 1); - last_ret_val = numbytes; - - } - } else { - last_ret_val = numbytes = (int) read(fd, buf, count); - } - my_errno = errno; - - DBG(3, fprintf(outfp, "Read %d bytes out of %d\n", numbytes, count)); - DBG(3, fprintf(outfp, "Got %s\n", buf)); - last_type = SINT; - - return SUCCESS; -} - -int test_do_ipwritev(int argc, char **argv) -{ - int fd, count, index, offset; - char *buf; - struct iovec *iov; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipwritev\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, - "ipwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d, offset: %d\n", - fd, iov->iov_base, (int)iov->iov_len, count, offset)); - - last_ret_val = (long) ipwritev(fd, iov, count, offset); - my_errno = errno; - if (last_ret_val < 0) - my_perror("ipwritev"); - last_type = SINT; - - return SUCCESS; -} - -int test_do_ipwrite(int argc, char **argv) -{ - int fd, count, index, offset; - char *buf; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipwrite\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3])); - return INVALID_ARGS; - } - - last_ret_val = (long) ipwrite(fd, buf, count, offset); - if (last_ret_val < 0) - my_perror("ipwrite"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_pwritev(int argc, char **argv) -{ - int fd, count, index, offset; - char *buf; - struct iovec *iov; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to pwritev\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3])); - return INVALID_ARGS; - } - - - DBG(3, fprintf(outfp, - "pwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d, offset: %d\n", - fd, iov->iov_base, (int)iov->iov_len, count, offset)); - - last_ret_val = (long) pwritev(fd, iov, count, offset); - if (last_ret_val < 0) - my_perror("ipwritev"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_pwrite(int argc, char **argv) -{ - int fd, count, index, offset; - char *buf; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to pwrite\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - offset = get_obj(argv[3]); - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3])); - return INVALID_ARGS; - } - - last_ret_val = pwrite(fd, buf, count, offset); - my_errno = errno; - if (last_ret_val < 0) - my_perror("pwrite"); - last_type = SINT; - - return SUCCESS; -} - - -int test_do_iwritev(int argc, char **argv) -{ - int fd, count, index; - char *buf; - struct iovec *iov; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwritev\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "iwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, (int)iov->iov_len, count)); - - last_ret_val = (long) iwritev(fd, iov, count); - my_errno = errno; - if (last_ret_val < 0) - my_perror("iwritev"); - last_type = SINT; - - return SUCCESS; -} - -int test_do_iwrite(int argc, char **argv) -{ - int fd, count, index; - char *buf; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwrite\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - last_ret_val = (long) iwrite(fd, buf, count); - my_errno = errno; - if (last_ret_val < 0) - my_perror("iwrite"); - last_type = SINT; - - return SUCCESS; -} - - -int test_do_write(int argc, char **argv) -{ - int fd, count, index, err; - char *buf; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to write\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_VAR; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - count = get_obj(argv[2]); - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2])); - return INVALID_ARGS; - } - - DBG(4, fprintf(outfp, "Writing out %d bytes (%s) using fd of %x\n", - count, buf, fd)); - err = write(fd, buf, count); - if (err < 0) - my_perror("write"); - - last_ret_val = err; - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_writev(int argc, char **argv) -{ - int fd, count, index; - char *buf; - struct iovec *iov; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to writev\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_ARGS; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - count = get_obj(argv[2]); - - if (count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "writev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, (int)iov->iov_len, count)); - - last_ret_val = writev(fd, iov, count); - if (last_ret_val < 0) - my_perror("writev"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - -int test_do_mknod(int argc, char **argv) -{ - int dev; - - if (argc != 3) { - DBG(2, fprintf(outfp, "Invalid number of args (%d) for mknod\n", argc)); - return INVALID_ARGS; - } - - dev = get_obj(argv[2]); - if (dev < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - last_type = SINT; - - - return sysio_mknod(argv[0], argv[1], (dev_t) dev); -} - -int test_do_umount(int argc, char **argv) -{ - int err; - - if (argc != 1) { - DBG(2, fprintf(outfp, "Invalid number (%d) of args for umount\n", argc)); - return INVALID_ARGS; - } - - err = umount(argv[0]); - if (err) - my_perror("umount"); - - my_errno = errno; - last_ret_val = err; - last_type = SINT; - - return SUCCESS; -} - -int test_do_init_iovec(int argc, char **argv) -{ - int iov_index, buf_index; - int offset, len, pos; - struct iovec *iov_ptr; - char *base_ptr; - - if (argc != 5) { - DBG(2, fprintf(outfp, "Need buffer, offset, len, array pos, and iov pointer\n")); - return INVALID_ARGS; - } - - if ((buf_index = get_obj(argv[0])) < 0) { - DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[0])); - return INVALID_VAR; - } - base_ptr = buflist[buf_index]->buf; - - if ((offset = get_obj(argv[1])) < 0) { - DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[1])); - return INVALID_VAR; - } - - if ((len = get_obj(argv[2])) < 0) { - DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[2])); - return INVALID_VAR; - } - - if ((pos = get_obj(argv[3])) < 0) { - DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[3])); - return INVALID_VAR; - } - - if ((iov_index = get_obj(argv[4])) < 0) { - DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[4])); - return INVALID_VAR; - } - iov_ptr = (struct iovec *)(buflist[iov_index]->buf); - - iov_ptr[pos].iov_len = len; - iov_ptr[pos].iov_base = (void *)(base_ptr + offset); - - DBG(3, fprintf(outfp, "iov_ptr.len is %d and base is %p\n", - (int)iov_ptr[pos].iov_len, iov_ptr[pos].iov_base)); - my_errno = errno; - last_type = PTR; - - return SUCCESS; -} - - -int test_do_init_xtvec(int argc, char **argv) -{ - int xtv_index; - int offset, len, pos; - struct xtvec *xtv_ptr; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Need offset, len, array pos, and xtv pointer\n")); - return INVALID_ARGS; - } - - if ((offset = get_obj(argv[0])) < 0) { - DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[0])); - return INVALID_VAR; - } - - if ((len = get_obj(argv[1])) < 0) { - DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[1])); - return INVALID_VAR; - } - - if ((pos = get_obj(argv[2])) < 0) { - DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[2])); - return INVALID_VAR; - } - - if ((xtv_index = get_obj(argv[3])) < 0) { - DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[3])); - return INVALID_VAR; - } - xtv_ptr = (struct xtvec *)(buflist[xtv_index]->buf); - - xtv_ptr[pos].xtv_len = len; - xtv_ptr[pos].xtv_off = offset; - - DBG(3, fprintf(outfp, "xtv_ptr.len is %d and offset is %d\n", - (int)xtv_ptr[pos].xtv_len, (int)xtv_ptr[pos].xtv_off)); - - my_errno = errno; - last_type = PTR; - - return SUCCESS; -} - -int test_do_writex(int argc, char **argv) -{ - int fd, iov_count, xtv_count,index; - char *buf; - struct iovec *iov; - struct xtvec *xtv; - - if (argc != 5) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to writex\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_ARGS; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - iov_count = get_obj(argv[2]); - - if (iov_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - index = get_obj(argv[3]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - xtv = (struct xtvec *)buf; - xtv_count = get_obj(argv[4]); - - if (xtv_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "writex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", - fd, (void *)iov, iov_count, (void *)xtv, xtv_count)); - - last_ret_val = writex(fd, iov, iov_count, xtv, xtv_count); - if (last_ret_val < 0) - my_perror("writex"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_iwritex(int argc, char **argv) -{ - int fd, iov_count, xtv_count,index; - char *buf; - struct iovec *iov; - struct xtvec *xtv; - - if (argc != 5) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwritex\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_ARGS; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - iov_count = get_obj(argv[2]); - - if (iov_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - index = get_obj(argv[3]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - xtv = (struct xtvec *)buf; - xtv_count = get_obj(argv[4]); - - if (xtv_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "iwritex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", - fd, (void *)iov, iov_count, (void *)xtv, xtv_count)); - - last_ret_val = (long) iwritex(fd, iov, iov_count, xtv, xtv_count); - if (last_ret_val < 0) - my_perror("iwritex"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_readx(int argc, char **argv) -{ - int fd, iov_count, xtv_count,index; - char *buf; - struct iovec *iov; - struct xtvec *xtv; - - if (argc != 5) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to readx\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_ARGS; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - iov_count = get_obj(argv[2]); - - if (iov_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - index = get_obj(argv[3]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - xtv = (struct xtvec *)buf; - xtv_count = get_obj(argv[4]); - - if (xtv_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "readx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", - fd, (void *)iov, iov_count, (void *)xtv, xtv_count)); - - last_ret_val = readx(fd, iov, iov_count, xtv, xtv_count); - if (last_ret_val < 0) - my_perror("readx"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int test_do_ireadx(int argc, char **argv) -{ - int fd, iov_count, xtv_count,index; - char *buf; - struct iovec *iov; - struct xtvec *xtv; - - if (argc != 5) { - DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ireadx\n", argc)); - return INVALID_ARGS; - } - - fd = get_obj(argv[0]); - - if (fd < 0) { - DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); - return INVALID_ARGS; - } - - index = get_obj(argv[1]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - iov = (struct iovec *)buf; - iov_count = get_obj(argv[2]); - - if (iov_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - index = get_obj(argv[3]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); - return INVALID_VAR; - } - - buf = buflist[index]->buf; - - xtv = (struct xtvec *)buf; - xtv_count = get_obj(argv[4]); - - if (xtv_count < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); - return INVALID_ARGS; - } - - DBG(3, fprintf(outfp, "ireadx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", - fd, (void *)iov, iov_count, (void *)xtv, xtv_count)); - - last_ret_val = (long) ireadx(fd, iov, iov_count, xtv, xtv_count); - if (last_ret_val < 0) - my_perror("ireadx"); - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} - - -int do_checkbuf(int argc, char **argv) -{ - int size, val, index, i, offset; - int *ref_buf, *buf; - - if (argc != 4) { - DBG(2, fprintf(outfp, "Need buffer, val, and offset for checkbuf\n")); - return INVALID_ARGS; - } - - index = get_obj(argv[0]); - - if (index < 0) { - DBG(2, fprintf(outfp, "Unable to find buf described by %s\n", argv[0])); - return INVALID_VAR; - } - - buf = (int *)buflist[index]->buf; - - - size = get_obj(argv[1]); - - if (size < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[1])); - return INVALID_ARGS; - } - - val = get_obj(argv[2]); - - if (val < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); - return INVALID_ARGS; - } - - - offset = get_obj(argv[3]); - - if (offset < 0) { - DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[3])); - return INVALID_ARGS; - } - - - ref_buf = (int *)malloc(size); - memset((void *)ref_buf, val, size); - - last_ret_val =0; - buf = (int *)((char *)buf + offset); - for (i=0; (unsigned)i < size/sizeof(int); i++) { - if (buf[i] != ref_buf[i]) { - DBG(2, fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x\n", - i, buf[i], ref_buf[i])); - fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x (val was %d)\n", - i, buf[i], ref_buf[i], val); - last_ret_val = 1; - break; - } - } - - my_errno = errno; - last_type = SINT; - - return SUCCESS; -} diff --git a/libsysio/tests/sysio_tests.c b/libsysio/tests/sysio_tests.c deleted file mode 100644 index 4077996..0000000 --- a/libsysio/tests/sysio_tests.c +++ /dev/null @@ -1,861 +0,0 @@ -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "mount.h" -#include "test.h" -#include "test_driver.h" - -/* - * ################################################### - * # Test functions # - * # These functions are used to test libsysio. # - * # Eventually, there should be one of these for # - * # every function document in sysio.h # - * ################################################### - */ -int initilize_sysio() -{ - char *wd; - - /* - * Attempt to set the cwd by getting it out of the - * user's environment. If that does not work, set - * it to / - */ - wd = getenv("PWD"); - if (wd == NULL) { - wd = malloc(5); - strcpy(wd, "/"); - } - if (chdir(wd) != 0) { - DBG(5, sprintf(output, "%schdir: errno %d\n", output, errno)); - my_perror(wd); - my_errno = errno; - last_ret_val = errno; - return SUCCESS; - } - - DBG(3, sprintf(output, "Your current working directory is %s\n", wd)); - last_ret_val = 0; - return SUCCESS; -} - - -int sysio_list(char *path) -{ - int fd; - size_t n; - struct dirent *buf, *dp; - __off_t base; - ssize_t cc; - int numfiles = 0; - - fd = open(path, O_RDONLY); - if (fd < 0) { - my_errno = errno; - last_ret_val = fd; - my_perror(path); - return SUCCESS; - } - - n = 16 * 1024; - buf = malloc(n); - if (!buf) { - my_perror(path); - cc = -1; - goto out; - } - base = 0; - DBG(5, sprintf(output, "About to call getdirentries\n")); - while ((cc = getdirentries(fd, (char *)buf, n, &base)) > 0) { - dp = buf; - while (cc > 0) { - DBG(4, fprintf(outfp, "\t%s: ino %#08x off %#08x type %#08x\n", - dp->d_name, - (unsigned int)dp->d_ino, - (unsigned int)dp->d_off, - (int )dp->d_type)); - - sprintf(output, "%s\n", dp->d_name); - cc -= dp->d_reclen; - dp = (struct dirent *)((char *)dp + dp->d_reclen); - numfiles++; - } - printf("Out of inner loop\n"); - if (!base) - break; - } - - out: - if (cc < 0) { - DBG(2, sprintf(output, "cc barfed\n")); - my_perror(path); - } - - free(buf); - { - int oerrno = errno; - - if (close(fd) != 0) { - DBG(2,sprintf(output, "close barfed\n")); - my_perror(path); - if (cc < 0) - errno = oerrno; - else - cc = -1; - } - } - - last_ret_val = numfiles; - my_errno = errno; - - return SUCCESS; -} - -int sysio_mount(char *from, char *to) -{ - int err; - char *s; - char *buf; - char *cp; - char *fstype, *source, *opts, *target; - - err = 0; - - /* - * Copy everything to a buffer we can modify. - */ - s = buf = malloc(strlen(from) + 1); - if (!buf) { - my_perror(from); - last_ret_val = -1; - my_errno = errno; - return SUCCESS; - } - (void )strcpy(s, from); - - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get fstype. - */ - fstype = cp = s; - while (*cp && *cp != ':' && *cp != ' ' && *cp != '\t') - cp++; - if (fstype == cp || *cp != ':') { - DBG(1, sprintf(output, "%s: Missing FS type\n", from)); - err = -1; - goto out; - } - *cp++ = '\0'; - - s = cp; - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get source. - */ - source = cp = s; - while (*cp && *cp != ' ' && *cp != '\t') - cp++; - if (source == cp) { - DBG(1, sprintf(output, "%s: Missing source\n", from)); - err = -1; - goto out; - } - if (*cp) - *cp++ = '\0'; - - s = to; - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get opts. - */ - opts = cp = s; - while (*cp && *cp != ' ' && *cp != '\t') - cp++; - if (opts == cp) { - DBG(1,sprintf(output, "%s: Missing target\n", to)); - err = -1; - goto out; - } - if (*cp) - *cp++ = '\0'; - - s = cp; - /* - * Eat leading white. - */ - while (*s && *s == ' ' && *s == '\t') - s++; - /* - * Get target - */ - target = cp = s; - while (*cp && *cp != ' ' && *cp != '\t') - cp++; - if (target == cp) { - target = opts; - opts = NULL; - } - if (*cp) - *cp++ = '\0'; - - err = mount(source, target, fstype, 0, opts); - if (err) - my_perror(from); - -out: - free(buf); - last_ret_val = err; - my_errno = errno; - return SUCCESS; -} - -int sysio_chdir(char *newdir) -{ - - if (chdir(newdir) != 0) { - my_perror(newdir); - return -1; - } - /* - buf = getcwd(NULL, 0); - if (!buf) { - my_perror(newdir); - last_ret_val = -1; - my_errno = errno; - return SUCCESS; - } - DBG(4, sprintf(output, "New dir is %s\n", buf)); - - free(buf); - */ - return SUCCESS; -} - -static mode_t get_mode(char *arg, int type, int start_mode); - -#define SYMBOLIC 0 -#define DEFINED 1 -#define NUMERIC 2 -/* - * Change the permissions on a given file - * - * sysio_chmod - * - */ -int sysio_chmod(char *mode_arg, const char *path) -{ - int err; - mode_t mode; - struct stat st; - - /* Get the current mode */ - err = stat(path, &st); - - /* Is the new mode symbolic? */ - if (isalpha(mode_arg[0])) { - /* Could be specifying defines */ - if (mode_arg[0] == 'S') - mode = get_mode(mode_arg, DEFINED, st.st_mode); - else - mode = get_mode(mode_arg, SYMBOLIC, st.st_mode); - } else - mode = get_mode(mode_arg, NUMERIC, st.st_mode); - DBG(3,sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); - - if (mode == 0) { - DBG(2,sprintf(output, "Invalid mode\n")); - return INVALID_ARGS; - } - - last_ret_val = chmod(path, mode); - my_errno = errno; - return SUCCESS; - -} - - -#define USER_STATE 0 /* Specifies that the users are still being listed */ -#define MODE_STATE_ADD 1 -#define MODE_STATE_REMOVE 2 - -#define READ 00444 -#define WRITE 00222 -#define EXECUTE 00111 - -#define OWNER 00700 -#define GROUP 00070 -#define OTHER 00007 - - -mode_t -get_mode(char *arg, int type, int start_mode) -{ - int i, j,digit, total; - char c; - int state = USER_STATE; - int len = strlen(arg); - unsigned int users = 0; - unsigned int modes = 0; - - - if (type == DEFINED) { - char curr_word[10]; - - total = digit = 0; - j = 0; - DBG(4, sprintf(output, "len is %d\n", len)); - for (i=0; i < len; i++) { - if (arg[i] == '|') { - curr_word[j] = '\0'; - DBG(3, sprintf(output, "Got mode word %s\n", curr_word)); - digit = get_obj(curr_word); - if (digit < 0 ) { - DBG(2, sprintf(output, "Unable to understand mode arg %s\n", - curr_word)); - return -1; - } - total |= digit; - j = 0; - } else - curr_word[j++] = arg[i]; - } - curr_word[j] = '\0'; - DBG(3, sprintf(output, "Got mode word %s\n", curr_word)); - digit = get_obj(curr_word); - if (digit < 0 ) { - DBG(3, sprintf(output, "Unable to understand mode arg %s\n", - curr_word)); - return -1; - } - total |= digit; - return total; - } - - if (type == SYMBOLIC) { - for (i=0; i < len; i++) { - c = arg[i]; - if (state == USER_STATE) { - switch(c){ - case 'u': - users |= OWNER; - break; - case 'g': - users |= GROUP; - break; - case 'o': - users |= OTHER; - break; - case 'a': - users |= (OWNER|GROUP|OTHER); - break; - case '+': - state = MODE_STATE_ADD; - break; - case '-': - state = MODE_STATE_REMOVE; - break; - default: - return 0; - } - } else { - - switch(c){ - case 'r': - modes |= READ; - break; - case 'w': - modes |= WRITE; - break; - case 'x': - modes |= EXECUTE; - break; - default: - return 0; - } - } - } - - if (state == MODE_STATE_ADD) { - return (start_mode | (users & modes)); - } else { - return (start_mode & ~(users & modes)); - } - - } else { - /* Digits should be octal digits, so should convert */ - total = 0; - for (i=0; i < len; i++) { - c = arg[i]; - digit = atoi(&c); - if (digit > 7) - return 0; - for (j=len-i-1; j >0; j--) - digit *= 8; - total += digit; - } - return total; - } - -} - -/* - * Changes the ownership of the file. The new_id - * is of the format owner:group. Either the owner - * or the group may be omitted, but, in order to - * change the group, the : must preced the group. - */ -int sysio_chown(char *new_id, char *file) -{ - char *owner = NULL; - char *group = NULL; - uid_t o_id=-1, g_id=-1; - int len, j, i=0; - int state = 0; /* Correspond to getting owner name */ - - len = strlen(new_id); - for (i=0; i < len; i++) { - - if (new_id[i] == ':') { - /* Group name */ - if (!group) - group = malloc(strlen(new_id) -i +2); - state = 1; /* Now getting group name */ - j = 0; - if (owner) - owner[i] = '\0'; - } - - if (!state) { - /* Getting owner name */ - if (!owner) - owner = malloc(strlen(new_id) +1 ); - owner[i] = new_id[i]; - } else { - /* Group name */ - group[j] = new_id[i]; - j++; - } - } - if (group) - group[i] = '\0'; - else - owner[i] = '\0'; - - /* Are the owner and/or group symbolic or numeric? */ - if (owner) { - if (isdigit(owner[0])) { - /* Numeric -- just convert */ - o_id = (uid_t) atoi(owner); - - } else { - /* No longer support non-numeric ids */ - - DBG(2, sprintf(output, "Error: non-numeric ids unsupported\n")); - return INVALID_ARGS; - } - } - - - - if (group) { - if (isdigit(group[0])) { - /* Numeric -- just convert */ - g_id = (uid_t) atoi(group); - } else { - /* Don't support group names either */ - DBG(2, sprintf(output, "Error: non-numeric ids unsupported\n")); - return INVALID_ARGS; - } - } - - /* Now issue the syscall */ - DBG(4, sprintf(output, "Changing owner of file %s to %d (group %d)\n", - file, o_id, g_id)); - - last_ret_val = chown(file, o_id, g_id); - my_errno = errno; - return SUCCESS; -} - -int sysio_open(char *path, int flags) -{ - last_ret_val = open(path, flags); - my_errno = errno; - DBG(3, sprintf(output, "Returning with errno set to %s (ret val is %d)\n", - strerror(my_errno), (int)last_ret_val)); - return SUCCESS; -} - -int sysio_open3(char *path, int flags, char *mode_arg) -{ - mode_t mode; - - /* Is the new mode symbolic? */ - if (isalpha(mode_arg[0])) { - /* Could be specifying defines */ - if (mode_arg[0] == 'S') - mode = get_mode(mode_arg, DEFINED, 0); - else - mode = get_mode(mode_arg, SYMBOLIC, 0); - } else - mode = get_mode(mode_arg, NUMERIC, 0); - - last_ret_val = open(path, flags, mode); - my_errno = errno; - - return SUCCESS; -} - -int sysio_close(int fd) -{ - - last_ret_val = close(fd); - my_errno = errno; - return SUCCESS; -} - -int sysio_fcntl(int fd, struct cmd_map* cmdptr, char *arg) -{ - int fd_new, index, cmd, flag; - char *cmdname; - void *buf; - - cmd = cmdptr->cmd; - cmdname = cmdptr->cmd_name; - - switch(cmd) { - case F_DUPFD: - fd_new = get_obj(arg); - last_ret_val = fcntl(fd, F_DUPFD, fd_new); - my_errno = errno; - return SUCCESS; - break; - - case F_GETFD: - case F_GETFL: - case F_GETOWN: - /* case F_GETSIG: - case F_GETLEASE: */ - - last_ret_val= fcntl(fd, cmd); - my_errno = errno; - return SUCCESS; - break; - - case F_SETFD: - case F_SETFL: - case F_SETOWN: - /*case F_SETSIG: - case F_SETLEASE: - case F_NOTIFY: */ - flag = atoi(arg); - last_ret_val = fcntl(fd, cmd, flag); - my_errno = errno; - return SUCCESS; - break; - - case F_SETLK: - case F_SETLKW: - case F_GETLK: - - /* Get the buffer to hold the lock structure */ - index = get_obj(arg); - if (index < 0) { - sprintf(output, "Unable to find buffer %s\n", arg+1); - return INVALID_VAR; - } - - buf = buflist[index]; - if (!buf) { - sprintf(output, "Buffer at index %d (mapped by %s) is null\n", - index, arg); - return INVALID_VAR; - } - - last_ret_val = fcntl(fd, cmd, (struct flock *)buf); - my_errno = errno; - return SUCCESS; - default: - /* THis should be impossible */ - return INVALID_ARGS; - } - - return INVALID_ARGS; -} - -void print_stat(struct stat *st) -{ - DBG(3, sprintf(output, "%sstruct stat: \n", output)); - DBG(3, sprintf(output, "%s st_dev: %#16x\n", output, (unsigned int)st->st_dev)); - DBG(3, sprintf(output, "%s st_ino: %#16x\n", output, (unsigned int) st->st_ino)); - DBG(3, sprintf(output, "%s st_mode: %#16x\n", output, st->st_mode)); - DBG(3, sprintf(output, "%s st_nlink: %#16x\n", output, (int)st->st_nlink)); - DBG(3, sprintf(output, "%s st_uid: %#16x\n", output, st->st_uid)); - DBG(3, sprintf(output, "%s st_gid: %#16x\n", output, st->st_gid)); - DBG(3, sprintf(output, "%s st_rdev: %#16x\n", output, (int)st->st_rdev)); - DBG(3, sprintf(output, "%s st_size: %#16x\n", output, (int) st->st_size)); - DBG(3, sprintf(output, "%s st_blksize: %#16x\n", output, (int) st->st_blksize)); - DBG(3, sprintf(output, "%s st_blocks: %#16x\n", output, (int) st->st_blocks)); - DBG(3, sprintf(output, "%s st_atime: %#16x\n", output, (unsigned int) st->st_atime)); - DBG(3, sprintf(output, "%s st_mtime: %#16x\n", output, (unsigned int) st->st_mtime)); - DBG(3, sprintf(output, "%s st_ctime: %#16x", output, (unsigned int) st->st_ctime)); -} - -int sysio_fstat(int fd, void *buf) -{ - int err; - struct stat *st = (struct stat *)buf; - err = fstat(fd, st); - if (err < 0) { - my_perror("fstat"); - } - my_errno = errno; - last_ret_val = err; - print_stat(st); - - return SUCCESS; -} - -int sysio_lstat(char *filename, void *buf) -{ - int err; - struct stat *st = (struct stat *)buf; - err = lstat(filename, st); - if (err < 0) { - my_perror("lstat"); - } - - my_errno = errno; - last_ret_val = err; - print_stat(st); - return SUCCESS; -} - - -int sysio_stat(char *filename, void *buf) -{ - int err; - struct stat *st = (struct stat *)buf; - - err = stat(filename, st); - if (err < 0) { - my_perror("stat"); - } - - my_errno = errno; - last_ret_val = err; - print_stat(st); - return SUCCESS; -} - - -int sysio_getdirentries(int fd, char *buf, size_t nbytes, off_t *basep) -{ - int err; - struct dirent *dp; - - err = getdirentries(fd, buf, nbytes, basep); - last_ret_val = err; - - DBG(4, sprintf(output, "%sRead %d bytes\n", output, err)); - - dp = (struct dirent *)buf; - while (err > 0) { - DBG(3, sprintf(output, "%s\t%s: ino %llu off %llu len %x type %c\n", - output, - dp->d_name, - (unsigned long long )dp->d_ino, - (unsigned long long )dp->d_off, - dp->d_reclen, - (char )dp->d_type)); - err -= dp->d_reclen; - dp = (struct dirent *)((char *)dp + dp->d_reclen); - } - - my_errno = errno; - return last_ret_val; -} - - -int sysio_mkdir(char *path, char *mode_arg) -{ - int err; - mode_t mode; - struct stat st; - - /* Is the new mode symbolic? */ - if (isalpha(mode_arg[0])) { - /* Could be specifying defines */ - if (mode_arg[0] == 'S') - mode = get_mode(mode_arg, DEFINED, st.st_mode); - else - mode = get_mode(mode_arg, SYMBOLIC, st.st_mode); - } else - mode = get_mode(mode_arg, NUMERIC, st.st_mode); - - DBG(3, sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); - - if (mode == 0) { - DBG(2, sprintf(output, "Invalid mode\n")); - return INVALID_ARGS; - } - - err = mkdir(path, mode); - my_errno = errno; - last_ret_val = err; - return SUCCESS; - -} - -int sysio_creat(char *path, char *mode_arg) -{ - mode_t mode; - int err; - - /* Is the new mode symbolic? */ - if (isalpha(mode_arg[0])) { - /* Could be specifying defines */ - if (mode_arg[0] == 'S') - mode = get_mode(mode_arg, DEFINED, 0); - else - mode = get_mode(mode_arg, SYMBOLIC, 0); - } else - mode = get_mode(mode_arg, NUMERIC, 0); - - DBG(3, sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); - - if (mode == 0) { - DBG(2, sprintf(output, "Invalid mode\n")); - return INVALID_ARGS; - } - - err = creat(path, mode); - my_errno = errno; - last_ret_val = err; - return SUCCESS; -} - -void print_statvfs(struct statvfs *st) -{ - DBG(3, sprintf(output, "%sstruct statvfs: \n", output)); - DBG(3, sprintf(output, "%s f_bsize: %x\n", output, (unsigned int) st->f_bsize)); - DBG(3, sprintf(output, "%s f_frsize: %x\n", output, (unsigned int) st->f_frsize)); - DBG(3, sprintf(output, "%s f_blocks: %x\n", output, (unsigned int) st->f_blocks)); - DBG(3, sprintf(output, "%s f_bfree: %x\n", output, (unsigned int) st->f_bfree)); - DBG(3, sprintf(output, "%s f_bavail: %x\n", output, (unsigned int) st->f_bavail)); - DBG(3, sprintf(output, "%s f_files: %x\n", output, (unsigned int) st->f_files)); - DBG(3, sprintf(output, "%s f_ffree: %x\n", output, (unsigned int) st->f_ffree)); - DBG(3, sprintf(output, "%s f_favail: %x\n", output, (unsigned int) st->f_favail)); - DBG(3, sprintf(output, "%s f_files: %x\n", output, (unsigned int) st->f_files)); -#if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1) - DBG(3, sprintf(output, "%s f_fsid: %x\n", output, (unsigned int) st->f_fsid.__val[1])); -#else - DBG(3, sprintf(output, "%s f_fsid: %x\n", output, (unsigned int) st->f_fsid)); -#endif - DBG(3, sprintf(output, "%s f_flag: %x\n", output, (unsigned int) st->f_flag)); - DBG(3, sprintf(output, "%s f_fnamemax: %x\n", output, (unsigned int) st->f_namemax)); -} - - -int sysio_statvfs(char *filename, void *buf) -{ - int err; - struct statvfs *st = (struct statvfs *)buf; - - err = statvfs(filename, st); - if ( err == -1) { - my_perror("statvfs"); - } - - my_errno = errno; - last_ret_val = err; - - print_statvfs(st); - return SUCCESS; -} - -int sysio_fstatvfs(int fd, void *buf) -{ - int err; - struct statvfs *st = (struct statvfs *)buf; - - err = fstatvfs(fd, st); - if (err == -1) { - my_perror("fstatvfs"); - } - - my_errno = errno; - last_ret_val = err; - - print_statvfs(st); - return SUCCESS; -} - -int sysio_umask(char *mode_arg) -{ - mode_t mode; - - /* Is the new mode symbolic? */ - if (isalpha(mode_arg[0])) { - /* Could be specifying defines */ - if (mode_arg[0] == 'S') - mode = get_mode(mode_arg, DEFINED, 0); - else - mode = get_mode(mode_arg, SYMBOLIC, 0); - } else - mode = get_mode(mode_arg, NUMERIC, 0); - - last_ret_val = umask(mode); - my_errno = errno; - return SUCCESS; -} - -int sysio_mknod(char *path, char *mode_arg, dev_t dev) -{ - int err; - int mode; - - mode = get_obj(mode_arg); - - if (mode < 0) { - DBG(2,sprintf(output, "Cant get mode from %s\n", mode_arg)); - fprintf(stderr, "Cant get mode from %s\n", mode_arg); - return INVALID_VAR; - } - - err = mknod(path, (mode_t) mode, dev); - if (err < 0) - my_perror("mknod"); - - last_ret_val = err; - my_errno = errno; - return SUCCESS; -} diff --git a/libsysio/tests/test.h b/libsysio/tests/test.h deleted file mode 100644 index 781d59b..0000000 --- a/libsysio/tests/test.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -extern int (*drvinits[])(void); - -extern int drv_init_all(void); -extern int _test_sysio_startup(void); -extern void _test_sysio_shutdown(void); diff --git a/libsysio/tests/test_all.pl b/libsysio/tests/test_all.pl deleted file mode 100755 index 65bf40e..0000000 --- a/libsysio/tests/test_all.pl +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/perl -w - -# -# VERY basic functionality test for sysio. To run, just type ./test_all.pl -# Absolutely no guarantees for running on alpha/cplant -# - -use strict; -use FindBin; - -use Cwd 'abs_path'; - -my $alpha_arg = ""; -my $use_system = 1; -my $is_broke = 1; # Don't test certain areas known to not work on Cplant -my $arg_count = @ARGV; -foreach my $arg (@ARGV) { - if ($arg eq "-alpha") { - $alpha_arg = "-alpha"; - } elsif ($arg eq "-nosystem") { - $use_system = 0; - } -} -my $alpha_env = $ENV{"IS_ALPHA"}; -# Check the environment vars -if (defined($alpha_env) && ($alpha_env eq "yes")) { - $alpha_arg = "-alpha"; -} - -my $failures = 0; -my $success = 0; -# Get cwd.. -my $cwd = $ENV{PWD}; - -# Get tests directory -my $testdir = $FindBin::Bin; - -my $namespace_env = "SYSIO_NAMESPACE"; -my $home = $ENV{"HOME"}; -my $auto_mount = $ENV{"SYSIO_AUTOMOUNT"}; -my $root_flags = "0"; -my $extras = ""; -if ((defined($auto_mount)) && ($auto_mount == "xyes")) { - $root_flags = "2"; - - # - # Add a /auto directory for automounted file systems. We - # craft one automount that mounts /usr/home from the native - # file system. Further automounts in the sub-mounts are not enabled. - # - $extras=" \ - {mnt, dev=\"incore:0755+0+0\",dir=\"/mnt\",fl=2} \ - {creat, ft=dir,nm=\"/mnt/home\",pm=0755,ow=0,gr=0} \ - {creat, ft=file,nm=\"/mnt/home/.mount\",pm=0600, \ - str=\"native:/usr/home\"}"; -} -$ENV{$namespace_env} = "\ - {mnt, dev=\"native:/\",dir=/,fl=$root_flags} \ - {mnt, dev=\"incore:0755+0+0\",dir=\"/dev\"} \ - {creat, ft=chr,nm=\"/dev/stdin\",pm=0400,mm=0+0} \ - {creat, ft=chr,nm=\"/dev/stdout\",pm=0200,mm=0+1} \ - {creat, ft=chr,nm=\"/dev/stderr\",pm=0200,mm=0+2} \ - {creat, ft=dir,nm=\"/dev/fd\",pm=0755,ow=0,gr=0} \ - {creat, ft=chr,nm=\"/dev/fd/0\",pm=0400,mm=0+0} \ - {open, nm=\"/dev/fd/0\",fd=0,m=0} \ - {creat, ft=chr,nm=\"/dev/fd/1\",pm=0200,mm=0+1} \ - {open, nm=\"/dev/fd/1\",fd=1,m=1} \ - {creat, ft=chr,nm=\"/dev/fd/2\",pm=0200,mm=0+2} \ - {open, nm=\"/dev/fd/2\",fd=2,m=1} \ - {cd, dir=\"$home\"} \ - $extras "; - -my $res; - -if ($use_system == 1) { - # Will use this directory... - system("mkdir -p $cwd/tmp_dir"); - - # Create a couple of files and subdirectories for use in the tests - system("mkdir -p $cwd/tmp_dir/test1"); - system("mkdir -p $cwd/tmp_dir/test2"); - - system("cp $testdir/helper.pm $cwd/tmp_dir/test1"); -} else { - $res = `perl $testdir/setup.pl $alpha_arg $cwd`; - chop($res); - if ($res ne "setup successful") { - print "Test setup failed with $res, bailing out\n"; - exit 1; - } -} - - -if (($alpha_arg eq "") || ($is_broke == 0)) { - # Test getdirentries - $res = `perl $testdir/test_list.pl $alpha_arg $cwd/tmp_dir`; - chop($res); - if ($res ne "list test successful") { - print "Basic getdirentries test failed with message: $res\n"; - $failures++; - } else { - print "test_list finished successfully\n"; - $success++; - } -} - -# Test path -my $path1 = abs_path($testdir); -my @resarr = `perl $testdir/test_path.pl $alpha_arg $path1 $cwd $cwd/tmp_dir`; -$res = $path1.": d\n"; -if ($resarr[0] ne $res) { - print "path test returned $resarr[0] instead of $res\n"; - $failures++; -} else { - $res = $cwd.": d\n"; - if ($resarr[1] ne $res) { - print "path test returned $resarr[1] instead of $res\n"; - $failures++; - } else { - $res = $cwd."/tmp_dir: d\n"; - if ($resarr[2] ne $res) { - print "path test returned $resarr[2] instead of $res\n"; - $failures++; - } else { - print "test_path finished successfully\n"; - $success++; - } - } -} - -# Test getcwd -$res = `perl $testdir/test_getcwd.pl $alpha_arg $cwd/tmp_dir/test1`; -chop($res); -if ($res ne "getcwd test successful") { - print "getcwd test failed with message: $res\n"; - $failures++; -} else { - $success++; - print "test_getcwd finished successfully\n"; -} - -# Test copy -$res = `perl $testdir/test_copy.pl $alpha_arg $cwd/tmp_dir/test1/helper.pm $cwd/tmp_dir/helper.pm`; -chop($res); -if ($res ne "copy test successful") { - print "copy test failed with message: $res\n"; - $failures++; -} else { - $success++; - print "test_copy finished successfully\n"; -} - -# Test stats -$res = `perl $testdir/test_stats.pl $alpha_arg $use_system $cwd/tmp_dir/test1/helper.pm`; -chop($res); -if ($res ne "stat test successful") { - print "stat test failed with message: $res\n"; - $failures++; -} else { - $success++; - print "test_stats finished successfully\n"; -} - -# Test stdfd -$res = `echo "foobar" | perl $testdir/test_copy.pl $alpha_arg -o /dev/stdin /dev/stdout`; -chop($res); -if ($res ne "copy test successful") { - print "stdfd test failed with message: $res\n"; - $failures++; -} else { - $success++; - print "test_stdfd finished successfully\n"; -} - -# Test symlink -$res = `perl $testdir/test_symlink.pl $alpha_arg $cwd/tmp_dir/test1/helper.pm $cwd/tmp_dir/helper.foo`; -chop($res); -if ($res ne "Symlink test successful") { - print "symlink test failed with message: $res\n"; - $failures++; -} else { - $success++; - print "test_symlink finished successfully\n"; -} - -# Test r/w calls -$res = `perl $testdir/test_rw.pl $alpha_arg $cwd/tmp_dir/tmp.foo`; -chop($res); -if ($res ne "rw test successful") { - print "rw test failed with message: $res\n"; - $failures++; -} else { - $success++; - print "rw test finished successfully\n"; -} - -# Test strided I/O -$res = `perl $testdir/test_strided.pl $alpha_arg $cwd/tmp_dir/tmp2.foo`; -chop($res); -if ($res ne "strided IO test successful") { - print "strided IO test failed with message: $res\n"; - $failures++; -} else { - $success++; - print "strided IO test finished successfully\n"; -} - -print "$failures tests failed and $success tests succeeded\n"; - -# cleanup -- only if no failures -if ($failures == 0) { - if ($use_system == 1) { - system(`rm -rf $cwd/tmp_dir`); - } else { - $res = `perl $testdir/cleanup.pl $alpha_arg $cwd`; - chop($res); - if ($res ne "cleanup successful") { - print "Test cleanup failed with $res, bailing out\n"; - exit 1; - } - } -} -exit $failures; diff --git a/libsysio/tests/test_copy.bash b/libsysio/tests/test_copy.bash deleted file mode 100644 index 7217ba0..0000000 --- a/libsysio/tests/test_copy.bash +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash -############################################################################# -# -# This Cplant(TM) source code is the property of Sandia National -# Laboratories. -# -# This Cplant(TM) source code is copyrighted by Sandia National -# Laboratories. -# -# The redistribution of this Cplant(TM) source code is subject to the -# terms of the GNU Lesser General Public License -# (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) -# -# Cplant(TM) Copyright 1998-2003 Sandia Corporation. -# Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive -# license for use of this work by or on behalf of the US Government. -# Export of this program may require a license from the United States -# Government. -# -############################################################################# - - -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Questions or comments about this library should be sent to: -# -# Lee Ward -# Sandia National Laboratories, New Mexico -# P.O. Box 5800 -# Albuquerque, NM 87185-1110 -# -# lee@sandia.gov - -############################################################################ -# -# File: test_copy.bash -# -# Description: Script to exercise the sysio library. -# -# Usage: -# test_copy.bash -# -# Limitations: -# 1. Doesn't exercise all of sysio. -# 2. Uses hardcoded /native prefix for file names which may not be the -# final solution. -# -############################################################################ - -# defaults - change as necessary for local system -SCRATCH=test_copy.$$ -CWD=`pwd` -SRC=${CWD}/test_copy.src -DEST=${CWD}/test_copy.dest -PREFIX=/native - -# main processing logic follows -cp /dev/null $SCRATCH -rm -f $SRC $DEST -if [ -f $SRC ] -then - echo "Could not remove $SRC - test INDETERMINATE" >> $SCRATCH - exit 5 -fi -if [ -f $DEST ] -then - echo "Could not remove $DEST - test INDETERMINATE" >> $SCRATCH - exit 5 -fi - -if ( ! cp /usr/include/stdio.h $SRC ) # just picked something handy -then - echo "Could not create source file - test INDETERMINATE" >> $SCRATCH - exit 5 -fi - - -# -# Run the test -# -./test_copy ${PREFIX}/${SRC} ${PREFIX}/${DEST} -SRC_VERF=`cksum $SRC | awk '{ print $1 }'` -DEST_VERF=`cksum $DEST | awk '{ print $1 }'` -if [ "$SRC_VERF" -ne "$DEST_VERF" ] -then - echo "The source and destination files did not match; test FAILED" >> $SCRATCH 2>&1 -else - echo "The source and destination files matched; test PASSED" >> $SCRATCH 2>&1 -fi - -# -# Report test results -# -echo "" -PASSCNT=1 -if grep "FAILED" $SCRATCH > /dev/null -then - echo "TEST $0 FAILED - found failed" - cat $SCRATCH - RC=8 -elif test `grep -c "PASSED" $SCRATCH` -ne $PASSCNT > /dev/null -then - echo "TEST $0 FAILED - wrong pass count" - cat $SCRATCH - RC=4 -else - echo "TEST $0 PASSED" - RC=0 - -fi - -if [ -z "$NOCLEANUP" ] -then - rm -f $SCRATCH $SRC $DEST -fi - -exit $RC diff --git a/libsysio/tests/test_copy.c b/libsysio/tests/test_copy.c deleted file mode 100644 index 9ac97b1..0000000 --- a/libsysio/tests/test_copy.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "test.h" - -/* - * Copy one file to another. - * - * Usage: test_copy [-o] - * - * Destination will not be overwritten if it already exist. - */ - -static int overwrite = 0; /* over-write? */ - -void usage(void); -int copy_file(const char *spath, const char *dpath); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - const char *spath, *dpath; - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, - argv, - "o" - )) != -1) - switch (i) { - - case 'o': - overwrite = 1; - break; - default: - usage(); - } - - if (!(argc - optind)) - usage(); - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - /* - * Source - */ - spath = argv[optind++]; - if (!(argc - optind)) - usage(); - /* - * Destination - */ - dpath = argv[optind++]; - if (argc - optind) - usage(); - - err = copy_file(spath, dpath); - - _test_sysio_shutdown(); - - return err; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_copy " - " source destination\n"); - exit(1); -} - -int -open_file(const char *path, int flags, mode_t mode) -{ - int fd; - - fd = open(path, flags, mode); - if (fd < 0) - perror(path); - - return fd; -} - -int -copy_file(const char *spath, const char *dpath) -{ - int sfd, dfd; - int flags; - int rtn; - static char buf[1024]; - ssize_t cc, wcc; - - sfd = dfd = -1; - rtn = -1; - - sfd = open_file(spath, O_RDONLY, 0); - if (sfd < 0) - goto out; - flags = O_CREAT|O_WRONLY; - if (!overwrite) - flags |= O_EXCL; - dfd = open_file(dpath, flags, 0666); - if (dfd < 0) - goto out; - - while ((cc = read(sfd, buf, sizeof(buf))) > 0) - if ((wcc = write(dfd, buf, cc)) != cc) { - if (wcc < 0) { - perror(dpath); - break; - } - (void )fprintf(stderr, - "%s: short write (%u/%u)\n", - dpath, - (unsigned )wcc, - (unsigned )cc); - break; - } - if (cc < 0) - perror(spath); - -out: - if (sfd >= 0 && close(sfd) != 0) - perror(spath); - if (dfd >= 0 && (fsync(dfd) != 0 || close(dfd) != 0)) - perror(dpath); - - return 0; -} diff --git a/libsysio/tests/test_copy.pl b/libsysio/tests/test_copy.pl deleted file mode 100755 index 6912dcc..0000000 --- a/libsysio/tests/test_copy.pl +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/perl -w - -# -# copy test: Copy a file from src to dest and verify that the new file -# : is the same as the old -# - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage: ./test_copy.pl [-alpha] : Copy a file from src to dest\n"; - exit(-1); -} - -sub process_cmd -{ - my ($src, $dest, $overwrite, $is_alpha) = @_; - -# Get tests directory - my $testdir = $FindBin::Bin; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 $testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - # Get the filesize of src - my $size = -s $src; - my $bufsize; - - # If reading from stdin, just read one line - my $line; - if ($src eq "/dev/stdin") { - $line = ; - $size = length($line); - } - - if ( $size > 1024) { # Arbitrary limit - $bufsize = 1024; - } else { - $bufsize = $size; - } - - my $cmdstr; - # Open src - if ($src ne "/dev/stdin") { - $cmdstr = '$src = CALL open '."$src O_RDONLY\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "open $src"); - } - if ($dest ne "/dev/stdout") { - # Open dest - my $flags = "O_WRONLY|O_CREAT"; - if ($overwrite == 0) { - $flags .= "|O_EXCL"; - } - $cmdstr = '$dest = CALL open '."$dest $flags 0777\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - my $destfile = helper::verify_cmd($cmdfh, $outfh, "open $dest"); - } - - # Allocate buffer - $cmdstr = '$buf = ALLOC '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "ALLOC", $cmdstr); - - # Read size bytes from src and write them out to dest - my $bytes = $size; - while ($bytes > 0) { - - my $readb; - my $res; - if ($src eq "/dev/stdin") { - # Send "delay" option to read which will give us time to - # put something in stdin (since we can't send an eof) - my $cmdstr = "CALL read ".'0 $buf '."$bytes delay\n"; - print $cmdfh $cmdstr; - # Give time to process command - sleep 1; - - # Send line from stdin - print $cmdfh $line; - sleep 0.5; - - # Make sure read was OK - $res = <$outfh>; - chop($res); - if ($res ne "0000 ") { - helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Read failed with code $res\n"); - } - - # See how many bytes we got... - $readb = helper::verify_cmd($cmdfh, $outfh, "read"); - $readb = oct($readb); - if ($readb != $bytes) { - helper::print_and_exit($cmdfh, $outfh, 0, "Short read\n"); - } - - if ($dest eq "/dev/stdout") { - $cmdstr = "CALL write ".'1 $buf '."$readb\n"; - } else { - $cmdstr = "CALL write ".'$dest $buf '."$readb\n"; - } - print $cmdfh $cmdstr; - - # Suck up the stdout... - $res = <$outfh>; - chop($res); - - $res = <$outfh>; - chop($res); - $res = oct($res); - - if ($res != 0) { - helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Write failed with code $res\n"); - } - } else { - $cmdstr = 'CALL read $src $buf '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "read", $cmdstr); - - $res = helper::verify_cmd($cmdfh, $outfh, "read"); - $readb = oct($res); - - # Now write $readb back out to dest - $cmdstr = 'CALL write $dest $buf '."$readb\n"; - helper::send_cmd($cmdfh, $outfh, "write", $cmdstr); - } - - $res = helper::verify_cmd($cmdfh, $outfh, "write"); - - if ($readb != oct($res)) { - print STDOUT "ERROR! Read $readb bytes but got back $res bytes\n"; - exit 1; - } - - $bytes -= $readb; - } - - # Clean up - if ($src ne "/dev/stdin") { - $cmdstr = 'CALL close $src'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - } - if ($dest ne "/dev/stdout") { - $cmdstr = 'CALL close $dest'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - } - if ($src ne "/dev/stdin") { - my $cmd = "cmp $src $dest " . '2>&1'; - my $cmpstr = qx($cmd); - my $exitval = $? >> 8; - if ($exitval != 0) { - if ($exitval == 1) { - print STDOUT "ERROR! File $src differs from $dest\n"; - print STDOUT "Comparison returned $cmpstr"; - } else { - print STDOUT "ERROR! File comparison failed with msg $cmpstr"; - } - exit 1; - } - } - helper::print_and_exit($cmdfh, $outfh, 0, "copy test successful\n"); -} - -my $currarg = 0; -my $is_alpha = 0; -my $overwrite = 0; - -my $len = @ARGV-2; - -if (@ARGV < 2) { - usage; -} - -my $i; -for ($i=0; $i < $len; $i++ ) { - if ($ARGV[$i] eq "-alpha") { - $is_alpha = 1; - } - if ($ARGV[$i] eq "-o") { - $overwrite = 1; - } -} - -my $src = $ARGV[$i++]; -my $dest = $ARGV[$i]; - - -process_cmd($src, $dest, $overwrite, $is_alpha); - - -exit 0; diff --git a/libsysio/tests/test_driver.c b/libsysio/tests/test_driver.c deleted file mode 100644 index cbc6415..0000000 --- a/libsysio/tests/test_driver.c +++ /dev/null @@ -1,1085 +0,0 @@ -#ifndef _BSD_SOURCE -#define _BSD_SOURCE -#endif -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 500 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "mount.h" -#include "test.h" -#include "test_driver.h" - - -struct queue_t; - -typedef struct cmd_tree_t { - char *res_name; - char *val; - int arg_count; - struct queue_t *children; -} cmd_tree; - -struct queue_t { - char *val; - cmd_tree *cmd; - struct queue_t *next; -}; - -struct cmd_t cmd_list[] = { - {"alloc", get_buffer, usage_get_buffer}, - {"chdir", test_do_chdir, usage_chdir}, - {"checkbuf", do_checkbuf, usage_checkbuf}, - {"chmod", test_do_chmod, usage_chmod}, - {"chown", test_do_chown, usage_chown}, - {"clear", test_do_clear, usage_clear}, - {"close", test_do_close, usage_close}, - {"cmpstr", cmp_bufs, usage_cmpbufs}, - {"creat", test_do_creat, usage_creat}, - {"debug", test_do_setdebug, usage_setdebug}, - {"dup", test_do_dup, usage_dup}, - {"dup2", test_do_dup2, usage_dup2}, - {"endian", get_endian, usage_endian}, - {"exit", test_do_exit, usage_exit}, - {"fcntl", test_do_fcntl, usage_fcntl}, - {"fdatasync", test_do_fdatasync, usage_fdatasync}, - {"fill", test_do_fillbuff, usage_do_fillbuff}, - {"free", free_buffer, usage_free_buffer}, - {"fstat", test_do_fstat, usage_fstat}, - {"fstatvfs", test_do_fstatvfs, usage_fstatvfs}, - {"fsync", test_do_fsync, usage_fsync}, - {"ftruncate", test_do_ftruncate, usage_ftruncate}, - {"getcwd", test_do_getcwd, usage_getcwd}, - {"getdirentries", test_do_getdirentries, usage_getdirentries}, - {"init", test_do_init, usage_init}, - {"init_iovec", test_do_init_iovec, usage_init_iovec}, - {"init_xtvec", test_do_init_xtvec, usage_init_xtvec}, - {"ioctl", test_do_ioctl, usage_ioctl}, - {"iodone", test_do_iodone, usage_iodone}, - {"iowait", test_do_iowait, usage_iowait}, - {"ipread", test_do_ipread, usage_ipread}, - {"ipreadv", test_do_ipreadv, usage_ipreadv}, - {"ipwrite", test_do_ipwrite, usage_ipwrite}, - {"ipwritev", test_do_ipwritev, usage_ipwritev}, - {"iread", test_do_iread, usage_iread}, - {"ireadv", test_do_ireadv, usage_ireadv}, - {"ireadx", test_do_ireadx, usage_ireadx}, - {"iwrite", test_do_iwrite, usage_iwrite}, - {"iwritev", test_do_iwritev, usage_iwritev}, - {"iwritex", test_do_iwritex, usage_iwritex}, - {"list", test_do_list, usage_list}, - {"lseek", test_do_lseek, usage_lseek}, - {"lstat", test_do_lstat, usage_lstat}, - {"mkdir", test_do_mkdir, usage_mkdir}, - {"mknod", test_do_mknod, usage_mknod}, - {"mount", test_do_mount, usage_mount}, - {"open", test_do_open, usage_open}, - {"printbuf", test_do_printbuf, usage_do_printbuf}, - {"printline", test_do_printline, usage_printline}, - {"pread", test_do_pread, usage_pread}, - {"preadv", test_do_preadv, usage_preadv}, - {"pwritev", test_do_pwritev, usage_pwritev}, - {"pwrite", test_do_pwrite, usage_pwrite}, - {"quit", test_do_exit, usage_exit}, - {"read", test_do_read, usage_read}, - {"readv", test_do_readv, usage_readv}, - {"readx", test_do_readx, usage_readx}, - {"rmdir", test_do_rmdir, usage_rmdir}, - {"setbuf", do_setbuf, usage_setbuf}, - {"sizeof", get_sizeof, usage_sizeof}, - /* {"setoutput", test_do_setoutput, usage_setoutput}, */ - {"stat", test_do_stat, usage_stat}, - {"statvfs", test_do_statvfs, usage_statvfs}, - {"symlink", test_do_symlink, usage_symlink}, - {"truncate", test_do_truncate, usage_truncate}, - {"umask", test_do_umask, usage_umask}, - {"umount", test_do_umount, usage_umount}, - {"unlink", test_do_unlink, usage_unlink}, - {"write", test_do_write, usage_write}, - {"writev", test_do_writev, usage_writev}, - {"writex", test_do_writex, usage_writex}, - {NULL, NULL, NULL} -}; - -int run_cmd(cmd_tree *cmd_arg); -cmd_tree* build_tree(char **cmd, int *length, int total); -/* - * ################################################## - * # Memory functions # - * # Intended to allow users to gain access to # - * # buffers of memory to be manipulated later # - * ################################################## - */ - -void * alloc_buff32(unsigned int size, int align) -{ - void* buf; - long buf_ptr; - - /* - if ((err = memalign(&buf, align, size)) != 0) { - perror("memalign"); - return 0; - } - */ - size += align; - buf = malloc(size); - align--; - DBG(3, fprintf(outfp, "Buf is at %p\n", (void *)buf)); - buf_ptr = (long)buf + ((long)buf & align); - - DBG(3, fprintf(outfp, "Buf is at %p\n", (void *)buf_ptr)); - return (void *)buf_ptr; -} - -void free_buf32(void * ptr) -{ - free(ptr); -} - -long alloc_buff64(unsigned int size, int align) -{ - char * buf; - long ret_value; - - /* - if (memalign((void **)&buf, align, size)) - return 0; - */ - size += align; - buf = malloc(size); - align--; - ret_value = (long)buf + ((long)buf & align); - return ret_value; -} - -void free_buf64(long ptr) -{ - free((char *)ptr); -} - - -/* - * Hash function for variables. Shamelessly stolen - * from the ext3 code - */ -unsigned int dx_hack_hash (const char *name, int len) -{ - unsigned int hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; - while (len--) - { - unsigned int hash = hash1 + (hash0 ^ (*name++ * 7152373)); - if (hash & 0x80000000) hash -= 0x7fffffff; - hash1 = hash0; - hash0 = hash; - } - return hash0; -} - -struct var_mapping *get_map(char *var_name) -{ - int index; - struct var_mapping_list *curr; - - - if (var_name[0] == '$') { - /* It is a name--chop off the initial and get the mapping $ */ - var_name++; - } - - index = dx_hack_hash(var_name, strlen(var_name)); - index %= MAX_VARS -1; - - DBG(5, fprintf(outfp, "Got index of %d for %s\n", index, var_name)); - curr = &map[index]; - - while ((curr) && (curr->map.obj != -1) ) { - if ( (curr->map.name == NULL) || (strcmp(curr->map.name, var_name)) ) - curr = curr->next; - else - return &curr->map; - } - - return NULL; -} - -char *get_str(char *var_name) -{ - /* See if it is a quoted string */ - if (var_name[0] == '"') { - /* Chop off the beginning and end quotes and return the string */ - int len = strlen(var_name); - var_name[len-1] = '\0'; - var_name++; - } - - return var_name; -} - -static char* -get_or_part(char **str, int* did_alloc) -{ - char *tmp_str = *str; - int i, norm_str=0; - - if (tmp_str == NULL) - return NULL; - - if (tmp_str[0] == '|') { - tmp_str++; - norm_str=1; - } - - for (i=0; (unsigned int)i < strlen(tmp_str); i++) { - if (tmp_str[i] == '|') { - char *new_str = (char *)malloc(i+1); - memcpy(new_str, tmp_str, i); - new_str[i] = '\0'; - *did_alloc = 1; - *str = &tmp_str[i]; - return new_str; - } - } - - if (norm_str) { - *did_alloc = 0; - *str = NULL; - return tmp_str; - } - - return NULL; -} - -int get_obj(char *var_name) -{ - char** str = &var_name; - char *str1; - struct var_mapping *var_map; - int did_alloc=0; - int obj=0, got_obj=0; - - DBG(5, fprintf(outfp, "Getting object for %s\n", var_name)); - - /* If var_name is a digit, we assume it is a literal */ - if (isdigit(var_name[0])) - return atoi(var_name); - - /* - * Check for '|', indicates that one or more values are or'd - * together - */ - while ((str1 = get_or_part(str, &did_alloc)) != NULL) { - - if (isdigit(str1[0])) { - if (str1[0] == '0') { - /* Assume octal format */ - obj |= strtol(str1, NULL, 8); - } else - obj |= atoi(str1); - } else { - var_map = get_map(str1); - if (!var_map) { - if (did_alloc) - free(str1); - return -1; - } - obj |= var_map->obj; - } - - if (did_alloc) { - did_alloc = 0; - free(str1); - } - got_obj++; - } - - if (got_obj) - return obj; - - var_map = get_map(var_name); - if (!var_map) - return -1; - else - return var_map->obj; -} - - -void store_result(char *var_name, int result) -{ - int index = dx_hack_hash(var_name, strlen(var_name)); - struct var_mapping_list *map_obj; - struct var_mapping_list *new_map; - index %= MAX_VARS -1 ; - - if (map[index].map.obj >= 0) { - - /* Got a collision --just chain it*/ - new_map = malloc(sizeof(struct var_mapping_list)); - - map_obj = &map[index]; - while (map_obj->next != NULL) - map_obj = map_obj->next; - - map_obj->next = new_map; - } else - new_map = &map[index]; - - new_map->map.name = malloc(strlen(var_name) + 1); - strcpy(new_map->map.name, var_name); - new_map->map.obj = result; - new_map->map.type = last_type; - new_map->next = NULL; - DBG(3, fprintf(outfp, "Stored %d in index %d hashed with %s\n", - result, index, var_name)); -} - -void free_obj(char *obj_name) -{ - int index; - struct var_mapping_list *prev, *curr; - - - /* See if it is a variable name */ - if (obj_name[0] == '$') { - /* It is a name--chop off the initial $ */ - obj_name++; - } - index = dx_hack_hash(obj_name, strlen(obj_name)); - index %= MAX_VARS -1; - - DBG(5, fprintf(outfp, "Got index of %d\n", index)); - curr = &map[index]; - - prev = NULL; - - while ((curr) && (curr->map.obj != -1) ) { - if (strcmp(curr->map.name, obj_name)) { - prev = curr; - curr = curr->next; - } else - break; - } - - /* Remove the object from the chain */ - if (prev) - prev->next = curr->next; - - curr->map.obj = -1; - free(curr->map.name); - if (prev) - free(curr); -} - - -/* - * Given a long string, returns the string divided into - * whitespace seperated words in list. Returns the number - * of words - */ -int parser(char *str, char** list) -{ - int len, i=0, j=0, counter=-1; - int in_quotes = 0; - char *new_str; - - - len = strlen(str); - DBG(5, fprintf(outfp, "str is %s len is %d\n", str, len)); - while (i < len) { - - if ((i==0) || ((str[i] == ' ') && (in_quotes == 0)) ) { - if (i != 0) { - new_str[j] = '\0'; - DBG(5, fprintf(outfp, "Got word %s\n", list[counter])); - i++; - } - while ((str[i] == ' ') && (in_quotes == 0)) - i++; - counter++; - new_str = list[counter] = malloc(MAX_WORD); - j = 0; - - } - - new_str[j] = str[i]; - if (str[i] == '"') { - if (in_quotes) - in_quotes = 0; - else - in_quotes = 1; - } - if ((str[i] == ' ') && (in_quotes==0)){ - while (str[i+1] == ' ') - i++; - new_str[j] = '\0'; - } - i++; - j++; - - } - new_str[j] = '\0'; - DBG(5, fprintf(outfp, "Got word %s\n", list[counter])); - return counter +1; -} - - -int execute_cmd(char *cmd, char **args, int arg_count) -{ - int i = 0; - - if (!strcmp(cmd, "help")) { - if (arg_count > 0) { - while(cmd_list[i].cmd != NULL) { - if (!strcmp(cmd_list[i].cmd, args[0])) { - (cmd_list[i].usage)(); - return 0; - } - i++; - } - } else { - do_help(); - return 0; - } - return -1; - } - while(cmd_list[i].cmd != NULL) { - if (!strcmp(cmd_list[i].cmd, cmd)) { - return (cmd_list[i].func)(arg_count, args); - } - i++; - } - DBG(2, fprintf(outfp, "Command %s was invalid\n", cmd)); - return INVALID_CMD; -} - -int get_args(struct queue_t *child, char** list, int num_args, int argnum) -{ - char *argval; - - if (child->val != NULL) { - argval = child->val; - } else if (child->cmd != NULL) { - run_cmd(child->cmd); - if (child->cmd->res_name != NULL) - argval = child->cmd->res_name; - else { - char tmpstr[50]; - int val = last_ret_val; - sprintf(tmpstr, "%x", val); - argval = tmpstr; - } - } else { - DBG(2, fprintf(outfp, "I am confused\n")); - return INVALID_ARGS; - } - - list[argnum] = malloc(strlen(argval) + 1); - strcpy(list[argnum], argval); - argnum++; - - if (argnum == num_args) - return SUCCESS; - else if (child->next == NULL) { - DBG(2, fprintf(outfp, "Only on arg number %d out of %d, but ran out of children\n", - argnum, num_args)); - return INVALID_ARGS; - } else - return get_args(child->next, list, num_args, argnum); - - return SUCCESS; -} - -int run_cmd(cmd_tree *cmd_arg) -{ - char cmdstr[MAX_COMMAND]; - char *cmdptr; - char **args; - int res, i; - struct buf_t *buf; - char *cmd; - struct queue_t *child; - - if (cmd_arg == NULL) - return INVALID_CMD; - - cmd = cmd_arg->val; - cmdptr = cmdstr; - child = cmd_arg->children; - if ( (!strcmp("exit", cmd)) || (!strcmp("quit", cmd)) || - (!strcmp("EXIT", cmd)) || (!strcmp("QUIT", cmd)) ) - strcpy(cmdstr, "exit"); - else if (!strcmp("ALLOC", cmd)) - strcpy(cmdstr, "alloc"); - else if (!strcmp("FREE", cmd)) - strcpy(cmdstr, "free"); - else if (!strcmp("HELP", cmd)) - strcpy(cmdstr, "help"); - else if (!strcmp("CALL", cmd)) { - if (cmd_arg->arg_count < 1) { - DBG(2, fprintf(outfp, "Need at least one command\n")); - return INVALID_CMD; - } - - cmd_arg->arg_count--; - if (child->val != NULL) - cmdptr = child->val; - else { - DBG(2, fprintf(outfp, "Need to specify command\n")); - return INVALID_CMD; - } - - DBG(3, fprintf(outfp, "Got cmd %s\n", child->val)); - if (cmd_arg->arg_count != 0) - child = child->next; - - - } else if (!strcmp("DEPOSIT", cmd)) - strcpy(cmdstr, "fill"); - else if (!strcmp("PRINT", cmd)) - strcpy(cmdstr, "printbuf"); - else { - if (cmd_arg->res_name != NULL) { - /* - * If the cmd is not a valid command, just store it - */ - res = get_obj(cmd_arg->children->val); - last_type = UINT; - if (res < 0) { - /* Just store it as a string */ - buf = (struct buf_t *)malloc(sizeof(struct buf_t)); - buf->len = strlen(cmd); - buf->buf = (char *)malloc(buf->len+1); - strcpy(buf->buf, cmd_arg->children->val); - buflist[next] = buf; - res = next; - DBG(3, fprintf(outfp, "Stored %s in index %d\n", (char *)buf->buf, next)); - next++; - last_type = STR; - } - store_result(cmd_arg->res_name, res); - return SUCCESS; - } else - return INVALID_CMD; - } - - - if (cmd_arg->arg_count == 0) - args = NULL; - else { - args = (char **)malloc(sizeof(char *)*cmd_arg->arg_count); - get_args(child, args, cmd_arg->arg_count, 0); - } - - DBG(3, fprintf(outfp, "CMD: %s\n ARGS: ",cmdptr)); - for (i=0; i < cmd_arg->arg_count; i++) - DBG(3, fprintf(outfp, "%s ", args[i])); - DBG(3, fprintf(outfp, "\n")); - res = execute_cmd(cmdptr, args, cmd_arg->arg_count); - if (cmd_arg->res_name != NULL) - store_result(cmd_arg->res_name, last_ret_val); - - return res; -} - - -int is_command(char *name) -{ - if ( (strcmp(name, "CALL")) && (strcmp(name, "FILL")) && - (strcmp(name, "ALLOC")) && (strcmp(name, "PRINT")) && - (strcmp(name, "FREE")) && (strcmp(name, "exit")) && - (strcmp(name, "HELP")) && (strcmp(name, "help")) && - (strcmp(name, "quit")) && (strcmp(name, "EXIT")) && - (strcmp(name, "QUIT")) && (strcmp(name, "DEPOSIT")) ) - return 0; - - return 1; -} - -#define ARGS 1 -int get_type(char *arg0) -{ - if ((arg0[0] == '(') || (is_command(arg0)) ){ - return 2; - } - - return ARGS; -} - - -int add_args(char **cmd, int length, int total, cmd_tree *tree) -{ - int new_len, type; - struct queue_t *old, *new; - - old = tree->children; - while ((old) && (old->next)) - old = old->next; - new = (struct queue_t *)malloc(sizeof(struct queue_t)); - if (old) - old->next = new; - else - tree->children = new; - new->next = NULL; - - type = get_type(cmd[0]); - if (type < 0) { - DBG(2, fprintf(outfp, "Don't understand %s\n", cmd[0])); - return INVALID_CMD; - } - if (type == ARGS) { - new->val = (char *)malloc(strlen(cmd[0])+1); - strcpy(new->val, cmd[0]); - new->cmd = NULL; - total = 1; - } else { - new_len = length; - if (cmd[0][0] == '(') { - new_len--; - } - - new->val = NULL; - new->cmd = build_tree(&cmd[1], &new_len, total); - if (new->cmd == NULL) { /* Invalid command */ - return length; /* Pretend we used everything up */ - } - total = (length - new_len); - DBG(4, fprintf(outfp, "Used %d bytes\n", total)); - } - - return total; -} - -void free_tree(cmd_tree* tree) -{ - if (!tree) - return; - - if (tree->children) { - struct queue_t *child = tree->children; - struct queue_t *next; - do { - next = child->next; - if (child->cmd) - free_tree(child->cmd); - free(child->val); - free(child); - child = next; - } while (child); - } - - if (tree->res_name) - free(tree->res_name); - - if (tree->val) - free(tree->val); - - free(tree); -} - -cmd_tree* build_tree(char **cmd, int *length, int total) -{ - int index = 0, used_args = 0; - cmd_tree *tree; - if ((*length < 0) || (!cmd) || (*cmd == NULL)) - return NULL; - - - DBG(4, fprintf(outfp, "length is %d\n", *length)); - tree = (cmd_tree *)malloc(sizeof(cmd_tree)); - tree->res_name = NULL; - tree->children = NULL; - if (cmd[index][0] == '$') { - tree->res_name = (char *)malloc(strlen(cmd[index])+1); - strcpy(tree->res_name, (char*)(cmd[index]+1)); - index++; - if (cmd[index][0] == '=') - index++; - } else - tree->res_name = NULL; - - if (is_command(cmd[index]) == 0) { - if (tree->res_name == NULL) { - DBG(2, fprintf(outfp, "command %s is invalid \n", cmd[index])); - return NULL; - } - } - - tree->val = (char *)malloc(strlen(cmd[index])+1); - strcpy(tree->val, cmd[index]); - index++; - *length -= index; - tree->arg_count = 0; - - if (*length == 0) { - /* All done! */ - return tree; - } - - /* Got to get the arguments */ - while (*length > 0) { - - if (cmd[index][0] == ')') { - *length = *length-1; - DBG(4, fprintf(outfp, "and now len is %d\n", *length)); - return tree; - } - - used_args = add_args(&cmd[index], *length, total, tree); - tree->arg_count++; - *length -= used_args; - index += used_args; - } - - return tree; -} - -char *line; -char *getline(char *prompt) -{ - int i=-1; - int count=0; - - line = malloc(MAX_LINE); - if ((do_prompt) && (infp == stdin)) - printf(prompt); - - do { - /* If we get an end of file, just wait */ - if (feof(infp)) { - while (feof(infp) && (line[i] != '\n')) { - clearerr(infp); - count++; - fseek(infp, 0, SEEK_CUR); - } - } else { - i++; - } - fread(&line[i], 1, 1, infp); - } while(line[i] != '\n'); - - line[i] = '\0'; - - /* fprintf(stderr, "Got word %s\n", line); */ - DBG(5, fprintf(outfp, "Got word %s\n", line)); - return line; -} - -void my_perror(char *msg) -{ - char *errmsg = strerror(errno); - - DBG(2, fprintf(outfp, "%s: %s\n", msg, errmsg)); -} - -/* Static list of flag names */ -struct var_mapping flags_map[] = { - {"O_RDONLY", O_RDONLY, UINT }, - {"O_WRONLY", O_WRONLY, UINT }, - {"O_RDWR", O_RDWR, UINT }, - {"O_CREAT", O_CREAT, UINT }, - {"O_EXCL", O_EXCL, UINT }, - {"O_NOCTTY", O_NOCTTY, UINT }, - {"O_TRUNC", O_TRUNC, UINT }, - {"O_APPEND", O_APPEND, UINT }, - {"O_SYNC", O_NONBLOCK, UINT }, - {"O_NDELAY", O_NDELAY, UINT }, - {"O_SYNC", O_SYNC, UINT }, - {"O_FSYNC", O_FSYNC, UINT }, - {"O_ASYNC", O_ASYNC, UINT }, - {"SEEK_SET", SEEK_SET, UINT }, - {"SEEK_CUR", SEEK_CUR, UINT }, - {"SEEK_END", SEEK_END, UINT }, - {"S_ISUID", S_ISUID, UINT }, - {"S_ISGID", S_ISGID, UINT }, - {"S_ISVTX", S_ISVTX, UINT }, - {"S_IRWXU", S_IRWXU, UINT }, - {"S_IRUSR", S_IRUSR, UINT }, - {"S_IREAD", S_IREAD, UINT }, - {"S_IWUSR", S_IWUSR, UINT }, - {"S_IWRITE", S_IWRITE, UINT }, - {"S_IXUSR", S_IXUSR, UINT }, - {"S_IEXEC", S_IEXEC, UINT }, - {"S_IRWXG", S_IRWXG, UINT }, - {"S_IRGRP", S_IRGRP, UINT }, - {"S_IWGRP", S_IWGRP, UINT }, - {"S_IXGRP", S_IXGRP, UINT }, - {"S_IRWXO", S_IRWXO, UINT }, - {"S_IROTH", S_IROTH, UINT }, - {"S_IWOTH", S_IWOTH, UINT }, - {"S_IXOTH", S_IXOTH, UINT }, - {"S_IFCHR", S_IFCHR, UINT }, - {"S_IFMT", S_IFMT, UINT }, - {"S_IFBLK", S_IFBLK, UINT }, - {"S_IFREG", S_IFREG, UINT }, - {"S_IFIFO", S_IFIFO, UINT }, - {"S_IFLNK", S_IFLNK, UINT }, - { NULL, -1, SINT } -}; - -void init_map() -{ - int index = 0; - - while (flags_map[index].obj != -1) { - store_result(flags_map[index].name, flags_map[index].obj); - index++; - } -} - -int getquotedlen(char *str) -{ - int i; - - if (str[0] != '"' && str[0] != '\'') - return -1; - - for (i=1; str[i] != '\0' && str[i] != '"' && str[i] != '\''; i++); - - return i; -} - -int perform_op(int num1, int num2, char op) -{ - switch(op) { - - case '+': - return num1 + num2; - break; - - case '*': - return num1 * num2; - break; - - case '/': - return num1 / num2; - break; - - case '-': - return num1 - num2; - break; - - case '%': - return num1%num2; - break; - - default: - return num1; - } - return 0; -} - -int get_constant_val(char **str_ptr, int type) -{ - struct buf_t *buf; - char *buf_ptr; - char *str = *str_ptr; - char ch; - int i, j, num1, num2, size; - - printf("Getting constant val from %s\n", str); - switch(type) { - case 1: - size = getquotedlen(str); - buf = (struct buf_t *)malloc(sizeof(struct buf_t)); - buf->buf = alloc_buff32(size, 8); - buf->len = size; - buf_ptr = buf->buf; - buflist[next] = buf; - j=0; - for (i=1; i < size; i++) { - buf_ptr[j] = str[i]; - j++; - } - buf_ptr[j] = '\0'; - - DBG(3, fprintf(outfp, "Your buffer (%p) (%p) is at index %d\n", - (void *)buf, buf->buf, next)); - next++; - - last_type = PTR; - last_ret_val = next-1; - return last_ret_val; - break; - - case 2: - if (str[0] == '$') { - num1 = get_obj(str); - } else { - num1 = atoi(str); - } - str = str_ptr[1]; - ch = str_ptr[1][0]; - if ((ch == '+') || (ch == '/') || (ch == '*') || - (ch == '-') || (ch == '%')) { - if (str_ptr[2][0] == '$') - num2 = get_obj(str_ptr[2]); - else - num2 = atoi(str_ptr[2]); - num1 = perform_op(num1, num2, ch); - } - - last_type = UINT; - last_ret_val = num1; - - break; - - default: - DBG(2, fprintf(outfp, "Can't understand type of %d\n", type)); - return INVALID_ARGS; - } - - return last_ret_val; -} - -int is_constant(char *str) -{ - if ((str[0] == '"') || (str[0] == '\'')) - return 1; - - - if ( (str[0] == '$') || - ( ((int)str[0] > 47) && ((int)str[0] < 57) ) ) - return 2; - - return 0; -} - -int main(int argc, char *argv[]) -{ - int count, err, i, orig_count; - char *input, *name; - char **cmd; - cmd_tree *tree; - extern int _test_sysio_startup(void); - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - - infp = stdin; - outfp = stdout; - - do_prompt = 1; - - errno = 0; - /* Get the input/output streams */ - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "--input")) { - i++; - infp = fopen(argv[i], "r"); - if (!infp) { - fprintf(outfp, "Unable to open file %s for reading\n", argv[i]); - return -1; - } - } else if (!strcmp(argv[i], "--output")) { - i++; - outfp = fopen(argv[i], "w"); - if (!outfp) { - fprintf(stderr, "Unable to open file %s for writing\n", argv[i]); - return -1; - } - } else if (!strcmp(argv[i], "--np")) { - do_prompt = 0; - } else { - fprintf(stderr, "%s: Invalid arg\n", argv[i]); - return -1; - } - } - /* Initilize the mapping */ - for (i=0; i < MAX_VARS; i++) - map[i].map.obj = -1; - - /* Debug defaults */ - debug_level = 1; - print_line = 0; - - -#if 0 - /* sysio defaults */ - strcpy(root_driver, DEFAULT_DRIVER); - strcpy(mntpath, "/"); - mntflgs = 0; -#endif - - my_errno = 0; - - /* Set up line buffering */ - setlinebuf(outfp); - setlinebuf(infp); - - /* - * This sets up some common flags so that the string - * names can be used (for instance 0_RDWR, SEEK_SET, etc - */ - init_map(); - i=0; - next = 0; - while (1) { - bzero(output, 4096); - - input = getline("> "); - cmd = malloc(MAX_COMMAND * sizeof(char *)); - count = orig_count = parser(input, cmd); - name = NULL; - if ((!count) || (count > MAX_COMMAND)){ - fprintf(outfp, "%s: invalid command\n", input); - } else { - i = 0; - if (cmd[0][0] == '$') { - /* Need to store output of command in var name */ - name = cmd[0]+1; - DBG(4, fprintf(outfp, "name is %s\n", name)); - count--; - /* The '=' is not necessary, but available */ - if (!strcmp(cmd[1], "=")){ - i++; - count--; - } - i++; - if ((err=is_constant(cmd[i])) != 0) { - store_result((char *)(&cmd[0][1]), get_constant_val(&cmd[i], err)); - tree = NULL; - err = 0; - } else { - - tree = build_tree(&cmd[i], &count, 0); - if (tree != NULL) { - err = run_cmd(tree); - store_result((char *)(&cmd[0][1]), last_ret_val); - } - } - } else { - - tree = build_tree(cmd, &count, 0); - if (tree != NULL) - err = run_cmd(tree); - } - /* Print out return code and any string from command */ - fprintf(outfp, "%#04x %s\n", err, output); - if (tree) - free_tree(tree); - /* fprintf(stderr, "%#04x %s\n", err, output); */ - for (i=0; i < count; i++) - free(cmd[i]); - } - free(cmd); - free(line); - } -} diff --git a/libsysio/tests/test_driver.h b/libsysio/tests/test_driver.h deleted file mode 100644 index d8fabaf..0000000 --- a/libsysio/tests/test_driver.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * I feel like I should be putting a comment here... - */ -#include -#include "test.h" - -/* Debugging stuff.. */ -#define PRINT_LINE 0 -int debug_level; -int print_line; - -FILE *outfp; /* output file */ -FILE *infp; - -#define DBG(level, _x) \ - do { \ -if (((level) <= (debug_level))) { \ - if (print_line) \ - fprintf(outfp, "From file %s line %d: \n", __FILE__, __LINE__); \ - (void)((_x)); \ -} \ -} while(0) - -/* Maximum size of a command or command argument */ -#define MAX_WORD 150 - -/* Maximum size of an input line */ -#define MAX_LINE 300 - -/* Structure to hold commands in */ -struct cmd_t { - char *cmd; - int (*func)(int, char **); - void (*usage)(); -}; - -extern struct cmd_t cmd_list[]; - -/* Maximum number of words in a command (command + command args) */ -#define MAX_COMMAND 50 - -/* - * Holds list of allocated buffers. To use a pre-allocated - * buffer, the index number needs to be passed in. This should - * probably be smarter--perhaps a hash table could store the - * list, with the hash being sent back to the user - */ -#define MAX_BUFFERS 50 -struct buf_t { - void *buf; - int len; -}; - -struct buf_t *buflist[MAX_BUFFERS]; - -int next; /* Next available buffer slot */ - - -/* Defaults for libsysio */ -char root_driver[75]; -char mntpath[250]; -unsigned int mntflgs; - - - -#define MAX_VARS 250 - -/* - * Valid types for fill buff and variables. - */ -#define UINT 0 -#define SINT 1 -#define STR 2 -#define PTR 3 -/* - * This defines a mapping from a variable name to - * some object known by the test harness. Variable - * names are distinguished by '$'. Variables are used - * in two possible ways: to capture the output of - * a function, as in $my_fd = open name, or to gain - * access to that variable, as in open $my_fd. Variables - * do not necessarily have to be initilized before use - */ -struct var_mapping { - char *name; /* Variable name */ - int obj; /* Object will always be an integer -- either a - file descriptor or an index into the buffer - array - */ - int type; -}; - -int last_type; - -struct var_mapping_list { - struct var_mapping map; - struct var_mapping_list *next; -}; - -/* - * Again, I am lazy and just use a static array - * This should be dynamically remappable - */ -struct var_mapping_list map[MAX_VARS]; -char output[4096]; -int pos; /* Pos in output string */ - -struct cmd_map { - char *cmd_name; - int cmd; - int num_args; -}; - -extern struct cmd_map fcntl_cmds[]; - -/* Return code information */ -#define SUCCESS 0x000 -#define INVALID_ARGS 0x001 -#define INVALID_CMD 0x002 -#define INVALID_VAR 0x004 - -int do_prompt; /* Prompt for interactive run? */ -int last_ret_val; /* Last return value returned by libsysio call */ -extern int errno; -int my_errno; /* Not sure what the difference will be */ - -/* Functions defined in test_driver.c */ -extern unsigned int dx_hack_hash (const char *name, int len); -extern int get_obj(char *var_name); -extern void *alloc_buff32(unsigned int size, int align); -extern void store_result(char *var_name, int result); -extern struct var_mapping *get_map(char *var_name); -extern void free_obj(char *obj_name); -extern void my_perror(char *msg); -extern char *get_str(char *var_name); - -/* Stub functions defined in sysio_stubs.c */ -extern int test_do_setdebug(int argc, char **argv); -extern int test_do_printline(int argc, char **argv); -extern int cmp_bufs(int argc, char **argv); -extern int test_do_printbuf(int argc, char **argv); -extern int test_do_fillbuff(int argc, char **argv); -extern int test_do_mount(int argc, char **args); -extern int test_do_list(int argc, char **args); -extern int test_do_init(int argc, char **args); -extern int get_endian(int argc, char **args); -extern int get_sizeof(int argc, char **args); -extern int do_setbuf(int argc, char **argv); -extern int test_do_exit(int argc, char **args); -extern int get_buffer(int argc, char **args); -extern int free_buffer(int argc, char **args); -extern int test_do_chdir(int argc, char **args); -extern int do_checkbuf(int argc, char **argv); -extern int test_do_chmod(int argc, char **args); -extern int test_do_chown(int argc, char **args); -extern int test_do_open(int argc, char **args); -extern int test_do_close(int argc, char **args); -extern int test_do_clear(int argc, char **argv); -extern int test_do_dup(int argc, char **args); -extern int test_do_dup2(int argc, char **args); -extern int test_do_fcntl(int argc, char **args); -extern int test_do_fstat(int argc, char **argv); -extern int test_do_fsync(int argc, char **argv); -extern int test_do_ftruncate(int argc, char **argv); -extern int test_do_getcwd(int argc, char **argv); -extern int test_do_init_iovec(int argc, char **argv); -extern int test_do_init_xtvec(int argc, char **argv); -extern int test_do_lseek(int argc, char **argv); -extern int test_do_lstat(int argc, char **argv); -extern int test_do_getdirentries(int argc, char **argv); -extern int test_do_mkdir(int argc, char **argv); -extern int test_do_creat(int argc, char **argv); -extern int test_do_stat(int argc, char **argv); -extern int test_do_statvfs(int argc, char **argv); -extern int test_do_fstatvfs(int argc, char **argv); -extern int test_do_truncate(int argc, char **argv); -extern int test_do_rmdir(int argc, char **argv); -extern int test_do_symlink(int argc, char **argv); -extern int test_do_unlink(int argc, char **argv); -extern int test_do_fdatasync(int argc, char **argv); -extern int test_do_ioctl(int argc, char **argv); -extern int test_do_umask(int argc, char **argv); -extern int test_do_iodone(int argc, char **argv); -extern int test_do_iowait(int argc, char **argv); -extern int test_do_ipreadv(int argc, char **argv); -extern int test_do_ipread(int argc, char **argv); -extern int test_do_preadv(int argc, char **argv); -extern int test_do_pread(int argc, char **argv); -extern int test_do_ireadv(int argc, char **argv); -extern int test_do_ireadx(int argc, char **argv); -extern int test_do_iread(int argc, char **argv); -extern int test_do_readv(int argc, char **argv); -extern int test_do_readx(int argc, char **argv); -extern int test_do_read(int argc, char **argv); -extern int test_do_ipwritev(int argc, char **argv); -extern int test_do_ipwrite(int argc, char **argv); -extern int test_do_pwritev(int argc, char **argv); -extern int test_do_pwrite(int argc, char **argv); -extern int test_do_iwritev(int argc, char **argv); -extern int test_do_iwrite(int argc, char **argv); -extern int test_do_iwritex(int argc, char **argv); -extern int test_do_writev(int argc, char **argv); -extern int test_do_writex(int argc, char **argv); -extern int test_do_write(int argc, char **argv); -extern int test_do_mknod(int argc, char **argv); -extern int test_do_umount(int argc, char **argv); - - -/* Functions defined in sysio_tests.c */ -extern int sysio_mount(char *from, char *to); -extern int sysio_list(char *path); -extern int initilize_sysio(void); -extern int sysio_chdir(char *newdir); -extern int sysio_chmod(char *mode_arg, const char *path); -extern int sysio_chown(char *new_id, char *file); -extern int sysio_open(char *path, int flags); -extern int sysio_open3(char *path, int flags, char *mode_arg); -extern int sysio_close(int fd); -extern int sysio_fcntl(int fd, struct cmd_map* cmdptr, char *arg); -extern int sysio_fstat(int fd, void *buf); -extern int sysio_lstat(char *filename, void *buf); -extern int sysio_getdirentries(int fd, char *buf, size_t nbytes, off_t *basep); -extern int sysio_mkdir(char *path, char *mode); -extern int sysio_creat(char *path, char *mode_arg); -extern int sysio_stat(char *filename, void *buf); -extern int sysio_statvfs(char *filename, void *buf); -extern int sysio_fstatvfs(int fd, void *buf); -extern int sysio_umask(char *mode_arg); -extern int sysio_mknod(char *path, char *mode_arg, dev_t dev); - -/* Usage functions defined in help.c */ -extern void do_help(); -extern void usage_setdebug(); -extern void usage_printline(); -extern void usage_endian(); -extern void usage_sizeof(); -extern void usage_get_buffer(); -extern void usage_free_buffer(); -extern void usage_do_printbuf(); -extern void usage_do_fillbuff(); -extern void usage_init(); -extern void usage_list(); -extern void usage_chdir(); -extern void usage_chmod(); -extern void usage_chown(); -extern void usage_open(); -extern void usage_close(); -extern void usage_clear(); -extern void usage_mount(); -extern void usage_dup(); -extern void usage_dup2(); -extern void usage_fcntl(); -extern void usage_fstat(); -extern void usage_fsync(); -extern void usage_ftruncate(); -extern void usage_getcwd(); -extern void usage_init_iovec(); -extern void usage_init_xtvec(); -extern void usage_lseek(); -extern void usage_lstat(); -extern void usage_getdirentries(); -extern void usage_mkdir(); -extern void usage_checkbuf(); -extern void usage_cmpbufs(); -extern void usage_creat(); -extern void usage_setbuf(); -extern void usage_stat(); -extern void usage_statvfs(); -extern void usage_fstatvfs(); -extern void usage_truncate(); -extern void usage_rmdir(); -extern void usage_symlink(); -extern void usage_unlink(); -extern void usage_fdatasync(); -extern void usage_ioctl(); -extern void usage_umask(); -extern void usage_iowait(); -extern void usage_iodone(); -extern void usage_ipreadv(); -extern void usage_ipread(); -extern void usage_preadv(); -extern void usage_pread(); -extern void usage_ireadv(); -extern void usage_iread(); -extern void usage_ireadx(); -extern void usage_readv(); -extern void usage_readx(); -extern void usage_read(); -extern void usage_ipwritev(); -extern void usage_ipwrite(); -extern void usage_pwritev(); -extern void usage_pwrite(); -extern void usage_iwritev(); -extern void usage_iwrite(); -extern void usage_iwritex(); -extern void usage_writev(); -extern void usage_write(); -extern void usage_writex(); -extern void usage_mknod(); -extern void usage_umount(); -extern void usage_exit(); diff --git a/libsysio/tests/test_getcwd.c b/libsysio/tests/test_getcwd.c deleted file mode 100644 index 8cd160d..0000000 --- a/libsysio/tests/test_getcwd.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "mount.h" - -#include "test.h" - -/* - * Test getcwd() - * - * Usage: test_cwd [...] - * - * Without any path arguments, the program reads from standard-in, dealing with - * each line as an absolute or relative path until EOF. - */ - -static int doit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )doit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - doit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -doit(const char *path) -{ - char *buf; - - if (chdir(path) != 0) { - perror(path); - return -1; - } - buf = getcwd(NULL, 0); - if (!buf) { - perror(path); - return -1; - } - (void )printf("%s\n", buf); - free(buf); - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_getcwd " - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/test_getcwd.pl b/libsysio/tests/test_getcwd.pl deleted file mode 100755 index 4255a32..0000000 --- a/libsysio/tests/test_getcwd.pl +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/perl -w - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; -use Fcntl; - - -sub usage -{ - print "Usage: ./test_getcwd.pl [-alpha] : Test getcwd by verifying that it \n"; - print " : setting the directory to dir and \n"; - print " : verifying that getcwd reflects \n"; - print " : the change\n"; - exit(-1); -} - -sub check_wkdir -{ - my ($wdir, $outfh, $cmdfh) = @_; - - - # Get cwd from libsysio - my $cmdstr = 'CALL getcwd ( $buf = ALLOC 512 ) 512'."\n"; - helper::send_cmd($cmdfh, $outfh, "getcwd", $cmdstr); - - # Verify the system call's output - helper::verify_cmd($cmdfh, $outfh, "getcwd"); - - # Print out the buffer - $cmdstr = 'PRINT $buf 0 1 STR'."\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - my $iodir = <$outfh>; - chop($iodir); - - # Only compare the last portion of the working directory - my @iodirs = split(/\//, $iodir); - my @wdirs = split(/\//, $wdir); - - if ($iodirs[-1] ne $wdirs[-1]) { - helper::print_and_exit - ($cmdfh, - $outfh, 0, - "ERROR! topmost wdir ($wdirs[-1]) does not match sysio's ($iodirs[-1])\n"); - } -} - -sub process_cmd -{ - my ($dir, $is_alpha) = @_; - - # Get tests directory - my $testdir = $FindBin::Bin; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -batch -quiet -sz 1 $testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - - # Get current working directory from environment - my $cwd = $ENV{PWD}; - - - } - - # Now change to dir - helper::send_cmd($cmdfh, $outfh, "chdir", "CALL chdir $dir\n"); - - # Verify the system call's output - helper::verify_cmd($cmdfh, $outfh, "PRINT"); - - check_wkdir($dir, $outfh, $cmdfh); - - # Clean up - helper::print_and_exit($cmdfh, $outfh, 0, "getcwd test successful\n"); -} - - -my $currarg = 0; -my $is_alpha = 0; - -if (@ARGV < 1) { - usage; -} elsif (@ARGV > 1) { - if ($ARGV[$currarg++] eq "-alpha") { - $is_alpha = 1; - } -} - -my $dir = $ARGV[$currarg]; - -process_cmd($dir, $is_alpha); - -exit 0; - - - - diff --git a/libsysio/tests/test_link.c b/libsysio/tests/test_link.c deleted file mode 100644 index 218dd49..0000000 --- a/libsysio/tests/test_link.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#include -#include - -#include "xtio.h" -#include "test.h" - -/* - * Test hard link - * - * Usage: link oldpath newpath - * - */ - -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - if (n < 2) usage(); - - /* - * Try paths listed on command-line. - */ - while (optind < argc) { - const char *old, *new; - struct stat stbuf; - - old = argv[optind++]; - new = argv[optind++]; - if ((err = link(old, new)) != 0) { - perror("link"); - break; - } - if ((err = lstat(new, &stbuf)) != 0) { - perror(new); - break; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return err ? -1 : 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: unlink" - " oldpath newpath\n"); - - exit(1); -} diff --git a/libsysio/tests/test_list.c b/libsysio/tests/test_list.c deleted file mode 100644 index 292bb54..0000000 --- a/libsysio/tests/test_list.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "test.h" - -/* - * Stat files. - * - * Usage: test_list [path...] - * - * Without any path arguments, the program reads from standard-in, dealing with - * each line as an absolute or relative path until EOF. - */ - -static int listit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )listit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - listit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -listit(const char *path) -{ - int fd; - size_t n; - struct dirent *buf, *dp; - off_t base; - ssize_t cc; - - fd = open(path, O_RDONLY); - if (fd < 0) { - perror(path); - return -1; - } - - n = 16 * 1024; - buf = malloc(n); - if (!buf) { - perror(path); - cc = -1; - goto out; - } - - base = 0; - while ((cc = getdirentries(fd, (char *)buf, n, &base)) > 0) { - dp = buf; - while (cc > 0) { - (void )printf("\t%s: ino %llu type %u\n", - dp->d_name, - (unsigned long long )dp->d_ino, - (int )dp->d_type); - cc -= dp->d_reclen; - dp = (struct dirent *)((char *)dp + dp->d_reclen); - } - if (!base) - break; - } - -out: - if (cc < 0) - perror(path); - - free(buf); - { - int oerrno = errno; - - if (close(fd) != 0) { - perror(path); - if (cc < 0) - errno = oerrno; - else - cc = -1; - } - } - - return (int )cc; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: list_path" - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/test_list.pl b/libsysio/tests/test_list.pl deleted file mode 100755 index 5be13d2..0000000 --- a/libsysio/tests/test_list.pl +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/perl -w - -# -# getdirentries test: Tests the equivalent of a ls. Note that this is not -# the most robust test in the world; it simply verifies -# that libsysio returns all the entries in the directory -# -# - -use IPC::Open2; - -use strict; - -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage: ./test_list.pl [-p|-alpha] \n"; - print " ./test_list.pl -m [-p|-alpha] fstype:mdir dir\n"; - print " In the first form, will attempt to verify libsysio's\n"; - print " getdirentries. If no dir is given, will use the \n"; - print " current working directory\n"; - print " In the second form, will mount the given mdir (of type fstype) in dir.\n"; - print " It will then verify the output of libsysio's getdirentries. It will \n"; - print " then umount the directory and verify that the umount worked\n"; - print " The -p option will print the directory listing\n"; - print " The -alpha option is for alpha architecture \n"; - exit(-1); -} - - -sub write_print -{ - my ($offset, $outfh, $cmdfh, $do_print, $is_alpha) = @_; - my $bytes = 0; - - my $intsize = 8; - my $intcmd = "INT"; - if ($is_alpha == 1) { - $intsize = 16; - $intcmd = "LONG" - } - my $shortoffset = $offset+$intsize; - my $charoffset = $shortoffset+2; - my $stroffset = $charoffset+1; - my $cmdstr = 'PRINT $buf '. - "$offset $intsize $intcmd $shortoffset 2 SHORT $charoffset 1 CHAR $stroffset 1 STR\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - my $res = <$outfh>; - chop($res); - my ($inode, $foffset, $size, $type, @names) = split(' ',$res); - $size = oct($size); - if ($size == 0) { - return -1; - } - my $name = join(' ', @names); - - if ($do_print == 1) { - printf(STDOUT "%-35s %-14s %-14s %-6s %-4s\n", $name, $inode, $foffset, $size, $type); - } - - return $size; -} - -sub do_print_cmds -{ - my ($numbytes, $outfh, $cmdfh, $start, $do_print, $is_alpha) = @_; - - my $offset = 0; - my $bytes = 0; - my $numfiles = 0; - my $i = $start; - - if ($numbytes == 0) { - $numbytes = 8192; - } - while ($bytes < $numbytes) { - my $len = write_print($offset, $outfh, $cmdfh, $do_print, $is_alpha); - if ($len <= 0) { - # write_print saw a 0 length record, indicating end of dir - return $numfiles; - } - $numfiles++; - if ($is_alpha == 0) { - $len += $len%4; - } else { - $len += $len%8; - } - $offset += $len; - $bytes += $len; - $i++; - } - return $numfiles; -} - -sub print_dir_cmd -{ - - my ($outfh, $cmdfh, $start, $mdir, $do_print, $is_alpha) = @_; - - my $cmdstr = "CALL getdirentries ( ".'$fd = CALL open '."$mdir O_RDONLY ) ( "; - $cmdstr .= '$buf = ALLOC 8192 ) 8192 $basep'."\n"; - helper::send_cmd($cmdfh, $outfh, "getdirentries", $cmdstr); - - # Verify that the sysio call succeeded - my $res = helper::verify_cmd($cmdfh, $outfh, "getdirentries"); - my $numbytes = oct($res); - - while ($numbytes > 0) { - - do_print_cmds($numbytes, $outfh, $cmdfh, $start, $do_print, $is_alpha); - - $cmdstr = "CALL getdirentries ".'$fd $buf 8192 $basep'."\n"; - helper::send_cmd($cmdfh, $outfh, "getdirentries", $cmdstr); - - # Verify that the sysio call succeeded - my $res = helper::verify_cmd($cmdfh, $outfh, "getdirentries"); - $numbytes = oct($res); - } -} - -sub process_cmd -{ - my ($mdir, $tdir, $do_mount, $is_alpha, $do_print) = @_; - my $size = 8192; - my $done_files = 0; - - # Get tests directory - my $testdir = $FindBin::Bin; - - eval { - if ($is_alpha == 1) { - open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 $testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - my $start = 0; - - if ($do_mount == 1) { - helper::send_cmd($cmdfh, $outfh, "mount", "CALL mount $mdir $tdir\n"); - print_dir_cmd($outfh, $cmdfh, $start, $tdir, $do_print, $is_alpha); - } else { - print_dir_cmd($outfh, $cmdfh, $start, $mdir, $do_print, $is_alpha); - } - - # Attempt to unmount and verify the contents - if ($do_mount == 1) { - - # Close the dir before we umount - my $cmdstr = 'CALL close $fd'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - - # umount dir - helper::send_cmd($cmdfh, $outfh, "umount", "CALL umount $tdir\n"); - - - # Verify it is umounted - $cmdstr = "CALL getdirentries ( ".'$fd2 = CALL open '."$tdir O_RDONLY ) "; - $cmdstr .= '$buf 8192 $newp'."\n"; - helper::send_cmd($cmdfh, $outfh, "getdirentries", $cmdstr); - my $res = helper::verify_cmd($cmdfh, $outfh, "getdirentries"); - - my $numbytes = oct($res); - # The only entries should be . and .., so should return 32 - if ($numbytes != 32) { - helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Read in $numbytes bytes\n"); - } - # Clean up - $cmdstr = 'CALL close $fd2'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - - } else { - my $cmdstr = 'CALL close $fd'."\n"; - helper::send_cmd($cmdfh, $outfh, "getdirentries", $cmdstr); - } - - helper::print_and_exit($cmdfh, $outfh, 0, "list test successful\n"); -} - - -# Default dir is cwd -my @mydir; -$mydir[0] = "./"; -my $do_mount = 0; -my $is_alpha = 0; -my $do_print = 0; -my $dircnt = 0; -for (my $i = 0; $i < @ARGV; $i++) -{ - if ($ARGV[$i] eq "-p") { - $do_print = 1; - } elsif ($ARGV[$i] eq "-m") { - $do_mount = 1; - } elsif ($ARGV[$i] eq "-alpha") { - $is_alpha = 1; - } else { - $mydir[$dircnt] = $ARGV[$i]; - $dircnt++; - } -} - -if ( ($dircnt == 0) || ($dircnt > 2) || - (($do_mount==1) && ($dircnt < 2)) || - (($do_mount == 0) && ($dircnt > 1)) ) { - usage(); -} - -my $dir = $mydir[0]; -if ($do_mount == 1) { - my $fstype; - ($fstype, $dir) = split(/:/, $mydir[0]); -} - -process_cmd($mydir[0], $mydir[1], $do_mount, $is_alpha, $do_print); - -exit 0; diff --git a/libsysio/tests/test_path.c b/libsysio/tests/test_path.c deleted file mode 100644 index 80cc74e..0000000 --- a/libsysio/tests/test_path.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "test.h" - -/* - * Stat files. - * - * Usage: test_path [path...] - * - * Without any path arguments, the program reads from standard-in, dealing with - * each line as an absolute or relative path until EOF. - */ - -static int statit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )statit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - statit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -statit(const char *path) -{ - int err; - struct stat stbuf; - char t; - static char buf[4096]; - ssize_t cc; - - /* - * Get file attrs. - */ - err = lstat(path, &stbuf); - if (err) { - perror(path); - return -1; - } - - /* - * Get readable representation of file type. - */ - if (S_ISDIR(stbuf.st_mode)) - t = 'd'; - else if (S_ISCHR(stbuf.st_mode)) - t = 'c'; - else if (S_ISBLK(stbuf.st_mode)) - t = 'b'; - else if (S_ISREG(stbuf.st_mode)) - t = 'f'; -#ifdef S_ISFIFO - else if (S_ISFIFO(stbuf.st_mode)) - t = 'p'; -#endif -#ifdef S_ISLNK - else if (S_ISLNK(stbuf.st_mode)) - t = 'S'; -#endif -#ifdef S_ISSOCK - else if (S_ISSOCK(stbuf.st_mode)) - t = 's'; -#endif -#ifdef S_TYPEISMQ - else if (S_TYPEISMQ(&stbuf)) - t = 'q'; -#endif -#ifdef S_TYPEISSEM - else if (S_TYPEISSEM(&stbuf)) - t = 'M'; -#endif -#ifdef S_TYPEISSHM - else if (S_TYPEISSHM(&stbuf)) - t = 'm'; -#endif - else - t = '?'; - - /* - * Print path and type. - */ - if (S_ISLNK(stbuf.st_mode)) { - cc = readlink(path, buf, sizeof(buf)); - if (cc < 0) { - perror(path); - return -1; - } - } - (void )printf("%s: %c", path, t); - if (S_ISLNK(stbuf.st_mode) && (size_t )cc < sizeof(buf)) - (void )printf(" %.*s", cc, buf); - (void )putchar('\n'); - - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_path" - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/test_path.pl b/libsysio/tests/test_path.pl deleted file mode 100755 index 67bdf73..0000000 --- a/libsysio/tests/test_path.pl +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/perl -w - -# -# path test: reads paths from stdin and prints out the path along with its -# : type -# - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; -use POSIX; -use Fcntl; - -sub usage -{ - print "Usage ./test_path.pl [path1 path2...] : Print each path listed and its type\n"; - print " : If no paths are given, stdin is read\n"; - exit(-1); -} - -sub get_type -{ - my $mode = $_[0]; - my $t = '?'; - - if (S_ISDIR($mode)) { - $t = 'd'; - } elsif (S_ISCHR($mode)) { - $t = 'c'; - } elsif (S_ISBLK($mode)) { - $t = 'b'; - } elsif (S_ISREG($mode)) { - $t = 'f'; - } elsif (S_ISFIFO($mode)) { - $t = 'p'; - } elsif (S_ISLNK($mode)) { - $t = 'S'; - } elsif (S_ISSOCK($mode)) { - $t = 's'; - } - - return $t; -} - -sub print_path -{ - my ($mode, $path) = @_; - - my $typechar = get_type($mode); - print STDOUT "$path: $typechar\n"; -} - -sub process_path -{ - my ($cmdfh, $outfh, $bits, $path) = @_; - - # Issue the stat command - my $cmdstr = 'CALL stat "'; - $cmdstr = sprintf("%s%s%s\n", $cmdstr, $path, '" $buf'); - - helper::send_cmd($cmdfh, $outfh, "stat", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "stat"); - - # Print out the stat buffer - if ($bits == 32) { - $cmdstr = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 52 8 INT 64 24 LONG'; - } else { - $cmdstr = 'PRINT $buf 0 24 LONG 24 16 INT 48 32 LONG 88 8 LONG 104 8 LONG'; - } - $cmdstr .= "\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - my $res = <$outfh>; - chop($res); - my ( $iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, - $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime ) - = split(' ', $res); - if ($bits == 64) { - ( $iodev, $ioino, $ionlink, $iomode, $iouid, $iogid, $iordev, - $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime ) - = split(' ', $res); - } - $iomode = oct($iomode); - - # Print out the path - print_path($iomode, $path); -} - -sub process_cmd -{ - my ($usestdin, $isalpha, @paths) = @_; - - my $path; - - # Get tests directory - my $testdir = $FindBin::Bin; - - eval { - if ($isalpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -batch -quiet -sz 1 $testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($isalpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - # Allocate the stat buffer - my $cmdstr = '$buf = ALLOC ( $size = CALL sizeof stat )'; - $cmdstr .= "\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - # Attempt to determine type - $cmdstr = 'PRINT $size'."\n"; - helper::send_cmd($cmdfh, $outfh, "print", $cmdstr); - my $statsize = <$outfh>; - chop($statsize); - $statsize = oct($statsize); - my $bits = 32; - if ($statsize == 144) { - $bits = 64; - } - - my $i=0; - if ($usestdin) { - $path = ; - if (defined($path)) { - chop($path); - } - } else { - $path = $paths[$i++]; - } - - # Enter a loop, reading a path argument and processing it with each - # phase of loop. - while (defined($path)) { - - process_path($cmdfh, $outfh, $bits, $path); - if ($usestdin) { - $path = ; - - if (defined($path)) { - chop($path); - } - if ($path eq "quit") { - helper::print_and_exit($cmdfh, $outfh, 0, "path test successful\n"); - } - } else { - $path = $paths[$i++]; - } - } - helper::print_and_exit($cmdfh, $outfh, 0, "path test successful\n"); -} - - -my $usestdin = 0; -my $isalpha = 0; - -# The -alpha arg must be before the paths -# (if they exist) -if ( (@ARGV > 0) && ($ARGV[0] eq "-alpha")) { - $isalpha = 1; - shift(@ARGV); -} - -if (@ARGV == 0) { - $usestdin = 1; -} - -process_cmd($usestdin, $isalpha, @ARGV); - diff --git a/libsysio/tests/test_regions.c b/libsysio/tests/test_regions.c deleted file mode 100644 index ba78800a..0000000 --- a/libsysio/tests/test_regions.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is regionsrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a regions of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#define _BSD_SOURCE - -#if (_LARGEFILE64_SOURCE && \ - ((defined(__STDC_VERSION__) && __STDC_VERSION__ == 199901L))) -#define GO64 -#else -#warning Cannot prompt the 64-bit interface -#endif - -#if defined(GO64) && defined(__GLIBC__) -#define _ISOC99_SOURCE 1 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "test.h" - -/* - * Copy one file to another. - * - * Usage: test_regions [-x] \ - * {r,w} - * - * Destination will not be overwritten if it already exist. - */ - -#if (_LARGEFILE64_SOURCE && \ - ((defined(__STDC_VERSION__) && __STDC_VERSION__ == 199901L) || \ - (defined(_ISOC99_SOURCE) && _ISOC99_SOURCE))) -#define GO64 -#else -#warning Cannot prompt the 64-bit interface -#endif - -char which; -#ifdef GO64 -int use64 = 0; /* 64-bit interface? */ -#endif - -void usage(void); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - long l; - off_t off; -#ifdef GO64 - long long ll; - off64_t off64; -#endif - char *cp; - unsigned long nbytes; - const char *path; - char *buf; - int flags; - int fd; - ssize_t cc; - extern int _test_sysio_startup(void); - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, - argv, -#ifdef __GLIBC__ - "+" -#endif -#ifdef GO64 - "x" -#endif - "")) != -1) - switch (i) { - -#ifdef GO64 - case 'x': - use64 = 1; - break; -#endif - default: - usage(); - } - - if (argc - optind != 4) - usage(); - - which = *argv[optind]; - if (strlen(argv[optind]) != 1 || !(which == 'r' || which == 'w')) { - (void )fprintf(stderr, "Which op?\n"); - exit(1); - } - optind++; - off = l = -#ifdef GO64 - ll = strtoll(argv[optind++], &cp, 0); -#else - strtol(argv[optind++], &cp, 0); -#endif -#ifdef GO64 - off64 = ll; -#endif - if (*cp != '\0' || -#ifdef GO64 - ((ll == LLONG_MIN || ll == LLONG_MAX) && errno == ERANGE) || - off64 != ll || (!use64 && off != ll) -#else - ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || - off != l -#endif - ) { - (void )fprintf(stderr, "Offset out of range\n"); - exit(1); - } - nbytes = strtoul(argv[optind++], &cp, 0); - if (*cp != '\0' || (nbytes == ULONG_MAX && errno == ERANGE)) { - (void )fprintf(stderr, "Transfer count out of range\n"); - exit(1); - } - if (!(argc - optind)) - usage(); - path = argv[optind++]; - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - (void )umask(022); - - buf = malloc(nbytes); - if (!buf) { - perror("malloc"); - err = 1; - goto out; - } - (void )memset(buf, 0, nbytes); - - err = 0; - flags = which == 'r' ? O_RDONLY : (O_WRONLY|O_CREAT|O_EXCL); -#ifdef GO64 - if (use64) - flags |= O_LARGEFILE; -#endif - fd = open(path, flags, 0666); - if (fd < 0) { - perror(path); - err = 1; - goto error; - } -#ifdef GO64 - if (use64) - off64 = lseek64(fd, off64, SEEK_SET); - else - off64 = -#endif - off = lseek(fd, off, SEEK_SET); -#ifdef GO64 - if ((use64 && off64 < 0) || (!use64 && off < 0)) { - perror(use64 ? "lseek64" : "lseek"); - err = 1; - goto error; - } -#else - if (off < 0) { - perror("lseek"); - err = 1; - goto error; - } -#endif - if (which == 'r') - cc = read(fd, buf, nbytes); - else - cc = write(fd, buf, nbytes); - if (cc < 0) { - perror(path); - err = 1; - goto error; - } -#ifdef GO64 - if (use64) { - off64 = lseek64(fd, 0, SEEK_CUR); - } else - off64 = -#endif - off = lseek(fd, 0, SEEK_CUR); - (void )printf(("%s%s@" -#ifdef GO64 - "%lld" -#else - "%ld" -#endif - ": %ld, off " -#ifdef GO64 - "%lld" -#else - "%ld" -#endif - "\n"), - which == 'r' ? "read" : "write", -#ifdef GO64 - use64 ? "64" : "", - ll, -#else - "", - l, -#endif - (long )cc, -#ifdef GO64 - (long long int)off64 -#else - off -#endif - ); - -error: - if (fd > 0 && close(fd) != 0) - perror(path); - free(buf); -out: - _test_sysio_shutdown(); - - return err; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_regions " -#ifdef GO64 - "[-x] " -#endif - " {r,w} \n"); - exit(1); -} diff --git a/libsysio/tests/test_rename.c b/libsysio/tests/test_rename.c deleted file mode 100644 index 8bc2ec82..0000000 --- a/libsysio/tests/test_rename.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xtio.h" -#include "test.h" - -/* - * Rename a file system object. - * - * Usage: test_rename - */ - -void usage(void); -int rename_file(const char *spath, const char *dpath); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - const char *spath, *dpath; - extern int _test_sysio_startup(void); - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, - argv, - "" - )) != -1) - switch (i) { - - default: - usage(); - } - - if (!(argc - optind)) - usage(); - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - (void )umask(022); - - /* - * Source - */ - spath = argv[optind++]; - if (!(argc - optind)) - usage(); - /* - * Destination - */ - dpath = argv[optind++]; - if (argc - optind) - usage(); - - err = rename(spath, dpath); - if (err) - perror("rename"); - - _test_sysio_shutdown(); - - return err; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_rename" - " source destination\n"); - exit(1); -} diff --git a/libsysio/tests/test_rw.pl b/libsysio/tests/test_rw.pl deleted file mode 100755 index 74a7fa0..0000000 --- a/libsysio/tests/test_rw.pl +++ /dev/null @@ -1,537 +0,0 @@ -#!/usr/bin/perl -w - -# -# rw test: Write a buffer out using all the different writes, read it back -# and make sure it matches -# -# - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage: ./test_rw.pl [-alpha] : Write to/read from file\n"; - exit(-1); -} - -sub verify_result -{ - my ($cmdfh, $outfh, $cmdstr, $exp_val, $eq_op) = @_; - my $print_err = 0; - - my $res = helper::verify_cmd($cmdfh, $outfh, $cmdstr); - $res = oct($res); - - if ($eq_op eq "!=") { - if ($res != $exp_val) { - print STDOUT "Error! $cmdstr returned $res insted of $exp_val\n"; - exit 1; - } - } else { - if ($eq_op eq ">") { - if ($res > $exp_val) { - $print_err = 1; - } - } elsif ($eq_op eq "<") { - if ($res < $exp_val) { - $print_err = 1; - } - } elsif ($eq_op eq "==") { - if ($res == $exp_val) { - $print_err = 1; - } - } - if ($print_err == 1) { - helper::print_and_exit($cmdfh, $outfh, 1, "Error! $cmdstr returned $res\n"); - } - } -} - -sub do_iowait -{ - my ($cmdfh, $outfh, $id, $rwcmd, $exp_size) = @_; - - my $cmdstr = "CALL iowait $id\n"; - helper::send_cmd($cmdfh, $outfh, "iowait", $cmdstr); - - my $descstr = "iowait:$rwcmd"; - verify_result($cmdfh, $outfh, $descstr, $exp_size, "!="); -} - -sub set_iovecs -{ - my ($cmdfh, $outfh, $callnum) = @_; - my $NUMVECS = 8; - my $VECLEN = $NUMVECS * 1024; - - my $varname = "iovbuf$callnum"; - - # Get size of iovecs - my $cmdstr = '$iovsize = CALL sizeof iovec'."\n"; - helper::send_cmd($cmdfh, $outfh, "sizeof", $cmdstr); - my $size = helper::verify_cmd($cmdfh, $outfh, "sizeof iovec"); - $size = oct($size); - $size = $size * $NUMVECS; - - # Allocate iovec buffer - $cmdstr = '$'."$varname = ALLOC $size\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - - # Now initilize all of them - my $off = 0; - for (my $i=0; $i < $NUMVECS; $i++) { - $cmdstr = 'CALL init_iovec $buf '."$off $VECLEN $i ". '$'."$varname\n"; - helper::send_cmd($cmdfh, $outfh, "init_iovec", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "init_iovec"); - $off += $VECLEN; - } - - return $varname; -} - - -sub set_xtvecs -{ - my ($cmdfh, $outfh, $callnum, $startoff) = @_; - my $VECLEN = 4 * 8 * 1024; - - my $varname = "xtvbuf$callnum"; - - # Get size of iovecs - my $cmdstr = '$xtvsize = CALL sizeof xtvec'."\n"; - helper::send_cmd($cmdfh, $outfh, "sizeof", $cmdstr); - my $size = helper::verify_cmd($cmdfh, $outfh, "sizeof xtvec"); - $size = oct($size); - $size = $size * 2; - - # Allocate iovec buffer - $cmdstr = '$'."$varname = ALLOC $size\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - - # Now initilize all of them - my $off = $startoff; - for (my $i=0; $i < 2; $i++) { - $cmdstr = "CALL init_xtvec $off $VECLEN $i ". '$'."$varname\n"; - helper::send_cmd($cmdfh, $outfh, "init_xtvec", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "init_xtvec"); - $off += $VECLEN; - } - - return $varname; -} - -sub check_buf -{ - - my ($cmdfh, $outfh, $bufsize, $readcmd) = @_; - my $i; - my $digit = 0; - my $offset = 0; - my $cmdstr; - - for ($i =0; $i < 64; $i++) { - $cmdstr = 'CALL checkbuf $buf'. " 1024 $digit $offset\n"; - helper::send_cmd($cmdfh, $outfh, "checkbuf", $cmdstr); - my $res = helper::verify_cmd($cmdfh, $outfh, "checkbuf"); - $res = oct($res); - - if ($res != 0) { - print STDOUT "Checkbuf returned $res\n"; - helper::print_and_exit($cmdfh, $outfh, 1, "$readcmd did not return all $digit 's\n"); - } - - $offset += 1024; - $digit++; - if ($digit == 10) { - $digit = 0; - } - } - - # Now fill the buffer with 0s - $cmdstr = '$buf = CALL setbuf 0 '."$bufsize ".'$buf'." 0\n"; - helper::send_cmd($cmdfh, $outfh, "setbuf", $cmdstr); - -} - -sub fill_buf -{ - my ($cmdfh, $outfh) = @_; - my $i; - my $digit=0; - my $cmdstr; - my $offset = 0; - - # Fill up the buffer with alternating digits - # from 0-9 - - for ($i=0; $i < 64 ; $i++) { - my $cmdstr = "CALL setbuf $digit 1024 ".'$buf'." $offset\n"; - helper::send_cmd($cmdfh, $outfh, "setbuf", $cmdstr); - $offset += 1024; - $digit++; - if ($digit == 10) { - $digit = 0; - } - } -} - -sub do_rwcalls -{ - my ($cmdfh, $outfh, $bufsize) = @_; - my $IOID_FAIL = 0; - my $NUMVECS = 8; - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # write 64K bytes at pos 0 - my $cmdstr = 'CALL write $fd $buf '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "write", $cmdstr); - verify_result($cmdfh, $outfh, "write", $bufsize, "!="); - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # iwrite 64K bytes at pos 64K - $cmdstr = '$id1 = CALL iwrite $fd $buf '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "iwrite", $cmdstr); - verify_result($cmdfh, $outfh, "iwrite", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id1', "iwrite", $bufsize); - - # Set up the iovecs - my $iovcnt = 0; - my $iovname = set_iovecs($cmdfh, $outfh, $iovcnt); - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # writev 64K bytes using 8 iovecs at pos 128K - $cmdstr = 'CALL writev $fd $'."$iovname $NUMVECS\n"; - helper::send_cmd($cmdfh, $outfh, "writev", $cmdstr); - verify_result($cmdfh, $outfh, "writev", $bufsize, "!="); - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # iwritev 64K bytes using 8 iovecs at pos 192K - $cmdstr = '$id2 = CALL iwritev $fd $'."$iovname $NUMVECS\n"; - helper::send_cmd($cmdfh, $outfh, "iwritev", $cmdstr); - verify_result($cmdfh, $outfh, "iwritev", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id2', "iwritev", $bufsize); - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # pwrite 64K bytes starting at pos 256K - my $offset = 256 * 1024; - $cmdstr = 'CALL pwrite $fd $buf '."$bufsize $offset\n"; - helper::send_cmd($cmdfh, $outfh, "pwrite", $cmdstr); - verify_result($cmdfh, $outfh, "pwrite", $bufsize, "!="); - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # ipwrite 64K bytes starting at pos 320K - $offset = 320 * 1024; - $cmdstr = '$id3 = CALL ipwrite $fd $buf '."$bufsize $offset\n"; - helper::send_cmd($cmdfh, $outfh, "ipwrite", $cmdstr); - verify_result($cmdfh, $outfh, "ipwrite", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id3', "ipwrite", $bufsize); - - $iovcnt++; - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # pwritev using 8 8K buffers at offset 384 - $offset = 384 * 1024; - $cmdstr = 'CALL pwritev $fd $'."$iovname $NUMVECS $offset\n"; - helper::send_cmd($cmdfh, $outfh, "pwritev", $cmdstr); - verify_result($cmdfh, $outfh, "pwritev", $bufsize, "!="); - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # ipwritev using 8 8k buffers at offset 448 - $offset = 448 * 1024; - $cmdstr = '$id4 = CALL ipwritev $fd $'."$iovname $NUMVECS $offset\n"; - helper::send_cmd($cmdfh, $outfh, "ipwritev", $cmdstr); - verify_result($cmdfh, $outfh, "ipwritev", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id4', "ipwritev", $bufsize); - - # Set up the xtvecs. Starting offset is 512K - my $xtvcnt = 0; - my $xtvname = set_xtvecs($cmdfh, $outfh, $xtvcnt, 512 * 1024); - - $iovcnt++; - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - # Call writex using 8 8k buffers at offset 512 - $cmdstr = 'CALL writex $fd $'."$iovname $NUMVECS ".'$'."$xtvname 2\n"; - helper::send_cmd($cmdfh, $outfh, "writex", $cmdstr); - verify_result($cmdfh, $outfh, "writex", $bufsize, "!="); - - # Call iwritex using 8 8k buffers starting at offset 576 - # Re-setup xtvs since I am lazy. This is leaking memory like - # a seive... - $xtvcnt++; - $xtvname = set_xtvecs($cmdfh, $outfh, $xtvcnt, 576 * 1024); - - $iovcnt++; - - # Initilize buffer - fill_buf($cmdfh, $outfh); - - $cmdstr = '$id5 = CALL iwritex $fd $'."$iovname $NUMVECS ".'$'."$xtvname 2\n"; - helper::send_cmd($cmdfh, $outfh, "iwritex", $cmdstr); - verify_result($cmdfh, $outfh, "iwritex", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id5', "iwritex", $bufsize); - - # Now do the reads - - # Lseek back to pos 0 - $cmdstr = 'CALL lseek $fd 0 SEEK_SET'."\n"; - helper::send_cmd($cmdfh, $outfh, "sizeof", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "sizeof xtvec"); - - # fill the buffer with 0's - $cmdstr = '$buf = CALL setbuf 0 '."$bufsize ".'$buf'." 0\n"; - helper::send_cmd($cmdfh, $outfh, "setbuf", $cmdstr); - - # read 64K bytes from pos 0 - $cmdstr = 'CALL read $fd $buf '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "read", $cmdstr); - verify_result($cmdfh, $outfh, "read", $bufsize, "!="); - - # Check the buffer to make sure it matches - check_buf($cmdfh, $outfh, $bufsize, "read"); - - # iread 64K bytes at pos 64K - $cmdstr = '$id6 = CALL iread $fd $buf '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "iread", $cmdstr); - verify_result($cmdfh, $outfh, "iread", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id6', "iread", $bufsize); - check_buf($cmdfh, $outfh, $bufsize, "iread"); - - $iovcnt++; - - # readv 64K bytes using 8 iovecs at pos 128K - $cmdstr = 'CALL readv $fd $'."$iovname $NUMVECS\n"; - helper::send_cmd($cmdfh, $outfh, "readv", $cmdstr); - verify_result($cmdfh, $outfh, "readv", $bufsize, "!="); - check_buf($cmdfh, $outfh, $bufsize, "readv"); - - # ireadv 64K bytes using 8 iovecs at pos 192K - $cmdstr = '$id7 = CALL ireadv $fd $'."$iovname $NUMVECS\n"; - helper::send_cmd($cmdfh, $outfh, "ireadv", $cmdstr); - verify_result($cmdfh, $outfh, "ireadv", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id7', "ireadv", $bufsize); - check_buf($cmdfh, $outfh, $bufsize, "ireadv"); - - # pread64K bytes starting at pos 256K - $offset = 256 * 1024; - $cmdstr = 'CALL pread $fd $buf '."$bufsize $offset\n"; - helper::send_cmd($cmdfh, $outfh, "pread", $cmdstr); - verify_result($cmdfh, $outfh, "pread", $bufsize, "!="); - check_buf($cmdfh, $outfh, $bufsize, "pread"); - - # ipread 64K bytes starting at pos 320K - $offset = 320 * 1024; - $cmdstr = '$id8 = CALL ipread $fd $buf '."$bufsize $offset\n"; - helper::send_cmd($cmdfh, $outfh, "ipread", $cmdstr); - verify_result($cmdfh, $outfh, "ipread", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id8', "ipread", $bufsize); - check_buf($cmdfh, $outfh, $bufsize, "ipread"); - - - $iovcnt++; - - # preadv using 8 8K buffers at offset 384 - $offset = 384 * 1024; - $cmdstr = 'CALL preadv $fd $'."$iovname $NUMVECS $offset\n"; - helper::send_cmd($cmdfh, $outfh, "preadv", $cmdstr); - verify_result($cmdfh, $outfh, "preadv", $bufsize, "!="); - check_buf($cmdfh, $outfh, $bufsize, "preadv"); - - # ipreadv using 8 8k buffers at offset 448 - $offset = 448 * 1024; - $cmdstr = '$id9 = CALL ipreadv $fd $'."$iovname $NUMVECS $offset\n"; - helper::send_cmd($cmdfh, $outfh, "ipreadv", $cmdstr); - verify_result($cmdfh, $outfh, "ipreadv", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id9', "ipreadv", $bufsize); - check_buf($cmdfh, $outfh, $bufsize, "ipreadv"); - - # Set up the xtvecs. Starting offset is 512K - $xtvcnt++; - $xtvname = set_xtvecs($cmdfh, $outfh, $xtvcnt, 512 * 1024); - - $iovcnt++; - - # Call readx using 8 8k buffers at offset 512 - $cmdstr = 'CALL readx $fd $'."$iovname $NUMVECS ".'$'."$xtvname 2\n"; - helper::send_cmd($cmdfh, $outfh, "readx", $cmdstr); - verify_result($cmdfh, $outfh, "readx", $bufsize, "!="); - check_buf($cmdfh, $outfh, $bufsize, "readx"); - - # Call ireadx using 8 8k buffers starting at offset 576 - # Re-setup xtvs since I am lazy. This is leaking memory like - # a seive... - $xtvcnt++; - $xtvname = set_xtvecs($cmdfh, $outfh, $xtvcnt, 576 * 1024); - - $iovcnt++; - - $cmdstr = '$id10 = CALL ireadx $fd $'."$iovname $NUMVECS ".'$'."$xtvname 2\n"; - helper::send_cmd($cmdfh, $outfh, "ireadx", $cmdstr); - verify_result($cmdfh, $outfh, "ireadx", $IOID_FAIL, "=="); - do_iowait($cmdfh, $outfh, '$id10', "ireadx", $bufsize); - check_buf($cmdfh, $outfh, $bufsize, "ireadx"); -} - - -sub check_array -{ - my ($exp_digit, @arr) = @_; - my $exp_char; - my $pos = 0; - - if ($exp_digit == 0) { - $exp_char = "\\0"; - } elsif ($exp_digit < 7) { - $exp_char = "00".$exp_digit; - } elsif ($exp_digit == 7) { - $exp_char = "\\a"; - } elsif ($exp_digit == 8) { - $exp_char = "\\b"; - } elsif ($exp_digit == 9) { - $exp_char = "\\t"; - } else { - print STDERR "Invalid expected digit $exp_digit\n"; - return(1); - } - - foreach my $str (@arr) { - if ($str ne $exp_char) { - print STDERR "At pos $pos got digit $str instead of $exp_char\n"; - return(1); - } - $pos++; - } - - return(0); -} - -# Perform an od on the output and verify that the output makes -# sense -sub od_verify -{ - my ($cmdfh, $outfh, $file) = @_; - my $exp_digit = 0; - - # Do an od in order to verify the contents of the file - system("od -c $file > tmp.out.$$"); - open(ODFILE, ") { - if (/^\*/) { - # Do nothing... - } else { - my ($lineno, @nums) = split($_); - if (check_array($exp_digit, @nums) != 0) { - helper::print_and_exit($cmdfh, $outfh, 1, "At line $lineno, got unexpected result\n"); - } - if ($exp_digit < 9) { - $exp_digit ++; - } else { - $exp_digit = 0; - } - } - } - - close(ODFILE); - system("rm -f tmp.out.$$"); -} - -sub process_cmd -{ - my ($file, $is_alpha) = @_; - - # Get tests directory - my $testdir = $FindBin::Bin; - my $bufsize = 65536; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 $testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - # Open file - my $cmdstr = '$fd = CALL open '."$file O_RDWR|O_CREAT 0777\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, $cmdstr); - - - # Allocate buffer - $cmdstr = '$buf = ALLOC '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "ALLOC", $cmdstr); - - - do_rwcalls($cmdfh, $outfh, $bufsize); - - # Clean up - $cmdstr = 'CALL close $fd'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - - # Verify it worked - od_verify($cmdfh, $outfh, $file); - - system("rm -f $file"); - helper::print_and_exit($cmdfh, $outfh, 0, "rw test successful\n"); -} - -my $currarg = 0; -my $is_alpha = 0; - -if (@ARGV < 1) { - usage; -} elsif (@ARGV > 1 ) { - if ($ARGV[$currarg++] eq "-alpha") { - $is_alpha = 1; - } -} - -my $file = $ARGV[$currarg]; - -process_cmd($file, $is_alpha); - - -exit 0; diff --git a/libsysio/tests/test_stats.c b/libsysio/tests/test_stats.c deleted file mode 100644 index 951e7cf..0000000 --- a/libsysio/tests/test_stats.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#define _BSD_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#ifdef notdef -#include -#endif -#include - -#include "xtio.h" -#include "test.h" - -/* - * Get stats of file and file system. - * - * Usage: test_stats [ ...] - */ - -void usage(void); -void do_stats(const char *path); - -int -main(int argc, char * const argv[]) -{ - int i; - int err; - extern int _test_sysio_startup(void); - - /* - * Parse command-line args. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - (void )umask(022); - - while (optind < argc) - do_stats(argv[optind++]); - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -void -usage() -{ - - (void )fprintf(stderr, - "Usage: test_stats" - " source destination\n"); - exit(1); -} - -void -do_stats(const char *path) -{ - int fd; - int err; - struct stat stbuf1, stbuf2; -#ifdef notdef - struct statvfs stvfsbuf1, stvfsbuf2; -#endif - - fd = open(path, O_RDONLY); - if (fd < 0) { - perror(path); - return; - } - err = fstat(fd, &stbuf1); - if (!err) - err = stat(path, &stbuf2); -#ifdef notdef - if (!err) - err = fstatvfs(fd, &stvfsbuf1); - if (!err) - err = statvfs(path, &stvfsbuf1); -#endif - if (err) { - perror(path); - goto out; - } - if (stbuf1.st_dev != stbuf2.st_dev || - stbuf1.st_ino != stbuf2.st_ino) { - (void )fprintf(stderr, "%s: [f]stat info mismatch\n", path); - goto out; - } -#ifdef notdef - if (stvfsbuf1.f_fsid != stvfsbuf2.f_fsid) { - (void )fprintf(stderr, "%s: [f]statvfs info mismatch\n", path); - } -#endif - printf("%s:" - " dev %lu," - " ino %lu," - " mode %lu," - " nlink %lu," - " uid %lu," - " gid %lu," - " rdev %lu," - " size %llu," - " blksize %lu," - " blocks %lu," - " atime %lu," - " mtime %lu," - " ctime %lu" - "\n", - path, - (unsigned long )stbuf1.st_dev, - (unsigned long )stbuf1.st_ino, - (unsigned long )stbuf1.st_mode, - (unsigned long )stbuf1.st_nlink, - (unsigned long )stbuf1.st_uid, - (unsigned long )stbuf1.st_gid, - (unsigned long )stbuf1.st_rdev, - (unsigned long long)stbuf1.st_size, - (unsigned long )stbuf1.st_blksize, - (unsigned long )stbuf1.st_blocks, - (unsigned long )stbuf1.st_atime, - (unsigned long )stbuf1.st_mtime, - (unsigned long )stbuf1.st_ctime); -out: - if (close(fd) != 0) - perror("closing file"); -} diff --git a/libsysio/tests/test_stats.pl b/libsysio/tests/test_stats.pl deleted file mode 100755 index fee6a32..0000000 --- a/libsysio/tests/test_stats.pl +++ /dev/null @@ -1,268 +0,0 @@ -#!/usr/bin/perl -w - -# -# stats test: Verifies that the set of stat calls (stat, fstat, fstatvfs, and -# statvfs) return the same items and that the calls return the -# same items as Perl's stat call (which would use a native library -# and not libsysio) -# -# - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage ./test_stats.pl file : Verifies that the set of stat calls (stat, \n"; - print " : fstat, fstatvfs, statvfs) return the same set\n"; - print " : of stats for file and that the calls return \n"; - print " : the same items as Perl's stat call (which \n"; - print " : would use a native library and not libsysio)\n"; - exit(-1); -} - -# Compares the output of Perl's stat function with the output -# from libsysio's stat -sub cmp_stats -{ - - my ( $cmdfh, $outfh, $is_alpha, $bits, @stats) = @_; - - - my ($iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, - $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime, @pstats) = - @stats; - - if ($is_alpha == 1) { - ($iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, - $iosize, $ioatime, $iomtime, $ioctime, $ioblks, $ioblksize, @pstats) = - @stats; - } - if ($bits == 64) { - ($iodev, $ioino, $ionlink, $iomode, $iouid, $iogid, $iordev, - $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime,@pstats) = - @stats; - } - my ($pdev, $pino, $pmode, $pnlink, $puid, $pgid, $prdev, - $psize, $patime, $pmtime, $pctime, $pblksize, $pblks) = @pstats; - -# helper::cmp_nums($cmdfh, $outfh, $iodev, $pdev, "device numbers"); - helper::cmp_nums($cmdfh, $outfh, $ioino, $pino, "inode numbers"); - helper::cmp_nums($cmdfh, $outfh, $iomode, $pmode, "file modes"); - helper::cmp_nums($cmdfh, $outfh, $ionlink, $pnlink, "number of links"); - helper::cmp_nums($cmdfh, $outfh, $iouid, $puid, "user ids"); - helper::cmp_nums($cmdfh, $outfh, $iogid, $pgid, "group ids"); - helper::cmp_nums($cmdfh, $outfh, $iordev, $prdev, "device ids"); - helper::cmp_nums($cmdfh, $outfh, $iosize, $psize, "file sizes"); - helper::cmp_nums($cmdfh, $outfh, $ioatime, $patime, "access times"); - helper::cmp_nums($cmdfh, $outfh, $iomtime, $pmtime, "modification times"); - helper::cmp_nums($cmdfh, $outfh, $ioctime, $pctime, "inode change times"); - helper::cmp_nums($cmdfh, $outfh, $ioblksize, $pblksize, "block sizes"); - helper::cmp_nums($cmdfh, $outfh, $ioblks, $pblks, "blocks allocated"); -} - - -# Prints out the stat buffer and verifies that it matches -# Perl's output -sub verify_stat -{ - my ($cmdfh, $outfh, $cmd, $is_alpha, $bits, @stats) = @_; - my $i=0; - - my $cmdstr; - # Print out the stat buffer - if ($is_alpha == 1) { - $cmdstr = 'PRINT $buf 0 16 LONG 16 16 INT 32 8 LONG 40 4 INT 48 40 LONG'."\n"; - } elsif ($bits == 32) { - $cmdstr = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 48 8 INT 56 24 LONG'."\n"; - } else { - $cmdstr = 'PRINT $buf 0 24 LONG 24 16 INT 48 32 LONG 88 8 LONG 104 8 LONG'."\n"; - } - - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - my $res = <$outfh>; - chop($res); - - my @iostats = split(' ', $res); - foreach my $iostat (@iostats) { - $iostats[$i] = oct($iostat); - $i++; - } - - cmp_stats($cmdfh, $outfh, $is_alpha, $bits, @iostats, @stats); - -} - -sub process_cmd -{ - my ($file, $use_system, $is_alpha) = @_; - -# Get tests directory - my $testdir = $FindBin::Bin; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -batch -quiet -sz 1 $testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - my @stats; - if ($use_system == 1) { - # Get stats for file - @stats = stat($file); - } - - # Allocate the buffer - my $cmdstr = '$buf = ALLOC ( $size = CALL sizeof stat )'."\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - - # Issue the stat command - $cmdstr = 'CALL stat '."$file ".'$buf'."\n"; - helper::send_cmd($cmdfh, $outfh, "stat", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "stat"); - - # Attempt to determine type - $cmdstr = 'PRINT $size'."\n"; - helper::send_cmd($cmdfh, $outfh, "print", $cmdstr); - my $statsize = <$outfh>; - chop($statsize); - $statsize = oct($statsize); - my $bits = 32; - if ($statsize == 144) { - $bits = 64; - } - - if ($use_system == 1) { - # Now print the buffer out and verify that it matches - # what Perl has - verify_stat($cmdfh, $outfh, "stat", $is_alpha, $bits, @stats); - } - - # Open the file - $cmdstr = '$fd = CALL open '."$file O_RDONLY\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "open"); - - - # Now issue an fstat call - $cmdstr = 'CALL fstat $fd $buf'."\n"; - helper::send_cmd($cmdfh, $outfh, "fstat", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "fstat"); - - if ($use_system == 1) { - verify_stat($cmdfh, $outfh, "fstat", $is_alpha, $bits, @stats); - } - - # Test lstat - if ($use_system == 1) { - @stats = lstat($file); - } - - $cmdstr = 'CALL lstat '."$file ".'$buf'."\n"; - helper::send_cmd($cmdfh, $outfh, "lstat", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "lstat"); - - if ($use_system == 1) { - verify_stat($cmdfh, $outfh, "lstat", $is_alpha, $bits, @stats); - } - - if (0) { - # Now do statvfs functions - $cmdstr = '$buf2 = ALLOC ( $size2 = CALL sizeof statvfs )'."\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - # Clear out the buffer - $cmdstr = 'CALL clear $buf2'."\n"; - helper::send_cmd($cmdfh, $outfh, "CLEAR", $cmdstr); - - $cmdstr = 'CALL statvfs '."$file ".'$buf2'."\n"; - helper::send_cmd($cmdfh, $outfh, "statvfs", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "statvfs"); - - # Print out the statvfs buffer - $cmdstr = 'PRINT $buf2 0 16 LONG 16 32 INT 48 16 LONG'."\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - my $res = <$outfh>; - chop($res); - my @vfsstats1 = split(' ', $res); - - # Clear out the buffer - $cmdstr = 'CALL clear $buf2'."\n"; - helper::send_cmd($cmdfh, $outfh, "CLEAR", $cmdstr); - - # Now do fstatvfs - $cmdstr = 'CALL fstatvfs $fd $buf2'."\n"; - helper::send_cmd($cmdfh, $outfh, "fstatvfs", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "fstatvfs"); - - # Print out the statvfs buffer - $cmdstr = 'PRINT $buf2 0 16 LONG 16 32 INT 48 16 LONG'."\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - $res = <$outfh>; - chop($res); - my @vfsstats2 = split(' ', $res); - - # Verify the two vfsstats arrays match - if (@vfsstats1 != @vfsstats2) { - helper::print_and_exit($cmdfh, $outfh, 1, "Two vfsstat arrays unequal lengths\n"); - } - - my $i=0; - - foreach my $stat1 (@vfsstats1) { - if ($stat1 ne $vfsstats2[$i++]) { - my $str = sprintf("vfsstats field %d are not equal (%s != %s)\n", - $i-1, $stat1, $vfsstats2[$i-1]); - helper::print_and_exit($cmdfh, $outfh, 1, $str); - } - } - } - - helper::print_and_exit($cmdfh, $outfh, 0, "stat test successful\n"); -} - - - - -my $currarg = 0; -my $is_alpha = 0; -if (@ARGV < 2) { - usage; -} elsif (@ARGV > 2) { - if ($ARGV[$currarg++] eq "-alpha") { - $is_alpha = 1; - } -} - -my $use_system= $ARGV[$currarg++]; -my $file = $ARGV[$currarg]; - -process_cmd($file, $use_system, $is_alpha); - diff --git a/libsysio/tests/test_stdfd.pl b/libsysio/tests/test_stdfd.pl deleted file mode 100755 index afd5548..0000000 --- a/libsysio/tests/test_stdfd.pl +++ /dev/null @@ -1,242 +0,0 @@ -#!/usr/bin/perl -w - -# -# stdfd test: Verifies that stdin, stdout, and stderr can be opened and -# either written to or read from (in the case of stdin) - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage ./test_stdfd : Verifies that stdin, stdout, and stderr can be opened and "; - print " : either written to or read from (in the case of stdin)"; - exit(-1); -} - -sub mkdev -{ - my ($major, $minor) = @_; - my $devno = ( (($major & 0xff) << 8) | ($minor & 0xff) ); - - return $devno; -} - -sub statit -{ - my ($cmdfh, $outfh, $do_print, $name) = @_; - - my $cmd = "CALL stat $name ".'$buf'."\n"; - - helper::send_cmd($cmdfh, $outfh, "stat", $cmd); - helper::verify_cmd($cmdfh, $outfh, "stat $name"); - - # Print out the stat buffer - $cmd = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 52 8 INT 64 24 LONG'; - $cmd .= "\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmd); - - my $res = <$outfh>; - chop($res); - my ( $iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, - $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime ) - = split(' ', $res); - - $iomode = oct($iomode); - - if ($do_print == 1) { - # Print out the path - my $typechar = helper::get_type($iomode); - print STDOUT "$name: $typechar\n"; - } - return 0; -} - -sub do_open -{ - - my ($cmdfh, $outfh, $name, $mode, $num) = @_; - - helper::send_cmd($cmdfh, $outfh, "open", "CALL open $name $mode\n"); - - my $res = helper::verify_cmd($cmdfh, $outfh, "open $name"); - - #chop($res); - $res = oct($res); - if ($res < 0) { - helper::print_and_exit($cmdfh, $outfh, 1, "Unable to open $name\n"); - } - - - if ($res == $num) { - return $res; - } - - helper::send_cmd($cmdfh, $outfh, "dup2", "CALL dup2 $res $num\n"); - $res = helper::verify_cmd($cmdfh, $outfh, "dup2"); - $res = oct($res); - - if ($res != $num) { - helper::print_and_exit($cmdfh, $outfh, 1, "Unable to dup $name (res was $res)\n"); - } -} - -sub do_mknod -{ - - my ($cmdfh, $outfh, $do_print, $name, $perm_num, $minor) = @_; - - my $perm = 'S_IFCHR|'.$perm_num; - my $devno = mkdev(0, $minor); - - helper::send_cmd($cmdfh, $outfh, "mknod", "CALL mknod $name $perm $devno\n"); - - helper::verify_cmd($cmdfh, $outfh, "mknod $name"); - - my $statres = statit($cmdfh, $outfh, $do_print, $name); - if ($statres != 0) { - helper::print_and_exit($cmdfh, $outfh, 1, "stat on $name failed\n"); - } -} - -sub process_cmd -{ - my ($dirname, $do_print, $is_alpha) = @_; - -# Get tests directory -my $testdir = $0; -$testdir =~ s/\/\w+.pl$//; - - eval { - if ($is_alpha == 1) { - open2(\*OUTFILE, \*CMDFILE, "yod -sz 1 -quiet -batch $testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init incore ".'"0777+0+0"'." 0\n"); - helper::verify_cmd($cmdfh, $outfh, "init incore"); - } - - - # Get a stat buffer - my $cmd = '$buf = ALLOC ( $size = CALL sizeof stat )'."\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmd); - - if ($is_alpha == 0) { - # Make the test directory - $cmd = "CALL mkdir $dirname 0777\n"; - helper::send_cmd($cmdfh, $outfh, "mkdir", $cmd); - helper::verify_cmd($cmdfh, $outfh, "mkdir"); - - - # Change working dir to test dir - $cmd = "CALL chdir $dirname\n"; - helper::send_cmd($cmdfh, $outfh, "chdir", $cmd); - helper::verify_cmd($cmdfh, $outfh, "chdir"); - - - # Create the 3 special files - do_mknod($cmdfh, $outfh, $do_print, "stdin", "0444", 0); - do_mknod($cmdfh, $outfh, $do_print, "stdout", "0222", 1); - do_mknod($cmdfh, $outfh, $do_print, "stderr", "0222", 2); - - # Open the 3 files - do_open($cmdfh, $outfh, "stdin", "O_RDONLY", 0); - do_open($cmdfh, $outfh, "stdout", "O_WRONLY", 1); - do_open($cmdfh, $outfh, "stderr", "O_WRONLY", 2); - } - #helper::send_cmd($cmdfh, $outfh, "debug", "CALL debug 5\n"); - - # Read from stdin, write to stdout and stderr - - # Send "delay" option to read which will give us time to - # put something in stdin (since we can't send an eof) - $cmd = "CALL read 0 ".'$buf 38'." delay\n"; - print $cmdfh $cmd; - # Give time to process command - sleep 1; - - # Send random junk... - print $cmdfh "This message is exactly 38 bytes long\n"; - sleep 0.5; - - # Make sure read was OK - my $res = <$outfh>; - chop($res); - if ($res ne "0000 ") { - helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n"); - } - - # See how many bytes we got... - my $bytes = helper::verify_cmd($cmdfh, $outfh, "read"); - $bytes = oct($bytes); - if ($bytes == 0) { - helper::print_and_exit($cmdfh, $outfh, 0, "test_stdfd successful but read nothing\n"); - } - - if ($bytes < 0) { - helper::print_and_exit($cmdfh, $outfh, 0, "test_stdfd unsuccessful\n"); - } - - $cmd = "CALL write 1 ".'$buf '."$bytes\n"; - print $cmdfh $cmd; - - # Suck up the stdout... - $res = <$outfh>; - chop($res); - - $res = <$outfh>; - chop($res); - $res = oct($res); - - if ($res != 0) { - helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n"); - } - - helper::verify_cmd($cmdfh, $outfh, "write stdout"); - - $cmd = "CALL write 2 ".'$buf '."$bytes\n"; - helper::send_cmd($cmdfh, $outfh, "write stderr", $cmd); - helper::verify_cmd($cmdfh, $outfh, "write stderr"); - - helper::print_and_exit($cmdfh, $outfh, 0, "test_stdfd successful\n"); -} - - -my $is_alpha = 0; -my $do_print = 0; -my $i; -for ($i=0; $i < @ARGV; $i++) { - if ($ARGV[$i] eq "-alpha") { - $is_alpha =1; - } elsif ($ARGV[$i] eq "-print") { - $do_print = 1; - } -} - -$i--; -my $dirname = $ARGV[$i]; - -process_cmd($dirname, $do_print, $is_alpha); - -exit 0; - diff --git a/libsysio/tests/test_strided.pl b/libsysio/tests/test_strided.pl deleted file mode 100755 index 5468d9b..0000000 --- a/libsysio/tests/test_strided.pl +++ /dev/null @@ -1,462 +0,0 @@ -#!/usr/bin/perl -w - -# -# strided IO test: Perform a series of different reads/writes -# using readx and writex with different buffer -# configurations -# - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage: ./test_rw.pl [-alpha] : Write to/read from file\n"; - exit(-1); -} - -sub verify_result -{ - my ($cmdfh, $outfh, $cmdstr, $exp_val, $eq_op) = @_; - my $print_err = 0; - - my $res = helper::verify_cmd($cmdfh, $outfh, $cmdstr); - $res = oct($res); - - if ($eq_op eq "!=") { - if ($res != $exp_val) { - print STDOUT "Error! $cmdstr returned $res insted of $exp_val\n"; - system("killall test_driver"); - exit(1); - } - } else { - if ($eq_op eq ">") { - if ($res > $exp_val) { - $print_err = 1; - } - } elsif ($eq_op eq "<") { - if ($res < $exp_val) { - $print_err = 1; - } - } elsif ($eq_op eq "==") { - if ($res == $exp_val) { - $print_err = 1; - } - } - if ($print_err == 1) { - print STDOUT "Error! $cmdstr returned $res\n"; - } - } - -} - -# Initilize the iovec number $vecnum -# in the iovec buffer $vecname with buffer -# pos $buf and using len $veclen -sub set_iovec -{ - my ($cmdfh, $outfh, $vecname, $vecnum, $buf, $veclen) = @_; - - my $cmdstr = 'CALL init_iovec $'.$buf." 0 $veclen "; - $cmdstr .= "$vecnum ".'$'."$vecname\n"; - - helper::send_cmd($cmdfh, $outfh, "init_iovec", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "init_iovec"); -} - - -sub setup_xtvecs -{ - my ($cmdfh, $outfh) = @_; - - # Get size of iovecs - my $cmdstr = '$xtvsize = CALL sizeof xtvec'."\n"; - helper::send_cmd($cmdfh, $outfh, "sizeof", $cmdstr); - my $size = helper::verify_cmd($cmdfh, $outfh, "sizeof xtvec"); - $size = oct($size); - $size = $size * 2; - - # Allocate iovec buffer - $cmdstr = '$xtvbuf'." = ALLOC $size\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - - # Now initilize xtvbuf - $cmdstr = "CALL init_xtvec 0 100 0 ". '$xtvbuf'."\n"; - helper::send_cmd($cmdfh, $outfh, "init_xtvec", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "init_xtvec"); - - $cmdstr = "CALL init_xtvec 1000 100 1 ". '$xtvbuf'."\n"; - helper::send_cmd($cmdfh, $outfh, "init_xtvec", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "init_xtvec"); -} - -sub check_buf -{ - - my ($cmdfh, $outfh, $bufsize, $bufname, - $readcmd, $digit, $offset) = @_; - - my $cmdstr = 'CALL checkbuf $'. "$bufname $bufsize $digit $offset\n"; - helper::send_cmd($cmdfh, $outfh, "checkbuf", $cmdstr); - my $res = helper::verify_cmd($cmdfh, $outfh, "checkbuf"); - $res = oct($res); - - if ($res != 0) { - print STDOUT "$readcmd did not return all $digit 's\n"; -} -} - -# Fill given buffer with $digit up to $size -# starting at $offset -sub fill_buf -{ - my ($cmdfh, $outfh, $buf, $digit, $size, $off) = @_; - - my $cmdstr = "CALL setbuf $digit $size ".'$'."$buf $off\n"; - helper::send_cmd($cmdfh, $outfh, "setbuf", $cmdstr); -} - -sub alloc_iovbuf -{ - my ($cmdfh, $outfh, $numbufs, $num) = @_; - - # Get size of iovecs - my $cmdstr = '$iovsize = CALL sizeof iovec'."\n"; - helper::send_cmd($cmdfh, $outfh, "sizeof", $cmdstr); - my $size = helper::verify_cmd($cmdfh, $outfh, "sizeof iovec"); - $size = oct($size); - $size = $size * $numbufs; - - # Allocate iovec buffer - $cmdstr = '$iovbuf'."$num = ALLOC $size\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - my $retstr = "iovbuf".$num; - - return $retstr; -} - -sub do_rwcalls -{ - my ($cmdfh, $outfh, $fh) = @_; - - # Allocate and initilize xtvecs - setup_xtvecs($cmdfh, $outfh); - - # Allocate 2 different iovecs, one for cases - # (a) and (d) and one for cases (b) and (c) - my $iovbuf1 = alloc_iovbuf($cmdfh, $outfh, 3, 0); - my $iovbuf2 = alloc_iovbuf($cmdfh, $outfh, 1, 1); - - # Allocate four buffers, each 200 bytes long - my $cmdstr = '$buf1 '. "= ALLOC 200\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - $cmdstr = '$buf2 '. "= ALLOC 200\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - $cmdstr = '$buf3 '. "= ALLOC 200\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - $cmdstr = '$buf4 '. "= ALLOC 200\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); - - # Case (a): - # xtvec[] = { { 0, 100 }, {1000, 100} } - # iovec[] = { { buf1, 50}, {buf2, 50}, {buf3, 100} - - # Fill each of the 3 buffers of. They will be filled - # as follows: - # buf1 --> 0- 49: 1 - # --> 49-200: 2 - # buf2 --> 0- 49: 3 - # --> 49-200: 4 - # buf3 --> 0-100: 5 - # --> 100-200: 6 - fill_buf($cmdfh, $outfh, "buf1", 1, 50, 0); - fill_buf($cmdfh, $outfh, "buf1", 2, 150, 50); - fill_buf($cmdfh, $outfh, "buf2", 3, 50, 0); - fill_buf($cmdfh, $outfh, "buf2", 4, 150, 50); - fill_buf($cmdfh, $outfh, "buf3", 5, 100, 0); - fill_buf($cmdfh, $outfh, "buf3", 6, 100, 100); - - # Initiize iovecs - set_iovec($cmdfh, $outfh, $iovbuf1, 0, "buf1", 50); - set_iovec($cmdfh, $outfh, $iovbuf1, 1, "buf2", 50); - set_iovec($cmdfh, $outfh, $iovbuf1, 2, "buf3", 100); - - # Write out to $fh - $cmdstr = 'CALL writex $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "writex", $cmdstr); - verify_result($cmdfh, $outfh, "writex (case a)", 200, "!="); - - # Clear out the buffers - fill_buf($cmdfh, $outfh, "buf1", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf2", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf3", 0, 200, 0); - - # Read it back - $cmdstr = 'CALL readx $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "readx", $cmdstr); - verify_result($cmdfh, $outfh, "readx (case a)", 200, "!="); - - # Make sure we got what we expected... - check_buf($cmdfh, $outfh, 50, "buf1", "readx (case a)", 1, 0); - check_buf($cmdfh, $outfh, 50, "buf2", "readx (case a)", 3, 0); - check_buf($cmdfh, $outfh, 100, "buf3", "readx (case a)", 5, 0); - - # Case (b): - # xtvec[] = { { 0, 100 }, {1000, 100} } - # iovec[] = { { buf4, 200} } - - - # Fill buf4 with 7's... - fill_buf($cmdfh, $outfh, "buf4", 7, 200, 0); - - # Initiize iovecs - set_iovec($cmdfh, $outfh, $iovbuf2, 0, "buf4", 200); - - # Write out to $fh - $cmdstr = 'CALL writex $'."$fh ".'$'."$iovbuf2 1 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "writex", $cmdstr); - verify_result($cmdfh, $outfh, "writex (case b)", 200, "!="); - - # Clear out the buffer - fill_buf($cmdfh, $outfh, "buf4", 0, 200, 0); - - # Read it back - $cmdstr = 'CALL readx $'."$fh $iovbuf2 1 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "readx", $cmdstr); - verify_result($cmdfh, $outfh, "readx (case b)", 200, "!="); - - # Make sure we got what we expected... - check_buf($cmdfh, $outfh, 200, "buf4", "readx (case b)", 7, 0); - - - # Case (c): - # xtvec[] = { { 0, 100 }, {1000, 100} } - # iovec[] = { { buf4, 40} } - - # Fill buf4 with 8's... - fill_buf($cmdfh, $outfh, "buf4", 8, 200, 0); - - # Initiize iovecs - set_iovec($cmdfh, $outfh, $iovbuf2, 0, "buf4", 40); - - # Write out to $fh - $cmdstr = 'CALL writex $'."$fh $iovbuf2 1 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "writex", $cmdstr); - verify_result($cmdfh, $outfh, "writex (case c)", 40, "!="); - - # Clear out the buffer - fill_buf($cmdfh, $outfh, "buf4", 0, 200, 0); - - # Read it back - $cmdstr = 'CALL readx $'."$fh $iovbuf2 1 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "readx", $cmdstr); - verify_result($cmdfh, $outfh, "readx (case c)", 40, "!="); - - # Make sure we got what we expected... - check_buf($cmdfh, $outfh, 40, "buf4", "readx (case c)", 8, 0); - - - # Case (d): - # xtvec[] = { { 0, 100 }, {1000, 100} } - # iovec[] = { { buf1, 40}, {buf2, 150}, {buf3, 200} } - - # Fill each of the 3 buffers of. They will be filled - # as follows: - # buf1 --> 0- 39: 1 - # --> 39-200: 2 - # buf2 --> 0-150: 3 - # --> 150-200: 4 - # buf3 --> 0- 9: 5 - # --> 10-200: 6 - fill_buf($cmdfh, $outfh, "buf1", 1, 40, 0); - fill_buf($cmdfh, $outfh, "buf1", 2, 160, 40); - fill_buf($cmdfh, $outfh, "buf2", 3, 150, 0); - fill_buf($cmdfh, $outfh, "buf2", 4, 50, 150); - fill_buf($cmdfh, $outfh, "buf3", 5, 10, 0); - fill_buf($cmdfh, $outfh, "buf3", 6, 190, 10); - - # Initiize iovecs - set_iovec($cmdfh, $outfh, $iovbuf1, 0, "buf1", 40); - set_iovec($cmdfh, $outfh, $iovbuf1, 1, "buf2", 150); - set_iovec($cmdfh, $outfh, $iovbuf1, 2, "buf3", 200); - - # Write out to $fh - $cmdstr = 'CALL writex $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "writex", $cmdstr); - verify_result($cmdfh, $outfh, "writex (case d)", 200, "!="); - - # Clear out the buffers - fill_buf($cmdfh, $outfh, "buf1", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf2", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf3", 0, 200, 0); - - # Read it back - $cmdstr = 'CALL readx $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "readx", $cmdstr); - verify_result($cmdfh, $outfh, "readx (case d)", 200, "!="); - - # Make sure we got what we expected... - check_buf($cmdfh, $outfh, 40, "buf1", "readx (case d)", 1, 0); - check_buf($cmdfh, $outfh, 150, "buf2", "readx (case d)", 3, 0); - check_buf($cmdfh, $outfh, 10, "buf3", "readx (case d)", 5, 0); - - # Case (e): - # xtvec[] = { { 0, 100 }, {1000, 100} } - # iovec[] = { { buf1, 30}, {buf2, 30}, {buf3, 30} } - - # Fill each of the 3 buffers as follows: - # buf1 --> 0- 30: 1 - # --> 30-200: 2 - # buf2 --> 0- 30: 3 - # --> 30-200: 4 - # buf3 --> 0- 30: 5 - # --> 30-200: 6 - fill_buf($cmdfh, $outfh, "buf1", 1, 30, 0); - fill_buf($cmdfh, $outfh, "buf1", 2, 170, 30); - fill_buf($cmdfh, $outfh, "buf2", 3, 30, 0); - fill_buf($cmdfh, $outfh, "buf2", 4, 170, 30); - fill_buf($cmdfh, $outfh, "buf3", 5, 30, 0); - fill_buf($cmdfh, $outfh, "buf3", 6, 170, 30); - - # Initiize iovecs - set_iovec($cmdfh, $outfh, $iovbuf1, 0, "buf1", 30); - set_iovec($cmdfh, $outfh, $iovbuf1, 1, "buf2", 30); - set_iovec($cmdfh, $outfh, $iovbuf1, 2, "buf3", 30); - - # Write out to $fh - $cmdstr = 'CALL writex $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "writex", $cmdstr); - verify_result($cmdfh, $outfh, "writex (case e)", 90, "!="); - - # Clear out the buffers - fill_buf($cmdfh, $outfh, "buf1", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf2", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf3", 0, 200, 0); - - # Read it back - $cmdstr = 'CALL readx $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "readx", $cmdstr); - verify_result($cmdfh, $outfh, "readx (case e)", 90, "!="); - - # Make sure we got what we expected... - check_buf($cmdfh, $outfh, 30, "buf1", "readx (case e)", 1, 0); - check_buf($cmdfh, $outfh, 30, "buf2", "readx (case e)", 3, 0); - check_buf($cmdfh, $outfh, 30, "buf3", "readx (case e)", 5, 0); - - # Case (f): - # xtvec[] = { { 0, 100 }, {1000, 100} } - # iovec[] = { { buf1, 30}, {buf2, 90}, {buf3, 200} } - - # Fill each of the 3 buffers as follows: - # buf1 --> 0- 30: 1 - # --> 30-200: 2 - # buf2 --> 0- 70: 3 - # --> 70- 90: 4 - # --> 90-200: 5 - # buf3 --> 0-200: 6 - fill_buf($cmdfh, $outfh, "buf1", 1, 30, 0); - fill_buf($cmdfh, $outfh, "buf1", 2, 170, 30); - fill_buf($cmdfh, $outfh, "buf2", 3, 70, 0); - fill_buf($cmdfh, $outfh, "buf2", 4, 90, 70); - fill_buf($cmdfh, $outfh, "buf2", 5, 110, 90); - fill_buf($cmdfh, $outfh, "buf3", 6, 200, 0); - - # Initiize iovecs - set_iovec($cmdfh, $outfh, $iovbuf1, 0, "buf1", 30); - set_iovec($cmdfh, $outfh, $iovbuf1, 1, "buf2", 90); - set_iovec($cmdfh, $outfh, $iovbuf1, 2, "buf3", 200); - - # Write out to $fh - $cmdstr = 'CALL writex $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "writex", $cmdstr); - verify_result($cmdfh, $outfh, "writex (case f)", 200, "!="); - - # Clear out the buffers - fill_buf($cmdfh, $outfh, "buf1", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf2", 0, 200, 0); - fill_buf($cmdfh, $outfh, "buf3", 0, 200, 0); - - # Read it back - $cmdstr = 'CALL readx $'."$fh $iovbuf1 3 ".'$xtvbuf '."2\n"; - helper::send_cmd($cmdfh, $outfh, "readx", $cmdstr); - verify_result($cmdfh, $outfh, "readx (case f)", 200, "!="); - - # Make sure we got what we expected... - check_buf($cmdfh, $outfh, 30, "buf1", "readx (case f)", 1, 0); - check_buf($cmdfh, $outfh, 70, "buf2", "readx (case f)", 3, 0); - check_buf($cmdfh, $outfh, 20, "buf2", "readx (case f)", 4, 70); - check_buf($cmdfh, $outfh, 70, "buf3", "readx (case f)", 6, 0); - -} - - -sub process_cmd -{ - my ($file, $is_alpha) = @_; - - # Get tests directory - my $testdir = $FindBin::Bin; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -quiet -sz 1 $testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - # Open file - my $cmdstr = '$fd = CALL open '."$file O_RDWR|O_CREAT|O_TRUNC S_IRWXU\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, $cmdstr); - - - do_rwcalls($cmdfh, $outfh, "fd"); - - # Clean up - $cmdstr = 'CALL close $fd'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - -# system("rm -f $file"); - helper::print_and_exit($cmdfh, $outfh, 0, "strided IO test successful\n"); -} - -my $currarg = 0; -my $is_alpha = 0; - -if (@ARGV < 1) { - usage; -} elsif (@ARGV > 1 ) { - if ($ARGV[$currarg++] eq "-alpha") { - $is_alpha = 1; - } -} - -my $file = $ARGV[$currarg]; - -process_cmd($file, $is_alpha); - -exit 0; diff --git a/libsysio/tests/test_symlink.pl b/libsysio/tests/test_symlink.pl deleted file mode 100755 index 23d5185..0000000 --- a/libsysio/tests/test_symlink.pl +++ /dev/null @@ -1,247 +0,0 @@ -#!/usr/bin/perl -w - -# -# symlink test: Verify that symbolic links work -# - -use IPC::Open2; - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use helper; - -sub usage -{ - print "Usage: ./test_symlink.pl [-alpha] : Create a symlink from src to dest\n"; - exit(-1); -} - -sub clean_exit -{ - my ($cmdfh, $outfh, $exit_num, $exit_str) = @_; - - print STDOUT "$exit_str"; - - # Free buffers - my $cmdstr = 'FREE $srcbuf'."\n"; - - print $cmdfh $cmdstr; - - my $res = <$outfh>; - chop($res); - if ($res ne "0000 ") { - print STDOUT "ERROR! Failed to free srcbuf (code $res)\n"; - } - - $cmdstr = 'FREE $destbuf'."\n"; - - print $cmdfh $cmdstr; - - $res = <$outfh>; - chop($res); - if ($res ne "0000 ") { - print STDOUT "ERROR! Failed to free destbuf (code $res)\n"; - } - - print $cmdfh "exit\n"; - close $outfh; - - # Give test_driver time to finish - sleep 0.000001; - - exit $exit_num; -} - -sub process_cmd -{ - my ($src, $dest, $is_alpha) = @_; - - # Get tests directory - my $testdir = $FindBin::Bin; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 $testdir/test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - # Get the filesize of src - my $size = -s $src; - my $bufsize; - - if ( $size > 1024) { # Arbitrary limit - $bufsize = 1024; - } else { - $bufsize = $size; - } - - # Create the symbolic link from src to dest - my $cmdstr = "CALL symlink $src $dest\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - - helper::verify_cmd($cmdfh, $outfh, "symlink"); - - # Open src - $cmdstr = '$src = CALL open '."$src O_RDONLY\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - - # Open dest - $cmdstr = '$dest = CALL open '."$dest O_RDONLY\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - - my $res = helper::verify_cmd($cmdfh, $outfh, "open $dest"); - - # Allocate buffer for src - $cmdstr = '$srcbuf = ALLOC '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "ALLOC", $cmdstr); - - # Allocate buffer for dest - $cmdstr = '$destbuf = ALLOC '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "ALLOC", $cmdstr); - - - # Read size bytes from src and dest, then compare them and verify they - # are the same - $cmdstr = 'CALL read $src $srcbuf '."$bufsize\n"; - helper::send_cmd($cmdfh, $outfh, "read $src", $cmdstr); - - $res = helper::verify_cmd($cmdfh, $outfh, "read $src"); - my $readb = oct($res); - - # Now read $readb from dest - $cmdstr = 'CALL read $dest $destbuf '."$readb\n"; - helper::send_cmd($cmdfh, $outfh, "read $dest", $cmdstr); - - $res = helper::verify_cmd($cmdfh, $outfh, "read $dest"); - - my $errstr; - if ($readb != oct($res)) { - $errstr = "ERROR! Read $readb bytes from src but only $res bytes from dest\n"; - clean_exit($cmdfh, $outfh, 1, $errstr); - } - - # Compare the two buffers - $cmdstr = 'CALL cmpstr $srcbuf $destbuf'."\n"; - helper::send_cmd($cmdfh, $outfh, "cmpstr", $cmdstr); - - # Verify that it returned an error - $cmdstr = 'PRINT $$'; - $cmdstr .= "\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - $res = <$outfh>; - chop($res); - - $res = helper::verify_cmd($cmdfh, $outfh, "cmpstr"); - $res = oct($res); - if ($res != 0) { - $errstr = "ERROR! Buffers from $src and $dest do not match\n"; - clean_exit($cmdfh, $outfh, 1, $errstr); - } - - # Clean up - $cmdstr = 'CALL close $src'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - $cmdstr = 'CALL close $dest'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - - # Clear out destbuf - $cmdstr = 'CALL clear $destbuf'."\n"; - helper::send_cmd($cmdfh, $outfh, "CLEAR", $cmdstr); - - # Now remove the symbolic link and make sure everything stays the same - - # Remove the link (this assumes the link is not in incore) - $cmdstr = "CALL unlink $dest\n"; - helper::send_cmd($cmdfh, $outfh, "unlink", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "unlink"); - - # Attempt to open the symbolic link. This should return an error - $cmdstr = 'CALL open '."$dest O_RDONLY\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - - # Verify that it returned an error - $cmdstr = 'PRINT $$'; - $cmdstr .= "\n"; - helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); - - $res = <$outfh>; - chop($res); - - if ($res ne "0xffffffff") { - $errstr = "ERROR! Open on $dest succeeded (should have failed)\n"; - clean_exit($cmdfh, $outfh, 1, $errstr); - } - - # Now read from the src again and make sure it matches the original - - # Open src - $cmdstr = '$src2 = CALL open '."$src O_RDONLY\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); - helper::verify_cmd($cmdfh, $outfh, "open $src(2)"); - - $cmdstr = 'CALL read $src2 $destbuf '."$readb\n"; - helper::send_cmd($cmdfh, $outfh, "read $src(2)", $cmdstr); - - $res = helper::verify_cmd($cmdfh, $outfh, "read $src(2)"); - - if ($readb != oct($res)) { - $errstr = "ERROR! Read $readb bytes from src originally but now only $res bytes\n"; - clean_exit($cmdfh, $outfh, 1, $errstr); - } - - # Compare the two buffers - $cmdstr = 'CALL cmpstr $srcbuf $destbuf'."\n"; - helper::send_cmd($cmdfh, $outfh, "cmpstr", $cmdstr); - $res = helper::verify_cmd($cmdfh, $outfh, "cmpstr"); - $res = oct($res); - if ($res != 0) { - $errstr = "ERROR! Original buffers from $src and new buf do not match\n"; - clean_exit($cmdfh, $outfh, 1, $errstr); - } - - # Clean up - $cmdstr = 'CALL close $src2'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - - clean_exit($cmdfh, $outfh, 0, "Symlink test successful\n"); - exit 0; -} - -my $currarg = 0; -my $is_alpha = 0; - -if (@ARGV < 2) { - usage; -} elsif (@ARGV > 2 ) { - if ($ARGV[$currarg++] eq "-alpha") { - $is_alpha = 1; - } -} - -my $src = $ARGV[$currarg++]; -my $dest = $ARGV[$currarg]; - -process_cmd($src, $dest, $is_alpha); - - -exit 0; diff --git a/libsysio/tests/test_unlink.c b/libsysio/tests/test_unlink.c deleted file mode 100644 index d168b28..0000000 --- a/libsysio/tests/test_unlink.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * This Cplant(TM) source code is the property of Sandia National - * Laboratories. - * - * This Cplant(TM) source code is copyrighted by Sandia National - * Laboratories. - * - * The redistribution of this Cplant(TM) source code is subject to the - * terms of the GNU Lesser General Public License - * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) - * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the US Government. - * Export of this program may require a license from the United States - * Government. - */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Questions or comments about this library should be sent to: - * - * Lee Ward - * Sandia National Laboratories, New Mexico - * P.O. Box 5800 - * Albuquerque, NM 87185-1110 - * - * lee@sandia.gov - */ - -#include -#include -#include -#include -#include -#include -#if 0 -#include -#endif -#include - -#include "xtio.h" -#include "test.h" - -/* - * Unlink files. - * - * Usage: unlink [path...] - * - * Without any path arguments, the program unlinks files named - * by the ocmmand line args. - */ - -static int unlinkit(const char *path); -static void usage(void); - -int -main(int argc, char *const argv[]) -{ - int i; - int err; - int n; - extern int _test_sysio_startup(void); - - /* - * Parse command line arguments. - */ - while ((i = getopt(argc, argv, "")) != -1) - switch (i) { - - default: - usage(); - } - - /* - * Init sysio lib. - */ - err = _test_sysio_startup(); - if (err) { - errno = -err; - perror("sysio startup"); - exit(1); - } - - n = argc - optind; - - /* - * Try path(s) listed on command-line. - */ - while (optind < argc) { - const char *path; - - path = argv[optind++]; - (void )unlinkit(path); - } - - /* - * If no command-line arguments, read from stdin until EOF. - */ - if (!n) { - int doflush; - static char buf[4096]; - size_t len; - char *cp; - char c; - - doflush = 0; - while (fgets(buf, sizeof(buf), stdin) != NULL) { - len = strlen(buf); - cp = buf + len - 1; - c = *cp; - *cp = '\0'; - if (!doflush) - unlinkit(buf); - doflush = c == '\n' ? 0 : 1; - } - } - - /* - * Clean up. - */ - _test_sysio_shutdown(); - - return 0; -} - -static int -unlinkit(const char *path) -{ - - if (unlink(path) != 0) { - perror(path); - return -1; - } - - return 0; -} - -static void -usage() -{ - - (void )fprintf(stderr, - "Usage: unlink" - " [ ...\n]"); - - exit(1); -} diff --git a/libsysio/tests/verifier.pl b/libsysio/tests/verifier.pl deleted file mode 100755 index 3afc51b..0000000 --- a/libsysio/tests/verifier.pl +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/perl -w - -# Verifies that the contents of a given file produced by producer.pl with the given -# seed are good - -use IPC::Open2; - -use strict; -use helper; - -sub usage -{ - print "Usage: ./verifier.pl <-seed seed> <-file fname> : Verifies that file fname,\n"; - print " : produced with the given \n"; - print " : seed matches\n"; - exit(-1); -} - -sub get_buf -{ - my $MAX_SIZE = 2147483648; - - my $str; - my $num; - my $len = 0; - - while ($len < 512) { - $num = rand $MAX_SIZE; - my $tmpstr = sprintf("%d", $num); - $str .= $tmpstr; - $len += length $tmpstr; - } - - return ($len, $str); -} - - -sub check_file -{ - my ($cmdfh, $outfh, $filename) = @_; - - - # Allocate the read buffer - my $cmd = '$buf = ALLOC 1024'."\n"; - helper::send_cmd($cmdfh, $outfh, "alloc", $cmd); - - # Open the file - $cmd = '$fd = CALL open '."$filename O_RDONLY\n"; - helper::send_cmd($cmdfh, $outfh, "open", $cmd); - - # Verify the system call's output - helper::verify_cmd($cmdfh, $outfh, "open"); - - my $total = 0; - my $bytes = 0; - - # Read all of the file in 1024 byte chunks - do { - - # Clear the buffer - $cmd = 'CALL clear $buf'."\n"; - helper::send_cmd($cmdfh, $outfh, "clear", $cmd); - - my ($len, $buf) = get_buf; - - $cmd = 'CALL read $fd $buf '."$len\n"; - helper::send_cmd($cmdfh, $outfh, "read", $cmd); - $bytes = helper::verify_cmd($cmdfh, $outfh, "read"); - $bytes = oct($bytes); - $total += $bytes; - if ($bytes > 0) { - - # Print out the buffer - $cmd = 'PRINT $buf 0 1 STR'."\n"; - helper::send_cmd($cmdfh, $outfh, "print", $cmd); - my $str = <$outfh>; - chop($str); - if ($bytes > $len) { - $str = substr($str, 0, $len-1); - } elsif ($len > $bytes) { - $buf = substr($buf, 0, $bytes); - } - if ($str ne $buf) { - my $errstr = "ERROR! Str $str is not equal to str $buf\n"; - helper::print_and_exit($cmdfh, $outfh, 1, $errstr); - } - } - } while ($bytes > 0); - -} - -sub verify_file -{ - my ($filename, $is_alpha) = @_; - - eval { - if ($is_alpha == 0) { - open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); - } else { - open2(\*OUTFILE, \*CMDFILE, - "yod -batch -quiet -sz 1 ./test_driver --np"); - } - }; - - if ($@) { - if ($@ =~ /^open2/) { - warn "open2 failed: $!\n$@\n"; - return; - } - die; - - } - - my $outfh = \*OUTFILE; - my $cmdfh = \*CMDFILE; - - if ($is_alpha == 0) { - helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - } - - # Now check the file - check_file($cmdfh, $outfh, $filename); - - # Close the file - my $cmd = 'CALL close $fd'."\n"; - helper::send_cmd($cmdfh, $outfh, "close", $cmd); - - helper::verify_cmd($cmdfh, $outfh, "close"); - - # All done - helper::print_and_exit($cmdfh, $outfh, 0, "File $filename valid\n"); -} - - -my $is_alpha = 0; -my $seed = time; -my $filename = "randfile.$seed.$$"; -my $bytes = 1024; -for (my $i = 0; $i < @ARGV; $i++) -{ - if ($ARGV[$i] eq "-file") { - $i++; - $filename = $ARGV[$i]; - } elsif ($ARGV[$i] eq "-seed") { - $i++; - $seed = $ARGV[$i]; - } elsif ($ARGV[$i] eq "-alpha") { - $is_alpha = 1; - } -} - -# seed the randome number generator -srand $seed; - -verify_file($filename, $is_alpha); - -exit 0; - - - - diff --git a/lnet/.cvsignore b/lnet/.cvsignore deleted file mode 100644 index f30d862..0000000 --- a/lnet/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -Kernelenv -Makefile -autoMakefile -autoMakefile.in -aclocal.m4 -autom4te.cache -config.log -config.status -configure -.*.cmd -.depend diff --git a/lnet/AUTHORS b/lnet/AUTHORS deleted file mode 100644 index e69de29..0000000 diff --git a/lnet/ChangeLog b/lnet/ChangeLog deleted file mode 100644 index e69de29..0000000 diff --git a/lnet/Kernelenv.in b/lnet/Kernelenv.in deleted file mode 100644 index 7a48c58..0000000 --- a/lnet/Kernelenv.in +++ /dev/null @@ -1,6 +0,0 @@ -EXTRA_CFLAGS := -Ifs/lustre/include -Ifs/lustre/portals/include -# portals/utils/debug.c wants from userspace. sigh. -HOSTCFLAGS := -I@LINUX@/include $(EXTRA_CFLAGS) -LIBREADLINE := @LIBREADLINE@ -# 2.5's makefiles aren't nice to cross dir libraries in host programs -PTLCTLOBJS := debug.o l_ioctl.o parser.o portals.o diff --git a/lnet/Kernelenv.mk b/lnet/Kernelenv.mk deleted file mode 100644 index 7c66dfa..0000000 --- a/lnet/Kernelenv.mk +++ /dev/null @@ -1,4 +0,0 @@ -EXTRA_CFLAGS := -Ifs/lustre/include -Ifs/lustre/portals/include -HOSTCFLAGS := $(EXTRA_CFLAGS) -# the kernel doesn't want us to build archives for host binaries :/ -PTLCTLOBJS := debug.o l_ioctl.o parser.o portals.o diff --git a/lnet/Makefile.in b/lnet/Makefile.in deleted file mode 100644 index 71d0dc8..0000000 --- a/lnet/Makefile.in +++ /dev/null @@ -1,9 +0,0 @@ -subdir-m += libcfs - -cray-subdirs += portals -cray-subdirs += knals -cray-subdirs += router -cray-subdirs += tests -@CRAY_PORTALS_FALSE@subdir-m += $(cray-subdirs) - -@INCLUDE_RULES@ diff --git a/lnet/Makefile.mk b/lnet/Makefile.mk deleted file mode 100644 index 73a19df..0000000 --- a/lnet/Makefile.mk +++ /dev/null @@ -1,12 +0,0 @@ -include $(src)/Kernelenv - -# The ordering of these determines the order that each subsystem's -# module_init() functions are called in. if these are changed make sure -# they reflect the dependencies between each subsystem's _init functions. -obj-y += libcfs/ -obj-y += portals/ -obj-y += router/ -obj-y += knals/ -obj-y += tests/ - -obj-m += utils/ diff --git a/lnet/NEWS b/lnet/NEWS deleted file mode 100644 index e69de29..0000000 diff --git a/lnet/README b/lnet/README deleted file mode 100644 index e69de29..0000000 diff --git a/lnet/archdep.m4 b/lnet/archdep.m4 deleted file mode 100644 index 2f1d5636..0000000 --- a/lnet/archdep.m4 +++ /dev/null @@ -1,902 +0,0 @@ -# -------- we can't build modules unless srcdir = builddir -if test x$enable_modules != xno ; then - AC_CHECK_FILE([autoMakefile.am],[], - [AC_MSG_ERROR([At this time, Lustre does not support building kernel modules with srcdir != buildir.])]) -fi - -# -------- in kernel compilation? (2.5 only) ------------- -AC_MSG_CHECKING([if inkernel build support is requested]) -AC_ARG_ENABLE([inkernel], - AC_HELP_STRING([--enable-inkernel], - [set up 2.5 kernel makefiles]), - [],[enable_inkernel=no]) -AC_MSG_RESULT([$enable_inkernel]) -AM_CONDITIONAL(INKERNEL, test x$enable_inkernel = xyes) - -# -------- are we building against an external portals? ------- -AC_MSG_CHECKING([for Cray portals]) -AC_ARG_WITH([cray-portals], - AC_HELP_STRING([--with-cray-portals=path], - [path to cray portals]), - [ - if test "$with_cray_portals" != no; then - CRAY_PORTALS_PATH=$with_cray_portals - CRAY_PORTALS_INCLUDES="$with_cray_portals/include" - CRAY_PORTALS_LIBS="$with_cray_portals" - fi - ],[with_cray_portals=no]) -AC_SUBST(CRAY_PORTALS_PATH) -AC_MSG_RESULT([$CRAY_PORTALS_PATH]) - -AC_MSG_CHECKING([for Cray portals includes]) -AC_ARG_WITH([cray-portals-includes], - AC_HELP_STRING([--with-cray-portals-includes=path], - [path to cray portals includes]), - [ - if test "$with_cray_portals_includes" != no; then - CRAY_PORTALS_INCLUDES="$with_cray_portals_includes" - fi - ]) -AC_SUBST(CRAY_PORTALS_INCLUDES) -AC_MSG_RESULT([$CRAY_PORTALS_INCLUDES]) - -AC_MSG_CHECKING([for Cray portals libs]) -AC_ARG_WITH([cray-portals-libs], - AC_HELP_STRING([--with-cray-portals-libs=path], - [path to cray portals libs]), - [ - if test "$with_cray_portals_libs" != no; then - CRAY_PORTALS_LIBS="$with_cray_portals_libs" - fi - ]) -AC_SUBST(CRAY_PORTALS_LIBS) -AC_MSG_RESULT([$CRAY_PORTALS_LIBS]) - -if test x$CRAY_PORTALS_INCLUDES != x ; then - if test ! -r $CRAY_PORTALS_INCLUDES/portals/api.h ; then - AC_MSG_ERROR([Cray portals headers were not found in $CRAY_PORTALS_INCLUDES. Please check the paths passed to --with-cray-portals or --with-cray-portals-includes.]) - fi -fi -if test x$CRAY_PORTALS_LIBS != x ; then - if test ! -r $CRAY_PORTALS_LIBS/libportals.a ; then - AC_MSG_ERROR([Cray portals libraries were not found in $CRAY_PORTALS_LIBS. Please check the paths passed to --with-cray-portals or --with-cray-portals-libs.]) - fi -fi - -AC_MSG_CHECKING([whether to use Cray portals]) -if test x$CRAY_PORTALS_INCLUDES != x -a x$CRAY_PORTALS_LIBS != x ; then - with_cray_portals=yes - AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals]) - CRAY_PORTALS_INCLUDES="-I$CRAY_PORTALS_INCLUDES" -else - with_cray_portals=no -fi -AC_MSG_RESULT([$with_cray_portals]) -AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno) - -# ---------------------------------------- -# some tests for catamount-like systems -# ---------------------------------------- -AC_ARG_ENABLE([sysio_init], - AC_HELP_STRING([--disable-sysio-init], - [call sysio init functions when initializing liblustre]), - [],[enable_sysio_init=yes]) -AC_MSG_CHECKING([whether to initialize libsysio]) -AC_MSG_RESULT([$enable_sysio_init]) -if test x$enable_sysio_init != xno ; then - AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions]) -fi - -AC_ARG_ENABLE([urandom], - AC_HELP_STRING([--disable-urandom], - [disable use of /dev/urandom for liblustre]), - [],[enable_urandom=yes]) -AC_MSG_CHECKING([whether to use /dev/urandom for liblustre]) -AC_MSG_RESULT([$enable_urandom]) -if test x$enable_urandom != xno ; then - AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data]) -fi - -# -------- check for -lcap and -lpthread ---- -if test x$enable_liblustre = xyes ; then - AC_CHECK_LIB([cap], [cap_get_proc], - [ - CAP_LIBS="-lcap" - AC_DEFINE([HAVE_LIBCAP], 1, [use libcap]) - ], - [CAP_LIBS=""]) - AC_SUBST(CAP_LIBS) - AC_CHECK_LIB([pthread], [pthread_create], - [ - PTHREAD_LIBS="-lpthread" - AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread]) - ], - [PTHREAD_LIBS=""]) - AC_SUBST(PTHREAD_LIBS) -fi - -# -------- enable tests and utils? ------- -if test x$enable_tests = xno ; then - AC_MSG_NOTICE([disabling tests]) - enable_tests=no -fi -if test x$enable_utils = xno ; then - AC_MSG_NOTICE([disabling utilities]) - enable_utils=no -fi - -if test x$enable_modules != xno ; then - # -------- set linuxdir ------------ - AC_MSG_CHECKING([for Linux sources]) - AC_ARG_WITH([linux], - AC_HELP_STRING([--with-linux=path], - [set path to Linux source (default=/usr/src/linux)]), - [LINUX=$with_linux], - [LINUX=/usr/src/linux]) - AC_MSG_RESULT([$LINUX]) - AC_SUBST(LINUX) - if test x$enable_inkernel = xyes ; then - echo ln -s `pwd` $LINUX/fs/lustre - rm $LINUX/fs/lustre - ln -s `pwd` $LINUX/fs/lustre - fi - - # -------- linux objects (for 2.6) -- - AC_MSG_CHECKING([for Linux objects dir]) - AC_ARG_WITH([linux-obj], - AC_HELP_STRING([--with-linux-obj=path], - [set path to Linux objects dir (default=\$LINUX)]), - [LINUX_OBJ=$with_linux_obj], - [LINUX_OBJ=$LINUX]) - AC_MSG_RESULT([$LINUX_OBJ]) - AC_SUBST(LINUX_OBJ) - - # -------- check for .confg -------- - AC_ARG_WITH([linux-config], - [AC_HELP_STRING([--with-linux-config=path], - [set path to Linux .conf (default=\$LINUX_OBJ/.config)])], - [LINUX_CONFIG=$with_linux_config], - [LINUX_CONFIG=$LINUX_OBJ/.config]) - AC_SUBST(LINUX_CONFIG) - - AC_CHECK_FILE([/boot/kernel.h], - [KERNEL_SOURCE_HEADER='/boot/kernel.h'], - [AC_CHECK_FILE([/var/adm/running-kernel.h]), - [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']]) - - AC_ARG_WITH([kernel-source-header], - AC_HELP_STRING([--with-kernel-source-header=path], - [Use a different kernel version header. Consult README.kernel-source for details.]), - [KERNEL_SOURCE_HEADER=$with_kernel_source_header]) - - # -------------------- - ARCH_UM= - UML_CFLAGS= - - AC_MSG_CHECKING([if you are running user mode linux for $host_cpu]) - if test -e $LINUX/include/asm-um ; then - if test X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then - ARCH_UM='ARCH=um' - # see notes in Rules.in - UML_CFLAGS='-O0' - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT([no (asm doesn't point at asm-um)]) - fi - else - AC_MSG_RESULT([no (asm-um missing)]) - fi - - AC_SUBST(ARCH_UM) - AC_SUBST(UML_CFLAGS) - - # --------- Linux 25 ------------------ - AC_CHECK_FILE([$LINUX/include/linux/namei.h], - [ - linux25="yes" - KMODEXT=".ko" - enable_ldiskfs="yes" - BACKINGFS="ldiskfs" - ],[ - KMODEXT=".o" - linux25="no" - ]) - AC_MSG_CHECKING([if you are using Linux 2.6]) - AC_MSG_RESULT([$linux25]) - - AC_SUBST(LINUX25) - AC_SUBST(KMODEXT) - - AC_PATH_PROG(PATCH, patch, [no]) - AC_PATH_PROG(QUILT, quilt, [no]) - - if test x$enable_ldiskfs$PATCH$QUILT = xyesnono ; then - AC_MSG_ERROR([Quilt or patch are needed to build the ldiskfs module (for Linux 2.6)]) - fi -fi -AM_CONDITIONAL(LINUX25, test x$linux25 = xyes) -AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno) - -# ------- Makeflags ------------------ - -CPPFLAGS="$CPPFLAGS $CRAY_PORTALS_INCLUDES -I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include" - -# liblustre are all the same -LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1" -AC_SUBST(LLCPPFLAGS) - -LLCFLAGS="-g -Wall -fPIC" -AC_SUBST(LLCFLAGS) - -# everyone builds against portals and lustre - -if test x$enable_ldiskfs = xyes ; then - AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module]) - AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs]) - AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls]) - AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security]) -fi - -EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDES -I$PWD/portals/include -I$PWD/include" - -# these are like AC_TRY_COMPILE, but try to build modules against the -# kernel, inside the kernel-tests directory - -AC_DEFUN([LUSTRE_MODULE_CONFTEST], -[cat >conftest.c <<_ACEOF -$1 -_ACEOF -]) - -AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE], -[m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl -rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.ko -AS_IF([AC_TRY_COMMAND(cp conftest.c kernel-tests && make [$2] CC="$CC" -f $PWD/kernel-tests/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/kernel-tests) >/dev/null && AC_TRY_COMMAND([$3])], - [$4], - [_AC_MSG_LOG_CONFTEST -m4_ifvaln([$5],[$5])dnl])dnl -rm -f kernel-tests/conftest.o kernel-tests/conftest.mod.c kernel-tests/conftest.mod.o kernel-tests/conftest.ko m4_ifval([$1], [kernel-tests/conftest.c conftest.c])[]dnl -]) - -AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE], -[LUSTRE_MODULE_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[$1]], [[$2]])], - [modules], - [test -s kernel-tests/conftest.o], - [$3], [$4])]) - -AC_DEFUN([LUSTRE_MODULE_TRY_MAKE], -[LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])]) - -# ------------ include paths ------------------ - -if test x$enable_modules != xno ; then - # ------------ .config exists ---------------- - AC_CHECK_FILE([$LINUX_CONFIG],[], - [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])]) - - # ----------- make dep run? ------------------ - AC_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h - $LINUX_OBJ/include/linux/version.h - $LINUX/include/linux/config.h],[], - [AC_MSG_ERROR([Run make config in $LINUX.])]) - - # ------------ rhconfig.h includes runtime-generated bits -- - # red hat kernel-source checks - - # we know this exists after the check above. if the user - # tarred up the tree and ran make dep etc. in it, then - # version.h gets overwritten with a standard linux one. - - if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then - # This is a clean kernel-source tree, we need to - # enable extensive workarounds to get this to build - # modules - AC_CHECK_FILE([$KERNEL_SOURCE_HEADER], - [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then - AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.]) - AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.]) - AC_MSG_WARN([Consult README.kernel-source for details.]) - fi], - [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])]) - EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS" - fi - - # ------------ external module support --------------------- - MODULE_TARGET="SUBDIRS" - if test $linux25 = 'yes' ; then - makerule="$PWD/kernel-tests" - AC_MSG_CHECKING([for external module build support]) - rm -f kernel-tests/conftest.i - LUSTRE_MODULE_TRY_MAKE([],[], - [$makerule LUSTRE_KERNEL_TEST=conftest.i], - [test -s kernel-tests/conftest.i], - [ - AC_MSG_RESULT([no]) - ],[ - AC_MSG_RESULT([yes]) - makerule="_module_$makerule" - MODULE_TARGET="M" - ]) - else - makerule="_dir_$PWD/kernel-tests" - fi - AC_SUBST(MODULE_TARGET) - - # --- check that we can build modules at all - AC_MSG_CHECKING([that modules can be built]) - LUSTRE_MODULE_TRY_COMPILE([],[], - [ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_WARN([Consult config.log for details.]) - AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source]) - AC_MSG_ERROR([Kernel modules could not be built.]) - ]) - - # ------------ LINUXRELEASE and moduledir ------------------ - LINUXRELEASE= - rm -f kernel-tests/conftest.i - AC_MSG_CHECKING([for Linux release]) - LUSTRE_MODULE_TRY_MAKE( - [#include ], - [char *LINUXRELEASE; - LINUXRELEASE=UTS_RELEASE;], - [$makerule LUSTRE_KERNEL_TEST=conftest.i], - [test -s kernel-tests/conftest.i], - [ - # LINUXRELEASE="UTS_RELEASE" - eval $(grep "LINUXRELEASE=" kernel-tests/conftest.i) - ],[ - AC_MSG_RESULT([unknown]) - AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.]) - ]) - rm -f kernel-tests/conftest.i - if test x$LINUXRELEASE = x ; then - AC_MSG_RESULT([unknown]) - AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.]) - fi - AC_MSG_RESULT([$LINUXRELEASE]) - AC_SUBST(LINUXRELEASE) - - moduledir='/lib/modules/'$LINUXRELEASE/kernel - modulefsdir='$(moduledir)/fs/$(PACKAGE)' - modulenetdir='$(moduledir)/net/$(PACKAGE)' - - AC_SUBST(moduledir) - AC_SUBST(modulefsdir) - AC_SUBST(modulenetdir) - - # ------------ RELEASE -------------------------------- - AC_MSG_CHECKING([for Lustre release]) - RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`" - AC_MSG_RESULT($RELEASE) - AC_SUBST(RELEASE) - - # ---------- Portals flags -------------------- - - AC_MSG_CHECKING([for zero-copy TCP support]) - AC_ARG_ENABLE([zerocopy], - AC_HELP_STRING([--disable-zerocopy], - [disable socknal zerocopy]), - [],[enable_zerocopy='yes']) - if test x$enable_zerocopy = xno ; then - AC_MSG_RESULT([no (by request)]) - else - ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`" - if test "$ZCCD" != 0 ; then - AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP]) - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT([no (no kernel support)]) - fi - fi - - AC_ARG_ENABLE([affinity], - AC_HELP_STRING([--disable-affinity], - [disable process/irq affinity]), - [],[enable_affinity='yes']) - - AC_MSG_CHECKING([for CPU affinity support]) - if test x$enable_affinity = xno ; then - AC_MSG_RESULT([no (by request)]) - else - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - struct task_struct t; - #ifdef CPU_ARRAY_SIZE - cpumask_t m; - #else - unsigned long m; - #endif - set_cpus_allowed(&t, m); - ],[ - AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support]) - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no (no kernel support)]) - ]) - fi - - ##################################### - - AC_MSG_CHECKING([if quadrics kernel headers are present]) - if test -d $LINUX/drivers/net/qsnet ; then - AC_MSG_RESULT([yes]) - QSWNAL="qswnal" - AC_MSG_CHECKING([for multirail EKC]) - if test -f $LINUX/include/elan/epcomms.h; then - AC_MSG_RESULT([supported]) - QSWCPPFLAGS="-DMULTIRAIL_EKC=1" - else - AC_MSG_RESULT([not supported]) - if test -d $LINUX/drivers/net/qsnet/include; then - QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include" - else - QSWCPPFLAGS="-I$LINUX/include/linux" - fi - fi - else - AC_MSG_RESULT([no]) - QSWNAL="" - QSWCPPFLAGS="" - fi - AC_SUBST(QSWCPPFLAGS) - AC_SUBST(QSWNAL) - - AC_MSG_CHECKING([if gm support was requested]) - AC_ARG_WITH([gm], - AC_HELP_STRING([--with-gm=path], - [build gmnal against path]), - [ - case $with_gm in - yes) - AC_MSG_RESULT([yes]) - GMCPPFLAGS="-I/usr/local/gm/include" - GMNAL="gmnal" - ;; - no) - AC_MSG_RESULT([no]) - GMCPPFLAGS="" - GMNAL="" - ;; - *) - AC_MSG_RESULT([yes]) - GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm" - GMNAL="gmnal" - ;; - esac - ],[ - AC_MSG_RESULT([no]) - GMCPPFLAGS="" - GMNAL="" - ]) - AC_SUBST(GMCPPFLAGS) - AC_SUBST(GMNAL) - - if test $linux25 = 'no' ; then - #### OpenIB - AC_MSG_CHECKING([if OpenIB kernel headers are present]) - OPENIBCPPFLAGS="-I$LINUX/drivers/infiniband/include -DIN_TREE_BUILD" - EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS" - EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS" - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - struct ib_device_properties props; - return 0; - ],[ - AC_MSG_RESULT([yes]) - OPENIBNAL="openibnal" - ],[ - AC_MSG_RESULT([no]) - OPENIBNAL="" - OPENIBCPPFLAGS="" - ]) - EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save" - AC_SUBST(OPENIBCPPFLAGS) - AC_SUBST(OPENIBNAL) - fi - - #### Infinicon IB - AC_MSG_CHECKING([if Infinicon IB kernel headers are present]) - # for how the only infinicon ib build has headers in /usr/include/iba - IIBCPPFLAGS="-I/usr/include -DIN_TREE_BUILD" - EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS" - EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS" - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - IBT_INTERFACE_UNION interfaces; - FSTATUS rc; - - rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2, - &interfaces); - - return rc == FSUCCESS ? 0 : 1; - ],[ - AC_MSG_RESULT([yes]) - IIBNAL="iibnal" - ],[ - AC_MSG_RESULT([no]) - IIBNAL="" - IIBCPPFLAGS="" - ]) - EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save" - AC_SUBST(IIBCPPFLAGS) - AC_SUBST(IIBNAL) - - #### Rapid Array - AC_MSG_CHECKING([if RapidArray kernel headers are present]) - # placeholder - RACPPFLAGS="-I/tmp" - EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS" - EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS" - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - #include - ],[ - RAP_RETURN rc; - RAP_PVOID dev_handle; - - rc = RapkGetDeviceByIndex(0, NULL, &dev_handle); - - return rc == RAP_SUCCESS ? 0 : 1; - ],[ - AC_MSG_RESULT([yes]) - RANAL="ranal" - ],[ - AC_MSG_RESULT([no]) - RANAL="" - RACPPFLAGS="" - ]) - EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save" - AC_SUBST(RACPPFLAGS) - AC_SUBST(RANAL) - - # ---------- Red Hat 2.4.18 has iobuf->dovary -------------- - # But other kernels don't - - AC_MSG_CHECKING([if struct kiobuf has a dovary field]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - struct kiobuf iobuf; - iobuf.dovary = 1; - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # ----------- 2.6.4 no longer has page->list --------------- - AC_MSG_CHECKING([if struct page has a list field]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - struct page page; - &page.list; - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # ---------- Red Hat 2.4.20 backports some 2.5 bits -------- - # This needs to run after we've defined the KCPPFLAGS - - AC_MSG_CHECKING([if task_struct has a sighand field]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - struct task_struct p; - p.sighand = NULL; - ],[ - AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches]) - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # ---------- 2.4.20 introduced cond_resched -------------- - - AC_MSG_CHECKING([if kernel offers cond_resched]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - cond_resched(); - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # --------- zap_page_range(vma) -------------------------------- - AC_MSG_CHECKING([if zap_pag_range with vma parameter]) - ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`" - if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then - AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter]) - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - - # ---------- Red Hat 2.4.21 backports some more 2.5 bits -------- - - AC_MSG_CHECKING([if kernel defines PDE]) - HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`" - if test "$HAVE_PDE" != 0 ; then - AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE]) - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - - AC_MSG_CHECKING([if kernel passes struct file to direct_IO]) - HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`" - if test "$HAVE_DIO_FILE" != 0 ; then - AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO]) - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - - AC_MSG_CHECKING([if kernel defines cpu_online()]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - cpu_online(0); - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found]) - ],[ - AC_MSG_RESULT([no]) - ]) - AC_MSG_CHECKING([if kernel defines cpumask_t]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - return sizeof (cpumask_t); - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # ---------- RHEL kernels define page_count in mm_inline.h - AC_MSG_CHECKING([if kernel has mm_inline.h header]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - #ifndef page_count - #error mm_inline.h does not define page_count - #endif - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # ---------- inode->i_alloc_sem -------------- - AC_MSG_CHECKING([if struct inode has i_alloc_sem]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - #include - ],[ - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24)) - #error "down_read_trylock broken before 2.4.24" - #endif - struct inode i; - return (char *)&i.i_alloc_sem - (char *)&i; - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem]) - ],[ - AC_MSG_RESULT([no]) - ]) - - - # ---------- modules? ------------------------ - AC_MSG_CHECKING([for module support]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - #ifndef CONFIG_MODULES - #error CONFIG_MODULES not #defined - #endif - ],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_ERROR([module support is required to build Lustre kernel modules.]) - ]) - - # ---------- modversions? -------------------- - AC_MSG_CHECKING([for MODVERSIONS]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - #ifndef CONFIG_MODVERSIONS - #error CONFIG_MODVERSIONS not #defined - #endif - ],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # ------------ preempt ----------------------- - AC_MSG_CHECKING([if preempt is enabled]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - #ifndef CONFIG_PREEMPT - #error CONFIG_PREEMPT is not #defined - #endif - ],[ - AC_MSG_RESULT([yes]) - AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.]) - ],[ - AC_MSG_RESULT([no]) - ]) - - # ------------ kallsyms (so software watchdogs produce useful stacks) - AC_MSG_CHECKING([if kallsyms is enabled]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - #ifndef CONFIG_KALLSYMS - #error CONFIG_KALLSYMS is not #defined - #endif - ],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - if test "x$ARCH_UM" = "x" ; then - AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.]) - fi - ]) - - # ------------ check for our show_task patch - AC_MSG_CHECKING([if kernel exports show_task]) - have_show_task=0 - for file in ksyms sched ; do - if grep -q "EXPORT_SYMBOL(show_task)" \ - "$LINUX/kernel/$file.c" 2>/dev/null ; then - have_show_task=1 - break - fi - done - if test x$have_show_task = x1 ; then - AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported]) - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - - case $BACKINGFS in - ext3) - # --- Check that ext3 and ext3 xattr are enabled in the kernel - AC_MSG_CHECKING([that ext3 is enabled in the kernel]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - #ifndef CONFIG_EXT3_FS - #ifndef CONFIG_EXT3_FS_MODULE - #error CONFIG_EXT3_FS not #defined - #endif - #endif - ],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel (CONFIG_EXT3_FS)]) - ]) - - AC_MSG_CHECKING([that extended attributes for ext3 are enabled in the kernel]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[ - #ifndef CONFIG_EXT3_FS_XATTR - #error CONFIG_EXT3_FS_XATTR not #defined - #endif - ],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel (CONFIG_EXT3_FS_XATTR.)]) - AC_MSG_WARN([This build may fail.]) - ]) - ;; - ldiskfs) - AC_MSG_CHECKING([if fshooks are present]) - LUSTRE_MODULE_TRY_COMPILE( - [ - #include - ],[],[ - AC_MSG_RESULT([yes]) - LDISKFS_SERIES="2.6-suse.series" - ],[ - AC_MSG_RESULT([no]) - LDISKFS_SERIES="2.6-vanilla.series" - ]) - AC_SUBST(LDISKFS_SERIES) - # --- check which ldiskfs series we should use - ;; - esac # $BACKINGFS -fi - -AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal") -AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal") -AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal") -AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal") -AM_CONDITIONAL(BUILD_RANAL, test x$RANAL = "xranal") - -# portals/utils/portals.c -AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h]) -AC_CHECK_FUNCS([gethostbyname socket connect]) - -# portals/utils/debug.c -AC_CHECK_HEADERS([linux/version.h]) - -# include/liblustre.h -AC_CHECK_HEADERS([asm/page.h sys/user.h stdint.h]) - -# liblustre/llite_lib.h -AC_CHECK_HEADERS([xtio.h file.h]) - -# liblustre/dir.c -AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h]) - -# liblustre/lutil.c -AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h]) -AC_CHECK_FUNCS([inet_ntoa]) - -CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS" -EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS" -AC_SUBST(EXTRA_KCFLAGS) - -echo "CPPFLAGS: $CPPFLAGS" -echo "LLCPPFLAGS: $LLCPPFLAGS" -echo "CFLAGS: $CFLAGS" -echo "EXTRA_KCFLAGS: $EXTRA_KCFLAGS" -echo "LLCFLAGS: $LLCFLAGS" - -ENABLE_INIT_SCRIPTS=0 -if test x$enable_utils = xyes ; then - AC_MSG_CHECKING([whether to install init scripts]) - # our scripts only work on red hat systems - if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then - ENABLE_INIT_SCRIPTS=1 - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi -fi -AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1") -AC_SUBST(ENABLE_INIT_SCRIPTS) diff --git a/lnet/autoMakefile.am b/lnet/autoMakefile.am deleted file mode 100644 index f2ba240..0000000 --- a/lnet/autoMakefile.am +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -SUBDIRS = portals libcfs knals unals router tests doc utils include \ - autoconf - -sources: diff --git a/lnet/autoconf/.cvsignore b/lnet/autoconf/.cvsignore deleted file mode 100644 index 282522d..0000000 --- a/lnet/autoconf/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/lnet/autoconf/Makefile.am b/lnet/autoconf/Makefile.am deleted file mode 100644 index f65d2c0..0000000 --- a/lnet/autoconf/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST := lustre-portals.m4 diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 deleted file mode 100644 index 0cb49a2..0000000 --- a/lnet/autoconf/lustre-lnet.m4 +++ /dev/null @@ -1,483 +0,0 @@ -# -# LP_CONFIG_ZEROCOPY -# -# check if zerocopy is available/wanted -# -AC_DEFUN([LP_CONFIG_ZEROCOPY], -[AC_MSG_CHECKING([for zero-copy TCP support]) -AC_ARG_ENABLE([zerocopy], - AC_HELP_STRING([--disable-zerocopy], - [disable socknal zerocopy]), - [],[enable_zerocopy='yes']) -if test x$enable_zerocopy = xno ; then - AC_MSG_RESULT([no (by request)]) -else - ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`" - if test "$ZCCD" != 0 ; then - AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP]) - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT([no (no kernel support)]) - fi -fi -]) - -# -# LP_CONFIG_AFFINITY -# -# check if cpu affinity is available/wanted -# -AC_DEFUN([LP_CONFIG_AFFINITY], -[AC_ARG_ENABLE([affinity], - AC_HELP_STRING([--disable-affinity], - [disable process/irq affinity]), - [],[enable_affinity='yes']) - -AC_MSG_CHECKING([for CPU affinity support]) -if test x$enable_affinity = xno ; then - AC_MSG_RESULT([no (by request)]) -else - LB_LINUX_TRY_COMPILE([ - #include - ],[ - struct task_struct t; - #ifdef CPU_ARRAY_SIZE - cpumask_t m; - #else - unsigned long m; - #endif - set_cpus_allowed(&t, m); - ],[ - AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support]) - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no (no kernel support)]) - ]) -fi -]) - -# -# LP_CONFIG_QUADRICS -# -# check if quadrics support is in this kernel -# -AC_DEFUN([LP_CONFIG_QUADRICS], -[AC_MSG_CHECKING([if quadrics kernel headers are present]) -if test -d $LINUX/drivers/net/qsnet ; then - AC_MSG_RESULT([yes]) - QSWNAL="qswnal" - AC_MSG_CHECKING([for multirail EKC]) - if test -f $LINUX/include/elan/epcomms.h; then - AC_MSG_RESULT([supported]) - QSWCPPFLAGS="-DMULTIRAIL_EKC=1" - else - AC_MSG_RESULT([not supported]) - if test -d $LINUX/drivers/net/qsnet/include; then - QSWCPPFLAGS="-I$LINUX/drivers/net/qsnet/include" - else - QSWCPPFLAGS="-I$LINUX/include/linux" - fi - fi -else - AC_MSG_RESULT([no]) - QSWNAL="" - QSWCPPFLAGS="" -fi -AC_SUBST(QSWCPPFLAGS) -AC_SUBST(QSWNAL) -]) - -# -# LP_CONFIG_GM -# -# check if infiniband support is available -# -AC_DEFUN([LP_CONFIG_GM], -[AC_MSG_CHECKING([if gm support was requested]) -AC_ARG_WITH([gm], - AC_HELP_STRING([--with-gm=path], - [build gmnal against path]), - [ - case $with_gm in - yes) - AC_MSG_RESULT([yes]) - GMCPPFLAGS="-I/usr/local/gm/include" - GMNAL="gmnal" - ;; - no) - AC_MSG_RESULT([no]) - GMCPPFLAGS="" - GMNAL="" - ;; - *) - AC_MSG_RESULT([yes]) - GMCPPFLAGS="-I$with_gm/include -I$with_gm/drivers -I$with_gm/drivers/linux/gm" - GMNAL="gmnal" - ;; - esac - ],[ - AC_MSG_RESULT([no]) - GMCPPFLAGS="" - GMNAL="" - ]) -AC_SUBST(GMCPPFLAGS) -AC_SUBST(GMNAL) -]) - -# -# LP_CONFIG_OPENIB -# -# check for OpenIB in the kernel -AC_DEFUN([LP_CONFIG_OPENIB], -[AC_MSG_CHECKING([if OpenIB kernel headers are present]) -OPENIBCPPFLAGS="-I$LINUX/drivers/infiniband/include -DIN_TREE_BUILD" -EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS" -LB_LINUX_TRY_COMPILE( - [ - #include - ],[ - struct ib_device_properties props; - return 0; - ],[ - AC_MSG_RESULT([yes]) - OPENIBNAL="openibnal" - ],[ - AC_MSG_RESULT([no]) - OPENIBNAL="" - OPENIBCPPFLAGS="" - ]) -EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save" -AC_SUBST(OPENIBCPPFLAGS) -AC_SUBST(OPENIBNAL) -]) - -# -# LP_CONFIG_IIB -# -# check for infinicon infiniband support -# -AC_DEFUN([LP_CONFIG_IIB], -[AC_MSG_CHECKING([if Infinicon IB kernel headers are present]) -# for how the only infinicon ib build has headers in /usr/include/iba -IIBCPPFLAGS="-I/usr/include -DIN_TREE_BUILD" -EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS" -LB_LINUX_TRY_COMPILE([ - #include -],[ - IBT_INTERFACE_UNION interfaces; - FSTATUS rc; - - rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2, - &interfaces); - - return rc == FSUCCESS ? 0 : 1; -],[ - AC_MSG_RESULT([yes]) - IIBNAL="iibnal" -],[ - AC_MSG_RESULT([no]) - IIBNAL="" - IIBCPPFLAGS="" -]) -EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save" -AC_SUBST(IIBCPPFLAGS) -AC_SUBST(IIBNAL) -]) - -# -# LP_STRUCT_PAGE_LIST -# -# 2.6.4 no longer has page->list -# -AC_DEFUN([LP_STRUCT_PAGE_LIST], -[AC_MSG_CHECKING([if struct page has a list field]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - struct page page; - &page.list; -],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LP_STRUCT_SIGHAND -# -# red hat 2.4 adds sighand to struct task_struct -# -AC_DEFUN([LP_STRUCT_SIGHAND], -[AC_MSG_CHECKING([if task_struct has a sighand field]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - struct task_struct p; - p.sighand = NULL; -],[ - AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches]) - AC_MSG_RESULT([yes]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LP_FUNC_CPU_ONLINE -# -# cpu_online is different in rh 2.4, vanilla 2.4, and 2.6 -# -AC_DEFUN([LP_FUNC_CPU_ONLINE], -[AC_MSG_CHECKING([if kernel defines cpu_online()]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - cpu_online(0); -],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LP_TYPE_CPUMASK_T -# -# same goes for cpumask_t -# -AC_DEFUN([LP_TYPE_CPUMASK_T], -[AC_MSG_CHECKING([if kernel defines cpumask_t]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - return sizeof (cpumask_t); -],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LP_FUNC_SHOW_TASK -# -# we export show_task(), but not all kernels have it (yet) -# -AC_DEFUN([LP_FUNC_SHOW_TASK], -[AC_MSG_CHECKING([if kernel exports show_task]) -have_show_task=0 -for file in ksyms sched ; do - if grep -q "EXPORT_SYMBOL(show_task)" \ - "$LINUX/kernel/$file.c" 2>/dev/null ; then - have_show_task=1 - break - fi -done -if test x$have_show_task = x1 ; then - AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported]) - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi -]) - -# -# LP_PROG_LINUX -# -# Portals linux kernel checks -# -AC_DEFUN([LP_PROG_LINUX], -[LP_CONFIG_ZEROCOPY -LP_CONFIG_AFFINITY -LP_CONFIG_QUADRICS -LP_CONFIG_GM -if test $linux25 = 'no' ; then - LP_CONFIG_OPENIB -fi -LP_CONFIG_IIB - -LP_STRUCT_PAGE_LIST -LP_STRUCT_SIGHAND -LP_FUNC_CPU_ONLINE -LP_TYPE_CPUMASK_T -LP_FUNC_SHOW_TASK -]) - -# -# LP_PATH_DEFAULTS -# -# default paths for installed files -# -AC_DEFUN([LP_PATH_DEFAULTS], -[ -]) - -# -# LP_CONFIGURE -# -# other configure checks -# -AC_DEFUN([LP_CONFIGURE], -[# portals/utils/portals.c -AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h]) -AC_CHECK_FUNCS([gethostbyname socket connect]) - -# portals/utils/debug.c -AC_CHECK_HEADERS([linux/version.h]) - -AC_CHECK_TYPE([spinlock_t], - [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])], - [], - [#include ]) - -# -------- Check for required packages -------------- - -# this doesn't seem to work on older autoconf -# AC_CHECK_LIB(readline, readline,,) -AC_MSG_CHECKING([for readline support]) -AC_ARG_ENABLE(readline, - AC_HELP_STRING([--disable-readline], - [do not use readline library]), - [],[enable_readline='yes']) -AC_MSG_RESULT([$enable_readline]) -if test x$enable_readline = xyes ; then - LIBREADLINE="-lreadline -lncurses" - AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available]) -else - LIBREADLINE="" -fi -AC_SUBST(LIBREADLINE) - -AC_MSG_CHECKING([if efence debugging support is requested]) -AC_ARG_ENABLE(efence, - AC_HELP_STRING([--enable-efence], - [use efence library]), - [],[enable_efence='no']) -AC_MSG_RESULT([$enable_efence]) -if test "$enable_efence" = "yes" ; then - LIBEFENCE="-lefence" - AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested]) -else - LIBEFENCE="" -fi -AC_SUBST(LIBEFENCE) - -# -------- enable acceptor libwrap (TCP wrappers) support? ------- -AC_MSG_CHECKING([if libwrap support is requested]) -AC_ARG_ENABLE([libwrap], - AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]), - [case "${enableval}" in - yes) enable_libwrap=yes ;; - no) enable_libwrap=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;; - esac],[enable_libwrap=no]) -AC_MSG_RESULT([$enable_libwrap]) -if test x$enable_libwrap = xyes ; then - LIBWRAP="-lwrap" - AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested]) -else - LIBWRAP="" -fi -AC_SUBST(LIBWRAP) - -# ---------------------------------------- -# some tests for catamount-like systems -# ---------------------------------------- -AC_ARG_ENABLE([sysio_init], - AC_HELP_STRING([--disable-sysio-init], - [call sysio init functions when initializing liblustre]), - [],[enable_sysio_init=yes]) -AC_MSG_CHECKING([whether to initialize libsysio]) -AC_MSG_RESULT([$enable_sysio_init]) -if test x$enable_sysio_init != xno ; then - AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions]) -fi - -AC_ARG_ENABLE([urandom], - AC_HELP_STRING([--disable-urandom], - [disable use of /dev/urandom for liblustre]), - [],[enable_urandom=yes]) -AC_MSG_CHECKING([whether to use /dev/urandom for liblustre]) -AC_MSG_RESULT([$enable_urandom]) -if test x$enable_urandom != xno ; then - AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data]) -fi - -# -------- check for -lcap and -lpthread ---- -if test x$enable_liblustre = xyes ; then - AC_CHECK_LIB([cap], [cap_get_proc], - [ - CAP_LIBS="-lcap" - AC_DEFINE([HAVE_LIBCAP], 1, [use libcap]) - ], - [CAP_LIBS=""]) - AC_SUBST(CAP_LIBS) - AC_CHECK_LIB([pthread], [pthread_create], - [ - PTHREAD_LIBS="-lpthread" - AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread]) - ], - [PTHREAD_LIBS=""]) - AC_SUBST(PTHREAD_LIBS) -fi -]) - -# -# LP_CONDITIONALS -# -# AM_CONDITOINAL defines for portals -# -AC_DEFUN([LP_CONDITIONALS], -[AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal") -AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal") -AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal") -AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal") -]) - -# -# LP_CONFIG_FILES -# -# files that should be generated with AC_OUTPUT -# -AC_DEFUN([LP_CONFIG_FILES], -[AC_CONFIG_FILES([ -portals/Kernelenv -portals/Makefile -portals/autoMakefile -portals/autoconf/Makefile -portals/doc/Makefile -portals/include/Makefile -portals/include/linux/Makefile -portals/include/portals/Makefile -portals/knals/Makefile -portals/knals/autoMakefile -portals/knals/gmnal/Makefile -portals/knals/gmnal/autoMakefile -portals/knals/iibnal/Makefile -portals/knals/iibnal/autoMakefile -portals/knals/openibnal/Makefile -portals/knals/openibnal/autoMakefile -portals/knals/qswnal/Makefile -portals/knals/qswnal/autoMakefile -portals/knals/socknal/Makefile -portals/knals/socknal/autoMakefile -portals/knals/lonal/Makefile -portals/knals/lonal/autoMakefile -portals/libcfs/Makefile -portals/libcfs/autoMakefile -portals/portals/Makefile -portals/portals/autoMakefile -portals/router/Makefile -portals/router/autoMakefile -portals/tests/Makefile -portals/tests/autoMakefile -portals/unals/Makefile -portals/utils/Makefile -]) -]) diff --git a/lnet/autogen.sh b/lnet/autogen.sh deleted file mode 100644 index 9deed73..0000000 --- a/lnet/autogen.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -aclocal && -automake --add-missing && -${AUTOCONF:-autoconf} diff --git a/lnet/build.m4 b/lnet/build.m4 deleted file mode 100644 index f158396..0000000 --- a/lnet/build.m4 +++ /dev/null @@ -1,127 +0,0 @@ -# ---------- other tests and settings --------- - -AC_CHECK_TYPE([spinlock_t], - [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])], - [], - [#include ]) - -# --------- unsigned long long sane? ------- - -AC_CHECK_SIZEOF(unsigned long long, 0) -echo "---> size SIZEOF $SIZEOF_unsigned_long_long" -echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long" -if test $ac_cv_sizeof_unsigned_long_long != 8 ; then - AC_MSG_ERROR([** we assume that sizeof(long long) == 8. Tell phil@clusterfs.com]) -fi - -# directories for binaries -ac_default_prefix=/usr - -# mount.lustre -rootsbindir='/sbin' -AC_SUBST(rootsbindir) -sysconfdir='/etc' -AC_SUBST(sysconfdir) -# Directories for documentation and demos. -docdir='${datadir}/doc/$(PACKAGE)' -AC_SUBST(docdir) -demodir='$(docdir)/demo' -AC_SUBST(demodir) -pkgexampledir='${pkgdatadir}/examples' -AC_SUBST(pkgexampledir) -pymoddir='${pkglibdir}/python/Lustre' -AC_SUBST(pymoddir) - -# ---------- BAD gcc? ------------ -AC_PROG_RANLIB -AC_PROG_CC -AC_MSG_CHECKING([for buggy compiler]) -CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"` -bad_cc() { - AC_MSG_RESULT([buggy compiler found!]) - echo - echo " '$CC_VERSION'" - echo " has been known to generate bad code, " - echo " please get an updated compiler." - AC_MSG_ERROR([sorry]) -} -TMP_VERSION=`echo $CC_VERSION | cut -c 1-16` -if test "$TMP_VERSION" = "gcc version 2.95"; then - bad_cc -fi -case "$CC_VERSION" in - # ost_pack_niobuf putting 64bit NTOH temporaries on the stack - # without "sub $0xc,%esp" to protect the stack from being - # stomped on by interrupts (bug 606) - "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)") - bad_cc - ;; - # mandrake's similar sub 0xc compiler bug - # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2 - "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)") - bad_cc - ;; - # unpatched 'gcc' on rh9. miscompiles a - # struct = (type) { .member = value, }; - # asignment in the iibnal where the struct is a mix - # of u64 and u32 bit-fields. - "gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)") - bad_cc - ;; - *) - AC_MSG_RESULT([no known problems]) - ;; -esac -# end ------ BAD gcc? ------------ - -# -------- Check for required packages -------------- - -# this doesn't seem to work on older autoconf -# AC_CHECK_LIB(readline, readline,,) -AC_MSG_CHECKING([for readline support]) -AC_ARG_ENABLE(readline, - AC_HELP_STRING([--disable-readline], - [do not use readline library]), - [],[enable_readline='yes']) -AC_MSG_RESULT([$enable_readline]) -if test x$enable_readline = xyes ; then - LIBREADLINE="-lreadline -lncurses" - AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available]) -else - LIBREADLINE="" -fi -AC_SUBST(LIBREADLINE) - -AC_MSG_CHECKING([if efence debugging support is requested]) -AC_ARG_ENABLE(efence, - AC_HELP_STRING([--enable-efence], - [use efence library]), - [],[enable_efence='no']) -AC_MSG_RESULT([$enable_efence]) -if test "$enable_efence" = "yes" ; then - LIBEFENCE="-lefence" - AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested]) -else - LIBEFENCE="" -fi -AC_SUBST(LIBEFENCE) - -# -------- enable acceptor libwrap (TCP wrappers) support? ------- -AC_MSG_CHECKING([if libwrap support is requested]) -AC_ARG_ENABLE([libwrap], - AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]), - [case "${enableval}" in - yes) enable_libwrap=yes ;; - no) enable_libwrap=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;; - esac],[enable_libwrap=no]) -AC_MSG_RESULT([$enable_libwrap]) -if test x$enable_libwrap = xyes ; then - LIBWRAP="-lwrap" - AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested]) -else - LIBWRAP="" -fi -AC_SUBST(LIBWRAP) - -AC_SUBST(LIBS) diff --git a/lnet/doc/.cvsignore b/lnet/doc/.cvsignore deleted file mode 100644 index 827dca4..0000000 --- a/lnet/doc/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile -Makefile.in -*.eps -*.pdf diff --git a/lnet/doc/Data-structures b/lnet/doc/Data-structures deleted file mode 100644 index b5532b1..0000000 --- a/lnet/doc/Data-structures +++ /dev/null @@ -1,65 +0,0 @@ -In this document I will try to draw the data structures and how they -interrelate in the Portals 3 reference implementation. It is probably -best shown with a drawing, so there may be an additional xfig or -Postscript figure. - - -MEMORY POOLS: ------------- - -First, a digression on memory allocation in the library. As mentioned -in the NAL Writer's Guide, the library does not link against any -standard C libraries and as such is unable to dynamically allocate -memory on its own. It requires that the NAL implement a method -for allocation that is appropriate for the protection domain in -which the library lives. This is only called when a network -interface is initialized to allocate the Portals object pools. - -These pools are preallocate blocks of objects that the library -can rapidly make active and manage with a minimum of overhead. -It is also cuts down on overhead for setting up structures -since the NAL->malloc() callback does not need to be called -for each object. - -The objects are maintained on a per-object type singly linked free -list and contain a pointer to the next free object. This pointer -is NULL if the object is not on the free list and is non-zero -if it is on the list. The special sentinal value of 0xDEADBEEF -is used to mark the end of the free list since NULL could -indicate that the last object in the list is not free. - -When one of the lib_*_alloc() functions is called, the library -returns the head of the free list and advances the head pointer -to the next item on the list. The special case of 0xDEADBEEF is -checked and a NULL pointer is returned if there are no more -objects of this type available. The lib_*_free() functions -are even simpler -- check to ensure that the object is not already -free, set its next pointer to the current head and then set -the head to be this newly freed object. - -Since C does not have templates, I did the next best thing and wrote -the memory pool allocation code as a macro that expands based on the -type of the argument. The mk_alloc(T) macro expands to -write the _lib_T_alloc() and lib_T_free() functions. -It requires that the object have a pointer of the type T named -"next_free". There are also functions that map _lib_T_alloc() -to lib_T_alloc() so that the library can add some extra -functionality to the T constructor. - - - -LINKED LISTS: ------------- - -Many of the active Portals objects are stored in doubly linked lists -when they are active. These are always implemented with the pointer -to the next object and a pointer to the next pointer of the -previous object. This avoids the "dummy head" object or -special cases for inserting at the beginning or end of the list. -The pointer manipulations are a little hairy at times, but -I hope that they are understandable. - -The actual linked list code is implemented as macros in , -although the object has to know about - - diff --git a/lnet/doc/Makefile.am b/lnet/doc/Makefile.am deleted file mode 100644 index b7f6252..0000000 --- a/lnet/doc/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -LYX2PDF = lyx --export pdf -LYX2TXT = lyx --export text -LYX2HTML = lyx --export html -SUFFIXES = .lin .lyx .pdf .sgml .html .txt .fig .eps - -if DOC - DOCS = portals3.pdf -else - DOCS = -endif - -IMAGES = file.eps flow_new.eps get.eps mpi.eps portals.eps put.eps -LYXFILES= portals3.lyx - -MAINTAINERCLEANFILES = $(IMAGES) $(DOCS) $(GENERATED) -GENERATED = -EXTRA_DIST = $(DOCS) $(IMAGES) $(LYXFILES) - -all: $(DOCS) - -# update date and version in document -date := $(shell date +%x) -tag := $(shell echo '$$Name: $$' | sed -e 's/^\$$Na''me: *\$$$$/HEAD/; s/^\$$Na''me: \(.*\) \$$$$/\1/') -addversion = sed -e 's|@T''AG@|$(tag)|g; s|@VER''SION@|$(VERSION)|g; s|@DA''TE@|$(date)|g' - -# Regenerate when the $(VERSION) or $Name: $ changes. -.INTERMEDIATE: $(GENERATED) -$(GENERATED) : %.lyx: %.lin Makefile - $(addversion) $< > $@ - -.lyx.pdf: - @$(LYX2PDF) $< || printf "\n*** Warning: not creating PDF docs; install lyx to rectify this\n" - -.lyx.txt: - @$(LYX2TXT) $< || printf "\n*** Warning: not creating text docs; install lyx to rectify this\n" -.lyx.html: - @$(LYX2HTML) $< || printf "\n*** Warning: not creating HTML docs; install lyx to rectify this\n" -.fig.eps: - -fig2dev -L eps $< > $@ - -portals3.pdf portals3.txt portals3.html: $(IMAGES) portals3.lyx - -syncweb: portals3.pdf -# cp lustre.pdf /usr/src/www/content/lustre/docs/lustre.pdf -# ( cd /usr/src/www ; make lustre ; make synclustre ) - diff --git a/lnet/doc/Message-life-cycle b/lnet/doc/Message-life-cycle deleted file mode 100644 index e8cc7e2..0000000 --- a/lnet/doc/Message-life-cycle +++ /dev/null @@ -1,118 +0,0 @@ -This documents the life cycle of message as it arrives and is handled by -a basic async, packetized NAL. There are four types of messages that have -slightly different life cycles, so they are addressed independently. - - -Put request ------------ - -1. NAL notices that there is a incoming message header on the network -and reads an ptl_hdr_t in from the wire. - -2. It may store additional NAL specific data that provides context -for this event in a void* that it will interpret in some fashion -later. - -3. The NAL calls lib_parse() with a pointer to the header and its -private data structure. - -4. The library decodes the header and may build a message state -object that describes the event to be written and the ACK to be -sent, if any. It then calls nal->recv() with the private data -that the NAL passed in, a pointer to the message state object -and a translated user address. - - The NAL will have been given a chance to pretranslate - all user addresses when the buffers are created. This - process is described in the NAL-HOWTO. - -5. The NAL should restore what ever context it required from the -private data pointer, begin receiving the bytes and possibly store -some extra state of its own. It should return at this point. - - - -Get request ------------ - -1. As with a Put, the NAL notices the incoming message header and -passes it to lib_parse(). - -2. The library decodes the header and calls nal->recv() with a -zero byte length, offset and destination to instruct it to clean -up the wire after reading the header. The private data will -be passed in as well, allowing the NAL to retrieve any state -or context that it requires. - -3. The library may build a message state object to possibly -write an event log or invalidate a memory region. - -4. The library will build a ptl_msg_t header that specifies the -Portals protocol information for delivery at the remote end. - -5. The library calls nal->send() with the pre-built header, -the optional message state object, the four part address -component, a translated user pointer + offset, and some -other things. - -6. The NAL is to put the header on the wire or copy it at -this point (since it off the stack). It should store some -amount of state about its current position in the message and -the destination address. - -7. And then return to the library. - - -Reply request -------------- - -1. Starting at "The library decodes the header..." - -2. The library decodes the header and calls nal->recv() -to bring in the rest of the message. Flow continues in -exactly the same fashion as with all other receives. - - -Ack request ------------ - -1. The library decodes the header, builds the appropriate data -structures for the event in a message state object and calls nal->recv() -with a zero byte length, etc. - - -Packet arrival --------------- - -1. The NAL should notice the arrival of a packet, retrieve whatever -state it needs from the message ID or other NAL specific header data -and place the data bytes directly into the user address that were -given to nal->recv(). - - How this happens is outside the scope of the Portals library - and soley determined by the NAL... - -2. If this is the last packet in a message, the NAL should retrieve -the lib_msg_t *cookie that it was given in the call to nal->recv() -and pass it to lib_finalize(). lib_finalize() may call nal->send() -to send an ACK, nal->write() to record an entry in the event log, -nal->invalidate() to unregister a region of memory or do nothing at all. - -3. It should then clean up any remaining NAL specific state about -the message and go back into the main loop. - - -Outgoing packets ----------------- - -1. When the NAL has pending output, it should put the packets on -the wire wrapped with whatever implementation specified wrappers. - -2. Once it has output all the packets of a message it should -call lib_finalize() with the message state object that was -handed to nal->send(). This will allows the library to clean -up its state regarding the message and write any pending event -entries. - - - diff --git a/lnet/doc/NAL-HOWTO b/lnet/doc/NAL-HOWTO deleted file mode 100644 index ea38aed..0000000 --- a/lnet/doc/NAL-HOWTO +++ /dev/null @@ -1,293 +0,0 @@ -This document is a first attempt at describing how to write a NAL -for the Portals 3 library. It also defines the library architecture -and the abstraction of protection domains. - - -First, an overview of the architecture: - - Application - -----|----+-------- - | - API === NAL (User space) - | ----------+---|----- - | - LIB === NAL (Library space) - | ----------+---|----- - - Physical wire (NIC space) - - -Application - API -API-side NAL ------------- -LIB-side NAL - LIB -LIB-side NAL - wire - -Communication is through the indicated paths via well defined -interfaces. The API and LIB portions are written to be portable -across platforms and do not depend on the network interface. - -Communcation between the application and the API code is -defined in the Portals 3 API specification. This is the -user-visible portion of the interface and should be the most -stable. - - - -API-side NAL: ------------- - -The user space NAL needs to implement only a few functions -that are stored in a nal_t data structure and called by the -API-side library: - - int forward( nal_t *nal, - int index, - void *args, - size_t arg_len, - void *ret, - size_t ret_len - ); - -Most of the data structures in the portals library are held in -the LIB section of the code, so it is necessary to forward API -calls across the protection domain to the library. This is -handled by the NAL's forward method. Once the argument and return -blocks are on the remote side the NAL should call lib_dispatch() -to invoke the appropriate API function. - - int validate( nal_t *nal, - void *base, - size_t extent, - void **trans_base, - void **trans_data - ); - -The validate method provides a means for the NAL to prevalidate -and possibly pretranslate user addresses into a form suitable -for fast use by the network card or kernel module. The trans_base -pointer will be used by the library everytime it needs to -refer to the block of memory. The trans_data result is a -cookie that will be handed to the NAL along with the trans_base. - -The library never performs calculations on the trans_base value; -it only computes offsets that are then handed to the NAL. - - - int shutdown( nal_t *nal, int interface ); - -Brings down the network interface. The remote NAL side should -call lib_fini() to bring down the library side of the network. - - void yield( nal_t *nal ); - -This allows the user application to gracefully give up the processor -while busy waiting. Performance critical applications may not -want to take the time to call this function, so it should be an -option to the PtlEQWait call. Right now it is not implemented as such. - -Lastly, the NAL must implement a function named PTL_IFACE_*, where -* is the name of the NAL such as PTL_IFACE_IP or PTL_IFACE_MYR. -This initialization function is to set up communication with the -library-side NAL, which should call lib_init() to bring up the -network interface. - - - -LIB-side NAL: ------------- - -On the library-side, the NAL has much more responsibility. It -is responsible for calling lib_dispatch() on behalf of the user, -it is also responsible for bringing packets off the wire and -pushing bits out. As on the user side, the methods are stored -in a nal_cb_t structure that is defined on a per network -interface basis. - -The calls to lib_dispatch() need to be examined. The prototype: - - void lib_dispatch( - nal_cb_t *nal, - void *private, - int index, - void *arg_block, - void *ret_block - ); - -has two complications. The private field is a NAL-specific -value that will be passed to any callbacks produced as a result -of this API call. Kernel module implementations may use this -for task structures, or perhaps network card data. It is ignored -by the library. - -Secondly, the arg_block and ret_block must be in the same protection -domain as the library. The NAL's two halves must communicate the -sizes and perform the copies. After the call, the buffer pointed -to by ret_block will be filled in and should be copied back to -the user space. How this is to be done is NAL specific. - - int lib_parse( - nal_cb_t *nal, - ptl_hdr_t *hdr, - void *private - ); - -This is the only other entry point into the library from the NAL. -When the NAL detects an incoming message on the wire it should read -sizeof(ptl_hdr_t) bytes and pass a pointer to the header to -lib_parse(). It may set private to be anything that it needs to -tie the incoming message to callbacks that are made as a result -of this event. - -The method calls are: - - int (*send)( - nal_cb_t *nal, - void *private, - lib_msg_t *cookie, - ptl_hdr_t *hdr, - int nid, - int pid, - int gid, - int rid, - user_ptr trans_base, - user_ptr trans_data, - size_t offset, - size_t len - ); - -This is a tricky function -- it must support async output -of messages as well as properly syncronized event log writing. -The private field is the same that was passed into lib_dispatch() -or lib_parse() and may be used to tie this call to the event -that initiated the entry to the library. - -The cookie is a pointer to a library private value that must -be passed to lib_finalize() once the message has been completely -sent. It should not be examined by the NAL for any meaning. - -The four ID fields are passed in, although some implementations -may not use all of them. - -The single base pointer has been replaced with the translated -address that the API NAL generated in the api_nal->validate() -call. The trans_data is unchanged and the offset is in bytes. - - - int (*recv)( - nal_cb_t *nal, - void *private, - lib_msg_t *cookie, - user_ptr trans_base, - user_ptr trans_data, - size_t offset, - size_t mlen, - size_t rlen - ); - -This callback will only be called in response to lib_parse(). -The cookie, trans_addr and trans_data are as discussed in send(). -The NAL should read mlen bytes from the wire, deposit them into -trans_base + offset and then discard (rlen - mlen) bytes. -Once the entire message has been received the NAL should call -lib_finalize() with the lib_msg_t *cookie. - -The special arguments of base=NULL, data=NULL, offset=0, mlen=0, rlen=0 -is used to indicate that the NAL should clean up the wire. This could -be implemented as a blocking call, although having it return as quickly -as possible is desirable. - - int (*write)( - nal_cb_t *nal, - void *private, - user_ptr trans_addr, - user_ptr trans_data, - size_t offset, - - void *src_addr, - size_t len - ); - -This is essentially a cross-protection domain memcpy(). The user address -has been pretranslated by the api_nal->translate() call. - - void *(*malloc)( - nal_cb_t *nal, - size_t len - ); - - void (*free)( - nal_cb_t *nal, - void *buf - ); - -Since the NAL may be in a non-standard hosted environment it can -not call malloc(). This allows the library side NAL to implement -the system specific malloc(). In the current reference implementation -the libary only calls nal->malloc() when the network interface is -initialized and then calls free when it is brought down. The library -maintains its own pool of objects for allocation so only one call to -malloc is made per object type. - - void (*invalidate)( - nal_cb_t *nal, - user_ptr trans_base, - user_ptr trans_data, - size_t extent - ); - -User addresses are validated/translated at the user-level API NAL -method, which is likely to push them to this level. Meanwhile, -the library NAL will be notified when the library no longer -needs the buffer. Overlapped buffers are not detected by the -library, so the NAL should ref count each page involved. - -Unfortunately we have a few bugs when the invalidate method is -called. It is still in progress... - - void (*printf)( - nal_cb_t *nal, - const char *fmt, - ... - ); - -As with malloc(), the library does not have any way to do printf -or printk. It is not necessary for the NAL to implement the this -call, although it will make debugging difficult. - - void (*cli)( - nal_cb_t *nal, - unsigned long *flags - ); - - void (*sti)( - nal_cb_t *nal, - unsigned long *flags - ); - -These are used by the library to mark critical sections. - - int (*gidrid2nidpid)( - nal_cb_t *nal, - ptl_id_t gid, - ptl_id_t rid, - ptl_id_t *nid, - ptl_id_t *pid - ); - - - int (*nidpid2gidrid)( - nal_cb_t *nal, - ptl_id_t nid, - ptl_id_t pid, - ptl_id_t *gid, - ptl_id_t *rid - ); - -Rolf added these. I haven't looked at how they have to work yet. diff --git a/lnet/doc/file.fig b/lnet/doc/file.fig deleted file mode 100644 index 914c294..0000000 --- a/lnet/doc/file.fig +++ /dev/null @@ -1,111 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -6 1200 750 1650 1050 -2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5 - 1650 1050 1650 750 1200 750 1200 1050 1650 1050 -4 1 0 100 0 0 10 0.0000 0 105 240 1425 952 FS0\001 --6 -6 1200 2325 1650 2625 -2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5 - 1650 2625 1650 2325 1200 2325 1200 2625 1650 2625 -4 1 0 100 0 0 10 0.0000 0 105 240 1425 2527 FS3\001 --6 -6 1200 1800 1650 2100 -2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5 - 1650 2100 1650 1800 1200 1800 1200 2100 1650 2100 -4 1 0 100 0 0 10 0.0000 0 105 240 1425 2002 FS2\001 --6 -6 1200 1275 1650 1575 -2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5 - 1650 1575 1650 1275 1200 1275 1200 1575 1650 1575 -4 1 0 100 0 0 10 0.0000 0 105 240 1425 1477 FS1\001 --6 -6 450 750 900 1200 -5 1 0 1 0 7 100 0 20 0.000 0 1 0 0 675.000 750.000 450 1050 675 1125 900 1050 -1 2 0 1 0 7 100 0 20 0.000 1 0.0000 675 825 225 75 450 900 900 750 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 450 825 450 1050 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 1050 900 825 --6 -6 450 2325 900 2775 -5 1 0 1 0 7 100 0 20 0.000 0 1 0 0 675.000 2325.000 450 2625 675 2700 900 2625 -1 2 0 1 0 7 100 0 20 0.000 1 0.0000 675 2400 225 75 450 2475 900 2325 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 450 2400 450 2625 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 2625 900 2400 --6 -6 450 1800 900 2250 -5 1 0 1 0 7 100 0 20 0.000 0 1 0 0 675.000 1800.000 450 2100 675 2175 900 2100 -1 2 0 1 0 7 100 0 20 0.000 1 0.0000 675 1875 225 75 450 1950 900 1800 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 450 1875 450 2100 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 2100 900 1875 --6 -6 450 1275 900 1725 -5 1 0 1 0 7 100 0 20 0.000 0 1 0 0 675.000 1275.000 450 1575 675 1650 900 1575 -1 2 0 1 0 7 100 0 20 0.000 1 0.0000 675 1350 225 75 450 1425 900 1275 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 450 1350 450 1575 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 1575 900 1350 --6 -6 2250 750 3450 2625 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2 - 2550 1200 3150 1200 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2 - 2550 1500 3150 1500 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2 - 2550 1800 3150 1800 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2 - 2550 2100 3150 2100 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 2550 975 3150 975 3150 2625 2550 2625 2550 975 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2 - 2550 2400 3150 2400 -4 1 0 100 0 0 10 0.0000 0 135 1185 2850 900 Application Buffer\001 --6 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 1 2 - 0 0 1.00 60.00 120.00 - 0 0 1.00 60.00 120.00 - 1650 2400 2550 1350 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 1 2 - 0 0 1.00 60.00 120.00 - 0 0 1.00 60.00 120.00 - 1650 1875 2550 1050 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 1 2 - 0 0 1.00 60.00 120.00 - 0 0 1.00 60.00 120.00 - 1650 1425 2550 1950 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 1 2 - 0 0 1.00 60.00 120.00 - 0 0 1.00 60.00 120.00 - 1650 900 2550 1650 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 900 1200 900 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 1425 1200 1425 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 1950 1200 1950 -2 1 0 1 0 7 100 0 20 0.000 0 0 -1 0 0 2 - 900 2475 1200 2475 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 1 2 - 0 0 1.00 60.00 120.00 - 0 0 1.00 60.00 120.00 - 1650 2025 2550 2250 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 1 2 - 0 0 1.00 60.00 120.00 - 0 0 1.00 60.00 120.00 - 1650 2550 2550 2475 -2 4 0 1 0 7 100 0 -1 0.000 0 0 7 0 0 5 - 1875 2850 1875 600 225 600 225 2850 1875 2850 -4 1 0 100 0 0 10 0.0000 0 105 1215 1050 525 Parallel File Server\001 diff --git a/lnet/doc/flow_new.fig b/lnet/doc/flow_new.fig deleted file mode 100644 index d828dea..0000000 --- a/lnet/doc/flow_new.fig +++ /dev/null @@ -1,213 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -6 525 2175 1575 2925 -6 675 2287 1425 2812 -4 1 0 50 0 0 10 0.0000 4 105 255 1050 2437 MD\001 -4 1 0 50 0 0 10 0.0000 4 105 645 1050 2587 Exists and\001 -4 1 0 50 0 0 10 0.0000 4 135 555 1050 2737 Accepts?\001 --6 -2 3 0 1 0 7 100 0 -1 0.000 0 0 0 0 0 5 - 1575 2550 1050 2175 525 2550 1050 2925 1575 2550 --6 -6 3450 1275 4350 1725 -6 3600 1312 4200 1687 -4 1 0 100 0 0 10 0.0000 0 135 525 3900 1612 Message\001 -4 1 0 100 0 0 10 0.0000 0 105 465 3900 1462 Discard\001 --6 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 3450 1275 4350 1275 4350 1725 3450 1725 3450 1275 --6 -6 4650 1275 5550 1725 -6 4725 1312 5475 1687 -4 1 0 100 0 0 10 0.0000 0 135 735 5100 1612 Drop Count\001 -4 1 0 100 0 0 10 0.0000 0 105 630 5100 1462 Increment\001 --6 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 4650 1275 5550 1275 5550 1725 4650 1725 4650 1275 --6 -6 1350 525 2250 975 -6 1350 562 2250 937 -4 1 0 100 0 0 10 0.0000 0 135 795 1800 862 Match Entry\001 -4 1 0 100 0 0 10 0.0000 0 105 585 1800 712 Get Next\001 --6 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 1350 525 2250 525 2250 975 1350 975 1350 525 --6 -6 525 1125 1575 1875 -2 3 0 1 0 7 100 0 -1 0.000 0 0 0 0 0 5 - 1575 1500 1050 1125 525 1500 1050 1875 1575 1500 -4 1 0 100 0 0 10 0.0000 0 105 465 1049 1552 Match?\001 --6 -6 2340 1237 2940 1687 -6 2340 1237 2940 1687 -4 1 0 100 0 0 10 0.0000 0 105 345 2640 1387 More\001 -4 1 0 100 0 0 10 0.0000 0 105 405 2640 1537 Match\001 -4 1 0 100 0 0 10 0.0000 0 105 510 2640 1687 Entries?\001 --6 --6 -6 525 3225 1575 3975 -6 675 3375 1425 3750 -4 1 0 50 0 0 10 0.0000 4 105 255 1050 3525 MD\001 -4 1 0 50 0 0 10 0.0000 4 105 615 1050 3720 has room?\001 --6 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 525 3600 1050 3225 1575 3600 1050 3975 525 3600 --6 -6 3300 3375 4350 3825 -6 3300 3412 4350 3787 -4 1 0 50 0 0 10 0.0000 4 105 735 3825 3562 Unlink MD\001 -4 1 0 50 0 0 10 0.0000 4 135 945 3825 3712 & Match Entry\001 --6 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 3300 3375 4350 3375 4350 3825 3300 3825 3300 3375 --6 -6 1950 3225 3000 3975 -6 2250 3450 2700 3750 -4 1 0 50 0 0 10 0.0000 4 105 450 2475 3600 Unlink\001 -4 1 0 50 0 0 10 0.0000 4 105 315 2475 3750 full?\001 --6 -2 3 0 1 0 7 100 0 -1 0.000 0 0 0 0 0 5 - 3000 3600 2475 3225 1950 3600 2475 3975 3000 3600 --6 -6 3150 4500 4200 4950 -6 3150 4537 4200 4912 -4 1 0 50 0 0 10 0.0000 4 105 735 3675 4687 Unlink MD\001 -4 1 0 50 0 0 10 0.0000 4 135 945 3675 4837 & Match Entry\001 --6 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 3150 4500 4200 4500 4200 4950 3150 4950 3150 4500 --6 -6 600 4500 1500 4950 -6 675 4537 1425 4912 -4 1 0 50 0 0 10 0.0000 4 135 615 1050 4837 Operation\001 -4 1 0 50 0 0 10 0.0000 4 105 525 1050 4687 Perform\001 --6 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 600 4500 1500 4500 1500 4950 600 4950 600 4500 --6 -6 4650 4350 5700 5100 -6 4950 4537 5400 4912 -6 4950 4537 5400 4912 -4 1 0 50 0 0 10 0.0000 4 135 435 5175 4837 Queue?\001 -4 1 0 50 0 0 10 0.0000 4 105 360 5175 4687 Event\001 --6 --6 -2 3 0 1 0 7 100 0 -1 0.000 0 0 0 0 0 5 - 5700 4725 5175 4350 4650 4725 5175 5100 5700 4725 --6 -6 6000 4500 6900 4950 -6 6225 4575 6675 4875 -4 1 0 50 0 0 10 0.0000 4 105 360 6450 4875 Event\001 -4 1 0 50 0 0 10 0.0000 4 105 435 6450 4725 Record\001 --6 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 6000 4500 6900 4500 6900 4950 6000 4950 6000 4500 --6 -6 1800 4350 2850 5100 -6 2100 4575 2550 4875 -4 1 0 50 0 0 10 0.0000 4 105 450 2325 4725 Unlink\001 -4 1 0 50 0 0 10 0.0000 4 105 450 2325 4875 thresh?\001 --6 -2 3 0 1 0 7 100 0 -1 0.000 0 0 0 0 0 5 - 2850 4725 2325 4350 1800 4725 2325 5100 2850 4725 --6 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1050 1875 1050 2175 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1575 1500 2100 1500 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1050 450 1050 1125 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1350 750 1050 750 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1050 2925 1050 3225 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3150 1500 3450 1500 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 4350 1500 4650 1500 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 2100 1500 2625 1125 3150 1500 2625 1875 2100 1500 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1575 3600 1950 3600 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1050 3975 1050 4500 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3000 3600 3300 3600 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1500 4725 1800 4725 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 5700 4725 6000 4725 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 2850 4725 3150 4725 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 4200 4725 4650 4725 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 6900 4725 7950 4725 -3 0 0 1 0 7 100 0 -1 0.000 0 1 0 5 - 0 0 1.00 60.00 120.00 - 1575 2550 1650 2550 1800 2550 1800 2400 1800 1500 - 0.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 100 0 -1 0.000 0 0 1 5 - 0 0 1.00 60.00 120.00 - 2250 750 2475 750 2625 750 2625 900 2625 1125 - 0.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 100 0 -1 0.000 0 0 1 5 - 0 0 1.00 60.00 120.00 - 7500 4725 7500 1650 7500 1500 7350 1500 5550 1500 - 0.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 50 0 -1 0.000 0 1 0 5 - 0 0 1.00 60.00 120.00 - 2475 3225 2475 2400 2475 2250 2325 2250 1800 2250 - 0.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 50 0 -1 0.000 0 1 0 5 - 0 0 1.00 60.00 120.00 - 3825 3375 3825 2175 3825 2025 3675 2025 1800 2025 - 0.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 50 0 -1 0.000 0 1 0 8 - 0 0 1.00 60.00 120.00 - 2325 4350 2325 4275 2325 4125 2475 4125 4275 4125 4425 4125 - 4425 4275 4425 4725 - 0.000 1.000 1.000 1.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 50 0 -1 0.000 0 1 0 8 - 0 0 1.00 60.00 120.00 - 5175 4350 5175 4275 5175 4125 5325 4125 7125 4125 7275 4125 - 7275 4275 7275 4725 - 0.000 1.000 1.000 1.000 1.000 1.000 1.000 0.000 -4 1 0 100 0 0 10 0.0000 0 75 150 1575 1425 no\001 -4 1 0 100 0 0 10 0.0000 0 135 360 825 525 Entry\001 -4 1 0 100 0 0 10 0.0000 0 75 150 1575 2475 no\001 -4 1 0 100 0 0 10 0.0000 0 105 195 1200 1950 yes\001 -4 1 0 100 0 0 10 0.0000 0 105 195 1200 3000 yes\001 -4 1 0 100 0 0 10 0.0000 0 105 195 2775 1050 yes\001 -4 1 0 100 0 0 10 0.0000 0 75 150 3225 1425 no\001 -4 1 0 100 0 0 10 0.0000 0 75 150 1650 3525 no\001 -4 1 0 100 0 0 10 0.0000 0 105 195 1200 4050 yes\001 -4 1 0 100 0 0 10 0.0000 0 105 195 3150 3525 yes\001 -4 1 0 100 0 0 10 0.0000 0 75 150 2625 3150 no\001 -4 1 0 100 0 0 10 0.0000 0 105 195 3000 4650 yes\001 -4 1 0 100 0 0 10 0.0000 0 105 195 5850 4650 yes\001 -4 1 0 100 0 0 10 0.0000 0 75 150 2475 4275 no\001 -4 1 0 100 0 0 10 0.0000 0 75 150 5325 4275 no\001 -4 1 0 50 0 0 10 0.0000 4 105 285 7800 4650 Exit\001 diff --git a/lnet/doc/get.fig b/lnet/doc/get.fig deleted file mode 100644 index 28db949..0000000 --- a/lnet/doc/get.fig +++ /dev/null @@ -1,33 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -6 2775 900 3525 1200 -4 0 0 100 0 0 10 0.0000 0 105 720 2775 1200 Translation\001 -4 0 0 100 0 0 10 0.0000 0 105 405 2850 1050 Portal\001 --6 -6 1350 1725 2175 2025 -4 0 0 100 0 0 10 0.0000 0 105 825 1350 2025 Transmission\001 -4 0 0 100 0 0 10 0.0000 0 105 285 1620 1875 Data\001 --6 -2 1 0 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 900 525 2700 750 -2 1 0 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 2700 825 2700 1275 -2 1 0 1 0 7 100 0 -1 3.000 0 0 7 1 0 2 - 0 0 1.00 60.00 120.00 - 2700 1350 900 1950 -2 2 0 1 0 7 100 0 -1 4.000 0 0 7 0 0 5 - 2400 300 3600 300 3600 2250 2400 2250 2400 300 -2 2 0 1 0 7 100 0 -1 4.000 0 0 7 0 0 5 - 0 300 1200 300 1200 2250 0 2250 0 300 -4 1 0 100 0 0 10 0.0000 4 135 495 1800 825 Request\001 -4 1 0 100 0 0 10 0.0000 0 105 540 600 525 Initiator\001 -4 1 0 100 0 0 10 0.0000 0 135 405 3000 525 Target\001 diff --git a/lnet/doc/ieee.bst b/lnet/doc/ieee.bst deleted file mode 100644 index 4df7c50..0000000 --- a/lnet/doc/ieee.bst +++ /dev/null @@ -1,1112 +0,0 @@ -% --------------------------------------------------------------- -% -% by Paolo.Ienne@di.epfl.ch -% -% --------------------------------------------------------------- -% -% no guarantee is given that the format corresponds perfectly to -% IEEE 8.5" x 11" Proceedings, but most features should be ok. -% -% --------------------------------------------------------------- -% -% `ieee' from BibTeX standard bibliography style `abbrv' -% version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09. -% Copyright (C) 1985, all rights reserved. -% Copying of this file is authorized only if either -% (1) you make absolutely no changes to your copy, including name, or -% (2) if you do make changes, you name it something other than -% btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst. -% This restriction helps ensure that all standard styles are identical. -% The file btxbst.doc has the documentation for this style. - -ENTRY - { address - author - booktitle - chapter - edition - editor - howpublished - institution - journal - key - month - note - number - organization - pages - publisher - school - series - title - type - volume - year - } - {} - { label } - -INTEGERS { output.state before.all mid.sentence after.sentence after.block } - -FUNCTION {init.state.consts} -{ #0 'before.all := - #1 'mid.sentence := - #2 'after.sentence := - #3 'after.block := -} - -STRINGS { s t } - -FUNCTION {output.nonnull} -{ 's := - output.state mid.sentence = - { ", " * write$ } - { output.state after.block = - { add.period$ write$ - newline$ - "\newblock " write$ - } - { output.state before.all = - 'write$ - { add.period$ " " * write$ } - if$ - } - if$ - mid.sentence 'output.state := - } - if$ - s -} - -FUNCTION {output} -{ duplicate$ empty$ - 'pop$ - 'output.nonnull - if$ -} - -FUNCTION {output.check} -{ 't := - duplicate$ empty$ - { pop$ "empty " t * " in " * cite$ * warning$ } - 'output.nonnull - if$ -} - -FUNCTION {output.bibitem} -{ newline$ - "\bibitem{" write$ - cite$ write$ - "}" write$ - newline$ - "" - before.all 'output.state := -} - -FUNCTION {fin.entry} -{ add.period$ - write$ - newline$ -} - -FUNCTION {new.block} -{ output.state before.all = - 'skip$ - { after.block 'output.state := } - if$ -} - -FUNCTION {new.sentence} -{ output.state after.block = - 'skip$ - { output.state before.all = - 'skip$ - { after.sentence 'output.state := } - if$ - } - if$ -} - -FUNCTION {not} -{ { #0 } - { #1 } - if$ -} - -FUNCTION {and} -{ 'skip$ - { pop$ #0 } - if$ -} - -FUNCTION {or} -{ { pop$ #1 } - 'skip$ - if$ -} - -FUNCTION {new.block.checka} -{ empty$ - 'skip$ - 'new.block - if$ -} - -FUNCTION {new.block.checkb} -{ empty$ - swap$ empty$ - and - 'skip$ - 'new.block - if$ -} - -FUNCTION {new.sentence.checka} -{ empty$ - 'skip$ - 'new.sentence - if$ -} - -FUNCTION {new.sentence.checkb} -{ empty$ - swap$ empty$ - and - 'skip$ - 'new.sentence - if$ -} - -FUNCTION {field.or.null} -{ duplicate$ empty$ - { pop$ "" } - 'skip$ - if$ -} - -FUNCTION {emphasize} -{ duplicate$ empty$ - { pop$ "" } - { "{\em " swap$ * "}" * } - if$ -} - -INTEGERS { nameptr namesleft numnames } - -FUNCTION {format.names} -{ 's := - #1 'nameptr := - s num.names$ 'numnames := - numnames 'namesleft := - { namesleft #0 > } - { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't := - nameptr #1 > - { namesleft #1 > - { ", " * t * } - { numnames #2 > - { "," * } - 'skip$ - if$ - t "others" = - { " et~al." * } - { " and " * t * } - if$ - } - if$ - } - 't - if$ - nameptr #1 + 'nameptr := - namesleft #1 - 'namesleft := - } - while$ -} - -FUNCTION {format.authors} -{ author empty$ - { "" } - { author format.names } - if$ -} - -FUNCTION {format.editors} -{ editor empty$ - { "" } - { editor format.names - editor num.names$ #1 > - { ", editors" * } - { ", editor" * } - if$ - } - if$ -} - -FUNCTION {format.title} -{ title empty$ - { "" } - { title "t" change.case$ } - if$ -} - -FUNCTION {n.dashify} -{ 't := - "" - { t empty$ not } - { t #1 #1 substring$ "-" = - { t #1 #2 substring$ "--" = not - { "--" * - t #2 global.max$ substring$ 't := - } - { { t #1 #1 substring$ "-" = } - { "-" * - t #2 global.max$ substring$ 't := - } - while$ - } - if$ - } - { t #1 #1 substring$ * - t #2 global.max$ substring$ 't := - } - if$ - } - while$ -} - -FUNCTION {format.date} -{ year empty$ - { month empty$ - { "" } - { "there's a month but no year in " cite$ * warning$ - month - } - if$ - } - { month empty$ - 'year - { month " " * year * } - if$ - } - if$ -} - -FUNCTION {format.btitle} -{ title emphasize -} - -FUNCTION {tie.or.space.connect} -{ duplicate$ text.length$ #3 < - { "~" } - { " " } - if$ - swap$ * * -} - -FUNCTION {either.or.check} -{ empty$ - 'pop$ - { "can't use both " swap$ * " fields in " * cite$ * warning$ } - if$ -} - -FUNCTION {format.bvolume} -{ volume empty$ - { "" } - { "volume" volume tie.or.space.connect - series empty$ - 'skip$ - { " of " * series emphasize * } - if$ - "volume and number" number either.or.check - } - if$ -} - -FUNCTION {format.number.series} -{ volume empty$ - { number empty$ - { series field.or.null } - { output.state mid.sentence = - { "number" } - { "Number" } - if$ - number tie.or.space.connect - series empty$ - { "there's a number but no series in " cite$ * warning$ } - { " in " * series * } - if$ - } - if$ - } - { "" } - if$ -} - -FUNCTION {format.edition} -{ edition empty$ - { "" } - { output.state mid.sentence = - { edition "l" change.case$ " edition" * } - { edition "t" change.case$ " edition" * } - if$ - } - if$ -} - -INTEGERS { multiresult } - -FUNCTION {multi.page.check} -{ 't := - #0 'multiresult := - { multiresult not - t empty$ not - and - } - { t #1 #1 substring$ - duplicate$ "-" = - swap$ duplicate$ "," = - swap$ "+" = - or or - { #1 'multiresult := } - { t #2 global.max$ substring$ 't := } - if$ - } - while$ - multiresult -} - -FUNCTION {format.pages} -{ pages empty$ - { "" } - { pages multi.page.check - { "pages" pages n.dashify tie.or.space.connect } - { "page" pages tie.or.space.connect } - if$ - } - if$ -} - -FUNCTION {format.vol.num.pages} -{ volume field.or.null - number empty$ - 'skip$ - { "(" number * ")" * * - volume empty$ - { "there's a number but no volume in " cite$ * warning$ } - 'skip$ - if$ - } - if$ - pages empty$ - 'skip$ - { duplicate$ empty$ - { pop$ format.pages } - { ":" * pages n.dashify * } - if$ - } - if$ -} - -FUNCTION {format.chapter.pages} -{ chapter empty$ - 'format.pages - { type empty$ - { "chapter" } - { type "l" change.case$ } - if$ - chapter tie.or.space.connect - pages empty$ - 'skip$ - { ", " * format.pages * } - if$ - } - if$ -} - -FUNCTION {format.in.ed.booktitle} -{ booktitle empty$ - { "" } - { editor empty$ - { "In " booktitle emphasize * } - { "In " format.editors * ", " * booktitle emphasize * } - if$ - } - if$ -} - -FUNCTION {empty.misc.check} -{ author empty$ title empty$ howpublished empty$ - month empty$ year empty$ note empty$ - and and and and and - key empty$ not and - { "all relevant fields are empty in " cite$ * warning$ } - 'skip$ - if$ -} - -FUNCTION {format.thesis.type} -{ type empty$ - 'skip$ - { pop$ - type "t" change.case$ - } - if$ -} - -FUNCTION {format.tr.number} -{ type empty$ - { "Technical Report" } - 'type - if$ - number empty$ - { "t" change.case$ } - { number tie.or.space.connect } - if$ -} - -FUNCTION {format.article.crossref} -{ key empty$ - { journal empty$ - { "need key or journal for " cite$ * " to crossref " * crossref * - warning$ - "" - } - { "In {\em " journal * "\/}" * } - if$ - } - { "In " key * } - if$ - " \cite{" * crossref * "}" * -} - -FUNCTION {format.crossref.editor} -{ editor #1 "{vv~}{ll}" format.name$ - editor num.names$ duplicate$ - #2 > - { pop$ " et~al." * } - { #2 < - 'skip$ - { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = - { " et~al." * } - { " and " * editor #2 "{vv~}{ll}" format.name$ * } - if$ - } - if$ - } - if$ -} - -FUNCTION {format.book.crossref} -{ volume empty$ - { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ - "In " - } - { "Volume" volume tie.or.space.connect - " of " * - } - if$ - editor empty$ - editor field.or.null author field.or.null = - or - { key empty$ - { series empty$ - { "need editor, key, or series for " cite$ * " to crossref " * - crossref * warning$ - "" * - } - { "{\em " * series * "\/}" * } - if$ - } - { key * } - if$ - } - { format.crossref.editor * } - if$ - " \cite{" * crossref * "}" * -} - -FUNCTION {format.incoll.inproc.crossref} -{ editor empty$ - editor field.or.null author field.or.null = - or - { key empty$ - { booktitle empty$ - { "need editor, key, or booktitle for " cite$ * " to crossref " * - crossref * warning$ - "" - } - { "In {\em " booktitle * "\/}" * } - if$ - } - { "In " key * } - if$ - } - { "In " format.crossref.editor * } - if$ - " \cite{" * crossref * "}" * -} - -FUNCTION {article} -{ output.bibitem - format.authors "author" output.check - new.block - format.title "title" output.check - new.block - crossref missing$ - { journal emphasize "journal" output.check - format.vol.num.pages output - format.date "year" output.check - } - { format.article.crossref output.nonnull - format.pages output - } - if$ - new.block - note output - fin.entry -} - -FUNCTION {book} -{ output.bibitem - author empty$ - { format.editors "author and editor" output.check } - { format.authors output.nonnull - crossref missing$ - { "author and editor" editor either.or.check } - 'skip$ - if$ - } - if$ - new.block - format.btitle "title" output.check - crossref missing$ - { format.bvolume output - new.block - format.number.series output - new.sentence - publisher "publisher" output.check - address output - } - { new.block - format.book.crossref output.nonnull - } - if$ - format.edition output - format.date "year" output.check - new.block - note output - fin.entry -} - -FUNCTION {booklet} -{ output.bibitem - format.authors output - new.block - format.title "title" output.check - howpublished address new.block.checkb - howpublished output - address output - format.date output - new.block - note output - fin.entry -} - -FUNCTION {inbook} -{ output.bibitem - author empty$ - { format.editors "author and editor" output.check } - { format.authors output.nonnull - crossref missing$ - { "author and editor" editor either.or.check } - 'skip$ - if$ - } - if$ - new.block - format.btitle "title" output.check - crossref missing$ - { format.bvolume output - format.chapter.pages "chapter and pages" output.check - new.block - format.number.series output - new.sentence - publisher "publisher" output.check - address output - } - { format.chapter.pages "chapter and pages" output.check - new.block - format.book.crossref output.nonnull - } - if$ - format.edition output - format.date "year" output.check - new.block - note output - fin.entry -} - -FUNCTION {incollection} -{ output.bibitem - format.authors "author" output.check - new.block - format.title "title" output.check - new.block - crossref missing$ - { format.in.ed.booktitle "booktitle" output.check - format.bvolume output - format.number.series output - format.chapter.pages output - new.sentence - publisher "publisher" output.check - address output - format.edition output - format.date "year" output.check - } - { format.incoll.inproc.crossref output.nonnull - format.chapter.pages output - } - if$ - new.block - note output - fin.entry -} - -FUNCTION {inproceedings} -{ output.bibitem - format.authors "author" output.check - new.block - format.title "title" output.check - new.block - crossref missing$ - { format.in.ed.booktitle "booktitle" output.check - format.bvolume output - format.number.series output - format.pages output - address empty$ - { organization publisher new.sentence.checkb - organization output - publisher output - format.date "year" output.check - } - { address output.nonnull - format.date "year" output.check - new.sentence - organization output - publisher output - } - if$ - } - { format.incoll.inproc.crossref output.nonnull - format.pages output - } - if$ - new.block - note output - fin.entry -} - -FUNCTION {conference} { inproceedings } - -FUNCTION {manual} -{ output.bibitem - author empty$ - { organization empty$ - 'skip$ - { organization output.nonnull - address output - } - if$ - } - { format.authors output.nonnull } - if$ - new.block - format.btitle "title" output.check - author empty$ - { organization empty$ - { address new.block.checka - address output - } - 'skip$ - if$ - } - { organization address new.block.checkb - organization output - address output - } - if$ - format.edition output - format.date output - new.block - note output - fin.entry -} - -FUNCTION {mastersthesis} -{ output.bibitem - format.authors "author" output.check - new.block - format.title "title" output.check - new.block - "Master's thesis" format.thesis.type output.nonnull - school "school" output.check - address output - format.date "year" output.check - new.block - note output - fin.entry -} - -FUNCTION {misc} -{ output.bibitem - format.authors output - title howpublished new.block.checkb - format.title output - howpublished new.block.checka - howpublished output - format.date output - new.block - note output - fin.entry - empty.misc.check -} - -FUNCTION {phdthesis} -{ output.bibitem - format.authors "author" output.check - new.block - format.btitle "title" output.check - new.block - "PhD thesis" format.thesis.type output.nonnull - school "school" output.check - address output - format.date "year" output.check - new.block - note output - fin.entry -} - -FUNCTION {proceedings} -{ output.bibitem - editor empty$ - { organization output } - { format.editors output.nonnull } - if$ - new.block - format.btitle "title" output.check - format.bvolume output - format.number.series output - address empty$ - { editor empty$ - { publisher new.sentence.checka } - { organization publisher new.sentence.checkb - organization output - } - if$ - publisher output - format.date "year" output.check - } - { address output.nonnull - format.date "year" output.check - new.sentence - editor empty$ - 'skip$ - { organization output } - if$ - publisher output - } - if$ - new.block - note output - fin.entry -} - -FUNCTION {techreport} -{ output.bibitem - format.authors "author" output.check - new.block - format.title "title" output.check - new.block - format.tr.number output.nonnull - institution "institution" output.check - address output - format.date "year" output.check - new.block - note output - fin.entry -} - -FUNCTION {unpublished} -{ output.bibitem - format.authors "author" output.check - new.block - format.title "title" output.check - new.block - note "note" output.check - format.date output - fin.entry -} - -FUNCTION {default.type} { misc } - -MACRO {jan} {"Jan."} - -MACRO {feb} {"Feb."} - -MACRO {mar} {"Mar."} - -MACRO {apr} {"Apr."} - -MACRO {may} {"May"} - -MACRO {jun} {"June"} - -MACRO {jul} {"July"} - -MACRO {aug} {"Aug."} - -MACRO {sep} {"Sept."} - -MACRO {oct} {"Oct."} - -MACRO {nov} {"Nov."} - -MACRO {dec} {"Dec."} - -MACRO {acmcs} {"ACM Comput. Surv."} - -MACRO {acta} {"Acta Inf."} - -MACRO {cacm} {"Commun. ACM"} - -MACRO {ibmjrd} {"IBM J. Res. Dev."} - -MACRO {ibmsj} {"IBM Syst.~J."} - -MACRO {ieeese} {"IEEE Trans. Softw. Eng."} - -MACRO {ieeetc} {"IEEE Trans. Comput."} - -MACRO {ieeetcad} - {"IEEE Trans. Comput.-Aided Design Integrated Circuits"} - -MACRO {ipl} {"Inf. Process. Lett."} - -MACRO {jacm} {"J.~ACM"} - -MACRO {jcss} {"J.~Comput. Syst. Sci."} - -MACRO {scp} {"Sci. Comput. Programming"} - -MACRO {sicomp} {"SIAM J. Comput."} - -MACRO {tocs} {"ACM Trans. Comput. Syst."} - -MACRO {tods} {"ACM Trans. Database Syst."} - -MACRO {tog} {"ACM Trans. Gr."} - -MACRO {toms} {"ACM Trans. Math. Softw."} - -MACRO {toois} {"ACM Trans. Office Inf. Syst."} - -MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."} - -MACRO {tcs} {"Theoretical Comput. Sci."} - -READ - -FUNCTION {sortify} -{ purify$ - "l" change.case$ -} - -INTEGERS { len } - -FUNCTION {chop.word} -{ 's := - 'len := - s #1 len substring$ = - { s len #1 + global.max$ substring$ } - 's - if$ -} - -FUNCTION {sort.format.names} -{ 's := - #1 'nameptr := - "" - s num.names$ 'numnames := - numnames 'namesleft := - { namesleft #0 > } - { nameptr #1 > - { " " * } - 'skip$ - if$ - s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := - nameptr numnames = t "others" = and - { "et al" * } - { t sortify * } - if$ - nameptr #1 + 'nameptr := - namesleft #1 - 'namesleft := - } - while$ -} - -FUNCTION {sort.format.title} -{ 't := - "A " #2 - "An " #3 - "The " #4 t chop.word - chop.word - chop.word - sortify - #1 global.max$ substring$ -} - -FUNCTION {author.sort} -{ author empty$ - { key empty$ - { "to sort, need author or key in " cite$ * warning$ - "" - } - { key sortify } - if$ - } - { author sort.format.names } - if$ -} - -FUNCTION {author.editor.sort} -{ author empty$ - { editor empty$ - { key empty$ - { "to sort, need author, editor, or key in " cite$ * warning$ - "" - } - { key sortify } - if$ - } - { editor sort.format.names } - if$ - } - { author sort.format.names } - if$ -} - -FUNCTION {author.organization.sort} -{ author empty$ - { organization empty$ - { key empty$ - { "to sort, need author, organization, or key in " cite$ * warning$ - "" - } - { key sortify } - if$ - } - { "The " #4 organization chop.word sortify } - if$ - } - { author sort.format.names } - if$ -} - -FUNCTION {editor.organization.sort} -{ editor empty$ - { organization empty$ - { key empty$ - { "to sort, need editor, organization, or key in " cite$ * warning$ - "" - } - { key sortify } - if$ - } - { "The " #4 organization chop.word sortify } - if$ - } - { editor sort.format.names } - if$ -} - -FUNCTION {presort} -{ type$ "book" = - type$ "inbook" = - or - 'author.editor.sort - { type$ "proceedings" = - 'editor.organization.sort - { type$ "manual" = - 'author.organization.sort - 'author.sort - if$ - } - if$ - } - if$ - " " - * - year field.or.null sortify - * - " " - * - title field.or.null - sort.format.title - * - #1 entry.max$ substring$ - 'sort.key$ := -} - -ITERATE {presort} - -SORT - -STRINGS { longest.label } - -INTEGERS { number.label longest.label.width } - -FUNCTION {initialize.longest.label} -{ "" 'longest.label := - #1 'number.label := - #0 'longest.label.width := -} - -FUNCTION {longest.label.pass} -{ number.label int.to.str$ 'label := - number.label #1 + 'number.label := - label width$ longest.label.width > - { label 'longest.label := - label width$ 'longest.label.width := - } - 'skip$ - if$ -} - -EXECUTE {initialize.longest.label} - -ITERATE {longest.label.pass} - -FUNCTION {begin.bib} -{ preamble$ empty$ - 'skip$ - { preamble$ write$ newline$ } - if$ - "\begin{thebibliography}{" longest.label * - "}\setlength{\itemsep}{-1ex}\small" * write$ newline$ -} - -EXECUTE {begin.bib} - -EXECUTE {init.state.consts} - -ITERATE {call.type$} - -FUNCTION {end.bib} -{ newline$ - "\end{thebibliography}" write$ newline$ -} - -EXECUTE {end.bib} - -% end of file ieee.bst -% --------------------------------------------------------------- diff --git a/lnet/doc/mpi.fig b/lnet/doc/mpi.fig deleted file mode 100644 index e1a91b5..0000000 --- a/lnet/doc/mpi.fig +++ /dev/null @@ -1,117 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -6 150 1650 900 2025 -4 1 0 100 0 0 10 0.0000 0 135 735 525 1800 Unexpected\001 -4 1 0 100 0 0 10 0.0000 0 135 585 525 1995 Messages\001 --6 -6 150 150 900 525 -4 1 0 100 0 0 10 0.0000 0 135 615 525 300 Preposted\001 -4 1 0 100 0 0 10 0.0000 0 105 525 525 495 Receives\001 --6 -6 2550 4125 3150 4725 -4 1 0 100 0 0 10 0.0000 0 135 600 2850 4275 Length=0\001 -4 1 0 100 0 0 10 0.0000 0 105 540 2850 4470 Truncate\001 -4 1 0 100 0 0 10 0.0000 0 105 480 2850 4665 No Ack\001 --6 -6 1050 1575 1950 1875 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 1050 1575 1950 1575 1950 1875 1050 1875 1050 1575 -4 1 0 100 0 0 10 0.0000 0 105 780 1500 1725 Match Short\001 --6 -6 5400 1575 6300 2175 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 5400 1575 6300 1575 6300 2175 5400 2175 5400 1575 -4 1 0 100 0 0 10 0.0000 0 105 405 5850 1875 Buffer\001 --6 -6 5400 2400 6300 3000 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 5400 2400 6300 2400 6300 3000 5400 3000 5400 2400 -4 1 0 100 0 0 10 0.0000 0 105 405 5850 2700 Buffer\001 --6 -6 1050 2400 1950 2700 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 1050 2400 1950 2400 1950 2700 1050 2700 1050 2400 -4 1 0 100 0 0 10 0.0000 0 105 780 1500 2550 Match Short\001 --6 -6 1050 825 1950 1125 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 1050 825 1950 825 1950 1125 1050 1125 1050 825 -4 1 0 100 0 0 10 0.0000 0 105 765 1500 975 Match None\001 --6 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1500 1125 1500 1575 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3225 2025 4050 3375 -2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 0 0 2 - 150 675 6600 675 -2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 0 0 2 - 150 1350 6600 1350 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 2400 4125 3300 4125 3300 4725 2400 4725 2400 4125 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3225 4500 4050 3675 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3225 1725 5400 1725 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3225 2550 5400 2550 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3225 2850 4050 3450 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1500 1800 1500 2400 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 2400 825 3300 825 3300 1275 2400 1275 2400 825 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1500 2625 1500 4125 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 1050 4125 1950 4125 1950 4425 1050 4425 1050 4125 -2 1 0 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1500 300 1500 825 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1875 975 2400 975 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1875 1725 2400 1725 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1875 2550 2400 2550 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 1875 4275 2400 4275 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 2400 1575 3300 1575 3300 2175 2400 2175 2400 1575 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 2400 2400 3300 2400 3300 3000 2400 3000 2400 2400 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 4050 3300 5250 3300 5250 3750 4050 3750 4050 3300 -4 1 0 100 0 0 10 0.0000 0 105 885 1500 150 Match Entries\001 -4 1 0 100 0 0 10 0.0000 0 135 1290 2850 150 Memory Descriptors\001 -4 1 0 100 0 0 10 0.0000 0 135 1065 5850 150 Memory Regions\001 -4 1 0 100 0 0 10 0.0000 0 135 825 4500 150 Event Queues\001 -4 1 0 100 0 0 10 0.0000 0 105 585 525 1050 RcvMark\001 -4 1 0 100 0 0 10 0.0000 0 105 330 2850 1102 None\001 -4 1 0 100 0 0 10 0.0000 0 135 705 1500 4275 Match Any\001 -4 1 0 50 0 0 10 0.0000 0 150 810 2850 1725 max_offset=\001 -4 1 0 50 0 0 10 0.0000 0 150 840 2850 1875 n - short_len\001 -4 1 0 50 0 0 10 0.0000 0 150 810 2850 2550 max_offset=\001 -4 1 0 50 0 0 10 0.0000 0 150 840 2850 2700 n - short_len\001 -4 1 0 50 0 0 10 0.0000 0 105 405 2850 2100 unlink\001 -4 1 0 50 0 0 10 0.0000 0 105 405 2850 2925 unlink\001 -4 1 0 100 0 0 10 0.0000 0 135 930 4650 3675 Message Queue\001 -4 1 0 100 0 0 10 0.0000 0 135 735 4650 3525 Unexpected\001 diff --git a/lnet/doc/portals.fig b/lnet/doc/portals.fig deleted file mode 100644 index 9b1271b..0000000 --- a/lnet/doc/portals.fig +++ /dev/null @@ -1,68 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 1350 900 1650 900 1650 1200 1350 1200 1350 900 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 1800 1350 2100 1350 2100 1650 1800 1650 1800 1350 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 2250 1800 2550 1800 2550 2100 2250 2100 2250 1800 -2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 0 0 2 - 4200 375 4200 2100 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 525 600 1125 600 1125 2100 525 2100 525 600 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 4425 1275 4875 1275 4875 1950 4425 1950 4425 1275 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 2550 1200 3150 1200 3150 1500 2550 1500 2550 1200 -2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3000 1425 4425 1425 -2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 - 3600 825 3750 825 3750 1125 3600 1125 3600 825 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 2025 1425 2550 1425 -2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 4425 750 4875 750 4875 1125 4425 1125 4425 750 -2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 3675 975 4425 975 -3 0 0 1 0 7 100 0 -1 0.000 0 1 0 2 - 0 0 1.00 60.00 120.00 - 825 1050 1350 1050 - 0.000 0.000 -3 0 0 1 0 7 100 0 -1 0.000 0 1 0 5 - 0 0 1.00 60.00 120.00 - 1500 1125 1500 1350 1500 1500 1650 1500 1800 1500 - 0.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 100 0 -1 0.000 0 1 0 5 - 0 0 1.00 60.00 120.00 - 1950 1575 1950 1800 1950 1950 2100 1950 2250 1950 - 0.000 1.000 1.000 1.000 0.000 -3 0 0 1 0 7 100 0 -1 0.000 0 0 0 2 - 525 975 1125 975 - 0.000 0.000 -3 0 0 1 0 7 100 0 -1 0.000 0 0 0 2 - 525 1125 1125 1125 - 0.000 0.000 -3 0 0 1 0 7 100 0 -1 0.000 0 1 0 7 - 0 0 1.00 60.00 120.00 - 3000 1275 3150 1275 3300 1275 3300 1125 3300 975 3450 975 - 3600 975 - 0.000 1.000 1.000 1.000 1.000 1.000 0.000 -4 0 0 100 0 0 10 0.0000 0 105 690 1275 750 Match List\001 -4 1 0 100 0 0 10 0.0000 0 105 780 825 525 Portal Table\001 -4 2 0 100 0 0 10 0.0000 0 135 825 4050 2025 Library Space\001 -4 0 0 100 0 0 10 0.0000 0 135 1110 4350 2175 Application Space\001 -4 1 0 100 0 0 10 0.0000 0 135 660 2850 1050 Descriptor\001 -4 1 0 100 0 0 10 0.0000 0 135 540 2850 825 Memory\001 -4 1 0 100 0 0 10 0.0000 0 135 765 3750 675 Event Queue\001 -4 1 0 100 0 0 10 0.0000 0 135 495 4650 675 Regions\001 -4 1 0 100 0 0 10 0.0000 0 135 540 4650 525 Memory\001 diff --git a/lnet/doc/portals3.bib b/lnet/doc/portals3.bib deleted file mode 100644 index 323b99f..0000000 --- a/lnet/doc/portals3.bib +++ /dev/null @@ -1,124 +0,0 @@ -@Article{ Cplant, - title = { {M}assively {P}arallel {C}omputing with - {C}ommodity {C}omponents }, - author = { Ron Brightwell and David S. Greenberg and Arthur - B. Maccabe and Rolf Riesen }, - journal = { Parallel Computing }, - volume = { 26 }, - month = { February }, - pages = { 243-266 }, - year = { 2000 } -} - -@Manual{ Portals, - organization = { Sandia National Laboratories }, - title = { {P}uma {P}ortals }, - note = { http://www.cs.sandia.gov/puma/portals }, - year = { 1997 } -} - -@Techreport{ VIA, - title = { {V}irtual {I}nterface {A}rchitecture - {S}pecification {V}ersion 1.0 }, - author = { {Compaq, Microsoft, and Intel} }, - institution = { Compaq, Microsoft, and Intel }, - month = { December }, - year = { 1997 } -} - -@Techreport{ ST, - title = { {I}nformation {T}echnology - {S}cheduled - {T}ransfer {P}rotocol - {W}orking {D}raft 2.0 }, - author = { {Task Group of Technical Committee T11} }, - institution = { Accredited Standards Committee NCITS }, - month = { July }, - year = { 1998 } -} - -@Manual{ TFLOPS, - organization = { Sandia National Laboratories }, - title = { ASCI Red }, - note = { http://www.sandia.gov/ASCI/TFLOP }, - year = { 1996 } -} - -@Techreport{ GM, - title = { The {GM} {M}essage {P}assing {S}ystem }, - author = { {Myricom, Inc.} }, - institution = { {Myricom, Inc.} }, - year = { 1997 }, -} - -@Article{ MPIstandard, - title = { {MPI}: {A} {M}essage-{P}assing {I}nterface standard }, - author = { {Message Passing Interface Forum} }, - journal = { The International Journal of Supercomputer Applications - and High Performance Computing }, - volume = { 8 }, - year = { 1994 } -} - -@Inproceedings{ PumaOS, - author = "Lance Shuler and Chu Jong and Rolf Riesen and - David van Dresser and Arthur B. Maccabe and - Lee Ann Fisk and T. Mack Stallcup", - booktitle = "Proceeding of the 1995 Intel Supercomputer - User's Group Conference", - title = "The {P}uma Operating System for Massively Parallel Computers", - organization = "Intel Supercomputer User's Group", - year = 1995 -} - -@InProceedings{ SUNMOS, -author = "Arthur B. Maccabe and Kevin S. McCurley and Rolf Riesen and - Stephen R. Wheat", -title = "{SUNMOS} for the {Intel} {Paragon}: A Brief User's Guide", -booktitle = "Proceedings of the {Intel} Supercomputer Users' Group. 1994 - Annual North America Users' Conference.", -year = 1994, -pages = "245--251", -month = "June", -location = "ftp.cs.sandia.gov /pub/sunmos/papers/ISUG94-1.ps" -} - -@InProceedings { PumaMPI, - title = { Design and Implementation of {MPI} on {P}uma Portals }, - author = { Ron Brightwell and Lance Shuler }, - booktitle = { Proceedings of the Second MPI Developer's Conference }, - pages = { 18-25 }, - month = { July }, - year = { 1996 } -} - -@Inproceedings{ FM2, - author = { Mario Lauria and Scott Pakin and Andrew Chien }, - title = { {E}fficient {L}ayering for {H}igh {S}peed - {C}ommunication: {F}ast {M}essages 2.x }, - Booktitle = { Proceedings of the IEEE International Symposium - on High Performance Distributed Computing }, - year = { 1998 } -} - -@Manual { CraySHMEM, - title = "SHMEM Technical Note for C, SG-2516 2.3", - organization = "Cray Research, Inc.", - month = "October", - year = 1994 -} - -@Manual { MPI2, - title = "{MPI}-2: {E}xtensions to the {M}essage-{P}assing {I}nterface", - organization = "Message Passing Interface Forum", - note = "http://www.mpi-forum.org/docs/mpi-20-html/mpi2-report.html", - month = "July", - year = 1997 -} - -@InProceedings { PMMPI, - title = { {The Design and Implementation of Zero Copy MPI Using - Commodity Hardware with a High Performance Network} }, - author = { Francis O'Carroll and Hiroshi Tezuka and Atsushi Hori - and Yutaka Ishikawa }, - booktitle = { Proceedings of the ICS }, - year = { 1998 } -} diff --git a/lnet/doc/portals3.lyx b/lnet/doc/portals3.lyx deleted file mode 100644 index 8429280..0000000 --- a/lnet/doc/portals3.lyx +++ /dev/null @@ -1,15944 +0,0 @@ -#LyX 1.2 created this file. For more info see http://www.lyx.org/ -\lyxformat 220 -\textclass report -\begin_preamble -\usepackage{fullpage} -\renewenvironment{comment}% -{\begin{quote}\textbf{Discussion}: \slshape}% -{\end{quote}} -\pagestyle{myheadings} -\end_preamble -\language american -\inputencoding auto -\fontscheme pslatex -\graphics default -\paperfontsize 10 -\spacing single -\papersize letterpaper -\paperpackage a4 -\use_geometry 0 -\use_amsmath 0 -\use_natbib 0 -\use_numerical_citations 0 -\paperorientation portrait -\secnumdepth 2 -\tocdepth 2 -\paragraph_separation indent -\defskip medskip -\quotes_language english -\quotes_times 2 -\papercolumns 1 -\papersides 2 -\paperpagestyle headings - -\layout Title - -The Portals 3.2 Message Passing Interface -\newline - Revision 1.1 -\layout Author - -Ron Brightwell -\begin_inset Foot -collapsed true - -\layout Standard - -R. - Brightwell and R. - Riesen are with the Scalable Computing Systems Department, Sandia National - Laboratories, P.O. - Box 5800, Albuquerque, NM\SpecialChar ~ -\SpecialChar ~ -87111-1110, bright@cs.sandia.gov, rolf@cs.sandia.gov. -\end_inset - -, Arthur B. - Maccabe -\begin_inset Foot -collapsed true - -\layout Standard - -A. - B. - Maccabe is with the Computer Science Department, University of New Mexico, - Albuquerque, NM\SpecialChar ~ -\SpecialChar ~ -87131-1386, maccabe@cs.unm.edu. -\end_inset - -, Rolf Riesen and Trammell Hudson -\layout Abstract - -This report presents a specification for the Portals 3.2 message passing - interface. - Portals 3.2 is intended to allow scalable, high-performance network communicatio -n between nodes of a parallel computing system. - Specifically, it is designed to support a parallel computing platform composed - of clusters of commodity workstations connected by a commodity system area - network fabric. - In addition, Portals 3.2 is well suited to massively parallel processing - and embedded systems. - Portals 3.2 represents an adaption of the data movement layer developed - for massively parallel processing platforms, such as the 4500-node Intel - TeraFLOPS machine. - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -clearpage -\backslash -pagenumbering{roman} -\backslash -setcounter{page}{3} -\end_inset - - -\layout Standard - - -\begin_inset LatexCommand \tableofcontents{} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -cleardoublepage -\end_inset - - -\layout Standard - - -\begin_inset FloatList figure - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -cleardoublepage -\end_inset - - -\layout Standard - - -\begin_inset FloatList table - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -cleardoublepage -\end_inset - - -\layout Chapter* - -Summary of Changes for Revision 1.1 -\layout Enumerate - -Updated version number to 3.2 throughout the document -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sub:PtlGetId} - -\end_inset - -: added -\family typewriter -PTL_SEGV -\family default - to error list for -\shape italic -PtlGetId -\shape default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - -: added -\family typewriter -PTL_ML_TOOLONG -\family default - to error list for -\shape italic -PtlMEAttach -\shape default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:meunlink} - -\end_inset - -: removed text referring to a list of associated memory descriptors. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:mdfree} - -\end_inset - -: added text to describe unlinking a free-floating memory descriptor. -\layout Enumerate - -Table -\begin_inset LatexCommand \ref{tab:types} - -\end_inset - -: added entry for -\family typewriter -ptl_seq_t -\family default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - -: -\begin_deeper -\layout Enumerate - -added definition of -\family typewriter -max_offset -\family default -. -\layout Enumerate - -added text to clarify -\family typewriter -PTL_MD_MANAGE_REMOTE -\family default -. -\end_deeper -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:mdattach} - -\end_inset - -: modified text for -\family typewriter -unlink_op -\family default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:niinit} - -\end_inset - -: added text to clarify multiple calls to -\shape italic -PtlNIInit -\shape default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:mdattach} - -\end_inset - -: added text to clarify -\family typewriter -unlink_nofit -\family default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:receiving} - -\end_inset - -: removed text indicating that an MD will reject a message if the associated - EQ is full. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:mdfree} - -\end_inset - -: added -\family typewriter -PTL_MD_INUSE -\family default - error code and text to indicate that only MDs with no pending operations - can be unlinked. -\layout Enumerate - -Table -\begin_inset LatexCommand \ref{tab:retcodes} - -\end_inset - -: added -\family typewriter -PTL_MD_INUSE -\family default - return code. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:event-type} - -\end_inset - -: added user id field, MD handle field, and NI specific failure field to - the -\family typewriter -ptl_event_t -\family default - structure. -\layout Enumerate - -Table -\begin_inset LatexCommand \ref{tab:types} - -\end_inset - -: added -\family typewriter -ptl_ni_fail_t -\family default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:event-type} - -\end_inset - -: added -\family typewriter -PTL_EVENT_UNLINK -\family default - event type. -\layout Enumerate - -Table -\begin_inset LatexCommand \ref{tab:func} - -\end_inset - -: removed -\shape slanted -PtlTransId -\shape default -. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - -, Section -\begin_inset LatexCommand \ref{sec:meinsert} - -\end_inset - -, Section -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - -: listed allowable constants with relevant fields. -\layout Enumerate - -Table -\begin_inset LatexCommand \ref{tab:func} - -\end_inset - -: added -\shape italic -PtlMEAttachAny -\shape default - function. -\layout Enumerate - -Table -\begin_inset LatexCommand \ref{tab:retcodes} - -\end_inset - -: added -\family typewriter -PTL_PT_FULL -\family default - return code for -\shape italic -PtlMEAttachAny -\shape default -. -\layout Enumerate - -Table -\begin_inset LatexCommand \ref{tab:oconsts} - -\end_inset - -: updated to reflect new event types. -\layout Enumerate - -Section -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - -: added -\family typewriter -ptl_nid_t -\family default -, -\family typewriter -ptl_pid_t -\family default -, and -\family typewriter -ptl_uid_t -\family default -. -\layout Chapter* - -Summary of Changes for Version 3.1 -\layout Section* - -Thread Issues -\layout Standard - -The most significant change to the interface from version 3.0 to 3.1 involves - the clarification of how the interface interacts with multi-threaded applicatio -ns. - We adopted a generic thread model in which processes define an address - space and threads share the address space. - Consideration of the API in the light of threads lead to several clarifications - throughout the document: -\layout Enumerate - -Glossary: -\begin_deeper -\layout Enumerate - -added a definition for -\emph on -thread -\emph default -, -\layout Enumerate - -reworded the definition for -\emph on -process -\emph default -. - -\end_deeper -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:apiover} - -\end_inset - -: added section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:threads} - -\end_inset - - to describe the multi-threading model used by the Portals API. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:ptlinit} - -\end_inset - -: -\emph on -PtlInit -\emph default - must be called at least once and may be called any number of times. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:ptlfini} - -\end_inset - -: -\emph on -PtlFini -\emph default - should be called once as the process is terminating and not as each thread - terminates. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:pid} - -\end_inset - -: Portals does not define thread ids. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:ni} - -\end_inset - -: network interfaces are associated with processes, not threads. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:niinit} - -\end_inset - -: -\emph on -PtlNIInit -\emph default - must be called at least once and may be called any number of times. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:eqget} - -\end_inset - -: -\emph on -PtlEQGet -\emph default - returns -\family typewriter -PTL_EQ_EMPTY -\family default - if a thread is blocked on -\emph on -PtlEQWait -\emph default -. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:eqwait} - -\end_inset - -: waiting threads are awakened in FIFO order. - -\layout Standard - -Two functions, -\emph on -PtlNIBarrier -\emph default - and -\emph on -PtlEQCount -\emph default - were removed from the API. - -\emph on -PtlNIBarrier -\emph default - was defined to block the calling process until all of the processes in - the application group had invoked -\emph on -PtlNIBarrier -\emph default -. - We now consider this functionality, along with the concept of groups (see - the discussion under -\begin_inset Quotes eld -\end_inset - -other changes -\begin_inset Quotes erd -\end_inset - -), to be part of the runtime system, not part of the Portals API. - -\emph on -PtlEQCount -\emph default - was defined to return the number of events in an event queue. - Because external operations may lead to new events being added and other - threads may remove events, the value returned by -\emph on -PtlEQCount -\emph default - would have to be a hint about the number of events in the event queue. -\layout Section* - -Handling small, unexpected messages -\layout Standard - -Another set of changes relates to handling small unexpected messages in - MPI. - In designing version 3.0, we assumed that each unexpected message would - be placed in a unique memory descriptor. - To avoid the need to process a long list of memory descriptors, we moved - the memory descriptors out of the match list and hung them off of a single - match list entry. - In this way, large unexpected messages would only encounter a single -\begin_inset Quotes eld -\end_inset - -short message -\begin_inset Quotes erd -\end_inset - - match list entry before encountering the -\begin_inset Quotes eld -\end_inset - -long message -\begin_inset Quotes erd -\end_inset - - match list entry. - Experience with this strategy identified resource management problems with - this approach. - In particular, a long sequence of very short (or zero length) messages - could quickly exhaust the memory descriptors constructed for handling unexpecte -d messages. - Our new strategy involves the use of several very large memory descriptors - for small unexpected messages. - Consecutive unexpected messages will be written into the first of these - memory descriptors until the memory descriptor fills up. - When the first of the -\begin_inset Quotes eld -\end_inset - -small memory -\begin_inset Quotes erd -\end_inset - - descriptors fills up, it will be unlinked and subsequent short messages - will be written into the next -\begin_inset Quotes eld -\end_inset - -short message -\begin_inset Quotes erd -\end_inset - - memory descriptor. - In this case, a -\begin_inset Quotes eld -\end_inset - -short message -\begin_inset Quotes erd -\end_inset - - memory descriptor will be declared full when it does not have sufficient - space for the largest small unexpected message. -\layout Standard - -This lead to two significant changes. - First, each match list entry now has a single memory descriptor rather - than a list of memory descriptors. - Second, in addition to exceeding the operation threshold, a memory descriptor - can be unlinked when the local offset exceeds a specified value. - These changes have lead to several changes in this document: -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{subsec:paddress} - -\end_inset - -: -\begin_deeper -\layout Enumerate - -removed references to the memory descriptor list, -\layout Enumerate - -changed the portals address translation description to indicate that unlinking - a memory descriptor implies unlinking the associated match list entry--match - list entries can no longer be unlinked independently from the memory descriptor. - -\end_deeper -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - -: -\begin_deeper -\layout Enumerate - -removed unlink from argument list, -\layout Enumerate - -removed description of -\family typewriter -ptl_unlink -\family default - type, -\layout Enumerate - -changed wording of the error condition when the Portal table index already - has an associated match list. - -\end_deeper -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:meinsert} - -\end_inset - -: removed unlink from argument list. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - -: added -\family typewriter -max_offset -\family default -. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:mdattach} - -\end_inset - -: -\begin_deeper -\layout Enumerate - -added description of -\family typewriter -ptl_unlink -\family default - type, -\layout Enumerate - -removed reference to memory descriptor lists, -\layout Enumerate - -changed wording of the error condition when match list entry already has - an associated memory descriptor, -\layout Enumerate - -changed the description of the -\family typewriter -unlink -\family default - argument. - -\end_deeper -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - -: removed -\family typewriter -PtlMDInsert -\family default - operation. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:mdbind} - -\end_inset - -: removed references to memory descriptor list. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:mdfree} - -\end_inset - -: removed reference to memory descriptor list. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:summary} - -\end_inset - -: removed references to PtlMDInsert. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:semantics} - -\end_inset - -: removed reference to memory descriptor list. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:exmpi} - -\end_inset - -: revised the MPI example to reflect the changes to the interface. - -\layout Standard - -Several changes have been made to improve the general documentation of the - interface. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:handle-type} - -\end_inset - -: documented the special value -\family typewriter -PTL_EQ_NONE -\family default -. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - -: documented the special value -\family typewriter -PTL_ID_ANY -\family default -. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:mdbind} - -\end_inset - -: documented the return value -\family typewriter -PTL_INV_EQ -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:mdupdate} - -\end_inset - -: clarified the description of the -\emph on -PtlMDUpdate -\emph default - function. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:implvals} - -\end_inset - -: introduced a new section to document the implementation defined values. - -\layout Enumerate - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:summary} - -\end_inset - -: modified Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:oconsts} - -\end_inset - - to indicate where each constant is introduced and where it is used. - -\layout Section* - -Other changes -\layout Subsection* - -Implementation defined limits (Section -\begin_inset LatexCommand \ref{sec:niinit} - -\end_inset - -) -\layout Standard - -The earlier version provided implementation defined limits for the maximum - number of match entries, the maximum number of memory descriptors, etc. - Rather than spanning the entire implementation, these limits are now associated - with individual network interfaces. -\layout Subsection* - -Added User Ids (Section -\begin_inset LatexCommand \ref{sec:uid} - -\end_inset - -) -\layout Standard - -Group Ids had been used to simplify access control entries. - In particular, a process could allow access for all of the processes in - a group. - User Ids have been introduced to regain this functionality. - We use user ids to fill this role. -\layout Subsection* - -Removed Group Ids and Rank Ids (Section -\begin_inset LatexCommand \ref{sec:pid} - -\end_inset - -) -\layout Standard - -The earlier version of Portals had two forms for addressing processes: and . - A process group was defined as the collection processes created during - application launch. - Each process in the group was given a unique rank id in the range 0 to - -\begin_inset Formula $n-1$ -\end_inset - - where -\begin_inset Formula $n$ -\end_inset - - was the number of processes in the group. - We removed groups because they are better handled in the runtime system. -\layout Subsection* - -Match lists (Section -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - -) -\layout Standard - -It is no longer illegal to have an existing match entry when calling PtlMEAttach. - A position argument was added to the list of arguments supplied to -\emph on -PtlMEAttach -\emph default - to specify whether the new match entry is prepended or appended to the - existing list. - If there is no existing match list, the position argument is ignored. -\layout Subsection* - -Unlinking Memory Descriptors (Section -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - -) -\layout Standard - -Previously, a memory descriptor could be unlinked if the offset exceeded - a threshold upon the completion of an operation. - In this version, the unlinking is delayed until there is a matching operation - which requires more memory than is currently available in the descriptor. - In addition to changes in section, this lead to a revision of Figure\SpecialChar ~ - -\begin_inset LatexCommand \ref{fig:flow} - -\end_inset - -. -\layout Subsection* - -Split Phase Operations and Events (Section -\begin_inset LatexCommand \ref{sec:eq} - -\end_inset - -) -\layout Standard - -Previously, there were five types of events: -\family typewriter -PTL_EVENT_PUT -\family default -, -\family typewriter -PTL_EVENT_GET -\family default -, -\family typewriter -PTL_EVENT_REPLY -\family default -, -\family typewriter -PTL_EVENT_SENT -\family default -, and -\family typewriter -PTL_EVENT_ACK. - -\family default -The first four of these reflected the completion of potentially long operations. - We have introduced new event types to reflect the fact that long operations - have a distinct starting point and a distinct completion point. - Moreover, the completion may be successful or unsuccessful. -\layout Standard - -In addition to providing a mechanism for reporting failure to higher levels - of software, this split provides an opportunity for for improved ordering - semantics. - Previously, if one process intiated two operations (e.g., two put operations) - on a remote process, these operations were guaranteed to complete in the - same order that they were initiated. - Now, we only guarantee that the initiation events are delivered in the - same order. - In particular, the operations do not need to complete in the order that - they were intiated. -\layout Subsection* - -Well known proces ids (Section -\begin_inset LatexCommand \ref{sec:niinit} - -\end_inset - -) -\layout Standard - -To support the notion of -\begin_inset Quotes eld -\end_inset - -well known process ids, -\begin_inset Quotes erd -\end_inset - - we added a process id argument to the arguments for PtlNIInit. -\layout Chapter* - -Glossary -\layout Description - -API Application Programming Interface. - A definition of the functions and semantics provided by library of functions. - -\layout Description - -Initiator A -\emph on -process -\emph default - that initiates a message operation. - -\layout Description - -Message An application-defined unit of data that is exchanged between -\emph on -processes -\emph default -. - -\layout Description - -Message\SpecialChar ~ -Operation Either a put operation, which writes data, or a get operation, - which reads data. - -\layout Description - -Network A network provides point-to-point communication between -\emph on -nodes -\emph default -. - Internally, a network may provide multiple routes between endpoints (to - improve fault tolerance or to improve performance characteristics); however, - multiple paths will not be exposed outside of the network. - -\layout Description - -Node A node is an endpoint in a -\emph on -network -\emph default -. - Nodes provide processing capabilities and memory. - A node may provide multiple processors (an SMP node) or it may act as a - -\emph on -gateway -\emph default - between networks. - -\layout Description - -Process A context of execution. - A process defines a virtual memory (VM) context. - This context is not shared with other processes. - Several threads may share the VM context defined by a process. - -\layout Description - -Target A -\emph on -process -\emph default - that is acted upon by a message operation. - -\layout Description - -Thread A context of execution that shares a VM context with other threads. - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -cleardoublepage -\layout Standard - -\backslash -setcounter{page}{1} -\backslash -pagenumbering{arabic} -\end_inset - - -\layout Chapter - -Introduction -\begin_inset LatexCommand \label{sec:intro} - -\end_inset - - -\layout Section - -Overview -\layout Standard - -This document describes an application programming interface for message - passing between nodes in a system area network. - The goal of this interface is to improve the scalability and performance - of network communication by defining the functions and semantics of message - passing required for scaling a parallel computing system to ten thousand - nodes. - This goal is achieved by providing an interface that will allow a quality - implementation to take advantage of the inherently scalable design of Portals. -\layout Standard - -This document is divided into several sections: -\layout Description - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:intro} - -\end_inset - ----Introduction This section describes the purpose and scope of the Portals - API. - -\layout Description - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:apiover} - -\end_inset - ----An\SpecialChar ~ -Overview\SpecialChar ~ -of\SpecialChar ~ -the\SpecialChar ~ -Portals\SpecialChar ~ -3.1\SpecialChar ~ -API This section gives a brief overview of the - Portals API. - The goal is to introduce the key concepts and terminology used in the descripti -on of the API. - -\layout Description - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:api} - -\end_inset - ----The\SpecialChar ~ -Portals\SpecialChar ~ -3.2\SpecialChar ~ -API This section describes the functions and semantics of - the Portals application programming interface. - -\layout Description - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:semantics} - -\end_inset - ---The\SpecialChar ~ -Semantics\SpecialChar ~ -of\SpecialChar ~ -Message\SpecialChar ~ -Transmission This section describes the semantics - of message transmission. - In particular, the information transmitted in each type of message and - the processing of incoming messages. - -\layout Description - -Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:examples} - -\end_inset - ----Examples This section presents several examples intended to illustrates - the use of the Portals API. - -\layout Section - -Purpose -\layout Standard - -Existing message passing technologies available for commodity cluster networking - hardware do not meet the scalability goals required by the Cplant\SpecialChar ~ - -\begin_inset LatexCommand \cite{Cplant} - -\end_inset - - project at Sandia National Laboratories. - The goal of the Cplant project is to construct a commodity cluster that - can scale to the order of ten thousand nodes. - This number greatly exceeds the capacity for which existing message passing - technologies have been designed and implemented. -\layout Standard - -In addition to the scalability requirements of the network, these technologies - must also be able to support a scalable implementation of the Message Passing - Interface (MPI)\SpecialChar ~ - -\begin_inset LatexCommand \cite{MPIstandard} - -\end_inset - - standard, which has become the -\shape italic -de facto -\shape default - standard for parallel scientific computing. - While MPI does not impose any scalability limitations, existing message - passing technologies do not provide the functionality needed to allow implement -ations of MPI to meet the scalability requirements of Cplant. -\layout Standard - -The following are properties of a network architecture that do not impose - any inherent scalability limitations: -\layout Itemize - -Connectionless - Many connection-oriented architectures, such as VIA\SpecialChar ~ - -\begin_inset LatexCommand \cite{VIA} - -\end_inset - - and TCP/IP sockets, have limitations on the number of peer connections - that can be established. - -\layout Itemize - -Network independence - Many communication systems depend on the host processor - to perform operations in order for messages in the network to be consumed. - Message consumption from the network should not be dependent on host processor - activity, such as the operating system scheduler or user-level thread scheduler. - -\layout Itemize - -User-level flow control - Many communication systems manage flow control - internally to avoid depleting resources, which can significantly impact - performance as the number of communicating processes increases. - -\layout Itemize - -OS Bypass - High performance network communication should not involve memory - copies into or out of a kernel-managed protocol stack. - -\layout Standard - -The following are properties of a network architecture that do not impose - scalability limitations for an implementation of MPI: -\layout Itemize - -Receiver-managed - Sender-managed message passing implementations require - a persistent block of memory to be available for every process, requiring - memory resources to increase with job size and requiring user-level flow - control mechanisms to manage these resources. - -\layout Itemize - -User-level Bypass - While OS Bypass is necessary for high-performance, it - alone is not sufficient to support the Progress Rule of MPI asynchronous - operations. - -\layout Itemize - -Unexpected messages - Few communication systems have support for receiving - messages for which there is no prior notification. - Support for these types of messages is necessary to avoid flow control - and protocol overhead. - -\layout Section - -Background -\layout Standard - -Portals was originally designed for and implemented on the nCube machine - as part of the SUNMOS (Sandia/UNM OS)\SpecialChar ~ - -\begin_inset LatexCommand \cite{SUNMOS} - -\end_inset - - and Puma\SpecialChar ~ - -\begin_inset LatexCommand \cite{PumaOS} - -\end_inset - - lightweight kernel development projects. - Portals went through two design phases, the latter of which is used on - the 4500-node Intel TeraFLOPS machine\SpecialChar ~ - -\begin_inset LatexCommand \cite{TFLOPS} - -\end_inset - -. - Portals have been very successful in meeting the needs of such a large - machine, not only as a layer for a high-performance MPI implementation\SpecialChar ~ - -\begin_inset LatexCommand \cite{PumaMPI} - -\end_inset - -, but also for implementing the scalable run-time environment and parallel - I/O capabilities of the machine. -\layout Standard - -The second generation Portals implementation was designed to take full advantage - of the hardware architecture of large MPP machines. - However, efforts to implement this same design on commodity cluster technology - identified several limitations, due to the differences in network hardware - as well as to shortcomings in the design of Portals. -\layout Section - -Scalability -\layout Standard - -The primary goal in the design of Portals is scalability. - Portals are designed specifically for an implementation capable of supporting - a parallel job running on tens of thousands of nodes. - Performance is critical only in terms of scalability. - That is, the level of message passing performance is characterized by how - far it allows an application to scale and not by how it performs in micro-bench -marks (e.g., a two node bandwidth or latency test). -\layout Standard - -The Portals API is designed to allow for scalability, not to guarantee it. - Portals cannot overcome the shortcomings of a poorly designed application - program. - Applications that have inherent scalability limitations, either through - design or implementation, will not be transformed by Portals into scalable - applications. - Scalability must be addressed at all levels. - Portals do not inhibit scalability, but do not guarantee it either. -\layout Standard - -To support scalability, the Portals interface maintains a minimal amount - of state. - Portals provide reliable, ordered delivery of messages between pairs of - processes. - They are connectionless: a process is not required to explicitly establish - a point-to-point connection with another process in order to communicate. - Moreover, all buffers used in the transmission of messages are maintained - in user space. - The target process determines how to respond to incoming messages, and - messages for which there are no buffers are discarded. -\layout Section - -Communication Model -\layout Standard - -Portals combine the characteristics of both one-side and two-sided communication. - They define a -\begin_inset Quotes eld -\end_inset - -matching put -\begin_inset Quotes erd -\end_inset - - operation and a -\begin_inset Quotes eld -\end_inset - -matching get -\begin_inset Quotes erd -\end_inset - - operation. - The destination of a put (or send) is not an explicit address; instead, - each message contains a set of match bits that allow the receiver to determine - where incoming messages should be placed. - This flexibility allows Portals to support both traditional one-sided operation -s and two-sided send/receive operations. -\layout Standard - -Portals allows the target to determine whether incoming messages are acceptable. - A target process can choose to accept message operations from any specific - process or can choose to ignore message operations from any specific process. -\layout Section - -Zero Copy, OS Bypass and Application Bypass -\layout Standard - -In traditional system architectures, network packets arrive at the network - interface card (NIC), are passed through one or more protocol layers in - the operating system, and eventually copied into the address space of the - application. - As network bandwidth began to approach memory copy rates, reduction of - memory copies became a critical concern. - This concern lead to the development of zero-copy message passing protocols - in which message copies are eliminated or pipelined to avoid the loss of - bandwidth. -\layout Standard - -A typical zero-copy protocol has the NIC generate an interrupt for the CPU - when a message arrives from the network. - The interrupt handler then controls the transfer of the incoming message - into the address space of the appropriate application. - The interrupt latency, the time from the initiation of an interrupt until - the interrupt handler is running, is fairly significant. - To avoid this cost, some modern NICs have processors that can be programmed - to implement part of a message passing protocol. - Given a properly designed protocol, it is possible to program the NIC to - control the transfer of incoming messages, without needing to interrupt - the CPU. - Because this strategy does not need to involve the OS on every message - transfer, it is frequently called -\begin_inset Quotes eld -\end_inset - -OS Bypass. -\begin_inset Quotes erd -\end_inset - - ST\SpecialChar ~ - -\begin_inset LatexCommand \cite{ST} - -\end_inset - -, VIA\SpecialChar ~ - -\begin_inset LatexCommand \cite{VIA} - -\end_inset - -, FM\SpecialChar ~ - -\begin_inset LatexCommand \cite{FM2} - -\end_inset - -, GM\SpecialChar ~ - -\begin_inset LatexCommand \cite{GM} - -\end_inset - -, and Portals are examples of OS Bypass protocols. -\layout Standard - -Many protocols that support OS Bypass still require that the application - actively participate in the protocol to ensure progress. - As an example, the long message protocol of PM requires that the application - receive and reply to a request to put or get a long message. - This complicates the runtime environment, requiring a thread to process - incoming requests, and significantly increases the latency required to - initiate a long message protocol. - The Portals message passing protocol does not require activity on the part - of the application to ensure progress. - We use the term -\begin_inset Quotes eld -\end_inset - -Application Bypass -\begin_inset Quotes erd -\end_inset - - to refer to this aspect of the Portals protocol. -\layout Section - -Faults -\layout Standard - -Given the number of components that we are dealing with and the fact that - we are interested in supporting applications that run for very long times, - failures are inevitable. - The Portals API recognizes that the underlying transport may not be able - to successfully complete an operation once it has been initiated. - This is reflected in the fact that the Portals API reports three types - of events: events indicating the initiation of an operation, events indicating - the successful completion of an operation, and events indicating the unsuccessf -ul completion of an operation. - Every initiation event is eventually followed by a successful completion - event or an unsuccessful completion event. -\layout Standard - -Between the time an operation is started and the time that the operation - completes (successfully or unsuccessfully), any memory associated with - the operation should be considered volatile. - That is, the memory may be changed in unpredictable ways while the operation - is progressing. - Once the operation completes, the memory associated with the operation - will not be subject to further modification (from this operation). - Notice that unsuccessful operations may alter memory in an essentially - unpredictable fashion. -\layout Chapter - -An Overview of the Portals API -\begin_inset LatexCommand \label{sec:apiover} - -\end_inset - - -\layout Standard - -In this section, we give a conceptual overview of the Portals API. - The goal is to provide a context for understanding the detailed description - of the API presented in the next section. -\layout Section - -Data Movement -\begin_inset LatexCommand \label{sec:dmsemantics} - -\end_inset - - -\layout Standard - -A Portal represents an opening in the address space of a process. - Other processes can use a Portal to read (get) or write (put) the memory - associated with the portal. - Every data movement operation involves two processes, the -\series bold -initiator -\series default - and the -\series bold -target -\series default -. - The initiator is the process that initiates the data movement operation. - The target is the process that responds to the operation by either accepting - the data for a put operation, or replying with the data for a get operation. -\layout Standard - -In this discussion, activities attributed to a process may refer to activities - that are actually performed by the process or -\emph on -on behalf of the process -\emph default -. - The inclusiveness of our terminology is important in the context of -\emph on -application bypass -\emph default -. - In particular, when we note that the target sends a reply in the case of - a get operation, it is possible that reply will be generated by another - component in the system, bypassing the application. -\layout Standard - -Figures\SpecialChar ~ - -\begin_inset LatexCommand \ref{fig:put} - -\end_inset - - and -\begin_inset LatexCommand \ref{fig:get} - -\end_inset - - present graphical interpretations of the Portal data movement operations: - put and get. - In the case of a put operation, the initiator sends a put request message - containing the data to the target. - The target translates the Portal addressing information in the request - using its local Portal structures. - When the request has been processed, the target optionally sends an acknowledge -ment message. -\layout Standard - - -\begin_inset Float figure -placement htbp -wide false -collapsed false - -\layout Standard -\align center - -\begin_inset Graphics FormatVersion 1 - filename put.eps - display color - size_type 0 - rotateOrigin center - lyxsize_type 1 - lyxwidth 218pt - lyxheight 119pt -\end_inset - - -\layout Caption - -Portal Put (Send) -\begin_inset LatexCommand \label{fig:put} - -\end_inset - - -\end_inset - - -\layout Standard - -In the case of a get operation, the initiator sends a get request to the - target. - As with the put operation, the target translates the Portal addressing - information in the request using its local Portal structures. - Once it has translated the Portal addressing information, the target sends - a reply that includes the requested data. -\layout Standard - - -\begin_inset Float figure -placement htbp -wide false -collapsed false - -\layout Standard -\align center - -\begin_inset Graphics FormatVersion 1 - filename get.eps - display color - size_type 0 - rotateOrigin center - lyxsize_type 1 - lyxwidth 218pt - lyxheight 119pt -\end_inset - - -\layout Caption - -Portal Get -\begin_inset LatexCommand \label{fig:get} - -\end_inset - - -\end_inset - - -\layout Standard - -We should note that Portal address translations are only performed on nodes - that respond to operations initiated by other nodes. - Acknowledgements and replies to get operations bypass the portals address - translation structures. -\layout Section - -Portal Addressing -\begin_inset LatexCommand \label{subsec:paddress} - -\end_inset - - -\layout Standard - -One-sided data movement models (e.g., shmem\SpecialChar ~ - -\begin_inset LatexCommand \cite{CraySHMEM} - -\end_inset - -, ST\SpecialChar ~ - -\begin_inset LatexCommand \cite{ST} - -\end_inset - -, MPI-2\SpecialChar ~ - -\begin_inset LatexCommand \cite{MPI2} - -\end_inset - -) typically use a triple to address memory on a remote node. - This triple consists of a process id, memory buffer id, and offset. - The process id identifies the target process, the memory buffer id specifies - the region of memory to be used for the operation, and the offset specifies - an offset within the memory buffer. -\layout Standard - -In addition to the standard address components (process id, memory buffer - id, and offset), a Portal address includes a set of match bits. - This addressing model is appropriate for supporting one-sided operations - as well as traditional two-sided message passing operations. - Specifically, the Portals API provides the flexibility needed for an efficient - implementation of MPI-1, which defines two-sided operations with one-sided - completion semantics. -\layout Standard - -Figure\SpecialChar ~ - -\begin_inset LatexCommand \ref{fig:portals} - -\end_inset - - presents a graphical representation of the structures used by a target - in the interpretation of a Portal address. - The process id is used to route the message to the appropriate node and - is not reflected in this diagram. - The memory buffer id, called the -\series bold -portal id -\series default -, is used as an index into the Portal table. - Each element of the Portal table identifies a match list. - Each element of the match list specifies two bit patterns: a set of -\begin_inset Quotes eld -\end_inset - -don't care -\begin_inset Quotes erd -\end_inset - - bits, and a set of -\begin_inset Quotes eld -\end_inset - -must match -\begin_inset Quotes erd -\end_inset - - bits. - In addition to the two sets of match bits, each match list element has - at most one memory descriptor. - Each memory descriptor identifies a memory region and an optional event - queue. - The memory region specifies the memory to be used in the operation and - the event queue is used to record information about these operations. -\layout Standard - - -\begin_inset Float figure -placement htbp -wide false -collapsed false - -\layout Standard -\align center - -\begin_inset Graphics FormatVersion 1 - filename portals.eps - display color - size_type 0 - rotateOrigin center - lyxsize_type 1 - lyxwidth 305pt - lyxheight 106pt -\end_inset - - -\layout Caption - -Portal Addressing Structures -\begin_inset LatexCommand \label{fig:portals} - -\end_inset - - -\end_inset - - -\layout Standard - -Figure\SpecialChar ~ - -\begin_inset LatexCommand \ref{fig:flow} - -\end_inset - - illustrates the steps involved in translating a Portal address, starting - from the first element in a match list. - If the match criteria specified in the match list entry are met and the - memory descriptor list accepts the operation -\begin_inset Foot -collapsed true - -\layout Standard - -Memory descriptors can reject operations because a threshold has been exceeded - or because the memory region does not have sufficient space, see Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - - -\end_inset - -, the operation (put or get) is performed using the memory region specified - in the memory descriptor. - If the memory descriptor specifies that it is to be unlinked when a threshold - has been exceeded, the match list entry is removed from the match list - and the resources associated with the memory descriptor and match list - entry are reclaimed. - Finally, if there is an event queue specified in the memory descriptor, - the operation is logged in the event queue. -\layout Standard - - -\begin_inset Float figure -placement htbp -wide false -collapsed false - -\layout Standard -\align center - -\begin_inset Graphics FormatVersion 1 - filename flow_new.eps - display color - size_type 0 - rotateOrigin center - lyxsize_type 1 - lyxwidth 447pt - lyxheight 282pt -\end_inset - - -\layout Caption - -Portals Address Translation -\begin_inset LatexCommand \label{fig:flow} - -\end_inset - - -\end_inset - - -\layout Standard - -If the match criteria specified in the match list entry are not met, or - there is no memory descriptor associated with the match list entry, or - the memory descriptor associated with the match list entry rejects the - operation, the address translation continues with the next match list entry. - If the end of the match list has been reached, the address translation - is aborted and the incoming requested is discarded. -\layout Section - -Access Control -\layout Standard - -A process can control access to its portals using an access control list. - Each entry in the access control list specifies a process id and a Portal - table index. - The access control list is actually an array of entries. - Each incoming request includes an index into the access control list (i.e., - a -\begin_inset Quotes eld -\end_inset - -cookie -\begin_inset Quotes erd -\end_inset - - or hint). - If the id of the process issuing the request doesn't match the id specified - in the access control list entry or the Portal table index specified in - the request doesn't match the Portal table index specified in the access - control list entry, the request is rejected. - Process identifiers and Portal table indexes may include wild card values - to increase the flexibility of this mechanism. - -\layout Standard - -Two aspects of this design merit further discussion. - First, the model assumes that the information in a message header, the - sender's id in particular, is trustworthy. - In most contexts, we assume that the entity that constructs the header - is trustworthy; however, using cryptographic techniques, we could easily - devise a protocol that would ensure the authenticity of the sender. -\layout Standard - -Second, because the access check is performed by the receiver, it is possible - that a malicious process will generate thousands of messages that will - be denied by the receiver. - This could saturate the network and/or the receiver, resulting in a -\emph on -denial of service -\emph default - attack. - Moving the check to the sender using capabilities, would remove the potential - for this form of attack. - However, the solution introduces the complexities of capability management - (exchange of capabilities, revocation, protections, etc). -\layout Section - -Multi-threaded Applications -\begin_inset LatexCommand \label{sec:threads} - -\end_inset - - -\layout Standard - -The Portals API supports a generic view of multi-threaded applications. - From the perspective of the Portals API, an application program is defined - by a set of processes. - Each process defines a unique address space. - The Portals API defines access to this address space from other processes - (using portals addressing and the data movement operations). - A process may have one or more -\emph on -threads -\emph default - executing in its address space. - -\layout Standard - -With the exception of -\emph on -PtlEQWait -\emph default - every function in the Portals API is non-blocking and atomic with respect - to both other threads and external operations that result from data movement - operations. - While individual operations are atomic, sequences of these operations may - be interleaved between different threads and with external operations. - The Portals API does not provide any mechanisms to control this interleaving. - It is expected that these mechanisms will be provided by the API used to - create threads. -\layout Chapter - -The Portals API -\begin_inset LatexCommand \label{sec:api} - -\end_inset - - -\layout Section - -Naming Conventions -\begin_inset LatexCommand \label{sec:conv} - -\end_inset - - -\layout Standard - -The Portals API defines two types of entities: functions and types. - Function always start with -\emph on -Ptl -\emph default - and use mixed upper and lower case. - When used in the body of this report, function names appear in italic face, - e.g., -\emph on -PtlInit -\emph default -. - The functions associated with an object type will have names that start - with -\emph on -Ptl -\emph default -, followed by the two letter object type code shown in Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:objcodes} - -\end_inset - -. - As an example, the function -\emph on -PtlEQAlloc -\emph default - allocates resources for an event queue. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Object Type Codes -\begin_inset LatexCommand \label{tab:objcodes} - -\end_inset - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\newline - -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\emph on -xx -\end_inset - - -\begin_inset Text - -\layout Standard - - Name -\end_inset - - -\begin_inset Text - -\layout Standard - - Section -\end_inset - - - - -\begin_inset Text - -\layout Standard - -EQ -\end_inset - - -\begin_inset Text - -\layout Standard - - Event Queue -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:eq} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - MD -\end_inset - - -\begin_inset Text - -\layout Standard - - Memory Descriptor -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - ME -\end_inset - - -\begin_inset Text - -\layout Standard - - Match list Entry -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:me} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - NI -\end_inset - - -\begin_inset Text - -\layout Standard - - Network Interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni} - -\end_inset - - -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Standard - -Type names use lower case with underscores to separate words. - Each type name starts with -\family typewriter -ptl -\family default -_ and ends with -\family typewriter -_t -\family default -. - When used in the body of this report, type names appear in a fixed font, - e.g., -\family typewriter -ptl_match_bits_t -\family default -. -\layout Standard - -Names for constants use upper case with underscores to separate words. - Each constant name starts with -\family typewriter -PTL_ -\family default -. - When used in the body of this report, type names appear in a fixed font, - e.g., -\family typewriter -PTL_OK -\family default -. -\layout Section - -Base Types -\layout Standard - -The Portals API defines a variety of base types. - These types represent a simple renaming of the base types provided by the - C programming language. - In most cases these new type names have been introduced to improve type - safety and to avoid issues arising from differences in representation sizes - (e.g., 16-bit or 32-bit integers). -\layout Subsection - -Sizes -\begin_inset LatexCommand \label{sec:size-t} - -\end_inset - - -\layout Standard - -The type -\family typewriter -ptl_size_t -\family default - is an unsigned 64-bit integral type used for representing sizes. -\layout Subsection - -Handles -\begin_inset LatexCommand \label{sec:handle-type} - -\end_inset - - -\layout Standard - -Objects maintained by the API are accessed through handles. - Handle types have names of the form -\family typewriter -ptl_handle_ -\emph on -xx -\emph default -_t -\family default -, where -\emph on -xx -\emph default - is one of the two letter object type codes shown in Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:objcodes} - -\end_inset - -. - For example, the type -\family typewriter -ptl_handle_ni_t -\family default - is used for network interface handles. -\layout Standard - -Each type of object is given a unique handle type to enhance type checking. - The type, -\family typewriter -ptl_handle_any_t -\family default -, can be used when a generic handle is needed. - Every handle value can be converted into a value of type -\family typewriter -ptl_handle_any_t -\family default - without loss of information. -\layout Standard - -Handles are not simple values. - Every portals object is associated with a specific network interface and - an identifier for this interface (along with an object identifier) is part - of the handle for the object. -\layout Standard - -The special value -\family typewriter -PTL_EQ_NONE -\family default -, of type -\family typewriter -ptl_handle_eq_t -\family default -, is used to indicate the absence of an event queue. - See sections -\begin_inset LatexCommand \ref{sec:mdfree} - -\end_inset - - and\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:mdupdate} - -\end_inset - - for uses of this value. -\layout Subsection - -Indexes -\begin_inset LatexCommand \label{sec:index-type} - -\end_inset - - -\layout Standard - -The types -\family typewriter -ptl_pt_index_t -\family default - and -\family typewriter -ptl_ac_index_t -\family default - are integral types used for representing Portal table indexes and access - control tables indexes, respectively. - See section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:niinit} - -\end_inset - - for limits on values of these types. -\layout Subsection - -Match Bits -\begin_inset LatexCommand \label{sec:mb-type} - -\end_inset - - -\layout Standard - -The type -\family typewriter -ptl_match_bits_t -\family default - is capable of holding unsigned 64-bit integer values. -\layout Subsection - -Network Interfaces -\begin_inset LatexCommand \label{sec:ni-type} - -\end_inset - - -\layout Standard - -The type -\family typewriter -ptl_interface_t -\family default - is an integral type used for identifying different network interfaces. - Users will need to consult the local documentation to determine appropriate - values for the interfaces available. - The special value -\family typewriter -PTL_IFACE_DEFAULT -\family default - identifies the default interface. -\layout Subsection - -Identifiers -\begin_inset LatexCommand \label{sec:id-type} - -\end_inset - - -\layout Standard - -The type -\family typewriter -ptl_nid_t -\family default - is an integral type used for representing node ids -\family typewriter -, ptl_pid_t -\family default - is an integral type for representing process ids, and -\family typewriter -ptl_uid_t -\family default -is an integral type for representing user ids. -\layout Standard - -The special values -\family typewriter -PTL_PID_ANY -\family default - matches any process identifier, PTL_NID_ANY matches any node identifier, - and -\family typewriter -PTL_UID_ANY -\family default - matches any user identifier. - See sections -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - - and\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:acentry} - -\end_inset - - for uses of these values. -\layout Subsection - -Status Registers -\begin_inset LatexCommand \label{sec:stat-type} - -\end_inset - - -\layout Standard - -Each network interface maintains an array of status registers that can be - accessed using the -\family typewriter -PtlNIStatus -\family default - function (see Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:nistatus} - -\end_inset - -). - The type -\family typewriter -ptl_sr_index_t -\family default - defines the types of indexes that can be used to access the status registers. - The only index defined for all implementations is -\family typewriter -PTL_SR_DROP_COUNT -\family default - which identifies the status register that counts the dropped requests for - the interface. - Other indexes (and registers) may be defined by the implementation. -\layout Standard - -The type -\family typewriter -ptl_sr_value_t -\family default - defines the types of values held in status registers. - This is a signed integer type. - The size is implementation dependent, but must be at least 32 bits. -\layout Section - -Initialization and Cleanup -\begin_inset LatexCommand \label{sec:init} - -\end_inset - - -\layout Standard - -The Portals API includes a function, -\emph on -PtlInit -\emph default -, to initialize the library and a function, -\emph on -PtlFini -\emph default -, to cleanup after the application is done using the library. -\layout Subsection - -PtlInit -\begin_inset LatexCommand \label{sec:ptlinit} - -\end_inset - - -\layout LyX-Code - -int PtlInit( int *max_interfaces ); -\layout Standard -\noindent -The -\emph on -PtlInit -\emph default - function initializes the Portals library. - PtlInit must be called at least once by a process before any thread makes - a Portals function call, but may be safely called more than once. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_FAIL Indicates an error during initialization. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -max_interfaces -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -max_interfaces -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold the maximum number of interfaces - that can be initialized. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlFini -\begin_inset LatexCommand \label{sec:ptlfini} - -\end_inset - - -\layout LyX-Code - -void PtlFini( void ); -\layout Standard -\noindent -The -\emph on -PtlFini -\emph default - function cleans up after the Portals library is no longer needed by a process. - After this function is called, calls to any of the functions defined by - the Portal API or use of the structures set up by the Portals API will - result in undefined behavior. - This function should be called once and only once during termination by - a process. - Typically, this function will be called in the exit sequence of a process. - Individual threads should not call PtlFini when they terminate. -\layout Section - -Network Interfaces -\begin_inset LatexCommand \label{sec:ni} - -\end_inset - - -\layout Standard - -The Portals API supports the use of multiple network interfaces. - However, each interface is treated as an independent entity. - Combining interfaces (e.g., -\begin_inset Quotes eld -\end_inset - -bonding -\begin_inset Quotes erd -\end_inset - - to create a higher bandwidth connection) must be implemented by the application - or embedded in the underlying network. - Interfaces are treated as independent entities to make it easier to cache - information on individual network interface cards. -\layout Standard - -Once initialized, each interface provides a Portal table, an access control - table, and a collection of status registers. - See Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:me} - -\end_inset - - for a discussion of updating Portal table entries using the -\emph on -PtlMEAttach -\emph default - function. - See Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:ac} - -\end_inset - - for a discussion of the initialization and updating of entries in the access - control table. - See Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:nistatus} - -\end_inset - - for a discussion of the -\emph on -PtlNIStatus -\emph default - function which can be used to determine the value of a status register. -\layout Standard - -Every other type of Portal object (e.g., memory descriptor, event queue, or - match list entry) is associated with a specific network interface. - The association to a network interface is established when the object is - created and is encoded in the handle for the object. -\layout Standard - -Each network interface is initialized and shutdown independently. - The initialization routine, -\emph on -PtlNIInit -\emph default -, returns a handle for an interface object which is used in all subsequent - Portal operations. - The -\emph on -PtlNIFini -\emph default - function is used to shutdown an interface and release any resources that - are associated with the interface. - Network interface handles are associated with processes, not threads. - All threads in a process share all of the network interface handles. -\layout Standard - -The Portals API also defines the -\emph on -PtlNIStatus -\emph default - function to query the status registers for a network interface, the -\emph on -PtlNIDist -\emph default - function to determine the -\begin_inset Quotes eld -\end_inset - -distance -\begin_inset Quotes erd -\end_inset - - to another process, and the -\emph on -PtlNIHandle -\emph default - function to determine the network interface that an object is associated - with. -\layout Subsection - -PtlNIInit -\begin_inset LatexCommand \label{sec:niinit} - -\end_inset - - -\layout LyX-Code - -typedef struct { -\newline - int max_match_entries; -\newline - int max_mem_descriptors; -\newline - int max_event_queues; -\newline - ptl_ac_index_t max_atable_index; -\newline - ptl_pt_index_t max_ptable_index; -\newline -} ptl_ni_limits_t; -\newline - -\newline -int PtlNIInit( ptl_interface_t interface -\newline - ptl_pid_t pid, -\newline - ptl_ni_limits_t* desired, -\newline - ptl_ni_limits_t* actual, -\newline - ptl_handle_ni_t* handle ); -\layout Standard - -Values of type -\family typewriter -ptl_ni_limits_t -\family default - include the following members: -\layout Description - -max_match_entries Maximum number of match entries that can be allocated - at any one time. -\layout Description - -max_mem_descriptors Maximum number of memory descriptors that can be allocated - at any one time. -\layout Description - -max_event_queues Maximum number of event queues that can be allocated at - any one time. -\layout Description - -max_atable_index Largest access control table index for this interface, - valid indexes range from zero to -\family typewriter -max_atable_index -\family default -, inclusive. -\layout Description - -max_ptable_index Largest Portal table index for this interface, valid indexes - range from zero to -\family typewriter -max_ptable_index -\family default -, inclusive. -\layout Standard -\noindent -The -\emph on -PtlNIInit -\emph default - function is used to initialized the Portals API for a network interface. - This function must be called at least once by each process before any other - operations that apply to the interface by any process or thread. - For subsequent calls to -\shape italic -PtlNIInit -\shape default - from within the same process (either by different threads or the same thread), - the desired limits will be ignored and the call will return the existing - NI handle. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INIT_DUP Indicates a duplicate initialization of -\family typewriter -interface -\family default -. - -\layout Description - -PTL_INIT_INV Indicates that -\family typewriter -interface -\family default - is not a valid network interface. - -\layout Description - -PTL_NOSPACE Indicates that there is insufficient memory to initialize the - interface. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -pid -\family default - is not a valid process id. -\layout Description - -PTL_SEGV Indicates that -\family typewriter -actual -\family default -or -\family typewriter - handle -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Identifies the network interface to be initialized. - (See section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:ni-type} - -\end_inset - - for a discussion of values used to identify network interfaces.) -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -pid -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Identifies the desired process id (for well known process ids). - The value -\family typewriter -PTL_PID_ANY -\family default - may be used to have the process id assigned by the underlying library. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -desired -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -If non-NULL, points to a structure that holds the desired limits. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -actual -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, the location pointed to by actual will hold the actual - limits. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold a handle for the interface. -\end_inset - - - - -\end_inset - - -\layout Comment - -The use of desired is implementation dependent. - In particular, an implementation may choose to ignore this argument. -\layout Subsection - -PtlNIFini -\begin_inset LatexCommand \label{sec:nifini} - -\end_inset - - -\layout LyX-Code - -int PtlNIFini( ptl_handle_ni_t interface ); -\layout Standard -\noindent -The -\emph on -PtlNIFini -\emph default - function is used to release the resources allocated for a network interface. - Once the -\emph on -PtlNIFini -\emph default - operation has been started, the results of pending API operations (e.g., - operations initiated by another thread) for this interface are undefined. - Similarly, the effects of incoming operations (puts and gets) or return - values (acknowledgements and replies) for this interface are undefined. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid network interface handle. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard - -A handle for the interface to shutdown. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlNIStatus -\begin_inset LatexCommand \label{sec:nistatus} - -\end_inset - - -\layout LyX-Code - -int PtlNIStatus( ptl_handle_ni_t interface, -\newline - ptl_sr_index_t status_register, -\newline - ptl_sr_value_t* status ); -\layout Standard -\noindent -The -\emph on -PtlNIStatus -\emph default - function returns the value of a status register for the specified interface. - (See section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:stat-type} - -\end_inset - - for more information on status register indexes and status register values.) -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid network interface handle. - -\layout Description - -PTL_INV_SR_INDX Indicates that -\family typewriter -status_register -\family default - is not a valid status register. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -status -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the interface to use. - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -status_register -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -An index for the status register to read. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -status -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold the current value of the status - register. -\end_inset - - - - -\end_inset - - -\layout Comment - -The only status register that must be defined is a drop count register ( -\family typewriter -PTL_SR_DROP_COUNT -\family default -). - Implementations may define additional status registers. - Identifiers for the indexes associated with these registers should start - with the prefix -\family typewriter -PTL_SR_ -\family default -. -\layout Subsection - -PtlNIDist -\layout LyX-Code - -int PtlNIDist( ptl_handle_ni_t interface, -\newline - ptl_process_id_t process, -\newline - unsigned long* distance ); -\layout Standard -\noindent -The -\emph on -PtlNIDist -\emph default - function returns the distance to another process using the specified interface. - Distances are only defined relative to an interface. - Distance comparisons between different interfaces on the same process may - be meaningless. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid network interface handle. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -process -\family default - is not a valid process identifier. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -distance -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the interface to use. - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -process -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -An identifier for the process whose distance is being requested. - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -distance -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold the distance to the remote - process. -\end_inset - - - - -\end_inset - - -\layout Comment - -This function should return a static measure of distance. - Examples include minimum latency, the inverse of available bandwidth, or - the number of switches between the two endpoints. -\layout Subsection - -PtlNIHandle -\layout LyX-Code - -int PtlNIHandle( ptl_handle_any_t handle, -\newline - ptl_handle_ni_t* interface ); -\layout Standard -\noindent -The -\emph on -PtlNIHandle -\emph default - function returns a handle for the network interface with which the object - identified by -\family typewriter -handle -\family default - is associated. - If the object identified by -\family typewriter -handle -\family default - is a network interface, this function returns the same value it is passed. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_HANDLE Indicates that -\family typewriter -handle -\family default - is not a valid handle. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -interface -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the object. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold a handle for the network interface - associated with -\family typewriter -handle -\family default -. -\end_inset - - - - -\end_inset - - -\layout Comment - -Every handle should encode the network interface and the object id relative - to this handle. - Both are presumably encoded using integer values. -\layout Section - -User Identification -\begin_inset LatexCommand \label{sec:uid} - -\end_inset - - -\layout Standard - -Every process runs on behalf of a user. - -\layout Subsection - -PtlGetUid -\layout LyX-Code - -int PtlGetUid( ptl_handle_ni_t ni_handle, -\newline - ptl_uid_t* uid ); -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -ni_handle -\family default - is not a valid network interface handle. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -interface -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A network interface handle. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -id -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold the user id for the calling - process. -\end_inset - - - - -\end_inset - - -\layout Comment - -Note that user identifiers are dependent on the network interface(s). - In particular, if a node has multiple interfaces, a process may have multiple - user identifiers. -\layout Section - -Process Identification -\begin_inset LatexCommand \label{sec:pid} - -\end_inset - - -\layout Standard - -Processes that use the Portals API, can be identified using a node id and - process id. - Every node accessible through a network interface has a unique node identifier - and every process running on a node has a unique process identifier. - As such, any process in the computing system can be identified by its node - id and process id. - -\layout Standard - -The Portals API defines a type, -\family typewriter -ptl_process_id_t -\family default - for representing process ids and a function, -\emph on -PtlGetId -\emph default -, which can be used to obtain the id of the current process. -\layout Comment - -The portals API does not include thread identifiers. - Messages are delivered to processes (address spaces) not threads (contexts - of execution). -\layout Subsection - -The Process Id Type -\begin_inset LatexCommand \label{sec:pid-type} - -\end_inset - - -\layout LyX-Code - -typedef struct { -\newline - ptl_nid_t nid; /* node id */ -\newline - ptl_pid_t pid; /* process id */ -\newline -} ptl_process_id_t; -\layout Standard -\noindent -The -\family typewriter -ptl_process_id_t -\family default - type uses two identifiers to represent a process id: a node id and a process - id. - -\layout Subsection - -PtlGetId -\begin_inset LatexCommand \label{sub:PtlGetId} - -\end_inset - - -\layout LyX-Code - -int PtlGetId( ptl_handle_ni_t ni_handle, -\newline - ptl_process_id_t* id ); -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -ni_handle -\family default - is not a valid network interface handle. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -id -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A network interface handle. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -id -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold the id for the calling process. -\end_inset - - - - -\end_inset - - -\layout Comment - -Note that process identifiers are dependent on the network interface(s). - In particular, if a node has multiple interfaces, it may have multiple - node identifiers. -\layout Section - -Match List Entries and Match Lists -\begin_inset LatexCommand \label{sec:me} - -\end_inset - - -\layout Standard - -A match list is a chain of match list entries. - Each match list entry includes a memory descriptor and a set of match criteria. - The match criteria can be used to reject incoming requests based on process - id or the match bits provided in the request. - A match list is created using the -\emph on -PtlMEAttach -\emph default - or -\shape italic -PtlMEAttachAny -\shape default - functions, which create a match list consisting of a single match list - entry, attaches the match list to the specified Portal index, and returns - a handle for the match list entry. - Match entries can be dynamically inserted and removed from a match list - using the -\emph on -PtlMEInsert -\emph default - and -\emph on -PtlMEUnlink -\emph default - functions. -\layout Subsection - -PtlMEAttach -\begin_inset LatexCommand \label{sec:meattach} - -\end_inset - - -\layout LyX-Code - -typedef enum { PTL_RETAIN, PTL_UNLINK } ptl_unlink_t; -\newline - -\layout LyX-Code - -typedef enum { PTL_INS_BEFORE, PTL_INS_AFTER } ptl_ins_pos_t; -\newline - -\layout LyX-Code - -int PtlMEAttach( ptl_handle_ni_t interface, -\newline - ptl_pt_index_t index, -\newline - ptl_process_id_t matchid, -\newline - ptl_match_bits_t match_bits, -\newline - ptl_match_bits_t ignorebits, -\newline - ptl_unlink_t unlink, -\newline - ptl_ins_pos_t position, -\newline - ptl_handle_me_t* handle ); -\layout Standard -\noindent -Values of the type -\family typewriter -ptl_ins_pos_t -\family default - are used to control where a new item is inserted. - The value -\family typewriter -PTL_INS_BEFORE -\family default - is used to insert the new item before the current item or before the head - of the list. - The value -\family typewriter -PTL_INS_AFTER -\family default - is used to insert the new item after the current item or after the last - item in the list. - -\layout Standard - -The -\emph on -PtlMEAttach -\emph default - function creates a match list consisting of a single entry and attaches - this list to the Portal table for -\family typewriter -interface -\family default -. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid network interface handle. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_PTINDEX Indicates that -\family typewriter -index -\family default - is not a valid Portal table index. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -matchid -\family default - is not a valid process identifier. - -\layout Description - -PTL_NOSPACE Indicates that there is insufficient memory to allocate the - match list entry. - -\layout Description - -PTL_ML_TOOLONG Indicates that the resulting match list is too long. - The maximum length for a match list is defined by the interface. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the interface to use. - -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -index -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The Portal table index where the match list should be attached. -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -matchid -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Specifies the match criteria for the process id of the requestor. - The constants -\family typewriter -PTL_PID_ANY -\family default - and -\family typewriter -PTL_NID_ANY -\family default - can be used to wildcard either of the ids in the -\family typewriter -ptl_process_id_t -\family default - structure. - -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -match_bits, ignorebits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Specify the match criteria to apply to the match bits in the incoming request. - The -\family typewriter -ignorebits -\family default - are used to mask out insignificant bits in the incoming match bits. - The resulting bits are then compared to the match list entry's match - bits to determine if the incoming request meets the match criteria. -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -unlink -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Indicates the match list entry should be unlinked when the last memory descripto -r associated with this match list entry is unlinked. - (Note, the check for unlinking a match entry only occurs when a memory - descriptor is unlinked.) -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -position -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Indicates whether the new match entry should be prepended or appended to - the existing match list. - If there is no existing list, this argument is ignored and the new match - entry becomes the only entry in the list. - Allowed constants: -\family typewriter -PTL_INS_BEFORE -\family default -, -\family typewriter -PTL_INS_AFTER -\family default -. -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold a handle for the newly created - match list entry. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlMEAttachAny -\begin_inset LatexCommand \label{sec:attachany} - -\end_inset - - -\layout LyX-Code - -int PtlMEAttachAny( ptl_handle_ni_t interface, -\newline - ptl_pt_index_t *index, -\newline - ptl_process_id_t matchid, -\newline - ptl_match_bits_t match_bits, -\newline - ptl_match_bits_t ignorebits, -\newline - ptl_unlink_t unlink, -\newline - ptl_handle_me_t* handle ); -\layout Standard - -The -\emph on -PtlMEAttachAny -\emph default - function creates a match list consisting of a single entry and attaches - this list to an unused Portal table entry for -\family typewriter -interface -\family default -. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid network interface handle. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -matchid -\family default - is not a valid process identifier. - -\layout Description - -PTL_NOSPACE Indicates that there is insufficient memory to allocate the - match list entry. - -\layout Description - -PTL_PT_FULL Indicates that there are no free entries in the Portal table. -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the interface to use. - -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -index -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On succesfful return, this location will hold the Portal index where the - match list has been attached. -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -matchid, match_bits, ignorebits, unlink -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -See the discussion for -\shape italic -PtlMEAttach -\shape default -. -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold a handle for the newly created - match list entry. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlMEInsert -\begin_inset LatexCommand \label{sec:meinsert} - -\end_inset - - -\layout LyX-Code - -int PtlMEInsert( ptl_handle_me_t current, -\newline - ptl_process_id_t matchid, -\newline - ptl_match_bits_t match_bits, -\newline - ptl_match_bits_t ignorebits, -\newline - ptl_ins_pos_t position, -\newline - ptl_handle_me_t* handle ); -\layout Standard - -The -\emph on -PtlMEInsert -\emph default - function creates a new match list entry and inserts this entry into the - match list containing -\family typewriter -current -\family default -. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -matchid -\family default - is not a valid process identifier. - -\layout Description - -PTL_INV_ME Indicates that -\family typewriter -current -\family default - is not a valid match entry handle. - -\layout Description - -PTL_ML_TOOLONG Indicates that the resulting match list is too long. - The maximum length for a match list is defined by the interface. - -\layout Description - -PTL_NOSPACE Indicates that there is insufficient memory to allocate the - match entry. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -current -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for a match entry. - The new match entry will be inserted immediately before or immediately - after this match entry. -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -matchid -\family default -, -\family typewriter -match_bits -\family default -, -\family typewriter -ignorebits -\family default -, -\family typewriter -unlink -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -See the discussion for -\emph on -PtlMEAttach -\emph default - -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -position -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Indicates whether the new match entry should be inserted before or after - the -\family typewriter -current -\family default - entry. - Allowed constants: -\family typewriter -PTL_INS_BEFORE -\family default -, -\family typewriter -PTL_INS_AFTER -\family default -. -\end_inset - - - - -\begin_inset Text - -\layout Standard -\noindent - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -See the discussion for -\emph on -PtlMEAttach -\emph default -. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlMEUnlink -\begin_inset LatexCommand \label{sec:meunlink} - -\end_inset - - -\layout LyX-Code - -int PtlMEUnlink( ptl_handle_me_t entry ); -\layout Standard -\noindent -The -\emph on -PtlMEUnlink -\emph default - function can be used to unlink a match entry from a match list. - This operation also releases any resources associated with the match entry - (including the associated memory descriptor). - It is an error to use the match entry handle after calling -\emph on -PtlMEUnlink -\emph default -. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_ME Indicates that -\family typewriter -entry -\family default - is not a valid match entry handle. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -entry -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard - -A handle for the match entry to be unlinked. -\end_inset - - - - -\end_inset - - -\layout Section - -Memory Descriptors -\begin_inset LatexCommand \label{sec:md} - -\end_inset - - -\layout Standard - -A memory descriptor contains information about a region of an application - process' memory and an event queue where information about the operations - performed on the memory descriptor are recorded. - The Portals API provides two operations to create memory descriptors: -\emph on -PtlMDAttach -\emph default -, and -\emph on -PtlMDBind -\emph default -; an operation to update a memory descriptor, -\emph on -PtlMDUpdate -\emph default -; and an operation to unlink and release the resources associated with a - memory descriptor, -\emph on -PtlMDUnlink -\emph default -. -\layout Subsection - -The Memory Descriptor Type -\begin_inset LatexCommand \label{sec:md-type} - -\end_inset - - -\layout LyX-Code - -typedef struct { -\newline - void* start; -\newline - ptl_size_t length; -\newline - int threshold; -\newline - unsigned int max_offset; -\newline - unsigned int options; -\newline - void* user_ptr; -\newline - ptl_handle_eq_t eventq; -\newline -} ptl_md_t; -\layout Standard -\noindent -The -\family typewriter -ptl_md_t -\family default - type defines the application view of a memory descriptor. - Values of this type are used to initialize and update the memory descriptors. -\layout Subsubsection - -Members -\layout Description - -start,\SpecialChar ~ -length Specify the memory region associated with the memory descriptor. - The -\family typewriter -start -\family default - member specifies the starting address for the memory region and the -\family typewriter -length -\family default - member specifies the length of the region. - The -\family typewriter -start member -\family default - can be NULL provided that the -\family typewriter -length -\family default - member is zero. - (Zero length buffers are useful to record events.) There are no alignment - restrictions on the starting address or the length of the region; although, - unaligned messages may be slower (i.e., lower bandwidth and/or longer latency) - on some implementations. - -\layout Description - -threshold Specifies the maximum number of operations that can be performed - on the memory descriptor. - An operation is any action that could possibly generate an event (see Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - for the different types of events). - In the usual case, the threshold value is decremented for each operation - on the memory descriptor. - When the threshold value is zero, the memory descriptor is -\emph on -inactive -\emph default -, and does not respond to operations. - A memory descriptor can have an initial threshold value of zero to allow - for manipulation of an inactive memory descriptor by the local process. - A threshold value of -\family typewriter -PTL_MD_THRESH_INF -\family default - indicates that there is no bound on the number of operations that may be - applied to a memory descriptor. - Note that local operations (e.g., -\emph on -PtlMDUpdate -\emph default -) are not applied to the threshold count. - -\layout Description - -max_offset Specifies the maximum local offset of a memory descriptor. - When the local offset of a memory descriptor exceeds this maximum, the - memory descriptor becomes -\shape italic -inactive -\shape default - and does not respond to further operations. -\layout Description - -options Specifies the behavior of the memory descriptor. - There are five options that can be selected: enable put operations (yes - or no), enable get operations (yes or no), offset management (local or - remote), message truncation (yes or no), and acknowledgement (yes or no). - Values for this argument can be constructed using a bitwise or of the following - values: -\begin_deeper -\begin_deeper -\layout Description - -PTL_MD_OP_PUT Specifies that the memory descriptor will respond to -\emph on -put -\emph default - operations. - By default, memory descriptors reject -\emph on -put -\emph default - operations. - -\layout Description - -PTL_MD_OP_GET Specifies that the memory descriptor will respond to -\emph on -get -\emph default - operations. - By default, memory descriptors reject -\emph on -get -\emph default - operations. - -\layout Description - -PTL_MD_MANAGE_REMOTE Specifies that the offset used in accessing the memory - region is provided by the incoming request. - By default, the offset is maintained locally. - When the offset is maintained locally, the offset is incremented by the - length of the request so that the next operation (put and/or get) will - access the next part of the memory region. -\layout Description - -PTL_MD_TRUNCATE Specifies that the length provided in the incoming request - can be reduced to match the memory available in the region. - (The memory available in a memory region is determined by subtracting the - offset from the length of the memory region.) By default, if the length - in the incoming operation is greater than the amount of memory available, - the operation is rejected. - -\layout Description - -PTL_MD_ACK_DISABLE Specifies that an acknowledgement should -\emph on -not -\emph default - be sent for incoming -\emph on -put -\emph default - operations, even if requested. - By default, acknowledgements are sent for -\emph on -put -\emph default - operations that request an acknowledgement. - Acknowledgements are never sent for -\emph on -get -\emph default - operations. - The value sent in the reply serves as an implicit acknowledgement. - -\end_deeper -\layout Standard - - -\series bold -Note -\series default -: It is not considered an error to have a memory descriptor that does not - respond to either -\emph on -put -\emph default - or -\emph on -get -\emph default - operations: Every memory descriptor responds to -\emph on -reply -\emph default - operations. - Nor is it considered an error to have a memory descriptor that responds - to both -\emph on -put -\emph default - and -\emph on -get -\emph default - operations. - -\end_deeper -\layout Description - -user_ptr A user-specified value that is associated with the memory descriptor. - The value does not need to be a pointer, but must fit in the space used - by a pointer. - This value (along with other values) is recorded in events associated with - operations on this memory descriptor. -\begin_inset Foot -collapsed true - -\layout Standard - -Tying the memory descriptor to a user-defined value can be useful when multiple - memory descriptor share the same event queue or when the memory descriptor - needs to be associated with a data structure maintained by the application. - For example, an MPI implementation can set the -\family typewriter -user_ptr -\family default - argument to the value of an MPI Request. - This direct association allows for processing of memory descriptor's by - the MPI implementation without a table lookup or a search for the appropriate - MPI Request. -\end_inset - - -\layout Description - -eventq A handle for the event queue used to log the operations performed - on the memory region. - If this argument is -\family typewriter -PTl_EQ_NONE -\family default -, operations performed on this memory descriptor are not logged. - -\layout Subsection - -PtlMDAttach -\begin_inset LatexCommand \label{sec:mdattach} - -\end_inset - - -\layout LyX-Code - -int PtlMDAttach( ptl_handle_me_t match, -\newline - ptl_md_t mem_desc, -\newline - ptl_unlink_t unlink_op, -\newline - ptl_unlink_t unlink_nofit, -\newline - ptl_handle_md_t* handle ); -\layout Standard -\noindent -Values of the type -\family typewriter -ptl_unlink_t -\family default - are used to control whether an item is unlinked from a list. - The value -\family typewriter -PTL_UNLINK -\family default - enables unlinking. - The value -\family typewriter -PTL_RETAIN -\family default - disables unlinking. -\layout Standard - -The -\emph on -PtlMDAttach -\emph default - operation is used to create a memory descriptor and attach it to a match - list entry. - An error code is returned if this match list entry already has an associated - memory descriptor. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INUSE Indicates that -\family typewriter -match -\family default - already has a memory descriptor attached. - -\layout Description - -PTL_INV_ME Indicates that -\family typewriter -match -\family default - is not a valid match entry handle. - -\layout Description - -PTL_ILL_MD Indicates that -\family typewriter -mem_desc -\family default - is not a legal memory descriptor. - This may happen because the memory region defined in -\family typewriter -mem_desc -\family default - is invalid or because the network interface associated with the -\family typewriter -eventq -\family default - in -\family typewriter -mem_desc -\family default - is not the same as the network interface associated with -\family typewriter -match -\family default -. - -\layout Description - -PTL_NOSPACE Indicates that there is insufficient memory to allocate the - memory descriptor. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -match -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the match entry that the memory descriptor will be associated - with. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Provides initial values for the application visible parts of a memory descriptor. - Other than its use for initialization, there is no linkage between this - structure and the memory descriptor maintained by the API. - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -unlink_op -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A flag to indicate whether the memory descriptor is unlinked when it becomes - inactive, either because the operation threshold drops to zero or because - the maximum offset has been exceeded. - (Note, the check for unlinking a memory descriptor only occurs after a - the completion of a successful operation. - If the threshold is set to zero during initialization or using -\emph on -PtlMDUpdate -\emph default -, the memory descriptor is -\series bold -not -\series default - unlinked.) -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -unlink_nofit -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A flag to indicate whether the memory descriptor is unlinked when the space - remaining in the memory descriptor is not sufficient for a matching operation. - If an incoming message arrives arrives at a memory descriptor that does - not have sufficient space and the -\series bold -PTL_MD_TRUNCATE -\series default - operation is not specified, the memory descriptor will be unlinked. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold a handle for the newly created - memory descriptor. - The -\family typewriter -handle -\family default - argument can be NULL, in which case the handle will not be returned. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlMDBind -\begin_inset LatexCommand \label{sec:mdbind} - -\end_inset - - -\layout LyX-Code - -int PtlMDBind( ptl_handle_ni_t interface, -\newline - ptl_md_t mem_desc, -\newline - ptl_handle_md_t* handle ); -\layout Standard -\noindent -The -\emph on -PtlMDBind -\emph default - operation is used to create a -\begin_inset Quotes eld -\end_inset - -free floating -\begin_inset Quotes erd -\end_inset - - memory descriptor, i.e., a memory descriptor that is not associated with - a match list entry. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid match entry handle. - -\layout Description - -PTL_ILL_MD Indicates that -\family typewriter -mem_desc -\family default - is not a legal memory descriptor. - This may happen because the memory region defined in -\family typewriter -mem_desc -\family default - is invalid or because the network interface associated with the -\family typewriter -eventq -\family default - in -\family typewriter -mem_desc -\family default - is not the same as the network interface, -\family typewriter -interface -\family default -. - -\layout Description - -PTL_INV_EQ Indicates that the event queue associated with -\family typewriter -mem_desc -\family default - is not valid. - -\layout Description - -PTL_NOSPACE Indicates that there is insufficient memory to allocate the - memory descriptor. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -handle -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the network interface with which the memory descriptor will - be associated. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Provides initial values for the application visible parts of a memory descriptor. - Other than its use for initialization, there is no linkage between this - structure and the memory descriptor maintained by the API. - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold a handle for the newly created - memory descriptor. - The -\family typewriter -handle -\family default - argument must be a valid address and cannot be NULL. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlMDUnlink -\begin_inset LatexCommand \label{sec:mdfree} - -\end_inset - - -\layout LyX-Code - -int PtlMDUnlink( ptl_handle_md_t mem_desc ); -\layout Standard -\noindent -The -\emph on -PtlMDUnlink -\emph default - function unlinks the memory descriptor from any match list entry it may - be linked to and releases the resources associated with a memory descriptor. - (This function does not free the memory region associated with the memory - descriptor.) This function also releases the resources associated with a - floating memory descriptor. - Only memory descriptors with no pending operations may be unlinked. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_MD Indicates that -\family typewriter -mem_desc -\family default - is not a valid memory descriptor handle. -\layout Description - -PTL_MD_INUSE Indicates that -\family typewriter -mem_desc -\family default - has pending operations and cannot be unlinked. -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the memory descriptor to be released. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlMDUpdate -\begin_inset LatexCommand \label{sec:mdupdate} - -\end_inset - - -\layout LyX-Code - -int PtlMDUpdate( ptl_handle_md_t mem_desc, -\newline - ptl_md_t* old_md, -\newline - ptl_md_t* new_md, -\newline - ptl_handle_eq_t testq ); -\layout Standard -\noindent -The -\emph on -PtlMDUpdate -\emph default - function provides a conditional, atomic update operation for memory descriptors. - The memory descriptor identified by -\family typewriter -mem_desc -\family default - is only updated if the event queue identified by -\family typewriter -testq -\family default - is empty. - The intent is to only enable updates to the memory descriptor when no new - messages have arrived since the last time the queue was checked. - See section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:exmpi} - -\end_inset - - for an example of how this function can be used. -\layout Standard - -If -\family typewriter -new -\family default - is not NULL the memory descriptor identified by handle will be updated - to reflect the values in the structure pointed to by -\family typewriter -new -\family default - if -\family typewriter -testq -\family default - has the value -\family typewriter -PTL_EQ_NONE -\family default - or if the event queue identified by -\family typewriter -testq -\family default - is empty. - If -\family typewriter -old -\family default - is not NULL, the current value of the memory descriptor identified by -\family typewriter -mem_desc -\family default - is recorded in the location identified by -\family typewriter -old -\family default -. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_NOUPDATE Indicates that the update was not performed because -\family typewriter -testq -\family default - was not empty. - -\layout Description - -PTL_INV_MD Indicates that -\family typewriter -mem_desc -\family default - is not a valid memory descriptor handle. - -\layout Description - -PTL_ILL_MD Indicates that the value pointed to by -\family typewriter -new -\family default - is not a legal memory descriptor (e.g., the memory region specified by the - memory descriptor may be invalid). - -\layout Description - -PTL_INV_EQ Indicates that -\family typewriter -testq -\family default - is not a valid event queue handle. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -new -\family default - or -\family typewriter -old -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the memory descriptor to update. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -old_md -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -If -\family typewriter -old_md -\family default - is not the value -\family typewriter -NULL -\family default -, the current value of the memory descriptor will be stored in the location - identified by -\family typewriter -old -\family default -_md. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -new_md -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -If -\family typewriter -new_md -\family default - is not the value -\family typewriter -NULL -\family default -, this argument provides the new values for the memory descriptor, if the - update is performed. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -testq -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for an event queue used to predicate the update. - If -\family typewriter -testq -\family default - is equal to -\family typewriter -PTL_EQ_NONE -\family default -, the update is performed unconditionally. - Otherwise, the update is performed if and only if -\family typewriter -testq -\family default - is empty. - If the update is not performed, the function returns the value -\family typewriter -PTL_NOUPDATE -\family default -. - (Note, the -\family typewriter -testq -\family default - argument does not need to be the same as the event queue associated with - the memory descriptor.) -\end_inset - - - - -\end_inset - - -\layout Standard - -The conditional update can be used to ensure that the memory descriptor - has not changed between the time it was examined and the time it is updated. - In particular, it is needed to support an MPI implementation where the - activity of searching an unexpected message queue and posting a receive - must be atomic. -\layout Section - -Events and Event Queues -\begin_inset LatexCommand \label{sec:eq} - -\end_inset - - -\layout Standard - -Event queues are used to log operations performed on memory descriptors. - They can also be used to hold acknowledgements for completed -\emph on -put -\emph default - operations and to note when the data specified in a -\emph on -put -\emph default - operation has been sent (i.e., when it is safe to reuse the buffer that holds - this data). - Multiple memory descriptors can share a single event queue. -\layout Standard - -In addition to the -\family typewriter -ptl_handle_eq_t -\family default - type, the Portals API defines two types associated with events: The -\family typewriter - -\newline -ptl_event_kind_t -\family default - type defines the kinds of events that can be stored in an event queue. - The -\family typewriter -ptl_event_t -\family default - type defines a structure that holds the information associated with an - event. -\layout Standard - -The Portals API also provides four functions for dealing with event queues: - The -\emph on -PtlEQAlloc -\emph default - function is used to allocate the API resources needed for an event queue, - the -\emph on -PtlEQFree -\emph default - function is used to release these resources, the -\emph on -PtlEQGet -\emph default - function can be used to get the next event from an event queue, and the - -\emph on -PtlEQWait -\emph default - function can be used to block a process (or thread) until an event queue - has at least one event. -\layout Subsection - -Kinds of Events -\begin_inset LatexCommand \label{sec:ek-type} - -\end_inset - - -\layout LyX-Code - -typedef enum { -\newline - PTL_EVENT_GET_START, PTL_EVENT_GET_END, PTL_EVENT_GET_FAIL, -\newline - PTL_EVENT_PUT_START, PTL_EVENT_PUT_END, PTL_EVENT_PUT_FAIL, -\newline - PTL_EVENT_REPLY_START, PTL_EVENT_REPLY_END, PTL_EVENT_REPLY_FAIL, -\newline - PTL_EVENT_SEND_START, PTL_EVENT_SEND_END, PTL_EVENT_SEND_FAIL, -\newline - PTL_EVENT_ACK, -\newline - PTL_EVENT_UNLINK -\newline -} ptl_event_kind_t; -\layout Standard -\noindent -The Portals API defines fourteen types of events that can be logged in an - event queue: -\layout Description - -PTL_EVENT_GET_START A remote -\emph on -get -\emph default - operation has been started on the memory descriptor. - The memory region associated with this descriptor should not be altered - until the corresponding END or FAIL event is logged. -\layout Description - -PTL_EVENT_GET_END A previously initiated -\emph on -get -\emph default - operation completed successfully. - This event is logged after the reply has been sent by the local node. - As such, the process could free the memory descriptor once it sees this - event. - -\layout Description - -PTL_EVENT_GET_FAIL A previously initiated -\emph on -get -\emph default - operation completed unsuccessfully. - This event is logged after the reply has been sent by the local node. - As such, the process could free the memory descriptor once it sees this - event. - -\layout Description - -PTL_EVENT_PUT_START A remote -\emph on -put -\emph default - operation has been started on the memory descriptor. - The memory region associated with this descriptor should should be considered - volatile until the corresponding END or FAIL event is logged. -\layout Description - -PTL_EVENT_PUT_END A previously initiated -\emph on -put -\emph default - operation completed successfully. - The underlying layers will not alter the memory (on behalf of this operation) - once this event has been logged. - -\layout Description - -PTL_EVENT_PUT_FAIL A previously initiated -\emph on -put -\emph default - operation completed unsuccessfully. - The underlying layers will not alter the memory (on behalf of this operation) - once this event has been logged. - -\layout Description - -PTL_EVENT_REPLY_START A -\emph on -reply -\emph default - operation has been started on the memory descriptor. - -\layout Description - -PTL_EVENT_REPLY_END A previously initiated -\emph on -reply -\emph default - operation has completed successfully . - This event is logged after the data (if any) from the reply has been written - into the memory descriptor. - -\layout Description - -PTL_EVENT_REPLY_FAIL A previously initiated -\emph on -reply -\emph default - operation has completed unsuccessfully. - This event is logged after the data (if any) from the reply has been written - into the memory descriptor. - -\layout Description - -PTL_EVENT_ACK An -\emph on -acknowledgement -\emph default - was received. - This event is logged when the acknowledgement is received -\layout Description - -PTL_EVENT_SEND_START An outgoing -\emph on -send -\emph default - operation has been started. - The memory region associated with this descriptor should not be altered - until the corresponding END or FAIL event is logged. -\layout Description - -PTL_EVENT_SEND_END A previously initiated -\emph on -send -\emph default - operation has completed successfully. - This event is logged after the entire buffer has been sent and it is safe - for the application to reuse the buffer. - -\layout Description - -PTL_EVENT_SEND_FAIL A previously initiated -\emph on -send -\emph default - operation has completed unsuccessfully. - The process can safely manipulate the memory or free the memory descriptor - once it sees this event. -\layout Description - -PTL_EVENT_UNLINK A memory descriptor associated with this event queue has - been automatically unlinked. - This event is not generated when a memory descriptor is explicitly unlinked - by calling -\shape italic -PtlMDUnlink -\shape default -. - This event does not decrement the threshold count. -\layout Subsection - -Event Ordering -\layout Standard - -The Portals API guarantees that a when a process initiates two operations - on a remote process, the operations will be initiated on the remote process - in the same order that they were initiated on the original process. - As an example, if process A intitates two -\emph on -put -\emph default - operations, -\emph on -x -\emph default - and -\emph on -y -\emph default -, on process B, the Portals API guarantees that process A will receive the - -\family typewriter -PTL_EVENT_SEND_START -\family default - events for -\emph on -x -\emph default - and -\emph on -y -\emph default - in the same order that process B receives the -\family typewriter -PTL_EVENT_PUT_START -\family default - events for -\emph on -x -\emph default - and -\emph on -y -\emph default -. - Notice that the API does not guarantee that the start events will be delivered - in the same order that process A initiated the -\emph on -x -\emph default - and -\emph on -y -\emph default - operations. - If process A needs to ensure the ordering of these operations, it should - include code to wait for the initiation of -\emph on -x -\emph default - before it initiates -\emph on -y -\emph default -. -\layout Subsection - -Failure Notification -\layout Standard - -Operations may fail to complete successfully; however, unless the node itself - fails, every operation that is started will eventually complete. - While an operation is in progress, the memory associated with the operation - should not be viewed (in the case of a put or a reply) or altered (in the - case of a send or get). - Operation completion, whether successful or unsuccessful, is final. - That is, when an operation completes, the memory associated with the operation - will no longer be read or altered by the operation. - A network interface can use the -\family typewriter -ptl_ni_fail_t -\family default - to define more specific information regarding the failure of the operation - and record this information in the -\family typewriter -ni_fail_type -\family default - field of the event. -\layout Subsection - -The Event Type -\begin_inset LatexCommand \label{sec:event-type} - -\end_inset - - -\layout LyX-Code - -typedef struct { -\newline - ptl_event_kind_t type; -\newline - ptl_process_id_t initiator; -\newline - ptl_uid_t uid; -\layout LyX-Code - - ptl_pt_index_t portal; -\newline - ptl_match_bits_t match_bits; -\newline - ptl_size_t rlength; -\newline - ptl_size_t mlength; -\newline - ptl_size_t offset; -\newline - ptl_handle_md_t md_handle; -\newline - ptl_md_t mem_desc; -\newline - ptl_hdr_data_t hdr_data; -\newline - ptl_seq_t link; -\newline - ptl_ni_fail_t ni_fail_type; -\newline - volatile ptl_seq_t sequence; -\newline -} ptl_event_t; -\layout Standard -\noindent -An event structure includes the following members: -\layout Description - -type Indicates the type of the event. - -\layout Description - -initiator The id of the initiator. - -\layout Description - -portal The Portal table index specified in the request. - -\layout Description - -match_bits A copy of the match bits specified in the request. - See section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:me} - -\end_inset - - for more information on match bits. - -\layout Description - -rlength The length (in bytes) specified in the request. - -\layout Description - -mlength The length (in bytes) of the data that was manipulated by the operation. - For truncated operations, the manipulated length will be the number of - bytes specified by the memory descriptor (possibly with an offset) operation. - For all other operations, the manipulated length will be the length of - the requested operation. - -\layout Description - -offset Is the displacement (in bytes) into the memory region that the operation - used. - The offset can be determined by the operation (see Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:datamovement} - -\end_inset - -) for a remote managed memory descriptor, or by the local memory descriptor - (see Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - -). - -\layout Description - -md_handle Is the handle to the memory descriptor associated with the event. -\layout Description - -mem_desc Is the state of the memory descriptor immediately after the event - has been processed. - -\layout Description - -hdr_data 64 bits of out-of-band user data (see Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - -). - -\layout Description - -link The -\emph on -link -\emph default - member is used to link -\family typewriter -START -\family default - events with the -\family typewriter -END -\family default - or -\family typewriter -FAIL -\family default - event that signifies completion of the operation. - The -\emph on -link -\emph default - member will be the same for the two events associated with an operation. - The link member is also used to link an -\family typewriter -UNLINK -\family default - event with the event that caused the memory descriptor to be unlinked. -\layout Description - -sequence The sequence number for this event. - Sequence numbers are unique to each event. -\layout Comment - -The -\emph on -sequence -\emph default - member is the last member and is volatile to support SMP implementations. - When an event structure is filled in, the -\emph on -sequence -\emph default - member should be written after all other members have been updated. - Moreover, a memory barrier should be inserted between the updating of other - members and the updating of the -\emph on -sequence -\emph default - member. -\layout Subsection - -PtlEQAlloc -\begin_inset LatexCommand \label{sec:eqalloc} - -\end_inset - - -\layout LyX-Code - -int PtlEQAlloc( ptl_handle_ni_t interface, -\newline - ptl_size_t count, -\newline - ptl_handle_eq_t* handle ); -\layout Standard -\noindent -The -\emph on -PtlEQAlloc -\emph default - function is used to build an event queue. - -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid network interface handle. - -\layout Description - -PTL_NOSPACE Indicates that there is insufficient memory to allocate the - event queue. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -handle -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the interface with which the event queue will be associated. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -count -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The number of events that can be stored in the event queue. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold a handle for the newly created - event queue. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlEQFree -\begin_inset LatexCommand \label{sec:eqfree} - -\end_inset - - -\layout LyX-Code - -int PtlEQFree( ptl_handle_eq_t eventq ); -\layout Standard -\noindent -The -\emph on -PtlEQFree -\emph default - function releases the resources associated with an event queue. - It is up to the user to insure that no memory descriptors are associated - with the event queue once it is freed. - -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_EQ Indicates that -\family typewriter -eventq -\family default - is not a valid event queue handle. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -eventq -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard - -A handle for the event queue to be released. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlEQGet -\begin_inset LatexCommand \label{sec:eqget} - -\end_inset - - -\layout LyX-Code - -int PtlEQGet( ptl_handle_eq_t eventq, -\newline - ptl_event_t* event ); -\layout Standard -\noindent -The -\emph on -PTLEQGet -\emph default - function is a nonblocking function that can be used to get the next event - in an event queue. - The event is removed from the queue. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_EQ_DROPPED Indicates success (i.e., an event is returned) and that at - least one event between this event and the last event obtained (using -\emph on -PtlEQGet -\emph default - or -\emph on -PtlEQWait -\emph default -) from this event queue has been dropped due to limited space in the event - queue. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_EQ_EMPTY Indicates that -\family typewriter -eventq -\family default - is empty or another thread is waiting on -\emph on -PtlEQWait -\emph default -. - -\layout Description - -PTL_INV_EQ Indicates that -\family typewriter -eventq -\family default - is not a valid event queue handle. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -event -\family default - is not a legal address. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -eventq -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the event queue. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -event -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold the values associated with - the next event in the event queue. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlEQWait -\begin_inset LatexCommand \label{sec:eqwait} - -\end_inset - - -\layout LyX-Code - -int PtlEQWait( ptl_handle_eq_t eventq, -\newline - ptl_event_t* event ); -\layout Standard -\noindent -The -\emph on -PTLEQWait -\emph default - function can be used to block the calling process (thread) until there - is an event in an event queue. - This function also returns the next event in the event queue and removes - this event from the queue. - This is the only blocking operation in the Portals 3.2 API. - In the event that multiple threads are waiting on the same event queue, - PtlEQWait is guaranteed to wake exactly one thread, but the order in which - they are awakened is not specified. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_EQ_DROPPED Indicates success (i.e., an event is returned) and that at - least one event between this event and the last event obtained (using -\emph on -PtlEQGet -\emph default - or -\emph on -PtlEQWait -\emph default -) from this event queue has been dropped due to limited space in the event - queue. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_EQ Indicates that -\family typewriter -eventq -\family default - is not a valid event queue handle. - -\layout Description - -PTL_SEGV Indicates that -\family typewriter -event -\family default - is not a legal address. - queue handle. - -\layout Subsubsection - -Arguments -\layout Standard -\noindent - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -eventq -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the event queue to wait on. - The calling process (thread) will be blocked until -\family typewriter -eventq -\family default - is not empty. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -event -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -output -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -On successful return, this location will hold the values associated with - the next event in the event queue. -\end_inset - - - - -\end_inset - - -\layout Section - -The Access Control Table -\begin_inset LatexCommand \label{sec:ac} - -\end_inset - - -\layout Standard - -Processes can use the access control table to control which processes are - allowed to perform operations on Portal table entries. - Each communication interface has a Portal table and an access control table. - The access control table for the default interface contains an entry at - index zero that allows all processes with the same user id to communicate. - Entries in the access control table can be manipulated using the -\emph on -PtlACEntry -\emph default - function. -\layout Subsection - -PtlACEntry -\begin_inset LatexCommand \label{sec:acentry} - -\end_inset - - -\layout LyX-Code - -int PtlACEntry( ptl_handle_ni_t interface, -\newline - ptl_ac_index_t index, -\newline - ptl_process_id_t matchid, -\newline - ptl_uid_t user_id, -\newline - ptl_pt_index_t portal ); -\layout Standard -\noindent -The -\emph on -PtlACEntry -\emph default - function can be used to update an entry in the access control table for - an interface. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_NI Indicates that -\family typewriter -interface -\family default - is not a valid network interface handle. - -\layout Description - -PTL_AC_INV_INDEX Indicates that -\family typewriter -index -\family default - is not a valid access control table index. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -matchid -\family default - is not a valid process identifier. - -\layout Description - -PTL_PT_INV_INDEX Indicates that -\family typewriter -portal -\family default - is not a valid Portal table index. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Identifies the interface to use. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -index -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The index of the entry in the access control table to update. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -matchid -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Identifies the process(es) that are allowed to perform operations. - The constants -\family typewriter -PTL_PID_ANY -\family default - and -\family typewriter -PTL_NID_ANY -\family default - can be used to wildcard either of the ids in the -\family typewriter -ptl_process_id_t -\family default - structure. - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -user_id -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Identifies the user that is allowed to perform operations. - The value -\family typewriter -PTL_UID_ANY -\family default - can be used to wildcard the user. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -portal -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Identifies the Portal index(es) that can be used. - The value -\family typewriter -PTL_PT_INDEX_ANY -\family default - can be used to wildcard the Portal index. -\end_inset - - - - -\end_inset - - -\layout Section - -Data Movement Operations -\begin_inset LatexCommand \label{sec:datamovement} - -\end_inset - - -\layout Standard - -The Portals API provides two data movement operations: -\emph on -PtlPut -\emph default - and -\emph on -PtlGet -\emph default -. -\layout Subsection - -PtlPut -\begin_inset LatexCommand \label{sec:put} - -\end_inset - - -\layout LyX-Code - -typedef enum { PTL_ACK_REQ, PTL_NOACK_REQ } ptl_ack_req_t; -\newline - -\newline -int PtlPut( ptl_handle_md_t mem_desc, -\newline - ptl_ack_req_t ack_req, -\newline - ptl_process_id_t target, -\newline - ptl_pt_index_t portal, -\newline - ptl_ac_index_t cookie, -\newline - ptl_match_bits_t match_bits, -\newline - ptl_size_t offset, -\newline - ptl_hdr_data_t hdr_data ); -\layout Standard -\noindent -Values of the type -\family typewriter -ptl_ack_req_t -\family default - are used to control whether an acknowledgement should be sent when the - operation completes (i.e., when the data has been written to a memory descriptor - of the -\family typewriter -target -\family default - process). - The value -\family typewriter -PTL_ACK_REQ -\family default - requests an acknowledgement, the value -\family typewriter -PTL_NOACK_REQ -\family default - requests that no acknowledgement should be generated. -\layout Standard - -The -\emph on -PtlPut -\emph default - function initiates an asynchronous put operation. - There are several events associated with a put operation: initiation of - the send on the local node ( -\family typewriter -PTL_EVENT_SEND_START -\family default -), completion of the send on the local node ( -\family typewriter -PTL_EVENT_SEND_END -\family default - or -\family typewriter -PTL_EVENT_SEND_FAIL -\family default -), and, when the send completes successfully, the receipt of an acknowledgement - ( -\family typewriter -PTL_EVENT_ACK -\family default -) indicating that the operation was accepted by the target. - These events will be logged in the event queue associated with the memory - descriptor ( -\family typewriter -mem_desc -\family default -) used in the put operation. - Using a memory descriptor that does not have an associated event queue - results in these events being discarded. - In this case, the application must have another mechanism (e.g., a higher - level protocol) for determining when it is safe to modify the memory region - associated with the memory descriptor. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_MD Indicates that -\family typewriter -mem_desc -\family default - is not a valid memory descriptor. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -target -\family default - is not a valid process id. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the memory descriptor that describes the memory to be sent. - If the memory descriptor has an event queue associated with it, it will - be used to record events when the message has been sent (PTL_EVENT_SEND_START, - PTL_EVENT_SEND_END). - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ack_req -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -Controls whether an acknowledgement event is requested. - Acknowledgements are only sent when they are requested by the initiating - process -\series bold -and -\series default - the memory descriptor has an event queue -\series bold -and -\series default - the target memory descriptor enables them. - Allowed constants: -\family typewriter -PTL_ACK_REQ -\family default -, -\family typewriter -PTL_NOACK_REQ -\family default -. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -target -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A process id for the target process. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -portal -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The index in the remote Portal table. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -cookie -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The index into the access control table of the target process. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -match_bits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The match bits to use for message selection at the target process. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -offset -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The offset into the target memory descriptor (only used when the target - memory descriptor has the -\family typewriter -PTL_MD_MANAGE_REMOTE -\family default - option set). -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -hdr_data -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -64 bits of user data that can be included in message header. - This data is written to an event queue entry at the target if an event - queue is present on the matching memory descriptor. -\end_inset - - - - -\end_inset - - -\layout Subsection - -PtlGet -\begin_inset LatexCommand \label{sec:get} - -\end_inset - - -\layout LyX-Code - -int PtlGet( ptl_handle_md_t mem_desc, -\newline - ptl_process_id_t target, -\newline - ptl_pt_index_t portal, -\newline - ptl_ac_index_t cookie, -\newline - ptl_match_bits_t match_bits, -\newline - ptl_size_t offset ); -\layout Standard -\noindent -The -\emph on -PtlGet -\emph default - function initiates a remote read operation. - There are two event pairs associated with a get operation , when the data - is sent from the remote node, a -\family typewriter -PTL_EVENT_GET{START|END} -\family default - event pair is registered on the remote node; and when the data is returned - from the remote node a -\family typewriter -PTL_EVENT_REPLY{START|END} -\family default - event pair is registered on the local node. -\layout Subsubsection - -Return Codes -\layout Description - -PTL_OK Indicates success. - -\layout Description - -PTL_NOINIT Indicates that the Portals API has not been successfully initialized. - -\layout Description - -PTL_INV_MD Indicates that -\family typewriter -mem_desc -\family default - is not a valid memory descriptor. - -\layout Description - -PTL_INV_PROC Indicates that -\family typewriter -target -\family default - is not a valid process id. - -\layout Subsubsection - -Arguments -\layout Standard - - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A handle for the memory descriptor that describes the memory into which - the requested data will be received. - The memory descriptor can have an event queue associated with it to record - events, such as when the message receive has started ( -\family typewriter -PTL_EVENT_REPLY -\family default -_ -\family typewriter -START -\family default -). -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -target -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -A process id for the target process. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -portal -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The index in the remote Portal table. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -cookie -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The index into the access control table of the target process. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -match_bits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The match bits to use for message selection at the target process. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -offset -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -input -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -The offset into the target memory descriptor (only used when the target - memory descriptor has the -\family typewriter -PTL_MD_MANAGE_REMOTE -\family default - option set). -\end_inset - - - - -\end_inset - - -\layout Section - -Summary -\layout Standard - - -\begin_inset LatexCommand \label{sec:summary} - -\end_inset - - We conclude this section by summarizing the names introduced by the Portals - 3.2 API. - We start by summarizing the names of the types introduced by the API. - This is followed by a summary of the functions introduced by the API. - Which is followed by a summary of the function return codes. - Finally, we conclude with a summary of the other constant values introduced - by the API. -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:types} - -\end_inset - - presents a summary of the types defined by the Portals API. - The first column in this table gives the type name, the second column gives - a brief description of the type, the third column identifies the section - where the type is defined, and the fourth column lists the functions that - have arguments of this type. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Types Defined by the Portals 3.2 API -\begin_inset LatexCommand \label{tab:types} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\noindent - -\size small - -\begin_inset Tabular - - - - - - - - -\begin_inset Text - -\layout Standard - - -\series bold - Name -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold - Meaning -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold - Sect -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold - Functions -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ac_index_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -indexes for an access control table -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:index-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlACEntry, PtlPut, PtlGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ack_req_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -acknowledgement request types -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlPut -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -kinds of events -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -information about events -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:event-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlEQGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -plt_seq_t -\end_inset - - -\begin_inset Text - -\layout Standard - -event sequence number -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:event-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -PtlEQGet, PtlEQWait -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_any_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -handles for any object -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:handle-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIHandle -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_eq_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -handles for event queues -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:handle-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlEQAlloc, PtlEQFree, PtlEQGet, PtlEQWait, PtlMDUpdate -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_md_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -handles for memory descriptors -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:handle-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMDAlloc, PtlMDUnlink, PtlMDUpdate, PtlMEAttach, PtlMEAttachAny, PtlMEInsert, - PtlPut, PtlGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_me_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -handles for match entries -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:handle-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMEAttach, PtlMEAttachAny, PtlMEInsert, PtlMEUnlink -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_ni_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -handles for network interfaces -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:handle-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit, PtlNIFini, PtlNIStatus, PtlNIDist, PtlEQAlloc, PtlACEntry, PtlPut, - PtlGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_nid_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -node identifiers -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlGetId,PtlACEntry -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pid_t -\end_inset - - -\begin_inset Text - -\layout Standard - -process identifier -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -PtlGetId, PtlACEntry -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_uid_t -\end_inset - - -\begin_inset Text - -\layout Standard - -user indentifier -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -PtlGetUid, PtlACEntry -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ins_pos_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -insertion position (before or after) -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMEAttach, PtlMEAttachAny, PtlMEInsert -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_interface_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -identifiers for network interfaces -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_match_bits_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -match (and ignore) bits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:mb-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMEAttach, PtlMEAttachAny, PtlMEInsert, PtlPut, PtlGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_md_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -memory descriptors -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMDAttach, PtlMDUpdate -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ni_fail_t -\end_inset - - -\begin_inset Text - -\layout Standard - -network interface-specific failures -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:eq} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -PtlEQGet, PtlEQWait -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -process identifiers -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:pid-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlGetId, PtlNIDist, PtlMEAttach, PtlMEAttachAny, PtlACEntry, PtlPut, PtlGet - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pt_index_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -indexes for Portal tables -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:index-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMEAttach, PtlMEAttachAny, PtlACEntry -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -sizes -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:size-t} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlEQAlloc, PtlPut, PtlGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_sr_index_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -indexes for status registers -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:stat-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIStatus -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_sr_value_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -values in status registers -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:stat-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIStatus -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_unlink_t -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -unlink options -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMEAttach, PtlMEAttachAny, PtlMEInsert, PtlMDAttach -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:func} - -\end_inset - - presents a summary of the functions defined by the Portals API. - The first column in this table gives the name for the function, the second - column gives a brief description of the operation implemented by the function, - and the third column identifies the section where the function is defined. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Functions Defined by the Portals 3.2 API -\begin_inset LatexCommand \label{tab:func} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - -Name -\end_inset - - -\begin_inset Text - -\layout Standard - - Operation -\end_inset - - -\begin_inset Text - -\layout Standard - - Section -\end_inset - - - - -\begin_inset Text - -\layout Standard - -PtlACEntry -\end_inset - - -\begin_inset Text - -\layout Standard - - update an entry in an access control table -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ac} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlEQAlloc -\end_inset - - -\begin_inset Text - -\layout Standard - - create an event queue -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:eq} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlEQGet -\end_inset - - -\begin_inset Text - -\layout Standard - - get the next event from an event queue -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:eq} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlEQFree -\end_inset - - -\begin_inset Text - -\layout Standard - - release the resources for an event queue -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:eq} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlEQWait -\end_inset - - -\begin_inset Text - -\layout Standard - - wait for a new event in an event queue -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:eq} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlFini -\end_inset - - -\begin_inset Text - -\layout Standard - - shutdown the Portals API -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:init} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlGet -\end_inset - - -\begin_inset Text - -\layout Standard - - perform a get operation -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:datamovement} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlGetId -\end_inset - - -\begin_inset Text - -\layout Standard - - get the id for the current process -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:pid} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlInit -\end_inset - - -\begin_inset Text - -\layout Standard - - initialize the Portals API -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:init} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlMDAttach -\end_inset - - -\begin_inset Text - -\layout Standard - - create a memory descriptor and attach it to a match entry -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlMDBind -\end_inset - - -\begin_inset Text - -\layout Standard - - create a free-floating memory descriptor -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:mdbind} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlMDUnlink -\end_inset - - -\begin_inset Text - -\layout Standard - - remove a memory descriptor from a list and release its resources -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlMDUpdate -\end_inset - - -\begin_inset Text - -\layout Standard - - update a memory descriptor -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlMEAttach -\end_inset - - -\begin_inset Text - -\layout Standard - -create a match entry and attach it to a Portal table -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:me} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -PtlMEAttachAny -\end_inset - - -\begin_inset Text - -\layout Standard - -create a match entry and attach it to a free Portal table entry -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:attachany} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlMEInsert -\end_inset - - -\begin_inset Text - -\layout Standard - - create a match entry and insert it in a list -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:me} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlMEUnlink -\end_inset - - -\begin_inset Text - -\layout Standard - - remove a match entry from a list and release its resources -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:me} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlNIDist -\end_inset - - -\begin_inset Text - -\layout Standard - - get the distance to another process -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlNIFini -\end_inset - - -\begin_inset Text - -\layout Standard - - shutdown a network interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlNIHandle -\end_inset - - -\begin_inset Text - -\layout Standard - - get the network interface handle for an object -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlNIInit -\end_inset - - -\begin_inset Text - -\layout Standard - - initialize a network interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlNIStatus -\end_inset - - -\begin_inset Text - -\layout Standard - - read a network interface status register -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - PtlPut -\end_inset - - -\begin_inset Text - -\layout Standard - - perform a put operation -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:datamovement} - -\end_inset - - -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:retcodes} - -\end_inset - - summarizes the return codes used by functions defined by the Portals API. - All of these constants are integer values. - The first column of this table gives the symbolic name for the constant, - the second column gives a brief description of the value, and the third - column identifies the functions that can return this value. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Function Return Codes for the Portals 3.2 API -\begin_inset LatexCommand \label{tab:retcodes} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - -\begin_inset Text - -\layout Standard - - -\series bold -Name -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Meaning -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Functions -\series default - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_AC_INV_INDEX -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid access control table index -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlACEntry -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EQ_DROPPED -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -at least one event has been dropped -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlEQGet, PtlWait -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EQ_EMPTY -\end_inset - - -\begin_inset Text - -\layout Standard - -no events available in an event queue -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlEQGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_FAIL -\end_inset - - -\begin_inset Text - -\layout Standard - -error during initialization or cleanup -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlInit, PtlFini -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_ILL_MD -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -illegal memory descriptor values -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMDAttach, PtlMDBind, PtlMDUpdate -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INIT_DUP -\end_inset - - -\begin_inset Text - -\layout Standard - -duplicate initialization of an interface -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INIT_INV -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -initialization of an invalid interface -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INUSE -\end_inset - - -\begin_inset Text - -\layout Standard - -the ME already has an MD -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMDAttach -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_ASIZE -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid access control table size -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_EQ -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid event queue handle -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMDUpdate, PtlEQFree, PtlEQGet -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_HANDLE -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid handle -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIHandle -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_MD -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid memory descriptor handle -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMDUnlink, PtlMDUpdate -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_ME -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid match entry handle -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlMDAttach -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_NI -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid network interface handle -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIDist, PtlNIFini, PtlMDBind, PtlEQAlloc -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_PROC -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid process identifier -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit, PtlNIDist, PtlMEAttach, PtlMEInsert, PtlACEntry, PtlPut, PtlGet - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_PTINDEX -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid Portal table index -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlMEAttach -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_REG -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid status register -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlNIStatus -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INV_SR_INDX -\end_inset - - -\begin_inset Text - -\layout Standard - -invalid status register index -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlNIStatus -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_ML_TOOLONG -\end_inset - - -\begin_inset Text - -\layout Standard - -match list too long -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlMEAttach, PtlMEInsert -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_MD_INUSE -\end_inset - - -\begin_inset Text - -\layout Standard - -MD has pending operations -\end_inset - - -\begin_inset Text - -\layout Standard - -PtlMDUnlink -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_NOINIT -\end_inset - - -\begin_inset Text - -\layout Standard - -uninitialized API -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - -\emph on -all -\emph default -, except PtlInit -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_NOSPACE -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -insufficient memory -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit, PtlMDAttach, PtlMDBind, PtlEQAlloc, PtlMEAttach, PtlMEInsert - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_NOUPDATE -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - no update was performed -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - PtlMDUpdate -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_PT_FULL -\end_inset - - -\begin_inset Text - -\layout Standard - -Portal table is full -\end_inset - - -\begin_inset Text - -\layout Standard - -PtlMEAttachAny -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_OK -\end_inset - - -\begin_inset Text - -\layout Standard - - success -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent - -\emph on -all -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_SEGV -\end_inset - - -\begin_inset Text - -\layout Standard - -addressing violation -\end_inset - - -\begin_inset Text - -\layout Standard -\noindent -PtlNIInit, PtlNIStatus, PtlNIDist, PtlNIHandle, PtlMDBind, PtlMDUpdate, - PtlEQAlloc, PtlEQGet, PtlEQWait -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:oconsts} - -\end_inset - - summarizes the remaining constant values introduced by the Portals API. - The first column in this table presents the symbolic name for the constant, - the second column gives a brief description of the value, the third column - identifies the type for the value, and the fourth column identifies the - sections in which the value is mentioned. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Other Constants Defined by the Portals 3.2 API -\begin_inset LatexCommand \label{tab:oconsts} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - - - -\begin_inset Text - -\layout Standard - - -\series bold -Name -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Meaning -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Base type -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Intr. -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Ref. -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_ACK_REQ -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -request an acknowledgement -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ack_req_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EQ_NONE -\end_inset - - -\begin_inset Text - -\layout Standard - -a NULL event queue handle -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_eq_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:handle-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md} - -\end_inset - -, -\begin_inset LatexCommand \ref{sec:mdupdate} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_GET_START -\end_inset - - -\begin_inset Text - -\layout Standard - -get event start -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:get} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_GET_END -\end_inset - - -\begin_inset Text - -\layout Standard - -get event end -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:get} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_GET_FAIL -\end_inset - - -\begin_inset Text - -\layout Standard - -get event fail -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:get} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_PUT_START -\end_inset - - -\begin_inset Text - -\layout Standard - -put event start -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_PUT_END -\end_inset - - -\begin_inset Text - -\layout Standard - -put event end -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_PUT_FAIL -\end_inset - - -\begin_inset Text - -\layout Standard - -put event fail -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_REPLY_START -\end_inset - - -\begin_inset Text - -\layout Standard - -reply event start -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:get} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_REPLY_END -\end_inset - - -\begin_inset Text - -\layout Standard - -reply event end -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:get} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_REPLY_FAIL -\end_inset - - -\begin_inset Text - -\layout Standard - -reply event fail -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:get} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_ACK_START -\end_inset - - -\begin_inset Text - -\layout Standard - -acknowledgement event start -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_ACK_END -\end_inset - - -\begin_inset Text - -\layout Standard - -acknowledgement event end -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_ACK_FAIL -\end_inset - - -\begin_inset Text - -\layout Standard - -acknowledgement event fail -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_SEND_START -\end_inset - - -\begin_inset Text - -\layout Standard - -send event start -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_SEND_END -\end_inset - - -\begin_inset Text - -\layout Standard - -send event end -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_SEND_FAIL -\end_inset - - -\begin_inset Text - -\layout Standard - -send event fail -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_EVENT_UNLINK -\end_inset - - -\begin_inset Text - -\layout Standard - -unlink event -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_event_kind_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ek-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_PID_ANY -\end_inset - - -\begin_inset Text - -\layout Standard - -wildcard for process id fields -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pid_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - -, -\begin_inset LatexCommand \ref{sec:acentry} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_NID_ANY -\end_inset - - -\begin_inset Text - -\layout Standard - -wildcard for node id fields -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_nid_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - -, -\begin_inset LatexCommand \ref{sec:acentry} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_UID_ANY -\end_inset - - -\begin_inset Text - -\layout Standard - -wildcard for user id -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_uid_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:id-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:meattach} - -\end_inset - -, -\begin_inset LatexCommand \ref{sec:acentry} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_IFACE_DEFAULT -\end_inset - - -\begin_inset Text - -\layout Standard - -default interface -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_interface_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:ni-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INS_AFTER -\end_inset - - -\begin_inset Text - -\layout Standard - -insert after -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ins_pos_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:meinsert} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_INS_BEFORE -\end_inset - - -\begin_inset Text - -\layout Standard - -insert before -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ins_pos_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:meinsert} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_MD_ACK_DISABLE -\end_inset - - -\begin_inset Text - -\layout Standard - -a flag to disable acknowledgements -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_MD_MANAGE_REMOTE -\end_inset - - -\begin_inset Text - -\layout Standard - -a flag to enable the use of remote offsets -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - -, -\begin_inset LatexCommand \ref{sec:get} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_MD_OP_GET -\end_inset - - -\begin_inset Text - -\layout Standard - -a flag to enable get operations -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_MD_OP_PUT -\end_inset - - -\begin_inset Text - -\layout Standard - -a flag to enable put operations -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_MD_THRESH_INF -\end_inset - - -\begin_inset Text - -\layout Standard - -infinite threshold for a memory descriptor -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_MD_TRUNCATE -\end_inset - - -\begin_inset Text - -\layout Standard - -a flag to enable truncation of a request -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:md-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_NOACK_REQ -\end_inset - - -\begin_inset Text - -\layout Standard - -request no acknowledgement -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ack_req_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:put} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_PT_INDEX_ANY -\end_inset - - -\begin_inset Text - -\layout Standard - -wildcard for Portal indexes -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pt_index_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:acentry} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_RETAIN -\end_inset - - -\begin_inset Text - -\layout Standard - -disable unlinking -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_unlink_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:mdattach} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_SR_DROP_COUNT -\end_inset - - -\begin_inset Text - -\layout Standard - -index for the dropped count register -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_sr_index_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:stat-type} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:nistatus} - -\end_inset - - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - -\family typewriter -PTL_UNLINK -\end_inset - - -\begin_inset Text - -\layout Standard - -enable unlinking -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_unlink_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\begin_inset LatexCommand \ref{sec:mdattach} - -\end_inset - - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Chapter - -The Semantics of Message Transmission -\begin_inset LatexCommand \label{sec:semantics} - -\end_inset - - -\layout Standard - -The portals API uses four types of messages: put requests, acknowledgements, - get requests, and replies. - In this section, we describe the information passed on the wire for each - type of message. - We also describe how this information is used to process incoming messages. -\layout Section - -Sending Messages -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:put-wire} - -\end_inset - - summarizes the information that is transmitted for a put request. - The first column provides a descriptive name for the information, the second - column provides the type for this information, the third column identifies - the source of the information, and the fourth column provides additional - notes. - Most information that is transmitted is obtained directly from the -\emph on -PtlPut -\emph default - operation. - Notice that the handle for the memory descriptor used in the -\emph on -PtlPut -\emph default - operation is transmitted even though this value cannot be interpreted by - the target. - A value of anything other than -\family typewriter -PTL_MD_NONE -\family default -, is interpreted as a request for an acknowledgement. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Information Passed in a Put Request -\begin_inset LatexCommand \label{tab:put-wire} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - - -\begin_inset Text - -\layout Standard - - -\series bold -Information -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Type -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -\emph on -PtlPut -\emph default - arg -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Notes -\end_inset - - - - -\begin_inset Text - -\layout Standard - -operation -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -indicates a put request -\end_inset - - - - -\begin_inset Text - -\layout Standard - -initiator -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -local information -\end_inset - - - - -\begin_inset Text - -\layout Standard - -user -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_uid_t -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -local information -\end_inset - - - - -\begin_inset Text - -\layout Standard - -target -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -target -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -portal index -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pt_index_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -portal -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -cookie -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ac_index_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -cookie -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -match bits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_match_bits_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -match_bits -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -offset -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -offset -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -memory desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_md_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -no ack if -\family typewriter -PTL_MD_NONE -\end_inset - - - - -\begin_inset Text - -\layout Standard - -length -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -length -\family default - member -\end_inset - - - - -\begin_inset Text - -\layout Standard - -data -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family roman -\emph on -bytes -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -start -\family default - and -\family typewriter -length -\family default - members -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:ack-wire} - -\end_inset - - summarizes the information transmitted in an acknowledgement. - Most of the information is simply echoed from the put request. - Notice that the initiator and target are obtained directly from the put - request, but are swapped in generating the acknowledgement. - The only new piece of information in the acknowledgement is the manipulated - length which is determined as the put request is satisfied. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Information Passed in an Acknowledgement -\begin_inset LatexCommand \label{tab:ack-wire} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - - -\begin_inset Text - -\layout Standard - - -\series bold -Information -\series default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Type -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Put Information -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Notes -\end_inset - - - - -\begin_inset Text - -\layout Standard - -operation -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - - indicates an acknowledgement -\end_inset - - - - -\begin_inset Text - -\layout Standard - - initiator -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - - target -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - target -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - - initiator -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - - portal index -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pt_index_t -\end_inset - - -\begin_inset Text - -\layout Standard - - portal index -\end_inset - - -\begin_inset Text - -\layout Standard - - echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - - match bits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_match_bits_t -\end_inset - - -\begin_inset Text - -\layout Standard - - match bits -\end_inset - - -\begin_inset Text - -\layout Standard - - echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - - offset -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\end_inset - - -\begin_inset Text - -\layout Standard - - offset -\end_inset - - -\begin_inset Text - -\layout Standard - - echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - - memory desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter - ptl_handle_md_t -\end_inset - - -\begin_inset Text - -\layout Standard - - memory desc -\end_inset - - -\begin_inset Text - -\layout Standard - - echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - - requested length -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter - ptl_size_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - - length -\end_inset - - -\begin_inset Text - -\layout Standard - - echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - - manipulated length -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter - ptl_size_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - - obtained from the operation -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:get-wire} - -\end_inset - - summarizes the information that is transmitted for a get request. - Like the information transmitted in a put request, most of the information - transmitted in a get request is obtained directly from the -\emph on -PtlGet -\emph default - operation. - Unlike put requests, get requests do not include the event queue handle. - In this case, the reply is generated whenever the operation succeeds and - the memory descriptor must not be unlinked until the reply is received. - As such, there is no advantage to explicitly sending the event queue handle. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Information Passed in a Get Request -\begin_inset LatexCommand \label{tab:get-wire} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - - -\begin_inset Text - -\layout Standard - - -\series bold -Information -\series default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Type -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -\emph on -PtlGet -\emph default - argument -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Notes -\end_inset - - - - -\begin_inset Text - -\layout Standard - -operation -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -indicates a get operation -\end_inset - - - - -\begin_inset Text - -\layout Standard - -initiator -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -local information -\end_inset - - - - -\begin_inset Text - -\layout Standard - -user -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_uid_t -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -local information -\end_inset - - - - -\begin_inset Text - -\layout Standard - -target -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -target -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -portal index -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pt_index_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -portal -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -cookie -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_ac_index_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -cookie -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -match bits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_match_bits_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -match_bits -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -offset -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -offset -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -memory desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_md_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -length -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -mem_desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -length -\family default - member -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Standard - -Table\SpecialChar ~ - -\begin_inset LatexCommand \ref{tab:reply-wire} - -\end_inset - - summarizes the information transmitted in a reply. - Like an acknowledgement, most of the information is simply echoed from - the get request. - The initiator and target are obtained directly from the get request, but - are swapped in generating the acknowledgement. - The only new information in the acknowledgement are the manipulated length - and the data, which are determined as the get request is satisfied. -\layout Standard - - -\begin_inset Float table -placement htbp -wide false -collapsed false - -\layout Caption - -Information Passed in a Reply -\begin_inset LatexCommand \label{tab:reply-wire} - -\end_inset - - -\layout Standard - - -\begin_inset ERT -status Collapsed - -\layout Standard - -\backslash -medskip -\end_inset - - -\layout Standard -\align center - -\size small - -\begin_inset Tabular - - - - - - - - -\begin_inset Text - -\layout Standard - - -\series bold -Information -\series default - -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Type -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Put Information -\end_inset - - -\begin_inset Text - -\layout Standard - - -\series bold -Notes -\end_inset - - - - -\begin_inset Text - -\layout Standard - -operation -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -int -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -indicates an acknowledgement -\end_inset - - - - -\begin_inset Text - -\layout Standard - -initiator -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - -target -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -target -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_process_id_t -\end_inset - - -\begin_inset Text - -\layout Standard - -initiator -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - - - -\begin_inset Text - -\layout Standard - -portal index -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_pt_index_t -\end_inset - - -\begin_inset Text - -\layout Standard - -portal index -\end_inset - - -\begin_inset Text - -\layout Standard - -echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - -match bits -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_match_bits_t -\end_inset - - -\begin_inset Text - -\layout Standard - -match bits -\end_inset - - -\begin_inset Text - -\layout Standard - -echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - -offset -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -offset -\end_inset - - -\begin_inset Text - -\layout Standard - -echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - -memory desc -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_handle_md_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -memory desc -\end_inset - - -\begin_inset Text - -\layout Standard - -echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - -requested length -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -length -\end_inset - - -\begin_inset Text - -\layout Standard - -echo -\end_inset - - - - -\begin_inset Text - -\layout Standard - -manipulated length -\end_inset - - -\begin_inset Text - -\layout Standard - - -\family typewriter -ptl_size_t -\family default - -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -obtained from the operation -\end_inset - - - - -\begin_inset Text - -\layout Standard - -data -\end_inset - - -\begin_inset Text - -\layout Standard - - -\emph on -bytes -\end_inset - - -\begin_inset Text - -\layout Standard - -\end_inset - - -\begin_inset Text - -\layout Standard - -obtained from the operation -\end_inset - - - - -\end_inset - - -\end_inset - - -\layout Section - -Receiving Messages -\begin_inset LatexCommand \label{sec:receiving} - -\end_inset - - -\layout Standard - -When an incoming message arrives on a network interface, the communication - system first checks that the target process identified in the request is - a valid process that has initialized the network interface (i.e., that the - target process has a valid Portal table). - If this test fails, the communication system discards the message and increment -s the dropped message count for the interface. - The remainder of the processing depends on the type of the incoming message. - Put and get messages are subject to access control checks and translation - (searching a match list), while acknowledgement and reply messages bypass - the access control checks and the translation step. -\layout Standard - -Acknowledgement messages include a handle for the memory descriptor used - in the original -\emph on -PtlPut -\emph default - operation. - This memory descriptor will identify the event queue where the event should - be recorded. - Upon receipt of an acknowledgement, the runtime system only needs to confirm - that the memory descriptor and event queue still exist and that there is - space for another event. - Should the any of these conditions fail, the message is simply discarded - and the dropped message count for the interface is incremented. - Otherwise, the system builds an acknowledgement event from the information - in the acknowledgement message and adds it to the event queue. -\layout Standard - -Reception of reply messages is also relatively straightforward. - Each reply message includes a handle for a memory descriptor. - If this descriptor exists, it is used to receive the message. - A reply message will be dropped if the memory descriptor identified in - the request doesn't exist. - In either of this case, the dropped message count for the interface is - incremented. - These are the only reasons for dropping reply messages. - Every memory descriptor accepts and truncates incoming reply messages, - eliminating the other potential reasons for rejecting a reply message. -\layout Standard - -The critical step in processing an incoming put or get request involves - mapping the request to a memory descriptor. - This step starts by using the Portal index in the incoming request to identify - a list of match entries. - This list of match entries is searched in order until a match entry is - found whose match criteria matches the match bits in the incoming request - and whose memory descriptor accepts the request. -\layout Standard - -Because acknowledge and reply messages are generated in response to requests - made by the process receiving these messages, the checks performed by the - runtime system for acknowledgements and replies are minimal. - In contrast, put and get messages are generated by remote processes and - the checks performed for these messages are more extensive. - Incoming put or get messages may be rejected because: -\layout Itemize - -the Portal index supplied in the request is not valid; -\layout Itemize - -the cookie supplied in the request is not a valid access control entry; - -\layout Itemize - -the access control entry identified by the cookie does not match the identifier - of the requesting process; -\layout Itemize - -the access control entry identified by the access control entry does not - match the Portal index supplied in the request; or -\layout Itemize - -the match bits supplied in the request do not match any of the match entries - with a memory descriptor that accepts the request. - -\layout Standard - -In all cases, if the message is rejected, the incoming message is discarded - and the dropped message count for the interface is incremented. -\layout Standard - -A memory descriptor may reject an incoming request for any of the following - reasons: -\layout Itemize - -the -\family typewriter -PTL_MD_PUT -\family default - or -\family typewriter -PTL_MD_GET -\family default - option has not been enabled and the operation is put or get, respectively; - -\layout Itemize - -the length specified in the request is too long for the memory descriptor - and the -\family typewriter -PTL_MD_TRUNCATE -\family default - option has not been enabled. -\layout Chapter - -Examples -\begin_inset LatexCommand \label{sec:examples} - -\end_inset - - -\layout Comment - -The examples presented in this chapter have not been updated to reflect - the current API. -\layout Standard - -In this section we present several example to illustrate expected usage - patterns for the Portals 3.2 API. - The first example describes how to implement parallel servers using the - features of the Portals 3.2 API. - This example covers the access control list and the use of remote managed - offsets. - The second example presents an approach to dealing with dropped requests. - This example covers aspects of match lists and memory descriptors. - The final example covers message reception in MPI. - This example illustrates more sophisticated uses of matching and a procedure - to update a memory descriptor. -\layout Section - -Parallel File Servers -\begin_inset LatexCommand \label{sec:expfs} - -\end_inset - - -\layout Standard - -Figure\SpecialChar ~ - -\begin_inset LatexCommand \ref{fig:file} - -\end_inset - - illustrates the logical structure of a parallel file server. - In this case, the parallel server consists of four servers that stripe - application data across four disks. - We would like to present applications with the illusion that the file server - is a single entity. - We will assume that all of the processes that constitute the parallel server - have the same user id. -\layout Standard - - -\begin_inset Float figure -placement htbp -wide false -collapsed false - -\layout Standard -\align center - -\begin_inset Graphics FormatVersion 1 - filename file.eps - display color - size_type 0 - rotateOrigin center - lyxsize_type 1 - lyxwidth 196pt - lyxheight 147pt -\end_inset - - -\layout Caption - -Parallel File Server -\begin_inset LatexCommand \label{fig:file} - -\end_inset - - -\end_inset - - -\layout Standard - -When an application establishes a connection to the parallel file server, - it will allocate a Portal and access control list entry for communicating - with the server. - The access control list entry will include the Portal and match any process - in the parallel file server's, so all of the file server processes will - have access to the portal. - The Portal information and access control entry will be sent to the file - server at this time. - If the application and server need to have multiple, concurrent I/O operations, - they can use additional portals or match entries to keep the operations - from interfering with one another. -\layout Standard - -When an application initiates an I/O operation, it first builds a memory - descriptor that describes the memory region involved in the operation. - This memory descriptor will enable the appropriate operation (put for read - operations and get for write operations) and enable the use of remote offsets - (this lets the servers decide where their data should be placed in the - memory region). - After creating the memory descriptor and linking it into the appropriate - Portal entry, the application sends a read or write request (using -\emph on -PtlPut -\emph default -) to one of the file server processes. - The file server processes can then use put or get operations with the appropria -te offsets to fill or retrieve the contents of the application's buffer. - To know when the operation has completed, the application can add an event - queue to the memory descriptor and add up the lengths of the remote operations - until the sum is the size of the requested I/O operation. -\layout Section - -Dealing with Dropped Requests -\begin_inset LatexCommand \label{sec:exdrop} - -\end_inset - - -\layout Standard - -If a process does not anticipate unexpected requests, they will be discarded. - Applications using the Portals API can query the dropped count for the - interface to determine the number of requests that have been dropped (see - Section\SpecialChar ~ - -\begin_inset LatexCommand \ref{sec:nistatus} - -\end_inset - -). - While this approach minimizes resource consumption, it does not provide - information that might be critical in debugging the implementation of a - higher level protocol. -\layout Standard - -To keep track of more information about dropped requests, we use a memory - descriptor that truncates each incoming request to zero bytes and logs - the -\begin_inset Quotes eld -\end_inset - -dropped -\begin_inset Quotes erd -\end_inset - - operations in an event queue. - Note that the operations are not dropped in the Portals sense, because - the operation succeeds. -\layout Standard - -The following code fragment illustrates an implementation of this approach. - In this case, we assume that a thread is launched to execute the function - -\family typewriter -watch_drop -\family default -. - This code starts by building an event queue to log truncated operations - and a memory descriptor to truncate the incoming requests. - This example only captures -\begin_inset Quotes eld -\end_inset - -dropped -\begin_inset Quotes erd -\end_inset - - requests for a single portal. - In a more realistic situation, the memory descriptor would be appended - to the match list for every portal. - We also assume that the thread is capable of keeping up with the -\begin_inset Quotes eld -\end_inset - -dropped -\begin_inset Quotes erd -\end_inset - - requests. - If this is not the case, we could use a finite threshold on the memory - descriptor to capture the first few dropped requests. -\layout LyX-Code - - -\size small -#include -\newline -#include -\newline -#include -\newline - -\newline -#define DROP_SIZE 32 /* number of dropped requests to track */ -\newline - -\newline -int watch_drop( ptl_handle_ni_t ni, ptl_pt_index_t index ) { -\newline - ptl_handle_eq_t drop_events; -\newline - ptl_event_t event; -\newline - ptl_handle_md_t drop_em; -\newline - ptl_md_t drop_desc; -\newline - ptl_process_id_t any_proc; -\newline - ptl_handle_me_t match_any; -\newline - -\newline - /* create the event queue */ -\newline - if( PtlEQAlloc(ni, DROP_SIZE, &drop_events) != PTL_OK ) { -\newline - fprintf( stderr, "Couldn't create the event queue -\backslash -n" ); -\newline - exit( 1 ); -\newline - } -\newline - -\newline - /* build a match entry */ -\newline - any_proc.nid = PTL_ID_ANY; -\newline - any_proc.pid = PTL_ID_ANY; -\newline - PtlMEAttach( index, any_proc, 0, ~(ptl_match_bits_t)0, PTL_RETAIN, -\newline - &match_any ); -\newline - -\newline - /* create the memory descriptor */ -\newline - drop_desc.start = NULL; -\newline - drop_desc.length = 0; -\newline - drop_desc.threshold = PTL_MD_THRESH_INF; -\newline - drop_desc.options = PTL_MD_OP_PUT | PTL_MD_OP_GET | PTL_MD_TRUNCATE; -\newline - drop_desc.user_ptr = NULL; -\newline - drop_desc.eventq = drop_events; -\newline - if( PtlMDAttach(match_any, drop_desc, &drop_em) != PTL_OK ) { -\newline - fprintf( stderr, "Couldn't create the memory descriptor -\backslash -n" ); -\newline - exit( 1 ); -\newline - } -\newline - -\newline - /* watch for "dropped" requests */ -\newline - while( 1 ) { -\newline - if( PtlEQWait( drop_events, &event ) != PTL_OK ) break; -\newline - fprintf( stderr, "Dropped request from gid = event.initiator.gid, - event.initiator.rid ); -\newline - } -\newline -} -\layout Section - -Message Transmission in MPI -\begin_inset LatexCommand \label{sec:exmpi} - -\end_inset - - -\layout Standard - -We conclude this section with a fairly extensive example that describes - an approach to implementing message transmission for MPI. - Like many MPI implementations, we distinguish two message transmission - protocols: a short message protocol and a long message protocol. - We use the constant -\family typewriter -MPI_LONG_LENGTH -\family default - to determine the size of a long message. -\layout Standard - -For small messages, the sender simply sends the message and presumes that - the message will be received (i.e., the receiver has allocated a memory region - to receive the message body). - For large messages, the sender also sends the message, but does not presume - that the message body will be saved. - Instead, the sender builds a memory descriptor for the message and enables - get operations on this descriptor. - If the target does not save the body of the message, it will record an - event for the put operation. - When the process later issues a matching MPI receive, it will perform a - get operation to retrieve the body of the message. -\layout Standard - -To facilitate receive side matching based on the protocol, we use the most - significant bit in the match bits to indicate the protocol: 1 for long - messages and 0 for short messages. -\layout Standard - -The following code presents a function that implements the send side of - the protocol. - The global variable -\family typewriter -EndGet -\family default - is the last match entry attached to the Portal index used for posting long - messages. - This entry does not match any incoming requests (i.e., the memory descriptor - rejects all get operations) and is built during initialization of the MPI - library. - The other global variable, -\family typewriter -MPI_NI -\family default -, is a handle for the network interface used by the MPI implementation. -\layout LyX-Code - - -\size small -extern ptl_handle_me_t EndGet; -\newline -extern ptl_handle_ni_t MPI_NI; -\newline - -\newline -void MPIsend( void *buf, ptl_size_t len, void *data, ptl_handle_eq_t eventq, -\newline - ptl_process_id target, ptl_match_bits_t match ) -\newline -{ -\newline - ptl_handle_md_t send_handle; -\newline - ptl_md_t mem_desc; -\newline - ptl_ack_req_t want_ack; -\newline - -\newline - mem_desc.start = buf; -\newline - mem_desc.length = len; -\newline - mem_desc.threshold = 1; -\newline - mem_desc.options = PTL_MD_GET_OP; -\newline - mem_desc.user_ptr = data; -\newline - mem_desc.eventq = eventq; -\newline - -\newline - if( len >= MPI_LONG_LENGTH ) { -\newline - ptl_handle_me_t me_handle; -\newline - -\newline - /* add a match entry to the end of the get list */ -\newline - PtlMEInsert( target, match, 0, PTL_UNLINK, PTL_INS_BEFORE, EndGet, - &me_handle ); -\newline - PtlMDAttach( me_handle, mem_desc, PTL_UNLINK, NULL ); -\newline - -\newline - /* we want an ack for long messages */ -\newline - want_ack = PTL_ACK_REQ; -\newline - -\newline - /* set the protocol bit to indicate that this is a long message - */ -\newline - match |= 1<<63; -\newline - } else { -\newline - /* we don't want an ack for short messages */ -\newline - want_ack = PTL_ACK_REQ; -\newline - -\newline - /* set the protocol bit to indicate that this is a short message - */ -\newline - match &= ~(1<<63); -\newline - } -\newline - -\newline - /* create a memory descriptor and send it */ -\newline - PtlMDBind( MPI_NI, mem_desc, &send_handle ); -\newline - PtlPut( send_handle, want_ack, target, MPI_SEND_PINDEX, MPI_AINDEX, match, - 0 ); -\newline -} -\layout Standard - -The -\emph on -MPISend -\emph default - function returns as soon as the message has been scheduled for transmission. - The event queue argument, -\family typewriter -eventq -\family default -, can be used to determine the disposition of the message. - Assuming that -\family typewriter -eventq -\family default - is not -\family typewriter -PTL_EQ_NONE -\family default -, a -\family typewriter -PTL_EVENT_SENT -\family default - event will be recorded for each message as the message is transmitted. - For small messages, this is the only event that will be recorded in -\family typewriter -eventq -\family default -. - In contrast, long messages include an explicit request for an acknowledgement. - If the -\family typewriter -target -\family default - process has posted a matching receive, the acknowledgement will be sent - as the message is received. - If a matching receive has not been posted, the message will be discarded - and no acknowledgement will be sent. - When the -\family typewriter -target -\family default - process later issues a matching receive, the receive will be translated - into a get operation and a -\family typewriter -PTL_EVENT_GET -\family default - event will be recorded in -\family typewriter -eventq -\family default -. -\layout Standard - -Figure\SpecialChar ~ - -\begin_inset LatexCommand \ref{fig:mpi} - -\end_inset - - illustrates the organization of the match list used for receiving MPI messages. - The initial entries (not shown in this figure) would be used to match the - MPI receives that have been preposted by the application. - The preposted receives are followed by a match entry, -\emph on -RcvMark -\emph default -, that marks the boundary between preposted receives and the memory descriptors - used for -\begin_inset Quotes eld -\end_inset - -unexpected -\begin_inset Quotes erd -\end_inset - - messages. - The -\emph on -RcvMark -\emph default - entry is followed by a small collection of match entries that match unexpected - -\begin_inset Quotes eld -\end_inset - -short -\begin_inset Quotes erd -\end_inset - - messages, i.e., messages that have a 0 in the most significant bit of their - match bits. - The memory descriptors associated with these match entries will append - the incoming message to the associated memory descriptor and record an - event in an event queue for unexpected messages. - The unexpected short message matching entries are followed by a match entry - that will match messages that were not matched by the preceding match entries, - i.e., the unexpected long messages. - The memory descriptor associated with this match entry truncates the message - body and records an event in the event queue for unexpected messages. - Note that of the memory descriptors used for unexpected messages share - a common event queue. - This makes it possible to process the unexpected messages in the order - in which they arrived, regardless of. -\layout Standard - - -\begin_inset Float figure -placement htbp -wide false -collapsed false - -\layout Standard -\align center - -\begin_inset Graphics FormatVersion 1 - filename mpi.eps - display color - size_type 0 - rotateOrigin center - lyxsize_type 1 - lyxwidth 389pt - lyxheight 284pt -\end_inset - - -\layout Caption - -Message Reception in MPI -\begin_inset LatexCommand \label{fig:mpi} - -\end_inset - - -\end_inset - - -\layout Standard - -When the local MPI process posts an MPI receive, we must first search the - events unexpected message queue to see if a matching message has already - arrived. - If no matching message is found, a match entry for the receive is inserted - before the -\emph on -RcvMark -\emph default - entry--after the match entries for all of the previously posted receives - and before the match entries for the unexpected messages. - This ensures that preposted receives are matched in the order that they - were posted (a requirement of MPI). - -\layout Standard - -While this strategy respects the temporal semantics of MPI, it introduces - a race condition: a matching message might arrive after the events in the - unexpected message queue have been searched, but before the match entry - for the receive has been inserted in the match list. - -\layout Standard - -To avoid this race condition we start by setting the -\family typewriter -threshold -\family default - of the memory descriptor to 0, making the descriptor inactive. - We then insert the match entry into the match list and proceed to search - the events in the unexpected message queue. - A matching message that arrives as we are searching the unexpected message - queue will not be accepted by the memory descriptor and, if not matched - by an earlier match list element, will add an event to the unexpected message - queue. - After searching the events in the unexpected message queue, we update the - memory descriptor, setting the threshold to 1 to activate the memory descriptor. - This update is predicated by the condition that the unexpected message - queue is empty. - We repeat the process of searching the unexpected message queue until the - update succeeds. -\layout Standard - -The following code fragment illustrates this approach. - Because events must be removed from the unexpected message queue to be - examined, this code fragment assumes the existence of a user managed event - list, -\family typewriter -Rcvd -\family default -, for the events that have already been removed from the unexpected message - queue. - In an effort to keep the example focused on the basic protocol, we have - omitted the code that would be needed to manage the memory descriptors - used for unexpected short messages. - In particular, we simply leave messages in these descriptors until they - are received by the application. - In a robust implementation, we would introduce code to ensure that short - unexpected messages are removed from these memory descriptors so that they - can be re-used. -\layout LyX-Code - - -\size small -extern ptl_handle_eq_t UnexpQueue; -\newline -extern ptl_handle_me_t RcvMark; -\newline -extern ptl_handle_me_t ShortMatch; -\newline - -\newline -typedef struct event_list_tag { -\newline - ptl_event_t event; -\newline - struct event_list_tag* next; -\newline -} event_list; -\newline - -\newline -extern event_list Rcvd; -\newline - -\newline -void AppendRcvd( ptl_event_t event ) -\newline -{ -\newline - /* append an event onto the Rcvd list */ -\newline -} -\newline - -\newline -int SearchRcvd( void *buf, ptl_size_t len, ptl_process_id_t sender, ptl_match_bi -ts_t match, -\newline - ptl_match_bits_t ignore, ptl_event_t *event ) -\newline -{ -\newline - /* Search the Rcvd event queue, looking for a message that matches the - requested message. -\newline - * If one is found, remove the event from the Rcvd list and return it. - */ -\newline -} -\newline - -\newline -typedef enum { RECEIVED, POSTED } receive_state; -\newline - -\newline -receive_state CopyMsg( void *buf, ptl_size_t &length, ptl_event_t event, - ptl_md_t md_buf ) -\newline -{ -\newline - ptl_md_t md_buf; -\newline - ptl_handle_me_t me_handle; -\newline - -\newline - if( event.rlength >= MPI_LONG_LENGTH ) { -\newline - PtlMDBind( MPI_NI, md_buf, &md_handle ); -\newline - PtlGet( event.initiator, MPI_GET_PINDEX, 0, event.match_bits, MPI_AINDEX, - md_handle ); -\newline - return POSTED; -\newline - } else { -\newline - /* copy the message */ -\newline - if( event.mlength < *length ) *length = event.mlength; -\newline - memcpy( buf, (char*)event.md_desc.start+event.offset, *length ); -\newline - return RECEIVED; -\newline - } -\newline -} -\newline - -\newline -receive_state MPIreceive( void *buf, ptl_size_t &len, void *MPI_data, ptl_handle -_eq_t eventq, -\newline - ptl_process_id_t sender, ptl_match_bits_t match, - ptl_match_bits_t ignore ) -\newline -{ -\newline - ptl_md_t md_buf; -\newline - ptl_handle_md_t md_handle; -\newline - ptl_handle_me_t me_handle; -\newline - ptl_event_t event; -\newline - -\newline - /* build a memory descriptor for the receive */ -\newline - md_buf.start = buf; -\newline - md_buf.length = *len; -\newline - md_buf.threshold = 0; /* temporarily disabled */ -\newline - md_buf.options = PTL_MD_PUT_OP; -\newline - md_buf.user_ptr = MPI_data; -\newline - md_buf.eventq = eventq; -\newline - -\newline - /* see if we have already received the message */ -\newline - if( SearchRcvd(buf, len, sender, match, ignore, &event) ) -\newline - return CopyMsg( buf, len, event, md_buf ); -\newline - -\newline - /* create the match entry and attach the memory descriptor */ -\newline - PtlMEInsert(sender, match, ignore, PTL_UNLINK, PTL_INS_BEFORE, RcvMark, - &me_handle); -\newline - PtlMDAttach( me_handle, md_buf, PTL_UNLINK, &md_handle ); -\newline - -\newline - md_buf.threshold = 1; -\newline - do -\newline - if( PtlEQGet( UnexpQueue, &event ) != PTL_EQ_EMPTY ) { -\newline - if( MPIMatch(event, match, ignore, sender) ) { -\newline - return CopyMsg( buf, len, (char*)event.md_desc.start+event.offset, - md_buf ); -\newline - } else { -\newline - AppendRcvd( event ); -\newline - } -\newline - } -\newline - while( PtlMDUpdate(md_handle, NULL, &md_buf, unexp_queue) == PTL_NOUPDATE - ); -\newline - return POSTED; -\newline -} -\layout Chapter* - -Acknowledgments -\layout Standard - -Several people have contributed to the philosophy, design, and implementation - of the Portals message passing architecture as it has evolved. - We acknowledge the following people for their contributions: Al Audette, - Lee Ann Fisk, David Greenberg, Tramm Hudson, Gabi Istrail, Chu Jong, Mike - Levenhagen, Jim Otto, Mark Sears, Lance Shuler, Mack Stallcup, Jeff VanDyke, - Dave van Dresser, Lee Ward, and Stephen Wheat. - -\layout Standard - - -\begin_inset LatexCommand \BibTeX[ieee]{portals3} - -\end_inset - - -\the_end diff --git a/lnet/doc/put.fig b/lnet/doc/put.fig deleted file mode 100644 index 5235b6d..0000000 --- a/lnet/doc/put.fig +++ /dev/null @@ -1,32 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -6 1350 900 2175 1200 -4 0 0 100 0 0 10 0.0000 0 105 825 1350 1200 Transmission\001 -4 0 0 100 0 0 10 0.0000 0 105 285 1620 1050 Data\001 --6 -2 1 0 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 2700 1275 2700 1725 -2 1 0 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2 - 0 0 1.00 60.00 120.00 - 900 525 2700 1200 -2 2 0 1 0 7 100 0 -1 3.000 0 0 7 0 0 5 - 0 300 1200 300 1200 2250 0 2250 0 300 -2 2 0 1 0 7 100 0 -1 3.000 0 0 7 0 0 5 - 2400 300 3600 300 3600 2250 2400 2250 2400 300 -2 1 1 1 0 7 100 0 -1 4.000 0 0 7 1 0 2 - 0 0 1.00 60.00 120.00 - 2699 1788 899 1938 -4 0 0 100 0 0 10 0.0000 0 105 720 2775 1650 Translation\001 -4 1 0 100 0 0 10 0.0000 0 135 555 1800 2025 Optional\001 -4 1 0 100 0 0 10 0.0000 0 135 1170 1800 2175 Acknowledgement\001 -4 0 0 100 0 0 10 0.0000 0 105 405 2850 1500 Portal\001 -4 1 0 100 0 0 10 0.0000 0 135 405 3000 525 Target\001 -4 1 0 100 0 0 10 0.0000 0 105 540 600 525 Initiator\001 diff --git a/lnet/include/.cvsignore b/lnet/include/.cvsignore deleted file mode 100644 index 94d3790..0000000 --- a/lnet/include/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -config.h -stamp-h -stamp-h1 -stamp-h.in -Makefile -Makefile.in diff --git a/lnet/include/Makefile.am b/lnet/include/Makefile.am deleted file mode 100644 index 2b3eb8c..0000000 --- a/lnet/include/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = linux portals - -EXTRA_DIST = cygwin-ioctl.h diff --git a/lnet/include/cygwin-ioctl.h b/lnet/include/cygwin-ioctl.h deleted file mode 100644 index 8a33957..0000000 --- a/lnet/include/cygwin-ioctl.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * linux/ioctl.h for Linux by H.H. Bergman. - */ - -#ifndef _ASMI386_IOCTL_H -#define _ASMI386_IOCTL_H - -/* ioctl command encoding: 32 bits total, command in lower 16 bits, - * size of the parameter structure in the lower 14 bits of the - * upper 16 bits. - * Encoding the size of the parameter structure in the ioctl request - * is useful for catching programs compiled with old versions - * and to avoid overwriting user space outside the user buffer area. - * The highest 2 bits are reserved for indicating the ``access mode''. - * NOTE: This limits the max parameter size to 16kB -1 ! - */ - -/* - * The following is for compatibility across the various Linux - * platforms. The i386 ioctl numbering scheme doesn't really enforce - * a type field. De facto, however, the top 8 bits of the lower 16 - * bits are indeed used as a type field, so we might just as well make - * this explicit here. Please be sure to use the decoding macros - * below from now on. - */ -#undef _IO -#undef _IOR -#undef _IOW -#undef _IOC -#undef IOC_IN -#undef IOC_OUT - -#define _IOC_NRBITS 8 -#define _IOC_TYPEBITS 8 -#define _IOC_SIZEBITS 14 -#define _IOC_DIRBITS 2 - -#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) -#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) -#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) -#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) - -#define _IOC_NRSHIFT 0 -#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) -#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) -#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) - -/* - * Direction bits. - */ -#define _IOC_NONE 0U -#define _IOC_WRITE 1U -#define _IOC_READ 2U - -#define _IOC(dir,type,nr,size) \ - (((dir) << _IOC_DIRSHIFT) | \ - ((type) << _IOC_TYPESHIFT) | \ - ((nr) << _IOC_NRSHIFT) | \ - ((size) << _IOC_SIZESHIFT)) - -/* used to create numbers */ -#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) -#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) -#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) -#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) - -/* used to decode ioctl numbers.. */ -#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) -#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) -#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) -#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) - -/* ...and for the drivers/sound files... */ - -#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) -#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) -#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) -#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) -#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) - -#endif /* _ASMI386_IOCTL_H */ diff --git a/lnet/include/linux/.cvsignore b/lnet/include/linux/.cvsignore deleted file mode 100644 index 282522d..0000000 --- a/lnet/include/linux/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/lnet/include/linux/Makefile.am b/lnet/include/linux/Makefile.am deleted file mode 100644 index 3c28c6e8..0000000 --- a/lnet/include/linux/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -linuxdir = $(includedir)/linux - -EXTRA_DIST = kp30.h kpr.h libcfs.h lustre_list.h portals_compat25.h \ - portals_lib.h diff --git a/lnet/include/linux/kp30.h b/lnet/include/linux/kp30.h deleted file mode 100644 index 85284ce..0000000 --- a/lnet/include/linux/kp30.h +++ /dev/null @@ -1,748 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ -#ifndef _KP30_INCLUDED -#define _KP30_INCLUDED - -#include -#define PORTAL_DEBUG - -#ifdef __KERNEL__ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define schedule_work schedule_task -#define prepare_work(wq,cb,cbdata) \ -do { \ - INIT_TQUEUE((wq), 0, 0); \ - PREPARE_TQUEUE((wq), (cb), (cbdata)); \ -} while (0) - -#define PageUptodate Page_Uptodate -#define our_recalc_sigpending(current) recalc_sigpending(current) -#define num_online_cpus() smp_num_cpus -static inline void our_cond_resched(void) -{ - if (current->need_resched) - schedule (); -} -#define work_struct_t struct tq_struct - -#else - -#define prepare_work(wq,cb,cbdata) \ -do { \ - INIT_WORK((wq), (void *)(cb), (void *)(cbdata)); \ -} while (0) -#define wait_on_page wait_on_page_locked -#define our_recalc_sigpending(current) recalc_sigpending() -#define strtok(a,b) strpbrk(a, b) -static inline void our_cond_resched(void) -{ - cond_resched(); -} -#define work_struct_t struct work_struct - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */ - -#ifdef PORTAL_DEBUG -extern void kportal_assertion_failed(char *expr, char *file, const char *func, - const int line); -#define LASSERT(e) ((e) ? 0 : kportal_assertion_failed( #e , __FILE__, \ - __FUNCTION__, __LINE__)) -#define LASSERTF(cond, fmt...) \ - do { \ - if (unlikely(!(cond))) { \ - portals_debug_msg(DEBUG_SUBSYSTEM, D_EMERG, __FILE__,\ - __FUNCTION__,__LINE__, CDEBUG_STACK,\ - "ASSERTION(" #cond ") failed:" fmt);\ - LBUG(); \ - } \ - } while (0) - -#else -#define LASSERT(e) -#define LASSERTF(cond, fmt...) do { } while (0) -#endif - -#ifdef CONFIG_SMP -#define LASSERT_SPIN_LOCKED(lock) LASSERT(spin_is_locked(lock)) -#else -#define LASSERT_SPIN_LOCKED(lock) do {} while(0) -#endif - -#ifdef __arch_um__ -#define LBUG_WITH_LOC(file, func, line) \ -do { \ - CEMERG("LBUG - trying to dump log to /tmp/lustre-log\n"); \ - portals_debug_dumplog(); \ - portals_run_lbug_upcall(file, func, line); \ - panic("LBUG"); \ -} while (0) -#else -#define LBUG_WITH_LOC(file, func, line) \ -do { \ - CEMERG("LBUG\n"); \ - portals_debug_dumpstack(NULL); \ - portals_debug_dumplog(); \ - portals_run_lbug_upcall(file, func, line); \ - set_task_state(current, TASK_UNINTERRUPTIBLE); \ - schedule(); \ -} while (0) -#endif /* __arch_um__ */ - -#define LBUG() LBUG_WITH_LOC(__FILE__, __FUNCTION__, __LINE__) - -/* - * Memory - */ -#ifdef PORTAL_DEBUG -extern atomic_t portal_kmemory; - -# define portal_kmem_inc(ptr, size) \ -do { \ - atomic_add(size, &portal_kmemory); \ -} while (0) - -# define portal_kmem_dec(ptr, size) do { \ - atomic_sub(size, &portal_kmemory); \ -} while (0) - -#else -# define portal_kmem_inc(ptr, size) do {} while (0) -# define portal_kmem_dec(ptr, size) do {} while (0) -#endif /* PORTAL_DEBUG */ - -#define PORTAL_VMALLOC_SIZE 16384 - -#define PORTAL_ALLOC_GFP(ptr, size, mask) \ -do { \ - LASSERT(!in_interrupt() || \ - (size <= PORTAL_VMALLOC_SIZE && mask == GFP_ATOMIC)); \ - if ((size) > PORTAL_VMALLOC_SIZE) \ - (ptr) = vmalloc(size); \ - else \ - (ptr) = kmalloc((size), (mask)); \ - if ((ptr) == NULL) { \ - CERROR("PORTALS: out of memory at %s:%d (tried to alloc '"\ - #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size));\ - CERROR("PORTALS: %d total bytes allocated by portals\n", \ - atomic_read(&portal_kmemory)); \ - } else { \ - portal_kmem_inc((ptr), (size)); \ - memset((ptr), 0, (size)); \ - } \ - CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n", \ - (int)(size), (ptr), atomic_read (&portal_kmemory)); \ -} while (0) - -#define PORTAL_ALLOC(ptr, size) \ - PORTAL_ALLOC_GFP(ptr, size, GFP_NOFS) - -#define PORTAL_ALLOC_ATOMIC(ptr, size) \ - PORTAL_ALLOC_GFP(ptr, size, GFP_ATOMIC) - -#define PORTAL_FREE(ptr, size) \ -do { \ - int s = (size); \ - if ((ptr) == NULL) { \ - CERROR("PORTALS: free NULL '" #ptr "' (%d bytes) at " \ - "%s:%d\n", s, __FILE__, __LINE__); \ - break; \ - } \ - if (s > PORTAL_VMALLOC_SIZE) \ - vfree(ptr); \ - else \ - kfree(ptr); \ - portal_kmem_dec((ptr), s); \ - CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n", \ - s, (ptr), atomic_read(&portal_kmemory)); \ -} while (0) - -/* ------------------------------------------------------------------- */ - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - -#define PORTAL_SYMBOL_REGISTER(x) inter_module_register(#x, THIS_MODULE, &x) -#define PORTAL_SYMBOL_UNREGISTER(x) inter_module_unregister(#x) - -#define PORTAL_SYMBOL_GET(x) ((typeof(&x))inter_module_get(#x)) -#define PORTAL_SYMBOL_PUT(x) inter_module_put(#x) - -#define PORTAL_MODULE_USE MOD_INC_USE_COUNT -#define PORTAL_MODULE_UNUSE MOD_DEC_USE_COUNT -#else - -#define PORTAL_SYMBOL_REGISTER(x) -#define PORTAL_SYMBOL_UNREGISTER(x) - -#define PORTAL_SYMBOL_GET(x) symbol_get(x) -#define PORTAL_SYMBOL_PUT(x) symbol_put(x) - -#define PORTAL_MODULE_USE try_module_get(THIS_MODULE) -#define PORTAL_MODULE_UNUSE module_put(THIS_MODULE) - -#endif - -/******************************************************************************/ - -#ifdef PORTALS_PROFILING -#define prof_enum(FOO) PROF__##FOO -enum { - prof_enum(our_recvmsg), - prof_enum(our_sendmsg), - prof_enum(socknal_recv), - prof_enum(lib_parse), - prof_enum(conn_list_walk), - prof_enum(memcpy), - prof_enum(lib_finalize), - prof_enum(pingcli_time), - prof_enum(gmnal_send), - prof_enum(gmnal_recv), - MAX_PROFS -}; - -struct prof_ent { - char *str; - /* hrmph. wrap-tastic. */ - u32 starts; - u32 finishes; - cycles_t total_cycles; - cycles_t start; - cycles_t end; -}; - -extern struct prof_ent prof_ents[MAX_PROFS]; - -#define PROF_START(FOO) \ - do { \ - struct prof_ent *pe = &prof_ents[PROF__##FOO]; \ - pe->starts++; \ - pe->start = get_cycles(); \ - } while (0) - -#define PROF_FINISH(FOO) \ - do { \ - struct prof_ent *pe = &prof_ents[PROF__##FOO]; \ - pe->finishes++; \ - pe->end = get_cycles(); \ - pe->total_cycles += (pe->end - pe->start); \ - } while (0) -#else /* !PORTALS_PROFILING */ -#define PROF_START(FOO) do {} while(0) -#define PROF_FINISH(FOO) do {} while(0) -#endif /* PORTALS_PROFILING */ - -/* debug.c */ -void portals_debug_dumpstack(struct task_struct *tsk); -void portals_run_upcall(char **argv); -void portals_run_lbug_upcall(char * file, const char *fn, const int line); -void portals_debug_dumplog(void); -int portals_debug_init(unsigned long bufsize); -int portals_debug_cleanup(void); -int portals_debug_clear_buffer(void); -int portals_debug_mark_buffer(char *text); -int portals_debug_set_daemon(unsigned int cmd, unsigned int length, - char *file, unsigned int size); -__s32 portals_debug_copy_to_user(char *buf, unsigned long len); -#if (__GNUC__) -/* Use the special GNU C __attribute__ hack to have the compiler check the - * printf style argument string against the actual argument count and - * types. - */ -#ifdef printf -# warning printf has been defined as a macro... -# undef printf -#endif -void portals_debug_msg(int subsys, int mask, char *file, const char *fn, - const int line, unsigned long stack, - char *format, ...) - __attribute__ ((format (printf, 7, 8))); -#else -void portals_debug_msg(int subsys, int mask, char *file, const char *fn, - const int line, unsigned long stack, - const char *format, ...); -#endif /* __GNUC__ */ -void portals_debug_set_level(unsigned int debug_level); - -# define fprintf(a, format, b...) CDEBUG(D_OTHER, format , ## b) -# define printf(format, b...) CDEBUG(D_OTHER, format , ## b) -# define time(a) CURRENT_TIME - -extern void kportal_daemonize (char *name); -extern void kportal_blockallsigs (void); - -#else /* !__KERNEL__ */ -# include -# include -#ifndef __CYGWIN__ -# include -#else -# include -#endif -# include -# include -# include -# ifndef DEBUG_SUBSYSTEM -# define DEBUG_SUBSYSTEM S_UNDEFINED -# endif -# ifdef PORTAL_DEBUG -# undef NDEBUG -# include -# define LASSERT(e) assert(e) -# define LASSERTF(cond, args...) \ -do { \ - if (!(cond)) \ - CERROR(args); \ - assert(cond); \ -} while (0) -# else -# define LASSERT(e) -# define LASSERTF(cond, args...) do { } while (0) -# endif -# define printk(format, args...) printf (format, ## args) -# define PORTAL_ALLOC(ptr, size) do { (ptr) = malloc(size); } while (0); -# define PORTAL_FREE(a, b) do { free(a); } while (0); -void portals_debug_dumplog(void); -# define portals_debug_msg(subsys, mask, file, fn, line, stack, format, a...) \ - printf("%02x:%06x (@%lu %s:%s,l. %d %d %lu): " format, \ - (subsys), (mask), (long)time(0), file, fn, line, \ - getpid() , stack, ## a); - -#undef CWARN -#undef CERROR -#define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a) -#define CERROR(format, a...) CDEBUG(D_ERROR, format, ## a) -#endif - -/* support decl needed both by kernel and liblustre */ -char *portals_nid2str(int nal, ptl_nid_t nid, char *str); -char *portals_id2str(int nal, ptl_process_id_t nid, char *str); - -#ifndef CURRENT_TIME -# define CURRENT_TIME time(0) -#endif - -/******************************************************************************/ -/* Light-weight trace - * Support for temporary event tracing with minimal Heisenberg effect. */ -#define LWT_SUPPORT 0 - -#define LWT_MEMORY (16<<20) - -#if !KLWT_SUPPORT -# if defined(__KERNEL__) -# if !defined(BITS_PER_LONG) -# error "BITS_PER_LONG not defined" -# endif -# elif !defined(__WORDSIZE) -# error "__WORDSIZE not defined" -# else -# define BITS_PER_LONG __WORDSIZE -# endif - -/* kernel hasn't defined this? */ -typedef struct { - long long lwte_when; - char *lwte_where; - void *lwte_task; - long lwte_p1; - long lwte_p2; - long lwte_p3; - long lwte_p4; -# if BITS_PER_LONG > 32 - long lwte_pad; -# endif -} lwt_event_t; -#endif /* !KLWT_SUPPORT */ - -#if LWT_SUPPORT -# ifdef __KERNEL__ -# if !KLWT_SUPPORT - -typedef struct _lwt_page { - struct list_head lwtp_list; - struct page *lwtp_page; - lwt_event_t *lwtp_events; -} lwt_page_t; - -typedef struct { - int lwtc_current_index; - lwt_page_t *lwtc_current_page; -} lwt_cpu_t; - -extern int lwt_enabled; -extern lwt_cpu_t lwt_cpus[]; - -/* Note that we _don't_ define LWT_EVENT at all if LWT_SUPPORT isn't set. - * This stuff is meant for finding specific problems; it never stays in - * production code... */ - -#define LWTSTR(n) #n -#define LWTWHERE(f,l) f ":" LWTSTR(l) -#define LWT_EVENTS_PER_PAGE (PAGE_SIZE / sizeof (lwt_event_t)) - -#define LWT_EVENT(p1, p2, p3, p4) \ -do { \ - unsigned long flags; \ - lwt_cpu_t *cpu; \ - lwt_page_t *p; \ - lwt_event_t *e; \ - \ - if (lwt_enabled) { \ - local_irq_save (flags); \ - \ - cpu = &lwt_cpus[smp_processor_id()]; \ - p = cpu->lwtc_current_page; \ - e = &p->lwtp_events[cpu->lwtc_current_index++]; \ - \ - if (cpu->lwtc_current_index >= LWT_EVENTS_PER_PAGE) { \ - cpu->lwtc_current_page = \ - list_entry (p->lwtp_list.next, \ - lwt_page_t, lwtp_list); \ - cpu->lwtc_current_index = 0; \ - } \ - \ - e->lwte_when = get_cycles(); \ - e->lwte_where = LWTWHERE(__FILE__,__LINE__); \ - e->lwte_task = current; \ - e->lwte_p1 = (long)(p1); \ - e->lwte_p2 = (long)(p2); \ - e->lwte_p3 = (long)(p3); \ - e->lwte_p4 = (long)(p4); \ - \ - local_irq_restore (flags); \ - } \ -} while (0) - -#endif /* !KLWT_SUPPORT */ - -extern int lwt_init (void); -extern void lwt_fini (void); -extern int lwt_lookup_string (int *size, char *knlptr, - char *usrptr, int usrsize); -extern int lwt_control (int enable, int clear); -extern int lwt_snapshot (cycles_t *now, int *ncpu, int *total_size, - void *user_ptr, int user_size); -# else /* __KERNEL__ */ -# define LWT_EVENT(p1,p2,p3,p4) /* no userland implementation yet */ -# endif /* __KERNEL__ */ -#endif /* LWT_SUPPORT */ - -struct portals_device_userstate -{ - int pdu_memhog_pages; - struct page *pdu_memhog_root_page; -}; - -#include - -/* - * USER LEVEL STUFF BELOW - */ - -#define PORTAL_IOCTL_VERSION 0x00010007 -#define PING_SYNC 0 -#define PING_ASYNC 1 - -struct portal_ioctl_hdr { - __u32 ioc_len; - __u32 ioc_version; -}; - -struct portals_debug_ioctl_data -{ - struct portal_ioctl_hdr hdr; - unsigned int subs; - unsigned int debug; -}; - -#define PORTAL_IOC_INIT(data) \ -do { \ - memset(&data, 0, sizeof(data)); \ - data.ioc_version = PORTAL_IOCTL_VERSION; \ - data.ioc_len = sizeof(data); \ -} while (0) - -/* FIXME check conflict with lustre_lib.h */ -#define PTL_IOC_DEBUG_MASK _IOWR('f', 250, long) - -static inline int portal_ioctl_packlen(struct portal_ioctl_data *data) -{ - int len = sizeof(*data); - len += size_round(data->ioc_inllen1); - len += size_round(data->ioc_inllen2); - return len; -} - -static inline int portal_ioctl_is_invalid(struct portal_ioctl_data *data) -{ - if (data->ioc_len > (1<<30)) { - CERROR ("PORTALS ioctl: ioc_len larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen1 > (1<<30)) { - CERROR ("PORTALS ioctl: ioc_inllen1 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen2 > (1<<30)) { - CERROR ("PORTALS ioctl: ioc_inllen2 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inlbuf1 && !data->ioc_inllen1) { - CERROR ("PORTALS ioctl: inlbuf1 pointer but 0 length\n"); - return 1; - } - if (data->ioc_inlbuf2 && !data->ioc_inllen2) { - CERROR ("PORTALS ioctl: inlbuf2 pointer but 0 length\n"); - return 1; - } - if (data->ioc_pbuf1 && !data->ioc_plen1) { - CERROR ("PORTALS ioctl: pbuf1 pointer but 0 length\n"); - return 1; - } - if (data->ioc_pbuf2 && !data->ioc_plen2) { - CERROR ("PORTALS ioctl: pbuf2 pointer but 0 length\n"); - return 1; - } - if (data->ioc_plen1 && !data->ioc_pbuf1) { - CERROR ("PORTALS ioctl: plen1 nonzero but no pbuf1 pointer\n"); - return 1; - } - if (data->ioc_plen2 && !data->ioc_pbuf2) { - CERROR ("PORTALS ioctl: plen2 nonzero but no pbuf2 pointer\n"); - return 1; - } - if (portal_ioctl_packlen(data) != data->ioc_len ) { - CERROR ("PORTALS ioctl: packlen != ioc_len\n"); - return 1; - } - if (data->ioc_inllen1 && - data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') { - CERROR ("PORTALS ioctl: inlbuf1 not 0 terminated\n"); - return 1; - } - if (data->ioc_inllen2 && - data->ioc_bulk[size_round(data->ioc_inllen1) + - data->ioc_inllen2 - 1] != '\0') { - CERROR ("PORTALS ioctl: inlbuf2 not 0 terminated\n"); - return 1; - } - return 0; -} - -#ifndef __KERNEL__ -static inline int portal_ioctl_pack(struct portal_ioctl_data *data, char **pbuf, - int max) -{ - char *ptr; - struct portal_ioctl_data *overlay; - data->ioc_len = portal_ioctl_packlen(data); - data->ioc_version = PORTAL_IOCTL_VERSION; - - if (*pbuf && portal_ioctl_packlen(data) > max) - return 1; - if (*pbuf == NULL) { - *pbuf = malloc(data->ioc_len); - } - if (!*pbuf) - return 1; - overlay = (struct portal_ioctl_data *)*pbuf; - memcpy(*pbuf, data, sizeof(*data)); - - ptr = overlay->ioc_bulk; - if (data->ioc_inlbuf1) - LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr); - if (data->ioc_inlbuf2) - LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr); - if (portal_ioctl_is_invalid(overlay)) - return 1; - - return 0; -} -#else -#include - -/* buffer MUST be at least the size of portal_ioctl_hdr */ -static inline int portal_ioctl_getdata(char *buf, char *end, void *arg) -{ - struct portal_ioctl_hdr *hdr; - struct portal_ioctl_data *data; - int err; - ENTRY; - - hdr = (struct portal_ioctl_hdr *)buf; - data = (struct portal_ioctl_data *)buf; - - err = copy_from_user(buf, (void *)arg, sizeof(*hdr)); - if (err) - RETURN(err); - - if (hdr->ioc_version != PORTAL_IOCTL_VERSION) { - CERROR("PORTALS: version mismatch kernel vs application\n"); - RETURN(-EINVAL); - } - - if (hdr->ioc_len + buf >= end) { - CERROR("PORTALS: user buffer exceeds kernel buffer\n"); - RETURN(-EINVAL); - } - - - if (hdr->ioc_len < sizeof(struct portal_ioctl_data)) { - CERROR("PORTALS: user buffer too small for ioctl\n"); - RETURN(-EINVAL); - } - - err = copy_from_user(buf, (void *)arg, hdr->ioc_len); - if (err) - RETURN(err); - - if (portal_ioctl_is_invalid(data)) { - CERROR("PORTALS: ioctl not correctly formatted\n"); - RETURN(-EINVAL); - } - - if (data->ioc_inllen1) - data->ioc_inlbuf1 = &data->ioc_bulk[0]; - - if (data->ioc_inllen2) - data->ioc_inlbuf2 = &data->ioc_bulk[0] + - size_round(data->ioc_inllen1); - - RETURN(0); -} -#endif - -/* ioctls for manipulating snapshots 30- */ -#define IOC_PORTAL_TYPE 'e' -#define IOC_PORTAL_MIN_NR 30 - -#define IOC_PORTAL_PING _IOWR('e', 30, long) - -#define IOC_PORTAL_CLEAR_DEBUG _IOWR('e', 32, long) -#define IOC_PORTAL_MARK_DEBUG _IOWR('e', 33, long) -#define IOC_PORTAL_PANIC _IOWR('e', 34, long) -#define IOC_PORTAL_NAL_CMD _IOWR('e', 35, long) -#define IOC_PORTAL_GET_NID _IOWR('e', 36, long) -#define IOC_PORTAL_FAIL_NID _IOWR('e', 37, long) - -#define IOC_PORTAL_LWT_CONTROL _IOWR('e', 39, long) -#define IOC_PORTAL_LWT_SNAPSHOT _IOWR('e', 40, long) -#define IOC_PORTAL_LWT_LOOKUP_STRING _IOWR('e', 41, long) -#define IOC_PORTAL_MEMHOG _IOWR('e', 42, long) -#define IOC_PORTAL_MAX_NR 42 - -enum { - QSWNAL = 1, - SOCKNAL = 2, - GMNAL = 3, - /* 4 unused */ - TCPNAL = 5, - ROUTER = 6, - OPENIBNAL = 7, - IIBNAL = 8, - LONAL = 9, - RANAL = 10, - NAL_ENUM_END_MARKER -}; - -#define PTL_NALFMT_SIZE 32 /* %u:%u.%u.%u.%u,%u (10+4+4+4+3+5+1) */ - -#define NAL_MAX_NR (NAL_ENUM_END_MARKER - 1) - -#define NAL_CMD_REGISTER_PEER_FD 100 -#define NAL_CMD_CLOSE_CONNECTION 101 -#define NAL_CMD_REGISTER_MYNID 102 -#define NAL_CMD_PUSH_CONNECTION 103 -#define NAL_CMD_GET_CONN 104 -#define NAL_CMD_DEL_PEER 105 -#define NAL_CMD_ADD_PEER 106 -#define NAL_CMD_GET_PEER 107 -#define NAL_CMD_GET_TXDESC 108 -#define NAL_CMD_ADD_ROUTE 109 -#define NAL_CMD_DEL_ROUTE 110 -#define NAL_CMD_GET_ROUTE 111 -#define NAL_CMD_NOTIFY_ROUTER 112 -#define NAL_CMD_ADD_INTERFACE 113 -#define NAL_CMD_DEL_INTERFACE 114 -#define NAL_CMD_GET_INTERFACE 115 - - -enum { - DEBUG_DAEMON_START = 1, - DEBUG_DAEMON_STOP = 2, - DEBUG_DAEMON_PAUSE = 3, - DEBUG_DAEMON_CONTINUE = 4, -}; - - -enum cfg_record_type { - PORTALS_CFG_TYPE = 1, - LUSTRE_CFG_TYPE = 123, -}; - -typedef int (*cfg_record_cb_t)(enum cfg_record_type, int len, void *data); - -#ifdef __CYGWIN__ -# ifndef BITS_PER_LONG -# if (~0UL) == 0xffffffffUL -# define BITS_PER_LONG 32 -# else -# define BITS_PER_LONG 64 -# endif -# endif -#endif - -#if BITS_PER_LONG > 32 -# define LI_POISON ((int)0x5a5a5a5a5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a) -#else -# define LI_POISON ((int)0x5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a) -#endif - -#if defined(__x86_64__) -# define LPU64 "%Lu" -# define LPD64 "%Ld" -# define LPX64 "%#Lx" -# define LPSZ "%lu" -# define LPSSZ "%ld" -#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32) -# define LPU64 "%Lu" -# define LPD64 "%Ld" -# define LPX64 "%#Lx" -# define LPSZ "%u" -# define LPSSZ "%d" -#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64) -# define LPU64 "%lu" -# define LPD64 "%ld" -# define LPX64 "%#lx" -# define LPSZ "%lu" -# define LPSSZ "%ld" -#endif -#ifndef LPU64 -# error "No word size defined" -#endif - -/* lustre_id output helper macros */ -#define DLID4 "%lu/%lu/%lu/%lu" - -#define OLID4(id) \ - (unsigned long)(id)->li_fid.lf_id, \ - (unsigned long)(id)->li_fid.lf_group, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_ino, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_gen - -#endif diff --git a/lnet/include/linux/kpr.h b/lnet/include/linux/kpr.h deleted file mode 100644 index 1127698..0000000 --- a/lnet/include/linux/kpr.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ -#ifndef _KPR_H -#define _KPR_H - -# include /* for ptl_hdr_t */ - -/******************************************************************************/ -/* Kernel Portals Router interface */ - -typedef void (*kpr_fwd_callback_t)(void *arg, int error); // completion callback - -/* space for routing targets to stash "stuff" in a forwarded packet */ -typedef union { - long long _alignment; - void *_space[16]; /* scale with CPU arch */ -} kprfd_scratch_t; - -/* Kernel Portals Routing Forwarded message Descriptor */ -typedef struct { - struct list_head kprfd_list; /* stash in queues (routing target can use) */ - ptl_nid_t kprfd_target_nid; /* final destination NID */ - ptl_nid_t kprfd_gateway_nid; /* gateway NID */ - ptl_hdr_t *kprfd_hdr; /* header in wire byte order */ - int kprfd_nob; /* # payload bytes */ - int kprfd_niov; /* # payload frags */ - ptl_kiov_t *kprfd_kiov; /* payload fragments */ - void *kprfd_router_arg; /* originating NAL's router arg */ - kpr_fwd_callback_t kprfd_callback; /* completion callback */ - void *kprfd_callback_arg; /* completion callback arg */ - kprfd_scratch_t kprfd_scratch; /* scratchpad for routing targets */ -} kpr_fwd_desc_t; - -typedef void (*kpr_fwd_t)(void *arg, kpr_fwd_desc_t *fwd); -typedef void (*kpr_notify_t)(void *arg, ptl_nid_t peer, int alive); - -/* NAL's routing interface (Kernel Portals Routing Nal Interface) */ -typedef const struct { - int kprni_nalid; /* NAL's id */ - void *kprni_arg; /* Arg to pass when calling into NAL */ - kpr_fwd_t kprni_fwd; /* NAL's forwarding entrypoint */ - kpr_notify_t kprni_notify; /* NAL's notification entrypoint */ -} kpr_nal_interface_t; - -/* Router's routing interface (Kernel Portals Routing Router Interface) */ -typedef const struct { - /* register the calling NAL with the router and get back the handle for - * subsequent calls */ - int (*kprri_register) (kpr_nal_interface_t *nal_interface, - void **router_arg); - - /* ask the router to find a gateway that forwards to 'nid' and is a - * peer of the calling NAL; assume caller will send 'nob' bytes of - * payload there */ - int (*kprri_lookup) (void *router_arg, ptl_nid_t nid, int nob, - ptl_nid_t *gateway_nid); - - /* hand a packet over to the router for forwarding */ - kpr_fwd_t kprri_fwd_start; - - /* hand a packet back to the router for completion */ - void (*kprri_fwd_done) (void *router_arg, kpr_fwd_desc_t *fwd, - int error); - - /* notify the router about peer state */ - void (*kprri_notify) (void *router_arg, ptl_nid_t peer, - int alive, time_t when); - - /* the calling NAL is shutting down */ - void (*kprri_shutdown) (void *router_arg); - - /* deregister the calling NAL with the router */ - void (*kprri_deregister) (void *router_arg); - -} kpr_router_interface_t; - -/* Convenient struct for NAL to stash router interface/args */ -typedef struct { - kpr_router_interface_t *kpr_interface; - void *kpr_arg; -} kpr_router_t; - -extern kpr_router_interface_t kpr_router_interface; - -static inline int -kpr_register (kpr_router_t *router, kpr_nal_interface_t *nalif) -{ - int rc; - - router->kpr_interface = PORTAL_SYMBOL_GET (kpr_router_interface); - if (router->kpr_interface == NULL) - return (-ENOENT); - - rc = (router->kpr_interface)->kprri_register (nalif, &router->kpr_arg); - if (rc != 0) - router->kpr_interface = NULL; - - PORTAL_SYMBOL_PUT (kpr_router_interface); - return (rc); -} - -static inline int -kpr_routing (kpr_router_t *router) -{ - return (router->kpr_interface != NULL); -} - -static inline int -kpr_lookup (kpr_router_t *router, ptl_nid_t nid, int nob, ptl_nid_t *gateway_nid) -{ - if (!kpr_routing (router)) - return (-ENETUNREACH); - - return (router->kpr_interface->kprri_lookup(router->kpr_arg, nid, nob, - gateway_nid)); -} - -static inline void -kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid, ptl_hdr_t *hdr, - int nob, int niov, ptl_kiov_t *kiov, - kpr_fwd_callback_t callback, void *callback_arg) -{ - fwd->kprfd_target_nid = nid; - fwd->kprfd_gateway_nid = nid; - fwd->kprfd_hdr = hdr; - fwd->kprfd_nob = nob; - fwd->kprfd_niov = niov; - fwd->kprfd_kiov = kiov; - fwd->kprfd_callback = callback; - fwd->kprfd_callback_arg = callback_arg; -} - -static inline void -kpr_fwd_start (kpr_router_t *router, kpr_fwd_desc_t *fwd) -{ - if (!kpr_routing (router)) - fwd->kprfd_callback (fwd->kprfd_callback_arg, -ENETUNREACH); - else - router->kpr_interface->kprri_fwd_start (router->kpr_arg, fwd); -} - -static inline void -kpr_fwd_done (kpr_router_t *router, kpr_fwd_desc_t *fwd, int error) -{ - LASSERT (kpr_routing (router)); - router->kpr_interface->kprri_fwd_done (router->kpr_arg, fwd, error); -} - -static inline void -kpr_notify (kpr_router_t *router, - ptl_nid_t peer, int alive, time_t when) -{ - if (!kpr_routing (router)) - return; - - router->kpr_interface->kprri_notify(router->kpr_arg, peer, alive, when); -} - -static inline void -kpr_shutdown (kpr_router_t *router) -{ - if (kpr_routing (router)) - router->kpr_interface->kprri_shutdown (router->kpr_arg); -} - -static inline void -kpr_deregister (kpr_router_t *router) -{ - if (!kpr_routing (router)) - return; - router->kpr_interface->kprri_deregister (router->kpr_arg); - router->kpr_interface = NULL; -} - -#endif /* _KPR_H */ diff --git a/lnet/include/linux/libcfs.h b/lnet/include/linux/libcfs.h deleted file mode 100644 index d8f5349..0000000 --- a/lnet/include/linux/libcfs.h +++ /dev/null @@ -1,410 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ -#ifndef _LIBCFS_H -#define _LIBCFS_H - -#ifdef HAVE_ASM_TYPES_H -#include -#else -#include "types.h" -#endif - -#ifdef __KERNEL__ -# include -# include -#else -# include -# define do_gettimeofday(tv) gettimeofday(tv, NULL); -typedef unsigned long long cycles_t; -#endif - -#define PORTAL_DEBUG - -#ifndef offsetof -# define offsetof(typ,memb) ((unsigned long)((char *)&(((typ *)0)->memb))) -#endif - -#define LOWEST_BIT_SET(x) ((x) & ~((x) - 1)) - -#ifndef __KERNEL__ -/* Userpace byte flipping */ -# include -# include -# define __swab16(x) bswap_16(x) -# define __swab32(x) bswap_32(x) -# define __swab64(x) bswap_64(x) -# define __swab16s(x) do {*(x) = bswap_16(*(x));} while (0) -# define __swab32s(x) do {*(x) = bswap_32(*(x));} while (0) -# define __swab64s(x) do {*(x) = bswap_64(*(x));} while (0) -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define le16_to_cpu(x) (x) -# define cpu_to_le16(x) (x) -# define le32_to_cpu(x) (x) -# define cpu_to_le32(x) (x) -# define le64_to_cpu(x) (x) -# define cpu_to_le64(x) (x) -# else -# if __BYTE_ORDER == __BIG_ENDIAN -# define le16_to_cpu(x) bswap_16(x) -# define cpu_to_le16(x) bswap_16(x) -# define le32_to_cpu(x) bswap_32(x) -# define cpu_to_le32(x) bswap_32(x) -# define le64_to_cpu(x) bswap_64(x) -# define cpu_to_le64(x) bswap_64(x) -# else -# error "Unknown byte order" -# endif /* __BIG_ENDIAN */ -# endif /* __LITTLE_ENDIAN */ -#endif /* ! __KERNEL__ */ - -/* - * Debugging - */ -extern unsigned int portal_subsystem_debug; -extern unsigned int portal_stack; -extern unsigned int portal_debug; -extern unsigned int portal_printk; - -struct ptldebug_header { - __u32 ph_len; - __u32 ph_flags; - __u32 ph_subsys; - __u32 ph_mask; - __u32 ph_cpu_id; - __u32 ph_sec; - __u64 ph_usec; - __u32 ph_stack; - __u32 ph_pid; - __u32 ph_extern_pid; - __u32 ph_line_num; -} __attribute__((packed)); - -#define PH_FLAG_FIRST_RECORD 1 - -/* Debugging subsystems (32 bits, non-overlapping) */ -#define S_UNDEFINED 0x00000001 -#define S_MDC 0x00000002 -#define S_MDS 0x00000004 -#define S_OSC 0x00000008 -#define S_OST 0x00000010 -#define S_CLASS 0x00000020 -#define S_LOG 0x00000040 -#define S_LLITE 0x00000080 -#define S_RPC 0x00000100 -#define S_MGMT 0x00000200 -#define S_PORTALS 0x00000400 -#define S_NAL 0x00000800 /* ALL NALs */ -#define S_PINGER 0x00001000 -#define S_FILTER 0x00002000 -#define S_PTLBD 0x00004000 -#define S_ECHO 0x00008000 -#define S_LDLM 0x00010000 -#define S_LOV 0x00020000 -#define S_PTLROUTER 0x00040000 -#define S_COBD 0x00080000 -#define S_SM 0x00100000 -#define S_ASOBD 0x00200000 -#define S_CONFOBD 0x00400000 -#define S_LMV 0x00800000 -#define S_CMOBD 0x01000000 -/* If you change these values, please keep these files up to date... - * portals/utils/debug.c - * utils/lconf - */ - -/* Debugging masks (32 bits, non-overlapping) */ -#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */ -#define D_INODE 0x00000002 -#define D_SUPER 0x00000004 -#define D_EXT2 0x00000008 /* anything from ext2_debug */ -#define D_MALLOC 0x00000010 /* print malloc, free information */ -#define D_CACHE 0x00000020 /* cache-related items */ -#define D_INFO 0x00000040 /* general information */ -#define D_IOCTL 0x00000080 /* ioctl related information */ -#define D_BLOCKS 0x00000100 /* ext2 block allocation */ -#define D_NET 0x00000200 /* network communications */ -#define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */ -#define D_BUFFS 0x00000800 -#define D_OTHER 0x00001000 -#define D_DENTRY 0x00002000 -#define D_PORTALS 0x00004000 /* ENTRY/EXIT markers */ -#define D_PAGE 0x00008000 /* bulk page handling */ -#define D_DLMTRACE 0x00010000 -#define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */ -#define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */ -#define D_HA 0x00080000 /* recovery and failover */ -#define D_RPCTRACE 0x00100000 /* for distributed debugging */ -#define D_VFSTRACE 0x00200000 -#define D_READA 0x00400000 /* read-ahead */ -#define D_MMAP 0x00800000 -#define D_CONFIG 0x01000000 -/* If you change these values, please keep these files up to date... - * portals/utils/debug.c - * utils/lconf - */ - -#ifdef __KERNEL__ -# include /* THREAD_SIZE */ -#else -# ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */ -# define THREAD_SIZE 8192 -# endif -#endif - -#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) - -#ifdef __KERNEL__ -# ifdef __ia64__ -# define CDEBUG_STACK (THREAD_SIZE - \ - ((unsigned long)__builtin_dwarf_cfa() & \ - (THREAD_SIZE - 1))) -# else -# define CDEBUG_STACK (THREAD_SIZE - \ - ((unsigned long)__builtin_frame_address(0) & \ - (THREAD_SIZE - 1))) -# endif /* __ia64__ */ - -#define CHECK_STACK(stack) \ - do { \ - if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \ - portals_debug_msg(DEBUG_SUBSYSTEM, D_WARNING, \ - __FILE__, __FUNCTION__, __LINE__, \ - (stack),"maximum lustre stack %u\n",\ - portal_stack = (stack)); \ - /*panic("LBUG");*/ \ - } \ - } while (0) -#else /* !__KERNEL__ */ -#define CHECK_STACK(stack) do { } while(0) -#define CDEBUG_STACK (0L) -#endif /* __KERNEL__ */ - -#if 1 -#define CDEBUG(mask, format, a...) \ -do { \ - CHECK_STACK(CDEBUG_STACK); \ - if (((mask) & (D_ERROR | D_EMERG | D_WARNING)) || \ - (portal_debug & (mask) && \ - portal_subsystem_debug & DEBUG_SUBSYSTEM)) \ - portals_debug_msg(DEBUG_SUBSYSTEM, mask, \ - __FILE__, __FUNCTION__, __LINE__, \ - CDEBUG_STACK, format, ## a); \ -} while (0) - -#define CDEBUG_MAX_LIMIT 600 -#define CDEBUG_LIMIT(cdebug_mask, cdebug_format, a...) \ -do { \ - static unsigned long cdebug_next = 0; \ - static int cdebug_count = 0, cdebug_delay = 1; \ - \ - CHECK_STACK(CDEBUG_STACK); \ - if (time_after(jiffies, cdebug_next)) { \ - portals_debug_msg(DEBUG_SUBSYSTEM, cdebug_mask, __FILE__, \ - __FUNCTION__, __LINE__, CDEBUG_STACK, \ - cdebug_format, ## a); \ - if (cdebug_count) { \ - portals_debug_msg(DEBUG_SUBSYSTEM, cdebug_mask, \ - __FILE__, __FUNCTION__, __LINE__, \ - 0, "skipped %d similar messages\n", \ - cdebug_count); \ - cdebug_count = 0; \ - } \ - if (time_after(jiffies, cdebug_next+(CDEBUG_MAX_LIMIT+10)*HZ))\ - cdebug_delay = cdebug_delay > 8 ? cdebug_delay/8 : 1; \ - else \ - cdebug_delay = cdebug_delay*2 >= CDEBUG_MAX_LIMIT*HZ ?\ - CDEBUG_MAX_LIMIT*HZ : cdebug_delay*2; \ - cdebug_next = jiffies + cdebug_delay; \ - } else { \ - portals_debug_msg(DEBUG_SUBSYSTEM, \ - portal_debug & ~(D_EMERG|D_ERROR|D_WARNING),\ - __FILE__, __FUNCTION__, __LINE__, \ - CDEBUG_STACK, cdebug_format, ## a); \ - cdebug_count++; \ - } \ -} while (0) - -#define CWARN(format, a...) CDEBUG_LIMIT(D_WARNING, format, ## a) -#define CERROR(format, a...) CDEBUG_LIMIT(D_ERROR, format, ## a) -#define CEMERG(format, a...) CDEBUG(D_EMERG, format, ## a) - -#define GOTO(label, rc) \ -do { \ - long GOTO__ret = (long)(rc); \ - CDEBUG(D_TRACE,"Process leaving via %s (rc=%lu : %ld : %lx)\n", \ - #label, (unsigned long)GOTO__ret, (signed long)GOTO__ret,\ - (signed long)GOTO__ret); \ - goto label; \ -} while (0) - -#define RETURN(rc) \ -do { \ - typeof(rc) RETURN__ret = (rc); \ - CDEBUG(D_TRACE, "Process leaving (rc=%lu : %ld : %lx)\n", \ - (long)RETURN__ret, (long)RETURN__ret, (long)RETURN__ret);\ - return RETURN__ret; \ -} while (0) - -#define ENTRY \ -do { \ - CDEBUG(D_TRACE, "Process entered\n"); \ -} while (0) - -#define EXIT \ -do { \ - CDEBUG(D_TRACE, "Process leaving\n"); \ -} while(0) -#else -#define CDEBUG(mask, format, a...) do { } while (0) -#define CWARN(format, a...) printk(KERN_WARNING format, ## a) -#define CERROR(format, a...) printk(KERN_ERR format, ## a) -#define CEMERG(format, a...) printk(KERN_EMERG format, ## a) -#define GOTO(label, rc) do { (void)(rc); goto label; } while (0) -#define RETURN(rc) return (rc) -#define ENTRY do { } while (0) -#define EXIT do { } while (0) -#endif - -/* initial pid */ -# if CRAY_PORTALS -/* - * 1) ptl_pid_t in cray portals is only 16 bits, not 32 bits, therefore this - * is too big. - * - * 2) the implementation of ernal in cray portals further restricts the pid - * space that may be used to 0 <= pid <= 255 (an 8 bit value). Returns - * an error at nal init time for any pid outside this range. Other nals - * in cray portals don't have this restriction. - * */ -#define LUSTRE_PTL_PID 9 -# else -#define LUSTRE_PTL_PID 12345 -# endif - -#define LUSTRE_SRV_PTL_PID LUSTRE_PTL_PID - -#define PORTALS_CFG_VERSION 0x00010001; - -struct portals_cfg { - __u32 pcfg_version; - __u32 pcfg_command; - - __u32 pcfg_nal; - __u32 pcfg_flags; - - __u32 pcfg_gw_nal; - __u64 pcfg_nid; - __u64 pcfg_nid2; - __u64 pcfg_nid3; - __u32 pcfg_id; - __u32 pcfg_misc; - __u32 pcfg_fd; - __u32 pcfg_count; - __u32 pcfg_size; - __u32 pcfg_wait; - - __u32 pcfg_plen1; /* buffers in userspace */ - char *pcfg_pbuf1; - __u32 pcfg_plen2; /* buffers in userspace */ - char *pcfg_pbuf2; -}; - -#define PCFG_INIT(pcfg, cmd) \ -do { \ - memset(&pcfg, 0, sizeof(pcfg)); \ - pcfg.pcfg_version = PORTALS_CFG_VERSION; \ - pcfg.pcfg_command = (cmd); \ - \ -} while (0) - -typedef int (nal_cmd_handler_fn)(struct portals_cfg *, void *); -int libcfs_nal_cmd_register(int nal, nal_cmd_handler_fn *handler, void *arg); -int libcfs_nal_cmd(struct portals_cfg *pcfg); -void libcfs_nal_cmd_unregister(int nal); - -struct portal_ioctl_data { - __u32 ioc_len; - __u32 ioc_version; - __u64 ioc_nid; - __u64 ioc_nid2; - __u64 ioc_nid3; - __u32 ioc_count; - __u32 ioc_nal; - __u32 ioc_nal_cmd; - __u32 ioc_fd; - __u32 ioc_id; - - __u32 ioc_flags; - __u32 ioc_size; - - __u32 ioc_wait; - __u32 ioc_timeout; - __u32 ioc_misc; - - __u32 ioc_inllen1; - char *ioc_inlbuf1; - __u32 ioc_inllen2; - char *ioc_inlbuf2; - - __u32 ioc_plen1; /* buffers in userspace */ - char *ioc_pbuf1; - __u32 ioc_plen2; /* buffers in userspace */ - char *ioc_pbuf2; - - char ioc_bulk[0]; -}; - - -#ifdef __KERNEL__ - -#include - -struct libcfs_ioctl_handler { - struct list_head item; - int (*handle_ioctl)(struct portal_ioctl_data *data, - unsigned int cmd, unsigned long args); -}; - -#define DECLARE_IOCTL_HANDLER(ident, func) \ - struct libcfs_ioctl_handler ident = { \ - .item = LIST_HEAD_INIT(ident.item), \ - .handle_ioctl = func \ - } - -int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand); -int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand); - -#endif - -#ifdef __KERNEL__ -/* libcfs watchdogs */ -struct lc_watchdog; - -/* Just use the default handler (dumplog) */ -#define LC_WATCHDOG_DEFAULT_CB NULL - -/* Add a watchdog which fires after "time" milliseconds of delay. You have to - * touch it once to enable it. */ -struct lc_watchdog *lc_watchdog_add(int time, - void (*cb)(struct lc_watchdog *, - struct task_struct *, - void *), - void *data); - -/* Enables a watchdog and resets its timer. */ -void lc_watchdog_touch(struct lc_watchdog *lcw); - -/* Disable a watchdog; touch it to restart it. */ -void lc_watchdog_disable(struct lc_watchdog *lcw); - -/* Clean up the watchdog */ -void lc_watchdog_delete(struct lc_watchdog *lcw); - -/* Dump a debug log */ -void lc_watchdog_dumplog(struct lc_watchdog *lcw, - struct task_struct *tsk, - void *data); -#endif /* !__KERNEL__ */ - -#endif /* _LIBCFS_H */ diff --git a/lnet/include/linux/lustre_list.h b/lnet/include/linux/lustre_list.h deleted file mode 100644 index a218f2c..0000000 --- a/lnet/include/linux/lustre_list.h +++ /dev/null @@ -1,246 +0,0 @@ -#ifndef _LUSTRE_LIST_H -#define _LUSTRE_LIST_H - -#ifdef __KERNEL__ -#include -#else -/* - * Simple doubly linked list implementation. - * - * Some of the internal functions ("__xxx") are useful when - * manipulating whole lists rather than single entries, as - * sometimes we already know the next/prev entries and we can - * generate better code by using them directly rather than - * using the generic single-entry routines. - */ - -#define prefetch(a) ((void)a) - -struct list_head { - struct list_head *next, *prev; -}; - -typedef struct list_head list_t; - -#define LIST_HEAD_INIT(name) { &(name), &(name) } - -#define LIST_HEAD(name) \ - struct list_head name = LIST_HEAD_INIT(name) - -#define INIT_LIST_HEAD(ptr) do { \ - (ptr)->next = (ptr); (ptr)->prev = (ptr); \ -} while (0) - -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_add(struct list_head * new, - struct list_head * prev, - struct list_head * next) -{ - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; -} - -/** - * list_add - add a new entry - * @new: new entry to be added - * @head: list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -static inline void list_add(struct list_head *new, struct list_head *head) -{ - __list_add(new, head, head->next); -} - -/** - * list_add_tail - add a new entry - * @new: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static inline void list_add_tail(struct list_head *new, struct list_head *head) -{ - __list_add(new, head->prev, head); -} - -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_del(struct list_head * prev, struct list_head * next) -{ - next->prev = prev; - prev->next = next; -} - -/** - * list_del - deletes entry from list. - * @entry: the element to delete from the list. - * Note: list_empty on entry does not return true after this, the entry is in an undefined state. - */ -static inline void list_del(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); -} - -/** - * list_del_init - deletes entry from list and reinitialize it. - * @entry: the element to delete from the list. - */ -static inline void list_del_init(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); - INIT_LIST_HEAD(entry); -} - -/** - * list_move - delete from one list and add as another's head - * @list: the entry to move - * @head: the head that will precede our entry - */ -static inline void list_move(struct list_head *list, struct list_head *head) -{ - __list_del(list->prev, list->next); - list_add(list, head); -} - -/** - * list_move_tail - delete from one list and add as another's tail - * @list: the entry to move - * @head: the head that will follow our entry - */ -static inline void list_move_tail(struct list_head *list, - struct list_head *head) -{ - __list_del(list->prev, list->next); - list_add_tail(list, head); -} - -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -static inline int list_empty(struct list_head *head) -{ - return head->next == head; -} - -static inline void __list_splice(struct list_head *list, - struct list_head *head) -{ - struct list_head *first = list->next; - struct list_head *last = list->prev; - struct list_head *at = head->next; - - first->prev = head; - head->next = first; - - last->next = at; - at->prev = last; -} - -/** - * list_splice - join two lists - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void list_splice(struct list_head *list, struct list_head *head) -{ - if (!list_empty(list)) - __list_splice(list, head); -} - -/** - * list_splice_init - join two lists and reinitialise the emptied list. - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * The list at @list is reinitialised - */ -static inline void list_splice_init(struct list_head *list, - struct list_head *head) -{ - if (!list_empty(list)) { - __list_splice(list, head); - INIT_LIST_HEAD(list); - } -} - -/** - * list_entry - get the struct for this entry - * @ptr: the &struct list_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_struct within the struct. - */ -#define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) - -/** - * list_for_each - iterate over a list - * @pos: the &struct list_head to use as a loop counter. - * @head: the head for your list. - */ -#define list_for_each(pos, head) \ - for (pos = (head)->next, prefetch(pos->next); pos != (head); \ - pos = pos->next, prefetch(pos->next)) - -/** - * list_for_each_prev - iterate over a list in reverse order - * @pos: the &struct list_head to use as a loop counter. - * @head: the head for your list. - */ -#define list_for_each_prev(pos, head) \ - for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \ - pos = pos->prev, prefetch(pos->prev)) - -/** - * list_for_each_safe - iterate over a list safe against removal of list entry - * @pos: the &struct list_head to use as a loop counter. - * @n: another &struct list_head to use as temporary storage - * @head: the head for your list. - */ -#define list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -/** - * list_for_each_entry - iterate over list of given type - * @pos: the type * to use as a loop counter. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - prefetch(pos->member.next); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member), \ - prefetch(pos->member.next)) - -/** - * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry - * @pos: the type * to use as a loop counter. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) - -#endif /* if !__KERNEL__*/ -#endif /* if !_LUSTRE_LIST_H */ diff --git a/lnet/include/linux/portals_compat25.h b/lnet/include/linux/portals_compat25.h deleted file mode 100644 index fa2709e..0000000 --- a/lnet/include/linux/portals_compat25.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ -#ifndef _PORTALS_COMPAT_H -#define _PORTALS_COMPAT_H - -// XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved -#if SPINLOCK_DEBUG -# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) || defined(CONFIG_RH_2_4_20) -# define SIGNAL_MASK_ASSERT() \ - LASSERT(current->sighand->siglock.magic == SPINLOCK_MAGIC) -# else -# define SIGNAL_MASK_ASSERT() \ - LASSERT(current->sigmask_lock.magic == SPINLOCK_MAGIC) -# endif -#else -# define SIGNAL_MASK_ASSERT() -#endif -// XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) - -# define SIGNAL_MASK_LOCK(task, flags) \ - spin_lock_irqsave(&task->sighand->siglock, flags) -# define SIGNAL_MASK_UNLOCK(task, flags) \ - spin_unlock_irqrestore(&task->sighand->siglock, flags) -# define USERMODEHELPER(path, argv, envp) \ - call_usermodehelper(path, argv, envp, 1) -# define RECALC_SIGPENDING recalc_sigpending() -# define CLEAR_SIGPENDING clear_tsk_thread_flag(current, \ - TIF_SIGPENDING) -# define CURRENT_SECONDS get_seconds() -# define smp_num_cpus num_online_cpus() - - -#elif defined(CONFIG_RH_2_4_20) /* RH 2.4.x */ - -# define SIGNAL_MASK_LOCK(task, flags) \ - spin_lock_irqsave(&task->sighand->siglock, flags) -# define SIGNAL_MASK_UNLOCK(task, flags) \ - spin_unlock_irqrestore(&task->sighand->siglock, flags) -# define USERMODEHELPER(path, argv, envp) \ - call_usermodehelper(path, argv, envp) -# define RECALC_SIGPENDING recalc_sigpending() -# define CLEAR_SIGPENDING (current->sigpending = 0) -# define CURRENT_SECONDS CURRENT_TIME - -#else /* 2.4.x */ - -# define SIGNAL_MASK_LOCK(task, flags) \ - spin_lock_irqsave(&task->sigmask_lock, flags) -# define SIGNAL_MASK_UNLOCK(task, flags) \ - spin_unlock_irqrestore(&task->sigmask_lock, flags) -# define USERMODEHELPER(path, argv, envp) \ - call_usermodehelper(path, argv, envp) -# define RECALC_SIGPENDING recalc_sigpending(current) -# define CLEAR_SIGPENDING (current->sigpending = 0) -# define CURRENT_SECONDS CURRENT_TIME - -#endif - -#if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)) -#define UML_PID(tsk) ((tsk)->thread.extern_pid) -#elif defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define UML_PID(tsk) ((tsk)->thread.mode.tt.extern_pid) -#else -#define UML_PID(tsk) ((tsk)->pid) -#endif - -#if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -# define THREAD_NAME(comm, len, fmt, a...) \ - snprintf(comm, len,fmt"|%d", ## a, UML_PID(current)) -#else -# define THREAD_NAME(comm, len, fmt, a...) \ - snprintf(comm, len, fmt, ## a) -#endif - -#ifdef HAVE_PAGE_LIST -/* 2.4 alloc_page users can use page->list */ -#define PAGE_LIST_ENTRY list -#define PAGE_LIST(page) ((page)->list) -#else -/* 2.6 alloc_page users can use page->lru */ -#define PAGE_LIST_ENTRY lru -#define PAGE_LIST(page) ((page)->lru) -#endif - -#ifndef HAVE_CPU_ONLINE -#define cpu_online(cpu) (test_bit(cpu_online_map, &(cpu))) -#endif -#ifndef HAVE_CPUMASK_T -#define cpu_set(cpu, map) (set_bit(cpu, &(map))) -typedef unsigned long cpumask_t; -#endif - -#endif /* _PORTALS_COMPAT_H */ diff --git a/lnet/include/linux/portals_lib.h b/lnet/include/linux/portals_lib.h deleted file mode 100644 index 8778a52..0000000 --- a/lnet/include/linux/portals_lib.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * 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. - * - * Basic library routines. - * - */ - -#ifndef _PORTALS_LIB_H -#define _PORTALS_LIB_H - -#ifndef __KERNEL__ -# include -#else -# include -#endif - -#undef MIN -#define MIN(a,b) (((a)<(b)) ? (a): (b)) -#undef MAX -#define MAX(a,b) (((a)>(b)) ? (a): (b)) -#define MKSTR(ptr) ((ptr))? (ptr) : "" - -static inline int size_round (int val) -{ - return (val + 7) & (~0x7); -} - -static inline int size_round16(int val) -{ - return (val + 0xf) & (~0xf); -} - -static inline int size_round32(int val) -{ - return (val + 0x1f) & (~0x1f); -} - -static inline int size_round0(int val) -{ - if (!val) - return 0; - return (val + 1 + 7) & (~0x7); -} - -static inline size_t round_strlen(char *fset) -{ - return size_round(strlen(fset) + 1); -} - -#define LOGL(var,len,ptr) \ -do { \ - if (var) \ - memcpy((char *)ptr, (const char *)var, len); \ - ptr += size_round(len); \ -} while (0) - -#define LOGU(var,len,ptr) \ -do { \ - if (var) \ - memcpy((char *)var, (const char *)ptr, len); \ - ptr += size_round(len); \ -} while (0) - -#define LOGL0(var,len,ptr) \ -do { \ - if (!len) \ - break; \ - memcpy((char *)ptr, (const char *)var, len); \ - *((char *)(ptr) + len) = 0; \ - ptr += size_round(len + 1); \ -} while (0) - -#endif /* _PORTALS_LIB_H */ diff --git a/lnet/include/lnet/.cvsignore b/lnet/include/lnet/.cvsignore deleted file mode 100644 index 282522d..0000000 --- a/lnet/include/lnet/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/lnet/include/lnet/Makefile.am b/lnet/include/lnet/Makefile.am deleted file mode 100644 index 4043f66..0000000 --- a/lnet/include/lnet/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -portalsdir=$(includedir)/portals - -if UTILS -portals_HEADERS = list.h -endif - -EXTRA_DIST = api.h api-support.h build_check.h errno.h \ - internal.h lib-p30.h lib-types.h list.h \ - lltrace.h myrnal.h nal.h nalids.h p30.h ptlctl.h \ - socknal.h stringtab.h types.h diff --git a/lnet/include/lnet/api-support.h b/lnet/include/lnet/api-support.h deleted file mode 100644 index c5994c6..0000000 --- a/lnet/include/lnet/api-support.h +++ /dev/null @@ -1,22 +0,0 @@ - -#include "build_check.h" - -#ifndef __KERNEL__ -# include -# include -# include -# include - -/* Lots of POSIX dependencies to support PtlEQWait_timeout */ -# include -# include -# include -#endif - -#include -#include -#include - -#include -#include - diff --git a/lnet/include/lnet/api.h b/lnet/include/lnet/api.h deleted file mode 100644 index 56b7b99..0000000 --- a/lnet/include/lnet/api.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef P30_API_H -#define P30_API_H - -#include "build_check.h" - -#include - -int PtlInit(int *); -void PtlFini(void); - -int PtlNIInit(ptl_interface_t interface, ptl_pid_t requested_pid, - ptl_ni_limits_t *desired_limits, ptl_ni_limits_t *actual_limits, - ptl_handle_ni_t *interface_out); - -int PtlNIInitialized(ptl_interface_t); - -int PtlNIFini(ptl_handle_ni_t interface_in); - -int PtlGetId(ptl_handle_ni_t ni_handle, ptl_process_id_t *id); - -int PtlGetUid(ptl_handle_ni_t ni_handle, ptl_uid_t *uid); - - -/* - * Network interfaces - */ - -int PtlNIStatus(ptl_handle_ni_t interface_in, ptl_sr_index_t register_in, - ptl_sr_value_t * status_out); - -int PtlNIDist(ptl_handle_ni_t interface_in, ptl_process_id_t process_in, - unsigned long *distance_out); - -int PtlNIHandle(ptl_handle_any_t handle_in, ptl_handle_ni_t * interface_out); - - -/* - * PtlNIFailNid - * - * Not an official Portals 3 API call. It provides a way of simulating - * communications failures to all (nid == PTL_NID_ANY), or specific peers - * (via multiple calls), either until further notice (threshold == -1), or - * for a specific number of messages. Passing a threshold of zero, "heals" - * the given peer. - */ -int PtlFailNid (ptl_handle_ni_t ni, ptl_nid_t nid, unsigned int threshold); - -/* - * PtlSnprintHandle: - * - * This is not an official Portals 3 API call. It is provided - * so that an application can print an opaque handle. - */ -void PtlSnprintHandle (char *str, int str_len, ptl_handle_any_t handle); - -/* - * Match entries - */ - -int PtlMEAttach(ptl_handle_ni_t interface_in, ptl_pt_index_t index_in, - ptl_process_id_t match_id_in, ptl_match_bits_t match_bits_in, - ptl_match_bits_t ignore_bits_in, ptl_unlink_t unlink_in, - ptl_ins_pos_t pos_in, ptl_handle_me_t * handle_out); - -int PtlMEInsert(ptl_handle_me_t current_in, ptl_process_id_t match_id_in, - ptl_match_bits_t match_bits_in, ptl_match_bits_t ignore_bits_in, - ptl_unlink_t unlink_in, ptl_ins_pos_t position_in, - ptl_handle_me_t * handle_out); - -int PtlMEUnlink(ptl_handle_me_t current_in); - -int PtlMEUnlinkList(ptl_handle_me_t current_in); - - - -/* - * Memory descriptors - */ - -int PtlMDAttach(ptl_handle_me_t current_in, ptl_md_t md_in, - ptl_unlink_t unlink_in, ptl_handle_md_t * handle_out); - -int PtlMDBind(ptl_handle_ni_t ni_in, ptl_md_t md_in, - ptl_unlink_t unlink_in, ptl_handle_md_t * handle_out); - -int PtlMDUnlink(ptl_handle_md_t md_in); - -int PtlMDUpdate(ptl_handle_md_t md_in, ptl_md_t * old_inout, - ptl_md_t * new_inout, ptl_handle_eq_t testq_in); - - -/* These should not be called by users */ -int PtlMDUpdate_internal(ptl_handle_md_t md_in, ptl_md_t * old_inout, - ptl_md_t * new_inout, ptl_handle_eq_t testq_in, - ptl_seq_t sequence_in); - - - - -/* - * Event queues - */ -int PtlEQAlloc(ptl_handle_ni_t ni_in, ptl_size_t count_in, - ptl_eq_handler_t handler, - ptl_handle_eq_t *handle_out); -int PtlEQFree(ptl_handle_eq_t eventq_in); - -int PtlEQGet(ptl_handle_eq_t eventq_in, ptl_event_t * event_out); - - -int PtlEQWait(ptl_handle_eq_t eventq_in, ptl_event_t * event_out); - -int PtlEQPoll(ptl_handle_eq_t *eventqs_in, int neq_in, int timeout, - ptl_event_t *event_out, int *which_out); - -/* - * Access Control Table - */ -int PtlACEntry(ptl_handle_ni_t ni_in, ptl_ac_index_t index_in, - ptl_process_id_t match_id_in, ptl_pt_index_t portal_in); - - -/* - * Data movement - */ - -int PtlPut(ptl_handle_md_t md_in, ptl_ack_req_t ack_req_in, - ptl_process_id_t target_in, ptl_pt_index_t portal_in, - ptl_ac_index_t cookie_in, ptl_match_bits_t match_bits_in, - ptl_size_t offset_in, ptl_hdr_data_t hdr_data_in); - -int PtlGet(ptl_handle_md_t md_in, ptl_process_id_t target_in, - ptl_pt_index_t portal_in, ptl_ac_index_t cookie_in, - ptl_match_bits_t match_bits_in, ptl_size_t offset_in); - - - -#endif diff --git a/lnet/include/lnet/build_check.h b/lnet/include/lnet/build_check.h deleted file mode 100644 index c219d2a..0000000 --- a/lnet/include/lnet/build_check.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _BUILD_CHECK_H -#define _BUILD_CHECK_H - -#if CRAY_PORTALS -#error "an application got to me instead of cray's includes" -#endif - -#endif diff --git a/lnet/include/lnet/errno.h b/lnet/include/lnet/errno.h deleted file mode 100644 index 42f2626..0000000 --- a/lnet/include/lnet/errno.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _P30_ERRNO_H_ -#define _P30_ERRNO_H_ - -#include "build_check.h" -/* - * include/portals/errno.h - * - * Shared error number lists - */ - -/* If you change these, you must update the string table in api-errno.c */ -typedef enum { - PTL_OK = 0, - PTL_SEGV = 1, - - PTL_NO_SPACE = 2, - PTL_ME_IN_USE = 3, - PTL_VAL_FAILED = 4, - - PTL_NAL_FAILED = 5, - PTL_NO_INIT = 6, - PTL_IFACE_DUP = 7, - PTL_IFACE_INVALID = 8, - - PTL_HANDLE_INVALID = 9, - PTL_MD_INVALID = 10, - PTL_ME_INVALID = 11, -/* If you change these, you must update the string table in api-errno.c */ - PTL_PROCESS_INVALID = 12, - PTL_PT_INDEX_INVALID = 13, - - PTL_SR_INDEX_INVALID = 14, - PTL_EQ_INVALID = 15, - PTL_EQ_DROPPED = 16, - - PTL_EQ_EMPTY = 17, - PTL_MD_NO_UPDATE = 18, - PTL_FAIL = 19, - - PTL_IOV_INVALID = 20, - - PTL_EQ_IN_USE = 21, - - PTL_NI_INVALID = 22, - PTL_MD_ILLEGAL = 23, - - PTL_MAX_ERRNO = 24 -} ptl_err_t; -/* If you change these, you must update the string table in api-errno.c */ - -extern const char *ptl_err_str[]; - -#endif diff --git a/lnet/include/lnet/internal.h b/lnet/include/lnet/internal.h deleted file mode 100644 index eae00a0..0000000 --- a/lnet/include/lnet/internal.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _P30_INTERNAL_H_ -#define _P30_INTERNAL_H_ - -#include "build_check.h" -/* - * p30/internal.h - * - * Internals for the API level library that are not needed - * by the user application - */ - -#include - -extern int ptl_init; /* Has the library been initialized */ - -#endif diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h deleted file mode 100644 index b710569..0000000 --- a/lnet/include/lnet/lib-lnet.h +++ /dev/null @@ -1,465 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib-p30.h - * - * Top level include for library side routines - */ - -#ifndef _LIB_P30_H_ -#define _LIB_P30_H_ - -#include "build_check.h" - -#ifdef __KERNEL__ -# include -# include -#else -# include -# include -# include -#endif -#include -#include -#include -#include -#include - -static inline int ptl_is_wire_handle_none (ptl_handle_wire_t *wh) -{ - return (wh->wh_interface_cookie == PTL_WIRE_HANDLE_NONE.wh_interface_cookie && - wh->wh_object_cookie == PTL_WIRE_HANDLE_NONE.wh_object_cookie); -} - -#ifdef __KERNEL__ -#define LIB_LOCK(nal,flags) \ - spin_lock_irqsave(&(nal)->libnal_ni.ni_lock, flags) -#define LIB_UNLOCK(nal,flags) \ - spin_unlock_irqrestore(&(nal)->libnal_ni.ni_lock, flags) -#else -#define LIB_LOCK(nal,flags) \ - (pthread_mutex_lock(&(nal)->libnal_ni.ni_mutex), (flags) = 0) -#define LIB_UNLOCK(nal,flags) \ - pthread_mutex_unlock(&(nal)->libnal_ni.ni_mutex) -#endif - - -#ifdef PTL_USE_LIB_FREELIST - -#define MAX_MES 2048 -#define MAX_MDS 2048 -#define MAX_MSGS 2048 /* Outstanding messages */ -#define MAX_EQS 512 - -extern int lib_freelist_init (lib_nal_t *nal, lib_freelist_t *fl, int nobj, int objsize); -extern void lib_freelist_fini (lib_nal_t *nal, lib_freelist_t *fl); - -static inline void * -lib_freelist_alloc (lib_freelist_t *fl) -{ - /* ALWAYS called with liblock held */ - lib_freeobj_t *o; - - if (list_empty (&fl->fl_list)) - return (NULL); - - o = list_entry (fl->fl_list.next, lib_freeobj_t, fo_list); - list_del (&o->fo_list); - return ((void *)&o->fo_contents); -} - -static inline void -lib_freelist_free (lib_freelist_t *fl, void *obj) -{ - /* ALWAYS called with liblock held */ - lib_freeobj_t *o = list_entry (obj, lib_freeobj_t, fo_contents); - - list_add (&o->fo_list, &fl->fl_list); -} - - -static inline lib_eq_t * -lib_eq_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_eq_t *eq; - - LIB_LOCK (nal, flags); - eq = (lib_eq_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_eqs); - LIB_UNLOCK (nal, flags); - - return (eq); -} - -static inline void -lib_eq_free (lib_nal_t *nal, lib_eq_t *eq) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_eqs, eq); -} - -static inline lib_md_t * -lib_md_alloc (lib_nal_t *nal, ptl_md_t *umd) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_md_t *md; - - LIB_LOCK (nal, flags); - md = (lib_md_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_mds); - LIB_UNLOCK (nal, flags); - - return (md); -} - -static inline void -lib_md_free (lib_nal_t *nal, lib_md_t *md) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_mds, md); -} - -static inline lib_me_t * -lib_me_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_me_t *me; - - LIB_LOCK (nal, flags); - me = (lib_me_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_mes); - LIB_UNLOCK (nal, flags); - - return (me); -} - -static inline void -lib_me_free (lib_nal_t *nal, lib_me_t *me) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_mes, me); -} - -static inline lib_msg_t * -lib_msg_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_msg_t *msg; - - LIB_LOCK (nal, flags); - msg = (lib_msg_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_msgs); - LIB_UNLOCK (nal, flags); - - if (msg != NULL) { - /* NULL pointers, clear flags etc */ - memset (msg, 0, sizeof (*msg)); - msg->ack_wmd = PTL_WIRE_HANDLE_NONE; - } - return(msg); -} - -static inline void -lib_msg_free (lib_nal_t *nal, lib_msg_t *msg) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_msgs, msg); -} - -#else - -static inline lib_eq_t * -lib_eq_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - lib_eq_t *eq; - - PORTAL_ALLOC(eq, sizeof(*eq)); - return (eq); -} - -static inline void -lib_eq_free (lib_nal_t *nal, lib_eq_t *eq) -{ - /* ALWAYS called with liblock held */ - PORTAL_FREE(eq, sizeof(*eq)); -} - -static inline lib_md_t * -lib_md_alloc (lib_nal_t *nal, ptl_md_t *umd) -{ - /* NEVER called with liblock held */ - lib_md_t *md; - int size; - int niov; - - if ((umd->options & PTL_MD_KIOV) != 0) { - niov = umd->length; - size = offsetof(lib_md_t, md_iov.kiov[niov]); - } else { - niov = ((umd->options & PTL_MD_IOVEC) != 0) ? - umd->length : 1; - size = offsetof(lib_md_t, md_iov.iov[niov]); - } - - PORTAL_ALLOC(md, size); - - if (md != NULL) { - /* Set here in case of early free */ - md->options = umd->options; - md->md_niov = niov; - } - - return (md); -} - -static inline void -lib_md_free (lib_nal_t *nal, lib_md_t *md) -{ - /* ALWAYS called with liblock held */ - int size; - - if ((md->options & PTL_MD_KIOV) != 0) - size = offsetof(lib_md_t, md_iov.kiov[md->md_niov]); - else - size = offsetof(lib_md_t, md_iov.iov[md->md_niov]); - - PORTAL_FREE(md, size); -} - -static inline lib_me_t * -lib_me_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - lib_me_t *me; - - PORTAL_ALLOC(me, sizeof(*me)); - return (me); -} - -static inline void -lib_me_free(lib_nal_t *nal, lib_me_t *me) -{ - /* ALWAYS called with liblock held */ - PORTAL_FREE(me, sizeof(*me)); -} - -static inline lib_msg_t * -lib_msg_alloc(lib_nal_t *nal) -{ - /* NEVER called with liblock held; may be in interrupt... */ - lib_msg_t *msg; - - if (in_interrupt()) - PORTAL_ALLOC_ATOMIC(msg, sizeof(*msg)); - else - PORTAL_ALLOC(msg, sizeof(*msg)); - - if (msg != NULL) { - /* NULL pointers, clear flags etc */ - memset (msg, 0, sizeof (*msg)); - msg->ack_wmd = PTL_WIRE_HANDLE_NONE; - } - return (msg); -} - -static inline void -lib_msg_free(lib_nal_t *nal, lib_msg_t *msg) -{ - /* ALWAYS called with liblock held */ - PORTAL_FREE(msg, sizeof(*msg)); -} -#endif - -extern lib_handle_t *lib_lookup_cookie (lib_nal_t *nal, __u64 cookie, int type); -extern void lib_initialise_handle (lib_nal_t *nal, lib_handle_t *lh, int type); -extern void lib_invalidate_handle (lib_nal_t *nal, lib_handle_t *lh); - -static inline void -ptl_eq2handle (ptl_handle_eq_t *handle, lib_nal_t *nal, lib_eq_t *eq) -{ - if (eq == NULL) { - *handle = PTL_EQ_NONE; - return; - } - - handle->nal_idx = nal->libnal_ni.ni_api->nal_handle.nal_idx; - handle->cookie = eq->eq_lh.lh_cookie; -} - -static inline lib_eq_t * -ptl_handle2eq (ptl_handle_eq_t *handle, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie, - PTL_COOKIE_TYPE_EQ); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_eq_t, eq_lh)); -} - -static inline void -ptl_md2handle (ptl_handle_md_t *handle, lib_nal_t *nal, lib_md_t *md) -{ - handle->nal_idx = nal->libnal_ni.ni_api->nal_handle.nal_idx; - handle->cookie = md->md_lh.lh_cookie; -} - -static inline lib_md_t * -ptl_handle2md (ptl_handle_md_t *handle, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie, - PTL_COOKIE_TYPE_MD); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_md_t, md_lh)); -} - -static inline lib_md_t * -ptl_wire_handle2md (ptl_handle_wire_t *wh, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh; - - if (wh->wh_interface_cookie != nal->libnal_ni.ni_interface_cookie) - return (NULL); - - lh = lib_lookup_cookie (nal, wh->wh_object_cookie, - PTL_COOKIE_TYPE_MD); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_md_t, md_lh)); -} - -static inline void -ptl_me2handle (ptl_handle_me_t *handle, lib_nal_t *nal, lib_me_t *me) -{ - handle->nal_idx = nal->libnal_ni.ni_api->nal_handle.nal_idx; - handle->cookie = me->me_lh.lh_cookie; -} - -static inline lib_me_t * -ptl_handle2me (ptl_handle_me_t *handle, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie, - PTL_COOKIE_TYPE_ME); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_me_t, me_lh)); -} - -extern int lib_init(lib_nal_t *libnal, nal_t *apinal, - ptl_process_id_t pid, - ptl_ni_limits_t *desired_limits, - ptl_ni_limits_t *actual_limits); -extern int lib_fini(lib_nal_t *libnal); - -/* - * When the NAL detects an incoming message header, it should call - * lib_parse() decode it. If the message header is garbage, lib_parse() - * returns immediately with failure, otherwise the NAL callbacks will be - * called to receive the message body. They are handed the private cookie - * as a way for the NAL to maintain state about which transaction is being - * processed. An extra parameter, lib_msg contains the lib-level message - * state for passing to lib_finalize() when the message body has been - * received. - */ -extern void lib_enq_event_locked (lib_nal_t *nal, void *private, - lib_eq_t *eq, ptl_event_t *ev); -extern void lib_finalize (lib_nal_t *nal, void *private, lib_msg_t *msg, - ptl_ni_fail_t ni_fail_type); -extern ptl_err_t lib_parse (lib_nal_t *nal, ptl_hdr_t *hdr, void *private); -extern lib_msg_t *lib_create_reply_msg (lib_nal_t *nal, ptl_nid_t peer_nid, - lib_msg_t *get_msg); -extern void print_hdr (lib_nal_t * nal, ptl_hdr_t * hdr); - - -extern ptl_size_t lib_iov_nob (int niov, struct iovec *iov); -extern void lib_copy_iov2buf (char *dest, int niov, struct iovec *iov, - ptl_size_t offset, ptl_size_t len); -extern void lib_copy_buf2iov (int niov, struct iovec *iov, ptl_size_t offset, - char *src, ptl_size_t len); -extern int lib_extract_iov (int dst_niov, struct iovec *dst, - int src_niov, struct iovec *src, - ptl_size_t offset, ptl_size_t len); - -extern ptl_size_t lib_kiov_nob (int niov, ptl_kiov_t *iov); -extern void lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *kiov, - ptl_size_t offset, ptl_size_t len); -extern void lib_copy_buf2kiov (int niov, ptl_kiov_t *kiov, ptl_size_t offset, - char *src, ptl_size_t len); -extern int lib_extract_kiov (int dst_niov, ptl_kiov_t *dst, - int src_niov, ptl_kiov_t *src, - ptl_size_t offset, ptl_size_t len); - -extern void lib_assert_wire_constants (void); - -extern ptl_err_t lib_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, lib_md_t *md, - ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen); -extern ptl_err_t lib_send (lib_nal_t *nal, void *private, lib_msg_t *msg, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - lib_md_t *md, ptl_size_t offset, ptl_size_t len); - -extern int lib_api_ni_status (nal_t *nal, ptl_sr_index_t sr_idx, - ptl_sr_value_t *status); -extern int lib_api_ni_dist (nal_t *nal, ptl_process_id_t *pid, - unsigned long *dist); - -extern int lib_api_eq_alloc (nal_t *nal, ptl_size_t count, - ptl_eq_handler_t callback, - ptl_handle_eq_t *handle); -extern int lib_api_eq_free(nal_t *nal, ptl_handle_eq_t *eqh); -extern int lib_api_eq_poll (nal_t *nal, - ptl_handle_eq_t *eventqs, int neq, int timeout_ms, - ptl_event_t *event, int *which); - -extern int lib_api_me_attach(nal_t *nal, - ptl_pt_index_t portal, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, - ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle); -extern int lib_api_me_insert(nal_t *nal, - ptl_handle_me_t *current_meh, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, - ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle); -extern int lib_api_me_unlink (nal_t *nal, ptl_handle_me_t *meh); -extern void lib_me_unlink(lib_nal_t *nal, lib_me_t *me); - -extern int lib_api_get_id(nal_t *nal, ptl_process_id_t *pid); - -extern void lib_md_unlink(lib_nal_t *nal, lib_md_t *md); -extern void lib_md_deconstruct(lib_nal_t *nal, lib_md_t *lmd, ptl_md_t *umd); -extern int lib_api_md_attach(nal_t *nal, ptl_handle_me_t *meh, - ptl_md_t *umd, ptl_unlink_t unlink, - ptl_handle_md_t *handle); -extern int lib_api_md_bind(nal_t *nal, ptl_md_t *umd, ptl_unlink_t unlink, - ptl_handle_md_t *handle); -extern int lib_api_md_unlink (nal_t *nal, ptl_handle_md_t *mdh); -extern int lib_api_md_update (nal_t *nal, ptl_handle_md_t *mdh, - ptl_md_t *oldumd, ptl_md_t *newumd, - ptl_handle_eq_t *testqh); - -extern int lib_api_get(nal_t *apinal, ptl_handle_md_t *mdh, - ptl_process_id_t *id, - ptl_pt_index_t portal, ptl_ac_index_t ac, - ptl_match_bits_t match_bits, ptl_size_t offset); -extern int lib_api_put(nal_t *apinal, ptl_handle_md_t *mdh, - ptl_ack_req_t ack, ptl_process_id_t *id, - ptl_pt_index_t portal, ptl_ac_index_t ac, - ptl_match_bits_t match_bits, - ptl_size_t offset, ptl_hdr_data_t hdr_data); -extern int lib_api_fail_nid(nal_t *apinal, ptl_nid_t nid, unsigned int threshold); - -#endif diff --git a/lnet/include/lnet/lib-p30.h b/lnet/include/lnet/lib-p30.h deleted file mode 100644 index b710569..0000000 --- a/lnet/include/lnet/lib-p30.h +++ /dev/null @@ -1,465 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib-p30.h - * - * Top level include for library side routines - */ - -#ifndef _LIB_P30_H_ -#define _LIB_P30_H_ - -#include "build_check.h" - -#ifdef __KERNEL__ -# include -# include -#else -# include -# include -# include -#endif -#include -#include -#include -#include -#include - -static inline int ptl_is_wire_handle_none (ptl_handle_wire_t *wh) -{ - return (wh->wh_interface_cookie == PTL_WIRE_HANDLE_NONE.wh_interface_cookie && - wh->wh_object_cookie == PTL_WIRE_HANDLE_NONE.wh_object_cookie); -} - -#ifdef __KERNEL__ -#define LIB_LOCK(nal,flags) \ - spin_lock_irqsave(&(nal)->libnal_ni.ni_lock, flags) -#define LIB_UNLOCK(nal,flags) \ - spin_unlock_irqrestore(&(nal)->libnal_ni.ni_lock, flags) -#else -#define LIB_LOCK(nal,flags) \ - (pthread_mutex_lock(&(nal)->libnal_ni.ni_mutex), (flags) = 0) -#define LIB_UNLOCK(nal,flags) \ - pthread_mutex_unlock(&(nal)->libnal_ni.ni_mutex) -#endif - - -#ifdef PTL_USE_LIB_FREELIST - -#define MAX_MES 2048 -#define MAX_MDS 2048 -#define MAX_MSGS 2048 /* Outstanding messages */ -#define MAX_EQS 512 - -extern int lib_freelist_init (lib_nal_t *nal, lib_freelist_t *fl, int nobj, int objsize); -extern void lib_freelist_fini (lib_nal_t *nal, lib_freelist_t *fl); - -static inline void * -lib_freelist_alloc (lib_freelist_t *fl) -{ - /* ALWAYS called with liblock held */ - lib_freeobj_t *o; - - if (list_empty (&fl->fl_list)) - return (NULL); - - o = list_entry (fl->fl_list.next, lib_freeobj_t, fo_list); - list_del (&o->fo_list); - return ((void *)&o->fo_contents); -} - -static inline void -lib_freelist_free (lib_freelist_t *fl, void *obj) -{ - /* ALWAYS called with liblock held */ - lib_freeobj_t *o = list_entry (obj, lib_freeobj_t, fo_contents); - - list_add (&o->fo_list, &fl->fl_list); -} - - -static inline lib_eq_t * -lib_eq_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_eq_t *eq; - - LIB_LOCK (nal, flags); - eq = (lib_eq_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_eqs); - LIB_UNLOCK (nal, flags); - - return (eq); -} - -static inline void -lib_eq_free (lib_nal_t *nal, lib_eq_t *eq) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_eqs, eq); -} - -static inline lib_md_t * -lib_md_alloc (lib_nal_t *nal, ptl_md_t *umd) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_md_t *md; - - LIB_LOCK (nal, flags); - md = (lib_md_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_mds); - LIB_UNLOCK (nal, flags); - - return (md); -} - -static inline void -lib_md_free (lib_nal_t *nal, lib_md_t *md) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_mds, md); -} - -static inline lib_me_t * -lib_me_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_me_t *me; - - LIB_LOCK (nal, flags); - me = (lib_me_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_mes); - LIB_UNLOCK (nal, flags); - - return (me); -} - -static inline void -lib_me_free (lib_nal_t *nal, lib_me_t *me) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_mes, me); -} - -static inline lib_msg_t * -lib_msg_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - unsigned long flags; - lib_msg_t *msg; - - LIB_LOCK (nal, flags); - msg = (lib_msg_t *)lib_freelist_alloc (&nal->libnal_ni.ni_free_msgs); - LIB_UNLOCK (nal, flags); - - if (msg != NULL) { - /* NULL pointers, clear flags etc */ - memset (msg, 0, sizeof (*msg)); - msg->ack_wmd = PTL_WIRE_HANDLE_NONE; - } - return(msg); -} - -static inline void -lib_msg_free (lib_nal_t *nal, lib_msg_t *msg) -{ - /* ALWAYS called with liblock held */ - lib_freelist_free (&nal->libnal_ni.ni_free_msgs, msg); -} - -#else - -static inline lib_eq_t * -lib_eq_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - lib_eq_t *eq; - - PORTAL_ALLOC(eq, sizeof(*eq)); - return (eq); -} - -static inline void -lib_eq_free (lib_nal_t *nal, lib_eq_t *eq) -{ - /* ALWAYS called with liblock held */ - PORTAL_FREE(eq, sizeof(*eq)); -} - -static inline lib_md_t * -lib_md_alloc (lib_nal_t *nal, ptl_md_t *umd) -{ - /* NEVER called with liblock held */ - lib_md_t *md; - int size; - int niov; - - if ((umd->options & PTL_MD_KIOV) != 0) { - niov = umd->length; - size = offsetof(lib_md_t, md_iov.kiov[niov]); - } else { - niov = ((umd->options & PTL_MD_IOVEC) != 0) ? - umd->length : 1; - size = offsetof(lib_md_t, md_iov.iov[niov]); - } - - PORTAL_ALLOC(md, size); - - if (md != NULL) { - /* Set here in case of early free */ - md->options = umd->options; - md->md_niov = niov; - } - - return (md); -} - -static inline void -lib_md_free (lib_nal_t *nal, lib_md_t *md) -{ - /* ALWAYS called with liblock held */ - int size; - - if ((md->options & PTL_MD_KIOV) != 0) - size = offsetof(lib_md_t, md_iov.kiov[md->md_niov]); - else - size = offsetof(lib_md_t, md_iov.iov[md->md_niov]); - - PORTAL_FREE(md, size); -} - -static inline lib_me_t * -lib_me_alloc (lib_nal_t *nal) -{ - /* NEVER called with liblock held */ - lib_me_t *me; - - PORTAL_ALLOC(me, sizeof(*me)); - return (me); -} - -static inline void -lib_me_free(lib_nal_t *nal, lib_me_t *me) -{ - /* ALWAYS called with liblock held */ - PORTAL_FREE(me, sizeof(*me)); -} - -static inline lib_msg_t * -lib_msg_alloc(lib_nal_t *nal) -{ - /* NEVER called with liblock held; may be in interrupt... */ - lib_msg_t *msg; - - if (in_interrupt()) - PORTAL_ALLOC_ATOMIC(msg, sizeof(*msg)); - else - PORTAL_ALLOC(msg, sizeof(*msg)); - - if (msg != NULL) { - /* NULL pointers, clear flags etc */ - memset (msg, 0, sizeof (*msg)); - msg->ack_wmd = PTL_WIRE_HANDLE_NONE; - } - return (msg); -} - -static inline void -lib_msg_free(lib_nal_t *nal, lib_msg_t *msg) -{ - /* ALWAYS called with liblock held */ - PORTAL_FREE(msg, sizeof(*msg)); -} -#endif - -extern lib_handle_t *lib_lookup_cookie (lib_nal_t *nal, __u64 cookie, int type); -extern void lib_initialise_handle (lib_nal_t *nal, lib_handle_t *lh, int type); -extern void lib_invalidate_handle (lib_nal_t *nal, lib_handle_t *lh); - -static inline void -ptl_eq2handle (ptl_handle_eq_t *handle, lib_nal_t *nal, lib_eq_t *eq) -{ - if (eq == NULL) { - *handle = PTL_EQ_NONE; - return; - } - - handle->nal_idx = nal->libnal_ni.ni_api->nal_handle.nal_idx; - handle->cookie = eq->eq_lh.lh_cookie; -} - -static inline lib_eq_t * -ptl_handle2eq (ptl_handle_eq_t *handle, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie, - PTL_COOKIE_TYPE_EQ); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_eq_t, eq_lh)); -} - -static inline void -ptl_md2handle (ptl_handle_md_t *handle, lib_nal_t *nal, lib_md_t *md) -{ - handle->nal_idx = nal->libnal_ni.ni_api->nal_handle.nal_idx; - handle->cookie = md->md_lh.lh_cookie; -} - -static inline lib_md_t * -ptl_handle2md (ptl_handle_md_t *handle, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie, - PTL_COOKIE_TYPE_MD); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_md_t, md_lh)); -} - -static inline lib_md_t * -ptl_wire_handle2md (ptl_handle_wire_t *wh, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh; - - if (wh->wh_interface_cookie != nal->libnal_ni.ni_interface_cookie) - return (NULL); - - lh = lib_lookup_cookie (nal, wh->wh_object_cookie, - PTL_COOKIE_TYPE_MD); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_md_t, md_lh)); -} - -static inline void -ptl_me2handle (ptl_handle_me_t *handle, lib_nal_t *nal, lib_me_t *me) -{ - handle->nal_idx = nal->libnal_ni.ni_api->nal_handle.nal_idx; - handle->cookie = me->me_lh.lh_cookie; -} - -static inline lib_me_t * -ptl_handle2me (ptl_handle_me_t *handle, lib_nal_t *nal) -{ - /* ALWAYS called with liblock held */ - lib_handle_t *lh = lib_lookup_cookie (nal, handle->cookie, - PTL_COOKIE_TYPE_ME); - if (lh == NULL) - return (NULL); - - return (lh_entry (lh, lib_me_t, me_lh)); -} - -extern int lib_init(lib_nal_t *libnal, nal_t *apinal, - ptl_process_id_t pid, - ptl_ni_limits_t *desired_limits, - ptl_ni_limits_t *actual_limits); -extern int lib_fini(lib_nal_t *libnal); - -/* - * When the NAL detects an incoming message header, it should call - * lib_parse() decode it. If the message header is garbage, lib_parse() - * returns immediately with failure, otherwise the NAL callbacks will be - * called to receive the message body. They are handed the private cookie - * as a way for the NAL to maintain state about which transaction is being - * processed. An extra parameter, lib_msg contains the lib-level message - * state for passing to lib_finalize() when the message body has been - * received. - */ -extern void lib_enq_event_locked (lib_nal_t *nal, void *private, - lib_eq_t *eq, ptl_event_t *ev); -extern void lib_finalize (lib_nal_t *nal, void *private, lib_msg_t *msg, - ptl_ni_fail_t ni_fail_type); -extern ptl_err_t lib_parse (lib_nal_t *nal, ptl_hdr_t *hdr, void *private); -extern lib_msg_t *lib_create_reply_msg (lib_nal_t *nal, ptl_nid_t peer_nid, - lib_msg_t *get_msg); -extern void print_hdr (lib_nal_t * nal, ptl_hdr_t * hdr); - - -extern ptl_size_t lib_iov_nob (int niov, struct iovec *iov); -extern void lib_copy_iov2buf (char *dest, int niov, struct iovec *iov, - ptl_size_t offset, ptl_size_t len); -extern void lib_copy_buf2iov (int niov, struct iovec *iov, ptl_size_t offset, - char *src, ptl_size_t len); -extern int lib_extract_iov (int dst_niov, struct iovec *dst, - int src_niov, struct iovec *src, - ptl_size_t offset, ptl_size_t len); - -extern ptl_size_t lib_kiov_nob (int niov, ptl_kiov_t *iov); -extern void lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *kiov, - ptl_size_t offset, ptl_size_t len); -extern void lib_copy_buf2kiov (int niov, ptl_kiov_t *kiov, ptl_size_t offset, - char *src, ptl_size_t len); -extern int lib_extract_kiov (int dst_niov, ptl_kiov_t *dst, - int src_niov, ptl_kiov_t *src, - ptl_size_t offset, ptl_size_t len); - -extern void lib_assert_wire_constants (void); - -extern ptl_err_t lib_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, lib_md_t *md, - ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen); -extern ptl_err_t lib_send (lib_nal_t *nal, void *private, lib_msg_t *msg, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - lib_md_t *md, ptl_size_t offset, ptl_size_t len); - -extern int lib_api_ni_status (nal_t *nal, ptl_sr_index_t sr_idx, - ptl_sr_value_t *status); -extern int lib_api_ni_dist (nal_t *nal, ptl_process_id_t *pid, - unsigned long *dist); - -extern int lib_api_eq_alloc (nal_t *nal, ptl_size_t count, - ptl_eq_handler_t callback, - ptl_handle_eq_t *handle); -extern int lib_api_eq_free(nal_t *nal, ptl_handle_eq_t *eqh); -extern int lib_api_eq_poll (nal_t *nal, - ptl_handle_eq_t *eventqs, int neq, int timeout_ms, - ptl_event_t *event, int *which); - -extern int lib_api_me_attach(nal_t *nal, - ptl_pt_index_t portal, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, - ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle); -extern int lib_api_me_insert(nal_t *nal, - ptl_handle_me_t *current_meh, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, - ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle); -extern int lib_api_me_unlink (nal_t *nal, ptl_handle_me_t *meh); -extern void lib_me_unlink(lib_nal_t *nal, lib_me_t *me); - -extern int lib_api_get_id(nal_t *nal, ptl_process_id_t *pid); - -extern void lib_md_unlink(lib_nal_t *nal, lib_md_t *md); -extern void lib_md_deconstruct(lib_nal_t *nal, lib_md_t *lmd, ptl_md_t *umd); -extern int lib_api_md_attach(nal_t *nal, ptl_handle_me_t *meh, - ptl_md_t *umd, ptl_unlink_t unlink, - ptl_handle_md_t *handle); -extern int lib_api_md_bind(nal_t *nal, ptl_md_t *umd, ptl_unlink_t unlink, - ptl_handle_md_t *handle); -extern int lib_api_md_unlink (nal_t *nal, ptl_handle_md_t *mdh); -extern int lib_api_md_update (nal_t *nal, ptl_handle_md_t *mdh, - ptl_md_t *oldumd, ptl_md_t *newumd, - ptl_handle_eq_t *testqh); - -extern int lib_api_get(nal_t *apinal, ptl_handle_md_t *mdh, - ptl_process_id_t *id, - ptl_pt_index_t portal, ptl_ac_index_t ac, - ptl_match_bits_t match_bits, ptl_size_t offset); -extern int lib_api_put(nal_t *apinal, ptl_handle_md_t *mdh, - ptl_ack_req_t ack, ptl_process_id_t *id, - ptl_pt_index_t portal, ptl_ac_index_t ac, - ptl_match_bits_t match_bits, - ptl_size_t offset, ptl_hdr_data_t hdr_data); -extern int lib_api_fail_nid(nal_t *apinal, ptl_nid_t nid, unsigned int threshold); - -#endif diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h deleted file mode 100644 index cfcef2b..0000000 --- a/lnet/include/lnet/lib-types.h +++ /dev/null @@ -1,359 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * p30/lib-types.h - * - * Types used by the library side routines that do not need to be - * exposed to the user application - */ - -#ifndef _LIB_TYPES_H_ -#define _LIB_TYPES_H_ - -#include "build_check.h" - -#include -#include -#ifdef __KERNEL__ -# include -# include -# include -#else -# define PTL_USE_LIB_FREELIST -# include -#endif - -typedef char *user_ptr; -typedef struct lib_msg_t lib_msg_t; -typedef struct lib_ptl_t lib_ptl_t; -typedef struct lib_ac_t lib_ac_t; -typedef struct lib_me_t lib_me_t; -typedef struct lib_md_t lib_md_t; -typedef struct lib_eq_t lib_eq_t; - -#define WIRE_ATTR __attribute__((packed)) - -/* The wire handle's interface cookie only matches one network interface in - * one epoch (i.e. new cookie when the interface restarts or the node - * reboots). The object cookie only matches one object on that interface - * during that object's lifetime (i.e. no cookie re-use). */ -typedef struct { - __u64 wh_interface_cookie; - __u64 wh_object_cookie; -} WIRE_ATTR ptl_handle_wire_t; - -/* byte-flip insensitive! */ -#define PTL_WIRE_HANDLE_NONE \ -((const ptl_handle_wire_t) {.wh_interface_cookie = -1, .wh_object_cookie = -1}) - -typedef enum { - PTL_MSG_ACK = 0, - PTL_MSG_PUT, - PTL_MSG_GET, - PTL_MSG_REPLY, - PTL_MSG_HELLO, -} ptl_msg_type_t; - -/* The variant fields of the portals message header are aligned on an 8 - * byte boundary in the message header. Note that all types used in these - * wire structs MUST be fixed size and the smaller types are placed at the - * end. */ -typedef struct ptl_ack { - ptl_handle_wire_t dst_wmd; - ptl_match_bits_t match_bits; - ptl_size_t mlength; -} WIRE_ATTR ptl_ack_t; - -typedef struct ptl_put { - ptl_handle_wire_t ack_wmd; - ptl_match_bits_t match_bits; - ptl_hdr_data_t hdr_data; - ptl_pt_index_t ptl_index; - ptl_size_t offset; -} WIRE_ATTR ptl_put_t; - -typedef struct ptl_get { - ptl_handle_wire_t return_wmd; - ptl_match_bits_t match_bits; - ptl_pt_index_t ptl_index; - ptl_size_t src_offset; - ptl_size_t sink_length; -} WIRE_ATTR ptl_get_t; - -typedef struct ptl_reply { - ptl_handle_wire_t dst_wmd; -} WIRE_ATTR ptl_reply_t; - -typedef struct ptl_hello { - __u64 incarnation; - __u32 type; -} WIRE_ATTR ptl_hello_t; - -typedef struct { - ptl_nid_t dest_nid; - ptl_nid_t src_nid; - ptl_pid_t dest_pid; - ptl_pid_t src_pid; - __u32 type; /* ptl_msg_type_t */ - __u32 payload_length; /* payload data to follow */ - /*<------__u64 aligned------->*/ - union { - ptl_ack_t ack; - ptl_put_t put; - ptl_get_t get; - ptl_reply_t reply; - ptl_hello_t hello; - } msg; -} WIRE_ATTR ptl_hdr_t; - -/* A HELLO message contains the portals magic number and protocol version - * code in the header's dest_nid, the peer's NID in the src_nid, and - * PTL_MSG_HELLO in the type field. All other common fields are zero - * (including payload_size; i.e. no payload). - * This is for use by byte-stream NALs (e.g. TCP/IP) to check the peer is - * running the same protocol and to find out its NID, so that hosts with - * multiple IP interfaces can have a single NID. These NALs should exchange - * HELLO messages when a connection is first established. - * Individual NALs can put whatever else they fancy in ptl_hdr_t::msg. - */ -typedef struct { - __u32 magic; /* PORTALS_PROTO_MAGIC */ - __u16 version_major; /* increment on incompatible change */ - __u16 version_minor; /* increment on compatible change */ -} WIRE_ATTR ptl_magicversion_t; - -#define PORTALS_PROTO_MAGIC 0xeebc0ded - -#define PORTALS_PROTO_VERSION_MAJOR 1 -#define PORTALS_PROTO_VERSION_MINOR 0 - -typedef struct { - long recv_count, recv_length, send_count, send_length, drop_count, - drop_length, msgs_alloc, msgs_max; -} lib_counters_t; - -/* temporary expedient: limit number of entries in discontiguous MDs */ -#define PTL_MTU (1<<20) -#define PTL_MD_MAX_IOV 256 - -struct lib_msg_t { - struct list_head msg_list; - lib_md_t *md; - ptl_handle_wire_t ack_wmd; - ptl_event_t ev; -}; - -struct lib_ptl_t { - ptl_pt_index_t size; - struct list_head *tbl; -}; - -struct lib_ac_t { - int next_free; -}; - -typedef struct { - struct list_head lh_hash_chain; - __u64 lh_cookie; -} lib_handle_t; - -#define lh_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) - -struct lib_eq_t { - struct list_head eq_list; - lib_handle_t eq_lh; - ptl_seq_t eq_enq_seq; - ptl_seq_t eq_deq_seq; - ptl_size_t eq_size; - ptl_event_t *eq_events; - int eq_refcount; - ptl_eq_handler_t eq_callback; - void *eq_addrkey; -}; - -struct lib_me_t { - struct list_head me_list; - lib_handle_t me_lh; - ptl_process_id_t match_id; - ptl_match_bits_t match_bits, ignore_bits; - ptl_unlink_t unlink; - lib_md_t *md; -}; - -struct lib_md_t { - struct list_head md_list; - lib_handle_t md_lh; - lib_me_t *me; - user_ptr start; - ptl_size_t offset; - ptl_size_t length; - ptl_size_t max_size; - int threshold; - int pending; - unsigned int options; - unsigned int md_flags; - void *user_ptr; - lib_eq_t *eq; - void *md_addrkey; - unsigned int md_niov; /* # frags */ - union { - struct iovec iov[PTL_MD_MAX_IOV]; - ptl_kiov_t kiov[PTL_MD_MAX_IOV]; - } md_iov; -}; - -#define PTL_MD_FLAG_ZOMBIE (1 << 0) -#define PTL_MD_FLAG_AUTO_UNLINK (1 << 1) - -static inline int lib_md_exhausted (lib_md_t *md) -{ - return (md->threshold == 0 || - ((md->options & PTL_MD_MAX_SIZE) != 0 && - md->offset + md->max_size > md->length)); -} - -#ifdef PTL_USE_LIB_FREELIST -typedef struct -{ - void *fl_objs; /* single contiguous array of objects */ - int fl_nobjs; /* the number of them */ - int fl_objsize; /* the size (including overhead) of each of them */ - struct list_head fl_list; /* where they are enqueued */ -} lib_freelist_t; - -typedef struct -{ - struct list_head fo_list; /* enqueue on fl_list */ - void *fo_contents; /* aligned contents */ -} lib_freeobj_t; -#endif - -typedef struct { - /* info about peers we are trying to fail */ - struct list_head tp_list; /* stash in ni.ni_test_peers */ - ptl_nid_t tp_nid; /* matching nid */ - unsigned int tp_threshold; /* # failures to simulate */ -} lib_test_peer_t; - -#define PTL_COOKIE_TYPE_MD 1 -#define PTL_COOKIE_TYPE_ME 2 -#define PTL_COOKIE_TYPE_EQ 3 -#define PTL_COOKIE_TYPES 4 -/* PTL_COOKIE_TYPES must be a power of 2, so the cookie type can be - * extracted by masking with (PTL_COOKIE_TYPES - 1) */ - -typedef struct lib_ni -{ - nal_t *ni_api; - ptl_process_id_t ni_pid; - lib_ptl_t ni_portals; - lib_counters_t ni_counters; - ptl_ni_limits_t ni_actual_limits; - - int ni_lh_hash_size; /* size of lib handle hash table */ - struct list_head *ni_lh_hash_table; /* all extant lib handles, this interface */ - __u64 ni_next_object_cookie; /* cookie generator */ - __u64 ni_interface_cookie; /* uniquely identifies this ni in this epoch */ - - struct list_head ni_test_peers; - -#ifdef PTL_USE_LIB_FREELIST - lib_freelist_t ni_free_mes; - lib_freelist_t ni_free_msgs; - lib_freelist_t ni_free_mds; - lib_freelist_t ni_free_eqs; -#endif - - struct list_head ni_active_msgs; - struct list_head ni_active_mds; - struct list_head ni_active_eqs; - -#ifdef __KERNEL__ - spinlock_t ni_lock; - wait_queue_head_t ni_waitq; -#else - pthread_mutex_t ni_mutex; - pthread_cond_t ni_cond; -#endif -} lib_ni_t; - - -typedef struct lib_nal -{ - /* lib-level interface state */ - lib_ni_t libnal_ni; - - /* NAL-private data */ - void *libnal_data; - - /* - * send: Sends a preformatted header and payload data to a - * specified remote process. The payload is scattered over 'niov' - * fragments described by iov, starting at 'offset' for 'mlen' - * bytes. - * NB the NAL may NOT overwrite iov. - * PTL_OK on success => NAL has committed to send and will call - * lib_finalize on completion - */ - ptl_err_t (*libnal_send) - (struct lib_nal *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int niov, struct iovec *iov, - size_t offset, size_t mlen); - - /* as send, but with a set of page fragments (NULL if not supported) */ - ptl_err_t (*libnal_send_pages) - (struct lib_nal *nal, void *private, lib_msg_t * cookie, - ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int niov, ptl_kiov_t *iov, - size_t offset, size_t mlen); - /* - * recv: Receives an incoming message from a remote process. The - * payload is to be received into the scattered buffer of 'niov' - * fragments described by iov, starting at 'offset' for 'mlen' - * bytes. Payload bytes after 'mlen' up to 'rlen' are to be - * discarded. - * NB the NAL may NOT overwrite iov. - * PTL_OK on success => NAL has committed to receive and will call - * lib_finalize on completion - */ - ptl_err_t (*libnal_recv) - (struct lib_nal *nal, void *private, lib_msg_t * cookie, - unsigned int niov, struct iovec *iov, - size_t offset, size_t mlen, size_t rlen); - - /* as recv, but with a set of page fragments (NULL if not supported) */ - ptl_err_t (*libnal_recv_pages) - (struct lib_nal *nal, void *private, lib_msg_t * cookie, - unsigned int niov, ptl_kiov_t *iov, - size_t offset, size_t mlen, size_t rlen); - - /* - * (un)map: Tell the NAL about some memory it will access. - * *addrkey passed to libnal_unmap() is what libnal_map() set it to. - * type of *iov depends on options. - * Set to NULL if not required. - */ - ptl_err_t (*libnal_map) - (struct lib_nal *nal, unsigned int niov, struct iovec *iov, - void **addrkey); - void (*libnal_unmap) - (struct lib_nal *nal, unsigned int niov, struct iovec *iov, - void **addrkey); - - /* as (un)map, but with a set of page fragments */ - ptl_err_t (*libnal_map_pages) - (struct lib_nal *nal, unsigned int niov, ptl_kiov_t *iov, - void **addrkey); - void (*libnal_unmap_pages) - (struct lib_nal *nal, unsigned int niov, ptl_kiov_t *iov, - void **addrkey); - - void (*libnal_printf)(struct lib_nal *nal, const char *fmt, ...); - - /* Calculate a network "distance" to given node */ - int (*libnal_dist) (struct lib_nal *nal, ptl_nid_t nid, unsigned long *dist); -} lib_nal_t; - -#endif diff --git a/lnet/include/lnet/list.h b/lnet/include/lnet/list.h deleted file mode 100644 index 37d9952..0000000 --- a/lnet/include/lnet/list.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef _LINUX_LIST_H -/* - * Simple doubly linked list implementation. - * - * Some of the internal functions ("__xxx") are useful when - * manipulating whole lists rather than single entries, as - * sometimes we already know the next/prev entries and we can - * generate better code by using them directly rather than - * using the generic single-entry routines. - */ - -struct list_head { - struct list_head *next, *prev; -}; - -typedef struct list_head list_t; - -#define LIST_HEAD_INIT(name) { &(name), &(name) } - -#define LIST_HEAD(name) \ - struct list_head name = LIST_HEAD_INIT(name) - -#define INIT_LIST_HEAD(ptr) do { \ - (ptr)->next = (ptr); (ptr)->prev = (ptr); \ -} while (0) - -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_add(struct list_head * new, - struct list_head * prev, - struct list_head * next) -{ - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; -} - -/** - * list_add - add a new entry - * @new: new entry to be added - * @head: list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -static inline void list_add(struct list_head *new, struct list_head *head) -{ - __list_add(new, head, head->next); -} - -/** - * list_add_tail - add a new entry - * @new: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static inline void list_add_tail(struct list_head *new, struct list_head *head) -{ - __list_add(new, head->prev, head); -} - -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_del(struct list_head * prev, struct list_head * next) -{ - next->prev = prev; - prev->next = next; -} - -/** - * list_del - deletes entry from list. - * @entry: the element to delete from the list. - * Note: list_empty on entry does not return true after this, the entry is in an undefined state. - */ -static inline void list_del(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); -} - -/** - * list_del_init - deletes entry from list and reinitialize it. - * @entry: the element to delete from the list. - */ -static inline void list_del_init(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); - INIT_LIST_HEAD(entry); -} -#endif - -#ifndef list_for_each_entry -/** - * list_move - delete from one list and add as another's head - * @list: the entry to move - * @head: the head that will precede our entry - */ -static inline void list_move(struct list_head *list, struct list_head *head) -{ - __list_del(list->prev, list->next); - list_add(list, head); -} - -/** - * list_move_tail - delete from one list and add as another's tail - * @list: the entry to move - * @head: the head that will follow our entry - */ -static inline void list_move_tail(struct list_head *list, - struct list_head *head) -{ - __list_del(list->prev, list->next); - list_add_tail(list, head); -} -#endif - -#ifndef _LINUX_LIST_H -#define _LINUX_LIST_H -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -static inline int list_empty(struct list_head *head) -{ - return head->next == head; -} - -static inline void __list_splice(struct list_head *list, - struct list_head *head) -{ - struct list_head *first = list->next; - struct list_head *last = list->prev; - struct list_head *at = head->next; - - first->prev = head; - head->next = first; - - last->next = at; - at->prev = last; -} - -/** - * list_splice - join two lists - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void list_splice(struct list_head *list, struct list_head *head) -{ - if (!list_empty(list)) - __list_splice(list, head); -} - -/** - * list_splice_init - join two lists and reinitialise the emptied list. - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * The list at @list is reinitialised - */ -static inline void list_splice_init(struct list_head *list, - struct list_head *head) -{ - if (!list_empty(list)) { - __list_splice(list, head); - INIT_LIST_HEAD(list); - } -} - -/** - * list_entry - get the struct for this entry - * @ptr: the &struct list_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_struct within the struct. - */ -#define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) - -/** - * list_for_each - iterate over a list - * @pos: the &struct list_head to use as a loop counter. - * @head: the head for your list. - */ -#define list_for_each(pos, head) \ - for (pos = (head)->next ; pos != (head); pos = pos->next ) - -/** - * list_for_each_prev - iterate over a list in reverse order - * @pos: the &struct list_head to use as a loop counter. - * @head: the head for your list. - */ -#define list_for_each_prev(pos, head) \ - for (pos = (head)->prev ; pos != (head); pos = pos->prev) - -/** - * list_for_each_safe - iterate over a list safe against removal of list entry - * @pos: the &struct list_head to use as a loop counter. - * @n: another &struct list_head to use as temporary storage - * @head: the head for your list. - */ -#define list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -#endif - -#ifndef list_for_each_entry -/** - * list_for_each_entry - iterate over list of given type - * @pos: the type * to use as a loop counter. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) -#endif - -#ifndef list_for_each_entry_safe -/** - * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry - * @pos: the type * to use as a loop counter. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) -#endif diff --git a/lnet/include/lnet/lltrace.h b/lnet/include/lnet/lltrace.h deleted file mode 100644 index 3e01df1..0000000 --- a/lnet/include/lnet/lltrace.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Compile with: - * cc -I../../portals/include -o fio fio.c -L../../portals/linux/utils -lptlctl - */ -#ifndef __LTRACE_H_ -#define __LTRACE_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static inline int ltrace_write_file(char* fname) -{ - char* argv[3]; - - argv[0] = "debug_kernel"; - argv[1] = fname; - argv[2] = "1"; - - fprintf(stderr, "[ptlctl] %s %s %s\n", argv[0], argv[1], argv[2]); - - return jt_dbg_debug_kernel(3, argv); -} - -static inline int ltrace_clear() -{ - char* argv[1]; - - argv[0] = "clear"; - - fprintf(stderr, "[ptlctl] %s\n", argv[0]); - - return jt_dbg_clear_debug_buf(1, argv); -} - -static inline int ltrace_mark(int indent_level, char* text) -{ - char* argv[2]; - char mark_buf[PATH_MAX]; - - snprintf(mark_buf, PATH_MAX, "====%d=%s", indent_level, text); - - argv[0] = "mark"; - argv[1] = mark_buf; - return jt_dbg_mark_debug_buf(2, argv); -} - -static inline int ltrace_applymasks() -{ - char* argv[2]; - argv[0] = "list"; - argv[1] = "applymasks"; - - fprintf(stderr, "[ptlctl] %s %s\n", argv[0], argv[1]); - - return jt_dbg_list(2, argv); -} - - -static inline int ltrace_filter(char* subsys_or_mask) -{ - char* argv[2]; - argv[0] = "filter"; - argv[1] = subsys_or_mask; - return jt_dbg_filter(2, argv); -} - -static inline int ltrace_show(char* subsys_or_mask) -{ - char* argv[2]; - argv[0] = "show"; - argv[1] = subsys_or_mask; - return jt_dbg_show(2, argv); -} - -static inline int ltrace_start() -{ - int rc = 0; - dbg_initialize(0, NULL); -#ifdef PORTALS_DEV_ID - rc = register_ioc_dev(PORTALS_DEV_ID, PORTALS_DEV_PATH); -#endif - ltrace_filter("class"); - ltrace_filter("nal"); - ltrace_filter("portals"); - - ltrace_show("all_types"); - ltrace_filter("trace"); - ltrace_filter("malloc"); - ltrace_filter("net"); - ltrace_filter("page"); - ltrace_filter("other"); - ltrace_filter("info"); - ltrace_applymasks(); - - return rc; -} - - -static inline void ltrace_stop() -{ -#ifdef PORTALS_DEV_ID - unregister_ioc_dev(PORTALS_DEV_ID); -#endif -} - -static inline int not_uml() -{ - /* Return Values: - * 0 when run under UML - * 1 when run on host - * <0 when lookup failed - */ - struct stat buf; - int rc = stat("/dev/ubd", &buf); - rc = ((rc<0) && (errno == ENOENT)) ? 1 : rc; - if (rc<0) { - fprintf(stderr, "Cannot stat /dev/ubd: %s\n", strerror(errno)); - rc = 1; /* Assume host */ - } - return rc; -} - -#define LTRACE_MAX_NOB 256 -static inline void ltrace_add_processnames(char* fname) -{ - char cmdbuf[LTRACE_MAX_NOB]; - struct timeval tv; - struct timezone tz; - int nob; - int underuml = !not_uml(); - - gettimeofday(&tv, &tz); - - nob = snprintf(cmdbuf, LTRACE_MAX_NOB, "ps --no-headers -eo \""); - - /* Careful - these format strings need to match the CDEBUG - * formats in portals/linux/debug.c EXACTLY - */ - nob += snprintf(cmdbuf+nob, LTRACE_MAX_NOB, "%02x:%06x:%d:%lu.%06lu ", - S_RPC >> 24, D_VFSTRACE, 0, tv.tv_sec, tv.tv_usec); - - if (underuml && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))) { - nob += snprintf (cmdbuf+nob, LTRACE_MAX_NOB, - "(%s:%d:%s() %d | %d+%lu): ", - "lltrace.h", __LINE__, __FUNCTION__, 0, 0, 0L); - } - else { - nob += snprintf (cmdbuf+nob, LTRACE_MAX_NOB, - "(%s:%d:%s() %d+%lu): ", - "lltrace.h", __LINE__, __FUNCTION__, 0, 0L); - } - - nob += snprintf(cmdbuf+nob, LTRACE_MAX_NOB, " %%p %%c\" >> %s", fname); - system(cmdbuf); -} - -#endif diff --git a/lnet/include/lnet/lnet.h b/lnet/include/lnet/lnet.h deleted file mode 100644 index 4b8631d..0000000 --- a/lnet/include/lnet/lnet.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ -#ifndef _P30_H_ -#define _P30_H_ - -#include "build_check.h" - -/* - * p30.h - * - * User application interface file - */ - -#if defined (__KERNEL__) -#include -#include -#else -#include -#include -#endif - -#include -#include - -#endif diff --git a/lnet/include/lnet/lnetctl.h b/lnet/include/lnet/lnetctl.h deleted file mode 100644 index ef52a25..0000000 --- a/lnet/include/lnet/lnetctl.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * header for libptlctl.a - */ -#ifndef _PTLCTL_H_ -#define _PTLCTL_H_ - -#include -#include -#include - -#define PORTALS_DEV_ID 0 -#define PORTALS_DEV_PATH "/dev/portals" -#define OBD_DEV_ID 1 -#define OBD_DEV_PATH "/dev/obd" -#define SMFS_DEV_ID 2 -#define SMFS_DEV_PATH "/dev/snapdev" - -int ptl_name2nal(char *str); -int ptl_parse_ipaddr (__u32 *ipaddrp, char *str); -int ptl_parse_nid (ptl_nid_t *nidp, char *str); -char * ptl_nid2str (char *buffer, ptl_nid_t nid); - -int ptl_initialize(int argc, char **argv); -int jt_ptl_network(int argc, char **argv); -int jt_ptl_print_interfaces(int argc, char **argv); -int jt_ptl_add_interface(int argc, char **argv); -int jt_ptl_del_interface(int argc, char **argv); -int jt_ptl_print_peers (int argc, char **argv); -int jt_ptl_add_peer (int argc, char **argv); -int jt_ptl_del_peer (int argc, char **argv); -int jt_ptl_print_connections (int argc, char **argv); -int jt_ptl_connect(int argc, char **argv); -int jt_ptl_disconnect(int argc, char **argv); -int jt_ptl_push_connection(int argc, char **argv); -int jt_ptl_print_active_txs(int argc, char **argv); -int jt_ptl_ping(int argc, char **argv); -int jt_ptl_shownid(int argc, char **argv); -int jt_ptl_mynid(int argc, char **argv); -int jt_ptl_add_uuid(int argc, char **argv); -int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility */ -int jt_ptl_close_uuid(int argc, char **argv); -int jt_ptl_del_uuid(int argc, char **argv); -int jt_ptl_add_route (int argc, char **argv); -int jt_ptl_del_route (int argc, char **argv); -int jt_ptl_notify_router (int argc, char **argv); -int jt_ptl_print_routes (int argc, char **argv); -int jt_ptl_fail_nid (int argc, char **argv); -int jt_ptl_lwt(int argc, char **argv); -int jt_ptl_memhog(int argc, char **argv); - -int dbg_initialize(int argc, char **argv); -int jt_dbg_filter(int argc, char **argv); -int jt_dbg_show(int argc, char **argv); -int jt_dbg_list(int argc, char **argv); -int jt_dbg_debug_kernel(int argc, char **argv); -int jt_dbg_debug_daemon(int argc, char **argv); -int jt_dbg_debug_file(int argc, char **argv); -int jt_dbg_clear_debug_buf(int argc, char **argv); -int jt_dbg_mark_debug_buf(int argc, char **argv); -int jt_dbg_modules(int argc, char **argv); -int jt_dbg_panic(int argc, char **argv); - -int ptl_set_cfg_record_cb(cfg_record_cb_t cb); - -/* l_ioctl.c */ -typedef int (ioc_handler_t)(int dev_id, unsigned int opc, void *buf); -void set_ioc_handler(ioc_handler_t *handler); -int register_ioc_dev(int dev_id, const char * dev_name); -void unregister_ioc_dev(int dev_id); -int set_ioctl_dump(char * file); -int l_ioctl(int dev_id, unsigned int opc, void *buf); -int parse_dump(char * dump_file, ioc_handler_t ioc_func); -int jt_ioc_dump(int argc, char **argv); -extern char *dump_filename; -int dump(int dev_id, unsigned int opc, void *buf); - -#endif diff --git a/lnet/include/lnet/myrnal.h b/lnet/include/lnet/myrnal.h deleted file mode 100644 index 13790f7..0000000 --- a/lnet/include/lnet/myrnal.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MYRNAL_H -#define MYRNAL_H - -#define MAX_ARGS_LEN (256) -#define MAX_RET_LEN (128) -#define MYRNAL_MAX_ACL_SIZE (64) -#define MYRNAL_MAX_PTL_SIZE (64) - -#define P3CMD (100) -#define P3SYSCALL (200) -#define P3REGISTER (300) - -enum { PTL_MLOCKALL }; - -typedef struct { - void *args; - size_t args_len; - void *ret; - size_t ret_len; - int p3cmd; -} myrnal_forward_t; - -#endif /* MYRNAL_H */ diff --git a/lnet/include/lnet/nal.h b/lnet/include/lnet/nal.h deleted file mode 100644 index bf86569..0000000 --- a/lnet/include/lnet/nal.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef _NAL_H_ -#define _NAL_H_ - -#include "build_check.h" - -/* - * p30/nal.h - * - * The API side NAL declarations - */ - -#include - -typedef struct nal_t nal_t; - -struct nal_t { - /* common interface state */ - int nal_refct; - ptl_handle_ni_t nal_handle; - - /* NAL-private data */ - void *nal_data; - - /* NAL API implementation - * NB only nal_ni_init needs to be set when the NAL registers itself */ - int (*nal_ni_init) (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *req, ptl_ni_limits_t *actual); - - void (*nal_ni_fini) (nal_t *nal); - - int (*nal_get_id) (nal_t *nal, ptl_process_id_t *id); - int (*nal_ni_status) (nal_t *nal, ptl_sr_index_t register, ptl_sr_value_t *status); - int (*nal_ni_dist) (nal_t *nal, ptl_process_id_t *id, unsigned long *distance); - int (*nal_fail_nid) (nal_t *nal, ptl_nid_t nid, unsigned int threshold); - - int (*nal_me_attach) (nal_t *nal, ptl_pt_index_t portal, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle); - int (*nal_me_insert) (nal_t *nal, ptl_handle_me_t *me, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle); - int (*nal_me_unlink) (nal_t *nal, ptl_handle_me_t *me); - - int (*nal_md_attach) (nal_t *nal, ptl_handle_me_t *me, - ptl_md_t *md, ptl_unlink_t unlink, - ptl_handle_md_t *handle); - int (*nal_md_bind) (nal_t *nal, - ptl_md_t *md, ptl_unlink_t unlink, - ptl_handle_md_t *handle); - int (*nal_md_unlink) (nal_t *nal, ptl_handle_md_t *md); - int (*nal_md_update) (nal_t *nal, ptl_handle_md_t *md, - ptl_md_t *old_md, ptl_md_t *new_md, - ptl_handle_eq_t *testq); - - int (*nal_eq_alloc) (nal_t *nal, ptl_size_t count, - ptl_eq_handler_t handler, - ptl_handle_eq_t *handle); - int (*nal_eq_free) (nal_t *nal, ptl_handle_eq_t *eq); - int (*nal_eq_poll) (nal_t *nal, - ptl_handle_eq_t *eqs, int neqs, int timeout, - ptl_event_t *event, int *which); - - int (*nal_ace_entry) (nal_t *nal, ptl_ac_index_t index, - ptl_process_id_t match_id, ptl_pt_index_t portal); - - int (*nal_put) (nal_t *nal, ptl_handle_md_t *md, ptl_ack_req_t ack, - ptl_process_id_t *target, ptl_pt_index_t portal, - ptl_ac_index_t ac, ptl_match_bits_t match, - ptl_size_t offset, ptl_hdr_data_t hdr_data); - int (*nal_get) (nal_t *nal, ptl_handle_md_t *md, - ptl_process_id_t *target, ptl_pt_index_t portal, - ptl_ac_index_t ac, ptl_match_bits_t match, - ptl_size_t offset); -}; - -extern nal_t *ptl_hndl2nal(ptl_handle_any_t *any); - -#ifdef __KERNEL__ -extern int ptl_register_nal(ptl_interface_t interface, nal_t *nal); -extern void ptl_unregister_nal(ptl_interface_t interface); -#endif - -#endif diff --git a/lnet/include/lnet/nalids.h b/lnet/include/lnet/nalids.h deleted file mode 100644 index 55a991b..0000000 --- a/lnet/include/lnet/nalids.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "build_check.h" - diff --git a/lnet/include/lnet/p30.h b/lnet/include/lnet/p30.h deleted file mode 100644 index 4b8631d..0000000 --- a/lnet/include/lnet/p30.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ -#ifndef _P30_H_ -#define _P30_H_ - -#include "build_check.h" - -/* - * p30.h - * - * User application interface file - */ - -#if defined (__KERNEL__) -#include -#include -#else -#include -#include -#endif - -#include -#include - -#endif diff --git a/lnet/include/lnet/ptlctl.h b/lnet/include/lnet/ptlctl.h deleted file mode 100644 index ef52a25..0000000 --- a/lnet/include/lnet/ptlctl.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * header for libptlctl.a - */ -#ifndef _PTLCTL_H_ -#define _PTLCTL_H_ - -#include -#include -#include - -#define PORTALS_DEV_ID 0 -#define PORTALS_DEV_PATH "/dev/portals" -#define OBD_DEV_ID 1 -#define OBD_DEV_PATH "/dev/obd" -#define SMFS_DEV_ID 2 -#define SMFS_DEV_PATH "/dev/snapdev" - -int ptl_name2nal(char *str); -int ptl_parse_ipaddr (__u32 *ipaddrp, char *str); -int ptl_parse_nid (ptl_nid_t *nidp, char *str); -char * ptl_nid2str (char *buffer, ptl_nid_t nid); - -int ptl_initialize(int argc, char **argv); -int jt_ptl_network(int argc, char **argv); -int jt_ptl_print_interfaces(int argc, char **argv); -int jt_ptl_add_interface(int argc, char **argv); -int jt_ptl_del_interface(int argc, char **argv); -int jt_ptl_print_peers (int argc, char **argv); -int jt_ptl_add_peer (int argc, char **argv); -int jt_ptl_del_peer (int argc, char **argv); -int jt_ptl_print_connections (int argc, char **argv); -int jt_ptl_connect(int argc, char **argv); -int jt_ptl_disconnect(int argc, char **argv); -int jt_ptl_push_connection(int argc, char **argv); -int jt_ptl_print_active_txs(int argc, char **argv); -int jt_ptl_ping(int argc, char **argv); -int jt_ptl_shownid(int argc, char **argv); -int jt_ptl_mynid(int argc, char **argv); -int jt_ptl_add_uuid(int argc, char **argv); -int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility */ -int jt_ptl_close_uuid(int argc, char **argv); -int jt_ptl_del_uuid(int argc, char **argv); -int jt_ptl_add_route (int argc, char **argv); -int jt_ptl_del_route (int argc, char **argv); -int jt_ptl_notify_router (int argc, char **argv); -int jt_ptl_print_routes (int argc, char **argv); -int jt_ptl_fail_nid (int argc, char **argv); -int jt_ptl_lwt(int argc, char **argv); -int jt_ptl_memhog(int argc, char **argv); - -int dbg_initialize(int argc, char **argv); -int jt_dbg_filter(int argc, char **argv); -int jt_dbg_show(int argc, char **argv); -int jt_dbg_list(int argc, char **argv); -int jt_dbg_debug_kernel(int argc, char **argv); -int jt_dbg_debug_daemon(int argc, char **argv); -int jt_dbg_debug_file(int argc, char **argv); -int jt_dbg_clear_debug_buf(int argc, char **argv); -int jt_dbg_mark_debug_buf(int argc, char **argv); -int jt_dbg_modules(int argc, char **argv); -int jt_dbg_panic(int argc, char **argv); - -int ptl_set_cfg_record_cb(cfg_record_cb_t cb); - -/* l_ioctl.c */ -typedef int (ioc_handler_t)(int dev_id, unsigned int opc, void *buf); -void set_ioc_handler(ioc_handler_t *handler); -int register_ioc_dev(int dev_id, const char * dev_name); -void unregister_ioc_dev(int dev_id); -int set_ioctl_dump(char * file); -int l_ioctl(int dev_id, unsigned int opc, void *buf); -int parse_dump(char * dump_file, ioc_handler_t ioc_func); -int jt_ioc_dump(int argc, char **argv); -extern char *dump_filename; -int dump(int dev_id, unsigned int opc, void *buf); - -#endif diff --git a/lnet/include/lnet/socklnd.h b/lnet/include/lnet/socklnd.h deleted file mode 100644 index 27e6f8e..0000000 --- a/lnet/include/lnet/socklnd.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * - * - * #defines shared between socknal implementation and utilities - */ - -#define SOCKNAL_CONN_NONE (-1) -#define SOCKNAL_CONN_ANY 0 -#define SOCKNAL_CONN_CONTROL 1 -#define SOCKNAL_CONN_BULK_IN 2 -#define SOCKNAL_CONN_BULK_OUT 3 -#define SOCKNAL_CONN_NTYPES 4 diff --git a/lnet/include/lnet/stringtab.h b/lnet/include/lnet/stringtab.h deleted file mode 100644 index 33e4375..0000000 --- a/lnet/include/lnet/stringtab.h +++ /dev/null @@ -1,3 +0,0 @@ -/* - * stringtab.h - */ diff --git a/lnet/include/lnet/types.h b/lnet/include/lnet/types.h deleted file mode 100644 index 0bada40..0000000 --- a/lnet/include/lnet/types.h +++ /dev/null @@ -1,193 +0,0 @@ -#ifndef _P30_TYPES_H_ -#define _P30_TYPES_H_ - -#include "build_check.h" - -#include -#include - -/* This implementation uses the same type for API function return codes and - * the completion status in an event */ -#define PTL_NI_OK PTL_OK -typedef ptl_err_t ptl_ni_fail_t; - -typedef __u32 ptl_uid_t; -typedef __u32 ptl_jid_t; -typedef __u64 ptl_nid_t; -typedef __u32 ptl_pid_t; -typedef __u32 ptl_pt_index_t; -typedef __u32 ptl_ac_index_t; -typedef __u64 ptl_match_bits_t; -typedef __u64 ptl_hdr_data_t; -typedef __u32 ptl_size_t; - -#define PTL_TIME_FOREVER (-1) - -typedef struct { - unsigned long nal_idx; /* which network interface */ - __u64 cookie; /* which thing on that interface */ -} ptl_handle_any_t; - -typedef ptl_handle_any_t ptl_handle_ni_t; -typedef ptl_handle_any_t ptl_handle_eq_t; -typedef ptl_handle_any_t ptl_handle_md_t; -typedef ptl_handle_any_t ptl_handle_me_t; - -#define PTL_INVALID_HANDLE \ - ((const ptl_handle_any_t){.nal_idx = -1, .cookie = -1}) -#define PTL_EQ_NONE PTL_INVALID_HANDLE - -static inline int PtlHandleIsEqual (ptl_handle_any_t h1, ptl_handle_any_t h2) -{ - return (h1.nal_idx == h2.nal_idx && h1.cookie == h2.cookie); -} - -#define PTL_UID_ANY ((ptl_uid_t) -1) -#define PTL_JID_ANY ((ptl_jid_t) -1) -#define PTL_NID_ANY ((ptl_nid_t) -1) -#define PTL_PID_ANY ((ptl_pid_t) -1) - -typedef struct { - ptl_nid_t nid; - ptl_pid_t pid; /* node id / process id */ -} ptl_process_id_t; - -typedef enum { - PTL_RETAIN = 0, - PTL_UNLINK -} ptl_unlink_t; - -typedef enum { - PTL_INS_BEFORE, - PTL_INS_AFTER -} ptl_ins_pos_t; - -typedef struct { - void *start; - ptl_size_t length; - int threshold; - int max_size; - unsigned int options; - void *user_ptr; - ptl_handle_eq_t eq_handle; -} ptl_md_t; - -/* Options for the MD structure */ -#define PTL_MD_OP_PUT (1 << 0) -#define PTL_MD_OP_GET (1 << 1) -#define PTL_MD_MANAGE_REMOTE (1 << 2) -/* unused (1 << 3) */ -#define PTL_MD_TRUNCATE (1 << 4) -#define PTL_MD_ACK_DISABLE (1 << 5) -#define PTL_MD_IOVEC (1 << 6) -#define PTL_MD_MAX_SIZE (1 << 7) -#define PTL_MD_KIOV (1 << 8) -#define PTL_MD_EVENT_START_DISABLE (1 << 9) -#define PTL_MD_EVENT_END_DISABLE (1 << 10) - -/* For compatibility with Cray Portals */ -#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS 0 -#define PTL_MD_PHYS 0 - -#define PTL_MD_THRESH_INF (-1) - -/* NB lustre portals uses struct iovec internally! */ -typedef struct iovec ptl_md_iovec_t; - -typedef struct { - struct page *kiov_page; - unsigned int kiov_len; - unsigned int kiov_offset; -} ptl_kiov_t; - -typedef enum { - PTL_EVENT_GET_START, - PTL_EVENT_GET_END, - - PTL_EVENT_PUT_START, - PTL_EVENT_PUT_END, - - PTL_EVENT_REPLY_START, - PTL_EVENT_REPLY_END, - - PTL_EVENT_ACK, - - PTL_EVENT_SEND_START, - PTL_EVENT_SEND_END, - - PTL_EVENT_UNLINK, -} ptl_event_kind_t; - -#define PTL_SEQ_BASETYPE long -typedef unsigned PTL_SEQ_BASETYPE ptl_seq_t; -#define PTL_SEQ_GT(a,b) (((signed PTL_SEQ_BASETYPE)((a) - (b))) > 0) - -/* XXX - * cygwin need the pragma line, not clear if it's needed in other places. - * checking!!! - */ -#ifdef __CYGWIN__ -#pragma pack(push, 4) -#endif -typedef struct { - ptl_event_kind_t type; - ptl_process_id_t initiator; - ptl_uid_t uid; - ptl_jid_t jid; - ptl_pt_index_t pt_index; - ptl_match_bits_t match_bits; - ptl_size_t rlength; - ptl_size_t mlength; - ptl_size_t offset; - ptl_handle_md_t md_handle; - ptl_md_t md; - ptl_hdr_data_t hdr_data; - ptl_seq_t link; - ptl_ni_fail_t ni_fail_type; - - int unlinked; - - volatile ptl_seq_t sequence; -} ptl_event_t; -#ifdef __CYGWIN__ -#pragma pop -#endif - -typedef enum { - PTL_ACK_REQ, - PTL_NOACK_REQ -} ptl_ack_req_t; - -typedef void (*ptl_eq_handler_t)(ptl_event_t *event); -#define PTL_EQ_HANDLER_NONE NULL - -typedef struct { - int max_mes; - int max_mds; - int max_eqs; - int max_ac_index; - int max_pt_index; - int max_md_iovecs; - int max_me_list; - int max_getput_md; -} ptl_ni_limits_t; - -/* - * Status registers - */ -typedef enum { - PTL_SR_DROP_COUNT, - PTL_SR_DROP_LENGTH, - PTL_SR_RECV_COUNT, - PTL_SR_RECV_LENGTH, - PTL_SR_SEND_COUNT, - PTL_SR_SEND_LENGTH, - PTL_SR_MSGS_MAX, -} ptl_sr_index_t; - -typedef int ptl_sr_value_t; - -typedef int ptl_interface_t; -#define PTL_IFACE_DEFAULT (-1) - -#endif diff --git a/lnet/klnds/.cvsignore b/lnet/klnds/.cvsignore deleted file mode 100644 index f5fd0b0..0000000 --- a/lnet/klnds/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -Makefile -autoMakefile -autoMakefile.in -.*.cmd -.depend diff --git a/lnet/klnds/Makefile.in b/lnet/klnds/Makefile.in deleted file mode 100644 index 7e2e601..0000000 --- a/lnet/klnds/Makefile.in +++ /dev/null @@ -1,9 +0,0 @@ -@BUILD_GMNAL_TRUE@subdir-m += gmnal -@BUILD_RANAL_TRUE@subdir-m += ranal -@BUILD_OPENIBNAL_TRUE@subdir-m += openibnal -@BUILD_IIBNAL_TRUE@subdir-m += iibnal -@BUILD_QSWNAL_TRUE@subdir-m += qswnal -subdir-m += socknal -subdir-m += lonal - -@INCLUDE_RULES@ diff --git a/lnet/klnds/Makefile.mk b/lnet/klnds/Makefile.mk deleted file mode 100644 index 454ee16..0000000 --- a/lnet/klnds/Makefile.mk +++ /dev/null @@ -1,5 +0,0 @@ -include $(obj)/../Kernelenv - -obj-y = socknal/ -obj-y = lonal/ -# more coming... diff --git a/lnet/klnds/autoMakefile.am b/lnet/klnds/autoMakefile.am deleted file mode 100644 index 4638188..0000000 --- a/lnet/klnds/autoMakefile.am +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -SUBDIRS = gmnal iibnal openibnal qswnal socknal lonal ranal diff --git a/lnet/klnds/gmlnd/.cvsignore b/lnet/klnds/gmlnd/.cvsignore deleted file mode 100644 index 642e2e6..0000000 --- a/lnet/klnds/gmlnd/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.cmd -.*.flags -.tmp_versions -.depend diff --git a/lnet/klnds/gmlnd/Makefile.in b/lnet/klnds/gmlnd/Makefile.in deleted file mode 100644 index 89ea361..0000000 --- a/lnet/klnds/gmlnd/Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -MODULES := kgmnal -kgmnal-objs := gmnal_api.o gmnal_cb.o gmnal_comm.o gmnal_utils.o gmnal_module.o - -EXTRA_PRE_CFLAGS := @GMCPPFLAGS@ - -@INCLUDE_RULES@ diff --git a/lnet/klnds/gmlnd/Makefile.mk b/lnet/klnds/gmlnd/Makefile.mk deleted file mode 100644 index b799a47..0000000 --- a/lnet/klnds/gmlnd/Makefile.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include ../../Kernelenv - -obj-y += gmnal.o -gmnal-objs := gmnal_api.o gmnal_cb.o gmnal_utils.o gmnal_comm.o gmnal_module.o - diff --git a/lnet/klnds/gmlnd/autoMakefile.am b/lnet/klnds/gmlnd/autoMakefile.am deleted file mode 100644 index d8b9edb..0000000 --- a/lnet/klnds/gmlnd/autoMakefile.am +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if BUILD_GMNAL -if !CRAY_PORTALS -modulenet_DATA = kgmnal$(KMODEXT) -endif -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(kgmnal-objs:%.o=%.c) gmnal.h diff --git a/lnet/klnds/gmlnd/gmlnd.h b/lnet/klnds/gmlnd/gmlnd.h deleted file mode 100644 index f45eab7..0000000 --- a/lnet/klnds/gmlnd/gmlnd.h +++ /dev/null @@ -1,455 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2003 Los Alamos National Laboratory (LANL) - * - * 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. - */ - - -/* - * Portals GM kernel NAL header file - * This file makes all declaration and prototypes - * for the API side and CB side of the NAL - */ -#ifndef __INCLUDE_GMNAL_H__ -#define __INCLUDE_GMNAL_H__ - -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include "linux/config.h" -#include "linux/module.h" -#include "linux/tty.h" -#include "linux/kernel.h" -#include "linux/mm.h" -#include "linux/string.h" -#include "linux/stat.h" -#include "linux/errno.h" -#include "linux/locks.h" -#include "linux/unistd.h" -#include "linux/init.h" -#include "linux/sem.h" -#include "linux/vmalloc.h" -#include "linux/sysctl.h" - -#define DEBUG_SUBSYSTEM S_NAL - -#include "portals/nal.h" -#include "portals/api.h" -#include "portals/errno.h" -#include "linux/kp30.h" -#include "portals/p30.h" - -#include "portals/nal.h" -#include "portals/lib-p30.h" - -#define GM_STRONG_TYPES 1 -#ifdef VERSION -#undef VERSION -#endif -#include "gm.h" -#include "gm_internal.h" - - - -/* - * Defines for the API NAL - */ - -/* - * Small message size is configurable - * insmod can set small_msg_size - * which is used to populate nal_data.small_msg_size - */ -#define GMNAL_SMALL_MESSAGE 1078 -#define GMNAL_LARGE_MESSAGE_INIT 1079 -#define GMNAL_LARGE_MESSAGE_ACK 1080 -#define GMNAL_LARGE_MESSAGE_FINI 1081 - -extern int gmnal_small_msg_size; -extern int num_rx_threads; -extern int num_stxds; -extern int gm_port; -#define GMNAL_SMALL_MSG_SIZE(a) a->small_msg_size -#define GMNAL_IS_SMALL_MESSAGE(n,a,b,c) gmnal_is_small_msg(n, a, b, c) -#define GMNAL_MAGIC 0x1234abcd -/* - * The gm_port to use for gmnal - */ -#define GMNAL_GM_PORT gm_port - - -/* - * Small Transmit Descriptor - * A structre to keep track of a small transmit operation - * This structure has a one-to-one relationship with a small - * transmit buffer (both create by gmnal_stxd_alloc). - * There are two free list of stxd. One for use by clients of the NAL - * and the other by the NAL rxthreads when doing sends. - * This helps prevent deadlock caused by stxd starvation. - */ -typedef struct _gmnal_stxd_t { - void *buffer; - int buffer_size; - gm_size_t gm_size; - int msg_size; - int gm_target_node; - int gm_priority; - int type; - struct _gmnal_data_t *nal_data; - lib_msg_t *cookie; - int niov; - struct iovec iov[PTL_MD_MAX_IOV]; - struct _gmnal_stxd_t *next; - int rxt; - int kniov; - struct iovec *iovec_dup; -} gmnal_stxd_t; - -/* - * keeps a transmit token for large transmit (gm_get) - * and a pointer to rxd that is used as context for large receive - */ -typedef struct _gmnal_ltxd_t { - struct _gmnal_ltxd_t *next; - struct _gmnal_srxd_t *srxd; -} gmnal_ltxd_t; - - -/* - * as for gmnal_stxd_t - * a hash table in nal_data find srxds from - * the rx buffer address. hash table populated at init time - */ -typedef struct _gmnal_srxd_t { - void *buffer; - int size; - gm_size_t gmsize; - unsigned int gm_source_node; - gmnal_stxd_t *source_stxd; - int type; - int nsiov; - int nriov; - struct iovec *riov; - int ncallbacks; - spinlock_t callback_lock; - int callback_status; - lib_msg_t *cookie; - struct _gmnal_srxd_t *next; - struct _gmnal_data_t *nal_data; -} gmnal_srxd_t; - -/* - * Header which lmgnal puts at the start of each message - */ -typedef struct _gmnal_msghdr { - int magic; - int type; - unsigned int sender_node_id; - gmnal_stxd_t *stxd; - int niov; - } gmnal_msghdr_t; -#define GMNAL_MSGHDR_SIZE sizeof(gmnal_msghdr_t) - -/* - * the caretaker thread (ct_thread) gets receive events - * (and other events) from the myrinet device via the GM2 API. - * caretaker thread populates one work entry for each receive event, - * puts it on a Q in nal_data and wakes a receive thread to - * process the receive. - * Processing a portals receive can involve a transmit operation. - * Because of this the caretaker thread cannot process receives - * as it may get deadlocked when supply of transmit descriptors - * is exhausted (as caretaker thread is responsible for replacing - * transmit descriptors on the free list) - */ -typedef struct _gmnal_rxtwe { - void *buffer; - unsigned snode; - unsigned sport; - unsigned type; - unsigned length; - struct _gmnal_rxtwe *next; -} gmnal_rxtwe_t; - -/* - * 1 receive thread started on each CPU - */ -#define NRXTHREADS 10 /* max number of receiver threads */ - -typedef struct _gmnal_data_t { - spinlock_t stxd_lock; - struct semaphore stxd_token; - gmnal_stxd_t *stxd; - spinlock_t rxt_stxd_lock; - struct semaphore rxt_stxd_token; - gmnal_stxd_t *rxt_stxd; - spinlock_t ltxd_lock; - struct semaphore ltxd_token; - gmnal_ltxd_t *ltxd; - spinlock_t srxd_lock; - struct semaphore srxd_token; - gmnal_srxd_t *srxd; - struct gm_hash *srxd_hash; - nal_t *nal; - lib_nal_t *libnal; - struct gm_port *gm_port; - unsigned int gm_local_nid; - unsigned int gm_global_nid; - spinlock_t gm_lock; - long rxthread_pid[NRXTHREADS]; - int rxthread_stop_flag; - spinlock_t rxthread_flag_lock; - long rxthread_flag; - long ctthread_pid; - int ctthread_flag; - gm_alarm_t ctthread_alarm; - int small_msg_size; - int small_msg_gmsize; - gmnal_rxtwe_t *rxtwe_head; - gmnal_rxtwe_t *rxtwe_tail; - spinlock_t rxtwe_lock; - struct semaphore rxtwe_wait; - struct ctl_table_header *sysctl; -} gmnal_data_t; - -/* - * Flags to start/stop and check status of threads - * each rxthread sets 1 bit (any bit) of the flag on startup - * and clears 1 bit when exiting - */ -#define GMNAL_THREAD_RESET 0 -#define GMNAL_THREAD_STOP 666 -#define GMNAL_CTTHREAD_STARTED 333 -#define GMNAL_RXTHREADS_STARTED ( (1<stxd_lock); -#define GMNAL_TXD_LOCK(a) spin_lock(&a->stxd_lock); -#define GMNAL_TXD_UNLOCK(a) spin_unlock(&a->stxd_lock); -#define GMNAL_TXD_TOKEN_INIT(a, n) sema_init(&a->stxd_token, n); -#define GMNAL_TXD_GETTOKEN(a) down(&a->stxd_token); -#define GMNAL_TXD_TRYGETTOKEN(a) down_trylock(&a->stxd_token) -#define GMNAL_TXD_RETURNTOKEN(a) up(&a->stxd_token); - -#define GMNAL_RXT_TXD_LOCK_INIT(a) spin_lock_init(&a->rxt_stxd_lock); -#define GMNAL_RXT_TXD_LOCK(a) spin_lock(&a->rxt_stxd_lock); -#define GMNAL_RXT_TXD_UNLOCK(a) spin_unlock(&a->rxt_stxd_lock); -#define GMNAL_RXT_TXD_TOKEN_INIT(a, n) sema_init(&a->rxt_stxd_token, n); -#define GMNAL_RXT_TXD_GETTOKEN(a) down(&a->rxt_stxd_token); -#define GMNAL_RXT_TXD_TRYGETTOKEN(a) down_trylock(&a->rxt_stxd_token) -#define GMNAL_RXT_TXD_RETURNTOKEN(a) up(&a->rxt_stxd_token); - -#define GMNAL_LTXD_LOCK_INIT(a) spin_lock_init(&a->ltxd_lock); -#define GMNAL_LTXD_LOCK(a) spin_lock(&a->ltxd_lock); -#define GMNAL_LTXD_UNLOCK(a) spin_unlock(&a->ltxd_lock); -#define GMNAL_LTXD_TOKEN_INIT(a, n) sema_init(&a->ltxd_token, n); -#define GMNAL_LTXD_GETTOKEN(a) down(&a->ltxd_token); -#define GMNAL_LTXD_TRYGETTOKEN(a) down_trylock(&a->ltxd_token) -#define GMNAL_LTXD_RETURNTOKEN(a) up(&a->ltxd_token); - -#define GMNAL_RXD_LOCK_INIT(a) spin_lock_init(&a->srxd_lock); -#define GMNAL_RXD_LOCK(a) spin_lock(&a->srxd_lock); -#define GMNAL_RXD_UNLOCK(a) spin_unlock(&a->srxd_lock); -#define GMNAL_RXD_TOKEN_INIT(a, n) sema_init(&a->srxd_token, n); -#define GMNAL_RXD_GETTOKEN(a) down(&a->srxd_token); -#define GMNAL_RXD_TRYGETTOKEN(a) down_trylock(&a->srxd_token) -#define GMNAL_RXD_RETURNTOKEN(a) up(&a->srxd_token); - -#define GMNAL_GM_LOCK_INIT(a) spin_lock_init(&a->gm_lock); -#define GMNAL_GM_LOCK(a) spin_lock(&a->gm_lock); -#define GMNAL_GM_UNLOCK(a) spin_unlock(&a->gm_lock); - - -/* - * Memory Allocator - */ - -/* - * API NAL - */ -int gmnal_api_startup(nal_t *, ptl_pid_t, - ptl_ni_limits_t *, ptl_ni_limits_t *); - -int gmnal_api_forward(nal_t *, int, void *, size_t, void *, size_t); - -void gmnal_api_shutdown(nal_t *); - -int gmnal_api_validate(nal_t *, void *, size_t); - -void gmnal_api_yield(nal_t *, unsigned long *, int); - -void gmnal_api_lock(nal_t *, unsigned long *); - -void gmnal_api_unlock(nal_t *, unsigned long *); - - -#define GMNAL_INIT_NAL(a) do { \ - (a)->nal_ni_init = gmnal_api_startup; \ - (a)->nal_ni_fini = gmnal_api_shutdown; \ - (a)->nal_data = NULL; \ - } while (0) - - -/* - * CB NAL - */ - -ptl_err_t gmnal_cb_send(lib_nal_t *, void *, lib_msg_t *, ptl_hdr_t *, - int, ptl_nid_t, ptl_pid_t, unsigned int, struct iovec *, size_t, size_t); - -ptl_err_t gmnal_cb_send_pages(lib_nal_t *, void *, lib_msg_t *, ptl_hdr_t *, - int, ptl_nid_t, ptl_pid_t, unsigned int, ptl_kiov_t *, size_t, size_t); - -ptl_err_t gmnal_cb_recv(lib_nal_t *, void *, lib_msg_t *, - unsigned int, struct iovec *, size_t, size_t, size_t); - -ptl_err_t gmnal_cb_recv_pages(lib_nal_t *, void *, lib_msg_t *, - unsigned int, ptl_kiov_t *, size_t, size_t, size_t); - -int gmnal_cb_dist(lib_nal_t *, ptl_nid_t, unsigned long *); - -int gmnal_init(void); - -void gmnal_fini(void); - - - -#define GMNAL_INIT_NAL_CB(a) do { \ - a->libnal_send = gmnal_cb_send; \ - a->libnal_send_pages = gmnal_cb_send_pages; \ - a->libnal_recv = gmnal_cb_recv; \ - a->libnal_recv_pages = gmnal_cb_recv_pages; \ - a->libnal_map = NULL; \ - a->libnal_unmap = NULL; \ - a->libnal_dist = gmnal_cb_dist; \ - a->libnal_data = NULL; \ - } while (0) - - -/* - * Small and Large Transmit and Receive Descriptor Functions - */ -int gmnal_alloc_txd(gmnal_data_t *); -void gmnal_free_txd(gmnal_data_t *); -gmnal_stxd_t* gmnal_get_stxd(gmnal_data_t *, int); -void gmnal_return_stxd(gmnal_data_t *, gmnal_stxd_t *); -gmnal_ltxd_t* gmnal_get_ltxd(gmnal_data_t *); -void gmnal_return_ltxd(gmnal_data_t *, gmnal_ltxd_t *); - -int gmnal_alloc_srxd(gmnal_data_t *); -void gmnal_free_srxd(gmnal_data_t *); -gmnal_srxd_t* gmnal_get_srxd(gmnal_data_t *, int); -void gmnal_return_srxd(gmnal_data_t *, gmnal_srxd_t *); - -/* - * general utility functions - */ -gmnal_srxd_t *gmnal_rxbuffer_to_srxd(gmnal_data_t *, void*); -void gmnal_stop_rxthread(gmnal_data_t *); -void gmnal_stop_ctthread(gmnal_data_t *); -void gmnal_small_tx_callback(gm_port_t *, void *, gm_status_t); -void gmnal_drop_sends_callback(gm_port_t *, void *, gm_status_t); -void gmnal_resume_sending_callback(gm_port_t *, void *, gm_status_t); -char *gmnal_gm_error(gm_status_t); -char *gmnal_rxevent(gm_recv_event_t*); -int gmnal_is_small_msg(gmnal_data_t*, int, struct iovec*, int); -void gmnal_yield(int); -int gmnal_start_kernel_threads(gmnal_data_t *); - - -/* - * Communication functions - */ - -/* - * Receive threads - */ -int gmnal_ct_thread(void *); /* caretaker thread */ -int gmnal_rx_thread(void *); /* receive thread */ -int gmnal_pre_receive(gmnal_data_t*, gmnal_rxtwe_t*, int); -int gmnal_rx_bad(gmnal_data_t *, gmnal_rxtwe_t *, gmnal_srxd_t*); -int gmnal_rx_requeue_buffer(gmnal_data_t *, gmnal_srxd_t *); -int gmnal_add_rxtwe(gmnal_data_t *, gm_recv_t *); -gmnal_rxtwe_t * gmnal_get_rxtwe(gmnal_data_t *); -void gmnal_remove_rxtwe(gmnal_data_t *); - - -/* - * Small messages - */ -int gmnal_small_rx(lib_nal_t *, void *, lib_msg_t *, unsigned int, - struct iovec *, size_t, size_t, size_t); -int gmnal_small_tx(lib_nal_t *, void *, lib_msg_t *, ptl_hdr_t *, - int, ptl_nid_t, ptl_pid_t, - unsigned int, struct iovec*, size_t, int); -void gmnal_small_tx_callback(gm_port_t *, void *, gm_status_t); - - - -/* - * Large messages - */ -int gmnal_large_rx(lib_nal_t *, void *, lib_msg_t *, unsigned int, - struct iovec *, size_t, size_t, size_t); - -int gmnal_large_tx(lib_nal_t *, void *, lib_msg_t *, ptl_hdr_t *, - int, ptl_nid_t, ptl_pid_t, unsigned int, - struct iovec*, size_t, int); - -void gmnal_large_tx_callback(gm_port_t *, void *, gm_status_t); - -int gmnal_remote_get(gmnal_srxd_t *, int, struct iovec*, int, - struct iovec*); - -void gmnal_remote_get_callback(gm_port_t *, void *, gm_status_t); - -int gmnal_copyiov(int, gmnal_srxd_t *, int, struct iovec*, int, - struct iovec*); - -void gmnal_large_tx_ack(gmnal_data_t *, gmnal_srxd_t *); -void gmnal_large_tx_ack_callback(gm_port_t *, void *, gm_status_t); -void gmnal_large_tx_ack_received(gmnal_data_t *, gmnal_srxd_t *); - -#endif /*__INCLUDE_GMNAL_H__*/ diff --git a/lnet/klnds/gmlnd/gmlnd_api.c b/lnet/klnds/gmlnd/gmlnd_api.c deleted file mode 100644 index bd6c83e..0000000 --- a/lnet/klnds/gmlnd/gmlnd_api.c +++ /dev/null @@ -1,424 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2003 Los Alamos National Laboratory (LANL) - * - * 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. - */ - -/* - * Implements the API NAL functions - */ - -#include "gmnal.h" - - - -gmnal_data_t *global_nal_data = NULL; -#define GLOBAL_NID_STR_LEN 16 -char global_nid_str[GLOBAL_NID_STR_LEN] = {0}; -ptl_handle_ni_t kgmnal_ni; - -extern int gmnal_cmd(struct portals_cfg *pcfg, void *private); - -/* - * Write the global nid /proc/sys/gmnal/globalnid - */ -#define GMNAL_SYSCTL 201 -#define GMNAL_SYSCTL_GLOBALNID 1 - -static ctl_table gmnal_sysctl_table[] = { - {GMNAL_SYSCTL_GLOBALNID, "globalnid", - global_nid_str, GLOBAL_NID_STR_LEN, - 0444, NULL, &proc_dostring}, - { 0 } -}; - - -static ctl_table gmnalnal_top_sysctl_table[] = { - {GMNAL_SYSCTL, "gmnal", NULL, 0, 0555, gmnal_sysctl_table}, - { 0 } -}; - -/* - * gmnal_api_shutdown - * nal_refct == 0 => called on last matching PtlNIFini() - * Close down this interface and free any resources associated with it - * nal_t nal our nal to shutdown - */ -void -gmnal_api_shutdown(nal_t *nal) -{ - gmnal_data_t *nal_data; - lib_nal_t *libnal; - - if (nal->nal_refct != 0) - return; - - - LASSERT(nal == global_nal_data->nal); - libnal = (lib_nal_t *)nal->nal_data; - nal_data = (gmnal_data_t *)libnal->libnal_data; - LASSERT(nal_data == global_nal_data); - CDEBUG(D_TRACE, "gmnal_api_shutdown: nal_data [%p]\n", nal_data); - - /* Stop portals calling our ioctl handler */ - libcfs_nal_cmd_unregister(GMNAL); - - /* XXX for shutdown "under fire" we probably need to set a shutdown - * flag so when lib calls us we fail immediately and dont queue any - * more work but our threads can still call into lib OK. THEN - * shutdown our threads, THEN lib_fini() */ - lib_fini(libnal); - - gmnal_stop_rxthread(nal_data); - gmnal_stop_ctthread(nal_data); - gmnal_free_txd(nal_data); - gmnal_free_srxd(nal_data); - GMNAL_GM_LOCK(nal_data); - gm_close(nal_data->gm_port); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - if (nal_data->sysctl) - unregister_sysctl_table (nal_data->sysctl); - /* Don't free 'nal'; it's a static struct */ - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - - global_nal_data = NULL; - PORTAL_MODULE_UNUSE; -} - - -int -gmnal_api_startup(nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - - lib_nal_t *libnal = NULL; - gmnal_data_t *nal_data = NULL; - gmnal_srxd_t *srxd = NULL; - gm_status_t gm_status; - unsigned int local_nid = 0, global_nid = 0; - ptl_process_id_t process_id; - - if (nal->nal_refct != 0) { - if (actual_limits != NULL) { - libnal = (lib_nal_t *)nal->nal_data; - *actual_limits = libnal->libnal_ni.ni_actual_limits; - } - return (PTL_OK); - } - - /* Called on first PtlNIInit() */ - - CDEBUG(D_TRACE, "startup\n"); - - LASSERT(global_nal_data == NULL); - - PORTAL_ALLOC(nal_data, sizeof(gmnal_data_t)); - if (!nal_data) { - CDEBUG(D_ERROR, "can't get memory\n"); - return(PTL_NO_SPACE); - } - memset(nal_data, 0, sizeof(gmnal_data_t)); - /* - * set the small message buffer size - */ - - CDEBUG(D_INFO, "Allocd and reset nal_data[%p]\n", nal_data); - CDEBUG(D_INFO, "small_msg_size is [%d]\n", nal_data->small_msg_size); - - PORTAL_ALLOC(libnal, sizeof(lib_nal_t)); - if (!libnal) { - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - return(PTL_NO_SPACE); - } - memset(libnal, 0, sizeof(lib_nal_t)); - CDEBUG(D_INFO, "Allocd and reset libnal[%p]\n", libnal); - - GMNAL_INIT_NAL_CB(libnal); - /* - * String them all together - */ - libnal->libnal_data = (void*)nal_data; - nal_data->nal = nal; - nal_data->libnal = libnal; - - GMNAL_GM_LOCK_INIT(nal_data); - - - /* - * initialise the interface, - */ - CDEBUG(D_INFO, "Calling gm_init\n"); - if (gm_init() != GM_SUCCESS) { - CDEBUG(D_ERROR, "call to gm_init failed\n"); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - } - - - CDEBUG(D_NET, "Calling gm_open with port [%d], " - "name [%s], version [%d]\n", GMNAL_GM_PORT, - "gmnal", GM_API_VERSION); - - GMNAL_GM_LOCK(nal_data); - gm_status = gm_open(&nal_data->gm_port, 0, GMNAL_GM_PORT, "gmnal", - GM_API_VERSION); - GMNAL_GM_UNLOCK(nal_data); - - CDEBUG(D_INFO, "gm_open returned [%d]\n", gm_status); - if (gm_status == GM_SUCCESS) { - CDEBUG(D_INFO, "gm_open succeeded port[%p]\n", - nal_data->gm_port); - } else { - switch(gm_status) { - case(GM_INVALID_PARAMETER): - CDEBUG(D_ERROR, "gm_open Failure. Invalid Parameter\n"); - break; - case(GM_BUSY): - CDEBUG(D_ERROR, "gm_open Failure. GM Busy\n"); - break; - case(GM_NO_SUCH_DEVICE): - CDEBUG(D_ERROR, "gm_open Failure. No such device\n"); - break; - case(GM_INCOMPATIBLE_LIB_AND_DRIVER): - CDEBUG(D_ERROR, "gm_open Failure. Incompatile lib " - "and driver\n"); - break; - case(GM_OUT_OF_MEMORY): - CDEBUG(D_ERROR, "gm_open Failure. Out of Memory\n"); - break; - default: - CDEBUG(D_ERROR, "gm_open Failure. Unknow error " - "code [%d]\n", gm_status); - break; - } - GMNAL_GM_LOCK(nal_data); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - } - - - nal_data->small_msg_size = gmnal_small_msg_size; - nal_data->small_msg_gmsize = - gm_min_size_for_length(gmnal_small_msg_size); - - if (gmnal_alloc_srxd(nal_data) != GMNAL_STATUS_OK) { - CDEBUG(D_ERROR, "Failed to allocate small rx descriptors\n"); - gmnal_free_txd(nal_data); - GMNAL_GM_LOCK(nal_data); - gm_close(nal_data->gm_port); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - } - - - /* - * Hang out a bunch of small receive buffers - * In fact hang them all out - */ - while((srxd = gmnal_get_srxd(nal_data, 0))) { - CDEBUG(D_NET, "giving [%p] to gm_provide_recvive_buffer\n", - srxd->buffer); - GMNAL_GM_LOCK(nal_data); - gm_provide_receive_buffer_with_tag(nal_data->gm_port, - srxd->buffer, srxd->gmsize, - GM_LOW_PRIORITY, 0); - GMNAL_GM_UNLOCK(nal_data); - } - - /* - * Allocate pools of small tx buffers and descriptors - */ - if (gmnal_alloc_txd(nal_data) != GMNAL_STATUS_OK) { - CDEBUG(D_ERROR, "Failed to allocate small tx descriptors\n"); - GMNAL_GM_LOCK(nal_data); - gm_close(nal_data->gm_port); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - } - - gmnal_start_kernel_threads(nal_data); - - while (nal_data->rxthread_flag != GMNAL_RXTHREADS_STARTED) { - gmnal_yield(1); - CDEBUG(D_INFO, "Waiting for receive thread signs of life\n"); - } - - CDEBUG(D_INFO, "receive thread seems to have started\n"); - - - /* - * Initialise the portals library - */ - CDEBUG(D_NET, "Getting node id\n"); - GMNAL_GM_LOCK(nal_data); - gm_status = gm_get_node_id(nal_data->gm_port, &local_nid); - GMNAL_GM_UNLOCK(nal_data); - if (gm_status != GM_SUCCESS) { - gmnal_stop_rxthread(nal_data); - gmnal_stop_ctthread(nal_data); - CDEBUG(D_ERROR, "can't determine node id\n"); - gmnal_free_txd(nal_data); - gmnal_free_srxd(nal_data); - GMNAL_GM_LOCK(nal_data); - gm_close(nal_data->gm_port); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - } - - nal_data->gm_local_nid = local_nid; - CDEBUG(D_INFO, "Local node id is [%u]\n", local_nid); - - GMNAL_GM_LOCK(nal_data); - gm_status = gm_node_id_to_global_id(nal_data->gm_port, local_nid, - &global_nid); - GMNAL_GM_UNLOCK(nal_data); - if (gm_status != GM_SUCCESS) { - CDEBUG(D_ERROR, "failed to obtain global id\n"); - gmnal_stop_rxthread(nal_data); - gmnal_stop_ctthread(nal_data); - gmnal_free_txd(nal_data); - gmnal_free_srxd(nal_data); - GMNAL_GM_LOCK(nal_data); - gm_close(nal_data->gm_port); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - } - CDEBUG(D_INFO, "Global node id is [%u]\n", global_nid); - nal_data->gm_global_nid = global_nid; - snprintf(global_nid_str, GLOBAL_NID_STR_LEN, "%u", global_nid); - -/* - pid = gm_getpid(); -*/ - process_id.pid = requested_pid; - process_id.nid = global_nid; - - CDEBUG(D_INFO, "portals_pid is [%u]\n", process_id.pid); - CDEBUG(D_INFO, "portals_nid is ["LPU64"]\n", process_id.nid); - - CDEBUG(D_PORTALS, "calling lib_init\n"); - if (lib_init(libnal, nal, process_id, - requested_limits, actual_limits) != PTL_OK) { - CDEBUG(D_ERROR, "lib_init failed\n"); - gmnal_stop_rxthread(nal_data); - gmnal_stop_ctthread(nal_data); - gmnal_free_txd(nal_data); - gmnal_free_srxd(nal_data); - GMNAL_GM_LOCK(nal_data); - gm_close(nal_data->gm_port); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - - } - - if (libcfs_nal_cmd_register(GMNAL, &gmnal_cmd, libnal->libnal_data) != 0) { - CDEBUG(D_INFO, "libcfs_nal_cmd_register failed\n"); - - /* XXX these cleanup cases should be restructured to - * minimise duplication... */ - lib_fini(libnal); - - gmnal_stop_rxthread(nal_data); - gmnal_stop_ctthread(nal_data); - gmnal_free_txd(nal_data); - gmnal_free_srxd(nal_data); - GMNAL_GM_LOCK(nal_data); - gm_close(nal_data->gm_port); - gm_finalize(); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(nal_data, sizeof(gmnal_data_t)); - PORTAL_FREE(libnal, sizeof(lib_nal_t)); - return(PTL_FAIL); - } - - /* might be better to initialise this at module load rather than in - * NAL startup */ - nal_data->sysctl = NULL; - nal_data->sysctl = register_sysctl_table (gmnalnal_top_sysctl_table, 0); - - - CDEBUG(D_INFO, "gmnal_init finished\n"); - global_nal_data = nal->nal_data; - - /* no unload now until shutdown */ - PORTAL_MODULE_USE; - - return(PTL_OK); -} - -nal_t the_gm_nal; - -/* - * Called when module loaded - */ -int gmnal_init(void) -{ - int rc; - - memset(&the_gm_nal, 0, sizeof(nal_t)); - CDEBUG(D_INFO, "reset nal[%p]\n", &the_gm_nal); - GMNAL_INIT_NAL(&the_gm_nal); - - rc = ptl_register_nal(GMNAL, &the_gm_nal); - if (rc != PTL_OK) - CERROR("Can't register GMNAL: %d\n", rc); - rc = PtlNIInit(GMNAL, LUSTRE_SRV_PTL_PID, NULL, NULL, &kgmnal_ni); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) { - ptl_unregister_nal(GMNAL); - return (-ENODEV); - } - - return (rc); -} - - - -/* - * Called when module removed - */ -void gmnal_fini() -{ - CDEBUG(D_TRACE, "gmnal_fini\n"); - - LASSERT(global_nal_data == NULL); - PtlNIFini(kgmnal_ni); - - ptl_unregister_nal(GMNAL); -} diff --git a/lnet/klnds/gmlnd/gmlnd_cb.c b/lnet/klnds/gmlnd/gmlnd_cb.c deleted file mode 100644 index 0ebf437..0000000 --- a/lnet/klnds/gmlnd/gmlnd_cb.c +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2003 Los Alamos National Laboratory (LANL) - * - * 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. - */ - - -/* - * This file implements the nal cb functions - */ - - -#include "gmnal.h" - -ptl_err_t gmnal_cb_recv(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - unsigned int niov, struct iovec *iov, size_t offset, - size_t mlen, size_t rlen) -{ - gmnal_srxd_t *srxd = (gmnal_srxd_t*)private; - int status = PTL_OK; - - - CDEBUG(D_TRACE, "gmnal_cb_recv libnal [%p], private[%p], cookie[%p], " - "niov[%d], iov [%p], offset["LPSZ"], mlen["LPSZ"], rlen["LPSZ"]\n", - libnal, private, cookie, niov, iov, offset, mlen, rlen); - - switch(srxd->type) { - case(GMNAL_SMALL_MESSAGE): - CDEBUG(D_INFO, "gmnal_cb_recv got small message\n"); - status = gmnal_small_rx(libnal, private, cookie, niov, - iov, offset, mlen, rlen); - break; - case(GMNAL_LARGE_MESSAGE_INIT): - CDEBUG(D_INFO, "gmnal_cb_recv got large message init\n"); - status = gmnal_large_rx(libnal, private, cookie, niov, - iov, offset, mlen, rlen); - } - - - CDEBUG(D_INFO, "gmnal_cb_recv gmnal_return status [%d]\n", status); - return(status); -} - -ptl_err_t gmnal_cb_recv_pages(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - unsigned int kniov, ptl_kiov_t *kiov, size_t offset, - size_t mlen, size_t rlen) -{ - gmnal_srxd_t *srxd = (gmnal_srxd_t*)private; - int status = PTL_OK; - struct iovec *iovec = NULL, *iovec_dup = NULL; - int i = 0; - ptl_kiov_t *kiov_dup = kiov;; - - - CDEBUG(D_TRACE, "gmnal_cb_recv_pages libnal [%p],private[%p], " - "cookie[%p], kniov[%d], kiov [%p], offset["LPSZ"], mlen["LPSZ"], rlen["LPSZ"]\n", - libnal, private, cookie, kniov, kiov, offset, mlen, rlen); - - if (srxd->type == GMNAL_SMALL_MESSAGE) { - PORTAL_ALLOC(iovec, sizeof(struct iovec)*kniov); - if (!iovec) { - CDEBUG(D_ERROR, "Can't malloc\n"); - return(GMNAL_STATUS_FAIL); - } - iovec_dup = iovec; - - /* - * map each page and create an iovec for it - */ - for (i=0; ikiov_page, kiov->kiov_len, - kiov->kiov_offset); - iovec->iov_len = kiov->kiov_len; - CDEBUG(D_INFO, "Calling kmap[%p]", kiov->kiov_page); - - iovec->iov_base = kmap(kiov->kiov_page) + - kiov->kiov_offset; - - CDEBUG(D_INFO, "iov_base is [%p]\n", iovec->iov_base); - iovec++; - kiov++; - } - CDEBUG(D_INFO, "calling gmnal_small_rx\n"); - status = gmnal_small_rx(libnal, private, cookie, kniov, - iovec_dup, offset, mlen, rlen); - for (i=0; ikiov_page); - kiov_dup++; - } - PORTAL_FREE(iovec_dup, sizeof(struct iovec)*kniov); - } - - - CDEBUG(D_INFO, "gmnal_return status [%d]\n", status); - return(status); -} - - -ptl_err_t gmnal_cb_send(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int niov, struct iovec *iov, size_t offset, size_t len) -{ - - gmnal_data_t *nal_data; - - - CDEBUG(D_TRACE, "gmnal_cb_send niov[%d] offset["LPSZ"] len["LPSZ"] nid["LPU64"]\n", - niov, offset, len, nid); - nal_data = libnal->libnal_data; - - if (GMNAL_IS_SMALL_MESSAGE(nal_data, niov, iov, len)) { - CDEBUG(D_INFO, "This is a small message send\n"); - gmnal_small_tx(libnal, private, cookie, hdr, type, nid, pid, - niov, iov, offset, len); - } else { - CDEBUG(D_ERROR, "Large message send it is not supported\n"); - lib_finalize(libnal, private, cookie, PTL_FAIL); - return(PTL_FAIL); - gmnal_large_tx(libnal, private, cookie, hdr, type, nid, pid, - niov, iov, offset, len); - } - return(PTL_OK); -} - -ptl_err_t gmnal_cb_send_pages(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int kniov, ptl_kiov_t *kiov, size_t offset, size_t len) -{ - - int i = 0; - gmnal_data_t *nal_data; - struct iovec *iovec = NULL, *iovec_dup = NULL; - ptl_kiov_t *kiov_dup = kiov; - - CDEBUG(D_TRACE, "gmnal_cb_send_pages nid ["LPU64"] niov[%d] offset["LPSZ"] len["LPSZ"]\n", - nid, kniov, offset, len); - nal_data = libnal->libnal_data; - PORTAL_ALLOC(iovec, kniov*sizeof(struct iovec)); - iovec_dup = iovec; - if (GMNAL_IS_SMALL_MESSAGE(nal_data, 0, NULL, len)) { - CDEBUG(D_INFO, "This is a small message send\n"); - - for (i=0; ikiov_page, kiov->kiov_len, - kiov->kiov_offset); - - iovec->iov_base = kmap(kiov->kiov_page) - + kiov->kiov_offset; - - iovec->iov_len = kiov->kiov_len; - iovec++; - kiov++; - } - gmnal_small_tx(libnal, private, cookie, hdr, type, nid, - pid, kniov, iovec_dup, offset, len); - } else { - CDEBUG(D_ERROR, "Large message send it is not supported yet\n"); - return(PTL_FAIL); - for (i=0; ikiov_page, kiov->kiov_len, - kiov->kiov_offset); - - iovec->iov_base = kmap(kiov->kiov_page) - + kiov->kiov_offset; - iovec->iov_len = kiov->kiov_len; - iovec++; - kiov++; - } - gmnal_large_tx(libnal, private, cookie, hdr, type, nid, - pid, kniov, iovec, offset, len); - } - for (i=0; ikiov_page); - kiov_dup++; - } - PORTAL_FREE(iovec_dup, kniov*sizeof(struct iovec)); - return(PTL_OK); -} - -int gmnal_cb_dist(lib_nal_t *libnal, ptl_nid_t nid, unsigned long *dist) -{ - CDEBUG(D_TRACE, "gmnal_cb_dist\n"); - if (dist) - *dist = 27; - return(PTL_OK); -} diff --git a/lnet/klnds/gmlnd/gmlnd_comm.c b/lnet/klnds/gmlnd/gmlnd_comm.c deleted file mode 100644 index 6a8fcbc..0000000 --- a/lnet/klnds/gmlnd/gmlnd_comm.c +++ /dev/null @@ -1,1380 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2003 Los Alamos National Laboratory (LANL) - * - * 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. - */ - -/* - * This file contains all gmnal send and receive functions - */ - -#include "gmnal.h" - -/* - * The caretaker thread - * This is main thread of execution for the NAL side - * This guy waits in gm_blocking_recvive and gets - * woken up when the myrinet adaptor gets an interrupt. - * Hands off receive operations to the receive thread - * This thread Looks after gm_callbacks etc inline. - */ -int -gmnal_ct_thread(void *arg) -{ - gmnal_data_t *nal_data; - gm_recv_event_t *rxevent = NULL; - gm_recv_t *recv = NULL; - - if (!arg) { - CDEBUG(D_TRACE, "NO nal_data. Exiting\n"); - return(-1); - } - - nal_data = (gmnal_data_t*)arg; - CDEBUG(D_TRACE, "nal_data is [%p]\n", arg); - - daemonize(); - - nal_data->ctthread_flag = GMNAL_CTTHREAD_STARTED; - - GMNAL_GM_LOCK(nal_data); - while(nal_data->ctthread_flag == GMNAL_CTTHREAD_STARTED) { - CDEBUG(D_NET, "waiting\n"); - rxevent = gm_blocking_receive_no_spin(nal_data->gm_port); - if (nal_data->ctthread_flag == GMNAL_THREAD_STOP) { - CDEBUG(D_INFO, "time to exit\n"); - break; - } - CDEBUG(D_INFO, "got [%s]\n", gmnal_rxevent(rxevent)); - switch (GM_RECV_EVENT_TYPE(rxevent)) { - - case(GM_RECV_EVENT): - CDEBUG(D_NET, "CTTHREAD:: GM_RECV_EVENT\n"); - recv = (gm_recv_t*)&rxevent->recv; - GMNAL_GM_UNLOCK(nal_data); - gmnal_add_rxtwe(nal_data, recv); - GMNAL_GM_LOCK(nal_data); - CDEBUG(D_NET, "CTTHREAD:: Added event to Q\n"); - break; - case(_GM_SLEEP_EVENT): - /* - * Blocking receive above just returns - * immediatly with _GM_SLEEP_EVENT - * Don't know what this is - */ - CDEBUG(D_NET, "Sleeping in gm_unknown\n"); - GMNAL_GM_UNLOCK(nal_data); - gm_unknown(nal_data->gm_port, rxevent); - GMNAL_GM_LOCK(nal_data); - CDEBUG(D_INFO, "Awake from gm_unknown\n"); - break; - - default: - /* - * Don't know what this is - * gm_unknown will make sense of it - * Should be able to do something with - * FAST_RECV_EVENTS here. - */ - CDEBUG(D_NET, "Passing event to gm_unknown\n"); - GMNAL_GM_UNLOCK(nal_data); - gm_unknown(nal_data->gm_port, rxevent); - GMNAL_GM_LOCK(nal_data); - CDEBUG(D_INFO, "Processed unknown event\n"); - } - } - GMNAL_GM_UNLOCK(nal_data); - nal_data->ctthread_flag = GMNAL_THREAD_RESET; - CDEBUG(D_INFO, "thread nal_data [%p] is exiting\n", nal_data); - return(GMNAL_STATUS_OK); -} - - -/* - * process a receive event - */ -int gmnal_rx_thread(void *arg) -{ - gmnal_data_t *nal_data; - void *buffer; - gmnal_rxtwe_t *we = NULL; - - if (!arg) { - CDEBUG(D_TRACE, "NO nal_data. Exiting\n"); - return(-1); - } - - nal_data = (gmnal_data_t*)arg; - CDEBUG(D_TRACE, "nal_data is [%p]\n", arg); - - daemonize(); - /* - * set 1 bit for each thread started - * doesn't matter which bit - */ - spin_lock(&nal_data->rxthread_flag_lock); - if (nal_data->rxthread_flag) - nal_data->rxthread_flag=nal_data->rxthread_flag*2 + 1; - else - nal_data->rxthread_flag = 1; - CDEBUG(D_INFO, "rxthread flag is [%ld]\n", nal_data->rxthread_flag); - spin_unlock(&nal_data->rxthread_flag_lock); - - while(nal_data->rxthread_stop_flag != GMNAL_THREAD_STOP) { - CDEBUG(D_NET, "RXTHREAD:: Receive thread waiting\n"); - we = gmnal_get_rxtwe(nal_data); - if (!we) { - CDEBUG(D_INFO, "Receive thread time to exit\n"); - break; - } - - buffer = we->buffer; - switch(((gmnal_msghdr_t*)buffer)->type) { - case(GMNAL_SMALL_MESSAGE): - gmnal_pre_receive(nal_data, we, - GMNAL_SMALL_MESSAGE); - break; - case(GMNAL_LARGE_MESSAGE_INIT): - gmnal_pre_receive(nal_data, we, - GMNAL_LARGE_MESSAGE_INIT); - break; - case(GMNAL_LARGE_MESSAGE_ACK): - gmnal_pre_receive(nal_data, we, - GMNAL_LARGE_MESSAGE_ACK); - break; - default: - CDEBUG(D_ERROR, "Unsupported message type\n"); - gmnal_rx_bad(nal_data, we, NULL); - } - PORTAL_FREE(we, sizeof(gmnal_rxtwe_t)); - } - - spin_lock(&nal_data->rxthread_flag_lock); - nal_data->rxthread_flag/=2; - CDEBUG(D_INFO, "rxthread flag is [%ld]\n", nal_data->rxthread_flag); - spin_unlock(&nal_data->rxthread_flag_lock); - CDEBUG(D_INFO, "thread nal_data [%p] is exiting\n", nal_data); - return(GMNAL_STATUS_OK); -} - - - -/* - * Start processing a small message receive - * Get here from gmnal_receive_thread - * Hand off to lib_parse, which calls cb_recv - * which hands back to gmnal_small_receive - * Deal with all endian stuff here. - */ -int -gmnal_pre_receive(gmnal_data_t *nal_data, gmnal_rxtwe_t *we, int gmnal_type) -{ - gmnal_srxd_t *srxd = NULL; - void *buffer = NULL; - unsigned int snode, sport, type, length; - gmnal_msghdr_t *gmnal_msghdr; - ptl_hdr_t *portals_hdr; - int rc; - - CDEBUG(D_INFO, "nal_data [%p], we[%p] type [%d]\n", - nal_data, we, gmnal_type); - - buffer = we->buffer; - snode = we->snode; - sport = we->sport; - type = we->type; - buffer = we->buffer; - length = we->length; - - gmnal_msghdr = (gmnal_msghdr_t*)buffer; - portals_hdr = (ptl_hdr_t*)(buffer+GMNAL_MSGHDR_SIZE); - - CDEBUG(D_INFO, "rx_event:: Sender node [%d], Sender Port [%d], " - "type [%d], length [%d], buffer [%p]\n", - snode, sport, type, length, buffer); - CDEBUG(D_INFO, "gmnal_msghdr:: Sender node [%u], magic [%d], " - "gmnal_type [%d]\n", gmnal_msghdr->sender_node_id, - gmnal_msghdr->magic, gmnal_msghdr->type); - CDEBUG(D_INFO, "portals_hdr:: Sender node ["LPD64"], " - "dest_node ["LPD64"]\n", portals_hdr->src_nid, - portals_hdr->dest_nid); - - - /* - * Get a receive descriptor for this message - */ - srxd = gmnal_rxbuffer_to_srxd(nal_data, buffer); - CDEBUG(D_INFO, "Back from gmnal_rxbuffer_to_srxd\n"); - if (!srxd) { - CDEBUG(D_ERROR, "Failed to get receive descriptor\n"); - /* I think passing a NULL srxd to lib_parse will crash - * gmnal_recv() */ - LBUG(); - lib_parse(nal_data->libnal, portals_hdr, srxd); - return(GMNAL_STATUS_FAIL); - } - - /* - * no need to bother portals library with this - */ - if (gmnal_type == GMNAL_LARGE_MESSAGE_ACK) { - gmnal_large_tx_ack_received(nal_data, srxd); - return(GMNAL_STATUS_OK); - } - - srxd->nal_data = nal_data; - srxd->type = gmnal_type; - srxd->nsiov = gmnal_msghdr->niov; - srxd->gm_source_node = gmnal_msghdr->sender_node_id; - - CDEBUG(D_PORTALS, "Calling lib_parse buffer is [%p]\n", - buffer+GMNAL_MSGHDR_SIZE); - /* - * control passes to lib, which calls cb_recv - * cb_recv is responsible for returning the buffer - * for future receive - */ - rc = lib_parse(nal_data->libnal, portals_hdr, srxd); - - if (rc != PTL_OK) { - /* I just received garbage; take appropriate action... */ - LBUG(); - } - - return(GMNAL_STATUS_OK); -} - - - -/* - * After a receive has been processed, - * hang out the receive buffer again. - * This implicitly returns a receive token. - */ -int -gmnal_rx_requeue_buffer(gmnal_data_t *nal_data, gmnal_srxd_t *srxd) -{ - CDEBUG(D_TRACE, "gmnal_rx_requeue_buffer\n"); - - CDEBUG(D_NET, "requeueing srxd[%p] nal_data[%p]\n", srxd, nal_data); - - GMNAL_GM_LOCK(nal_data); - gm_provide_receive_buffer_with_tag(nal_data->gm_port, srxd->buffer, - srxd->gmsize, GM_LOW_PRIORITY, 0 ); - GMNAL_GM_UNLOCK(nal_data); - - return(GMNAL_STATUS_OK); -} - - -/* - * Handle a bad message - * A bad message is one we don't expect or can't interpret - */ -int -gmnal_rx_bad(gmnal_data_t *nal_data, gmnal_rxtwe_t *we, gmnal_srxd_t *srxd) -{ - CDEBUG(D_TRACE, "Can't handle message\n"); - - if (!srxd) - srxd = gmnal_rxbuffer_to_srxd(nal_data, - we->buffer); - if (srxd) { - gmnal_rx_requeue_buffer(nal_data, srxd); - } else { - CDEBUG(D_ERROR, "Can't find a descriptor for this buffer\n"); - /* - * get rid of it ? - */ - return(GMNAL_STATUS_FAIL); - } - - return(GMNAL_STATUS_OK); -} - - - -/* - * Process a small message receive. - * Get here from gmnal_receive_thread, gmnal_pre_receive - * lib_parse, cb_recv - * Put data from prewired receive buffer into users buffer(s) - * Hang out the receive buffer again for another receive - * Call lib_finalize - */ -int -gmnal_small_rx(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - unsigned int niov, struct iovec *iov, size_t offset, size_t mlen, size_t rlen) -{ - gmnal_srxd_t *srxd = NULL; - void *buffer = NULL; - gmnal_data_t *nal_data = (gmnal_data_t*)libnal->libnal_data; - - - CDEBUG(D_TRACE, "niov [%d] mlen["LPSZ"]\n", niov, mlen); - - if (!private) { - CDEBUG(D_ERROR, "gmnal_small_rx no context\n"); - lib_finalize(libnal, private, cookie, PTL_FAIL); - return(PTL_FAIL); - } - - srxd = (gmnal_srxd_t*)private; - buffer = srxd->buffer; - buffer += sizeof(gmnal_msghdr_t); - buffer += sizeof(ptl_hdr_t); - - while(niov--) { - if (offset >= iov->iov_len) { - offset -= iov->iov_len; - } else if (offset > 0) { - CDEBUG(D_INFO, "processing [%p] base [%p] len %d, " - "offset %d, len ["LPSZ"]\n", iov, - iov->iov_base + offset, iov->iov_len, offset, - iov->iov_len - offset); - gm_bcopy(buffer, iov->iov_base + offset, - iov->iov_len - offset); - offset = 0; - buffer += iov->iov_len - offset; - } else { - CDEBUG(D_INFO, "processing [%p] len ["LPSZ"]\n", iov, - iov->iov_len); - gm_bcopy(buffer, iov->iov_base, iov->iov_len); - buffer += iov->iov_len; - } - iov++; - } - - - /* - * let portals library know receive is complete - */ - CDEBUG(D_PORTALS, "calling lib_finalize\n"); - lib_finalize(libnal, private, cookie, PTL_OK); - /* - * return buffer so it can be used again - */ - CDEBUG(D_NET, "calling gm_provide_receive_buffer\n"); - GMNAL_GM_LOCK(nal_data); - gm_provide_receive_buffer_with_tag(nal_data->gm_port, srxd->buffer, - srxd->gmsize, GM_LOW_PRIORITY, 0); - GMNAL_GM_UNLOCK(nal_data); - - return(PTL_OK); -} - - -/* - * Start a small transmit. - * Get a send token (and wired transmit buffer). - * Copy data from senders buffer to wired buffer and - * initiate gm_send from the wired buffer. - * The callback function informs when the send is complete. - */ -int -gmnal_small_tx(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t global_nid, ptl_pid_t pid, - unsigned int niov, struct iovec *iov, size_t offset, int size) -{ - gmnal_data_t *nal_data = (gmnal_data_t*)libnal->libnal_data; - gmnal_stxd_t *stxd = NULL; - void *buffer = NULL; - gmnal_msghdr_t *msghdr = NULL; - int tot_size = 0; - unsigned int local_nid; - gm_status_t gm_status = GM_SUCCESS; - - CDEBUG(D_TRACE, "gmnal_small_tx libnal [%p] private [%p] cookie [%p] " - "hdr [%p] type [%d] global_nid ["LPU64"] pid [%d] niov [%d] " - "iov [%p] size [%d]\n", libnal, private, cookie, hdr, type, - global_nid, pid, niov, iov, size); - - CDEBUG(D_INFO, "portals_hdr:: dest_nid ["LPU64"], src_nid ["LPU64"]\n", - hdr->dest_nid, hdr->src_nid); - - if (!nal_data) { - CDEBUG(D_ERROR, "no nal_data\n"); - return(GMNAL_STATUS_FAIL); - } else { - CDEBUG(D_INFO, "nal_data [%p]\n", nal_data); - } - - GMNAL_GM_LOCK(nal_data); - gm_status = gm_global_id_to_node_id(nal_data->gm_port, global_nid, - &local_nid); - GMNAL_GM_UNLOCK(nal_data); - if (gm_status != GM_SUCCESS) { - CDEBUG(D_ERROR, "Failed to obtain local id\n"); - return(GMNAL_STATUS_FAIL); - } - CDEBUG(D_INFO, "Local Node_id is [%u][%x]\n", local_nid, local_nid); - - stxd = gmnal_get_stxd(nal_data, 1); - CDEBUG(D_INFO, "stxd [%p]\n", stxd); - - stxd->type = GMNAL_SMALL_MESSAGE; - stxd->cookie = cookie; - - /* - * Copy gmnal_msg_hdr and portals header to the transmit buffer - * Then copy the data in - */ - buffer = stxd->buffer; - msghdr = (gmnal_msghdr_t*)buffer; - - msghdr->magic = GMNAL_MAGIC; - msghdr->type = GMNAL_SMALL_MESSAGE; - msghdr->sender_node_id = nal_data->gm_global_nid; - CDEBUG(D_INFO, "processing msghdr at [%p]\n", buffer); - - buffer += sizeof(gmnal_msghdr_t); - - CDEBUG(D_INFO, "processing portals hdr at [%p]\n", buffer); - gm_bcopy(hdr, buffer, sizeof(ptl_hdr_t)); - - buffer += sizeof(ptl_hdr_t); - - while(niov--) { - if (offset >= iov->iov_len) { - offset -= iov->iov_len; - } else if (offset > 0) { - CDEBUG(D_INFO, "processing iov [%p] base [%p] len ["LPSZ"] to [%p]\n", - iov, iov->iov_base + offset, iov->iov_len - offset, buffer); - gm_bcopy(iov->iov_base + offset, buffer, iov->iov_len - offset); - buffer+= iov->iov_len - offset; - offset = 0; - } else { - CDEBUG(D_INFO, "processing iov [%p] len ["LPSZ"] to [%p]\n", - iov, iov->iov_len, buffer); - gm_bcopy(iov->iov_base, buffer, iov->iov_len); - buffer+= iov->iov_len; - } - iov++; - } - - CDEBUG(D_INFO, "sending\n"); - tot_size = size+sizeof(ptl_hdr_t)+sizeof(gmnal_msghdr_t); - stxd->msg_size = tot_size; - - - CDEBUG(D_NET, "Calling gm_send_to_peer port [%p] buffer [%p] " - "gmsize [%lu] msize [%d] global_nid ["LPU64"] local_nid[%d] " - "stxd [%p]\n", nal_data->gm_port, stxd->buffer, stxd->gm_size, - stxd->msg_size, global_nid, local_nid, stxd); - - GMNAL_GM_LOCK(nal_data); - stxd->gm_priority = GM_LOW_PRIORITY; - stxd->gm_target_node = local_nid; - gm_send_to_peer_with_callback(nal_data->gm_port, stxd->buffer, - stxd->gm_size, stxd->msg_size, - GM_LOW_PRIORITY, local_nid, - gmnal_small_tx_callback, (void*)stxd); - GMNAL_GM_UNLOCK(nal_data); - CDEBUG(D_INFO, "done\n"); - - return(PTL_OK); -} - - -/* - * A callback to indicate the small transmit operation is compete - * Check for erros and try to deal with them. - * Call lib_finalise to inform the client application that the send - * is complete and the memory can be reused. - * Return the stxd when finished with it (returns a send token) - */ -void -gmnal_small_tx_callback(gm_port_t *gm_port, void *context, gm_status_t status) -{ - gmnal_stxd_t *stxd = (gmnal_stxd_t*)context; - lib_msg_t *cookie = stxd->cookie; - gmnal_data_t *nal_data = (gmnal_data_t*)stxd->nal_data; - lib_nal_t *libnal = nal_data->libnal; - - if (!stxd) { - CDEBUG(D_TRACE, "send completion event for unknown stxd\n"); - return; - } - if (status != GM_SUCCESS) { - CDEBUG(D_ERROR, "Result of send stxd [%p] is [%s]\n", - stxd, gmnal_gm_error(status)); - } - - switch(status) { - case(GM_SUCCESS): - break; - - - - case(GM_SEND_DROPPED): - /* - * do a resend on the dropped ones - */ - CDEBUG(D_ERROR, "send stxd [%p] was dropped " - "resending\n", context); - GMNAL_GM_LOCK(nal_data); - gm_send_to_peer_with_callback(nal_data->gm_port, - stxd->buffer, - stxd->gm_size, - stxd->msg_size, - stxd->gm_priority, - stxd->gm_target_node, - gmnal_small_tx_callback, - context); - GMNAL_GM_UNLOCK(nal_data); - - return; - case(GM_TIMED_OUT): - case(GM_SEND_TIMED_OUT): - /* - * drop these ones - */ - CDEBUG(D_INFO, "calling gm_drop_sends\n"); - GMNAL_GM_LOCK(nal_data); - gm_drop_sends(nal_data->gm_port, stxd->gm_priority, - stxd->gm_target_node, GMNAL_GM_PORT, - gmnal_drop_sends_callback, context); - GMNAL_GM_UNLOCK(nal_data); - - return; - - - /* - * abort on these ? - */ - case(GM_TRY_AGAIN): - case(GM_INTERRUPTED): - case(GM_FAILURE): - case(GM_INPUT_BUFFER_TOO_SMALL): - case(GM_OUTPUT_BUFFER_TOO_SMALL): - case(GM_BUSY): - case(GM_MEMORY_FAULT): - case(GM_INVALID_PARAMETER): - case(GM_OUT_OF_MEMORY): - case(GM_INVALID_COMMAND): - case(GM_PERMISSION_DENIED): - case(GM_INTERNAL_ERROR): - case(GM_UNATTACHED): - case(GM_UNSUPPORTED_DEVICE): - case(GM_SEND_REJECTED): - case(GM_SEND_TARGET_PORT_CLOSED): - case(GM_SEND_TARGET_NODE_UNREACHABLE): - case(GM_SEND_PORT_CLOSED): - case(GM_NODE_ID_NOT_YET_SET): - case(GM_STILL_SHUTTING_DOWN): - case(GM_CLONE_BUSY): - case(GM_NO_SUCH_DEVICE): - case(GM_ABORTED): - case(GM_INCOMPATIBLE_LIB_AND_DRIVER): - case(GM_UNTRANSLATED_SYSTEM_ERROR): - case(GM_ACCESS_DENIED): - case(GM_NO_DRIVER_SUPPORT): - case(GM_PTE_REF_CNT_OVERFLOW): - case(GM_NOT_SUPPORTED_IN_KERNEL): - case(GM_NOT_SUPPORTED_ON_ARCH): - case(GM_NO_MATCH): - case(GM_USER_ERROR): - case(GM_DATA_CORRUPTED): - case(GM_HARDWARE_FAULT): - case(GM_SEND_ORPHANED): - case(GM_MINOR_OVERFLOW): - case(GM_PAGE_TABLE_FULL): - case(GM_UC_ERROR): - case(GM_INVALID_PORT_NUMBER): - case(GM_DEV_NOT_FOUND): - case(GM_FIRMWARE_NOT_RUNNING): - case(GM_YP_NO_MATCH): - default: - CDEBUG(D_ERROR, "Unknown send error\n"); - gm_resume_sending(nal_data->gm_port, stxd->gm_priority, - stxd->gm_target_node, GMNAL_GM_PORT, - gmnal_resume_sending_callback, context); - return; - - } - - /* - * TO DO - * If this is a large message init, - * we're not finished with the data yet, - * so can't call lib_finalise. - * However, we're also holding on to a - * stxd here (to keep track of the source - * iovec only). Should use another structure - * to keep track of iovec and return stxd to - * free list earlier. - */ - if (stxd->type == GMNAL_LARGE_MESSAGE_INIT) { - CDEBUG(D_INFO, "large transmit done\n"); - return; - } - gmnal_return_stxd(nal_data, stxd); - lib_finalize(libnal, stxd, cookie, PTL_OK); - return; -} - -/* - * After an error on the port - * call this to allow future sends to complete - */ -void gmnal_resume_sending_callback(struct gm_port *gm_port, void *context, - gm_status_t status) -{ - gmnal_data_t *nal_data; - gmnal_stxd_t *stxd = (gmnal_stxd_t*)context; - CDEBUG(D_TRACE, "status is [%d] context is [%p]\n", status, context); - gmnal_return_stxd(stxd->nal_data, stxd); - return; -} - - -void gmnal_drop_sends_callback(struct gm_port *gm_port, void *context, - gm_status_t status) -{ - gmnal_stxd_t *stxd = (gmnal_stxd_t*)context; - gmnal_data_t *nal_data = stxd->nal_data; - - CDEBUG(D_TRACE, "status is [%d] context is [%p]\n", status, context); - if (status == GM_SUCCESS) { - GMNAL_GM_LOCK(nal_data); - gm_send_to_peer_with_callback(gm_port, stxd->buffer, - stxd->gm_size, stxd->msg_size, - stxd->gm_priority, - stxd->gm_target_node, - gmnal_small_tx_callback, - context); - GMNAL_GM_LOCK(nal_data); - } else { - CDEBUG(D_ERROR, "send_to_peer status for stxd [%p] is " - "[%d][%s]\n", stxd, status, gmnal_gm_error(status)); - } - - - return; -} - - -/* - * Begine a large transmit. - * Do a gm_register of the memory pointed to by the iovec - * and send details to the receiver. The receiver does a gm_get - * to pull the data and sends and ack when finished. Upon receipt of - * this ack, deregister the memory. Only 1 send token is required here. - */ -int -gmnal_large_tx(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t global_nid, ptl_pid_t pid, - unsigned int niov, struct iovec *iov, size_t offset, int size) -{ - - gmnal_data_t *nal_data; - gmnal_stxd_t *stxd = NULL; - void *buffer = NULL; - gmnal_msghdr_t *msghdr = NULL; - unsigned int local_nid; - int mlen = 0; /* the size of the init message data */ - struct iovec *iov_dup = NULL; - gm_status_t gm_status; - int niov_dup; - - - CDEBUG(D_TRACE, "gmnal_large_tx libnal [%p] private [%p], cookie [%p] " - "hdr [%p], type [%d] global_nid ["LPU64"], pid [%d], niov [%d], " - "iov [%p], size [%d]\n", libnal, private, cookie, hdr, type, - global_nid, pid, niov, iov, size); - - if (libnal) - nal_data = (gmnal_data_t*)libnal->libnal_data; - else { - CDEBUG(D_ERROR, "no libnal.\n"); - return(GMNAL_STATUS_FAIL); - } - - - /* - * Get stxd and buffer. Put local address of data in buffer, - * send local addresses to target, - * wait for the target node to suck the data over. - * The stxd is used to ren - */ - stxd = gmnal_get_stxd(nal_data, 1); - CDEBUG(D_INFO, "stxd [%p]\n", stxd); - - stxd->type = GMNAL_LARGE_MESSAGE_INIT; - stxd->cookie = cookie; - - /* - * Copy gmnal_msg_hdr and portals header to the transmit buffer - * Then copy the iov in - */ - buffer = stxd->buffer; - msghdr = (gmnal_msghdr_t*)buffer; - - CDEBUG(D_INFO, "processing msghdr at [%p]\n", buffer); - - msghdr->magic = GMNAL_MAGIC; - msghdr->type = GMNAL_LARGE_MESSAGE_INIT; - msghdr->sender_node_id = nal_data->gm_global_nid; - msghdr->stxd = stxd; - msghdr->niov = niov ; - buffer += sizeof(gmnal_msghdr_t); - mlen = sizeof(gmnal_msghdr_t); - CDEBUG(D_INFO, "mlen is [%d]\n", mlen); - - - CDEBUG(D_INFO, "processing portals hdr at [%p]\n", buffer); - - gm_bcopy(hdr, buffer, sizeof(ptl_hdr_t)); - buffer += sizeof(ptl_hdr_t); - mlen += sizeof(ptl_hdr_t); - CDEBUG(D_INFO, "mlen is [%d]\n", mlen); - - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - niov--; - iov++; - } - - LASSERT(offset >= 0); - /* - * Store the iovs in the stxd for we can get - * them later if we need them - */ - stxd->iov[0].iov_base = iov->iov_base + offset; - stxd->iov[0].iov_len = iov->iov_len - offset; - CDEBUG(D_NET, "Copying iov [%p] to [%p], niov=%d\n", iov, stxd->iov, niov); - if (niov > 1) - gm_bcopy(&iov[1], &stxd->iov[1], (niov-1)*sizeof(struct iovec)); - stxd->niov = niov; - - /* - * copy the iov to the buffer so target knows - * where to get the data from - */ - CDEBUG(D_INFO, "processing iov to [%p]\n", buffer); - gm_bcopy(stxd->iov, buffer, stxd->niov*sizeof(struct iovec)); - mlen += stxd->niov*(sizeof(struct iovec)); - CDEBUG(D_INFO, "mlen is [%d]\n", mlen); - - /* - * register the memory so the NIC can get hold of the data - * This is a slow process. it'd be good to overlap it - * with something else. - */ - iov = stxd->iov; - iov_dup = iov; - niov_dup = niov; - while(niov--) { - CDEBUG(D_INFO, "Registering memory [%p] len ["LPSZ"] \n", - iov->iov_base, iov->iov_len); - GMNAL_GM_LOCK(nal_data); - gm_status = gm_register_memory(nal_data->gm_port, - iov->iov_base, iov->iov_len); - if (gm_status != GM_SUCCESS) { - GMNAL_GM_UNLOCK(nal_data); - CDEBUG(D_ERROR, "gm_register_memory returns [%d][%s] " - "for memory [%p] len ["LPSZ"]\n", - gm_status, gmnal_gm_error(gm_status), - iov->iov_base, iov->iov_len); - GMNAL_GM_LOCK(nal_data); - while (iov_dup != iov) { - gm_deregister_memory(nal_data->gm_port, - iov_dup->iov_base, - iov_dup->iov_len); - iov_dup++; - } - GMNAL_GM_UNLOCK(nal_data); - gmnal_return_stxd(nal_data, stxd); - return(PTL_FAIL); - } - - GMNAL_GM_UNLOCK(nal_data); - iov++; - } - - /* - * Send the init message to the target - */ - CDEBUG(D_INFO, "sending mlen [%d]\n", mlen); - GMNAL_GM_LOCK(nal_data); - gm_status = gm_global_id_to_node_id(nal_data->gm_port, global_nid, - &local_nid); - if (gm_status != GM_SUCCESS) { - GMNAL_GM_UNLOCK(nal_data); - CDEBUG(D_ERROR, "Failed to obtain local id\n"); - gmnal_return_stxd(nal_data, stxd); - /* TO DO deregister memory on failure */ - return(GMNAL_STATUS_FAIL); - } - CDEBUG(D_INFO, "Local Node_id is [%d]\n", local_nid); - gm_send_to_peer_with_callback(nal_data->gm_port, stxd->buffer, - stxd->gm_size, mlen, GM_LOW_PRIORITY, - local_nid, gmnal_large_tx_callback, - (void*)stxd); - GMNAL_GM_UNLOCK(nal_data); - - CDEBUG(D_INFO, "done\n"); - - return(PTL_OK); -} - -/* - * Callback function indicates that send of buffer with - * large message iovec has completed (or failed). - */ -void -gmnal_large_tx_callback(gm_port_t *gm_port, void *context, gm_status_t status) -{ - gmnal_small_tx_callback(gm_port, context, status); - -} - - - -/* - * Have received a buffer that contains an iovec of the sender. - * Do a gm_register_memory of the receivers buffer and then do a get - * data from the sender. - */ -int -gmnal_large_rx(lib_nal_t *libnal, void *private, lib_msg_t *cookie, - unsigned int nriov, struct iovec *riov, size_t offset, - size_t mlen, size_t rlen) -{ - gmnal_data_t *nal_data = libnal->libnal_data; - gmnal_srxd_t *srxd = (gmnal_srxd_t*)private; - void *buffer = NULL; - struct iovec *riov_dup; - int nriov_dup; - gmnal_msghdr_t *msghdr = NULL; - gm_status_t gm_status; - - CDEBUG(D_TRACE, "gmnal_large_rx :: libnal[%p], private[%p], " - "cookie[%p], niov[%d], iov[%p], mlen["LPSZ"], rlen["LPSZ"]\n", - libnal, private, cookie, nriov, riov, mlen, rlen); - - if (!srxd) { - CDEBUG(D_ERROR, "gmnal_large_rx no context\n"); - lib_finalize(libnal, private, cookie, PTL_FAIL); - return(PTL_FAIL); - } - - buffer = srxd->buffer; - msghdr = (gmnal_msghdr_t*)buffer; - buffer += sizeof(gmnal_msghdr_t); - buffer += sizeof(ptl_hdr_t); - - /* - * Store the senders stxd address in the srxd for this message - * The gmnal_large_message_ack needs it to notify the sender - * the pull of data is complete - */ - srxd->source_stxd = msghdr->stxd; - - /* - * Register the receivers memory - * get the data, - * tell the sender that we got the data - * then tell the receiver we got the data - * TO DO - * If the iovecs match, could interleave - * gm_registers and gm_gets for each element - */ - while (offset >= riov->iov_len) { - offset -= riov->iov_len; - riov++; - nriov--; - } - LASSERT (nriov >= 0); - LASSERT (offset >= 0); - /* - * do this so the final gm_get callback can deregister the memory - */ - PORTAL_ALLOC(srxd->riov, nriov*(sizeof(struct iovec))); - - srxd->riov[0].iov_base = riov->iov_base + offset; - srxd->riov[0].iov_len = riov->iov_len - offset; - if (nriov > 1) - gm_bcopy(&riov[1], &srxd->riov[1], (nriov-1)*(sizeof(struct iovec))); - srxd->nriov = nriov; - - riov = srxd->riov; - nriov_dup = nriov; - riov_dup = riov; - while(nriov--) { - CDEBUG(D_INFO, "Registering memory [%p] len ["LPSZ"] \n", - riov->iov_base, riov->iov_len); - GMNAL_GM_LOCK(nal_data); - gm_status = gm_register_memory(nal_data->gm_port, - riov->iov_base, riov->iov_len); - if (gm_status != GM_SUCCESS) { - GMNAL_GM_UNLOCK(nal_data); - CDEBUG(D_ERROR, "gm_register_memory returns [%d][%s] " - "for memory [%p] len ["LPSZ"]\n", - gm_status, gmnal_gm_error(gm_status), - riov->iov_base, riov->iov_len); - GMNAL_GM_LOCK(nal_data); - while (riov_dup != riov) { - gm_deregister_memory(nal_data->gm_port, - riov_dup->iov_base, - riov_dup->iov_len); - riov_dup++; - } - GMNAL_GM_LOCK(nal_data); - /* - * give back srxd and buffer. Send NACK to sender - */ - PORTAL_FREE(srxd->riov, nriov_dup*(sizeof(struct iovec))); - return(PTL_FAIL); - } - GMNAL_GM_UNLOCK(nal_data); - riov++; - } - - /* - * now do gm_get to get the data - */ - srxd->cookie = cookie; - if (gmnal_remote_get(srxd, srxd->nsiov, (struct iovec*)buffer, - nriov_dup, riov_dup) != GMNAL_STATUS_OK) { - CDEBUG(D_ERROR, "can't get the data"); - } - - CDEBUG(D_INFO, "lgmanl_large_rx done\n"); - - return(PTL_OK); -} - - -/* - * Perform a number of remote gets as part of receiving - * a large message. - * The final one to complete (i.e. the last callback to get called) - * tidies up. - * gm_get requires a send token. - */ -int -gmnal_remote_get(gmnal_srxd_t *srxd, int nsiov, struct iovec *siov, - int nriov, struct iovec *riov) -{ - - int ncalls = 0; - - CDEBUG(D_TRACE, "gmnal_remote_get srxd[%p], nriov[%d], riov[%p], " - "nsiov[%d], siov[%p]\n", srxd, nriov, riov, nsiov, siov); - - - ncalls = gmnal_copyiov(0, srxd, nsiov, siov, nriov, riov); - if (ncalls < 0) { - CDEBUG(D_ERROR, "there's something wrong with the iovecs\n"); - return(GMNAL_STATUS_FAIL); - } - CDEBUG(D_INFO, "gmnal_remote_get ncalls [%d]\n", ncalls); - spin_lock_init(&srxd->callback_lock); - srxd->ncallbacks = ncalls; - srxd->callback_status = 0; - - ncalls = gmnal_copyiov(1, srxd, nsiov, siov, nriov, riov); - if (ncalls < 0) { - CDEBUG(D_ERROR, "there's something wrong with the iovecs\n"); - return(GMNAL_STATUS_FAIL); - } - - return(GMNAL_STATUS_OK); - -} - - -/* - * pull data from source node (source iovec) to a local iovec. - * The iovecs may not match which adds the complications below. - * Count the number of gm_gets that will be required to the callbacks - * can determine who is the last one. - */ -int -gmnal_copyiov(int do_copy, gmnal_srxd_t *srxd, int nsiov, - struct iovec *siov, int nriov, struct iovec *riov) -{ - - int ncalls = 0; - int slen = siov->iov_len, rlen = riov->iov_len; - char *sbuf = siov->iov_base, *rbuf = riov->iov_base; - unsigned long sbuf_long; - gm_remote_ptr_t remote_ptr = 0; - unsigned int source_node; - gmnal_ltxd_t *ltxd = NULL; - gmnal_data_t *nal_data = srxd->nal_data; - - CDEBUG(D_TRACE, "copy[%d] nal_data[%p]\n", do_copy, nal_data); - if (do_copy) { - if (!nal_data) { - CDEBUG(D_ERROR, "Bad args No nal_data\n"); - return(GMNAL_STATUS_FAIL); - } - GMNAL_GM_LOCK(nal_data); - if (gm_global_id_to_node_id(nal_data->gm_port, - srxd->gm_source_node, - &source_node) != GM_SUCCESS) { - - CDEBUG(D_ERROR, "cannot resolve global_id [%u] " - "to local node_id\n", srxd->gm_source_node); - GMNAL_GM_UNLOCK(nal_data); - return(GMNAL_STATUS_FAIL); - } - GMNAL_GM_UNLOCK(nal_data); - /* - * We need a send token to use gm_get - * getting an stxd gets us a send token. - * the stxd is used as the context to the - * callback function (so stxd can be returned). - * Set pointer in stxd to srxd so callback count in srxd - * can be decremented to find last callback to complete - */ - CDEBUG(D_INFO, "gmnal_copyiov source node is G[%u]L[%d]\n", - srxd->gm_source_node, source_node); - } - - do { - CDEBUG(D_INFO, "sbuf[%p] slen[%d] rbuf[%p], rlen[%d]\n", - sbuf, slen, rbuf, rlen); - if (slen > rlen) { - ncalls++; - if (do_copy) { - CDEBUG(D_INFO, "slen>rlen\n"); - ltxd = gmnal_get_ltxd(nal_data); - ltxd->srxd = srxd; - GMNAL_GM_LOCK(nal_data); - /* - * funny business to get rid - * of compiler warning - */ - sbuf_long = (unsigned long) sbuf; - remote_ptr = (gm_remote_ptr_t)sbuf_long; - gm_get(nal_data->gm_port, remote_ptr, rbuf, - rlen, GM_LOW_PRIORITY, source_node, - GMNAL_GM_PORT, - gmnal_remote_get_callback, ltxd); - GMNAL_GM_UNLOCK(nal_data); - } - /* - * at the end of 1 iov element - */ - sbuf+=rlen; - slen-=rlen; - riov++; - nriov--; - rbuf = riov->iov_base; - rlen = riov->iov_len; - } else if (rlen > slen) { - ncalls++; - if (do_copy) { - CDEBUG(D_INFO, "slensrxd = srxd; - GMNAL_GM_LOCK(nal_data); - sbuf_long = (unsigned long) sbuf; - remote_ptr = (gm_remote_ptr_t)sbuf_long; - gm_get(nal_data->gm_port, remote_ptr, rbuf, - slen, GM_LOW_PRIORITY, source_node, - GMNAL_GM_PORT, - gmnal_remote_get_callback, ltxd); - GMNAL_GM_UNLOCK(nal_data); - } - /* - * at end of siov element - */ - rbuf+=slen; - rlen-=slen; - siov++; - sbuf = siov->iov_base; - slen = siov->iov_len; - } else { - ncalls++; - if (do_copy) { - CDEBUG(D_INFO, "rlen=slen\n"); - ltxd = gmnal_get_ltxd(nal_data); - ltxd->srxd = srxd; - GMNAL_GM_LOCK(nal_data); - sbuf_long = (unsigned long) sbuf; - remote_ptr = (gm_remote_ptr_t)sbuf_long; - gm_get(nal_data->gm_port, remote_ptr, rbuf, - rlen, GM_LOW_PRIORITY, source_node, - GMNAL_GM_PORT, - gmnal_remote_get_callback, ltxd); - GMNAL_GM_UNLOCK(nal_data); - } - /* - * at end of siov and riov element - */ - siov++; - sbuf = siov->iov_base; - slen = siov->iov_len; - riov++; - nriov--; - rbuf = riov->iov_base; - rlen = riov->iov_len; - } - - } while (nriov); - return(ncalls); -} - - -/* - * The callback function that is invoked after each gm_get call completes. - * Multiple callbacks may be invoked for 1 transaction, only the final - * callback has work to do. - */ -void -gmnal_remote_get_callback(gm_port_t *gm_port, void *context, - gm_status_t status) -{ - - gmnal_ltxd_t *ltxd = (gmnal_ltxd_t*)context; - gmnal_srxd_t *srxd = ltxd->srxd; - lib_nal_t *libnal = srxd->nal_data->libnal; - int lastone; - struct iovec *riov; - int nriov; - gmnal_data_t *nal_data; - - CDEBUG(D_TRACE, "called for context [%p]\n", context); - - if (status != GM_SUCCESS) { - CDEBUG(D_ERROR, "reports error [%d][%s]\n", status, - gmnal_gm_error(status)); - } - - spin_lock(&srxd->callback_lock); - srxd->ncallbacks--; - srxd->callback_status |= status; - lastone = srxd->ncallbacks?0:1; - spin_unlock(&srxd->callback_lock); - nal_data = srxd->nal_data; - - /* - * everyone returns a send token - */ - gmnal_return_ltxd(nal_data, ltxd); - - if (!lastone) { - CDEBUG(D_ERROR, "NOT final callback context[%p]\n", srxd); - return; - } - - /* - * Let our client application proceed - */ - CDEBUG(D_ERROR, "final callback context[%p]\n", srxd); - lib_finalize(libnal, srxd, srxd->cookie, PTL_OK); - - /* - * send an ack to the sender to let him know we got the data - */ - gmnal_large_tx_ack(nal_data, srxd); - - /* - * Unregister the memory that was used - * This is a very slow business (slower then register) - */ - nriov = srxd->nriov; - riov = srxd->riov; - GMNAL_GM_LOCK(nal_data); - while (nriov--) { - CDEBUG(D_ERROR, "deregister memory [%p]\n", riov->iov_base); - if (gm_deregister_memory(srxd->nal_data->gm_port, - riov->iov_base, riov->iov_len)) { - CDEBUG(D_ERROR, "failed to deregister memory [%p]\n", - riov->iov_base); - } - riov++; - } - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(srxd->riov, sizeof(struct iovec)*nriov); - - /* - * repost the receive buffer (return receive token) - */ - GMNAL_GM_LOCK(nal_data); - gm_provide_receive_buffer_with_tag(nal_data->gm_port, srxd->buffer, - srxd->gmsize, GM_LOW_PRIORITY, 0); - GMNAL_GM_UNLOCK(nal_data); - - return; -} - - -/* - * Called on target node. - * After pulling data from a source node - * send an ack message to indicate the large transmit is complete. - */ -void -gmnal_large_tx_ack(gmnal_data_t *nal_data, gmnal_srxd_t *srxd) -{ - - gmnal_stxd_t *stxd; - gmnal_msghdr_t *msghdr; - void *buffer = NULL; - unsigned int local_nid; - gm_status_t gm_status = GM_SUCCESS; - - CDEBUG(D_TRACE, "srxd[%p] target_node [%u]\n", srxd, - srxd->gm_source_node); - - GMNAL_GM_LOCK(nal_data); - gm_status = gm_global_id_to_node_id(nal_data->gm_port, - srxd->gm_source_node, &local_nid); - GMNAL_GM_UNLOCK(nal_data); - if (gm_status != GM_SUCCESS) { - CDEBUG(D_ERROR, "Failed to obtain local id\n"); - return; - } - CDEBUG(D_INFO, "Local Node_id is [%u][%x]\n", local_nid, local_nid); - - stxd = gmnal_get_stxd(nal_data, 1); - CDEBUG(D_TRACE, "gmnal_large_tx_ack got stxd[%p]\n", stxd); - - stxd->nal_data = nal_data; - stxd->type = GMNAL_LARGE_MESSAGE_ACK; - - /* - * Copy gmnal_msg_hdr and portals header to the transmit buffer - * Then copy the data in - */ - buffer = stxd->buffer; - msghdr = (gmnal_msghdr_t*)buffer; - - /* - * Add in the address of the original stxd from the sender node - * so it knows which thread to notify. - */ - msghdr->magic = GMNAL_MAGIC; - msghdr->type = GMNAL_LARGE_MESSAGE_ACK; - msghdr->sender_node_id = nal_data->gm_global_nid; - msghdr->stxd = srxd->source_stxd; - CDEBUG(D_INFO, "processing msghdr at [%p]\n", buffer); - - CDEBUG(D_INFO, "sending\n"); - stxd->msg_size= sizeof(gmnal_msghdr_t); - - - CDEBUG(D_NET, "Calling gm_send_to_peer port [%p] buffer [%p] " - "gmsize [%lu] msize [%d] global_nid [%u] local_nid[%d] " - "stxd [%p]\n", nal_data->gm_port, stxd->buffer, stxd->gm_size, - stxd->msg_size, srxd->gm_source_node, local_nid, stxd); - GMNAL_GM_LOCK(nal_data); - stxd->gm_priority = GM_LOW_PRIORITY; - stxd->gm_target_node = local_nid; - gm_send_to_peer_with_callback(nal_data->gm_port, stxd->buffer, - stxd->gm_size, stxd->msg_size, - GM_LOW_PRIORITY, local_nid, - gmnal_large_tx_ack_callback, - (void*)stxd); - - GMNAL_GM_UNLOCK(nal_data); - CDEBUG(D_INFO, "gmnal_large_tx_ack :: done\n"); - - return; -} - - -/* - * A callback to indicate the small transmit operation is compete - * Check for errors and try to deal with them. - * Call lib_finalise to inform the client application that the - * send is complete and the memory can be reused. - * Return the stxd when finished with it (returns a send token) - */ -void -gmnal_large_tx_ack_callback(gm_port_t *gm_port, void *context, - gm_status_t status) -{ - gmnal_stxd_t *stxd = (gmnal_stxd_t*)context; - gmnal_data_t *nal_data = (gmnal_data_t*)stxd->nal_data; - - if (!stxd) { - CDEBUG(D_ERROR, "send completion event for unknown stxd\n"); - return; - } - CDEBUG(D_TRACE, "send completion event for stxd [%p] status is [%d]\n", - stxd, status); - gmnal_return_stxd(stxd->nal_data, stxd); - - GMNAL_GM_UNLOCK(nal_data); - return; -} - -/* - * Indicates the large transmit operation is compete. - * Called on transmit side (means data has been pulled by receiver - * or failed). - * Call lib_finalise to inform the client application that the send - * is complete, deregister the memory and return the stxd. - * Finally, report the rx buffer that the ack message was delivered in. - */ -void -gmnal_large_tx_ack_received(gmnal_data_t *nal_data, gmnal_srxd_t *srxd) -{ - lib_nal_t *libnal = nal_data->libnal; - gmnal_stxd_t *stxd = NULL; - gmnal_msghdr_t *msghdr = NULL; - void *buffer = NULL; - struct iovec *iov; - - - CDEBUG(D_TRACE, "gmnal_large_tx_ack_received buffer [%p]\n", buffer); - - buffer = srxd->buffer; - msghdr = (gmnal_msghdr_t*)buffer; - stxd = msghdr->stxd; - - CDEBUG(D_INFO, "gmnal_large_tx_ack_received stxd [%p]\n", stxd); - - lib_finalize(libnal, stxd, stxd->cookie, PTL_OK); - - /* - * extract the iovec from the stxd, deregister the memory. - * free the space used to store the iovec - */ - iov = stxd->iov; - while(stxd->niov--) { - CDEBUG(D_INFO, "deregister memory [%p] size ["LPSZ"]\n", - iov->iov_base, iov->iov_len); - GMNAL_GM_LOCK(nal_data); - gm_deregister_memory(nal_data->gm_port, iov->iov_base, - iov->iov_len); - GMNAL_GM_UNLOCK(nal_data); - iov++; - } - - /* - * return the send token - * TO DO It is bad to hold onto the send token so long? - */ - gmnal_return_stxd(nal_data, stxd); - - - /* - * requeue the receive buffer - */ - gmnal_rx_requeue_buffer(nal_data, srxd); - - - return; -} diff --git a/lnet/klnds/gmlnd/gmlnd_module.c b/lnet/klnds/gmlnd/gmlnd_module.c deleted file mode 100644 index 3aca90f..0000000 --- a/lnet/klnds/gmlnd/gmlnd_module.c +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2003 Los Alamos National Laboratory (LANL) - * - * 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. - */ - -#include "gmnal.h" - - -int gmnal_small_msg_size = 525312; -/* - * -1 indicates default value. - * This is 1 thread per cpu - * See start_kernel_threads - */ -int num_rx_threads = -1; -int num_stxds = 5; -int gm_port = 4; - -int -gmnal_cmd(struct portals_cfg *pcfg, void *private) -{ - gmnal_data_t *nal_data = NULL; - char *name = NULL; - int nid = -2; - int gnid; - gm_status_t gm_status; - - - CDEBUG(D_TRACE, "gmnal_cmd [%d] private [%p]\n", - pcfg->pcfg_command, private); - nal_data = (gmnal_data_t*)private; - switch(pcfg->pcfg_command) { - /* - * just reuse already defined GET_NID. Should define GMNAL version - */ - case(GMNAL_IOC_GET_GNID): - - PORTAL_ALLOC(name, pcfg->pcfg_plen1); - copy_from_user(name, pcfg->pcfg_pbuf1, pcfg->pcfg_plen1); - - GMNAL_GM_LOCK(nal_data); - //nid = gm_host_name_to_node_id(nal_data->gm_port, name); - gm_status = gm_host_name_to_node_id_ex (nal_data->gm_port, 0, name, &nid); - GMNAL_GM_UNLOCK(nal_data); - if (gm_status != GM_SUCCESS) { - CDEBUG(D_INFO, "gm_host_name_to_node_id_ex(...host %s) failed[%d]\n", - name, gm_status); - return (-1); - } else - CDEBUG(D_INFO, "Local node %s id is [%d]\n", name, nid); - GMNAL_GM_LOCK(nal_data); - gm_status = gm_node_id_to_global_id(nal_data->gm_port, - nid, &gnid); - GMNAL_GM_UNLOCK(nal_data); - if (gm_status != GM_SUCCESS) { - CDEBUG(D_INFO, "gm_node_id_to_global_id failed[%d]\n", - gm_status); - return(-1); - } - CDEBUG(D_INFO, "Global node is is [%u][%x]\n", gnid, gnid); - copy_to_user(pcfg->pcfg_pbuf2, &gnid, pcfg->pcfg_plen2); - break; - default: - CDEBUG(D_INFO, "gmnal_cmd UNKNOWN[%d]\n", pcfg->pcfg_command); - pcfg->pcfg_nid2 = -1; - } - - - return(0); -} - - -static int __init -gmnal_load(void) -{ - int status; - CDEBUG(D_TRACE, "This is the gmnal module initialisation routine\n"); - - - CDEBUG(D_INFO, "Calling gmnal_init\n"); - status = gmnal_init(); - if (status == PTL_OK) { - CDEBUG(D_INFO, "Portals GMNAL initialised ok\n"); - } else { - CDEBUG(D_INFO, "Portals GMNAL Failed to initialise\n"); - return(-ENODEV); - - } - - CDEBUG(D_INFO, "This is the end of the gmnal init routine"); - - - return(0); -} - - -static void __exit -gmnal_unload(void) -{ - gmnal_fini(); - return; -} - - -module_init(gmnal_load); - -module_exit(gmnal_unload); - -MODULE_PARM(gmnal_small_msg_size, "i"); -MODULE_PARM(num_rx_threads, "i"); -MODULE_PARM(num_stxds, "i"); -MODULE_PARM(gm_port, "i"); - -MODULE_AUTHOR("Morgan Doyle"); - -MODULE_DESCRIPTION("A Portals kernel NAL for Myrinet GM."); - -MODULE_LICENSE("GPL"); diff --git a/lnet/klnds/gmlnd/gmlnd_utils.c b/lnet/klnds/gmlnd/gmlnd_utils.c deleted file mode 100644 index 6a52319..0000000 --- a/lnet/klnds/gmlnd/gmlnd_utils.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2003 Los Alamos National Laboratory (LANL) - * - * 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. - */ -/* - * All utilities required by lgmanl - */ - -#include "gmnal.h" - -/* - * Am I one of the gmnal rxthreads ? - */ -int -gmnal_is_rxthread(gmnal_data_t *nal_data) -{ - int i; - for (i=0; irxthread_pid[i] == current->pid) - return(1); - } - return(0); -} - - -/* - * Allocate tx descriptors/tokens (large and small) - * allocate a number of small tx buffers and register with GM - * so they are wired and set up for DMA. This is a costly operation. - * Also allocate a corrosponding descriptor to keep track of - * the buffer. - * Put all small descriptors on singly linked list to be available to send - * function. - * Allocate the rest of the available tx tokens for large messages. These will be - * used to do gm_gets in gmnal_copyiov - */ -int -gmnal_alloc_txd(gmnal_data_t *nal_data) -{ - int ntx= 0, nstx= 0, nrxt_stx= 0, - nltx= 0, i = 0; - gmnal_stxd_t *txd = NULL; - gmnal_ltxd_t *ltxd = NULL; - void *txbuffer = NULL; - - CDEBUG(D_TRACE, "gmnal_alloc_small tx\n"); - - GMNAL_GM_LOCK(nal_data); - /* - * total number of transmit tokens - */ - ntx = gm_num_send_tokens(nal_data->gm_port); - GMNAL_GM_UNLOCK(nal_data); - CDEBUG(D_INFO, "total number of send tokens available is [%d]\n", ntx); - - /* - * allocate a number for small sends - * num_stxds from gmnal_module.c - */ - nstx = num_stxds; - /* - * give that number plus 1 to the receive threads - */ - nrxt_stx = nstx + 1; - - /* - * give the rest for gm_gets - */ - nltx = ntx - (nrxt_stx + nstx); - if (nltx < 1) { - CDEBUG(D_ERROR, "No tokens available for large messages\n"); - return(GMNAL_STATUS_FAIL); - } - - - /* - * A semaphore is initialised with the - * number of transmit tokens available. - * To get a stxd, acquire the token semaphore. - * this decrements the available token count - * (if no tokens you block here, someone returning a - * stxd will release the semaphore and wake you) - * When token is obtained acquire the spinlock - * to manipulate the list - */ - GMNAL_TXD_TOKEN_INIT(nal_data, nstx); - GMNAL_TXD_LOCK_INIT(nal_data); - GMNAL_RXT_TXD_TOKEN_INIT(nal_data, nrxt_stx); - GMNAL_RXT_TXD_LOCK_INIT(nal_data); - GMNAL_LTXD_TOKEN_INIT(nal_data, nltx); - GMNAL_LTXD_LOCK_INIT(nal_data); - - for (i=0; i<=nstx; i++) { - PORTAL_ALLOC(txd, sizeof(gmnal_stxd_t)); - if (!txd) { - CDEBUG(D_ERROR, "Failed to malloc txd [%d]\n", i); - return(GMNAL_STATUS_NOMEM); - } - GMNAL_GM_LOCK(nal_data); - txbuffer = gm_dma_malloc(nal_data->gm_port, - GMNAL_SMALL_MSG_SIZE(nal_data)); - GMNAL_GM_UNLOCK(nal_data); - if (!txbuffer) { - CDEBUG(D_ERROR, "Failed to gm_dma_malloc txbuffer [%d]," - " size [%d]\n", i, - GMNAL_SMALL_MSG_SIZE(nal_data)); - PORTAL_FREE(txd, sizeof(gmnal_stxd_t)); - return(GMNAL_STATUS_FAIL); - } - txd->buffer = txbuffer; - txd->buffer_size = GMNAL_SMALL_MSG_SIZE(nal_data); - txd->gm_size = gm_min_size_for_length(txd->buffer_size); - txd->nal_data = (struct _gmnal_data_t*)nal_data; - txd->rxt = 0; - - txd->next = nal_data->stxd; - nal_data->stxd = txd; - CDEBUG(D_INFO, "Registered txd [%p] with buffer [%p], " - "size [%d]\n", txd, txd->buffer, txd->buffer_size); - } - - for (i=0; i<=nrxt_stx; i++) { - PORTAL_ALLOC(txd, sizeof(gmnal_stxd_t)); - if (!txd) { - CDEBUG(D_ERROR, "Failed to malloc txd [%d]\n", i); - return(GMNAL_STATUS_NOMEM); - } - GMNAL_GM_LOCK(nal_data); - txbuffer = gm_dma_malloc(nal_data->gm_port, - GMNAL_SMALL_MSG_SIZE(nal_data)); - GMNAL_GM_UNLOCK(nal_data); - if (!txbuffer) { - CDEBUG(D_ERROR, "Failed to gm_dma_malloc txbuffer [%d]," - " size [%d]\n", i, - GMNAL_SMALL_MSG_SIZE(nal_data)); - PORTAL_FREE(txd, sizeof(gmnal_stxd_t)); - return(GMNAL_STATUS_FAIL); - } - txd->buffer = txbuffer; - txd->buffer_size = GMNAL_SMALL_MSG_SIZE(nal_data); - txd->gm_size = gm_min_size_for_length(txd->buffer_size); - txd->nal_data = (struct _gmnal_data_t*)nal_data; - txd->rxt = 1; - - txd->next = nal_data->rxt_stxd; - nal_data->rxt_stxd = txd; - CDEBUG(D_INFO, "Registered txd [%p] with buffer [%p], " - "size [%d]\n", txd, txd->buffer, txd->buffer_size); - } - - /* - * string together large tokens - */ - for (i=0; i<=nltx ; i++) { - PORTAL_ALLOC(ltxd, sizeof(gmnal_ltxd_t)); - ltxd->next = nal_data->ltxd; - nal_data->ltxd = ltxd; - } - return(GMNAL_STATUS_OK); -} - -/* Free the list of wired and gm_registered small tx buffers and - * the tx descriptors that go along with them. - */ -void -gmnal_free_txd(gmnal_data_t *nal_data) -{ - gmnal_stxd_t *txd = nal_data->stxd, *_txd = NULL; - gmnal_ltxd_t *ltxd = NULL, *_ltxd = NULL; - - CDEBUG(D_TRACE, "gmnal_free_small tx\n"); - - while(txd) { - CDEBUG(D_INFO, "Freeing txd [%p] with buffer [%p], " - "size [%d]\n", txd, txd->buffer, txd->buffer_size); - _txd = txd; - txd = txd->next; - GMNAL_GM_LOCK(nal_data); - gm_dma_free(nal_data->gm_port, _txd->buffer); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(_txd, sizeof(gmnal_stxd_t)); - } - txd = nal_data->rxt_stxd; - while(txd) { - CDEBUG(D_INFO, "Freeing txd [%p] with buffer [%p], " - "size [%d]\n", txd, txd->buffer, txd->buffer_size); - _txd = txd; - txd = txd->next; - GMNAL_GM_LOCK(nal_data); - gm_dma_free(nal_data->gm_port, _txd->buffer); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(_txd, sizeof(gmnal_stxd_t)); - } - ltxd = nal_data->ltxd; - while(txd) { - _ltxd = ltxd; - ltxd = ltxd->next; - PORTAL_FREE(_ltxd, sizeof(gmnal_ltxd_t)); - } - - return; -} - - -/* - * Get a txd from the list - * This get us a wired and gm_registered small tx buffer. - * This implicitly gets us a send token also. - */ -gmnal_stxd_t * -gmnal_get_stxd(gmnal_data_t *nal_data, int block) -{ - - gmnal_stxd_t *txd = NULL; - pid_t pid = current->pid; - - - CDEBUG(D_TRACE, "gmnal_get_stxd nal_data [%p] block[%d] pid [%d]\n", - nal_data, block, pid); - - if (gmnal_is_rxthread(nal_data)) { - CDEBUG(D_INFO, "RXTHREAD Attempting to get token\n"); - GMNAL_RXT_TXD_GETTOKEN(nal_data); - GMNAL_RXT_TXD_LOCK(nal_data); - txd = nal_data->rxt_stxd; - nal_data->rxt_stxd = txd->next; - GMNAL_RXT_TXD_UNLOCK(nal_data); - CDEBUG(D_INFO, "RXTHREAD got [%p], head is [%p]\n", - txd, nal_data->rxt_stxd); - txd->kniov = 0; - txd->rxt = 1; - } else { - if (block) { - CDEBUG(D_INFO, "Attempting to get token\n"); - GMNAL_TXD_GETTOKEN(nal_data); - CDEBUG(D_PORTALS, "Got token\n"); - } else { - if (GMNAL_TXD_TRYGETTOKEN(nal_data)) { - CDEBUG(D_ERROR, "can't get token\n"); - return(NULL); - } - } - GMNAL_TXD_LOCK(nal_data); - txd = nal_data->stxd; - nal_data->stxd = txd->next; - GMNAL_TXD_UNLOCK(nal_data); - CDEBUG(D_INFO, "got [%p], head is [%p]\n", txd, - nal_data->stxd); - txd->kniov = 0; - } /* general txd get */ - return(txd); -} - -/* - * Return a txd to the list - */ -void -gmnal_return_stxd(gmnal_data_t *nal_data, gmnal_stxd_t *txd) -{ - CDEBUG(D_TRACE, "nal_data [%p], txd[%p] rxt[%d]\n", nal_data, - txd, txd->rxt); - - /* - * this transmit descriptor is - * for the rxthread - */ - if (txd->rxt) { - GMNAL_RXT_TXD_LOCK(nal_data); - txd->next = nal_data->rxt_stxd; - nal_data->rxt_stxd = txd; - GMNAL_RXT_TXD_UNLOCK(nal_data); - GMNAL_RXT_TXD_RETURNTOKEN(nal_data); - CDEBUG(D_INFO, "Returned stxd to rxthread list\n"); - } else { - GMNAL_TXD_LOCK(nal_data); - txd->next = nal_data->stxd; - nal_data->stxd = txd; - GMNAL_TXD_UNLOCK(nal_data); - GMNAL_TXD_RETURNTOKEN(nal_data); - CDEBUG(D_INFO, "Returned stxd to general list\n"); - } - return; -} - - -/* - * Get a large transmit descriptor from the free list - * This implicitly gets us a transmit token . - * always wait for one. - */ -gmnal_ltxd_t * -gmnal_get_ltxd(gmnal_data_t *nal_data) -{ - - gmnal_ltxd_t *ltxd = NULL; - - CDEBUG(D_TRACE, "nal_data [%p]\n", nal_data); - - GMNAL_LTXD_GETTOKEN(nal_data); - GMNAL_LTXD_LOCK(nal_data); - ltxd = nal_data->ltxd; - nal_data->ltxd = ltxd->next; - GMNAL_LTXD_UNLOCK(nal_data); - CDEBUG(D_INFO, "got [%p], head is [%p]\n", ltxd, nal_data->ltxd); - return(ltxd); -} - -/* - * Return an ltxd to the list - */ -void -gmnal_return_ltxd(gmnal_data_t *nal_data, gmnal_ltxd_t *ltxd) -{ - CDEBUG(D_TRACE, "nal_data [%p], ltxd[%p]\n", nal_data, ltxd); - - GMNAL_LTXD_LOCK(nal_data); - ltxd->next = nal_data->ltxd; - nal_data->ltxd = ltxd; - GMNAL_LTXD_UNLOCK(nal_data); - GMNAL_LTXD_RETURNTOKEN(nal_data); - return; -} -/* - * allocate a number of small rx buffers and register with GM - * so they are wired and set up for DMA. This is a costly operation. - * Also allocate a corrosponding descriptor to keep track of - * the buffer. - * Put all descriptors on singly linked list to be available to - * receive thread. - */ -int -gmnal_alloc_srxd(gmnal_data_t *nal_data) -{ - int nrx = 0, nsrx = 0, i = 0; - gmnal_srxd_t *rxd = NULL; - void *rxbuffer = NULL; - - CDEBUG(D_TRACE, "gmnal_alloc_small rx\n"); - - GMNAL_GM_LOCK(nal_data); - nrx = gm_num_receive_tokens(nal_data->gm_port); - GMNAL_GM_UNLOCK(nal_data); - CDEBUG(D_INFO, "total number of receive tokens available is [%d]\n", - nrx); - - nsrx = nrx/2; - nsrx = 12; - /* - * make the number of rxds twice our total - * number of stxds plus 1 - */ - nsrx = num_stxds*2 + 2; - - CDEBUG(D_INFO, "Allocated [%d] receive tokens to small messages\n", - nsrx); - - - GMNAL_GM_LOCK(nal_data); - nal_data->srxd_hash = gm_create_hash(gm_hash_compare_ptrs, - gm_hash_hash_ptr, 0, 0, nsrx, 0); - GMNAL_GM_UNLOCK(nal_data); - if (!nal_data->srxd_hash) { - CDEBUG(D_ERROR, "Failed to create hash table\n"); - return(GMNAL_STATUS_NOMEM); - } - - GMNAL_RXD_TOKEN_INIT(nal_data, nsrx); - GMNAL_RXD_LOCK_INIT(nal_data); - - for (i=0; i<=nsrx; i++) { - PORTAL_ALLOC(rxd, sizeof(gmnal_srxd_t)); - if (!rxd) { - CDEBUG(D_ERROR, "Failed to malloc rxd [%d]\n", i); - return(GMNAL_STATUS_NOMEM); - } -#if 0 - PORTAL_ALLOC(rxbuffer, GMNAL_SMALL_MSG_SIZE(nal_data)); - if (!rxbuffer) { - CDEBUG(D_ERROR, "Failed to malloc rxbuffer [%d], " - "size [%d]\n", i, - GMNAL_SMALL_MSG_SIZE(nal_data)); - PORTAL_FREE(rxd, sizeof(gmnal_srxd_t)); - return(GMNAL_STATUS_FAIL); - } - CDEBUG(D_NET, "Calling gm_register_memory with port [%p] " - "rxbuffer [%p], size [%d]\n", nal_data->gm_port, - rxbuffer, GMNAL_SMALL_MSG_SIZE(nal_data)); - GMNAL_GM_LOCK(nal_data); - gm_status = gm_register_memory(nal_data->gm_port, rxbuffer, - GMNAL_SMALL_MSG_SIZE(nal_data)); - GMNAL_GM_UNLOCK(nal_data); - if (gm_status != GM_SUCCESS) { - CDEBUG(D_ERROR, "gm_register_memory failed buffer [%p]," - " index [%d]\n", rxbuffer, i); - switch(gm_status) { - case(GM_FAILURE): - CDEBUG(D_ERROR, "GM_FAILURE\n"); - break; - case(GM_PERMISSION_DENIED): - CDEBUG(D_ERROR, "PERMISSION_DENIED\n"); - break; - case(GM_INVALID_PARAMETER): - CDEBUG(D_ERROR, "INVALID_PARAMETER\n"); - break; - default: - CDEBUG(D_ERROR, "Unknown error[%d]\n", - gm_status); - break; - - } - return(GMNAL_STATUS_FAIL); - } -#else - GMNAL_GM_LOCK(nal_data); - rxbuffer = gm_dma_malloc(nal_data->gm_port, - GMNAL_SMALL_MSG_SIZE(nal_data)); - GMNAL_GM_UNLOCK(nal_data); - if (!rxbuffer) { - CDEBUG(D_ERROR, "Failed to gm_dma_malloc rxbuffer [%d]," - " size [%d]\n", i, - GMNAL_SMALL_MSG_SIZE(nal_data)); - PORTAL_FREE(rxd, sizeof(gmnal_srxd_t)); - return(GMNAL_STATUS_FAIL); - } -#endif - - rxd->buffer = rxbuffer; - rxd->size = GMNAL_SMALL_MSG_SIZE(nal_data); - rxd->gmsize = gm_min_size_for_length(rxd->size); - - if (gm_hash_insert(nal_data->srxd_hash, - (void*)rxbuffer, (void*)rxd)) { - - CDEBUG(D_ERROR, "failed to create hash entry rxd[%p] " - "for rxbuffer[%p]\n", rxd, rxbuffer); - return(GMNAL_STATUS_FAIL); - } - - rxd->next = nal_data->srxd; - nal_data->srxd = rxd; - CDEBUG(D_INFO, "Registered rxd [%p] with buffer [%p], " - "size [%d]\n", rxd, rxd->buffer, rxd->size); - } - - return(GMNAL_STATUS_OK); -} - - - -/* Free the list of wired and gm_registered small rx buffers and the - * rx descriptors that go along with them. - */ -void -gmnal_free_srxd(gmnal_data_t *nal_data) -{ - gmnal_srxd_t *rxd = nal_data->srxd, *_rxd = NULL; - - CDEBUG(D_TRACE, "gmnal_free_small rx\n"); - - while(rxd) { - CDEBUG(D_INFO, "Freeing rxd [%p] buffer [%p], size [%d]\n", - rxd, rxd->buffer, rxd->size); - _rxd = rxd; - rxd = rxd->next; - -#if 0 - GMNAL_GM_LOCK(nal_data); - gm_deregister_memory(nal_data->gm_port, _rxd->buffer, - _rxd->size); - GMNAL_GM_UNLOCK(nal_data); - PORTAL_FREE(_rxd->buffer, GMNAL_SMALL_RXBUFFER_SIZE); -#else - GMNAL_GM_LOCK(nal_data); - gm_dma_free(nal_data->gm_port, _rxd->buffer); - GMNAL_GM_UNLOCK(nal_data); -#endif - PORTAL_FREE(_rxd, sizeof(gmnal_srxd_t)); - } - return; -} - - -/* - * Get a rxd from the free list - * This get us a wired and gm_registered small rx buffer. - * This implicitly gets us a receive token also. - */ -gmnal_srxd_t * -gmnal_get_srxd(gmnal_data_t *nal_data, int block) -{ - - gmnal_srxd_t *rxd = NULL; - CDEBUG(D_TRACE, "nal_data [%p] block [%d]\n", nal_data, block); - - if (block) { - GMNAL_RXD_GETTOKEN(nal_data); - } else { - if (GMNAL_RXD_TRYGETTOKEN(nal_data)) { - CDEBUG(D_INFO, "gmnal_get_srxd Can't get token\n"); - return(NULL); - } - } - GMNAL_RXD_LOCK(nal_data); - rxd = nal_data->srxd; - if (rxd) - nal_data->srxd = rxd->next; - GMNAL_RXD_UNLOCK(nal_data); - CDEBUG(D_INFO, "got [%p], head is [%p]\n", rxd, nal_data->srxd); - return(rxd); -} - -/* - * Return an rxd to the list - */ -void -gmnal_return_srxd(gmnal_data_t *nal_data, gmnal_srxd_t *rxd) -{ - CDEBUG(D_TRACE, "nal_data [%p], rxd[%p]\n", nal_data, rxd); - - GMNAL_RXD_LOCK(nal_data); - rxd->next = nal_data->srxd; - nal_data->srxd = rxd; - GMNAL_RXD_UNLOCK(nal_data); - GMNAL_RXD_RETURNTOKEN(nal_data); - return; -} - -/* - * Given a pointer to a srxd find - * the relevant descriptor for it - * This is done by searching a hash - * list that is created when the srxd's - * are created - */ -gmnal_srxd_t * -gmnal_rxbuffer_to_srxd(gmnal_data_t *nal_data, void *rxbuffer) -{ - gmnal_srxd_t *srxd = NULL; - CDEBUG(D_TRACE, "nal_data [%p], rxbuffer [%p]\n", nal_data, rxbuffer); - srxd = gm_hash_find(nal_data->srxd_hash, rxbuffer); - CDEBUG(D_INFO, "srxd is [%p]\n", srxd); - return(srxd); -} - - -void -gmnal_stop_rxthread(gmnal_data_t *nal_data) -{ - int delay = 30; - - - - CDEBUG(D_TRACE, "Attempting to stop rxthread nal_data [%p]\n", - nal_data); - - nal_data->rxthread_stop_flag = GMNAL_THREAD_STOP; - - gmnal_remove_rxtwe(nal_data); - /* - * kick the thread - */ - up(&nal_data->rxtwe_wait); - - while(nal_data->rxthread_flag != GMNAL_THREAD_RESET && delay--) { - CDEBUG(D_INFO, "gmnal_stop_rxthread sleeping\n"); - gmnal_yield(1); - up(&nal_data->rxtwe_wait); - } - - if (nal_data->rxthread_flag != GMNAL_THREAD_RESET) { - CDEBUG(D_ERROR, "I don't know how to wake the thread\n"); - } else { - CDEBUG(D_INFO, "rx thread seems to have stopped\n"); - } -} - -void -gmnal_stop_ctthread(gmnal_data_t *nal_data) -{ - int delay = 15; - - - - CDEBUG(D_TRACE, "Attempting to stop ctthread nal_data [%p]\n", - nal_data); - - nal_data->ctthread_flag = GMNAL_THREAD_STOP; - GMNAL_GM_LOCK(nal_data); - gm_set_alarm(nal_data->gm_port, &nal_data->ctthread_alarm, 10, - NULL, NULL); - GMNAL_GM_UNLOCK(nal_data); - - while(nal_data->ctthread_flag == GMNAL_THREAD_STOP && delay--) { - CDEBUG(D_INFO, "gmnal_stop_ctthread sleeping\n"); - gmnal_yield(1); - } - - if (nal_data->ctthread_flag == GMNAL_THREAD_STOP) { - CDEBUG(D_ERROR, "I DON'T KNOW HOW TO WAKE THE THREAD\n"); - } else { - CDEBUG(D_INFO, "CT THREAD SEEMS TO HAVE STOPPED\n"); - } -} - - - -char * -gmnal_gm_error(gm_status_t status) -{ - return(gm_strerror(status)); - - switch(status) { - case(GM_SUCCESS): - return("SUCCESS"); - case(GM_FAILURE): - return("FAILURE"); - case(GM_INPUT_BUFFER_TOO_SMALL): - return("INPUT_BUFFER_TOO_SMALL"); - case(GM_OUTPUT_BUFFER_TOO_SMALL): - return("OUTPUT_BUFFER_TOO_SMALL"); - case(GM_TRY_AGAIN ): - return("TRY_AGAIN"); - case(GM_BUSY): - return("BUSY"); - case(GM_MEMORY_FAULT): - return("MEMORY_FAULT"); - case(GM_INTERRUPTED): - return("INTERRUPTED"); - case(GM_INVALID_PARAMETER): - return("INVALID_PARAMETER"); - case(GM_OUT_OF_MEMORY): - return("OUT_OF_MEMORY"); - case(GM_INVALID_COMMAND): - return("INVALID_COMMAND"); - case(GM_PERMISSION_DENIED): - return("PERMISSION_DENIED"); - case(GM_INTERNAL_ERROR): - return("INTERNAL_ERROR"); - case(GM_UNATTACHED): - return("UNATTACHED"); - case(GM_UNSUPPORTED_DEVICE): - return("UNSUPPORTED_DEVICE"); - case(GM_SEND_TIMED_OUT): - return("GM_SEND_TIMEDOUT"); - case(GM_SEND_REJECTED): - return("GM_SEND_REJECTED"); - case(GM_SEND_TARGET_PORT_CLOSED): - return("GM_SEND_TARGET_PORT_CLOSED"); - case(GM_SEND_TARGET_NODE_UNREACHABLE): - return("GM_SEND_TARGET_NODE_UNREACHABLE"); - case(GM_SEND_DROPPED): - return("GM_SEND_DROPPED"); - case(GM_SEND_PORT_CLOSED): - return("GM_SEND_PORT_CLOSED"); - case(GM_NODE_ID_NOT_YET_SET): - return("GM_NODE_ID_NOT_YET_SET"); - case(GM_STILL_SHUTTING_DOWN): - return("GM_STILL_SHUTTING_DOWN"); - case(GM_CLONE_BUSY): - return("GM_CLONE_BUSY"); - case(GM_NO_SUCH_DEVICE): - return("GM_NO_SUCH_DEVICE"); - case(GM_ABORTED): - return("GM_ABORTED"); - case(GM_INCOMPATIBLE_LIB_AND_DRIVER): - return("GM_INCOMPATIBLE_LIB_AND_DRIVER"); - case(GM_UNTRANSLATED_SYSTEM_ERROR): - return("GM_UNTRANSLATED_SYSTEM_ERROR"); - case(GM_ACCESS_DENIED): - return("GM_ACCESS_DENIED"); - - -/* - * These ones are in the docs but aren't in the header file - case(GM_DEV_NOT_FOUND): - return("GM_DEV_NOT_FOUND"); - case(GM_INVALID_PORT_NUMBER): - return("GM_INVALID_PORT_NUMBER"); - case(GM_UC_ERROR): - return("GM_US_ERROR"); - case(GM_PAGE_TABLE_FULL): - return("GM_PAGE_TABLE_FULL"); - case(GM_MINOR_OVERFLOW): - return("GM_MINOR_OVERFLOW"); - case(GM_SEND_ORPHANED): - return("GM_SEND_ORPHANED"); - case(GM_HARDWARE_FAULT): - return("GM_HARDWARE_FAULT"); - case(GM_DATA_CORRUPTED): - return("GM_DATA_CORRUPTED"); - case(GM_TIMED_OUT): - return("GM_TIMED_OUT"); - case(GM_USER_ERROR): - return("GM_USER_ERROR"); - case(GM_NO_MATCH): - return("GM_NOMATCH"); - case(GM_NOT_SUPPORTED_IN_KERNEL): - return("GM_NOT_SUPPORTED_IN_KERNEL"); - case(GM_NOT_SUPPORTED_ON_ARCH): - return("GM_NOT_SUPPORTED_ON_ARCH"); - case(GM_PTE_REF_CNT_OVERFLOW): - return("GM_PTR_REF_CNT_OVERFLOW"); - case(GM_NO_DRIVER_SUPPORT): - return("GM_NO_DRIVER_SUPPORT"); - case(GM_FIRMWARE_NOT_RUNNING): - return("GM_FIRMWARE_NOT_RUNNING"); - - * These ones are in the docs but aren't in the header file - */ - default: - return("UNKNOWN GM ERROR CODE"); - } -} - - -char * -gmnal_rxevent(gm_recv_event_t *ev) -{ - short event; - event = GM_RECV_EVENT_TYPE(ev); - switch(event) { - case(GM_NO_RECV_EVENT): - return("GM_NO_RECV_EVENT"); - case(GM_SENDS_FAILED_EVENT): - return("GM_SEND_FAILED_EVENT"); - case(GM_ALARM_EVENT): - return("GM_ALARM_EVENT"); - case(GM_SENT_EVENT): - return("GM_SENT_EVENT"); - case(_GM_SLEEP_EVENT): - return("_GM_SLEEP_EVENT"); - case(GM_RAW_RECV_EVENT): - return("GM_RAW_RECV_EVENT"); - case(GM_BAD_SEND_DETECTED_EVENT): - return("GM_BAD_SEND_DETECTED_EVENT"); - case(GM_SEND_TOKEN_VIOLATION_EVENT): - return("GM_SEND_TOKEN_VIOLATION_EVENT"); - case(GM_RECV_TOKEN_VIOLATION_EVENT): - return("GM_RECV_TOKEN_VIOLATION_EVENT"); - case(GM_BAD_RECV_TOKEN_EVENT): - return("GM_BAD_RECV_TOKEN_EVENT"); - case(GM_ALARM_VIOLATION_EVENT): - return("GM_ALARM_VIOLATION_EVENT"); - case(GM_RECV_EVENT): - return("GM_RECV_EVENT"); - case(GM_HIGH_RECV_EVENT): - return("GM_HIGH_RECV_EVENT"); - case(GM_PEER_RECV_EVENT): - return("GM_PEER_RECV_EVENT"); - case(GM_HIGH_PEER_RECV_EVENT): - return("GM_HIGH_PEER_RECV_EVENT"); - case(GM_FAST_RECV_EVENT): - return("GM_FAST_RECV_EVENT"); - case(GM_FAST_HIGH_RECV_EVENT): - return("GM_FAST_HIGH_RECV_EVENT"); - case(GM_FAST_PEER_RECV_EVENT): - return("GM_FAST_PEER_RECV_EVENT"); - case(GM_FAST_HIGH_PEER_RECV_EVENT): - return("GM_FAST_HIGH_PEER_RECV_EVENT"); - case(GM_REJECTED_SEND_EVENT): - return("GM_REJECTED_SEND_EVENT"); - case(GM_ORPHANED_SEND_EVENT): - return("GM_ORPHANED_SEND_EVENT"); - case(GM_BAD_RESEND_DETECTED_EVENT): - return("GM_BAD_RESEND_DETETED_EVENT"); - case(GM_DROPPED_SEND_EVENT): - return("GM_DROPPED_SEND_EVENT"); - case(GM_BAD_SEND_VMA_EVENT): - return("GM_BAD_SEND_VMA_EVENT"); - case(GM_BAD_RECV_VMA_EVENT): - return("GM_BAD_RECV_VMA_EVENT"); - case(_GM_FLUSHED_ALARM_EVENT): - return("GM_FLUSHED_ALARM_EVENT"); - case(GM_SENT_TOKENS_EVENT): - return("GM_SENT_TOKENS_EVENTS"); - case(GM_IGNORE_RECV_EVENT): - return("GM_IGNORE_RECV_EVENT"); - case(GM_ETHERNET_RECV_EVENT): - return("GM_ETHERNET_RECV_EVENT"); - case(GM_NEW_NO_RECV_EVENT): - return("GM_NEW_NO_RECV_EVENT"); - case(GM_NEW_SENDS_FAILED_EVENT): - return("GM_NEW_SENDS_FAILED_EVENT"); - case(GM_NEW_ALARM_EVENT): - return("GM_NEW_ALARM_EVENT"); - case(GM_NEW_SENT_EVENT): - return("GM_NEW_SENT_EVENT"); - case(_GM_NEW_SLEEP_EVENT): - return("GM_NEW_SLEEP_EVENT"); - case(GM_NEW_RAW_RECV_EVENT): - return("GM_NEW_RAW_RECV_EVENT"); - case(GM_NEW_BAD_SEND_DETECTED_EVENT): - return("GM_NEW_BAD_SEND_DETECTED_EVENT"); - case(GM_NEW_SEND_TOKEN_VIOLATION_EVENT): - return("GM_NEW_SEND_TOKEN_VIOLATION_EVENT"); - case(GM_NEW_RECV_TOKEN_VIOLATION_EVENT): - return("GM_NEW_RECV_TOKEN_VIOLATION_EVENT"); - case(GM_NEW_BAD_RECV_TOKEN_EVENT): - return("GM_NEW_BAD_RECV_TOKEN_EVENT"); - case(GM_NEW_ALARM_VIOLATION_EVENT): - return("GM_NEW_ALARM_VIOLATION_EVENT"); - case(GM_NEW_RECV_EVENT): - return("GM_NEW_RECV_EVENT"); - case(GM_NEW_HIGH_RECV_EVENT): - return("GM_NEW_HIGH_RECV_EVENT"); - case(GM_NEW_PEER_RECV_EVENT): - return("GM_NEW_PEER_RECV_EVENT"); - case(GM_NEW_HIGH_PEER_RECV_EVENT): - return("GM_NEW_HIGH_PEER_RECV_EVENT"); - case(GM_NEW_FAST_RECV_EVENT): - return("GM_NEW_FAST_RECV_EVENT"); - case(GM_NEW_FAST_HIGH_RECV_EVENT): - return("GM_NEW_FAST_HIGH_RECV_EVENT"); - case(GM_NEW_FAST_PEER_RECV_EVENT): - return("GM_NEW_FAST_PEER_RECV_EVENT"); - case(GM_NEW_FAST_HIGH_PEER_RECV_EVENT): - return("GM_NEW_FAST_HIGH_PEER_RECV_EVENT"); - case(GM_NEW_REJECTED_SEND_EVENT): - return("GM_NEW_REJECTED_SEND_EVENT"); - case(GM_NEW_ORPHANED_SEND_EVENT): - return("GM_NEW_ORPHANED_SEND_EVENT"); - case(_GM_NEW_PUT_NOTIFICATION_EVENT): - return("_GM_NEW_PUT_NOTIFICATION_EVENT"); - case(GM_NEW_FREE_SEND_TOKEN_EVENT): - return("GM_NEW_FREE_SEND_TOKEN_EVENT"); - case(GM_NEW_FREE_HIGH_SEND_TOKEN_EVENT): - return("GM_NEW_FREE_HIGH_SEND_TOKEN_EVENT"); - case(GM_NEW_BAD_RESEND_DETECTED_EVENT): - return("GM_NEW_BAD_RESEND_DETECTED_EVENT"); - case(GM_NEW_DROPPED_SEND_EVENT): - return("GM_NEW_DROPPED_SEND_EVENT"); - case(GM_NEW_BAD_SEND_VMA_EVENT): - return("GM_NEW_BAD_SEND_VMA_EVENT"); - case(GM_NEW_BAD_RECV_VMA_EVENT): - return("GM_NEW_BAD_RECV_VMA_EVENT"); - case(_GM_NEW_FLUSHED_ALARM_EVENT): - return("GM_NEW_FLUSHED_ALARM_EVENT"); - case(GM_NEW_SENT_TOKENS_EVENT): - return("GM_NEW_SENT_TOKENS_EVENT"); - case(GM_NEW_IGNORE_RECV_EVENT): - return("GM_NEW_IGNORE_RECV_EVENT"); - case(GM_NEW_ETHERNET_RECV_EVENT): - return("GM_NEW_ETHERNET_RECV_EVENT"); - default: - return("Unknown Recv event"); -#if 0 - case(/* _GM_PUT_NOTIFICATION_EVENT */ - case(/* GM_FREE_SEND_TOKEN_EVENT */ - case(/* GM_FREE_HIGH_SEND_TOKEN_EVENT */ -#endif - } -} - - -void -gmnal_yield(int delay) -{ - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(delay); -} - -int -gmnal_is_small_msg(gmnal_data_t *nal_data, int niov, struct iovec *iov, - int len) -{ - - CDEBUG(D_TRACE, "len [%d] limit[%d]\n", len, - GMNAL_SMALL_MSG_SIZE(nal_data)); - - if ((len + sizeof(ptl_hdr_t) + sizeof(gmnal_msghdr_t)) - < GMNAL_SMALL_MSG_SIZE(nal_data)) { - - CDEBUG(D_INFO, "Yep, small message\n"); - return(1); - } else { - CDEBUG(D_ERROR, "No, not small message\n"); - /* - * could be made up of lots of little ones ! - */ - return(0); - } - -} - -/* - * extract info from the receive event. - * Have to do this before the next call to gm_receive - * Deal with all endian stuff here. - * Then stick work entry on list where rxthreads - * can get it to complete the receive - */ -int -gmnal_add_rxtwe(gmnal_data_t *nal_data, gm_recv_t *recv) -{ - gmnal_rxtwe_t *we = NULL; - - CDEBUG(D_NET, "adding entry to list\n"); - - PORTAL_ALLOC(we, sizeof(gmnal_rxtwe_t)); - if (!we) { - CDEBUG(D_ERROR, "failed to malloc\n"); - return(GMNAL_STATUS_FAIL); - } - we->buffer = gm_ntohp(recv->buffer); - we->snode = (int)gm_ntoh_u16(recv->sender_node_id); - we->sport = (int)gm_ntoh_u8(recv->sender_port_id); - we->type = (int)gm_ntoh_u8(recv->type); - we->length = (int)gm_ntohl(recv->length); - - spin_lock(&nal_data->rxtwe_lock); - if (nal_data->rxtwe_tail) { - nal_data->rxtwe_tail->next = we; - } else { - nal_data->rxtwe_head = we; - nal_data->rxtwe_tail = we; - } - nal_data->rxtwe_tail = we; - spin_unlock(&nal_data->rxtwe_lock); - - up(&nal_data->rxtwe_wait); - return(GMNAL_STATUS_OK); -} - -void -gmnal_remove_rxtwe(gmnal_data_t *nal_data) -{ - gmnal_rxtwe_t *_we, *we = nal_data->rxtwe_head; - - CDEBUG(D_NET, "removing all work list entries\n"); - - spin_lock(&nal_data->rxtwe_lock); - CDEBUG(D_NET, "Got lock\n"); - while (we) { - _we = we; - we = we->next; - PORTAL_FREE(_we, sizeof(gmnal_rxtwe_t)); - } - spin_unlock(&nal_data->rxtwe_lock); - nal_data->rxtwe_head = NULL; - nal_data->rxtwe_tail = NULL; -} - -gmnal_rxtwe_t * -gmnal_get_rxtwe(gmnal_data_t *nal_data) -{ - gmnal_rxtwe_t *we = NULL; - - CDEBUG(D_NET, "Getting entry to list\n"); - - do { - down(&nal_data->rxtwe_wait); - if (nal_data->rxthread_stop_flag == GMNAL_THREAD_STOP) { - /* - * time to stop - * TO DO some one free the work entries - */ - return(NULL); - } - spin_lock(&nal_data->rxtwe_lock); - if (nal_data->rxtwe_head) { - CDEBUG(D_INFO, "Got a work entry\n"); - we = nal_data->rxtwe_head; - nal_data->rxtwe_head = we->next; - if (!nal_data->rxtwe_head) - nal_data->rxtwe_tail = NULL; - } else { - CDEBUG(D_WARNING, "woken but no work\n"); - } - spin_unlock(&nal_data->rxtwe_lock); - } while (!we); - - CDEBUG(D_INFO, "Returning we[%p]\n", we); - return(we); -} - - -/* - * Start the caretaker thread and a number of receiver threads - * The caretaker thread gets events from the gm library. - * It passes receive events to the receiver threads via a work list. - * It processes other events itself in gm_unknown. These will be - * callback events or sleeps. - */ -int -gmnal_start_kernel_threads(gmnal_data_t *nal_data) -{ - - int threads = 0; - /* - * the alarm is used to wake the caretaker thread from - * gm_unknown call (sleeping) to exit it. - */ - CDEBUG(D_NET, "Initializing caretaker thread alarm and flag\n"); - gm_initialize_alarm(&nal_data->ctthread_alarm); - nal_data->ctthread_flag = GMNAL_THREAD_RESET; - - - CDEBUG(D_INFO, "Starting caretaker thread\n"); - nal_data->ctthread_pid = - kernel_thread(gmnal_ct_thread, (void*)nal_data, 0); - if (nal_data->ctthread_pid <= 0) { - CDEBUG(D_ERROR, "Caretaker thread failed to start\n"); - return(GMNAL_STATUS_FAIL); - } - - while (nal_data->rxthread_flag != GMNAL_THREAD_RESET) { - gmnal_yield(1); - CDEBUG(D_INFO, "Waiting for caretaker thread signs of life\n"); - } - - CDEBUG(D_INFO, "caretaker thread has started\n"); - - - /* - * Now start a number of receiver threads - * these treads get work to do from the caretaker (ct) thread - */ - nal_data->rxthread_flag = GMNAL_THREAD_RESET; - nal_data->rxthread_stop_flag = GMNAL_THREAD_RESET; - - for (threads=0; threadsrxthread_pid[threads] = -1; - spin_lock_init(&nal_data->rxtwe_lock); - spin_lock_init(&nal_data->rxthread_flag_lock); - sema_init(&nal_data->rxtwe_wait, 0); - nal_data->rxtwe_head = NULL; - nal_data->rxtwe_tail = NULL; - /* - * If the default number of receive threades isn't - * modified at load time, then start one thread per cpu - */ - if (num_rx_threads == -1) - num_rx_threads = smp_num_cpus; - CDEBUG(D_INFO, "Starting [%d] receive threads\n", num_rx_threads); - for (threads=0; threadsrxthread_pid[threads] = - kernel_thread(gmnal_rx_thread, (void*)nal_data, 0); - if (nal_data->rxthread_pid[threads] <= 0) { - CDEBUG(D_ERROR, "Receive thread failed to start\n"); - gmnal_stop_rxthread(nal_data); - gmnal_stop_ctthread(nal_data); - return(GMNAL_STATUS_FAIL); - } - } - - for (;;) { - spin_lock(&nal_data->rxthread_flag_lock); - if (nal_data->rxthread_flag == GMNAL_RXTHREADS_STARTED) { - spin_unlock(&nal_data->rxthread_flag_lock); - break; - } - spin_unlock(&nal_data->rxthread_flag_lock); - gmnal_yield(1); - } - - CDEBUG(D_INFO, "receive threads seem to have started\n"); - - return(GMNAL_STATUS_OK); -} diff --git a/lnet/klnds/iiblnd/.cvsignore b/lnet/klnds/iiblnd/.cvsignore deleted file mode 100644 index 5ed596b..0000000 --- a/lnet/klnds/iiblnd/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/klnds/iiblnd/Makefile.in b/lnet/klnds/iiblnd/Makefile.in deleted file mode 100644 index e7934e2..0000000 --- a/lnet/klnds/iiblnd/Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -MODULES := kiibnal -kiibnal-objs := iibnal.o iibnal_cb.o - -EXTRA_POST_CFLAGS := @IIBCPPFLAGS@ - -@INCLUDE_RULES@ diff --git a/lnet/klnds/iiblnd/Makefile.mk b/lnet/klnds/iiblnd/Makefile.mk deleted file mode 100644 index 0459a20..0000000 --- a/lnet/klnds/iiblnd/Makefile.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include $(src)/../../Kernelenv - -obj-y += kiibnal.o -kiibnal-objs := iibnal.o iibnal_cb.o - diff --git a/lnet/klnds/iiblnd/autoMakefile.am b/lnet/klnds/iiblnd/autoMakefile.am deleted file mode 100644 index 251df66..0000000 --- a/lnet/klnds/iiblnd/autoMakefile.am +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if !CRAY_PORTALS -if BUILD_IIBNAL -modulenet_DATA = kiibnal$(KMODEXT) -endif -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(kiibnal-objs:%.o=%.c) iibnal.h diff --git a/lnet/klnds/iiblnd/iiblnd.c b/lnet/klnds/iiblnd/iiblnd.c deleted file mode 100644 index 09908c9..0000000 --- a/lnet/klnds/iiblnd/iiblnd.c +++ /dev/null @@ -1,1713 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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. - * - */ - -#include "iibnal.h" - -nal_t kibnal_api; -ptl_handle_ni_t kibnal_ni; -kib_tunables_t kibnal_tunables; - -kib_data_t kibnal_data = { - .kib_service_id = IBNAL_SERVICE_NUMBER, -}; - -#ifdef CONFIG_SYSCTL -#define IBNAL_SYSCTL 202 - -#define IBNAL_SYSCTL_TIMEOUT 1 - -static ctl_table kibnal_ctl_table[] = { - {IBNAL_SYSCTL_TIMEOUT, "timeout", - &kibnal_tunables.kib_io_timeout, sizeof (int), - 0644, NULL, &proc_dointvec}, - { 0 } -}; - -static ctl_table kibnal_top_ctl_table[] = { - {IBNAL_SYSCTL, "iibnal", NULL, 0, 0555, kibnal_ctl_table}, - { 0 } -}; -#endif - -#ifdef unused -void -print_service(IB_SERVICE_RECORD *service, char *tag, int rc) -{ - char name[32]; - - if (service == NULL) - { - CWARN("tag : %s\n" - "status : %d (NULL)\n", tag, rc); - return; - } - strncpy (name, service->ServiceName, sizeof(name)-1); - name[sizeof(name)-1] = 0; - - CWARN("tag : %s\n" - "status : %d\n" - "service id: "LPX64"\n" - "name : %s\n" - "NID : "LPX64"\n", tag, rc, - service->RID.ServiceID, name, - *kibnal_service_nid_field(service)); -} -#endif - -static void -kibnal_service_setunset_done (void *arg, FABRIC_OPERATION_DATA *fod, - FSTATUS frc, uint32 madrc) -{ - *(FSTATUS *)arg = frc; - up (&kibnal_data.kib_nid_signal); -} - -#if IBNAL_CHECK_ADVERT -static void -kibnal_service_query_done (void *arg, QUERY *qry, - QUERY_RESULT_VALUES *qry_result) -{ - FSTATUS frc = qry_result->Status; - - if (frc != FSUCCESS && - qry_result->ResultDataSize == 0) - frc = FERROR; - - *(FSTATUS *)arg = frc; - up (&kibnal_data.kib_nid_signal); -} - -static void -kibnal_check_advert (void) -{ - QUERY *qry; - IB_SERVICE_RECORD *svc; - FSTATUS frc; - FSTATUS frc2; - - PORTAL_ALLOC(qry, sizeof(*qry)); - if (qry == NULL) - return; - - memset (qry, 0, sizeof(*qry)); - qry->InputType = InputTypeServiceRecord; - qry->OutputType = OutputTypeServiceRecord; - qry->InputValue.ServiceRecordValue.ComponentMask = KIBNAL_SERVICE_KEY_MASK; - svc = &qry->InputValue.ServiceRecordValue.ServiceRecord; - kibnal_set_service_keys(svc, kibnal_data.kib_nid); - - frc = iibt_sd_query_port_fabric_information(kibnal_data.kib_sd, - kibnal_data.kib_port_guid, - qry, - kibnal_service_query_done, - NULL, &frc2); - if (frc != FSUCCESS && frc != FPENDING) { - CERROR ("Immediate error %d checking SM service\n", frc); - } else { - down (&kibnal_data.kib_nid_signal); - frc = frc2; - - if (frc != 0) - CERROR ("Error %d checking SM service\n", rc); - } - - return (rc); -} -#endif - -static void fill_fod(FABRIC_OPERATION_DATA *fod, FABRIC_OPERATION_TYPE type) -{ - IB_SERVICE_RECORD *svc; - - memset (fod, 0, sizeof(*fod)); - fod->Type = type; - - svc = &fod->Value.ServiceRecordValue.ServiceRecord; - svc->RID.ServiceID = kibnal_data.kib_service_id; - svc->RID.ServiceGID.Type.Global.InterfaceID = kibnal_data.kib_port_guid; - svc->RID.ServiceGID.Type.Global.SubnetPrefix = DEFAULT_SUBNET_PREFIX; - svc->RID.ServiceP_Key = kibnal_data.kib_port_pkey; - svc->ServiceLease = 0xffffffff; - - kibnal_set_service_keys(svc, kibnal_data.kib_nid); -} - -static int -kibnal_advertise (void) -{ - FABRIC_OPERATION_DATA *fod; - IB_SERVICE_RECORD *svc; - FSTATUS frc; - FSTATUS frc2; - - LASSERT (kibnal_data.kib_nid != PTL_NID_ANY); - - PORTAL_ALLOC(fod, sizeof(*fod)); - if (fod == NULL) - return (-ENOMEM); - - fill_fod(fod, FabOpSetServiceRecord); - svc = &fod->Value.ServiceRecordValue.ServiceRecord; - - CDEBUG(D_NET, "Advertising service id "LPX64" %s:"LPX64"\n", - svc->RID.ServiceID, - svc->ServiceName, *kibnal_service_nid_field(svc)); - - frc = iibt_sd_port_fabric_operation(kibnal_data.kib_sd, - kibnal_data.kib_port_guid, - fod, kibnal_service_setunset_done, - NULL, &frc2); - - if (frc != FSUCCESS && frc != FPENDING) { - CERROR ("Immediate error %d advertising NID "LPX64"\n", - frc, kibnal_data.kib_nid); - goto out; - } - - down (&kibnal_data.kib_nid_signal); - - frc = frc2; - if (frc != FSUCCESS) - CERROR ("Error %d advertising BUD "LPX64"\n", - frc, kibnal_data.kib_nid); -out: - PORTAL_FREE(fod, sizeof(*fod)); - return (frc == FSUCCESS) ? 0 : -EINVAL; -} - -static void -kibnal_unadvertise (int expect_success) -{ - FABRIC_OPERATION_DATA *fod; - IB_SERVICE_RECORD *svc; - FSTATUS frc; - FSTATUS frc2; - - LASSERT (kibnal_data.kib_nid != PTL_NID_ANY); - - PORTAL_ALLOC(fod, sizeof(*fod)); - if (fod == NULL) - return; - - fill_fod(fod, FabOpDeleteServiceRecord); - svc = &fod->Value.ServiceRecordValue.ServiceRecord; - - CDEBUG(D_NET, "Unadvertising service %s:"LPX64"\n", - svc->ServiceName, *kibnal_service_nid_field(svc)); - - frc = iibt_sd_port_fabric_operation(kibnal_data.kib_sd, - kibnal_data.kib_port_guid, - fod, kibnal_service_setunset_done, - NULL, &frc2); - - if (frc != FSUCCESS && frc != FPENDING) { - CERROR ("Immediate error %d unadvertising NID "LPX64"\n", - frc, kibnal_data.kib_nid); - goto out; - } - - down (&kibnal_data.kib_nid_signal); - - if ((frc2 == FSUCCESS) == !!expect_success) - goto out; - - if (expect_success) - CERROR("Error %d unadvertising NID "LPX64"\n", - frc2, kibnal_data.kib_nid); - else - CWARN("Removed conflicting NID "LPX64"\n", - kibnal_data.kib_nid); - out: - PORTAL_FREE(fod, sizeof(*fod)); -} - -static int -kibnal_set_mynid(ptl_nid_t nid) -{ - struct timeval tv; - lib_ni_t *ni = &kibnal_lib.libnal_ni; - int rc; - FSTATUS frc; - - CDEBUG(D_IOCTL, "setting mynid to "LPX64" (old nid="LPX64")\n", - nid, ni->ni_pid.nid); - - do_gettimeofday(&tv); - - down (&kibnal_data.kib_nid_mutex); - - if (nid == kibnal_data.kib_nid) { - /* no change of NID */ - up (&kibnal_data.kib_nid_mutex); - return (0); - } - - CDEBUG(D_NET, "NID "LPX64"("LPX64")\n", - kibnal_data.kib_nid, nid); - - if (kibnal_data.kib_nid != PTL_NID_ANY) { - - kibnal_unadvertise (1); - - frc = iibt_cm_cancel(kibnal_data.kib_cep); - if (frc != FSUCCESS && frc != FPENDING) - CERROR ("Error %d stopping listener\n", frc); - - frc = iibt_cm_destroy_cep(kibnal_data.kib_cep); - if (frc != FSUCCESS) - CERROR ("Error %d destroying CEP\n", frc); - - kibnal_data.kib_cep = NULL; - } - - kibnal_data.kib_nid = ni->ni_pid.nid = nid; - kibnal_data.kib_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; - - /* Delete all existing peers and their connections after new - * NID/incarnation set to ensure no old connections in our brave - * new world. */ - kibnal_del_peer (PTL_NID_ANY, 0); - - if (kibnal_data.kib_nid == PTL_NID_ANY) { - /* No new NID to install */ - up (&kibnal_data.kib_nid_mutex); - return (0); - } - - /* remove any previous advert (crashed node etc) */ - kibnal_unadvertise(0); - - kibnal_data.kib_cep = iibt_cm_create_cep(CM_RC_TYPE); - if (kibnal_data.kib_cep == NULL) { - CERROR ("Can't create CEP\n"); - rc = -ENOMEM; - } else { - CM_LISTEN_INFO info; - memset (&info, 0, sizeof(info)); - info.ListenAddr.EndPt.SID = kibnal_data.kib_service_id; - - frc = iibt_cm_listen(kibnal_data.kib_cep, &info, - kibnal_listen_callback, NULL); - if (frc != FSUCCESS && frc != FPENDING) { - CERROR ("iibt_cm_listen error: %d\n", frc); - rc = -EINVAL; - } else { - rc = 0; - } - } - - if (rc == 0) { - rc = kibnal_advertise(); - if (rc == 0) { -#if IBNAL_CHECK_ADVERT - kibnal_check_advert(); -#endif - up (&kibnal_data.kib_nid_mutex); - return (0); - } - - iibt_cm_cancel (kibnal_data.kib_cep); - iibt_cm_destroy_cep (kibnal_data.kib_cep); - /* remove any peers that sprung up while I failed to - * advertise myself */ - kibnal_del_peer (PTL_NID_ANY, 0); - } - - kibnal_data.kib_nid = PTL_NID_ANY; - up (&kibnal_data.kib_nid_mutex); - return (rc); -} - -kib_peer_t * -kibnal_create_peer (ptl_nid_t nid) -{ - kib_peer_t *peer; - - LASSERT (nid != PTL_NID_ANY); - - PORTAL_ALLOC (peer, sizeof (*peer)); - if (peer == NULL) - return (NULL); - - memset(peer, 0, sizeof(*peer)); /* zero flags etc */ - - peer->ibp_nid = nid; - atomic_set (&peer->ibp_refcount, 1); /* 1 ref for caller */ - - INIT_LIST_HEAD (&peer->ibp_list); /* not in the peer table yet */ - INIT_LIST_HEAD (&peer->ibp_conns); - INIT_LIST_HEAD (&peer->ibp_tx_queue); - - peer->ibp_reconnect_time = jiffies; - peer->ibp_reconnect_interval = IBNAL_MIN_RECONNECT_INTERVAL; - - atomic_inc (&kibnal_data.kib_npeers); - return (peer); -} - -void -kibnal_destroy_peer (kib_peer_t *peer) -{ - - LASSERT (atomic_read (&peer->ibp_refcount) == 0); - LASSERT (peer->ibp_persistence == 0); - LASSERT (!kibnal_peer_active(peer)); - LASSERT (peer->ibp_connecting == 0); - LASSERT (list_empty (&peer->ibp_conns)); - LASSERT (list_empty (&peer->ibp_tx_queue)); - - PORTAL_FREE (peer, sizeof (*peer)); - - /* NB a peer's connections keep a reference on their peer until - * they are destroyed, so we can be assured that _all_ state to do - * with this peer has been cleaned up when its refcount drops to - * zero. */ - atomic_dec (&kibnal_data.kib_npeers); -} - -/* the caller is responsible for accounting for the additional reference - * that this creates */ -kib_peer_t * -kibnal_find_peer_locked (ptl_nid_t nid) -{ - struct list_head *peer_list = kibnal_nid2peerlist (nid); - struct list_head *tmp; - kib_peer_t *peer; - - list_for_each (tmp, peer_list) { - - peer = list_entry (tmp, kib_peer_t, ibp_list); - - LASSERT (peer->ibp_persistence != 0 || /* persistent peer */ - peer->ibp_connecting != 0 || /* creating conns */ - !list_empty (&peer->ibp_conns)); /* active conn */ - - if (peer->ibp_nid != nid) - continue; - - CDEBUG(D_NET, "got peer [%p] -> "LPX64" (%d)\n", - peer, nid, atomic_read (&peer->ibp_refcount)); - return (peer); - } - return (NULL); -} - -kib_peer_t * -kibnal_get_peer (ptl_nid_t nid) -{ - kib_peer_t *peer; - - read_lock (&kibnal_data.kib_global_lock); - peer = kibnal_find_peer_locked (nid); - if (peer != NULL) /* +1 ref for caller? */ - kib_peer_addref(peer); - read_unlock (&kibnal_data.kib_global_lock); - - return (peer); -} - -void -kibnal_unlink_peer_locked (kib_peer_t *peer) -{ - LASSERT (peer->ibp_persistence == 0); - LASSERT (list_empty(&peer->ibp_conns)); - - LASSERT (kibnal_peer_active(peer)); - list_del_init (&peer->ibp_list); - /* lose peerlist's ref */ - kib_peer_decref(peer); -} - -static int -kibnal_get_peer_info (int index, ptl_nid_t *nidp, int *persistencep) -{ - kib_peer_t *peer; - struct list_head *ptmp; - int i; - - read_lock (&kibnal_data.kib_global_lock); - - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) { - - list_for_each (ptmp, &kibnal_data.kib_peers[i]) { - - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence != 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - if (index-- > 0) - continue; - - *nidp = peer->ibp_nid; - *persistencep = peer->ibp_persistence; - - read_unlock (&kibnal_data.kib_global_lock); - return (0); - } - } - - read_unlock (&kibnal_data.kib_global_lock); - return (-ENOENT); -} - -static int -kibnal_add_persistent_peer (ptl_nid_t nid) -{ - unsigned long flags; - kib_peer_t *peer; - kib_peer_t *peer2; - - if (nid == PTL_NID_ANY) - return (-EINVAL); - - peer = kibnal_create_peer (nid); - if (peer == NULL) - return (-ENOMEM); - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - peer2 = kibnal_find_peer_locked (nid); - if (peer2 != NULL) { - kib_peer_decref (peer); - peer = peer2; - } else { - /* peer table takes existing ref on peer */ - list_add_tail (&peer->ibp_list, - kibnal_nid2peerlist (nid)); - } - - peer->ibp_persistence++; - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - return (0); -} - -static void -kibnal_del_peer_locked (kib_peer_t *peer, int single_share) -{ - struct list_head *ctmp; - struct list_head *cnxt; - kib_conn_t *conn; - - if (!single_share) - peer->ibp_persistence = 0; - else if (peer->ibp_persistence > 0) - peer->ibp_persistence--; - - if (peer->ibp_persistence != 0) - return; - - list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry(ctmp, kib_conn_t, ibc_list); - - kibnal_close_conn_locked (conn, 0); - } - - /* NB peer unlinks itself when last conn is closed */ -} - -int -kibnal_del_peer (ptl_nid_t nid, int single_share) -{ - unsigned long flags; - struct list_head *ptmp; - struct list_head *pnxt; - kib_peer_t *peer; - int lo; - int hi; - int i; - int rc = -ENOENT; - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = kibnal_nid2peerlist(nid) - kibnal_data.kib_peers; - else { - lo = 0; - hi = kibnal_data.kib_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &kibnal_data.kib_peers[i]) { - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence != 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - if (!(nid == PTL_NID_ANY || peer->ibp_nid == nid)) - continue; - - kibnal_del_peer_locked (peer, single_share); - rc = 0; /* matched something */ - - if (single_share) - goto out; - } - } - out: - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - return (rc); -} - -static kib_conn_t * -kibnal_get_conn_by_idx (int index) -{ - kib_peer_t *peer; - struct list_head *ptmp; - kib_conn_t *conn; - struct list_head *ctmp; - int i; - - read_lock (&kibnal_data.kib_global_lock); - - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) { - list_for_each (ptmp, &kibnal_data.kib_peers[i]) { - - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence > 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - list_for_each (ctmp, &peer->ibp_conns) { - if (index-- > 0) - continue; - - conn = list_entry (ctmp, kib_conn_t, ibc_list); - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - read_unlock (&kibnal_data.kib_global_lock); - return (conn); - } - } - } - - read_unlock (&kibnal_data.kib_global_lock); - return (NULL); -} - -kib_conn_t * -kibnal_create_conn (void) -{ - kib_conn_t *conn; - int i; - __u64 vaddr = 0; - __u64 vaddr_base; - int page_offset; - int ipage; - int rc; - FSTATUS frc; - union { - IB_QP_ATTRIBUTES_CREATE qp_create; - IB_QP_ATTRIBUTES_MODIFY qp_attr; - } params; - - PORTAL_ALLOC (conn, sizeof (*conn)); - if (conn == NULL) { - CERROR ("Can't allocate connection\n"); - return (NULL); - } - - /* zero flags, NULL pointers etc... */ - memset (conn, 0, sizeof (*conn)); - - INIT_LIST_HEAD (&conn->ibc_tx_queue); - INIT_LIST_HEAD (&conn->ibc_active_txs); - spin_lock_init (&conn->ibc_lock); - - atomic_inc (&kibnal_data.kib_nconns); - /* well not really, but I call destroy() on failure, which decrements */ - - PORTAL_ALLOC (conn->ibc_rxs, IBNAL_RX_MSGS * sizeof (kib_rx_t)); - if (conn->ibc_rxs == NULL) - goto failed; - memset (conn->ibc_rxs, 0, IBNAL_RX_MSGS * sizeof(kib_rx_t)); - - rc = kibnal_alloc_pages(&conn->ibc_rx_pages, IBNAL_RX_MSG_PAGES, 1); - if (rc != 0) - goto failed; - - vaddr_base = vaddr = conn->ibc_rx_pages->ibp_vaddr; - - for (i = ipage = page_offset = 0; i < IBNAL_RX_MSGS; i++) { - struct page *page = conn->ibc_rx_pages->ibp_pages[ipage]; - kib_rx_t *rx = &conn->ibc_rxs[i]; - - rx->rx_conn = conn; - rx->rx_msg = (kib_msg_t *)(((char *)page_address(page)) + - page_offset); - - if (kibnal_whole_mem()) - rx->rx_vaddr = kibnal_page2phys(page) + - page_offset + - kibnal_data.kib_md.md_addr; - else - rx->rx_vaddr = vaddr; - - vaddr += IBNAL_MSG_SIZE; - LASSERT (vaddr <= vaddr_base + IBNAL_RX_MSG_BYTES); - - page_offset += IBNAL_MSG_SIZE; - LASSERT (page_offset <= PAGE_SIZE); - - if (page_offset == PAGE_SIZE) { - page_offset = 0; - ipage++; - LASSERT (ipage <= IBNAL_RX_MSG_PAGES); - } - } - - params.qp_create = (IB_QP_ATTRIBUTES_CREATE) { - .Type = QPTypeReliableConnected, - .SendQDepth = IBNAL_TX_MAX_SG * - IBNAL_MSG_QUEUE_SIZE, - .RecvQDepth = IBNAL_MSG_QUEUE_SIZE, - .SendDSListDepth = 1, - .RecvDSListDepth = 1, - .SendCQHandle = kibnal_data.kib_cq, - .RecvCQHandle = kibnal_data.kib_cq, - .PDHandle = kibnal_data.kib_pd, - .SendSignaledCompletions = TRUE, - }; - frc = iibt_qp_create(kibnal_data.kib_hca, ¶ms.qp_create, NULL, - &conn->ibc_qp, &conn->ibc_qp_attrs); - if (rc != 0) { - CERROR ("Failed to create queue pair: %d\n", rc); - goto failed; - } - - /* Mark QP created */ - conn->ibc_state = IBNAL_CONN_INIT_QP; - - params.qp_attr = (IB_QP_ATTRIBUTES_MODIFY) { - .RequestState = QPStateInit, - .Attrs = (IB_QP_ATTR_PORTGUID | - IB_QP_ATTR_PKEYINDEX | - IB_QP_ATTR_ACCESSCONTROL), - .PortGUID = kibnal_data.kib_port_guid, - .PkeyIndex = 0, - .AccessControl = { - .s = { - .RdmaWrite = 1, - .RdmaRead = 1, - }, - }, - }; - rc = iibt_qp_modify(conn->ibc_qp, ¶ms.qp_attr, NULL); - if (rc != 0) { - CERROR ("Failed to modify queue pair: %d\n", rc); - goto failed; - } - - /* 1 ref for caller */ - atomic_set (&conn->ibc_refcount, 1); - return (conn); - - failed: - kibnal_destroy_conn (conn); - return (NULL); -} - -void -kibnal_destroy_conn (kib_conn_t *conn) -{ - int rc; - FSTATUS frc; - - CDEBUG (D_NET, "connection %p\n", conn); - - LASSERT (atomic_read (&conn->ibc_refcount) == 0); - LASSERT (list_empty(&conn->ibc_tx_queue)); - LASSERT (list_empty(&conn->ibc_active_txs)); - LASSERT (conn->ibc_nsends_posted == 0); - LASSERT (conn->ibc_connreq == NULL); - - switch (conn->ibc_state) { - case IBNAL_CONN_DISCONNECTED: - /* called after connection sequence initiated */ - /* fall through */ - - case IBNAL_CONN_INIT_QP: - /* _destroy includes an implicit Reset of the QP which - * discards posted work */ - rc = iibt_qp_destroy(conn->ibc_qp); - if (rc != 0) - CERROR("Can't destroy QP: %d\n", rc); - /* fall through */ - - case IBNAL_CONN_INIT_NOTHING: - break; - - default: - LASSERT (0); - } - - if (conn->ibc_cep != NULL) { - frc = iibt_cm_destroy_cep(conn->ibc_cep); - if (frc != 0) - CERROR("Can't destroy CEP %p: %d\n", conn->ibc_cep, - frc); - } - - if (conn->ibc_rx_pages != NULL) - kibnal_free_pages(conn->ibc_rx_pages); - - if (conn->ibc_rxs != NULL) - PORTAL_FREE(conn->ibc_rxs, - IBNAL_RX_MSGS * sizeof(kib_rx_t)); - - if (conn->ibc_peer != NULL) - kib_peer_decref(conn->ibc_peer); - - PORTAL_FREE(conn, sizeof (*conn)); - - atomic_dec(&kibnal_data.kib_nconns); - - if (atomic_read (&kibnal_data.kib_nconns) == 0 && - kibnal_data.kib_shutdown) { - /* I just nuked the last connection on shutdown; wake up - * everyone so they can exit. */ - wake_up_all(&kibnal_data.kib_sched_waitq); - wake_up_all(&kibnal_data.kib_connd_waitq); - } -} - -void -kibnal_put_conn (kib_conn_t *conn) -{ - unsigned long flags; - - CDEBUG (D_NET, "putting conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - - LASSERT (atomic_read (&conn->ibc_refcount) > 0); - if (!atomic_dec_and_test (&conn->ibc_refcount)) - return; - - /* must disconnect before dropping the final ref */ - LASSERT (conn->ibc_state == IBNAL_CONN_DISCONNECTED); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - - list_add (&conn->ibc_list, &kibnal_data.kib_connd_conns); - wake_up (&kibnal_data.kib_connd_waitq); - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); -} - -static int -kibnal_close_peer_conns_locked (kib_peer_t *peer, int why) -{ - kib_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry (ctmp, kib_conn_t, ibc_list); - - count++; - kibnal_close_conn_locked (conn, why); - } - - return (count); -} - -int -kibnal_close_stale_conns_locked (kib_peer_t *peer, __u64 incarnation) -{ - kib_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry (ctmp, kib_conn_t, ibc_list); - - if (conn->ibc_incarnation == incarnation) - continue; - - CDEBUG(D_NET, "Closing stale conn nid:"LPX64" incarnation:"LPX64"("LPX64")\n", - peer->ibp_nid, conn->ibc_incarnation, incarnation); - - count++; - kibnal_close_conn_locked (conn, -ESTALE); - } - - return (count); -} - -static int -kibnal_close_matching_conns (ptl_nid_t nid) -{ - unsigned long flags; - kib_peer_t *peer; - struct list_head *ptmp; - struct list_head *pnxt; - int lo; - int hi; - int i; - int count = 0; - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = kibnal_nid2peerlist(nid) - kibnal_data.kib_peers; - else { - lo = 0; - hi = kibnal_data.kib_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &kibnal_data.kib_peers[i]) { - - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence != 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - if (!(nid == PTL_NID_ANY || nid == peer->ibp_nid)) - continue; - - count += kibnal_close_peer_conns_locked (peer, 0); - } - } - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - /* wildcards always succeed */ - if (nid == PTL_NID_ANY) - return (0); - - return (count == 0 ? -ENOENT : 0); -} - -static int -kibnal_cmd(struct portals_cfg *pcfg, void * private) -{ - int rc = -EINVAL; - ENTRY; - - LASSERT (pcfg != NULL); - - switch(pcfg->pcfg_command) { - case NAL_CMD_GET_PEER: { - ptl_nid_t nid = 0; - int share_count = 0; - - rc = kibnal_get_peer_info(pcfg->pcfg_count, - &nid, &share_count); - pcfg->pcfg_nid = nid; - pcfg->pcfg_size = 0; - pcfg->pcfg_id = 0; - pcfg->pcfg_misc = 0; - pcfg->pcfg_count = 0; - pcfg->pcfg_wait = share_count; - break; - } - case NAL_CMD_ADD_PEER: { - rc = kibnal_add_persistent_peer (pcfg->pcfg_nid); - break; - } - case NAL_CMD_DEL_PEER: { - rc = kibnal_del_peer (pcfg->pcfg_nid, - /* flags == single_share */ - pcfg->pcfg_flags != 0); - break; - } - case NAL_CMD_GET_CONN: { - kib_conn_t *conn = kibnal_get_conn_by_idx (pcfg->pcfg_count); - - if (conn == NULL) - rc = -ENOENT; - else { - rc = 0; - pcfg->pcfg_nid = conn->ibc_peer->ibp_nid; - pcfg->pcfg_id = 0; - pcfg->pcfg_misc = 0; - pcfg->pcfg_flags = 0; - kibnal_put_conn (conn); - } - break; - } - case NAL_CMD_CLOSE_CONNECTION: { - rc = kibnal_close_matching_conns (pcfg->pcfg_nid); - break; - } - case NAL_CMD_REGISTER_MYNID: { - if (pcfg->pcfg_nid == PTL_NID_ANY) - rc = -EINVAL; - else - rc = kibnal_set_mynid (pcfg->pcfg_nid); - break; - } - } - - RETURN(rc); -} - -void -kibnal_free_pages (kib_pages_t *p) -{ - int npages = p->ibp_npages; - int rc; - int i; - - if (p->ibp_mapped) { - rc = iibt_deregister_memory(p->ibp_handle); - if (rc != 0) - CERROR ("Deregister error: %d\n", rc); - } - - for (i = 0; i < npages; i++) - if (p->ibp_pages[i] != NULL) - __free_page(p->ibp_pages[i]); - - PORTAL_FREE (p, offsetof(kib_pages_t, ibp_pages[npages])); -} - -int -kibnal_alloc_pages (kib_pages_t **pp, int npages, int allow_write) -{ - kib_pages_t *p; - __u64 *phys_pages; - int i; - FSTATUS frc; - IB_ACCESS_CONTROL access; - - memset(&access, 0, sizeof(access)); - access.s.MWBindable = 1; - access.s.LocalWrite = 1; - access.s.RdmaRead = 1; - access.s.RdmaWrite = 1; - - PORTAL_ALLOC(p, offsetof(kib_pages_t, ibp_pages[npages])); - if (p == NULL) { - CERROR ("Can't allocate buffer %d\n", npages); - return (-ENOMEM); - } - - memset (p, 0, offsetof(kib_pages_t, ibp_pages[npages])); - p->ibp_npages = npages; - - for (i = 0; i < npages; i++) { - p->ibp_pages[i] = alloc_page (GFP_KERNEL); - if (p->ibp_pages[i] == NULL) { - CERROR ("Can't allocate page %d of %d\n", i, npages); - kibnal_free_pages(p); - return (-ENOMEM); - } - } - - if (kibnal_whole_mem()) - goto out; - - PORTAL_ALLOC(phys_pages, npages * sizeof(*phys_pages)); - if (phys_pages == NULL) { - CERROR ("Can't allocate physarray for %d pages\n", npages); - /* XXX free ibp_pages? */ - kibnal_free_pages(p); - return (-ENOMEM); - } - - /* if we were using the _contig_ registration variant we would have - * an array of PhysAddr/Length pairs, but the discontiguous variant - * just takes the PhysAddr */ - for (i = 0; i < npages; i++) - phys_pages[i] = kibnal_page2phys(p->ibp_pages[i]); - - frc = iibt_register_physical_memory(kibnal_data.kib_hca, - 0, /* requested vaddr */ - phys_pages, npages, - 0, /* offset */ - kibnal_data.kib_pd, - access, - &p->ibp_handle, &p->ibp_vaddr, - &p->ibp_lkey, &p->ibp_rkey); - - PORTAL_FREE(phys_pages, npages * sizeof(*phys_pages)); - - if (frc != FSUCCESS) { - CERROR ("Error %d mapping %d pages\n", frc, npages); - kibnal_free_pages(p); - return (-ENOMEM); - } - - CDEBUG(D_NET, "registered %d pages; handle: %p vaddr "LPX64" " - "lkey %x rkey %x\n", npages, p->ibp_handle, - p->ibp_vaddr, p->ibp_lkey, p->ibp_rkey); - - p->ibp_mapped = 1; -out: - *pp = p; - return (0); -} - -static int -kibnal_setup_tx_descs (void) -{ - int ipage = 0; - int page_offset = 0; - __u64 vaddr; - __u64 vaddr_base; - struct page *page; - kib_tx_t *tx; - int i; - int rc; - - /* pre-mapped messages are not bigger than 1 page */ - LASSERT (IBNAL_MSG_SIZE <= PAGE_SIZE); - - /* No fancy arithmetic when we do the buffer calculations */ - LASSERT (PAGE_SIZE % IBNAL_MSG_SIZE == 0); - - rc = kibnal_alloc_pages(&kibnal_data.kib_tx_pages, IBNAL_TX_MSG_PAGES, - 0); - if (rc != 0) - return (rc); - - /* ignored for the whole_mem case */ - vaddr = vaddr_base = kibnal_data.kib_tx_pages->ibp_vaddr; - - for (i = 0; i < IBNAL_TX_MSGS; i++) { - page = kibnal_data.kib_tx_pages->ibp_pages[ipage]; - tx = &kibnal_data.kib_tx_descs[i]; - - memset (tx, 0, sizeof(*tx)); /* zero flags etc */ - - tx->tx_msg = (kib_msg_t *)(((char *)page_address(page)) + - page_offset); - - if (kibnal_whole_mem()) - tx->tx_vaddr = kibnal_page2phys(page) + - page_offset + - kibnal_data.kib_md.md_addr; - else - tx->tx_vaddr = vaddr; - - tx->tx_isnblk = (i >= IBNAL_NTX); - tx->tx_mapped = KIB_TX_UNMAPPED; - - CDEBUG(D_NET, "Tx[%d] %p->%p - "LPX64"\n", - i, tx, tx->tx_msg, tx->tx_vaddr); - - if (tx->tx_isnblk) - list_add (&tx->tx_list, - &kibnal_data.kib_idle_nblk_txs); - else - list_add (&tx->tx_list, - &kibnal_data.kib_idle_txs); - - vaddr += IBNAL_MSG_SIZE; - LASSERT (vaddr <= vaddr_base + IBNAL_TX_MSG_BYTES); - - page_offset += IBNAL_MSG_SIZE; - LASSERT (page_offset <= PAGE_SIZE); - - if (page_offset == PAGE_SIZE) { - page_offset = 0; - ipage++; - LASSERT (ipage <= IBNAL_TX_MSG_PAGES); - } - } - - return (0); -} - -static void -kibnal_api_shutdown (nal_t *nal) -{ - int i; - int rc; - - if (nal->nal_refct != 0) { - /* This module got the first ref */ - PORTAL_MODULE_UNUSE; - return; - } - - CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n", - atomic_read (&portal_kmemory)); - - LASSERT(nal == &kibnal_api); - - switch (kibnal_data.kib_init) { - default: - CERROR ("Unexpected state %d\n", kibnal_data.kib_init); - LBUG(); - - case IBNAL_INIT_ALL: - /* stop calls to nal_cmd */ - libcfs_nal_cmd_unregister(IIBNAL); - /* No new peers */ - - /* resetting my NID to unadvertises me, removes my - * listener and nukes all current peers */ - kibnal_set_mynid (PTL_NID_ANY); - - /* Wait for all peer state to clean up (crazy) */ - i = 2; - while (atomic_read (&kibnal_data.kib_npeers) != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "waiting for %d peers to disconnect (can take a few seconds)\n", - atomic_read (&kibnal_data.kib_npeers)); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - } - /* fall through */ - - case IBNAL_INIT_CQ: - rc = iibt_cq_destroy(kibnal_data.kib_cq); - if (rc != 0) - CERROR ("Destroy CQ error: %d\n", rc); - /* fall through */ - - case IBNAL_INIT_TXD: - kibnal_free_pages (kibnal_data.kib_tx_pages); - /* fall through */ - - case IBNAL_INIT_MR: - if (kibnal_data.kib_md.md_handle != NULL) { - rc = iibt_deregister_memory(kibnal_data.kib_md.md_handle); - if (rc != FSUCCESS) - CERROR ("Deregister memory: %d\n", rc); - } - /* fall through */ - -#if IBNAL_FMR - case IBNAL_INIT_FMR: - rc = ib_fmr_pool_destroy (kibnal_data.kib_fmr_pool); - if (rc != 0) - CERROR ("Destroy FMR pool error: %d\n", rc); - /* fall through */ -#endif - case IBNAL_INIT_PD: - rc = iibt_pd_free(kibnal_data.kib_pd); - if (rc != 0) - CERROR ("Destroy PD error: %d\n", rc); - /* fall through */ - - case IBNAL_INIT_SD: - rc = iibt_sd_deregister(kibnal_data.kib_sd); - if (rc != 0) - CERROR ("Deregister SD error: %d\n", rc); - /* fall through */ - - case IBNAL_INIT_PORT: - /* XXX ??? */ - /* fall through */ - - case IBNAL_INIT_PORTATTRS: - PORTAL_FREE(kibnal_data.kib_hca_attrs.PortAttributesList, - kibnal_data.kib_hca_attrs.PortAttributesListSize); - /* fall through */ - - case IBNAL_INIT_HCA: - rc = iibt_close_hca(kibnal_data.kib_hca); - if (rc != 0) - CERROR ("Close HCA error: %d\n", rc); - /* fall through */ - - case IBNAL_INIT_LIB: - lib_fini(&kibnal_lib); - /* fall through */ - - case IBNAL_INIT_DATA: - /* Module refcount only gets to zero when all peers - * have been closed so all lists must be empty */ - LASSERT (atomic_read (&kibnal_data.kib_npeers) == 0); - LASSERT (kibnal_data.kib_peers != NULL); - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) { - LASSERT (list_empty (&kibnal_data.kib_peers[i])); - } - LASSERT (atomic_read (&kibnal_data.kib_nconns) == 0); - LASSERT (list_empty (&kibnal_data.kib_sched_rxq)); - LASSERT (list_empty (&kibnal_data.kib_sched_txq)); - LASSERT (list_empty (&kibnal_data.kib_connd_conns)); - LASSERT (list_empty (&kibnal_data.kib_connd_peers)); - - /* flag threads to terminate; wake and wait for them to die */ - kibnal_data.kib_shutdown = 1; - wake_up_all (&kibnal_data.kib_sched_waitq); - wake_up_all (&kibnal_data.kib_connd_waitq); - - i = 2; - while (atomic_read (&kibnal_data.kib_nthreads) != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "Waiting for %d threads to terminate\n", - atomic_read (&kibnal_data.kib_nthreads)); - set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout (HZ); - } - /* fall through */ - - case IBNAL_INIT_NOTHING: - break; - } - - if (kibnal_data.kib_tx_descs != NULL) - PORTAL_FREE (kibnal_data.kib_tx_descs, - IBNAL_TX_MSGS * sizeof(kib_tx_t)); - - if (kibnal_data.kib_peers != NULL) - PORTAL_FREE (kibnal_data.kib_peers, - sizeof (struct list_head) * - kibnal_data.kib_peer_hash_size); - - CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n", - atomic_read (&portal_kmemory)); - printk(KERN_INFO "Lustre: Infinicon IB NAL unloaded (final mem %d)\n", - atomic_read(&portal_kmemory)); - - kibnal_data.kib_init = IBNAL_INIT_NOTHING; -} - -#define roundup_power(val, power) \ - ( (val + (__u64)(power - 1)) & ~((__u64)(power - 1)) ) - -/* this isn't very portable or sturdy in the face of funny mem/bus configs */ -static __u64 max_phys_mem(IB_CA_ATTRIBUTES *ca_attr) -{ - struct sysinfo si; - __u64 ret; - - /* XXX we don't bother with first-gen cards */ - if (ca_attr->VendorId == 0xd0b7 && ca_attr->DeviceId == 0x3101) - return 0ULL; - - si_meminfo(&si); - ret = (__u64)max(si.totalram, max_mapnr) * si.mem_unit; - return roundup_power(ret, 128 * 1024 * 1024); -} -#undef roundup_power - -static int -kibnal_api_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - ptl_process_id_t process_id; - int pkmem = atomic_read(&portal_kmemory); - IB_PORT_ATTRIBUTES *pattr; - FSTATUS frc; - int rc; - int n; - int i; - - LASSERT (nal == &kibnal_api); - - if (nal->nal_refct != 0) { - if (actual_limits != NULL) - *actual_limits = kibnal_lib.libnal_ni.ni_actual_limits; - /* This module got the first ref */ - PORTAL_MODULE_USE; - return (PTL_OK); - } - - LASSERT (kibnal_data.kib_init == IBNAL_INIT_NOTHING); - - frc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2, - &kibnal_data.kib_interfaces); - if (frc != FSUCCESS) { - CERROR("IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2) = %d\n", - frc); - return -ENOSYS; - } - - init_MUTEX (&kibnal_data.kib_nid_mutex); - init_MUTEX_LOCKED (&kibnal_data.kib_nid_signal); - kibnal_data.kib_nid = PTL_NID_ANY; - - rwlock_init(&kibnal_data.kib_global_lock); - - kibnal_data.kib_peer_hash_size = IBNAL_PEER_HASH_SIZE; - PORTAL_ALLOC (kibnal_data.kib_peers, - sizeof (struct list_head) * kibnal_data.kib_peer_hash_size); - if (kibnal_data.kib_peers == NULL) { - goto failed; - } - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) - INIT_LIST_HEAD(&kibnal_data.kib_peers[i]); - - spin_lock_init (&kibnal_data.kib_connd_lock); - INIT_LIST_HEAD (&kibnal_data.kib_connd_peers); - INIT_LIST_HEAD (&kibnal_data.kib_connd_conns); - init_waitqueue_head (&kibnal_data.kib_connd_waitq); - - spin_lock_init (&kibnal_data.kib_sched_lock); - INIT_LIST_HEAD (&kibnal_data.kib_sched_txq); - INIT_LIST_HEAD (&kibnal_data.kib_sched_rxq); - init_waitqueue_head (&kibnal_data.kib_sched_waitq); - - spin_lock_init (&kibnal_data.kib_tx_lock); - INIT_LIST_HEAD (&kibnal_data.kib_idle_txs); - INIT_LIST_HEAD (&kibnal_data.kib_idle_nblk_txs); - init_waitqueue_head(&kibnal_data.kib_idle_tx_waitq); - - PORTAL_ALLOC (kibnal_data.kib_tx_descs, - IBNAL_TX_MSGS * sizeof(kib_tx_t)); - if (kibnal_data.kib_tx_descs == NULL) { - CERROR ("Can't allocate tx descs\n"); - goto failed; - } - - /* lists/ptrs/locks initialised */ - kibnal_data.kib_init = IBNAL_INIT_DATA; - /*****************************************************/ - - process_id.pid = 0; - process_id.nid = kibnal_data.kib_nid; - - rc = lib_init(&kibnal_lib, nal, process_id, - requested_limits, actual_limits); - if (rc != PTL_OK) { - CERROR("lib_init failed: error %d\n", rc); - goto failed; - } - - /* lib interface initialised */ - kibnal_data.kib_init = IBNAL_INIT_LIB; - /*****************************************************/ - - for (i = 0; i < IBNAL_N_SCHED; i++) { - rc = kibnal_thread_start (kibnal_scheduler, (void *)i); - if (rc != 0) { - CERROR("Can't spawn iibnal scheduler[%d]: %d\n", - i, rc); - goto failed; - } - } - - rc = kibnal_thread_start (kibnal_connd, NULL); - if (rc != 0) { - CERROR ("Can't spawn iibnal connd: %d\n", rc); - goto failed; - } - - n = sizeof(kibnal_data.kib_hca_guids) / - sizeof(kibnal_data.kib_hca_guids[0]); - frc = iibt_get_hca_guids(&n, kibnal_data.kib_hca_guids); - if (frc != FSUCCESS) { - CERROR ("Can't get channel adapter guids: %d\n", frc); - goto failed; - } - if (n == 0) { - CERROR ("No channel adapters found\n"); - goto failed; - } - - /* Infinicon has per-HCA rather than per CQ completion handlers */ - frc = iibt_open_hca(kibnal_data.kib_hca_guids[0], - kibnal_ca_callback, - kibnal_ca_async_callback, - &kibnal_data.kib_hca, - &kibnal_data.kib_hca); - if (frc != FSUCCESS) { - CERROR ("Can't open CA[0]: %d\n", frc); - goto failed; - } - - /* Channel Adapter opened */ - kibnal_data.kib_init = IBNAL_INIT_HCA; - /*****************************************************/ - - kibnal_data.kib_hca_attrs.PortAttributesList = NULL; - kibnal_data.kib_hca_attrs.PortAttributesListSize = 0; - frc = iibt_query_hca(kibnal_data.kib_hca, - &kibnal_data.kib_hca_attrs, NULL); - if (frc != FSUCCESS) { - CERROR ("Can't size port attrs: %d\n", frc); - goto failed; - } - - PORTAL_ALLOC(kibnal_data.kib_hca_attrs.PortAttributesList, - kibnal_data.kib_hca_attrs.PortAttributesListSize); - if (kibnal_data.kib_hca_attrs.PortAttributesList == NULL) - goto failed; - - /* Port attrs allocated */ - kibnal_data.kib_init = IBNAL_INIT_PORTATTRS; - /*****************************************************/ - - frc = iibt_query_hca(kibnal_data.kib_hca, &kibnal_data.kib_hca_attrs, - NULL); - if (frc != FSUCCESS) { - CERROR ("Can't get port attrs for CA 0: %d\n", frc); - goto failed; - } - - for (i = 0, pattr = kibnal_data.kib_hca_attrs.PortAttributesList; - pattr != NULL; - i++, pattr = pattr->Next) { - switch (pattr->PortState) { - default: - CERROR("Unexpected port[%d] state %d\n", - i, pattr->PortState); - continue; - case PortStateDown: - CDEBUG(D_NET, "port[%d] Down\n", i); - continue; - case PortStateInit: - CDEBUG(D_NET, "port[%d] Init\n", i); - continue; - case PortStateArmed: - CDEBUG(D_NET, "port[%d] Armed\n", i); - continue; - - case PortStateActive: - CDEBUG(D_NET, "port[%d] Active\n", i); - kibnal_data.kib_port = i; - kibnal_data.kib_port_guid = pattr->GUID; - kibnal_data.kib_port_pkey = pattr->PkeyTable[0]; - break; - } - break; - } - - if (pattr == NULL) { - CERROR ("Can't find an active port\n"); - goto failed; - } - - CDEBUG(D_NET, "got guid "LPX64"\n", kibnal_data.kib_port_guid); - - /* Active port found */ - kibnal_data.kib_init = IBNAL_INIT_PORT; - /*****************************************************/ - - frc = iibt_sd_register(&kibnal_data.kib_sd, NULL); - if (frc != FSUCCESS) { - CERROR ("Can't register with SD: %d\n", frc); - goto failed; - } - - /* Registered with SD OK */ - kibnal_data.kib_init = IBNAL_INIT_SD; - /*****************************************************/ - - frc = iibt_pd_allocate(kibnal_data.kib_hca, 0, &kibnal_data.kib_pd); - if (frc != FSUCCESS) { - CERROR ("Can't create PD: %d\n", rc); - goto failed; - } - - /* flag PD initialised */ - kibnal_data.kib_init = IBNAL_INIT_PD; - /*****************************************************/ - -#if IBNAL_FMR - { - const int pool_size = IBNAL_NTX + IBNAL_NTX_NBLK; - struct ib_fmr_pool_param params = { - .max_pages_per_fmr = PTL_MTU/PAGE_SIZE, - .access = (IB_ACCESS_LOCAL_WRITE | - IB_ACCESS_REMOTE_WRITE | - IB_ACCESS_REMOTE_READ), - .pool_size = pool_size, - .dirty_watermark = (pool_size * 3)/4, - .flush_function = NULL, - .flush_arg = NULL, - .cache = 1, - }; - rc = ib_fmr_pool_create(kibnal_data.kib_pd, ¶ms, - &kibnal_data.kib_fmr_pool); - if (rc != 0) { - CERROR ("Can't create FMR pool size %d: %d\n", - pool_size, rc); - goto failed; - } - } - - /* flag FMR pool initialised */ - kibnal_data.kib_init = IBNAL_INIT_FMR; -#endif - /*****************************************************/ - if (IBNAL_WHOLE_MEM) { - IB_MR_PHYS_BUFFER phys; - IB_ACCESS_CONTROL access; - kib_md_t *md = &kibnal_data.kib_md; - - memset(&access, 0, sizeof(access)); - access.s.MWBindable = 1; - access.s.LocalWrite = 1; - access.s.RdmaRead = 1; - access.s.RdmaWrite = 1; - - phys.PhysAddr = 0; - phys.Length = max_phys_mem(&kibnal_data.kib_hca_attrs); - if (phys.Length == 0) { - CERROR ("couldn't determine the end of phys mem\n"); - goto failed; - } - - rc = iibt_register_contig_physical_memory(kibnal_data.kib_hca, - 0, - &phys, 1, - 0, - kibnal_data.kib_pd, - access, - &md->md_handle, - &md->md_addr, - &md->md_lkey, - &md->md_rkey); - if (rc != FSUCCESS) { - CERROR("registering physical memory failed: %d\n", - rc); - CERROR("falling back to registration per-rdma\n"); - md->md_handle = NULL; - } else { - CDEBUG(D_NET, "registered "LPU64" bytes of mem\n", - phys.Length); - kibnal_data.kib_init = IBNAL_INIT_MR; - } - } - - /*****************************************************/ - - rc = kibnal_setup_tx_descs(); - if (rc != 0) { - CERROR ("Can't register tx descs: %d\n", rc); - goto failed; - } - - /* flag TX descs initialised */ - kibnal_data.kib_init = IBNAL_INIT_TXD; - /*****************************************************/ - - { - uint32 nentries; - - frc = iibt_cq_create(kibnal_data.kib_hca, IBNAL_CQ_ENTRIES, - &kibnal_data.kib_cq, &kibnal_data.kib_cq, - &nentries); - if (frc != FSUCCESS) { - CERROR ("Can't create RX CQ: %d\n", frc); - goto failed; - } - - /* flag CQ initialised */ - kibnal_data.kib_init = IBNAL_INIT_CQ; - - if (nentries < IBNAL_CQ_ENTRIES) { - CERROR ("CQ only has %d entries, need %d\n", - nentries, IBNAL_CQ_ENTRIES); - goto failed; - } - - rc = iibt_cq_rearm(kibnal_data.kib_cq, CQEventSelNextWC); - if (rc != 0) { - CERROR ("Failed to re-arm completion queue: %d\n", rc); - goto failed; - } - } - - /*****************************************************/ - - rc = libcfs_nal_cmd_register(IIBNAL, &kibnal_cmd, NULL); - if (rc != 0) { - CERROR ("Can't initialise command interface (rc = %d)\n", rc); - goto failed; - } - - /* flag everything initialised */ - kibnal_data.kib_init = IBNAL_INIT_ALL; - /*****************************************************/ - - printk(KERN_INFO "Lustre: Infinicon IB NAL loaded " - "(initial mem %d)\n", pkmem); - - return (PTL_OK); - - failed: - kibnal_api_shutdown (&kibnal_api); - return (PTL_FAIL); -} - -void __exit -kibnal_module_fini (void) -{ -#ifdef CONFIG_SYSCTL - if (kibnal_tunables.kib_sysctl != NULL) - unregister_sysctl_table (kibnal_tunables.kib_sysctl); -#endif - PtlNIFini(kibnal_ni); - - ptl_unregister_nal(IIBNAL); -} - -int __init -kibnal_module_init (void) -{ - int rc; - - if (sizeof(kib_wire_connreq_t) > CM_REQUEST_INFO_USER_LEN) { - CERROR("sizeof(kib_wire_connreq_t) > CM_REQUEST_INFO_USER_LEN\n"); - return -EINVAL; - } - - /* the following must be sizeof(int) for proc_dointvec() */ - if (sizeof (kibnal_tunables.kib_io_timeout) != sizeof (int)) { - CERROR("sizeof (kibnal_tunables.kib_io_timeout) != sizeof (int)\n"); - return -EINVAL; - } - - kibnal_api.nal_ni_init = kibnal_api_startup; - kibnal_api.nal_ni_fini = kibnal_api_shutdown; - - /* Initialise dynamic tunables to defaults once only */ - kibnal_tunables.kib_io_timeout = IBNAL_IO_TIMEOUT; - - rc = ptl_register_nal(IIBNAL, &kibnal_api); - if (rc != PTL_OK) { - CERROR("Can't register IBNAL: %d\n", rc); - return (-ENOMEM); /* or something... */ - } - - /* Pure gateways want the NAL started up at module load time... */ - rc = PtlNIInit(IIBNAL, 0, NULL, NULL, &kibnal_ni); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) { - ptl_unregister_nal(IIBNAL); - return (-ENODEV); - } - -#ifdef CONFIG_SYSCTL - /* Press on regardless even if registering sysctl doesn't work */ - kibnal_tunables.kib_sysctl = - register_sysctl_table (kibnal_top_ctl_table, 0); -#endif - return (0); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Kernel Infinicon IB NAL v0.01"); -MODULE_LICENSE("GPL"); - -module_init(kibnal_module_init); -module_exit(kibnal_module_fini); - diff --git a/lnet/klnds/iiblnd/iiblnd.h b/lnet/klnds/iiblnd/iiblnd.h deleted file mode 100644 index 3242158..0000000 --- a/lnet/klnds/iiblnd/iiblnd.h +++ /dev/null @@ -1,892 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_NAL - -#include -#include -#include -#include - -#include - -#define GCC_VERSION (__GNUC__ * 10000 \ - + __GNUC_MINOR__ * 100 \ - + __GNUC_PATCHLEVEL__) - -/* Test for GCC > 3.2.2 */ -#if GCC_VERSION <= 30202 -/* GCC 3.2.2, and presumably several versions before it, will - * miscompile this driver. See - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9853. */ -#error Invalid GCC version. Must use GCC >= 3.2.3 -#endif - -#define IBNAL_SERVICE_NAME "iibnal" -#define IBNAL_SERVICE_NUMBER 0x11b9a1 - -#if CONFIG_SMP -# define IBNAL_N_SCHED num_online_cpus() /* # schedulers */ -#else -# define IBNAL_N_SCHED 1 /* # schedulers */ -#endif - -#define IBNAL_MIN_RECONNECT_INTERVAL HZ /* first failed connection retry... */ -#define IBNAL_MAX_RECONNECT_INTERVAL (60*HZ) /* ...exponentially increasing to this */ - -#define IBNAL_MSG_SIZE (4<<10) /* max size of queued messages (inc hdr) */ - -#define IBNAL_MSG_QUEUE_SIZE 8 /* # messages/RDMAs in-flight */ -#define IBNAL_CREDIT_HIGHWATER 7 /* when to eagerly return credits */ -/* 7 indicates infinite retry attempts, Infinicon recommended 5 */ -#define IBNAL_RETRY 5 /* # times to retry */ -#define IBNAL_RNR_RETRY 5 /* */ -#define IBNAL_CM_RETRY 5 /* # times to retry connection */ -#define IBNAL_FLOW_CONTROL 1 -#define IBNAL_ACK_TIMEOUT 20 /* supposedly 4 secs */ - -#define IBNAL_NTX 64 /* # tx descs */ -/* this had to be dropped down so that we only register < 255 pages per - * region. this will change if we register all memory. */ -#define IBNAL_NTX_NBLK 128 /* # reserved tx descs */ - -#define IBNAL_PEER_HASH_SIZE 101 /* # peer lists */ - -#define IBNAL_RESCHED 100 /* # scheduler loops before reschedule */ - -#define IBNAL_CONCURRENT_PEERS 1000 /* # nodes all talking at once to me */ - -/* default vals for runtime tunables */ -#define IBNAL_IO_TIMEOUT 50 /* default comms timeout (seconds) */ - -/************************/ -/* derived constants... */ - -/* TX messages (shared by all connections) */ -#define IBNAL_TX_MSGS (IBNAL_NTX + IBNAL_NTX_NBLK) -#define IBNAL_TX_MSG_BYTES (IBNAL_TX_MSGS * IBNAL_MSG_SIZE) -#define IBNAL_TX_MSG_PAGES ((IBNAL_TX_MSG_BYTES + PAGE_SIZE - 1)/PAGE_SIZE) - -#define IBNAL_TX_MAX_SG (PTL_MD_MAX_IOV + 1) - -/* RX messages (per connection) */ -#define IBNAL_RX_MSGS IBNAL_MSG_QUEUE_SIZE -#define IBNAL_RX_MSG_BYTES (IBNAL_RX_MSGS * IBNAL_MSG_SIZE) -#define IBNAL_RX_MSG_PAGES ((IBNAL_RX_MSG_BYTES + PAGE_SIZE - 1)/PAGE_SIZE) - - -/* we may have up to 2 completions per transmit + - 1 completion per receive, per connection */ -#define IBNAL_CQ_ENTRIES ((2*IBNAL_TX_MSGS) + \ - (IBNAL_RX_MSGS * IBNAL_CONCURRENT_PEERS)) - -#define IBNAL_RDMA_BASE 0x0eeb0000 -#define IBNAL_FMR 0 -#define IBNAL_WHOLE_MEM 1 -#define IBNAL_CKSUM 0 -//#define IBNAL_CALLBACK_CTXT IB_CQ_CALLBACK_PROCESS -#define IBNAL_CALLBACK_CTXT IB_CQ_CALLBACK_INTERRUPT - -/* XXX I have no idea. */ -#define IBNAL_STARTING_PSN 1 - -typedef struct -{ - int kib_io_timeout; /* comms timeout (seconds) */ - struct ctl_table_header *kib_sysctl; /* sysctl interface */ -} kib_tunables_t; - -/* some of these have specific types in the stack that just map back - * to the uFOO types, like IB_{L,R}_KEY. */ -typedef struct -{ - int ibp_npages; /* # pages */ - int ibp_mapped; /* mapped? */ - __u64 ibp_vaddr; /* mapped region vaddr */ - __u32 ibp_lkey; /* mapped region lkey */ - __u32 ibp_rkey; /* mapped region rkey */ - IB_HANDLE ibp_handle; /* mapped region handle */ - struct page *ibp_pages[0]; -} kib_pages_t; - -typedef struct -{ - IB_HANDLE md_handle; - __u32 md_lkey; - __u32 md_rkey; - __u64 md_addr; -} kib_md_t __attribute__((packed)); - -typedef struct -{ - int kib_init; /* initialisation state */ - __u64 kib_incarnation; /* which one am I */ - int kib_shutdown; /* shut down? */ - atomic_t kib_nthreads; /* # live threads */ - - __u64 kib_service_id; /* service number I listen on */ - __u64 kib_port_guid; /* my GUID (lo 64 of GID)*/ - __u16 kib_port_pkey; /* my pkey, whatever that is */ - ptl_nid_t kib_nid; /* my NID */ - struct semaphore kib_nid_mutex; /* serialise NID ops */ - struct semaphore kib_nid_signal; /* signal completion */ - IB_HANDLE kib_cep; /* connection end point */ - - rwlock_t kib_global_lock; /* stabilize peer/conn ops */ - - struct list_head *kib_peers; /* hash table of all my known peers */ - int kib_peer_hash_size; /* size of kib_peers */ - atomic_t kib_npeers; /* # peers extant */ - atomic_t kib_nconns; /* # connections extant */ - - struct list_head kib_connd_conns; /* connections to progress */ - struct list_head kib_connd_peers; /* peers waiting for a connection */ - wait_queue_head_t kib_connd_waitq; /* connection daemons sleep here */ - unsigned long kib_connd_waketime; /* when connd will wake */ - spinlock_t kib_connd_lock; /* serialise */ - - wait_queue_head_t kib_sched_waitq; /* schedulers sleep here */ - struct list_head kib_sched_txq; /* tx requiring attention */ - struct list_head kib_sched_rxq; /* rx requiring attention */ - spinlock_t kib_sched_lock; /* serialise */ - - struct kib_tx *kib_tx_descs; /* all the tx descriptors */ - kib_pages_t *kib_tx_pages; /* premapped tx msg pages */ - - struct list_head kib_idle_txs; /* idle tx descriptors */ - struct list_head kib_idle_nblk_txs; /* idle reserved tx descriptors */ - wait_queue_head_t kib_idle_tx_waitq; /* block here for tx descriptor */ - __u64 kib_next_tx_cookie; /* RDMA completion cookie */ - spinlock_t kib_tx_lock; /* serialise */ - - IB_HANDLE kib_hca; /* The HCA */ - int kib_port; /* port on the device */ - IB_HANDLE kib_pd; /* protection domain */ - IB_HANDLE kib_sd; /* SD handle */ - IB_HANDLE kib_cq; /* completion queue */ - kib_md_t kib_md; /* full-mem registration */ - - void *kib_listen_handle; /* where I listen for connections */ - - IBT_INTERFACE_UNION kib_interfaces; /* The Infinicon IBT interface */ - - uint64 kib_hca_guids[8]; /* all the HCA guids */ - IB_CA_ATTRIBUTES kib_hca_attrs; /* where to get HCA attrs */ - FABRIC_OPERATION_DATA kib_fabopdata; /* (un)advertise service record */ -} kib_data_t; - -#define IBNAL_INIT_NOTHING 0 -#define IBNAL_INIT_DATA 1 -#define IBNAL_INIT_LIB 2 -#define IBNAL_INIT_HCA 3 -#define IBNAL_INIT_PORTATTRS 4 -#define IBNAL_INIT_PORT 5 -#define IBNAL_INIT_SD 6 -#define IBNAL_INIT_PD 7 -#define IBNAL_INIT_FMR 8 -#define IBNAL_INIT_MR 9 -#define IBNAL_INIT_TXD 10 -#define IBNAL_INIT_CQ 11 -#define IBNAL_INIT_ALL 12 - -/************************************************************************ - * Wire message structs. - * These are sent in sender's byte order (i.e. receiver flips). - * CAVEAT EMPTOR: other structs communicated between nodes (e.g. MAD - * private data and SM service info), is LE on the wire. - */ - -/* also kib_md_t above */ - -typedef struct -{ - __u32 rd_key; /* remote key */ - __u32 rd_nob; /* # of bytes */ - __u64 rd_addr; /* remote io vaddr */ -} kib_rdma_desc_t __attribute__((packed)); - -typedef struct -{ - ptl_hdr_t ibim_hdr; /* portals header */ - char ibim_payload[0]; /* piggy-backed payload */ -} kib_immediate_msg_t __attribute__((packed)); - -/* these arrays serve two purposes during rdma. they are built on the passive - * side and sent to the active side as remote arguments. On the active side - * the descs are used as a data structure on the way to local gather items. - * the different roles result in split local/remote meaning of desc->rd_key */ -typedef struct -{ - ptl_hdr_t ibrm_hdr; /* portals header */ - __u64 ibrm_cookie; /* opaque completion cookie */ - __u32 ibrm_num_descs; /* how many descs */ - kib_rdma_desc_t ibrm_desc[0]; /* where to suck/blow */ -} kib_rdma_msg_t __attribute__((packed)); - -#define kib_rdma_msg_len(num_descs) \ - offsetof(kib_msg_t, ibm_u.rdma.ibrm_desc[num_descs]) - -typedef struct -{ - __u64 ibcm_cookie; /* opaque completion cookie */ - __u32 ibcm_status; /* completion status */ -} kib_completion_msg_t __attribute__((packed)); - -typedef struct -{ - __u32 ibm_magic; /* I'm an openibnal message */ - __u16 ibm_version; /* this is my version number */ - __u8 ibm_type; /* msg type */ - __u8 ibm_credits; /* returned credits */ -#if IBNAL_CKSUM - __u32 ibm_nob; - __u32 ibm_cksum; -#endif - union { - kib_immediate_msg_t immediate; - kib_rdma_msg_t rdma; - kib_completion_msg_t completion; - } ibm_u __attribute__((packed)); -} kib_msg_t __attribute__((packed)); - -#define IBNAL_MSG_MAGIC 0x0be91b91 /* unique magic */ -#define IBNAL_MSG_VERSION 1 /* current protocol version */ - -#define IBNAL_MSG_NOOP 0xd0 /* nothing (just credits) */ -#define IBNAL_MSG_IMMEDIATE 0xd1 /* portals hdr + payload */ -#define IBNAL_MSG_PUT_RDMA 0xd2 /* portals PUT hdr + source rdma desc */ -#define IBNAL_MSG_PUT_DONE 0xd3 /* signal PUT rdma completion */ -#define IBNAL_MSG_GET_RDMA 0xd4 /* portals GET hdr + sink rdma desc */ -#define IBNAL_MSG_GET_DONE 0xd5 /* signal GET rdma completion */ - -/***********************************************************************/ - -typedef struct kib_rx /* receive message */ -{ - struct list_head rx_list; /* queue for attention */ - struct kib_conn *rx_conn; /* owning conn */ - int rx_rdma; /* RDMA completion posted? */ - int rx_posted; /* posted? */ - __u64 rx_vaddr; /* pre-mapped buffer (hca vaddr) */ - kib_msg_t *rx_msg; /* pre-mapped buffer (host vaddr) */ - IB_WORK_REQ rx_wrq; - IB_LOCAL_DATASEGMENT rx_gl; /* and it's memory */ -} kib_rx_t; - -typedef struct kib_tx /* transmit message */ -{ - struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */ - int tx_isnblk; /* I'm reserved for non-blocking sends */ - struct kib_conn *tx_conn; /* owning conn */ - int tx_mapped; /* mapped for RDMA? */ - int tx_sending; /* # tx callbacks outstanding */ - int tx_status; /* completion status */ - unsigned long tx_deadline; /* completion deadline */ - int tx_passive_rdma; /* peer sucks/blows */ - int tx_passive_rdma_wait; /* waiting for peer to complete */ - __u64 tx_passive_rdma_cookie; /* completion cookie */ - lib_msg_t *tx_libmsg[2]; /* lib msgs to finalize on completion */ - kib_md_t tx_md; /* RDMA mapping (active/passive) */ - __u64 tx_vaddr; /* pre-mapped buffer (hca vaddr) */ - kib_msg_t *tx_msg; /* pre-mapped buffer (host vaddr) */ - int tx_nsp; /* # send work items */ - IB_WORK_REQ tx_wrq[IBNAL_TX_MAX_SG]; /* send work items... */ - IB_LOCAL_DATASEGMENT tx_gl[IBNAL_TX_MAX_SG]; /* ...and their memory */ -} kib_tx_t; - -#define KIB_TX_UNMAPPED 0 -#define KIB_TX_MAPPED 1 -#define KIB_TX_MAPPED_FMR 2 - -typedef struct kib_wire_connreq -{ - __u32 wcr_magic; /* I'm an openibnal connreq */ - __u16 wcr_version; /* this is my version number */ - __u16 wcr_queue_depth; /* this is my receive queue size */ - __u64 wcr_nid; /* peer's NID */ - __u64 wcr_incarnation; /* peer's incarnation */ -} kib_wire_connreq_t; - -typedef struct kib_gid -{ - __u64 hi, lo; -} kib_gid_t; - -typedef struct kib_connreq -{ - /* connection-in-progress */ - struct kib_conn *cr_conn; - kib_wire_connreq_t cr_wcr; - __u64 cr_tid; - IB_SERVICE_RECORD cr_service; - kib_gid_t cr_gid; - IB_PATH_RECORD cr_path; - CM_REQUEST_INFO cr_cmreq; - CM_CONN_INFO cr_discarded; - CM_REJECT_INFO cr_rej_info; -} kib_connreq_t; - -typedef struct kib_conn -{ - struct kib_peer *ibc_peer; /* owning peer */ - struct list_head ibc_list; /* stash on peer's conn list */ - __u64 ibc_incarnation; /* which instance of the peer */ - atomic_t ibc_refcount; /* # users */ - int ibc_state; /* what's happening */ - atomic_t ibc_nob; /* # bytes buffered */ - int ibc_nsends_posted; /* # uncompleted sends */ - int ibc_credits; /* # credits I have */ - int ibc_outstanding_credits; /* # credits to return */ - int ibc_rcvd_disconnect;/* received discon request */ - int ibc_sent_disconnect;/* sent discon request */ - struct list_head ibc_tx_queue; /* send queue */ - struct list_head ibc_active_txs; /* active tx awaiting completion */ - spinlock_t ibc_lock; /* serialise */ - kib_rx_t *ibc_rxs; /* the rx descs */ - kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */ - IB_HANDLE ibc_qp; /* queue pair */ - IB_HANDLE ibc_cep; /* connection ID? */ - IB_QP_ATTRIBUTES_QUERY ibc_qp_attrs; /* QP attrs */ - kib_connreq_t *ibc_connreq; /* connection request state */ -} kib_conn_t; - -#define IBNAL_CONN_INIT_NOTHING 0 /* initial state */ -#define IBNAL_CONN_INIT_QP 1 /* ibc_qp set up */ -#define IBNAL_CONN_CONNECTING 2 /* started to connect */ -#define IBNAL_CONN_ESTABLISHED 3 /* connection established */ -#define IBNAL_CONN_SEND_DREQ 4 /* to send disconnect req */ -#define IBNAL_CONN_DREQ 5 /* sent disconnect req */ -#define IBNAL_CONN_DREP 6 /* sent disconnect rep */ -#define IBNAL_CONN_DISCONNECTED 7 /* no more QP or CM traffic */ - -#define KIB_ASSERT_CONN_STATE(conn, state) do { \ - LASSERTF((conn)->ibc_state == state, "%d\n", conn->ibc_state); \ -} while (0) - -#define KIB_ASSERT_CONN_STATE_RANGE(conn, low, high) do { \ - LASSERTF(low <= high, "%d %d\n", low, high); \ - LASSERTF((conn)->ibc_state >= low && (conn)->ibc_state <= high, \ - "%d\n", conn->ibc_state); \ -} while (0) - -typedef struct kib_peer -{ - struct list_head ibp_list; /* stash on global peer list */ - struct list_head ibp_connd_list; /* schedule on kib_connd_peers */ - ptl_nid_t ibp_nid; /* who's on the other end(s) */ - atomic_t ibp_refcount; /* # users */ - int ibp_persistence; /* "known" peer refs */ - struct list_head ibp_conns; /* all active connections */ - struct list_head ibp_tx_queue; /* msgs waiting for a conn */ - int ibp_connecting; /* connecting+accepting */ - unsigned long ibp_reconnect_time; /* when reconnect may be attempted */ - unsigned long ibp_reconnect_interval; /* exponential backoff */ -} kib_peer_t; - - -extern lib_nal_t kibnal_lib; -extern kib_data_t kibnal_data; -extern kib_tunables_t kibnal_tunables; - -/******************************************************************************/ -/* Infinicon IBT interface wrappers */ -#define IIBT_IF (kibnal_data.kib_interfaces.ver2) - -static inline FSTATUS -iibt_get_hca_guids(uint32 *hca_count, EUI64 *hca_guid_list) -{ - return IIBT_IF.GetCaGuids(hca_count, hca_guid_list); -} - -static inline FSTATUS -iibt_open_hca(EUI64 hca_guid, - IB_COMPLETION_CALLBACK completion_callback, - IB_ASYNC_EVENT_CALLBACK async_event_callback, - void *arg, - IB_HANDLE *handle) -{ - return IIBT_IF.Vpi.OpenCA(hca_guid, completion_callback, - async_event_callback, arg, handle); -} - -static inline FSTATUS -iibt_query_hca(IB_HANDLE hca_handle, IB_CA_ATTRIBUTES *attrs, void **argp) -{ - return IIBT_IF.Vpi.QueryCA(hca_handle, attrs, argp); -} - -static inline FSTATUS -iibt_close_hca(IB_HANDLE hca_handle) -{ - return IIBT_IF.Vpi.CloseCA(hca_handle); -} - -static inline FSTATUS -iibt_pd_allocate(IB_HANDLE hca_handle, __u32 max_avs, IB_HANDLE *pd_handle) -{ - return IIBT_IF.Vpi.AllocatePD(hca_handle, max_avs, pd_handle); -} - -static inline FSTATUS -iibt_pd_free(IB_HANDLE pd_handle) -{ - return IIBT_IF.Vpi.FreePD(pd_handle); -} - -static inline FSTATUS -iibt_register_physical_memory(IB_HANDLE hca_handle, - IB_VIRT_ADDR requested_io_va, - void *phys_buffers, uint64 nphys_buffers, - uint32 io_va_offset, IB_HANDLE pd_handle, - IB_ACCESS_CONTROL access, - IB_HANDLE *mem_handle, - IB_VIRT_ADDR *actual_io_va, - IB_L_KEY *lkey, IB_R_KEY *rkey) -{ - return IIBT_IF.Vpi.RegisterPhysMemRegion(hca_handle, requested_io_va, - phys_buffers, nphys_buffers, - io_va_offset, pd_handle, - access, - mem_handle, actual_io_va, - lkey, rkey); -} - -static inline FSTATUS -iibt_register_contig_physical_memory(IB_HANDLE hca_handle, - IB_VIRT_ADDR requested_io_va, - IB_MR_PHYS_BUFFER *phys_buffers, - uint64 nphys_buffers, - uint32 io_va_offset, IB_HANDLE pd_handle, - IB_ACCESS_CONTROL access, - IB_HANDLE *mem_handle, - IB_VIRT_ADDR *actual_io_va, - IB_L_KEY *lkey, IB_R_KEY *rkey) -{ - return IIBT_IF.Vpi.RegisterContigPhysMemRegion(hca_handle, - requested_io_va, - phys_buffers, - nphys_buffers, - io_va_offset, pd_handle, - access, - mem_handle, actual_io_va, - lkey, rkey); -} - -static inline FSTATUS -iibt_register_memory(IB_HANDLE hca_handle, - void *virt_addr, unsigned int length, - IB_HANDLE pd_handle, - IB_ACCESS_CONTROL access, - IB_HANDLE *mem_handle, - IB_L_KEY *lkey, IB_R_KEY *rkey) -{ - return IIBT_IF.Vpi.RegisterMemRegion(hca_handle, - virt_addr, length, - pd_handle, - access, - mem_handle, - lkey, rkey); -} - -static inline FSTATUS -iibt_deregister_memory(IB_HANDLE mem_handle) -{ - return IIBT_IF.Vpi.DeregisterMemRegion(mem_handle); -} - -static inline FSTATUS -iibt_cq_create(IB_HANDLE hca_handle, uint32 requested_size, - void *arg, IB_HANDLE *cq_handle, uint32 *actual_size) -{ - return IIBT_IF.Vpi.CreateCQ(hca_handle, requested_size, - arg, cq_handle, actual_size); -} - -static inline FSTATUS -iibt_cq_poll(IB_HANDLE cq_handle, IB_WORK_COMPLETION *wc) -{ - return IIBT_IF.Vpi.PollCQ(cq_handle, wc); -} - -static inline FSTATUS -iibt_cq_rearm(IB_HANDLE cq_handle, IB_CQ_EVENT_SELECT select) -{ - return IIBT_IF.Vpi.RearmCQ(cq_handle, select); -} - -static inline FSTATUS -iibt_cq_destroy(IB_HANDLE cq_handle) -{ - return IIBT_IF.Vpi.DestroyCQ(cq_handle); -} - -static inline FSTATUS -iibt_qp_create(IB_HANDLE hca_handle, IB_QP_ATTRIBUTES_CREATE *create_attr, - void *arg, IB_HANDLE *cq_handle, - IB_QP_ATTRIBUTES_QUERY *query_attr) -{ - return IIBT_IF.Vpi.CreateQP(hca_handle, create_attr, arg, cq_handle, - query_attr); -} - -static inline FSTATUS -iibt_qp_query(IB_HANDLE qp_handle, IB_QP_ATTRIBUTES_QUERY *query_attr, - void **arg_ptr) -{ - return IIBT_IF.Vpi.QueryQP(qp_handle, query_attr, arg_ptr); -} - -static inline FSTATUS -iibt_qp_modify(IB_HANDLE qp_handle, IB_QP_ATTRIBUTES_MODIFY *modify_attr, - IB_QP_ATTRIBUTES_QUERY *query_attr) -{ - return IIBT_IF.Vpi.ModifyQP(qp_handle, modify_attr, query_attr); -} - -static inline FSTATUS -iibt_qp_destroy(IB_HANDLE qp_handle) -{ - return IIBT_IF.Vpi.DestroyQP(qp_handle); -} - -static inline FSTATUS -iibt_postrecv(IB_HANDLE qp_handle, IB_WORK_REQ *work_req) -{ - return IIBT_IF.Vpi.PostRecv(qp_handle, work_req); -} - -static inline FSTATUS -iibt_postsend(IB_HANDLE qp_handle, IB_WORK_REQ *work_req) -{ - return IIBT_IF.Vpi.PostSend(qp_handle, work_req); -} - -static inline FSTATUS -iibt_sd_register(IB_HANDLE *sd_handle, CLIENT_CONTROL_PARAMETERS *p) -{ - return IIBT_IF.Sdi.Register(sd_handle, p); -} - -static inline FSTATUS -iibt_sd_deregister(IB_HANDLE sd_handle) -{ - return IIBT_IF.Sdi.Deregister(sd_handle); -} - -static inline FSTATUS -iibt_sd_port_fabric_operation(IB_HANDLE sd_handle, EUI64 port_guid, - FABRIC_OPERATION_DATA *fod, - PFABRIC_OPERATION_CALLBACK callback, - COMMAND_CONTROL_PARAMETERS *p, void *arg) -{ - return IIBT_IF.Sdi.PortFabricOperation(sd_handle, port_guid, - fod, callback, p, arg); -} - -static inline FSTATUS -iibt_sd_query_port_fabric_information(IB_HANDLE sd_handle, EUI64 port_guid, - QUERY *qry, - PQUERY_CALLBACK callback, - COMMAND_CONTROL_PARAMETERS *p, void *arg) -{ - return IIBT_IF.Sdi.QueryPortFabricInformation(sd_handle, port_guid, - qry, callback, p, arg); -} - -static inline IB_HANDLE -iibt_cm_create_cep(CM_CEP_TYPE type) -{ - return IIBT_IF.Cmi.CmCreateCEP(type); -} - -static inline FSTATUS -iibt_cm_modify_cep(IB_HANDLE cep, uint32 attr, char* value, uint32 len, - uint32 offset) -{ - return IIBT_IF.Cmi.CmModifyCEP(cep, attr, value, len, offset); -} - -static inline FSTATUS -iibt_cm_destroy_cep(IB_HANDLE cep_handle) -{ - return IIBT_IF.Cmi.CmDestroyCEP(cep_handle); -} - -static inline FSTATUS -iibt_cm_listen(IB_HANDLE cep, CM_LISTEN_INFO *info, - PFN_CM_CALLBACK callback, void *arg) -{ - return IIBT_IF.Cmi.CmListen(cep, info, callback, arg); -} - -static inline FSTATUS -iibt_cm_cancel(IB_HANDLE cep) -{ - return IIBT_IF.Cmi.CmCancel(cep); -} - -static inline FSTATUS -iibt_cm_accept(IB_HANDLE cep, - CM_CONN_INFO *send_info, CM_CONN_INFO *recv_info, - PFN_CM_CALLBACK callback, void *arg, - IB_HANDLE *new_cep) -{ - return IIBT_IF.Cmi.CmAccept(cep, - send_info, recv_info, - callback, arg, new_cep); -} - -static inline FSTATUS -iibt_cm_reject(IB_HANDLE cep, CM_REJECT_INFO *rej) -{ - return IIBT_IF.Cmi.CmReject(cep, rej); -} - -static inline FSTATUS -iibt_cm_disconnect(IB_HANDLE cep, CM_DREQUEST_INFO *req, - CM_DREPLY_INFO *reply) -{ - return IIBT_IF.Cmi.CmDisconnect(cep, req, reply); -} - -static inline FSTATUS -iibt_cm_connect (IB_HANDLE cep, CM_REQUEST_INFO *req, - PFN_CM_CALLBACK callback, void *arg) -{ - return IIBT_IF.Cmi.CmConnect (cep, req, callback, arg); -} - -static inline int wrq_signals_completion(IB_WORK_REQ *wrq) -{ - return wrq->Req.SendRC.Options.s.SignaledCompletion == 1; -} - - -/******************************************************************************/ - -/* these are purposely avoiding using local vars so they don't increase - * stack consumption. */ - -#define kib_peer_addref(peer) do { \ - LASSERTF(atomic_read(&peer->ibp_refcount) > 0, "%d\n", \ - atomic_read(&peer->ibp_refcount)); \ - CDEBUG(D_NET, "++peer[%p] -> "LPX64" (%d)\n", \ - peer, peer->ibp_nid, atomic_read (&peer->ibp_refcount)); \ - atomic_inc(&peer->ibp_refcount); \ -} while (0) - -#define kib_peer_decref(peer) do { \ - LASSERTF(atomic_read(&peer->ibp_refcount) > 0, "%d\n", \ - atomic_read(&peer->ibp_refcount)); \ - CDEBUG(D_NET, "--peer[%p] -> "LPX64" (%d)\n", \ - peer, peer->ibp_nid, atomic_read (&peer->ibp_refcount)); \ - if (atomic_dec_and_test (&peer->ibp_refcount)) { \ - CDEBUG (D_NET, "destroying peer "LPX64" %p\n", \ - peer->ibp_nid, peer); \ - kibnal_destroy_peer (peer); \ - } \ -} while (0) - -/******************************************************************************/ - -static inline struct list_head * -kibnal_nid2peerlist (ptl_nid_t nid) -{ - unsigned int hash = ((unsigned int)nid) % kibnal_data.kib_peer_hash_size; - - return (&kibnal_data.kib_peers [hash]); -} - -static inline int -kibnal_peer_active(kib_peer_t *peer) -{ - /* Am I in the peer hash table? */ - return (!list_empty(&peer->ibp_list)); -} - -static inline void -kibnal_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn) -{ - /* CAVEAT EMPTOR: tx takes caller's ref on conn */ - - LASSERT (tx->tx_nsp > 0); /* work items set up */ - LASSERT (tx->tx_conn == NULL); /* only set here */ - - tx->tx_conn = conn; - tx->tx_deadline = jiffies + kibnal_tunables.kib_io_timeout * HZ; - list_add_tail(&tx->tx_list, &conn->ibc_tx_queue); -} - -#define KIBNAL_SERVICE_KEY_MASK (IB_SERVICE_RECORD_COMP_SERVICENAME | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_1 | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_2 | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_3 | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_4 | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_5 | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_6 | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_7 | \ - IB_SERVICE_RECORD_COMP_SERVICEDATA8_8) - -static inline __u64* -kibnal_service_nid_field(IB_SERVICE_RECORD *srv) -{ - /* must be consistent with KIBNAL_SERVICE_KEY_MASK */ - return (__u64 *)srv->ServiceData8; -} - - -static inline void -kibnal_set_service_keys(IB_SERVICE_RECORD *srv, ptl_nid_t nid) -{ - LASSERT (strlen(IBNAL_SERVICE_NAME) < sizeof(srv->ServiceName)); - memset (srv->ServiceName, 0, sizeof(srv->ServiceName)); - strcpy (srv->ServiceName, IBNAL_SERVICE_NAME); - - *kibnal_service_nid_field(srv) = cpu_to_le64(nid); -} - -#if 0 -static inline void -kibnal_show_rdma_attr (kib_conn_t *conn) -{ - struct ib_qp_attribute qp_attr; - int rc; - - memset (&qp_attr, 0, sizeof(qp_attr)); - rc = ib_qp_query(conn->ibc_qp, &qp_attr); - if (rc != 0) { - CERROR ("Can't get qp attrs: %d\n", rc); - return; - } - - CWARN ("RDMA CAPABILITY: write %s read %s\n", - (qp_attr.valid_fields & TS_IB_QP_ATTRIBUTE_RDMA_ATOMIC_ENABLE) ? - (qp_attr.enable_rdma_write ? "enabled" : "disabled") : "invalid", - (qp_attr.valid_fields & TS_IB_QP_ATTRIBUTE_RDMA_ATOMIC_ENABLE) ? - (qp_attr.enable_rdma_read ? "enabled" : "disabled") : "invalid"); -} -#endif - -#if CONFIG_X86 -static inline __u64 -kibnal_page2phys (struct page *p) -{ - __u64 page_number = p - mem_map; - - return (page_number << PAGE_SHIFT); -} -#else -# error "no page->phys" -#endif - -/* CAVEAT EMPTOR: - * We rely on tx/rx descriptor alignment to allow us to use the lowest bit - * of the work request id as a flag to determine if the completion is for a - * transmit or a receive. It seems that that the CQ entry's 'op' field - * isn't always set correctly on completions that occur after QP teardown. */ - -static inline __u64 -kibnal_ptr2wreqid (void *ptr, int isrx) -{ - unsigned long lptr = (unsigned long)ptr; - - LASSERT ((lptr & 1) == 0); - return (__u64)(lptr | (isrx ? 1 : 0)); -} - -static inline void * -kibnal_wreqid2ptr (__u64 wreqid) -{ - return (void *)(((unsigned long)wreqid) & ~1UL); -} - -static inline int -kibnal_wreqid_is_rx (__u64 wreqid) -{ - return (wreqid & 1) != 0; -} - -static inline int -kibnal_whole_mem(void) -{ - return kibnal_data.kib_md.md_handle != NULL; -} - -extern kib_peer_t *kibnal_create_peer (ptl_nid_t nid); -extern void kibnal_destroy_peer (kib_peer_t *peer); -extern int kibnal_del_peer (ptl_nid_t nid, int single_share); -extern kib_peer_t *kibnal_find_peer_locked (ptl_nid_t nid); -extern void kibnal_unlink_peer_locked (kib_peer_t *peer); -extern int kibnal_close_stale_conns_locked (kib_peer_t *peer, - __u64 incarnation); -extern kib_conn_t *kibnal_create_conn (void); -extern void kibnal_put_conn (kib_conn_t *conn); -extern void kibnal_destroy_conn (kib_conn_t *conn); -void kibnal_listen_callback(IB_HANDLE cep, CM_CONN_INFO *info, void *arg); - -extern int kibnal_alloc_pages (kib_pages_t **pp, int npages, int access); -extern void kibnal_free_pages (kib_pages_t *p); - -extern void kibnal_check_sends (kib_conn_t *conn); -extern void kibnal_close_conn_locked (kib_conn_t *conn, int error); -extern void kibnal_destroy_conn (kib_conn_t *conn); -extern int kibnal_thread_start (int (*fn)(void *arg), void *arg); -extern int kibnal_scheduler(void *arg); -extern int kibnal_connd (void *arg); -extern void kibnal_init_tx_msg (kib_tx_t *tx, int type, int body_nob); -extern void kibnal_close_conn (kib_conn_t *conn, int why); -extern void kibnal_start_active_rdma (int type, int status, - kib_rx_t *rx, lib_msg_t *libmsg, - unsigned int niov, - struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t nob); - -void kibnal_ca_async_callback (void *ca_arg, IB_EVENT_RECORD *ev); -void kibnal_ca_callback (void *ca_arg, void *cq_arg); diff --git a/lnet/klnds/iiblnd/iiblnd_cb.c b/lnet/klnds/iiblnd/iiblnd_cb.c deleted file mode 100644 index a827ba5..0000000 --- a/lnet/klnds/iiblnd/iiblnd_cb.c +++ /dev/null @@ -1,3018 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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. - * - */ - -#include "iibnal.h" - -/* - * LIB functions follow - * - */ -static void -kibnal_schedule_tx_done (kib_tx_t *tx) -{ - unsigned long flags; - - spin_lock_irqsave (&kibnal_data.kib_sched_lock, flags); - - list_add_tail(&tx->tx_list, &kibnal_data.kib_sched_txq); - wake_up (&kibnal_data.kib_sched_waitq); - - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, flags); -} - -static void -kibnal_tx_done (kib_tx_t *tx) -{ - ptl_err_t ptlrc = (tx->tx_status == 0) ? PTL_OK : PTL_FAIL; - unsigned long flags; - int i; - FSTATUS frc; - - LASSERT (tx->tx_sending == 0); /* mustn't be awaiting callback */ - LASSERT (!tx->tx_passive_rdma_wait); /* mustn't be awaiting RDMA */ - - switch (tx->tx_mapped) { - default: - LBUG(); - - case KIB_TX_UNMAPPED: - break; - - case KIB_TX_MAPPED: - if (in_interrupt()) { - /* can't deregister memory in IRQ context... */ - kibnal_schedule_tx_done(tx); - return; - } - frc = iibt_deregister_memory(tx->tx_md.md_handle); - LASSERT (frc == FSUCCESS); - tx->tx_mapped = KIB_TX_UNMAPPED; - break; - -#if IBNAL_FMR - case KIB_TX_MAPPED_FMR: - if (in_interrupt() && tx->tx_status != 0) { - /* can't flush FMRs in IRQ context... */ - kibnal_schedule_tx_done(tx); - return; - } - - rc = ib_fmr_deregister(tx->tx_md.md_handle.fmr); - LASSERT (rc == 0); - - if (tx->tx_status != 0) - ib_fmr_pool_force_flush(kibnal_data.kib_fmr_pool); - tx->tx_mapped = KIB_TX_UNMAPPED; - break; -#endif - } - - for (i = 0; i < 2; i++) { - /* tx may have up to 2 libmsgs to finalise */ - if (tx->tx_libmsg[i] == NULL) - continue; - - lib_finalize (&kibnal_lib, NULL, tx->tx_libmsg[i], ptlrc); - tx->tx_libmsg[i] = NULL; - } - - if (tx->tx_conn != NULL) { - kibnal_put_conn (tx->tx_conn); - tx->tx_conn = NULL; - } - - tx->tx_nsp = 0; - tx->tx_passive_rdma = 0; - tx->tx_status = 0; - - spin_lock_irqsave (&kibnal_data.kib_tx_lock, flags); - - if (tx->tx_isnblk) { - list_add_tail (&tx->tx_list, &kibnal_data.kib_idle_nblk_txs); - } else { - list_add_tail (&tx->tx_list, &kibnal_data.kib_idle_txs); - wake_up (&kibnal_data.kib_idle_tx_waitq); - } - - spin_unlock_irqrestore (&kibnal_data.kib_tx_lock, flags); -} - -static kib_tx_t * -kibnal_get_idle_tx (int may_block) -{ - unsigned long flags; - kib_tx_t *tx = NULL; - ENTRY; - - for (;;) { - spin_lock_irqsave (&kibnal_data.kib_tx_lock, flags); - - /* "normal" descriptor is free */ - if (!list_empty (&kibnal_data.kib_idle_txs)) { - tx = list_entry (kibnal_data.kib_idle_txs.next, - kib_tx_t, tx_list); - break; - } - - if (!may_block) { - /* may dip into reserve pool */ - if (list_empty (&kibnal_data.kib_idle_nblk_txs)) { - CERROR ("reserved tx desc pool exhausted\n"); - break; - } - - tx = list_entry (kibnal_data.kib_idle_nblk_txs.next, - kib_tx_t, tx_list); - break; - } - - /* block for idle tx */ - spin_unlock_irqrestore (&kibnal_data.kib_tx_lock, flags); - - wait_event (kibnal_data.kib_idle_tx_waitq, - !list_empty (&kibnal_data.kib_idle_txs) || - kibnal_data.kib_shutdown); - } - - if (tx != NULL) { - list_del (&tx->tx_list); - - /* Allocate a new passive RDMA completion cookie. It might - * not be needed, but we've got a lock right now and we're - * unlikely to wrap... */ - tx->tx_passive_rdma_cookie = kibnal_data.kib_next_tx_cookie++; - - LASSERT (tx->tx_mapped == KIB_TX_UNMAPPED); - LASSERT (tx->tx_nsp == 0); - LASSERT (tx->tx_sending == 0); - LASSERT (tx->tx_status == 0); - LASSERT (tx->tx_conn == NULL); - LASSERT (!tx->tx_passive_rdma); - LASSERT (!tx->tx_passive_rdma_wait); - LASSERT (tx->tx_libmsg[0] == NULL); - LASSERT (tx->tx_libmsg[1] == NULL); - } - - spin_unlock_irqrestore (&kibnal_data.kib_tx_lock, flags); - - RETURN(tx); -} - -static int -kibnal_dist(lib_nal_t *nal, ptl_nid_t nid, unsigned long *dist) -{ - /* I would guess that if kibnal_get_peer (nid) == NULL, - and we're not routing, then 'nid' is very distant :) */ - if ( nal->libnal_ni.ni_pid.nid == nid ) { - *dist = 0; - } else { - *dist = 1; - } - - return 0; -} - -static void -kibnal_complete_passive_rdma(kib_conn_t *conn, __u64 cookie, int status) -{ - struct list_head *ttmp; - unsigned long flags; - int idle; - - spin_lock_irqsave (&conn->ibc_lock, flags); - - list_for_each (ttmp, &conn->ibc_active_txs) { - kib_tx_t *tx = list_entry(ttmp, kib_tx_t, tx_list); - - LASSERT (tx->tx_passive_rdma || - !tx->tx_passive_rdma_wait); - - LASSERT (tx->tx_passive_rdma_wait || - tx->tx_sending != 0); - - if (!tx->tx_passive_rdma_wait || - tx->tx_passive_rdma_cookie != cookie) - continue; - - CDEBUG(D_NET, "Complete %p "LPD64": %d\n", tx, cookie, status); - - tx->tx_status = status; - tx->tx_passive_rdma_wait = 0; - idle = (tx->tx_sending == 0); - - if (idle) - list_del (&tx->tx_list); - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - /* I could be racing with tx callbacks. It's whoever - * _makes_ tx idle that frees it */ - if (idle) - kibnal_tx_done (tx); - return; - } - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - CERROR ("Unmatched (late?) RDMA completion "LPX64" from "LPX64"\n", - cookie, conn->ibc_peer->ibp_nid); -} - -static __u32 -kibnal_lkey(kib_pages_t *ibp) -{ - if (kibnal_whole_mem()) - return kibnal_data.kib_md.md_lkey; - - return ibp->ibp_lkey; -} - -static void -kibnal_post_rx (kib_rx_t *rx, int do_credits) -{ - kib_conn_t *conn = rx->rx_conn; - int rc = 0; - unsigned long flags; - FSTATUS frc; - ENTRY; - - rx->rx_gl = (IB_LOCAL_DATASEGMENT) { - .Address = rx->rx_vaddr, - .Length = IBNAL_MSG_SIZE, - .Lkey = kibnal_lkey(conn->ibc_rx_pages), - }; - - rx->rx_wrq = (IB_WORK_REQ) { - .Operation = WROpRecv, - .DSListDepth = 1, - .MessageLen = IBNAL_MSG_SIZE, - .WorkReqId = kibnal_ptr2wreqid(rx, 1), - .DSList = &rx->rx_gl, - }; - - KIB_ASSERT_CONN_STATE_RANGE(conn, IBNAL_CONN_ESTABLISHED, - IBNAL_CONN_DREP); - LASSERT (!rx->rx_posted); - rx->rx_posted = 1; - mb(); - - if (conn->ibc_state != IBNAL_CONN_ESTABLISHED) - rc = -ECONNABORTED; - else { - frc = iibt_postrecv(conn->ibc_qp, &rx->rx_wrq); - if (frc != FSUCCESS) { - CDEBUG(D_NET, "post failed %d\n", frc); - rc = -EINVAL; - } - CDEBUG(D_NET, "posted rx %p\n", &rx->rx_wrq); - } - - if (rc == 0) { - if (do_credits) { - spin_lock_irqsave(&conn->ibc_lock, flags); - conn->ibc_outstanding_credits++; - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - kibnal_check_sends(conn); - } - EXIT; - return; - } - - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) { - CERROR ("Error posting receive -> "LPX64": %d\n", - conn->ibc_peer->ibp_nid, rc); - kibnal_close_conn (rx->rx_conn, rc); - } else { - CDEBUG (D_NET, "Error posting receive -> "LPX64": %d\n", - conn->ibc_peer->ibp_nid, rc); - } - - /* Drop rx's ref */ - kibnal_put_conn (conn); - EXIT; -} - -#if IBNAL_CKSUM -static inline __u32 kibnal_cksum (void *ptr, int nob) -{ - char *c = ptr; - __u32 sum = 0; - - while (nob-- > 0) - sum = ((sum << 1) | (sum >> 31)) + *c++; - - return (sum); -} -#endif - -static void hexdump(char *string, void *ptr, int len) -{ - unsigned char *c = ptr; - int i; - - return; - - if (len < 0 || len > 2048) { - printk("XXX what the hell? %d\n",len); - return; - } - - printk("%d bytes of '%s' from 0x%p\n", len, string, ptr); - - for (i = 0; i < len;) { - printk("%02x",*(c++)); - i++; - if (!(i & 15)) { - printk("\n"); - } else if (!(i&1)) { - printk(" "); - } - } - - if(len & 15) { - printk("\n"); - } -} - -static void -kibnal_rx_callback (IB_WORK_COMPLETION *wc) -{ - kib_rx_t *rx = (kib_rx_t *)kibnal_wreqid2ptr(wc->WorkReqId); - kib_msg_t *msg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; - int nob = wc->Length; - const int base_nob = offsetof(kib_msg_t, ibm_u); - int credits; - int flipped; - unsigned long flags; - __u32 i; -#if IBNAL_CKSUM - __u32 msg_cksum; - __u32 computed_cksum; -#endif - - /* we set the QP to erroring after we've finished disconnecting, - * maybe we should do so sooner. */ - KIB_ASSERT_CONN_STATE_RANGE(conn, IBNAL_CONN_ESTABLISHED, - IBNAL_CONN_DISCONNECTED); - - CDEBUG(D_NET, "rx %p conn %p\n", rx, conn); - LASSERT (rx->rx_posted); - rx->rx_posted = 0; - mb(); - - /* receives complete with error in any case after we've started - * disconnecting */ - if (conn->ibc_state > IBNAL_CONN_ESTABLISHED) - goto failed; - - if (wc->Status != WRStatusSuccess) { - CERROR("Rx from "LPX64" failed: %d\n", - conn->ibc_peer->ibp_nid, wc->Status); - goto failed; - } - - if (nob < base_nob) { - CERROR ("Short rx from "LPX64": %d < expected %d\n", - conn->ibc_peer->ibp_nid, nob, base_nob); - goto failed; - } - - hexdump("rx", rx->rx_msg, sizeof(kib_msg_t)); - - /* Receiver does any byte flipping if necessary... */ - - if (msg->ibm_magic == IBNAL_MSG_MAGIC) { - flipped = 0; - } else { - if (msg->ibm_magic != __swab32(IBNAL_MSG_MAGIC)) { - CERROR ("Unrecognised magic: %08x from "LPX64"\n", - msg->ibm_magic, conn->ibc_peer->ibp_nid); - goto failed; - } - flipped = 1; - __swab16s (&msg->ibm_version); - LASSERT (sizeof(msg->ibm_type) == 1); - LASSERT (sizeof(msg->ibm_credits) == 1); - } - - if (msg->ibm_version != IBNAL_MSG_VERSION) { - CERROR ("Incompatible msg version %d (%d expected)\n", - msg->ibm_version, IBNAL_MSG_VERSION); - goto failed; - } - -#if IBNAL_CKSUM - if (nob != msg->ibm_nob) { - CERROR ("Unexpected # bytes %d (%d expected)\n", nob, msg->ibm_nob); - goto failed; - } - - msg_cksum = le32_to_cpu(msg->ibm_cksum); - msg->ibm_cksum = 0; - computed_cksum = kibnal_cksum (msg, nob); - - if (msg_cksum != computed_cksum) { - CERROR ("Checksum failure %d: (%d expected)\n", - computed_cksum, msg_cksum); -// goto failed; - } - CDEBUG(D_NET, "cksum %x, nob %d\n", computed_cksum, nob); -#endif - - /* Have I received credits that will let me send? */ - credits = msg->ibm_credits; - if (credits != 0) { - spin_lock_irqsave(&conn->ibc_lock, flags); - conn->ibc_credits += credits; - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - kibnal_check_sends(conn); - } - - switch (msg->ibm_type) { - case IBNAL_MSG_NOOP: - kibnal_post_rx (rx, 1); - return; - - case IBNAL_MSG_IMMEDIATE: - if (nob < base_nob + sizeof (kib_immediate_msg_t)) { - CERROR ("Short IMMEDIATE from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, nob); - goto failed; - } - break; - - case IBNAL_MSG_PUT_RDMA: - case IBNAL_MSG_GET_RDMA: - if (nob < base_nob + sizeof (kib_rdma_msg_t)) { - CERROR ("Short RDMA msg from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, nob); - goto failed; - } - if (flipped) - __swab32(msg->ibm_u.rdma.ibrm_num_descs); - - CDEBUG(D_NET, "%d RDMA: cookie "LPX64":\n", - msg->ibm_type, msg->ibm_u.rdma.ibrm_cookie); - - if ((msg->ibm_u.rdma.ibrm_num_descs > PTL_MD_MAX_IOV) || - (kib_rdma_msg_len(msg->ibm_u.rdma.ibrm_num_descs) > - min(nob, IBNAL_MSG_SIZE))) { - CERROR ("num_descs %d too large\n", - msg->ibm_u.rdma.ibrm_num_descs); - goto failed; - } - - for(i = 0; i < msg->ibm_u.rdma.ibrm_num_descs; i++) { - kib_rdma_desc_t *desc = &msg->ibm_u.rdma.ibrm_desc[i]; - - if (flipped) { - __swab32(desc->rd_key); - __swab32(desc->rd_nob); - __swab64(desc->rd_addr); - } - - CDEBUG(D_NET, " key %x, " "addr "LPX64", nob %u\n", - desc->rd_key, desc->rd_addr, desc->rd_nob); - } - break; - - case IBNAL_MSG_PUT_DONE: - case IBNAL_MSG_GET_DONE: - if (nob < base_nob + sizeof (kib_completion_msg_t)) { - CERROR ("Short COMPLETION msg from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, nob); - goto failed; - } - if (flipped) - __swab32s(&msg->ibm_u.completion.ibcm_status); - - CDEBUG(D_NET, "%d DONE: cookie "LPX64", status %d\n", - msg->ibm_type, msg->ibm_u.completion.ibcm_cookie, - msg->ibm_u.completion.ibcm_status); - - kibnal_complete_passive_rdma (conn, - msg->ibm_u.completion.ibcm_cookie, - msg->ibm_u.completion.ibcm_status); - kibnal_post_rx (rx, 1); - return; - - default: - CERROR ("Can't parse type from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, msg->ibm_type); - goto failed; - } - - /* schedule for kibnal_rx() in thread context */ - spin_lock_irqsave(&kibnal_data.kib_sched_lock, flags); - - list_add_tail (&rx->rx_list, &kibnal_data.kib_sched_rxq); - wake_up (&kibnal_data.kib_sched_waitq); - - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, flags); - return; - - failed: - CDEBUG(D_NET, "rx %p conn %p\n", rx, conn); - kibnal_close_conn(conn, -ECONNABORTED); - - /* Don't re-post rx & drop its ref on conn */ - kibnal_put_conn(conn); -} - -void -kibnal_rx (kib_rx_t *rx) -{ - kib_msg_t *msg = rx->rx_msg; - - /* Clear flag so I can detect if I've sent an RDMA completion */ - rx->rx_rdma = 0; - - switch (msg->ibm_type) { - case IBNAL_MSG_GET_RDMA: - lib_parse(&kibnal_lib, &msg->ibm_u.rdma.ibrm_hdr, rx); - /* If the incoming get was matched, I'll have initiated the - * RDMA and the completion message... */ - if (rx->rx_rdma) - break; - - /* Otherwise, I'll send a failed completion now to prevent - * the peer's GET blocking for the full timeout. */ - CERROR ("Completing unmatched RDMA GET from "LPX64"\n", - rx->rx_conn->ibc_peer->ibp_nid); - kibnal_start_active_rdma (IBNAL_MSG_GET_DONE, -EIO, - rx, NULL, 0, NULL, NULL, 0, 0); - break; - - case IBNAL_MSG_PUT_RDMA: - lib_parse(&kibnal_lib, &msg->ibm_u.rdma.ibrm_hdr, rx); - if (rx->rx_rdma) - break; - /* This is most unusual, since even if lib_parse() didn't - * match anything, it should have asked us to read (and - * discard) the payload. The portals header must be - * inconsistent with this message type, so it's the - * sender's fault for sending garbage and she can time - * herself out... */ - CERROR ("Uncompleted RMDA PUT from "LPX64"\n", - rx->rx_conn->ibc_peer->ibp_nid); - break; - - case IBNAL_MSG_IMMEDIATE: - lib_parse(&kibnal_lib, &msg->ibm_u.immediate.ibim_hdr, rx); - LASSERT (!rx->rx_rdma); - break; - - default: - LBUG(); - break; - } - - kibnal_post_rx (rx, 1); -} - -static struct page * -kibnal_kvaddr_to_page (unsigned long vaddr) -{ - struct page *page; - - if (vaddr >= VMALLOC_START && - vaddr < VMALLOC_END) - page = vmalloc_to_page ((void *)vaddr); -#if CONFIG_HIGHMEM - else if (vaddr >= PKMAP_BASE && - vaddr < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE)) - page = vmalloc_to_page ((void *)vaddr); - /* in 2.4 ^ just walks the page tables */ -#endif - else - page = virt_to_page (vaddr); - - if (!VALID_PAGE (page)) - page = NULL; - - return page; -} - -static void -kibnal_fill_ibrm(kib_tx_t *tx, struct page *page, unsigned long page_offset, - unsigned long len, int active) -{ - kib_rdma_msg_t *ibrm = &tx->tx_msg->ibm_u.rdma; - kib_rdma_desc_t *desc; - - LASSERTF(ibrm->ibrm_num_descs < PTL_MD_MAX_IOV, "%u\n", - ibrm->ibrm_num_descs); - - desc = &ibrm->ibrm_desc[ibrm->ibrm_num_descs]; - if (active) - desc->rd_key = kibnal_data.kib_md.md_lkey; - else - desc->rd_key = kibnal_data.kib_md.md_rkey; - desc->rd_nob = len; /*PAGE_SIZE - kiov->kiov_offset; */ - desc->rd_addr = kibnal_page2phys(page) + page_offset + - kibnal_data.kib_md.md_addr; - - ibrm->ibrm_num_descs++; -} - -static int -kibnal_map_rdma_iov(kib_tx_t *tx, unsigned long vaddr, int nob, int active) -{ - struct page *page; - int page_offset, len; - - while (nob > 0) { - page = kibnal_kvaddr_to_page(vaddr); - if (page == NULL) - return -EFAULT; - - page_offset = vaddr & (PAGE_SIZE - 1); - len = min(nob, (int)PAGE_SIZE - page_offset); - - kibnal_fill_ibrm(tx, page, page_offset, len, active); - nob -= len; - vaddr += len; - } - return 0; -} - -static int -kibnal_map_iov (kib_tx_t *tx, IB_ACCESS_CONTROL access, - int niov, struct iovec *iov, int offset, int nob, int active) - -{ - void *vaddr; - FSTATUS frc; - - LASSERT (nob > 0); - LASSERT (niov > 0); - LASSERT (tx->tx_mapped == KIB_TX_UNMAPPED); - - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - niov--; - iov++; - LASSERT (niov > 0); - } - - if (nob > iov->iov_len - offset) { - CERROR ("Can't map multiple vaddr fragments\n"); - return (-EMSGSIZE); - } - - /* our large contiguous iov could be backed by multiple physical - * pages. */ - if (kibnal_whole_mem()) { - int rc; - tx->tx_msg->ibm_u.rdma.ibrm_num_descs = 0; - rc = kibnal_map_rdma_iov(tx, (unsigned long)iov->iov_base + - offset, nob, active); - if (rc != 0) { - CERROR ("Can't map iov: %d\n", rc); - return rc; - } - return 0; - } - - vaddr = (void *)(((unsigned long)iov->iov_base) + offset); - tx->tx_md.md_addr = (__u64)((unsigned long)vaddr); - - frc = iibt_register_memory(kibnal_data.kib_hca, vaddr, nob, - kibnal_data.kib_pd, access, - &tx->tx_md.md_handle, &tx->tx_md.md_lkey, - &tx->tx_md.md_rkey); - if (frc != 0) { - CERROR ("Can't map vaddr %p: %d\n", vaddr, frc); - return -EINVAL; - } - - tx->tx_mapped = KIB_TX_MAPPED; - return (0); -} - -static int -kibnal_map_kiov (kib_tx_t *tx, IB_ACCESS_CONTROL access, - int nkiov, ptl_kiov_t *kiov, - int offset, int nob, int active) -{ - __u64 *phys = NULL; - int page_offset; - int nphys; - int resid; - int phys_size = 0; - FSTATUS frc; - int i, rc = 0; - - CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob); - - LASSERT (nob > 0); - LASSERT (nkiov > 0); - LASSERT (tx->tx_mapped == KIB_TX_UNMAPPED); - - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; - nkiov--; - kiov++; - LASSERT (nkiov > 0); - } - - page_offset = kiov->kiov_offset + offset; - nphys = 1; - - if (!kibnal_whole_mem()) { - phys_size = nkiov * sizeof (*phys); - PORTAL_ALLOC(phys, phys_size); - if (phys == NULL) { - CERROR ("Can't allocate tmp phys\n"); - return (-ENOMEM); - } - - phys[0] = kibnal_page2phys(kiov->kiov_page); - } else { - tx->tx_msg->ibm_u.rdma.ibrm_num_descs = 0; - kibnal_fill_ibrm(tx, kiov->kiov_page, kiov->kiov_offset, - kiov->kiov_len, active); - } - - resid = nob - (kiov->kiov_len - offset); - - while (resid > 0) { - kiov++; - nkiov--; - LASSERT (nkiov > 0); - - if (kiov->kiov_offset != 0 || - ((resid > PAGE_SIZE) && - kiov->kiov_len < PAGE_SIZE)) { - /* Can't have gaps */ - CERROR ("Can't make payload contiguous in I/O VM:" - "page %d, offset %d, len %d \n", nphys, - kiov->kiov_offset, kiov->kiov_len); - - for (i = -nphys; i < nkiov; i++) - { - CERROR("kiov[%d] %p +%d for %d\n", - i, kiov[i].kiov_page, kiov[i].kiov_offset, kiov[i].kiov_len); - } - - rc = -EINVAL; - goto out; - } - - if (nphys == PTL_MD_MAX_IOV) { - CERROR ("payload too big (%d)\n", nphys); - rc = -EMSGSIZE; - goto out; - } - - if (!kibnal_whole_mem()) { - LASSERT (nphys * sizeof (*phys) < phys_size); - phys[nphys] = kibnal_page2phys(kiov->kiov_page); - } else { - if (kib_rdma_msg_len(nphys) > IBNAL_MSG_SIZE) { - CERROR ("payload too big (%d)\n", nphys); - rc = -EMSGSIZE; - goto out; - } - kibnal_fill_ibrm(tx, kiov->kiov_page, - kiov->kiov_offset, kiov->kiov_len, - active); - } - - nphys ++; - resid -= PAGE_SIZE; - } - - if (kibnal_whole_mem()) - goto out; - -#if 0 - CWARN ("nphys %d, nob %d, page_offset %d\n", nphys, nob, page_offset); - for (i = 0; i < nphys; i++) - CWARN (" [%d] "LPX64"\n", i, phys[i]); -#endif - -#if IBNAL_FMR -#error "iibnal hasn't learned about FMR yet" - rc = ib_fmr_register_physical (kibnal_data.kib_fmr_pool, - phys, nphys, - &tx->tx_md.md_addr, - page_offset, - &tx->tx_md.md_handle.fmr, - &tx->tx_md.md_lkey, - &tx->tx_md.md_rkey); -#else - frc = iibt_register_physical_memory(kibnal_data.kib_hca, - IBNAL_RDMA_BASE, - phys, nphys, - 0, /* offset */ - kibnal_data.kib_pd, - access, - &tx->tx_md.md_handle, - &tx->tx_md.md_addr, - &tx->tx_md.md_lkey, - &tx->tx_md.md_rkey); -#endif - if (frc == FSUCCESS) { - CDEBUG(D_NET, "Mapped %d pages %d bytes @ offset %d: lkey %x, rkey %x\n", - nphys, nob, page_offset, tx->tx_md.md_lkey, tx->tx_md.md_rkey); -#if IBNAL_FMR - tx->tx_mapped = KIB_TX_MAPPED_FMR; -#else - tx->tx_mapped = KIB_TX_MAPPED; -#endif - } else { - CERROR ("Can't map phys: %d\n", rc); - rc = -EFAULT; - } - - out: - if (phys != NULL) - PORTAL_FREE(phys, phys_size); - return (rc); -} - -static kib_conn_t * -kibnal_find_conn_locked (kib_peer_t *peer) -{ - struct list_head *tmp; - - /* just return the first connection */ - list_for_each (tmp, &peer->ibp_conns) { - return (list_entry(tmp, kib_conn_t, ibc_list)); - } - - return (NULL); -} - -void -kibnal_check_sends (kib_conn_t *conn) -{ - unsigned long flags; - kib_tx_t *tx; - int rc; - int i; - int done; - int nwork; - ENTRY; - - spin_lock_irqsave (&conn->ibc_lock, flags); - - LASSERT (conn->ibc_nsends_posted <= IBNAL_MSG_QUEUE_SIZE); - - if (list_empty(&conn->ibc_tx_queue) && - conn->ibc_outstanding_credits >= IBNAL_CREDIT_HIGHWATER) { - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - tx = kibnal_get_idle_tx(0); /* don't block */ - if (tx != NULL) - kibnal_init_tx_msg(tx, IBNAL_MSG_NOOP, 0); - - spin_lock_irqsave(&conn->ibc_lock, flags); - - if (tx != NULL) { - atomic_inc(&conn->ibc_refcount); - kibnal_queue_tx_locked(tx, conn); - } - } - - while (!list_empty (&conn->ibc_tx_queue)) { - tx = list_entry (conn->ibc_tx_queue.next, kib_tx_t, tx_list); - - /* We rely on this for QP sizing */ - LASSERT (tx->tx_nsp > 0 && tx->tx_nsp <= IBNAL_TX_MAX_SG); - - LASSERT (conn->ibc_outstanding_credits >= 0); - LASSERT (conn->ibc_outstanding_credits <= IBNAL_MSG_QUEUE_SIZE); - LASSERT (conn->ibc_credits >= 0); - LASSERT (conn->ibc_credits <= IBNAL_MSG_QUEUE_SIZE); - - /* Not on ibc_rdma_queue */ - LASSERT (!tx->tx_passive_rdma_wait); - - if (conn->ibc_nsends_posted == IBNAL_MSG_QUEUE_SIZE) - GOTO(out, 0); - - if (conn->ibc_credits == 0) /* no credits */ - GOTO(out, 1); - - if (conn->ibc_credits == 1 && /* last credit reserved for */ - conn->ibc_outstanding_credits == 0) /* giving back credits */ - GOTO(out, 2); - - list_del (&tx->tx_list); - - if (tx->tx_msg->ibm_type == IBNAL_MSG_NOOP && - (!list_empty(&conn->ibc_tx_queue) || - conn->ibc_outstanding_credits < IBNAL_CREDIT_HIGHWATER)) { - /* redundant NOOP */ - spin_unlock_irqrestore(&conn->ibc_lock, flags); - kibnal_tx_done(tx); - spin_lock_irqsave(&conn->ibc_lock, flags); - continue; - } - - tx->tx_msg->ibm_credits = conn->ibc_outstanding_credits; - conn->ibc_outstanding_credits = 0; - - conn->ibc_nsends_posted++; - conn->ibc_credits--; - - /* we only get a tx completion for the final rdma op */ - tx->tx_sending = min(tx->tx_nsp, 2); - tx->tx_passive_rdma_wait = tx->tx_passive_rdma; - list_add (&tx->tx_list, &conn->ibc_active_txs); -#if IBNAL_CKSUM - tx->tx_msg->ibm_cksum = 0; - tx->tx_msg->ibm_cksum = kibnal_cksum(tx->tx_msg, tx->tx_msg->ibm_nob); - CDEBUG(D_NET, "cksum %x, nob %d\n", tx->tx_msg->ibm_cksum, tx->tx_msg->ibm_nob); -#endif - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - /* NB the gap between removing tx from the queue and sending it - * allows message re-ordering to occur */ - - LASSERT (tx->tx_nsp > 0); - - rc = -ECONNABORTED; - nwork = 0; - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) { - tx->tx_status = 0; - /* Driver only accepts 1 item at a time */ - for (i = 0; i < tx->tx_nsp; i++) { - hexdump("tx", tx->tx_msg, sizeof(kib_msg_t)); - rc = iibt_postsend(conn->ibc_qp, - &tx->tx_wrq[i]); - if (rc != 0) - break; - if (wrq_signals_completion(&tx->tx_wrq[i])) - nwork++; - CDEBUG(D_NET, "posted tx wrq %p\n", - &tx->tx_wrq[i]); - } - } - - spin_lock_irqsave (&conn->ibc_lock, flags); - if (rc != 0) { - /* NB credits are transferred in the actual - * message, which can only be the last work item */ - conn->ibc_outstanding_credits += tx->tx_msg->ibm_credits; - conn->ibc_credits++; - conn->ibc_nsends_posted--; - - tx->tx_status = rc; - tx->tx_passive_rdma_wait = 0; - tx->tx_sending -= tx->tx_nsp - nwork; - - done = (tx->tx_sending == 0); - if (done) - list_del (&tx->tx_list); - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) - CERROR ("Error %d posting transmit to "LPX64"\n", - rc, conn->ibc_peer->ibp_nid); - else - CDEBUG (D_NET, "Error %d posting transmit to " - LPX64"\n", rc, conn->ibc_peer->ibp_nid); - - kibnal_close_conn (conn, rc); - - if (done) - kibnal_tx_done (tx); - return; - } - - } - - EXIT; -out: - spin_unlock_irqrestore (&conn->ibc_lock, flags); -} - -static void -kibnal_tx_callback (IB_WORK_COMPLETION *wc) -{ - kib_tx_t *tx = (kib_tx_t *)kibnal_wreqid2ptr(wc->WorkReqId); - kib_conn_t *conn; - unsigned long flags; - int idle; - - conn = tx->tx_conn; - LASSERT (conn != NULL); - LASSERT (tx->tx_sending != 0); - - spin_lock_irqsave(&conn->ibc_lock, flags); - - CDEBUG(D_NET, "conn %p tx %p [%d/%d]: %d\n", conn, tx, - tx->tx_sending, tx->tx_nsp, wc->Status); - - /* I could be racing with rdma completion. Whoever makes 'tx' idle - * gets to free it, which also drops its ref on 'conn'. If it's - * not me, then I take an extra ref on conn so it can't disappear - * under me. */ - - tx->tx_sending--; - idle = (tx->tx_sending == 0) && /* This is the final callback */ - (!tx->tx_passive_rdma_wait); /* Not waiting for RDMA completion */ - if (idle) - list_del(&tx->tx_list); - - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - - if (tx->tx_sending == 0) - conn->ibc_nsends_posted--; - - if (wc->Status != WRStatusSuccess && - tx->tx_status == 0) - tx->tx_status = -ECONNABORTED; - - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - if (idle) - kibnal_tx_done (tx); - - if (wc->Status != WRStatusSuccess) { - CERROR ("Tx completion to "LPX64" failed: %d\n", - conn->ibc_peer->ibp_nid, wc->Status); - kibnal_close_conn (conn, -ENETDOWN); - } else { - /* can I shovel some more sends out the door? */ - kibnal_check_sends(conn); - } - - kibnal_put_conn (conn); -} - -void -kibnal_ca_async_callback (void *ca_arg, IB_EVENT_RECORD *ev) -{ - /* XXX flesh out. this seems largely for async errors */ - CERROR("type: %d code: %u\n", ev->EventType, ev->EventCode); -} - -void -kibnal_ca_callback (void *ca_arg, void *cq_arg) -{ - IB_HANDLE cq = *(IB_HANDLE *)cq_arg; - IB_HANDLE ca = *(IB_HANDLE *)ca_arg; - IB_WORK_COMPLETION wc; - int armed = 0; - - CDEBUG(D_NET, "ca %p cq %p\n", ca, cq); - - for(;;) { - while (iibt_cq_poll(cq, &wc) == FSUCCESS) { - if (kibnal_wreqid_is_rx(wc.WorkReqId)) - kibnal_rx_callback(&wc); - else - kibnal_tx_callback(&wc); - } - if (armed) - return; - if (iibt_cq_rearm(cq, CQEventSelNextWC) != FSUCCESS) { - CERROR("rearm failed?\n"); - return; - } - armed = 1; - } -} - -void -kibnal_init_tx_msg (kib_tx_t *tx, int type, int body_nob) -{ - IB_LOCAL_DATASEGMENT *gl = &tx->tx_gl[tx->tx_nsp]; - IB_WORK_REQ *wrq = &tx->tx_wrq[tx->tx_nsp]; - int fence; - int nob = offsetof (kib_msg_t, ibm_u) + body_nob; - - LASSERT (tx->tx_nsp >= 0 && - tx->tx_nsp < sizeof(tx->tx_wrq)/sizeof(tx->tx_wrq[0])); - LASSERT (nob <= IBNAL_MSG_SIZE); - - tx->tx_msg->ibm_magic = IBNAL_MSG_MAGIC; - tx->tx_msg->ibm_version = IBNAL_MSG_VERSION; - tx->tx_msg->ibm_type = type; -#if IBNAL_CKSUM - tx->tx_msg->ibm_nob = nob; -#endif - /* Fence the message if it's bundled with an RDMA read */ - fence = (tx->tx_nsp > 0) && - (type == IBNAL_MSG_PUT_DONE); - - *gl = (IB_LOCAL_DATASEGMENT) { - .Address = tx->tx_vaddr, - .Length = IBNAL_MSG_SIZE, - .Lkey = kibnal_lkey(kibnal_data.kib_tx_pages), - }; - - wrq->WorkReqId = kibnal_ptr2wreqid(tx, 0); - wrq->Operation = WROpSend; - wrq->DSList = gl; - wrq->DSListDepth = 1; - wrq->MessageLen = nob; - wrq->Req.SendRC.ImmediateData = 0; - wrq->Req.SendRC.Options.s.SolicitedEvent = 1; - wrq->Req.SendRC.Options.s.SignaledCompletion = 1; - wrq->Req.SendRC.Options.s.ImmediateData = 0; - wrq->Req.SendRC.Options.s.Fence = fence; - - tx->tx_nsp++; -} - -static void -kibnal_queue_tx (kib_tx_t *tx, kib_conn_t *conn) -{ - unsigned long flags; - - spin_lock_irqsave(&conn->ibc_lock, flags); - - kibnal_queue_tx_locked (tx, conn); - - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - kibnal_check_sends(conn); -} - -static void -kibnal_launch_tx (kib_tx_t *tx, ptl_nid_t nid) -{ - unsigned long flags; - kib_peer_t *peer; - kib_conn_t *conn; - rwlock_t *g_lock = &kibnal_data.kib_global_lock; - - /* If I get here, I've committed to send, so I complete the tx with - * failure on any problems */ - - LASSERT (tx->tx_conn == NULL); /* only set when assigned a conn */ - LASSERT (tx->tx_nsp > 0); /* work items have been set up */ - - read_lock (g_lock); - - peer = kibnal_find_peer_locked (nid); - if (peer == NULL) { - read_unlock (g_lock); - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - return; - } - - conn = kibnal_find_conn_locked (peer); - if (conn != NULL) { - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); /* 1 ref for the tx */ - read_unlock (g_lock); - - kibnal_queue_tx (tx, conn); - return; - } - - /* Making one or more connections; I'll need a write lock... */ - read_unlock (g_lock); - write_lock_irqsave (g_lock, flags); - - peer = kibnal_find_peer_locked (nid); - if (peer == NULL) { - write_unlock_irqrestore (g_lock, flags); - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - return; - } - - conn = kibnal_find_conn_locked (peer); - if (conn != NULL) { - /* Connection exists; queue message on it */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); /* 1 ref for the tx */ - write_unlock_irqrestore (g_lock, flags); - - kibnal_queue_tx (tx, conn); - return; - } - - if (peer->ibp_connecting == 0) { - if (!time_after_eq(jiffies, peer->ibp_reconnect_time)) { - write_unlock_irqrestore (g_lock, flags); - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - return; - } - - peer->ibp_connecting = 1; - kib_peer_addref(peer); /* extra ref for connd */ - - spin_lock (&kibnal_data.kib_connd_lock); - - list_add_tail (&peer->ibp_connd_list, - &kibnal_data.kib_connd_peers); - wake_up (&kibnal_data.kib_connd_waitq); - - spin_unlock (&kibnal_data.kib_connd_lock); - } - - /* A connection is being established; queue the message... */ - list_add_tail (&tx->tx_list, &peer->ibp_tx_queue); - - write_unlock_irqrestore (g_lock, flags); -} - -static ptl_err_t -kibnal_start_passive_rdma (int type, ptl_nid_t nid, - lib_msg_t *libmsg, ptl_hdr_t *hdr) -{ - int nob = libmsg->md->length; - kib_tx_t *tx; - kib_msg_t *ibmsg; - int rc; - IB_ACCESS_CONTROL access = {0,}; - - LASSERT (type == IBNAL_MSG_PUT_RDMA || type == IBNAL_MSG_GET_RDMA); - LASSERT (nob > 0); - LASSERT (!in_interrupt()); /* Mapping could block */ - - access.s.MWBindable = 1; - access.s.LocalWrite = 1; - access.s.RdmaRead = 1; - access.s.RdmaWrite = 1; - - tx = kibnal_get_idle_tx (1); /* May block; caller is an app thread */ - LASSERT (tx != NULL); - - if ((libmsg->md->options & PTL_MD_KIOV) == 0) - rc = kibnal_map_iov (tx, access, - libmsg->md->md_niov, - libmsg->md->md_iov.iov, - 0, nob, 0); - else - rc = kibnal_map_kiov (tx, access, - libmsg->md->md_niov, - libmsg->md->md_iov.kiov, - 0, nob, 0); - - if (rc != 0) { - CERROR ("Can't map RDMA for "LPX64": %d\n", nid, rc); - goto failed; - } - - if (type == IBNAL_MSG_GET_RDMA) { - /* reply gets finalized when tx completes */ - tx->tx_libmsg[1] = lib_create_reply_msg(&kibnal_lib, - nid, libmsg); - if (tx->tx_libmsg[1] == NULL) { - CERROR ("Can't create reply for GET -> "LPX64"\n", - nid); - rc = -ENOMEM; - goto failed; - } - } - - tx->tx_passive_rdma = 1; - - ibmsg = tx->tx_msg; - - ibmsg->ibm_u.rdma.ibrm_hdr = *hdr; - ibmsg->ibm_u.rdma.ibrm_cookie = tx->tx_passive_rdma_cookie; - /* map_kiov alrady filled the rdma descs for the whole_mem case */ - if (!kibnal_whole_mem()) { - ibmsg->ibm_u.rdma.ibrm_desc[0].rd_key = tx->tx_md.md_rkey; - ibmsg->ibm_u.rdma.ibrm_desc[0].rd_addr = tx->tx_md.md_addr; - ibmsg->ibm_u.rdma.ibrm_desc[0].rd_nob = nob; - ibmsg->ibm_u.rdma.ibrm_num_descs = 1; - } - - kibnal_init_tx_msg (tx, type, - kib_rdma_msg_len(ibmsg->ibm_u.rdma.ibrm_num_descs)); - - CDEBUG(D_NET, "Passive: %p cookie "LPX64", key %x, addr " - LPX64", nob %d\n", - tx, tx->tx_passive_rdma_cookie, tx->tx_md.md_rkey, - tx->tx_md.md_addr, nob); - - /* libmsg gets finalized when tx completes. */ - tx->tx_libmsg[0] = libmsg; - - kibnal_launch_tx(tx, nid); - return (PTL_OK); - - failed: - tx->tx_status = rc; - kibnal_tx_done (tx); - return (PTL_FAIL); -} - -void -kibnal_start_active_rdma (int type, int status, - kib_rx_t *rx, lib_msg_t *libmsg, - unsigned int niov, - struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t nob) -{ - kib_msg_t *rxmsg = rx->rx_msg; - kib_msg_t *txmsg; - kib_tx_t *tx; - IB_ACCESS_CONTROL access = {0,}; - IB_WR_OP rdma_op; - int rc; - __u32 i; - - CDEBUG(D_NET, "type %d, status %d, niov %d, offset %d, nob %d\n", - type, status, niov, offset, nob); - - /* Called by scheduler */ - LASSERT (!in_interrupt ()); - - /* Either all pages or all vaddrs */ - LASSERT (!(kiov != NULL && iov != NULL)); - - /* No data if we're completing with failure */ - LASSERT (status == 0 || nob == 0); - - LASSERT (type == IBNAL_MSG_GET_DONE || - type == IBNAL_MSG_PUT_DONE); - - /* Flag I'm completing the RDMA. Even if I fail to send the - * completion message, I will have tried my best so further - * attempts shouldn't be tried. */ - LASSERT (!rx->rx_rdma); - rx->rx_rdma = 1; - - if (type == IBNAL_MSG_GET_DONE) { - rdma_op = WROpRdmaWrite; - LASSERT (rxmsg->ibm_type == IBNAL_MSG_GET_RDMA); - } else { - access.s.LocalWrite = 1; - rdma_op = WROpRdmaRead; - LASSERT (rxmsg->ibm_type == IBNAL_MSG_PUT_RDMA); - } - - tx = kibnal_get_idle_tx (0); /* Mustn't block */ - if (tx == NULL) { - CERROR ("tx descs exhausted on RDMA from "LPX64 - " completing locally with failure\n", - rx->rx_conn->ibc_peer->ibp_nid); - lib_finalize (&kibnal_lib, NULL, libmsg, PTL_NO_SPACE); - return; - } - LASSERT (tx->tx_nsp == 0); - - if (nob == 0) - GOTO(init_tx, 0); - - /* We actually need to transfer some data (the transfer - * size could get truncated to zero when the incoming - * message is matched) */ - if (kiov != NULL) - rc = kibnal_map_kiov (tx, access, niov, kiov, offset, nob, 1); - else - rc = kibnal_map_iov (tx, access, niov, iov, offset, nob, 1); - - if (rc != 0) { - CERROR ("Can't map RDMA -> "LPX64": %d\n", - rx->rx_conn->ibc_peer->ibp_nid, rc); - /* We'll skip the RDMA and complete with failure. */ - status = rc; - nob = 0; - GOTO(init_tx, rc); - } - - if (!kibnal_whole_mem()) { - tx->tx_msg->ibm_u.rdma.ibrm_desc[0].rd_key = tx->tx_md.md_lkey; - tx->tx_msg->ibm_u.rdma.ibrm_desc[0].rd_addr = tx->tx_md.md_addr; - tx->tx_msg->ibm_u.rdma.ibrm_desc[0].rd_nob = nob; - tx->tx_msg->ibm_u.rdma.ibrm_num_descs = 1; - } - - /* XXX ugh. different page-sized hosts. */ - if (tx->tx_msg->ibm_u.rdma.ibrm_num_descs != - rxmsg->ibm_u.rdma.ibrm_num_descs) { - CERROR("tx descs (%u) != rx descs (%u)\n", - tx->tx_msg->ibm_u.rdma.ibrm_num_descs, - rxmsg->ibm_u.rdma.ibrm_num_descs); - /* We'll skip the RDMA and complete with failure. */ - status = rc; - nob = 0; - GOTO(init_tx, rc); - } - - /* map_kiov filled in the rdma descs which describe our side of the - * rdma transfer. */ - /* ibrm_num_descs was verified in rx_callback */ - for(i = 0; i < rxmsg->ibm_u.rdma.ibrm_num_descs; i++) { - kib_rdma_desc_t *ldesc, *rdesc; /* local, remote */ - IB_LOCAL_DATASEGMENT *ds = &tx->tx_gl[i]; - IB_WORK_REQ *wrq = &tx->tx_wrq[i]; - - ldesc = &tx->tx_msg->ibm_u.rdma.ibrm_desc[i]; - rdesc = &rxmsg->ibm_u.rdma.ibrm_desc[i]; - - ds->Address = ldesc->rd_addr; - ds->Length = ldesc->rd_nob; - ds->Lkey = ldesc->rd_key; - - memset(wrq, 0, sizeof(*wrq)); - wrq->WorkReqId = kibnal_ptr2wreqid(tx, 0); - wrq->Operation = rdma_op; - wrq->DSList = ds; - wrq->DSListDepth = 1; - wrq->MessageLen = ds->Length; - wrq->Req.SendRC.ImmediateData = 0; - wrq->Req.SendRC.Options.s.SolicitedEvent = 0; - wrq->Req.SendRC.Options.s.SignaledCompletion = 0; - wrq->Req.SendRC.Options.s.ImmediateData = 0; - wrq->Req.SendRC.Options.s.Fence = 0; - wrq->Req.SendRC.RemoteDS.Address = rdesc->rd_addr; - wrq->Req.SendRC.RemoteDS.Rkey = rdesc->rd_key; - - /* only the last rdma post triggers tx completion */ - if (i == rxmsg->ibm_u.rdma.ibrm_num_descs - 1) - wrq->Req.SendRC.Options.s.SignaledCompletion = 1; - - tx->tx_nsp++; - } - -init_tx: - txmsg = tx->tx_msg; - - txmsg->ibm_u.completion.ibcm_cookie = rxmsg->ibm_u.rdma.ibrm_cookie; - txmsg->ibm_u.completion.ibcm_status = status; - - kibnal_init_tx_msg(tx, type, sizeof (kib_completion_msg_t)); - - if (status == 0 && nob != 0) { - LASSERT (tx->tx_nsp > 1); - /* RDMA: libmsg gets finalized when the tx completes. This - * is after the completion message has been sent, which in - * turn is after the RDMA has finished. */ - tx->tx_libmsg[0] = libmsg; - } else { - LASSERT (tx->tx_nsp == 1); - /* No RDMA: local completion happens now! */ - CDEBUG(D_WARNING,"No data: immediate completion\n"); - lib_finalize (&kibnal_lib, NULL, libmsg, - status == 0 ? PTL_OK : PTL_FAIL); - } - - /* +1 ref for this tx... */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - rx->rx_conn, rx->rx_conn->ibc_state, - rx->rx_conn->ibc_peer->ibp_nid, - atomic_read (&rx->rx_conn->ibc_refcount)); - atomic_inc (&rx->rx_conn->ibc_refcount); - /* ...and queue it up */ - kibnal_queue_tx(tx, rx->rx_conn); -} - -static ptl_err_t -kibnal_sendmsg(lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - struct iovec *payload_iov, - ptl_kiov_t *payload_kiov, - size_t payload_offset, - size_t payload_nob) -{ - kib_msg_t *ibmsg; - kib_tx_t *tx; - int nob; - - /* NB 'private' is different depending on what we're sending.... */ - - CDEBUG(D_NET, "sending "LPSZ" bytes in %d frags to nid:"LPX64 - " pid %d\n", payload_nob, payload_niov, nid , pid); - - LASSERT (payload_nob == 0 || payload_niov > 0); - LASSERT (payload_niov <= PTL_MD_MAX_IOV); - - /* Thread context if we're sending payload */ - LASSERT (!in_interrupt() || payload_niov == 0); - /* payload is either all vaddrs or all pages */ - LASSERT (!(payload_kiov != NULL && payload_iov != NULL)); - - switch (type) { - default: - LBUG(); - return (PTL_FAIL); - - case PTL_MSG_REPLY: { - /* reply's 'private' is the incoming receive */ - kib_rx_t *rx = private; - - /* RDMA reply expected? */ - if (rx->rx_msg->ibm_type == IBNAL_MSG_GET_RDMA) { - kibnal_start_active_rdma(IBNAL_MSG_GET_DONE, 0, - rx, libmsg, payload_niov, - payload_iov, payload_kiov, - payload_offset, payload_nob); - return (PTL_OK); - } - - /* Incoming message consistent with immediate reply? */ - if (rx->rx_msg->ibm_type != IBNAL_MSG_IMMEDIATE) { - CERROR ("REPLY to "LPX64" bad opbm type %d!!!\n", - nid, rx->rx_msg->ibm_type); - return (PTL_FAIL); - } - - /* Will it fit in a message? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob]); - if (nob >= IBNAL_MSG_SIZE) { - CERROR("REPLY for "LPX64" too big (RDMA not requested): %d\n", - nid, payload_nob); - return (PTL_FAIL); - } - break; - } - - case PTL_MSG_GET: - /* might the REPLY message be big enough to need RDMA? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[libmsg->md->length]); - if (nob > IBNAL_MSG_SIZE) - return (kibnal_start_passive_rdma(IBNAL_MSG_GET_RDMA, - nid, libmsg, hdr)); - break; - - case PTL_MSG_ACK: - LASSERT (payload_nob == 0); - break; - - case PTL_MSG_PUT: - /* Is the payload big enough to need RDMA? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob]); - if (nob > IBNAL_MSG_SIZE) - return (kibnal_start_passive_rdma(IBNAL_MSG_PUT_RDMA, - nid, libmsg, hdr)); - - break; - } - - tx = kibnal_get_idle_tx(!(type == PTL_MSG_ACK || - type == PTL_MSG_REPLY || - in_interrupt())); - if (tx == NULL) { - CERROR ("Can't send %d to "LPX64": tx descs exhausted%s\n", - type, nid, in_interrupt() ? " (intr)" : ""); - return (PTL_NO_SPACE); - } - - ibmsg = tx->tx_msg; - ibmsg->ibm_u.immediate.ibim_hdr = *hdr; - - if (payload_nob > 0) { - if (payload_kiov != NULL) - lib_copy_kiov2buf(ibmsg->ibm_u.immediate.ibim_payload, - payload_niov, payload_kiov, - payload_offset, payload_nob); - else - lib_copy_iov2buf(ibmsg->ibm_u.immediate.ibim_payload, - payload_niov, payload_iov, - payload_offset, payload_nob); - } - - kibnal_init_tx_msg (tx, IBNAL_MSG_IMMEDIATE, - offsetof(kib_immediate_msg_t, - ibim_payload[payload_nob])); - - /* libmsg gets finalized when tx completes */ - tx->tx_libmsg[0] = libmsg; - - kibnal_launch_tx(tx, nid); - return (PTL_OK); -} - -static ptl_err_t -kibnal_send (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, struct iovec *payload_iov, - size_t payload_offset, size_t payload_len) -{ - return (kibnal_sendmsg(nal, private, cookie, - hdr, type, nid, pid, - payload_niov, payload_iov, NULL, - payload_offset, payload_len)); -} - -static ptl_err_t -kibnal_send_pages (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, ptl_kiov_t *payload_kiov, - size_t payload_offset, size_t payload_len) -{ - return (kibnal_sendmsg(nal, private, cookie, - hdr, type, nid, pid, - payload_niov, NULL, payload_kiov, - payload_offset, payload_len)); -} - -static ptl_err_t -kibnal_recvmsg (lib_nal_t *nal, void *private, lib_msg_t *libmsg, - unsigned int niov, struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t mlen, size_t rlen) -{ - kib_rx_t *rx = private; - kib_msg_t *rxmsg = rx->rx_msg; - int msg_nob; - - LASSERT (mlen <= rlen); - LASSERT (!in_interrupt ()); - /* Either all pages or all vaddrs */ - LASSERT (!(kiov != NULL && iov != NULL)); - - switch (rxmsg->ibm_type) { - default: - LBUG(); - return (PTL_FAIL); - - case IBNAL_MSG_IMMEDIATE: - msg_nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[rlen]); - if (msg_nob > IBNAL_MSG_SIZE) { - CERROR ("Immediate message from "LPX64" too big: %d\n", - rxmsg->ibm_u.immediate.ibim_hdr.src_nid, rlen); - return (PTL_FAIL); - } - - if (kiov != NULL) - lib_copy_buf2kiov(niov, kiov, offset, - rxmsg->ibm_u.immediate.ibim_payload, - mlen); - else - lib_copy_buf2iov(niov, iov, offset, - rxmsg->ibm_u.immediate.ibim_payload, - mlen); - - lib_finalize (nal, NULL, libmsg, PTL_OK); - return (PTL_OK); - - case IBNAL_MSG_GET_RDMA: - /* We get called here just to discard any junk after the - * GET hdr. */ - LASSERT (libmsg == NULL); - lib_finalize (nal, NULL, libmsg, PTL_OK); - return (PTL_OK); - - case IBNAL_MSG_PUT_RDMA: - kibnal_start_active_rdma (IBNAL_MSG_PUT_DONE, 0, - rx, libmsg, - niov, iov, kiov, offset, mlen); - return (PTL_OK); - } -} - -static ptl_err_t -kibnal_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, struct iovec *iov, - size_t offset, size_t mlen, size_t rlen) -{ - return (kibnal_recvmsg (nal, private, msg, niov, iov, NULL, - offset, mlen, rlen)); -} - -static ptl_err_t -kibnal_recv_pages (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, ptl_kiov_t *kiov, - size_t offset, size_t mlen, size_t rlen) -{ - return (kibnal_recvmsg (nal, private, msg, niov, NULL, kiov, - offset, mlen, rlen)); -} - -/***************************************************************************** - * the rest of this file concerns connection management. active connetions - * start with connect_peer, passive connections start with passive_callback. - * active disconnects start with conn_close, cm_callback starts passive - * disconnects and contains the guts of how the disconnect state machine - * progresses. - *****************************************************************************/ - -int -kibnal_thread_start (int (*fn)(void *arg), void *arg) -{ - long pid = kernel_thread (fn, arg, 0); - - if (pid < 0) - return ((int)pid); - - atomic_inc (&kibnal_data.kib_nthreads); - return (0); -} - -static void -kibnal_thread_fini (void) -{ - atomic_dec (&kibnal_data.kib_nthreads); -} - -/* this can be called by anyone at any time to close a connection. if - * the connection is still established it heads to the connd to start - * the disconnection in a safe context. It has no effect if called - * on a connection that is already disconnecting */ -void -kibnal_close_conn_locked (kib_conn_t *conn, int error) -{ - /* This just does the immmediate housekeeping, and schedules the - * connection for the connd to finish off. - * Caller holds kib_global_lock exclusively in irq context */ - kib_peer_t *peer = conn->ibc_peer; - - KIB_ASSERT_CONN_STATE_RANGE(conn, IBNAL_CONN_CONNECTING, - IBNAL_CONN_DISCONNECTED); - - if (conn->ibc_state > IBNAL_CONN_ESTABLISHED) - return; /* already disconnecting */ - - CDEBUG (error == 0 ? D_NET : D_ERROR, - "closing conn to "LPX64": error %d\n", peer->ibp_nid, error); - - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) { - /* kib_connd_conns takes ibc_list's ref */ - list_del (&conn->ibc_list); - } else { - /* new ref for kib_connd_conns */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - } - - if (list_empty (&peer->ibp_conns) && - peer->ibp_persistence == 0) { - /* Non-persistent peer with no more conns... */ - kibnal_unlink_peer_locked (peer); - } - - conn->ibc_state = IBNAL_CONN_SEND_DREQ; - - spin_lock (&kibnal_data.kib_connd_lock); - - list_add_tail (&conn->ibc_list, &kibnal_data.kib_connd_conns); - wake_up (&kibnal_data.kib_connd_waitq); - - spin_unlock (&kibnal_data.kib_connd_lock); -} - -void -kibnal_close_conn (kib_conn_t *conn, int error) -{ - unsigned long flags; - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - kibnal_close_conn_locked (conn, error); - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); -} - -static void -kibnal_peer_connect_failed (kib_peer_t *peer, int active, int rc) -{ - LIST_HEAD (zombies); - kib_tx_t *tx; - unsigned long flags; - - LASSERT (rc != 0); - LASSERT (peer->ibp_reconnect_interval >= IBNAL_MIN_RECONNECT_INTERVAL); - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - LASSERT (peer->ibp_connecting != 0); - peer->ibp_connecting--; - - if (peer->ibp_connecting != 0) { - /* another connection attempt under way (loopback?)... */ - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - return; - } - - if (list_empty(&peer->ibp_conns)) { - /* Say when active connection can be re-attempted */ - peer->ibp_reconnect_time = jiffies + peer->ibp_reconnect_interval; - /* Increase reconnection interval */ - peer->ibp_reconnect_interval = MIN (peer->ibp_reconnect_interval * 2, - IBNAL_MAX_RECONNECT_INTERVAL); - - /* Take peer's blocked blocked transmits; I'll complete - * them with error */ - while (!list_empty (&peer->ibp_tx_queue)) { - tx = list_entry (peer->ibp_tx_queue.next, - kib_tx_t, tx_list); - - list_del (&tx->tx_list); - list_add_tail (&tx->tx_list, &zombies); - } - - if (kibnal_peer_active(peer) && - (peer->ibp_persistence == 0)) { - /* failed connection attempt on non-persistent peer */ - kibnal_unlink_peer_locked (peer); - } - } else { - /* Can't have blocked transmits if there are connections */ - LASSERT (list_empty(&peer->ibp_tx_queue)); - } - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - if (!list_empty (&zombies)) - CERROR ("Deleting messages for "LPX64": connection failed\n", - peer->ibp_nid); - - while (!list_empty (&zombies)) { - tx = list_entry (zombies.next, kib_tx_t, tx_list); - - list_del (&tx->tx_list); - /* complete now */ - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - } -} - -static void -kibnal_connreq_done (kib_conn_t *conn, int active, int status) -{ - int state = conn->ibc_state; - kib_peer_t *peer = conn->ibc_peer; - kib_tx_t *tx; - unsigned long flags; - int i; - - /* passive connection has no connreq & vice versa */ - LASSERTF(!active == !(conn->ibc_connreq != NULL), - "%d %p\n", active, conn->ibc_connreq); - if (active) { - PORTAL_FREE (conn->ibc_connreq, sizeof (*conn->ibc_connreq)); - conn->ibc_connreq = NULL; - } - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - LASSERT (peer->ibp_connecting != 0); - - if (status == 0) { - /* connection established... */ - KIB_ASSERT_CONN_STATE(conn, IBNAL_CONN_CONNECTING); - conn->ibc_state = IBNAL_CONN_ESTABLISHED; - - if (!kibnal_peer_active(peer)) { - /* ...but peer deleted meantime */ - status = -ECONNABORTED; - } - } else { - KIB_ASSERT_CONN_STATE_RANGE(conn, IBNAL_CONN_INIT_QP, - IBNAL_CONN_CONNECTING); - } - - if (status == 0) { - /* Everything worked! */ - - peer->ibp_connecting--; - - /* +1 ref for ibc_list; caller(== CM)'s ref remains until - * the IB_CM_IDLE callback */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - list_add (&conn->ibc_list, &peer->ibp_conns); - - /* reset reconnect interval for next attempt */ - peer->ibp_reconnect_interval = IBNAL_MIN_RECONNECT_INTERVAL; - - /* post blocked sends to the new connection */ - spin_lock (&conn->ibc_lock); - - while (!list_empty (&peer->ibp_tx_queue)) { - tx = list_entry (peer->ibp_tx_queue.next, - kib_tx_t, tx_list); - - list_del (&tx->tx_list); - - /* +1 ref for each tx */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - kibnal_queue_tx_locked (tx, conn); - } - - spin_unlock (&conn->ibc_lock); - - /* Nuke any dangling conns from a different peer instance... */ - kibnal_close_stale_conns_locked (conn->ibc_peer, - conn->ibc_incarnation); - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - /* queue up all the receives */ - for (i = 0; i < IBNAL_RX_MSGS; i++) { - /* +1 ref for rx desc */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - - CDEBUG(D_NET, "RX[%d] %p->%p - "LPX64"\n", - i, &conn->ibc_rxs[i], conn->ibc_rxs[i].rx_msg, - conn->ibc_rxs[i].rx_vaddr); - - kibnal_post_rx (&conn->ibc_rxs[i], 0); - } - - kibnal_check_sends (conn); - return; - } - - /* connection failed */ - if (state == IBNAL_CONN_CONNECTING) { - /* schedule for connd to close */ - kibnal_close_conn_locked (conn, status); - } else { - /* Don't have a CM comm_id; just wait for refs to drain */ - conn->ibc_state = IBNAL_CONN_DISCONNECTED; - } - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - kibnal_peer_connect_failed (conn->ibc_peer, active, status); - - /* If we didn't establish the connection we don't have to pass - * through the disconnect protocol before dropping the CM ref */ - if (state < IBNAL_CONN_CONNECTING) - kibnal_put_conn (conn); -} - -static int -kibnal_accept (kib_conn_t **connp, IB_HANDLE *cep, - ptl_nid_t nid, __u64 incarnation, int queue_depth) -{ - kib_conn_t *conn = kibnal_create_conn(); - kib_peer_t *peer; - kib_peer_t *peer2; - unsigned long flags; - - if (conn == NULL) - return (-ENOMEM); - - if (queue_depth != IBNAL_MSG_QUEUE_SIZE) { - CERROR("Can't accept "LPX64": bad queue depth %d (%d expected)\n", - nid, queue_depth, IBNAL_MSG_QUEUE_SIZE); - atomic_dec (&conn->ibc_refcount); - kibnal_destroy_conn(conn); - return (-EPROTO); - } - - /* assume 'nid' is a new peer */ - peer = kibnal_create_peer (nid); - if (peer == NULL) { - CDEBUG(D_NET, "--conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_dec (&conn->ibc_refcount); - kibnal_destroy_conn(conn); - return (-ENOMEM); - } - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - peer2 = kibnal_find_peer_locked(nid); - if (peer2 == NULL) { - /* peer table takes my ref on peer */ - list_add_tail (&peer->ibp_list, kibnal_nid2peerlist(nid)); - } else { - kib_peer_decref (peer); - peer = peer2; - } - - kib_peer_addref(peer); /* +1 ref for conn */ - peer->ibp_connecting++; - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - conn->ibc_peer = peer; - conn->ibc_state = IBNAL_CONN_CONNECTING; - /* conn->ibc_cep is set when cm_accept is called */ - conn->ibc_incarnation = incarnation; - conn->ibc_credits = IBNAL_MSG_QUEUE_SIZE; - - *connp = conn; - return (0); -} - -static void kibnal_set_qp_state(IB_HANDLE *qp, IB_QP_STATE state) -{ - IB_QP_ATTRIBUTES_MODIFY modify_attr = {0,}; - FSTATUS frc; - - modify_attr.RequestState = state; - - frc = iibt_qp_modify(qp, &modify_attr, NULL); - if (frc != FSUCCESS) - CERROR("couldn't set qp state to %d, error %d\n", state, frc); -} - -static void kibnal_flush_pending(kib_conn_t *conn) -{ - LIST_HEAD (zombies); - struct list_head *tmp; - struct list_head *nxt; - kib_tx_t *tx; - unsigned long flags; - int done; - - /* NB we wait until the connection has closed before completing - * outstanding passive RDMAs so we can be sure the network can't - * touch the mapped memory any more. */ - KIB_ASSERT_CONN_STATE(conn, IBNAL_CONN_DISCONNECTED); - - /* set the QP to the error state so that we get flush callbacks - * on our posted receives which can then drop their conn refs */ - kibnal_set_qp_state(conn->ibc_qp, QPStateError); - - spin_lock_irqsave (&conn->ibc_lock, flags); - - /* grab passive RDMAs not waiting for the tx callback */ - list_for_each_safe (tmp, nxt, &conn->ibc_active_txs) { - tx = list_entry (tmp, kib_tx_t, tx_list); - - LASSERT (tx->tx_passive_rdma || - !tx->tx_passive_rdma_wait); - - LASSERT (tx->tx_passive_rdma_wait || - tx->tx_sending != 0); - - /* still waiting for tx callback? */ - if (!tx->tx_passive_rdma_wait) - continue; - - tx->tx_status = -ECONNABORTED; - tx->tx_passive_rdma_wait = 0; - done = (tx->tx_sending == 0); - - if (!done) - continue; - - list_del (&tx->tx_list); - list_add (&tx->tx_list, &zombies); - } - - /* grab all blocked transmits */ - list_for_each_safe (tmp, nxt, &conn->ibc_tx_queue) { - tx = list_entry (tmp, kib_tx_t, tx_list); - - list_del (&tx->tx_list); - list_add (&tx->tx_list, &zombies); - } - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - while (!list_empty(&zombies)) { - tx = list_entry (zombies.next, kib_tx_t, tx_list); - - list_del(&tx->tx_list); - kibnal_tx_done (tx); - } -} - -static void -kibnal_reject (IB_HANDLE cep, uint16_t reason) -{ - CM_REJECT_INFO *rej; - - PORTAL_ALLOC(rej, sizeof(*rej)); - if (rej == NULL) /* PORTAL_ALLOC() will CERROR on failure */ - return; - - rej->Reason = reason; - iibt_cm_reject(cep, rej); - PORTAL_FREE(rej, sizeof(*rej)); -} - -static FSTATUS -kibnal_qp_rts(IB_HANDLE qp_handle, __u32 qpn, __u8 resp_res, - IB_PATH_RECORD *path, __u8 init_depth, __u32 send_psn) -{ - IB_QP_ATTRIBUTES_MODIFY modify_attr; - FSTATUS frc; - ENTRY; - - modify_attr = (IB_QP_ATTRIBUTES_MODIFY) { - .RequestState = QPStateReadyToRecv, - .RecvPSN = IBNAL_STARTING_PSN, - .DestQPNumber = qpn, - .ResponderResources = resp_res, - .MinRnrTimer = UsecToRnrNakTimer(2000), /* 20 ms */ - .Attrs = (IB_QP_ATTR_RECVPSN | - IB_QP_ATTR_DESTQPNUMBER | - IB_QP_ATTR_RESPONDERRESOURCES | - IB_QP_ATTR_DESTAV | - IB_QP_ATTR_PATHMTU | - IB_QP_ATTR_MINRNRTIMER), - }; - GetAVFromPath(0, path, &modify_attr.PathMTU, NULL, - &modify_attr.DestAV); - - frc = iibt_qp_modify(qp_handle, &modify_attr, NULL); - if (frc != FSUCCESS) - RETURN(frc); - - modify_attr = (IB_QP_ATTRIBUTES_MODIFY) { - .RequestState = QPStateReadyToSend, - .FlowControl = TRUE, - .InitiatorDepth = init_depth, - .SendPSN = send_psn, - .LocalAckTimeout = path->PktLifeTime + 2, /* 2 or 1? */ - .RetryCount = IBNAL_RETRY, - .RnrRetryCount = IBNAL_RNR_RETRY, - .Attrs = (IB_QP_ATTR_FLOWCONTROL | - IB_QP_ATTR_INITIATORDEPTH | - IB_QP_ATTR_SENDPSN | - IB_QP_ATTR_LOCALACKTIMEOUT | - IB_QP_ATTR_RETRYCOUNT | - IB_QP_ATTR_RNRRETRYCOUNT), - }; - - frc = iibt_qp_modify(qp_handle, &modify_attr, NULL); - RETURN(frc); -} - -static void -kibnal_connect_reply (IB_HANDLE cep, CM_CONN_INFO *info, void *arg) -{ - IB_CA_ATTRIBUTES *ca_attr = &kibnal_data.kib_hca_attrs; - kib_conn_t *conn = arg; - kib_wire_connreq_t *wcr; - CM_REPLY_INFO *rep = &info->Info.Reply; - uint16_t reason; - FSTATUS frc; - - wcr = (kib_wire_connreq_t *)info->Info.Reply.PrivateData; - - if (wcr->wcr_magic != cpu_to_le32(IBNAL_MSG_MAGIC)) { - CERROR ("Can't connect "LPX64": bad magic %08x\n", - conn->ibc_peer->ibp_nid, le32_to_cpu(wcr->wcr_magic)); - GOTO(reject, reason = RC_USER_REJ); - } - - if (wcr->wcr_version != cpu_to_le16(IBNAL_MSG_VERSION)) { - CERROR ("Can't connect "LPX64": bad version %d\n", - conn->ibc_peer->ibp_nid, le16_to_cpu(wcr->wcr_magic)); - GOTO(reject, reason = RC_USER_REJ); - } - - if (wcr->wcr_queue_depth != cpu_to_le16(IBNAL_MSG_QUEUE_SIZE)) { - CERROR ("Can't connect "LPX64": bad queue depth %d\n", - conn->ibc_peer->ibp_nid, - le16_to_cpu(wcr->wcr_queue_depth)); - GOTO(reject, reason = RC_USER_REJ); - } - - if (le64_to_cpu(wcr->wcr_nid) != conn->ibc_peer->ibp_nid) { - CERROR ("Unexpected NID "LPX64" from "LPX64"\n", - le64_to_cpu(wcr->wcr_nid), conn->ibc_peer->ibp_nid); - GOTO(reject, reason = RC_USER_REJ); - } - - CDEBUG(D_NET, "Connection %p -> "LPX64" REP_RECEIVED.\n", - conn, conn->ibc_peer->ibp_nid); - - conn->ibc_incarnation = le64_to_cpu(wcr->wcr_incarnation); - conn->ibc_credits = IBNAL_MSG_QUEUE_SIZE; - - frc = kibnal_qp_rts(conn->ibc_qp, rep->QPN, - min_t(__u8, rep->ArbInitiatorDepth, - ca_attr->MaxQPResponderResources), - &conn->ibc_connreq->cr_path, - min_t(__u8, rep->ArbResponderResources, - ca_attr->MaxQPInitiatorDepth), - rep->StartingPSN); - if (frc != FSUCCESS) { - CERROR("Connection %p -> "LPX64" QP RTS/RTR failed: %d\n", - conn, conn->ibc_peer->ibp_nid, frc); - GOTO(reject, reason = RC_NO_QP); - } - - /* the callback arguments are ignored for an active accept */ - conn->ibc_connreq->cr_discarded.Status = FSUCCESS; - frc = iibt_cm_accept(cep, &conn->ibc_connreq->cr_discarded, - NULL, NULL, NULL, NULL); - if (frc != FCM_CONNECT_ESTABLISHED) { - CERROR("Connection %p -> "LPX64" CMAccept failed: %d\n", - conn, conn->ibc_peer->ibp_nid, frc); - kibnal_connreq_done (conn, 1, -ECONNABORTED); - /* XXX don't call reject after accept fails? */ - return; - } - - CDEBUG(D_NET, "Connection %p -> "LPX64" Established\n", - conn, conn->ibc_peer->ibp_nid); - - kibnal_connreq_done (conn, 1, 0); - return; - -reject: - kibnal_reject(cep, reason); - kibnal_connreq_done (conn, 1, -EPROTO); -} - -/* ib_cm.h has a wealth of information on the CM procedures */ -static void -kibnal_cm_callback(IB_HANDLE cep, CM_CONN_INFO *info, void *arg) -{ - kib_conn_t *conn = arg; - - CDEBUG(D_NET, "status 0x%x\n", info->Status); - - /* Established Connection Notifier */ - switch (info->Status) { - default: - CERROR("unknown status %d on Connection %p -> "LPX64"\n", - info->Status, conn, conn->ibc_peer->ibp_nid); - LBUG(); - break; - - case FCM_CONNECT_REPLY: - kibnal_connect_reply(cep, info, arg); - break; - - case FCM_DISCONNECT_REQUEST: - /* XXX lock around these state management bits? */ - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) - kibnal_close_conn (conn, 0); - conn->ibc_state = IBNAL_CONN_DREP; - iibt_cm_disconnect(conn->ibc_cep, NULL, NULL); - break; - - /* these both guarantee that no more cm callbacks will occur */ - case FCM_DISCONNECTED: /* aka FCM_DISCONNECT_TIMEOUT */ - case FCM_DISCONNECT_REPLY: - CDEBUG(D_NET, "Connection %p -> "LPX64" disconnect done.\n", - conn, conn->ibc_peer->ibp_nid); - - conn->ibc_state = IBNAL_CONN_DISCONNECTED; - kibnal_flush_pending(conn); - kibnal_put_conn(conn); /* Lose CM's ref */ - break; - } - - return; -} - -static int -kibnal_set_cm_flags(IB_HANDLE cep) -{ - FSTATUS frc; - uint32 value = 1; - - frc = iibt_cm_modify_cep(cep, CM_FLAG_TIMEWAIT_CALLBACK, - (char *)&value, sizeof(value), 0); - if (frc != FSUCCESS) { - CERROR("error setting timeout callback: %d\n", frc); - return -1; - } - -#if 0 - frc = iibt_cm_modify_cep(cep, CM_FLAG_ASYNC_ACCEPT, (char *)&value, - sizeof(value), 0); - if (frc != FSUCCESS) { - CERROR("error setting async accept: %d\n", frc); - return -1; - } -#endif - - return 0; -} - -void -kibnal_listen_callback(IB_HANDLE cep, CM_CONN_INFO *info, void *arg) -{ - IB_CA_ATTRIBUTES *ca_attr = &kibnal_data.kib_hca_attrs; - IB_QP_ATTRIBUTES_QUERY *query; - CM_REQUEST_INFO *req; - CM_CONN_INFO *rep = NULL, *rcv = NULL; - kib_wire_connreq_t *wcr; - kib_conn_t *conn = NULL; - uint16_t reason = 0; - FSTATUS frc; - int rc = 0; - - LASSERT(cep); - LASSERT(info); - LASSERT(arg == NULL); /* no conn yet for passive */ - - CDEBUG(D_NET, "status 0x%x\n", info->Status); - - req = &info->Info.Request; - wcr = (kib_wire_connreq_t *)req->PrivateData; - - CDEBUG(D_NET, "%d from "LPX64"\n", info->Status, - le64_to_cpu(wcr->wcr_nid)); - - if (info->Status == FCM_CONNECT_CANCEL) - return; - - LASSERT (info->Status == FCM_CONNECT_REQUEST); - - if (wcr->wcr_magic != cpu_to_le32(IBNAL_MSG_MAGIC)) { - CERROR ("Can't accept: bad magic %08x\n", - le32_to_cpu(wcr->wcr_magic)); - GOTO(out, reason = RC_USER_REJ); - } - - if (wcr->wcr_version != cpu_to_le16(IBNAL_MSG_VERSION)) { - CERROR ("Can't accept: bad version %d\n", - le16_to_cpu(wcr->wcr_magic)); - GOTO(out, reason = RC_USER_REJ); - } - - rc = kibnal_accept(&conn, cep, - le64_to_cpu(wcr->wcr_nid), - le64_to_cpu(wcr->wcr_incarnation), - le16_to_cpu(wcr->wcr_queue_depth)); - if (rc != 0) { - CERROR ("Can't accept "LPX64": %d\n", - le64_to_cpu(wcr->wcr_nid), rc); - GOTO(out, reason = RC_NO_RESOURCES); - } - - frc = kibnal_qp_rts(conn->ibc_qp, req->CEPInfo.QPN, - min_t(__u8, req->CEPInfo.OfferedInitiatorDepth, - ca_attr->MaxQPResponderResources), - &req->PathInfo.Path, - min_t(__u8, req->CEPInfo.OfferedResponderResources, - ca_attr->MaxQPInitiatorDepth), - req->CEPInfo.StartingPSN); - - if (frc != FSUCCESS) { - CERROR ("Can't mark QP RTS/RTR "LPX64": %d\n", - le64_to_cpu(wcr->wcr_nid), frc); - GOTO(out, reason = RC_NO_QP); - } - - frc = iibt_qp_query(conn->ibc_qp, &conn->ibc_qp_attrs, NULL); - if (frc != FSUCCESS) { - CERROR ("Couldn't query qp attributes "LPX64": %d\n", - le64_to_cpu(wcr->wcr_nid), frc); - GOTO(out, reason = RC_NO_QP); - } - query = &conn->ibc_qp_attrs; - - PORTAL_ALLOC(rep, sizeof(*rep)); - PORTAL_ALLOC(rcv, sizeof(*rcv)); - if (rep == NULL || rcv == NULL) { - CERROR ("can't reply and receive buffers\n"); - GOTO(out, reason = RC_INSUFFICIENT_RESP_RES); - } - - /* don't try to deref this into the incoming wcr :) */ - wcr = (kib_wire_connreq_t *)rep->Info.Reply.PrivateData; - - rep->Info.Reply = (CM_REPLY_INFO) { - .QPN = query->QPNumber, - .QKey = query->Qkey, - .StartingPSN = query->RecvPSN, - .EndToEndFlowControl = query->FlowControl, - /* XXX Hmm. */ - .ArbInitiatorDepth = query->InitiatorDepth, - .ArbResponderResources = query->ResponderResources, - .TargetAckDelay = 0, - .FailoverAccepted = 0, - .RnRRetryCount = req->CEPInfo.RnrRetryCount, - }; - - *wcr = (kib_wire_connreq_t) { - .wcr_magic = cpu_to_le32(IBNAL_MSG_MAGIC), - .wcr_version = cpu_to_le16(IBNAL_MSG_VERSION), - .wcr_queue_depth = cpu_to_le32(IBNAL_MSG_QUEUE_SIZE), - .wcr_nid = cpu_to_le64(kibnal_data.kib_nid), - .wcr_incarnation = cpu_to_le64(kibnal_data.kib_incarnation), - }; - - frc = iibt_cm_accept(cep, rep, rcv, kibnal_cm_callback, conn, - &conn->ibc_cep); - - PORTAL_FREE(rep, sizeof(*rep)); - PORTAL_FREE(rcv, sizeof(*rcv)); - - if (frc != FCM_CONNECT_ESTABLISHED) { - /* XXX it seems we don't call reject after this point? */ - CERROR("iibt_cm_accept() failed: %d, aborting\n", frc); - rc = -ECONNABORTED; - goto out; - } - - if (kibnal_set_cm_flags(conn->ibc_cep)) { - rc = -ECONNABORTED; - goto out; - } - - CDEBUG(D_WARNING, "Connection %p -> "LPX64" ESTABLISHED.\n", - conn, conn->ibc_peer->ibp_nid); - -out: - if (reason) { - kibnal_reject(cep, reason); - rc = -ECONNABORTED; - } - if (conn != NULL) - kibnal_connreq_done(conn, 0, rc); - - return; -} - -static void -dump_path_records(PATH_RESULTS *results) -{ - IB_PATH_RECORD *path; - int i; - - for(i = 0; i < results->NumPathRecords; i++) { - path = &results->PathRecords[i]; - CDEBUG(D_NET, "%d: sgid "LPX64":"LPX64" dgid " - LPX64":"LPX64" pkey %x\n", - i, - path->SGID.Type.Global.SubnetPrefix, - path->SGID.Type.Global.InterfaceID, - path->DGID.Type.Global.SubnetPrefix, - path->DGID.Type.Global.InterfaceID, - path->P_Key); - } -} - -static void -kibnal_pathreq_callback (void *arg, QUERY *query, - QUERY_RESULT_VALUES *query_res) -{ - IB_CA_ATTRIBUTES *ca_attr = &kibnal_data.kib_hca_attrs; - kib_conn_t *conn = arg; - PATH_RESULTS *path; - FSTATUS frc; - - if (query_res->Status != FSUCCESS || query_res->ResultDataSize == 0) { - CERROR ("status %d data size %d\n", query_res->Status, - query_res->ResultDataSize); - kibnal_connreq_done (conn, 1, -EINVAL); - return; - } - - path = (PATH_RESULTS *)query_res->QueryResult; - - if (path->NumPathRecords < 1) { - CERROR ("expected path records: %d\n", path->NumPathRecords); - kibnal_connreq_done (conn, 1, -EINVAL); - return; - } - - dump_path_records(path); - - /* just using the first. this is probably a horrible idea. */ - conn->ibc_connreq->cr_path = path->PathRecords[0]; - - conn->ibc_cep = iibt_cm_create_cep(CM_RC_TYPE); - if (conn->ibc_cep == NULL) { - CERROR ("Can't create CEP\n"); - kibnal_connreq_done (conn, 1, -EINVAL); - return; - } - - if (kibnal_set_cm_flags(conn->ibc_cep)) { - kibnal_connreq_done (conn, 1, -EINVAL); - return; - } - - conn->ibc_connreq->cr_wcr = (kib_wire_connreq_t) { - .wcr_magic = cpu_to_le32(IBNAL_MSG_MAGIC), - .wcr_version = cpu_to_le16(IBNAL_MSG_VERSION), - .wcr_queue_depth = cpu_to_le16(IBNAL_MSG_QUEUE_SIZE), - .wcr_nid = cpu_to_le64(kibnal_data.kib_nid), - .wcr_incarnation = cpu_to_le64(kibnal_data.kib_incarnation), - }; - - conn->ibc_connreq->cr_cmreq = (CM_REQUEST_INFO) { - .SID = conn->ibc_connreq->cr_service.RID.ServiceID, - .CEPInfo = (CM_CEP_INFO) { - .CaGUID = kibnal_data.kib_hca_guids[0], - .EndToEndFlowControl = FALSE, - .PortGUID = conn->ibc_connreq->cr_path.SGID.Type.Global.InterfaceID, - .RetryCount = IBNAL_RETRY, - .RnrRetryCount = IBNAL_RNR_RETRY, - .AckTimeout = IBNAL_ACK_TIMEOUT, - .StartingPSN = IBNAL_STARTING_PSN, - .QPN = conn->ibc_qp_attrs.QPNumber, - .QKey = conn->ibc_qp_attrs.Qkey, - .OfferedResponderResources = ca_attr->MaxQPResponderResources, - .OfferedInitiatorDepth = ca_attr->MaxQPInitiatorDepth, - }, - .PathInfo = (CM_CEP_PATHINFO) { - .bSubnetLocal = TRUE, - .Path = conn->ibc_connreq->cr_path, - }, - }; - -#if 0 - /* XXX set timeout just like SDP!!!*/ - conn->ibc_connreq->cr_path.packet_life = 13; -#endif - /* Flag I'm getting involved with the CM... */ - conn->ibc_state = IBNAL_CONN_CONNECTING; - - CDEBUG(D_NET, "Connecting to, service id "LPX64", on "LPX64"\n", - conn->ibc_connreq->cr_service.RID.ServiceID, - *kibnal_service_nid_field(&conn->ibc_connreq->cr_service)); - - memset(conn->ibc_connreq->cr_cmreq.PrivateData, 0, - CM_REQUEST_INFO_USER_LEN); - memcpy(conn->ibc_connreq->cr_cmreq.PrivateData, - &conn->ibc_connreq->cr_wcr, sizeof(conn->ibc_connreq->cr_wcr)); - - /* kibnal_cm_callback gets my conn ref */ - frc = iibt_cm_connect(conn->ibc_cep, &conn->ibc_connreq->cr_cmreq, - kibnal_cm_callback, conn); - if (frc != FPENDING && frc != FSUCCESS) { - CERROR ("Connect: %d\n", frc); - /* Back out state change as connect failed */ - conn->ibc_state = IBNAL_CONN_INIT_QP; - kibnal_connreq_done (conn, 1, -EINVAL); - } -} - -static void -dump_service_records(SERVICE_RECORD_RESULTS *results) -{ - IB_SERVICE_RECORD *svc; - int i; - - for(i = 0; i < results->NumServiceRecords; i++) { - svc = &results->ServiceRecords[i]; - CDEBUG(D_NET, "%d: sid "LPX64" gid "LPX64":"LPX64" pkey %x\n", - i, - svc->RID.ServiceID, - svc->RID.ServiceGID.Type.Global.SubnetPrefix, - svc->RID.ServiceGID.Type.Global.InterfaceID, - svc->RID.ServiceP_Key); - } -} - - -static void -kibnal_service_get_callback (void *arg, QUERY *query, - QUERY_RESULT_VALUES *query_res) -{ - kib_conn_t *conn = arg; - SERVICE_RECORD_RESULTS *svc; - COMMAND_CONTROL_PARAMETERS sd_params; - QUERY path_query; - FSTATUS frc; - - if (query_res->Status != FSUCCESS || query_res->ResultDataSize == 0) { - CERROR ("status %d data size %d\n", query_res->Status, - query_res->ResultDataSize); - kibnal_connreq_done (conn, 1, -EINVAL); - return; - } - - svc = (SERVICE_RECORD_RESULTS *)query_res->QueryResult; - - if (svc->NumServiceRecords < 1) { - CERROR ("%d service records\n", svc->NumServiceRecords); - kibnal_connreq_done (conn, 1, -EINVAL); - return; - } - - dump_service_records(svc); - - conn->ibc_connreq->cr_service = svc->ServiceRecords[0]; - - CDEBUG(D_NET, "Got status %d, service id "LPX64", on "LPX64"\n", - query_res->Status , conn->ibc_connreq->cr_service.RID.ServiceID, - *kibnal_service_nid_field(&conn->ibc_connreq->cr_service)); - - memset(&path_query, 0, sizeof(path_query)); - path_query.InputType = InputTypePortGuidPair; - path_query.OutputType = OutputTypePathRecord; - path_query.InputValue.PortGuidPair.SourcePortGuid = kibnal_data.kib_port_guid; - path_query.InputValue.PortGuidPair.DestPortGuid = conn->ibc_connreq->cr_service.RID.ServiceGID.Type.Global.InterfaceID; - - memset(&sd_params, 0, sizeof(sd_params)); - sd_params.RetryCount = IBNAL_RETRY; - sd_params.Timeout = 10 * 1000; /* wait 10 seconds */ - - /* kibnal_service_get_callback gets my conn ref */ - - frc = iibt_sd_query_port_fabric_information(kibnal_data.kib_sd, - kibnal_data.kib_port_guid, - &path_query, - kibnal_pathreq_callback, - &sd_params, conn); - if (frc == FPENDING) - return; - - CERROR ("Path record request failed: %d\n", frc); - kibnal_connreq_done (conn, 1, -EINVAL); -} - -static void -kibnal_connect_peer (kib_peer_t *peer) -{ - COMMAND_CONTROL_PARAMETERS sd_params; - QUERY query; - FSTATUS frc; - kib_conn_t *conn = kibnal_create_conn(); - - LASSERT (peer->ibp_connecting != 0); - - if (conn == NULL) { - CERROR ("Can't allocate conn\n"); - kibnal_peer_connect_failed (peer, 1, -ENOMEM); - return; - } - - conn->ibc_peer = peer; - kib_peer_addref(peer); - - PORTAL_ALLOC (conn->ibc_connreq, sizeof (*conn->ibc_connreq)); - if (conn->ibc_connreq == NULL) { - CERROR ("Can't allocate connreq\n"); - kibnal_connreq_done (conn, 1, -ENOMEM); - return; - } - - memset(conn->ibc_connreq, 0, sizeof (*conn->ibc_connreq)); - - kibnal_set_service_keys(&conn->ibc_connreq->cr_service, peer->ibp_nid); - - memset(&query, 0, sizeof(query)); - query.InputType = InputTypeServiceRecord; - query.OutputType = OutputTypeServiceRecord; - query.InputValue.ServiceRecordValue.ServiceRecord = conn->ibc_connreq->cr_service; - query.InputValue.ServiceRecordValue.ComponentMask = KIBNAL_SERVICE_KEY_MASK; - - memset(&sd_params, 0, sizeof(sd_params)); - sd_params.RetryCount = IBNAL_RETRY; - sd_params.Timeout = 10 * 1000; /* wait 10 seconds */ - - /* kibnal_service_get_callback gets my conn ref */ - frc = iibt_sd_query_port_fabric_information(kibnal_data.kib_sd, - kibnal_data.kib_port_guid, - &query, - kibnal_service_get_callback, - &sd_params, conn); - if (frc == FPENDING) - return; - - CERROR ("iibt_sd_query_port_fabric_information(): %d\n", frc); - kibnal_connreq_done (conn, 1, frc); -} - -static int -kibnal_conn_timed_out (kib_conn_t *conn) -{ - kib_tx_t *tx; - struct list_head *ttmp; - unsigned long flags; - - spin_lock_irqsave (&conn->ibc_lock, flags); - - list_for_each (ttmp, &conn->ibc_tx_queue) { - tx = list_entry (ttmp, kib_tx_t, tx_list); - - LASSERT (!tx->tx_passive_rdma_wait); - LASSERT (tx->tx_sending == 0); - - if (time_after_eq (jiffies, tx->tx_deadline)) { - spin_unlock_irqrestore (&conn->ibc_lock, flags); - return 1; - } - } - - list_for_each (ttmp, &conn->ibc_active_txs) { - tx = list_entry (ttmp, kib_tx_t, tx_list); - - LASSERT (tx->tx_passive_rdma || - !tx->tx_passive_rdma_wait); - - LASSERT (tx->tx_passive_rdma_wait || - tx->tx_sending != 0); - - if (time_after_eq (jiffies, tx->tx_deadline)) { - spin_unlock_irqrestore (&conn->ibc_lock, flags); - return 1; - } - } - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - return 0; -} - -static void -kibnal_check_conns (int idx) -{ - struct list_head *peers = &kibnal_data.kib_peers[idx]; - struct list_head *ptmp; - kib_peer_t *peer; - kib_conn_t *conn; - struct list_head *ctmp; - - again: - /* NB. We expect to have a look at all the peers and not find any - * rdmas to time out, so we just use a shared lock while we - * take a look... */ - read_lock (&kibnal_data.kib_global_lock); - - list_for_each (ptmp, peers) { - peer = list_entry (ptmp, kib_peer_t, ibp_list); - - list_for_each (ctmp, &peer->ibp_conns) { - conn = list_entry (ctmp, kib_conn_t, ibc_list); - - KIB_ASSERT_CONN_STATE(conn, IBNAL_CONN_ESTABLISHED); - - /* In case we have enough credits to return via a - * NOOP, but there were no non-blocking tx descs - * free to do it last time... */ - kibnal_check_sends(conn); - - if (!kibnal_conn_timed_out(conn)) - continue; - - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - - atomic_inc (&conn->ibc_refcount); - read_unlock (&kibnal_data.kib_global_lock); - - CERROR("Timed out RDMA with "LPX64"\n", - peer->ibp_nid); - - kibnal_close_conn (conn, -ETIMEDOUT); - kibnal_put_conn (conn); - - /* start again now I've dropped the lock */ - goto again; - } - } - - read_unlock (&kibnal_data.kib_global_lock); -} - -static void -kib_connd_handle_state(kib_conn_t *conn) -{ - FSTATUS frc; - - switch (conn->ibc_state) { - /* all refs have gone, free and be done with it */ - case IBNAL_CONN_DISCONNECTED: - kibnal_destroy_conn (conn); - return; /* avoid put_conn */ - - case IBNAL_CONN_SEND_DREQ: - frc = iibt_cm_disconnect(conn->ibc_cep, NULL, NULL); - if (frc != FSUCCESS) /* XXX do real things */ - CERROR("disconnect failed: %d\n", frc); - conn->ibc_state = IBNAL_CONN_DREQ; - break; - - /* a callback got to the conn before we did */ - case IBNAL_CONN_DREP: - break; - - default: - CERROR ("Bad conn %p state: %d\n", conn, - conn->ibc_state); - LBUG(); - break; - } - - /* drop ref from close_conn */ - kibnal_put_conn(conn); -} - -int -kibnal_connd (void *arg) -{ - wait_queue_t wait; - unsigned long flags; - kib_conn_t *conn; - kib_peer_t *peer; - int timeout; - int i; - int peer_index = 0; - unsigned long deadline = jiffies; - - kportal_daemonize ("kibnal_connd"); - kportal_blockallsigs (); - - init_waitqueue_entry (&wait, current); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - - for (;;) { - if (!list_empty (&kibnal_data.kib_connd_conns)) { - conn = list_entry (kibnal_data.kib_connd_conns.next, - kib_conn_t, ibc_list); - list_del (&conn->ibc_list); - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - kib_connd_handle_state(conn); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - continue; - } - - if (!list_empty (&kibnal_data.kib_connd_peers)) { - peer = list_entry (kibnal_data.kib_connd_peers.next, - kib_peer_t, ibp_connd_list); - - list_del_init (&peer->ibp_connd_list); - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - - kibnal_connect_peer (peer); - kib_peer_decref (peer); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - } - - /* shut down and nobody left to reap... */ - if (kibnal_data.kib_shutdown && - atomic_read(&kibnal_data.kib_nconns) == 0) - break; - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - - /* careful with the jiffy wrap... */ - while ((timeout = (int)(deadline - jiffies)) <= 0) { - const int n = 4; - const int p = 1; - int chunk = kibnal_data.kib_peer_hash_size; - - /* Time to check for RDMA timeouts on a few more - * peers: I do checks every 'p' seconds on a - * proportion of the peer table and I need to check - * every connection 'n' times within a timeout - * interval, to ensure I detect a timeout on any - * connection within (n+1)/n times the timeout - * interval. */ - - if (kibnal_tunables.kib_io_timeout > n * p) - chunk = (chunk * n * p) / - kibnal_tunables.kib_io_timeout; - if (chunk == 0) - chunk = 1; - - for (i = 0; i < chunk; i++) { - kibnal_check_conns (peer_index); - peer_index = (peer_index + 1) % - kibnal_data.kib_peer_hash_size; - } - - deadline += p * HZ; - } - - kibnal_data.kib_connd_waketime = jiffies + timeout; - - set_current_state (TASK_INTERRUPTIBLE); - add_wait_queue (&kibnal_data.kib_connd_waitq, &wait); - - if (!kibnal_data.kib_shutdown && - list_empty (&kibnal_data.kib_connd_conns) && - list_empty (&kibnal_data.kib_connd_peers)) - schedule_timeout (timeout); - - set_current_state (TASK_RUNNING); - remove_wait_queue (&kibnal_data.kib_connd_waitq, &wait); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - } - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - - kibnal_thread_fini (); - return (0); -} - -int -kibnal_scheduler(void *arg) -{ - long id = (long)arg; - char name[16]; - kib_rx_t *rx; - kib_tx_t *tx; - unsigned long flags; - int rc; - int counter = 0; - int did_something; - - snprintf(name, sizeof(name), "kibnal_sd_%02ld", id); - kportal_daemonize(name); - kportal_blockallsigs(); - - spin_lock_irqsave(&kibnal_data.kib_sched_lock, flags); - - for (;;) { - did_something = 0; - - while (!list_empty(&kibnal_data.kib_sched_txq)) { - tx = list_entry(kibnal_data.kib_sched_txq.next, - kib_tx_t, tx_list); - list_del(&tx->tx_list); - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, - flags); - kibnal_tx_done(tx); - - spin_lock_irqsave(&kibnal_data.kib_sched_lock, - flags); - } - - if (!list_empty(&kibnal_data.kib_sched_rxq)) { - rx = list_entry(kibnal_data.kib_sched_rxq.next, - kib_rx_t, rx_list); - list_del(&rx->rx_list); - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, - flags); - - kibnal_rx(rx); - - did_something = 1; - spin_lock_irqsave(&kibnal_data.kib_sched_lock, - flags); - } - - /* shut down and no receives to complete... */ - if (kibnal_data.kib_shutdown && - atomic_read(&kibnal_data.kib_nconns) == 0) - break; - - /* nothing to do or hogging CPU */ - if (!did_something || counter++ == IBNAL_RESCHED) { - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, - flags); - counter = 0; - - if (!did_something) { - rc = wait_event_interruptible( - kibnal_data.kib_sched_waitq, - !list_empty(&kibnal_data.kib_sched_txq) || - !list_empty(&kibnal_data.kib_sched_rxq) || - (kibnal_data.kib_shutdown && - atomic_read (&kibnal_data.kib_nconns) == 0)); - } else { - our_cond_resched(); - } - - spin_lock_irqsave(&kibnal_data.kib_sched_lock, - flags); - } - } - - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, flags); - - kibnal_thread_fini(); - return (0); -} - - -lib_nal_t kibnal_lib = { - libnal_data: &kibnal_data, /* NAL private data */ - libnal_send: kibnal_send, - libnal_send_pages: kibnal_send_pages, - libnal_recv: kibnal_recv, - libnal_recv_pages: kibnal_recv_pages, - libnal_dist: kibnal_dist -}; diff --git a/lnet/klnds/lolnd/.cvsignore b/lnet/klnds/lolnd/.cvsignore deleted file mode 100644 index 5ed596b..0000000 --- a/lnet/klnds/lolnd/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/klnds/lolnd/Makefile.in b/lnet/klnds/lolnd/Makefile.in deleted file mode 100644 index 222e861..0000000 --- a/lnet/klnds/lolnd/Makefile.in +++ /dev/null @@ -1,4 +0,0 @@ -MODULES := klonal -klonal-objs := lonal.o lonal_cb.o - -@INCLUDE_RULES@ diff --git a/lnet/klnds/lolnd/autoMakefile.am b/lnet/klnds/lolnd/autoMakefile.am deleted file mode 100644 index d1ef995..0000000 --- a/lnet/klnds/lolnd/autoMakefile.am +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -modulenet_DATA = klonal$(KMODEXT) -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(klonal-objs:%.o=%.c) lonal.h diff --git a/lnet/klnds/lolnd/lolnd.c b/lnet/klnds/lolnd/lolnd.c deleted file mode 100644 index 03c2742..0000000 --- a/lnet/klnds/lolnd/lolnd.c +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * - * 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. - */ - -#include "lonal.h" - -nal_t klonal_api; -klonal_data_t klonal_data; -ptl_handle_ni_t klonal_ni; - - -int -klonal_cmd (struct portals_cfg *pcfg, void *private) -{ - LASSERT (pcfg != NULL); - - switch (pcfg->pcfg_command) { - case NAL_CMD_REGISTER_MYNID: - CDEBUG (D_IOCTL, "setting NID to "LPX64" (was "LPX64")\n", - pcfg->pcfg_nid, klonal_lib.libnal_ni.ni_pid.nid); - klonal_lib.libnal_ni.ni_pid.nid = pcfg->pcfg_nid; - return (0); - - default: - return (-EINVAL); - } -} - -static void -klonal_shutdown(nal_t *nal) -{ - /* NB The first ref was this module! */ - if (nal->nal_refct != 0) - return; - - CDEBUG (D_NET, "shutdown\n"); - LASSERT (nal == &klonal_api); - - switch (klonal_data.klo_init) - { - default: - LASSERT (0); - - case KLO_INIT_ALL: - libcfs_nal_cmd_unregister(LONAL); - /* fall through */ - - case KLO_INIT_LIB: - lib_fini (&klonal_lib); - break; - - case KLO_INIT_NOTHING: - return; - } - - memset(&klonal_data, 0, sizeof (klonal_data)); - - CDEBUG (D_MALLOC, "done kmem %d\n", atomic_read(&portal_kmemory)); - - printk (KERN_INFO "Lustre: LO NAL unloaded (final mem %d)\n", - atomic_read(&portal_kmemory)); - PORTAL_MODULE_UNUSE; -} - -static int -klonal_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - int rc; - ptl_process_id_t my_process_id; - int pkmem = atomic_read(&portal_kmemory); - - LASSERT (nal == &klonal_api); - - if (nal->nal_refct != 0) { - if (actual_limits != NULL) - *actual_limits = klonal_lib.libnal_ni.ni_actual_limits; - return (PTL_OK); - } - - LASSERT (klonal_data.klo_init == KLO_INIT_NOTHING); - - CDEBUG (D_MALLOC, "start kmem %d\n", atomic_read(&portal_kmemory)); - - /* ensure all pointers NULL etc */ - memset (&klonal_data, 0, sizeof (klonal_data)); - - my_process_id.nid = 0; - my_process_id.pid = requested_pid; - - rc = lib_init(&klonal_lib, nal, my_process_id, - requested_limits, actual_limits); - if (rc != PTL_OK) { - CERROR ("lib_init failed %d\n", rc); - klonal_shutdown (nal); - return (rc); - } - - klonal_data.klo_init = KLO_INIT_LIB; - - rc = libcfs_nal_cmd_register (LONAL, &klonal_cmd, NULL); - if (rc != 0) { - CERROR ("Can't initialise command interface (rc = %d)\n", rc); - klonal_shutdown (nal); - return (PTL_FAIL); - } - - klonal_data.klo_init = KLO_INIT_ALL; - - printk(KERN_INFO "Lustre: LO NAL (initial mem %d)\n", pkmem); - PORTAL_MODULE_USE; - - return (PTL_OK); -} - -void __exit -klonal_finalise (void) -{ - PtlNIFini(klonal_ni); - - ptl_unregister_nal(LONAL); -} - -static int __init -klonal_initialise (void) -{ - int rc; - - klonal_api.nal_ni_init = klonal_startup; - klonal_api.nal_ni_fini = klonal_shutdown; - - rc = ptl_register_nal(LONAL, &klonal_api); - if (rc != PTL_OK) { - CERROR("Can't register LONAL: %d\n", rc); - return (-ENOMEM); /* or something... */ - } - - return (0); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Loopback NAL v0.01"); -MODULE_LICENSE("GPL"); - -module_init (klonal_initialise); -module_exit (klonal_finalise); diff --git a/lnet/klnds/lolnd/lolnd.h b/lnet/klnds/lolnd/lolnd.h deleted file mode 100644 index 9d3d3ff..0000000 --- a/lnet/klnds/lolnd/lolnd.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * - * 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 _LONAL_H -#define _LONAL_H -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_NAL - -#include -#include -#include -#include - -#define KLOD_IOV 153401 -#define KLOD_KIOV 153402 - -typedef struct -{ - unsigned int klod_type; - unsigned int klod_niov; - size_t klod_offset; - size_t klod_nob; - union { - struct iovec *iov; - ptl_kiov_t *kiov; - } klod_iov; -} klo_desc_t; - -typedef struct -{ - char klo_init; /* what's been initialised */ -} klonal_data_t; - -/* kqn_init state */ -#define KLO_INIT_NOTHING 0 /* MUST BE ZERO so zeroed state is initialised OK */ -#define KLO_INIT_LIB 1 -#define KLO_INIT_ALL 2 - -extern lib_nal_t klonal_lib; -extern nal_t klonal_api; -extern klonal_data_t klonal_data; - -#endif /* _LONAL_H */ diff --git a/lnet/klnds/lolnd/lolnd_cb.c b/lnet/klnds/lolnd/lolnd_cb.c deleted file mode 100644 index cf5df0d..0000000 --- a/lnet/klnds/lolnd/lolnd_cb.c +++ /dev/null @@ -1,267 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * - * 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. - */ - -#include "lonal.h" - -/* - * LIB functions follow - * - */ -static int -klonal_dist(lib_nal_t *nal, ptl_nid_t nid, unsigned long *dist) -{ - *dist = 0; /* it's me */ - return (0); -} - -static ptl_err_t -klonal_send (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - struct iovec *payload_iov, - size_t payload_offset, - size_t payload_nob) -{ - klo_desc_t klod = { - .klod_type = KLOD_IOV, - .klod_niov = payload_niov, - .klod_offset = payload_offset, - .klod_nob = payload_nob, - .klod_iov = { .iov = payload_iov } }; - ptl_err_t rc; - - LASSERT(nid == klonal_lib.libnal_ni.ni_pid.nid); - - rc = lib_parse(&klonal_lib, hdr, &klod); - if (rc == PTL_OK) - lib_finalize(&klonal_lib, private, libmsg, PTL_OK); - - return rc; -} - -static ptl_err_t -klonal_send_pages (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - ptl_kiov_t *payload_kiov, - size_t payload_offset, - size_t payload_nob) -{ - klo_desc_t klod = { - .klod_type = KLOD_KIOV, - .klod_niov = payload_niov, - .klod_offset = payload_offset, - .klod_nob = payload_nob, - .klod_iov = { .kiov = payload_kiov } }; - ptl_err_t rc; - - LASSERT(nid == klonal_lib.libnal_ni.ni_pid.nid); - - rc = lib_parse(&klonal_lib, hdr, &klod); - if (rc == PTL_OK) - lib_finalize(&klonal_lib, private, libmsg, PTL_OK); - - return rc; -} - -static ptl_err_t -klonal_recv(lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - unsigned int niov, - struct iovec *iov, - size_t offset, - size_t mlen, - size_t rlen) -{ - klo_desc_t *klod = (klo_desc_t *)private; - - /* I only handle mapped->mapped matches */ - LASSERT(klod->klod_type == KLOD_IOV); - - if (mlen == 0) - return PTL_OK; - - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - iov++; - niov--; - LASSERT(niov > 0); - } - - while (klod->klod_offset >= klod->klod_iov.iov->iov_len) { - klod->klod_offset -= klod->klod_iov.iov->iov_len; - klod->klod_iov.iov++; - klod->klod_niov--; - LASSERT(klod->klod_niov > 0); - } - - do { - int fraglen = MIN(iov->iov_len - offset, - klod->klod_iov.iov->iov_len - klod->klod_offset); - - LASSERT(niov > 0); - LASSERT(klod->klod_niov > 0); - - if (fraglen > mlen) - fraglen = mlen; - - memcpy((void *)((unsigned long)iov->iov_base + offset), - (void *)((unsigned long)klod->klod_iov.iov->iov_base + - klod->klod_offset), - fraglen); - - if (offset + fraglen < iov->iov_len) { - offset += fraglen; - } else { - offset = 0; - iov++; - niov--; - } - - if (klod->klod_offset + fraglen < klod->klod_iov.iov->iov_len ) { - klod->klod_offset += fraglen; - } else { - klod->klod_offset = 0; - klod->klod_iov.iov++; - klod->klod_niov--; - } - - mlen -= fraglen; - } while (mlen > 0); - - lib_finalize(&klonal_lib, private, libmsg, PTL_OK); - return PTL_OK; -} - -static ptl_err_t -klonal_recv_pages(lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - unsigned int niov, - ptl_kiov_t *kiov, - size_t offset, - size_t mlen, - size_t rlen) -{ - void *srcaddr = NULL; - void *dstaddr = NULL; - unsigned long srcfrag = 0; - unsigned long dstfrag = 0; - unsigned long fraglen; - klo_desc_t *klod = (klo_desc_t *)private; - - /* I only handle unmapped->unmapped matches */ - LASSERT(klod->klod_type == KLOD_KIOV); - - if (mlen == 0) - return PTL_OK; - - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; - kiov++; - niov--; - LASSERT(niov > 0); - } - - while (klod->klod_offset >= klod->klod_iov.kiov->kiov_len) { - klod->klod_offset -= klod->klod_iov.kiov->kiov_len; - klod->klod_iov.kiov++; - klod->klod_niov--; - LASSERT(klod->klod_niov > 0); - } - - do { - /* CAVEAT EMPTOR: I kmap 2 pages at once == slight risk of deadlock */ - LASSERT(niov > 0); - if (dstaddr == NULL) { - dstaddr = (void *)((unsigned long)kmap(kiov->kiov_page) + - kiov->kiov_offset + offset); - dstfrag = kiov->kiov_len - offset; - } - - LASSERT(klod->klod_niov > 0); - if (srcaddr == NULL) { - srcaddr = (void *)((unsigned long)kmap(klod->klod_iov.kiov->kiov_page) + - klod->klod_iov.kiov->kiov_offset + klod->klod_offset); - srcfrag = klod->klod_iov.kiov->kiov_len - klod->klod_offset; - } - - fraglen = MIN(srcfrag, dstfrag); - if (fraglen > mlen) - fraglen = mlen; - - memcpy(dstaddr, srcaddr, fraglen); - - if (fraglen < dstfrag) { - dstfrag -= fraglen; - dstaddr = (void *)((unsigned long)dstaddr + fraglen); - } else { - kunmap(kiov->kiov_page); - dstaddr = NULL; - offset = 0; - kiov++; - niov--; - } - - if (fraglen < srcfrag) { - srcfrag -= fraglen; - srcaddr = (void *)((unsigned long)srcaddr + fraglen); - } else { - kunmap(klod->klod_iov.kiov->kiov_page); - srcaddr = NULL; - klod->klod_offset = 0; - klod->klod_iov.kiov++; - klod->klod_niov--; - } - - mlen -= fraglen; - } while (mlen > 0); - - if (dstaddr != NULL) - kunmap(kiov->kiov_page); - - if (srcaddr != NULL) - kunmap(klod->klod_iov.kiov->kiov_page); - - lib_finalize(&klonal_lib, private, libmsg, PTL_OK); - return PTL_OK; -} - -lib_nal_t klonal_lib = -{ - libnal_data: &klonal_data, /* NAL private data */ - libnal_send: klonal_send, - libnal_send_pages: klonal_send_pages, - libnal_recv: klonal_recv, - libnal_recv_pages: klonal_recv_pages, - libnal_dist: klonal_dist -}; diff --git a/lnet/klnds/openiblnd/.cvsignore b/lnet/klnds/openiblnd/.cvsignore deleted file mode 100644 index 5ed596b..0000000 --- a/lnet/klnds/openiblnd/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/klnds/openiblnd/Makefile.in b/lnet/klnds/openiblnd/Makefile.in deleted file mode 100644 index 9b8ed5d..0000000 --- a/lnet/klnds/openiblnd/Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -MODULES := kopenibnal -kopenibnal-objs := openibnal.o openibnal_cb.o - -EXTRA_POST_CFLAGS := @OPENIBCPPFLAGS@ - -@INCLUDE_RULES@ diff --git a/lnet/klnds/openiblnd/Makefile.mk b/lnet/klnds/openiblnd/Makefile.mk deleted file mode 100644 index bd8043e..0000000 --- a/lnet/klnds/openiblnd/Makefile.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include $(src)/../../Kernelenv - -obj-y += kopenibnal.o -kopenibnal-objs := openibnal.o openibnal_cb.o - diff --git a/lnet/klnds/openiblnd/autoMakefile.am b/lnet/klnds/openiblnd/autoMakefile.am deleted file mode 100644 index a4207ae..0000000 --- a/lnet/klnds/openiblnd/autoMakefile.am +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if !CRAY_PORTALS -if BUILD_OPENIBNAL -modulenet_DATA = kopenibnal$(KMODEXT) -endif -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(kopenibnal-objs:%.o=%.c) openibnal.h diff --git a/lnet/klnds/openiblnd/openiblnd.c b/lnet/klnds/openiblnd/openiblnd.c deleted file mode 100644 index 652eb34..0000000 --- a/lnet/klnds/openiblnd/openiblnd.c +++ /dev/null @@ -1,1486 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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. - * - */ - -#include "openibnal.h" - -nal_t kibnal_api; -ptl_handle_ni_t kibnal_ni; -kib_data_t kibnal_data; -kib_tunables_t kibnal_tunables; - -#ifdef CONFIG_SYSCTL -#define IBNAL_SYSCTL 202 - -#define IBNAL_SYSCTL_TIMEOUT 1 - -static ctl_table kibnal_ctl_table[] = { - {IBNAL_SYSCTL_TIMEOUT, "timeout", - &kibnal_tunables.kib_io_timeout, sizeof (int), - 0644, NULL, &proc_dointvec}, - { 0 } -}; - -static ctl_table kibnal_top_ctl_table[] = { - {IBNAL_SYSCTL, "openibnal", NULL, 0, 0555, kibnal_ctl_table}, - { 0 } -}; -#endif - -void -print_service(struct ib_common_attrib_service *service, char *tag, int rc) -{ - char name[32]; - - if (service == NULL) - { - CWARN("tag : %s\n" - "status : %d (NULL)\n", tag, rc); - return; - } - strncpy (name, service->service_name, sizeof(name)-1); - name[sizeof(name)-1] = 0; - - CWARN("tag : %s\n" - "status : %d\n" - "service id: "LPX64"\n" - "name : %s\n" - "NID : "LPX64"\n", tag, rc, - service->service_id, name, - *kibnal_service_nid_field(service)); -} - -void -kibnal_service_setunset_done (tTS_IB_CLIENT_QUERY_TID tid, int status, - struct ib_common_attrib_service *service, void *arg) -{ - *(int *)arg = status; - up (&kibnal_data.kib_nid_signal); -} - -#if IBNAL_CHECK_ADVERT -void -kibnal_check_advert (void) -{ - struct ib_common_attrib_service *svc; - __u64 tid; - int rc; - int rc2; - - PORTAL_ALLOC(svc, sizeof(*svc)); - if (svc == NULL) - return; - - memset (svc, 0, sizeof (*svc)); - kibnal_set_service_keys(svc, kibnal_data.kib_nid); - - rc = ib_service_get (kibnal_data.kib_device, - kibnal_data.kib_port, - svc, - KIBNAL_SERVICE_KEY_MASK, - kibnal_tunables.kib_io_timeout * HZ, - kibnal_service_setunset_done, &rc2, - &tid); - - if (rc != 0) { - CERROR ("Immediate error %d checking SM service\n", rc); - } else { - down (&kibnal_data.kib_nid_signal); - rc = rc2; - - if (rc != 0) - CERROR ("Error %d checking SM service\n", rc); - } - - PORTAL_FREE(svc, sizeof(*svc)); -} -#endif - -int -kibnal_advertise (void) -{ - struct ib_common_attrib_service *svc; - __u64 tid; - int rc; - int rc2; - - LASSERT (kibnal_data.kib_nid != PTL_NID_ANY); - - PORTAL_ALLOC(svc, sizeof(*svc)); - if (svc == NULL) - return (-ENOMEM); - - memset (svc, 0, sizeof (*svc)); - - svc->service_id = kibnal_data.kib_service_id; - - rc = ib_cached_gid_get(kibnal_data.kib_device, - kibnal_data.kib_port, - 0, - svc->service_gid); - if (rc != 0) { - CERROR ("Can't get port %d GID: %d\n", - kibnal_data.kib_port, rc); - goto out; - } - - rc = ib_cached_pkey_get(kibnal_data.kib_device, - kibnal_data.kib_port, - 0, - &svc->service_pkey); - if (rc != 0) { - CERROR ("Can't get port %d PKEY: %d\n", - kibnal_data.kib_port, rc); - goto out; - } - - svc->service_lease = 0xffffffff; - - kibnal_set_service_keys(svc, kibnal_data.kib_nid); - - CDEBUG(D_NET, "Advertising service id "LPX64" %s:"LPX64"\n", - svc->service_id, - svc->service_name, *kibnal_service_nid_field(svc)); - - rc = ib_service_set (kibnal_data.kib_device, - kibnal_data.kib_port, - svc, - IB_SA_SERVICE_COMP_MASK_ID | - IB_SA_SERVICE_COMP_MASK_GID | - IB_SA_SERVICE_COMP_MASK_PKEY | - IB_SA_SERVICE_COMP_MASK_LEASE | - KIBNAL_SERVICE_KEY_MASK, - kibnal_tunables.kib_io_timeout * HZ, - kibnal_service_setunset_done, &rc2, &tid); - - if (rc != 0) { - CERROR ("Immediate error %d advertising NID "LPX64"\n", - rc, kibnal_data.kib_nid); - goto out; - } - - down (&kibnal_data.kib_nid_signal); - - rc = rc2; - if (rc != 0) - CERROR ("Error %d advertising NID "LPX64"\n", - rc, kibnal_data.kib_nid); - out: - PORTAL_FREE(svc, sizeof(*svc)); - return (rc); -} - -void -kibnal_unadvertise (int expect_success) -{ - struct ib_common_attrib_service *svc; - __u64 tid; - int rc; - int rc2; - - LASSERT (kibnal_data.kib_nid != PTL_NID_ANY); - - PORTAL_ALLOC(svc, sizeof(*svc)); - if (svc == NULL) - return; - - memset (svc, 0, sizeof(*svc)); - - kibnal_set_service_keys(svc, kibnal_data.kib_nid); - - CDEBUG(D_NET, "Unadvertising service %s:"LPX64"\n", - svc->service_name, *kibnal_service_nid_field(svc)); - - rc = ib_service_delete (kibnal_data.kib_device, - kibnal_data.kib_port, - svc, - KIBNAL_SERVICE_KEY_MASK, - kibnal_tunables.kib_io_timeout * HZ, - kibnal_service_setunset_done, &rc2, &tid); - if (rc != 0) { - CERROR ("Immediate error %d unadvertising NID "LPX64"\n", - rc, kibnal_data.kib_nid); - goto out; - } - - down (&kibnal_data.kib_nid_signal); - - if ((rc2 == 0) == !!expect_success) - goto out; /* success: rc == 0 */ - - if (expect_success) - CERROR("Error %d unadvertising NID "LPX64"\n", - rc, kibnal_data.kib_nid); - else - CWARN("Removed conflicting NID "LPX64"\n", - kibnal_data.kib_nid); - out: - PORTAL_FREE(svc, sizeof(*svc)); -} - -int -kibnal_set_mynid(ptl_nid_t nid) -{ - struct timeval tv; - lib_ni_t *ni = &kibnal_lib.libnal_ni; - int rc; - - CDEBUG(D_IOCTL, "setting mynid to "LPX64" (old nid="LPX64")\n", - nid, ni->ni_pid.nid); - - do_gettimeofday(&tv); - - down (&kibnal_data.kib_nid_mutex); - - if (nid == kibnal_data.kib_nid) { - /* no change of NID */ - up (&kibnal_data.kib_nid_mutex); - return (0); - } - - CDEBUG(D_NET, "NID "LPX64"("LPX64")\n", - kibnal_data.kib_nid, nid); - - if (kibnal_data.kib_nid != PTL_NID_ANY) { - - kibnal_unadvertise (1); - - rc = ib_cm_listen_stop (kibnal_data.kib_listen_handle); - if (rc != 0) - CERROR ("Error %d stopping listener\n", rc); - } - - kibnal_data.kib_nid = ni->ni_pid.nid = nid; - kibnal_data.kib_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; - - /* Delete all existing peers and their connections after new - * NID/incarnation set to ensure no old connections in our brave - * new world. */ - kibnal_del_peer (PTL_NID_ANY, 0); - - if (kibnal_data.kib_nid == PTL_NID_ANY) { - /* No new NID to install */ - up (&kibnal_data.kib_nid_mutex); - return (0); - } - - /* remove any previous advert (crashed node etc) */ - kibnal_unadvertise(0); - - /* Assign new service number */ - kibnal_data.kib_service_id = ib_cm_service_assign(); - CDEBUG(D_NET, "service_id "LPX64"\n", kibnal_data.kib_service_id); - - rc = ib_cm_listen(kibnal_data.kib_service_id, - TS_IB_CM_SERVICE_EXACT_MASK, - kibnal_passive_conn_callback, NULL, - &kibnal_data.kib_listen_handle); - if (rc == 0) { - rc = kibnal_advertise(); - if (rc == 0) { -#if IBNAL_CHECK_ADVERT - kibnal_check_advert(); -#endif - up (&kibnal_data.kib_nid_mutex); - return (0); - } - - ib_cm_listen_stop(kibnal_data.kib_listen_handle); - /* remove any peers that sprung up while I failed to - * advertise myself */ - kibnal_del_peer (PTL_NID_ANY, 0); - } - - kibnal_data.kib_nid = PTL_NID_ANY; - up (&kibnal_data.kib_nid_mutex); - return (rc); -} - -kib_peer_t * -kibnal_create_peer (ptl_nid_t nid) -{ - kib_peer_t *peer; - - LASSERT (nid != PTL_NID_ANY); - - PORTAL_ALLOC (peer, sizeof (*peer)); - if (peer == NULL) - return (NULL); - - memset(peer, 0, sizeof(*peer)); /* zero flags etc */ - - peer->ibp_nid = nid; - atomic_set (&peer->ibp_refcount, 1); /* 1 ref for caller */ - - INIT_LIST_HEAD (&peer->ibp_list); /* not in the peer table yet */ - INIT_LIST_HEAD (&peer->ibp_conns); - INIT_LIST_HEAD (&peer->ibp_tx_queue); - - peer->ibp_reconnect_time = jiffies; - peer->ibp_reconnect_interval = IBNAL_MIN_RECONNECT_INTERVAL; - - atomic_inc (&kibnal_data.kib_npeers); - return (peer); -} - -void -kibnal_destroy_peer (kib_peer_t *peer) -{ - CDEBUG (D_NET, "peer "LPX64" %p deleted\n", peer->ibp_nid, peer); - - LASSERT (atomic_read (&peer->ibp_refcount) == 0); - LASSERT (peer->ibp_persistence == 0); - LASSERT (!kibnal_peer_active(peer)); - LASSERT (peer->ibp_connecting == 0); - LASSERT (list_empty (&peer->ibp_conns)); - LASSERT (list_empty (&peer->ibp_tx_queue)); - - PORTAL_FREE (peer, sizeof (*peer)); - - /* NB a peer's connections keep a reference on their peer until - * they are destroyed, so we can be assured that _all_ state to do - * with this peer has been cleaned up when its refcount drops to - * zero. */ - atomic_dec (&kibnal_data.kib_npeers); -} - -void -kibnal_put_peer (kib_peer_t *peer) -{ - CDEBUG (D_OTHER, "putting peer[%p] -> "LPX64" (%d)\n", - peer, peer->ibp_nid, - atomic_read (&peer->ibp_refcount)); - - LASSERT (atomic_read (&peer->ibp_refcount) > 0); - if (!atomic_dec_and_test (&peer->ibp_refcount)) - return; - - kibnal_destroy_peer (peer); -} - -kib_peer_t * -kibnal_find_peer_locked (ptl_nid_t nid) -{ - struct list_head *peer_list = kibnal_nid2peerlist (nid); - struct list_head *tmp; - kib_peer_t *peer; - - list_for_each (tmp, peer_list) { - - peer = list_entry (tmp, kib_peer_t, ibp_list); - - LASSERT (peer->ibp_persistence != 0 || /* persistent peer */ - peer->ibp_connecting != 0 || /* creating conns */ - !list_empty (&peer->ibp_conns)); /* active conn */ - - if (peer->ibp_nid != nid) - continue; - - CDEBUG(D_NET, "got peer [%p] -> "LPX64" (%d)\n", - peer, nid, atomic_read (&peer->ibp_refcount)); - return (peer); - } - return (NULL); -} - -kib_peer_t * -kibnal_get_peer (ptl_nid_t nid) -{ - kib_peer_t *peer; - - read_lock (&kibnal_data.kib_global_lock); - peer = kibnal_find_peer_locked (nid); - if (peer != NULL) /* +1 ref for caller? */ - atomic_inc (&peer->ibp_refcount); - read_unlock (&kibnal_data.kib_global_lock); - - return (peer); -} - -void -kibnal_unlink_peer_locked (kib_peer_t *peer) -{ - LASSERT (peer->ibp_persistence == 0); - LASSERT (list_empty(&peer->ibp_conns)); - - LASSERT (kibnal_peer_active(peer)); - list_del_init (&peer->ibp_list); - /* lose peerlist's ref */ - kibnal_put_peer (peer); -} - -int -kibnal_get_peer_info (int index, ptl_nid_t *nidp, int *persistencep) -{ - kib_peer_t *peer; - struct list_head *ptmp; - int i; - - read_lock (&kibnal_data.kib_global_lock); - - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) { - - list_for_each (ptmp, &kibnal_data.kib_peers[i]) { - - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence != 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - if (index-- > 0) - continue; - - *nidp = peer->ibp_nid; - *persistencep = peer->ibp_persistence; - - read_unlock (&kibnal_data.kib_global_lock); - return (0); - } - } - - read_unlock (&kibnal_data.kib_global_lock); - return (-ENOENT); -} - -int -kibnal_add_persistent_peer (ptl_nid_t nid) -{ - unsigned long flags; - kib_peer_t *peer; - kib_peer_t *peer2; - - if (nid == PTL_NID_ANY) - return (-EINVAL); - - peer = kibnal_create_peer (nid); - if (peer == NULL) - return (-ENOMEM); - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - peer2 = kibnal_find_peer_locked (nid); - if (peer2 != NULL) { - kibnal_put_peer (peer); - peer = peer2; - } else { - /* peer table takes existing ref on peer */ - list_add_tail (&peer->ibp_list, - kibnal_nid2peerlist (nid)); - } - - peer->ibp_persistence++; - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - return (0); -} - -void -kibnal_del_peer_locked (kib_peer_t *peer, int single_share) -{ - struct list_head *ctmp; - struct list_head *cnxt; - kib_conn_t *conn; - - if (!single_share) - peer->ibp_persistence = 0; - else if (peer->ibp_persistence > 0) - peer->ibp_persistence--; - - if (peer->ibp_persistence != 0) - return; - - list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry(ctmp, kib_conn_t, ibc_list); - - kibnal_close_conn_locked (conn, 0); - } - - /* NB peer unlinks itself when last conn is closed */ -} - -int -kibnal_del_peer (ptl_nid_t nid, int single_share) -{ - unsigned long flags; - struct list_head *ptmp; - struct list_head *pnxt; - kib_peer_t *peer; - int lo; - int hi; - int i; - int rc = -ENOENT; - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = kibnal_nid2peerlist(nid) - kibnal_data.kib_peers; - else { - lo = 0; - hi = kibnal_data.kib_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &kibnal_data.kib_peers[i]) { - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence != 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - if (!(nid == PTL_NID_ANY || peer->ibp_nid == nid)) - continue; - - kibnal_del_peer_locked (peer, single_share); - rc = 0; /* matched something */ - - if (single_share) - goto out; - } - } - out: - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - return (rc); -} - -kib_conn_t * -kibnal_get_conn_by_idx (int index) -{ - kib_peer_t *peer; - struct list_head *ptmp; - kib_conn_t *conn; - struct list_head *ctmp; - int i; - - read_lock (&kibnal_data.kib_global_lock); - - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) { - list_for_each (ptmp, &kibnal_data.kib_peers[i]) { - - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence > 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - list_for_each (ctmp, &peer->ibp_conns) { - if (index-- > 0) - continue; - - conn = list_entry (ctmp, kib_conn_t, ibc_list); - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - read_unlock (&kibnal_data.kib_global_lock); - return (conn); - } - } - } - - read_unlock (&kibnal_data.kib_global_lock); - return (NULL); -} - -kib_conn_t * -kibnal_create_conn (void) -{ - kib_conn_t *conn; - int i; - __u64 vaddr = 0; - __u64 vaddr_base; - int page_offset; - int ipage; - int rc; - union { - struct ib_qp_create_param qp_create; - struct ib_qp_attribute qp_attr; - } params; - - PORTAL_ALLOC (conn, sizeof (*conn)); - if (conn == NULL) { - CERROR ("Can't allocate connection\n"); - return (NULL); - } - - /* zero flags, NULL pointers etc... */ - memset (conn, 0, sizeof (*conn)); - - INIT_LIST_HEAD (&conn->ibc_tx_queue); - INIT_LIST_HEAD (&conn->ibc_active_txs); - spin_lock_init (&conn->ibc_lock); - - atomic_inc (&kibnal_data.kib_nconns); - /* well not really, but I call destroy() on failure, which decrements */ - - PORTAL_ALLOC (conn->ibc_rxs, IBNAL_RX_MSGS * sizeof (kib_rx_t)); - if (conn->ibc_rxs == NULL) - goto failed; - memset (conn->ibc_rxs, 0, IBNAL_RX_MSGS * sizeof(kib_rx_t)); - - rc = kibnal_alloc_pages(&conn->ibc_rx_pages, - IBNAL_RX_MSG_PAGES, - IB_ACCESS_LOCAL_WRITE); - if (rc != 0) - goto failed; - - vaddr_base = vaddr = conn->ibc_rx_pages->ibp_vaddr; - - for (i = ipage = page_offset = 0; i < IBNAL_RX_MSGS; i++) { - struct page *page = conn->ibc_rx_pages->ibp_pages[ipage]; - kib_rx_t *rx = &conn->ibc_rxs[i]; - - rx->rx_conn = conn; - rx->rx_vaddr = vaddr; - rx->rx_msg = (kib_msg_t *)(((char *)page_address(page)) + page_offset); - - vaddr += IBNAL_MSG_SIZE; - LASSERT (vaddr <= vaddr_base + IBNAL_RX_MSG_BYTES); - - page_offset += IBNAL_MSG_SIZE; - LASSERT (page_offset <= PAGE_SIZE); - - if (page_offset == PAGE_SIZE) { - page_offset = 0; - ipage++; - LASSERT (ipage <= IBNAL_RX_MSG_PAGES); - } - } - - params.qp_create = (struct ib_qp_create_param) { - .limit = { - /* Sends have an optional RDMA */ - .max_outstanding_send_request = 2 * IBNAL_MSG_QUEUE_SIZE, - .max_outstanding_receive_request = IBNAL_MSG_QUEUE_SIZE, - .max_send_gather_element = 1, - .max_receive_scatter_element = 1, - }, - .pd = kibnal_data.kib_pd, - .send_queue = kibnal_data.kib_cq, - .receive_queue = kibnal_data.kib_cq, - .send_policy = IB_WQ_SIGNAL_SELECTABLE, - .receive_policy = IB_WQ_SIGNAL_SELECTABLE, - .rd_domain = 0, - .transport = IB_TRANSPORT_RC, - .device_specific = NULL, - }; - - rc = ib_qp_create (¶ms.qp_create, &conn->ibc_qp, &conn->ibc_qpn); - if (rc != 0) { - CERROR ("Failed to create queue pair: %d\n", rc); - goto failed; - } - - /* Mark QP created */ - conn->ibc_state = IBNAL_CONN_INIT_QP; - - params.qp_attr = (struct ib_qp_attribute) { - .state = IB_QP_STATE_INIT, - .port = kibnal_data.kib_port, - .enable_rdma_read = 1, - .enable_rdma_write = 1, - .valid_fields = (IB_QP_ATTRIBUTE_STATE | - IB_QP_ATTRIBUTE_PORT | - IB_QP_ATTRIBUTE_PKEY_INDEX | - IB_QP_ATTRIBUTE_RDMA_ATOMIC_ENABLE), - }; - rc = ib_qp_modify(conn->ibc_qp, ¶ms.qp_attr); - if (rc != 0) { - CERROR ("Failed to modify queue pair: %d\n", rc); - goto failed; - } - - /* 1 ref for caller */ - atomic_set (&conn->ibc_refcount, 1); - return (conn); - - failed: - kibnal_destroy_conn (conn); - return (NULL); -} - -void -kibnal_destroy_conn (kib_conn_t *conn) -{ - int rc; - - CDEBUG (D_NET, "connection %p\n", conn); - - LASSERT (atomic_read (&conn->ibc_refcount) == 0); - LASSERT (list_empty(&conn->ibc_tx_queue)); - LASSERT (list_empty(&conn->ibc_active_txs)); - LASSERT (conn->ibc_nsends_posted == 0); - LASSERT (conn->ibc_connreq == NULL); - - switch (conn->ibc_state) { - case IBNAL_CONN_ZOMBIE: - /* called after connection sequence initiated */ - - case IBNAL_CONN_INIT_QP: - rc = ib_qp_destroy(conn->ibc_qp); - if (rc != 0) - CERROR("Can't destroy QP: %d\n", rc); - /* fall through */ - - case IBNAL_CONN_INIT_NOTHING: - break; - - default: - LASSERT (0); - } - - if (conn->ibc_rx_pages != NULL) - kibnal_free_pages(conn->ibc_rx_pages); - - if (conn->ibc_rxs != NULL) - PORTAL_FREE(conn->ibc_rxs, - IBNAL_RX_MSGS * sizeof(kib_rx_t)); - - if (conn->ibc_peer != NULL) - kibnal_put_peer(conn->ibc_peer); - - PORTAL_FREE(conn, sizeof (*conn)); - - atomic_dec(&kibnal_data.kib_nconns); - - if (atomic_read (&kibnal_data.kib_nconns) == 0 && - kibnal_data.kib_shutdown) { - /* I just nuked the last connection on shutdown; wake up - * everyone so they can exit. */ - wake_up_all(&kibnal_data.kib_sched_waitq); - wake_up_all(&kibnal_data.kib_connd_waitq); - } -} - -void -kibnal_put_conn (kib_conn_t *conn) -{ - unsigned long flags; - - CDEBUG (D_NET, "putting conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - - LASSERT (atomic_read (&conn->ibc_refcount) > 0); - if (!atomic_dec_and_test (&conn->ibc_refcount)) - return; - - /* last ref only goes on zombies */ - LASSERT (conn->ibc_state == IBNAL_CONN_ZOMBIE); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - - list_add (&conn->ibc_list, &kibnal_data.kib_connd_conns); - wake_up (&kibnal_data.kib_connd_waitq); - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); -} - -int -kibnal_close_peer_conns_locked (kib_peer_t *peer, int why) -{ - kib_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry (ctmp, kib_conn_t, ibc_list); - - count++; - kibnal_close_conn_locked (conn, why); - } - - return (count); -} - -int -kibnal_close_stale_conns_locked (kib_peer_t *peer, __u64 incarnation) -{ - kib_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry (ctmp, kib_conn_t, ibc_list); - - if (conn->ibc_incarnation == incarnation) - continue; - - CDEBUG(D_NET, "Closing stale conn nid:"LPX64" incarnation:"LPX64"("LPX64")\n", - peer->ibp_nid, conn->ibc_incarnation, incarnation); - - count++; - kibnal_close_conn_locked (conn, -ESTALE); - } - - return (count); -} - -int -kibnal_close_matching_conns (ptl_nid_t nid) -{ - unsigned long flags; - kib_peer_t *peer; - struct list_head *ptmp; - struct list_head *pnxt; - int lo; - int hi; - int i; - int count = 0; - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = kibnal_nid2peerlist(nid) - kibnal_data.kib_peers; - else { - lo = 0; - hi = kibnal_data.kib_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &kibnal_data.kib_peers[i]) { - - peer = list_entry (ptmp, kib_peer_t, ibp_list); - LASSERT (peer->ibp_persistence != 0 || - peer->ibp_connecting != 0 || - !list_empty (&peer->ibp_conns)); - - if (!(nid == PTL_NID_ANY || nid == peer->ibp_nid)) - continue; - - count += kibnal_close_peer_conns_locked (peer, 0); - } - } - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - /* wildcards always succeed */ - if (nid == PTL_NID_ANY) - return (0); - - return (count == 0 ? -ENOENT : 0); -} - -int -kibnal_cmd(struct portals_cfg *pcfg, void * private) -{ - int rc = -EINVAL; - - LASSERT (pcfg != NULL); - - switch(pcfg->pcfg_command) { - case NAL_CMD_GET_PEER: { - ptl_nid_t nid = 0; - int share_count = 0; - - rc = kibnal_get_peer_info(pcfg->pcfg_count, - &nid, &share_count); - pcfg->pcfg_nid = nid; - pcfg->pcfg_size = 0; - pcfg->pcfg_id = 0; - pcfg->pcfg_misc = 0; - pcfg->pcfg_count = 0; - pcfg->pcfg_wait = share_count; - break; - } - case NAL_CMD_ADD_PEER: { - rc = kibnal_add_persistent_peer (pcfg->pcfg_nid); - break; - } - case NAL_CMD_DEL_PEER: { - rc = kibnal_del_peer (pcfg->pcfg_nid, - /* flags == single_share */ - pcfg->pcfg_flags != 0); - break; - } - case NAL_CMD_GET_CONN: { - kib_conn_t *conn = kibnal_get_conn_by_idx (pcfg->pcfg_count); - - if (conn == NULL) - rc = -ENOENT; - else { - rc = 0; - pcfg->pcfg_nid = conn->ibc_peer->ibp_nid; - pcfg->pcfg_id = 0; - pcfg->pcfg_misc = 0; - pcfg->pcfg_flags = 0; - kibnal_put_conn (conn); - } - break; - } - case NAL_CMD_CLOSE_CONNECTION: { - rc = kibnal_close_matching_conns (pcfg->pcfg_nid); - break; - } - case NAL_CMD_REGISTER_MYNID: { - if (pcfg->pcfg_nid == PTL_NID_ANY) - rc = -EINVAL; - else - rc = kibnal_set_mynid (pcfg->pcfg_nid); - break; - } - } - - return rc; -} - -void -kibnal_free_pages (kib_pages_t *p) -{ - int npages = p->ibp_npages; - int rc; - int i; - - if (p->ibp_mapped) { - rc = ib_memory_deregister(p->ibp_handle); - if (rc != 0) - CERROR ("Deregister error: %d\n", rc); - } - - for (i = 0; i < npages; i++) - if (p->ibp_pages[i] != NULL) - __free_page(p->ibp_pages[i]); - - PORTAL_FREE (p, offsetof(kib_pages_t, ibp_pages[npages])); -} - -int -kibnal_alloc_pages (kib_pages_t **pp, int npages, int access) -{ - kib_pages_t *p; - struct ib_physical_buffer *phys_pages; - int i; - int rc; - - PORTAL_ALLOC(p, offsetof(kib_pages_t, ibp_pages[npages])); - if (p == NULL) { - CERROR ("Can't allocate buffer %d\n", npages); - return (-ENOMEM); - } - - memset (p, 0, offsetof(kib_pages_t, ibp_pages[npages])); - p->ibp_npages = npages; - - for (i = 0; i < npages; i++) { - p->ibp_pages[i] = alloc_page (GFP_KERNEL); - if (p->ibp_pages[i] == NULL) { - CERROR ("Can't allocate page %d of %d\n", i, npages); - kibnal_free_pages(p); - return (-ENOMEM); - } - } - - PORTAL_ALLOC(phys_pages, npages * sizeof(*phys_pages)); - if (phys_pages == NULL) { - CERROR ("Can't allocate physarray for %d pages\n", npages); - kibnal_free_pages(p); - return (-ENOMEM); - } - - for (i = 0; i < npages; i++) { - phys_pages[i].size = PAGE_SIZE; - phys_pages[i].address = - kibnal_page2phys(p->ibp_pages[i]); - } - - p->ibp_vaddr = 0; - rc = ib_memory_register_physical(kibnal_data.kib_pd, - phys_pages, npages, - &p->ibp_vaddr, - npages * PAGE_SIZE, 0, - access, - &p->ibp_handle, - &p->ibp_lkey, - &p->ibp_rkey); - - PORTAL_FREE(phys_pages, npages * sizeof(*phys_pages)); - - if (rc != 0) { - CERROR ("Error %d mapping %d pages\n", rc, npages); - kibnal_free_pages(p); - return (rc); - } - - p->ibp_mapped = 1; - *pp = p; - return (0); -} - -int -kibnal_setup_tx_descs (void) -{ - int ipage = 0; - int page_offset = 0; - __u64 vaddr; - __u64 vaddr_base; - struct page *page; - kib_tx_t *tx; - int i; - int rc; - - /* pre-mapped messages are not bigger than 1 page */ - LASSERT (IBNAL_MSG_SIZE <= PAGE_SIZE); - - /* No fancy arithmetic when we do the buffer calculations */ - LASSERT (PAGE_SIZE % IBNAL_MSG_SIZE == 0); - - rc = kibnal_alloc_pages(&kibnal_data.kib_tx_pages, - IBNAL_TX_MSG_PAGES, - 0); /* local read access only */ - if (rc != 0) - return (rc); - - vaddr = vaddr_base = kibnal_data.kib_tx_pages->ibp_vaddr; - - for (i = 0; i < IBNAL_TX_MSGS; i++) { - page = kibnal_data.kib_tx_pages->ibp_pages[ipage]; - tx = &kibnal_data.kib_tx_descs[i]; - - memset (tx, 0, sizeof(*tx)); /* zero flags etc */ - - tx->tx_msg = (kib_msg_t *)(((char *)page_address(page)) + page_offset); - tx->tx_vaddr = vaddr; - tx->tx_isnblk = (i >= IBNAL_NTX); - tx->tx_mapped = KIB_TX_UNMAPPED; - - CDEBUG(D_NET, "Tx[%d] %p->%p - "LPX64"\n", - i, tx, tx->tx_msg, tx->tx_vaddr); - - if (tx->tx_isnblk) - list_add (&tx->tx_list, - &kibnal_data.kib_idle_nblk_txs); - else - list_add (&tx->tx_list, - &kibnal_data.kib_idle_txs); - - vaddr += IBNAL_MSG_SIZE; - LASSERT (vaddr <= vaddr_base + IBNAL_TX_MSG_BYTES); - - page_offset += IBNAL_MSG_SIZE; - LASSERT (page_offset <= PAGE_SIZE); - - if (page_offset == PAGE_SIZE) { - page_offset = 0; - ipage++; - LASSERT (ipage <= IBNAL_TX_MSG_PAGES); - } - } - - return (0); -} - -void -kibnal_api_shutdown (nal_t *nal) -{ - int i; - int rc; - - if (nal->nal_refct != 0) { - /* This module got the first ref */ - PORTAL_MODULE_UNUSE; - return; - } - - CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n", - atomic_read (&portal_kmemory)); - - LASSERT(nal == &kibnal_api); - - switch (kibnal_data.kib_init) { - default: - CERROR ("Unexpected state %d\n", kibnal_data.kib_init); - LBUG(); - - case IBNAL_INIT_ALL: - /* stop calls to nal_cmd */ - libcfs_nal_cmd_unregister(OPENIBNAL); - /* No new peers */ - - /* resetting my NID to unadvertises me, removes my - * listener and nukes all current peers */ - kibnal_set_mynid (PTL_NID_ANY); - - /* Wait for all peer state to clean up */ - i = 2; - while (atomic_read (&kibnal_data.kib_npeers) != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "waiting for %d peers to close down\n", - atomic_read (&kibnal_data.kib_npeers)); - set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout (HZ); - } - /* fall through */ - - case IBNAL_INIT_CQ: - rc = ib_cq_destroy (kibnal_data.kib_cq); - if (rc != 0) - CERROR ("Destroy CQ error: %d\n", rc); - /* fall through */ - - case IBNAL_INIT_TXD: - kibnal_free_pages (kibnal_data.kib_tx_pages); - /* fall through */ -#if IBNAL_FMR - case IBNAL_INIT_FMR: - rc = ib_fmr_pool_destroy (kibnal_data.kib_fmr_pool); - if (rc != 0) - CERROR ("Destroy FMR pool error: %d\n", rc); - /* fall through */ -#endif - case IBNAL_INIT_PD: - rc = ib_pd_destroy(kibnal_data.kib_pd); - if (rc != 0) - CERROR ("Destroy PD error: %d\n", rc); - /* fall through */ - - case IBNAL_INIT_LIB: - lib_fini(&kibnal_lib); - /* fall through */ - - case IBNAL_INIT_DATA: - /* Module refcount only gets to zero when all peers - * have been closed so all lists must be empty */ - LASSERT (atomic_read (&kibnal_data.kib_npeers) == 0); - LASSERT (kibnal_data.kib_peers != NULL); - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) { - LASSERT (list_empty (&kibnal_data.kib_peers[i])); - } - LASSERT (atomic_read (&kibnal_data.kib_nconns) == 0); - LASSERT (list_empty (&kibnal_data.kib_sched_rxq)); - LASSERT (list_empty (&kibnal_data.kib_sched_txq)); - LASSERT (list_empty (&kibnal_data.kib_connd_conns)); - LASSERT (list_empty (&kibnal_data.kib_connd_peers)); - - /* flag threads to terminate; wake and wait for them to die */ - kibnal_data.kib_shutdown = 1; - wake_up_all (&kibnal_data.kib_sched_waitq); - wake_up_all (&kibnal_data.kib_connd_waitq); - - i = 2; - while (atomic_read (&kibnal_data.kib_nthreads) != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "Waiting for %d threads to terminate\n", - atomic_read (&kibnal_data.kib_nthreads)); - set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout (HZ); - } - /* fall through */ - - case IBNAL_INIT_NOTHING: - break; - } - - if (kibnal_data.kib_tx_descs != NULL) - PORTAL_FREE (kibnal_data.kib_tx_descs, - IBNAL_TX_MSGS * sizeof(kib_tx_t)); - - if (kibnal_data.kib_peers != NULL) - PORTAL_FREE (kibnal_data.kib_peers, - sizeof (struct list_head) * - kibnal_data.kib_peer_hash_size); - - CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n", - atomic_read (&portal_kmemory)); - printk(KERN_INFO "Lustre: OpenIB NAL unloaded (final mem %d)\n", - atomic_read(&portal_kmemory)); - - kibnal_data.kib_init = IBNAL_INIT_NOTHING; -} - -int -kibnal_api_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - ptl_process_id_t process_id; - int pkmem = atomic_read(&portal_kmemory); - int rc; - int i; - - LASSERT (nal == &kibnal_api); - - if (nal->nal_refct != 0) { - if (actual_limits != NULL) - *actual_limits = kibnal_lib.libnal_ni.ni_actual_limits; - /* This module got the first ref */ - PORTAL_MODULE_USE; - return (PTL_OK); - } - - LASSERT (kibnal_data.kib_init == IBNAL_INIT_NOTHING); - - memset (&kibnal_data, 0, sizeof (kibnal_data)); /* zero pointers, flags etc */ - - init_MUTEX (&kibnal_data.kib_nid_mutex); - init_MUTEX_LOCKED (&kibnal_data.kib_nid_signal); - kibnal_data.kib_nid = PTL_NID_ANY; - - rwlock_init(&kibnal_data.kib_global_lock); - - kibnal_data.kib_peer_hash_size = IBNAL_PEER_HASH_SIZE; - PORTAL_ALLOC (kibnal_data.kib_peers, - sizeof (struct list_head) * kibnal_data.kib_peer_hash_size); - if (kibnal_data.kib_peers == NULL) { - goto failed; - } - for (i = 0; i < kibnal_data.kib_peer_hash_size; i++) - INIT_LIST_HEAD(&kibnal_data.kib_peers[i]); - - spin_lock_init (&kibnal_data.kib_connd_lock); - INIT_LIST_HEAD (&kibnal_data.kib_connd_peers); - INIT_LIST_HEAD (&kibnal_data.kib_connd_conns); - init_waitqueue_head (&kibnal_data.kib_connd_waitq); - - spin_lock_init (&kibnal_data.kib_sched_lock); - INIT_LIST_HEAD (&kibnal_data.kib_sched_txq); - INIT_LIST_HEAD (&kibnal_data.kib_sched_rxq); - init_waitqueue_head (&kibnal_data.kib_sched_waitq); - - spin_lock_init (&kibnal_data.kib_tx_lock); - INIT_LIST_HEAD (&kibnal_data.kib_idle_txs); - INIT_LIST_HEAD (&kibnal_data.kib_idle_nblk_txs); - init_waitqueue_head(&kibnal_data.kib_idle_tx_waitq); - - PORTAL_ALLOC (kibnal_data.kib_tx_descs, - IBNAL_TX_MSGS * sizeof(kib_tx_t)); - if (kibnal_data.kib_tx_descs == NULL) { - CERROR ("Can't allocate tx descs\n"); - goto failed; - } - - /* lists/ptrs/locks initialised */ - kibnal_data.kib_init = IBNAL_INIT_DATA; - /*****************************************************/ - - - process_id.pid = requested_pid; - process_id.nid = kibnal_data.kib_nid; - - rc = lib_init(&kibnal_lib, nal, process_id, - requested_limits, actual_limits); - if (rc != PTL_OK) { - CERROR("lib_init failed: error %d\n", rc); - goto failed; - } - - /* lib interface initialised */ - kibnal_data.kib_init = IBNAL_INIT_LIB; - /*****************************************************/ - - for (i = 0; i < IBNAL_N_SCHED; i++) { - rc = kibnal_thread_start (kibnal_scheduler, (void *)i); - if (rc != 0) { - CERROR("Can't spawn openibnal scheduler[%d]: %d\n", - i, rc); - goto failed; - } - } - - rc = kibnal_thread_start (kibnal_connd, NULL); - if (rc != 0) { - CERROR ("Can't spawn openibnal connd: %d\n", rc); - goto failed; - } - - kibnal_data.kib_device = ib_device_get_by_index(0); - if (kibnal_data.kib_device == NULL) { - CERROR ("Can't open ib device 0\n"); - goto failed; - } - - rc = ib_device_properties_get(kibnal_data.kib_device, - &kibnal_data.kib_device_props); - if (rc != 0) { - CERROR ("Can't get device props: %d\n", rc); - goto failed; - } - - CDEBUG(D_NET, "Max Initiator: %d Max Responder %d\n", - kibnal_data.kib_device_props.max_initiator_per_qp, - kibnal_data.kib_device_props.max_responder_per_qp); - - kibnal_data.kib_port = 0; - for (i = 1; i <= 2; i++) { - rc = ib_port_properties_get(kibnal_data.kib_device, i, - &kibnal_data.kib_port_props); - if (rc == 0) { - kibnal_data.kib_port = i; - break; - } - } - if (kibnal_data.kib_port == 0) { - CERROR ("Can't find a port\n"); - goto failed; - } - - rc = ib_pd_create(kibnal_data.kib_device, - NULL, &kibnal_data.kib_pd); - if (rc != 0) { - CERROR ("Can't create PD: %d\n", rc); - goto failed; - } - - /* flag PD initialised */ - kibnal_data.kib_init = IBNAL_INIT_PD; - /*****************************************************/ -#if IBNAL_FMR - { - const int pool_size = IBNAL_NTX + IBNAL_NTX_NBLK; - struct ib_fmr_pool_param params = { - .max_pages_per_fmr = PTL_MTU/PAGE_SIZE, - .access = (IB_ACCESS_LOCAL_WRITE | - IB_ACCESS_REMOTE_WRITE | - IB_ACCESS_REMOTE_READ), - .pool_size = pool_size, - .dirty_watermark = (pool_size * 3)/4, - .flush_function = NULL, - .flush_arg = NULL, - .cache = 1, - }; - rc = ib_fmr_pool_create(kibnal_data.kib_pd, ¶ms, - &kibnal_data.kib_fmr_pool); - if (rc != 0) { - CERROR ("Can't create FMR pool size %d: %d\n", - pool_size, rc); - goto failed; - } - } - - /* flag FMR pool initialised */ - kibnal_data.kib_init = IBNAL_INIT_FMR; -#endif - /*****************************************************/ - - rc = kibnal_setup_tx_descs(); - if (rc != 0) { - CERROR ("Can't register tx descs: %d\n", rc); - goto failed; - } - - /* flag TX descs initialised */ - kibnal_data.kib_init = IBNAL_INIT_TXD; - /*****************************************************/ - - { - struct ib_cq_callback callback = { - .context = IBNAL_CALLBACK_CTXT, - .policy = IB_CQ_PROVIDER_REARM, - .function = { - .entry = kibnal_callback, - }, - .arg = NULL, - }; - int nentries = IBNAL_CQ_ENTRIES; - - rc = ib_cq_create (kibnal_data.kib_device, - &nentries, &callback, NULL, - &kibnal_data.kib_cq); - if (rc != 0) { - CERROR ("Can't create CQ: %d\n", rc); - goto failed; - } - - /* I only want solicited events */ - rc = ib_cq_request_notification(kibnal_data.kib_cq, 1); - LASSERT (rc == 0); - } - - /* flag CQ initialised */ - kibnal_data.kib_init = IBNAL_INIT_CQ; - /*****************************************************/ - - rc = libcfs_nal_cmd_register(OPENIBNAL, &kibnal_cmd, NULL); - if (rc != 0) { - CERROR ("Can't initialise command interface (rc = %d)\n", rc); - goto failed; - } - - /* flag everything initialised */ - kibnal_data.kib_init = IBNAL_INIT_ALL; - /*****************************************************/ - - printk(KERN_INFO "Lustre: OpenIB NAL loaded " - "(initial mem %d)\n", pkmem); - - return (PTL_OK); - - failed: - kibnal_api_shutdown (&kibnal_api); - return (PTL_FAIL); -} - -void __exit -kibnal_module_fini (void) -{ -#ifdef CONFIG_SYSCTL - if (kibnal_tunables.kib_sysctl != NULL) - unregister_sysctl_table (kibnal_tunables.kib_sysctl); -#endif - PtlNIFini(kibnal_ni); - - ptl_unregister_nal(OPENIBNAL); -} - -int __init -kibnal_module_init (void) -{ - int rc; - - /* the following must be sizeof(int) for proc_dointvec() */ - LASSERT(sizeof (kibnal_tunables.kib_io_timeout) == sizeof (int)); - - kibnal_api.nal_ni_init = kibnal_api_startup; - kibnal_api.nal_ni_fini = kibnal_api_shutdown; - - /* Initialise dynamic tunables to defaults once only */ - kibnal_tunables.kib_io_timeout = IBNAL_IO_TIMEOUT; - - rc = ptl_register_nal(OPENIBNAL, &kibnal_api); - if (rc != PTL_OK) { - CERROR("Can't register IBNAL: %d\n", rc); - return (-ENOMEM); /* or something... */ - } - - /* Pure gateways want the NAL started up at module load time... */ - rc = PtlNIInit(OPENIBNAL, LUSTRE_SRV_PTL_PID, NULL, NULL, &kibnal_ni); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) { - ptl_unregister_nal(OPENIBNAL); - return (-ENODEV); - } - -#ifdef CONFIG_SYSCTL - /* Press on regardless even if registering sysctl doesn't work */ - kibnal_tunables.kib_sysctl = - register_sysctl_table (kibnal_top_ctl_table, 0); -#endif - return (0); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Kernel OpenIB NAL v0.01"); -MODULE_LICENSE("GPL"); - -module_init(kibnal_module_init); -module_exit(kibnal_module_fini); - diff --git a/lnet/klnds/openiblnd/openiblnd.h b/lnet/klnds/openiblnd/openiblnd.h deleted file mode 100644 index 2fbd88b..0000000 --- a/lnet/klnds/openiblnd/openiblnd.h +++ /dev/null @@ -1,533 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_NAL - -#include -#include -#include -#include - -#include -#include -#include - -#define IBNAL_SERVICE_NAME "openibnal" - -#if CONFIG_SMP -# define IBNAL_N_SCHED num_online_cpus() /* # schedulers */ -#else -# define IBNAL_N_SCHED 1 /* # schedulers */ -#endif - -#define IBNAL_MIN_RECONNECT_INTERVAL HZ /* first failed connection retry... */ -#define IBNAL_MAX_RECONNECT_INTERVAL (60*HZ) /* ...exponentially increasing to this */ - -#define IBNAL_MSG_SIZE (4<<10) /* max size of queued messages (inc hdr) */ - -#define IBNAL_MSG_QUEUE_SIZE 8 /* # messages/RDMAs in-flight */ -#define IBNAL_CREDIT_HIGHWATER 6 /* when to eagerly return credits */ -#define IBNAL_RETRY 7 /* # times to retry */ -#define IBNAL_RNR_RETRY 7 /* */ -#define IBNAL_CM_RETRY 7 /* # times to retry connection */ -#define IBNAL_FLOW_CONTROL 1 -#define IBNAL_RESPONDER_RESOURCES 8 - -#define IBNAL_NTX 64 /* # tx descs */ -#define IBNAL_NTX_NBLK 256 /* # reserved tx descs */ - -#define IBNAL_PEER_HASH_SIZE 101 /* # peer lists */ - -#define IBNAL_RESCHED 100 /* # scheduler loops before reschedule */ - -#define IBNAL_CONCURRENT_PEERS 1000 /* # nodes all talking at once to me */ - -/* default vals for runtime tunables */ -#define IBNAL_IO_TIMEOUT 50 /* default comms timeout (seconds) */ - -/************************/ -/* derived constants... */ - -/* TX messages (shared by all connections) */ -#define IBNAL_TX_MSGS (IBNAL_NTX + IBNAL_NTX_NBLK) -#define IBNAL_TX_MSG_BYTES (IBNAL_TX_MSGS * IBNAL_MSG_SIZE) -#define IBNAL_TX_MSG_PAGES ((IBNAL_TX_MSG_BYTES + PAGE_SIZE - 1)/PAGE_SIZE) - -/* RX messages (per connection) */ -#define IBNAL_RX_MSGS IBNAL_MSG_QUEUE_SIZE -#define IBNAL_RX_MSG_BYTES (IBNAL_RX_MSGS * IBNAL_MSG_SIZE) -#define IBNAL_RX_MSG_PAGES ((IBNAL_RX_MSG_BYTES + PAGE_SIZE - 1)/PAGE_SIZE) - -/* we may have up to 2 completions per transmit + - 1 completion per receive, per connection */ -#define IBNAL_CQ_ENTRIES ((2*IBNAL_TX_MSGS) + \ - (IBNAL_RX_MSGS * IBNAL_CONCURRENT_PEERS)) - -#define IBNAL_RDMA_BASE 0x0eeb0000 -#define IBNAL_FMR 1 -#define IBNAL_CKSUM 0 -//#define IBNAL_CALLBACK_CTXT IB_CQ_CALLBACK_PROCESS -#define IBNAL_CALLBACK_CTXT IB_CQ_CALLBACK_INTERRUPT - -typedef struct -{ - int kib_io_timeout; /* comms timeout (seconds) */ - struct ctl_table_header *kib_sysctl; /* sysctl interface */ -} kib_tunables_t; - -typedef struct -{ - int ibp_npages; /* # pages */ - int ibp_mapped; /* mapped? */ - __u64 ibp_vaddr; /* mapped region vaddr */ - __u32 ibp_lkey; /* mapped region lkey */ - __u32 ibp_rkey; /* mapped region rkey */ - struct ib_mr *ibp_handle; /* mapped region handle */ - struct page *ibp_pages[0]; -} kib_pages_t; - -typedef struct -{ - int kib_init; /* initialisation state */ - __u64 kib_incarnation; /* which one am I */ - int kib_shutdown; /* shut down? */ - atomic_t kib_nthreads; /* # live threads */ - - __u64 kib_service_id; /* service number I listen on */ - ptl_nid_t kib_nid; /* my NID */ - struct semaphore kib_nid_mutex; /* serialise NID ops */ - struct semaphore kib_nid_signal; /* signal completion */ - - rwlock_t kib_global_lock; /* stabilize peer/conn ops */ - - struct list_head *kib_peers; /* hash table of all my known peers */ - int kib_peer_hash_size; /* size of kib_peers */ - atomic_t kib_npeers; /* # peers extant */ - atomic_t kib_nconns; /* # connections extant */ - - struct list_head kib_connd_conns; /* connections to progress */ - struct list_head kib_connd_peers; /* peers waiting for a connection */ - wait_queue_head_t kib_connd_waitq; /* connection daemons sleep here */ - unsigned long kib_connd_waketime; /* when connd will wake */ - spinlock_t kib_connd_lock; /* serialise */ - - wait_queue_head_t kib_sched_waitq; /* schedulers sleep here */ - struct list_head kib_sched_txq; /* tx requiring attention */ - struct list_head kib_sched_rxq; /* rx requiring attention */ - spinlock_t kib_sched_lock; /* serialise */ - - struct kib_tx *kib_tx_descs; /* all the tx descriptors */ - kib_pages_t *kib_tx_pages; /* premapped tx msg pages */ - - struct list_head kib_idle_txs; /* idle tx descriptors */ - struct list_head kib_idle_nblk_txs; /* idle reserved tx descriptors */ - wait_queue_head_t kib_idle_tx_waitq; /* block here for tx descriptor */ - __u64 kib_next_tx_cookie; /* RDMA completion cookie */ - spinlock_t kib_tx_lock; /* serialise */ - - struct ib_device *kib_device; /* "the" device */ - struct ib_device_properties kib_device_props; /* its properties */ - int kib_port; /* port on the device */ - struct ib_port_properties kib_port_props; /* its properties */ - struct ib_pd *kib_pd; /* protection domain */ -#if IBNAL_FMR - struct ib_fmr_pool *kib_fmr_pool; /* fast memory region pool */ -#endif - struct ib_cq *kib_cq; /* completion queue */ - void *kib_listen_handle; /* where I listen for connections */ - -} kib_data_t; - -#define IBNAL_INIT_NOTHING 0 -#define IBNAL_INIT_DATA 1 -#define IBNAL_INIT_LIB 2 -#define IBNAL_INIT_PD 3 -#define IBNAL_INIT_FMR 4 -#define IBNAL_INIT_TXD 5 -#define IBNAL_INIT_CQ 6 -#define IBNAL_INIT_ALL 7 - -/************************************************************************ - * Wire message structs. - * These are sent in sender's byte order (i.e. receiver flips). - * CAVEAT EMPTOR: other structs communicated between nodes (e.g. MAD - * private data and SM service info), is LE on the wire. - */ - -typedef struct -{ - union { - struct ib_mr *mr; - struct ib_fmr *fmr; - } md_handle; - __u32 md_lkey; - __u32 md_rkey; - __u64 md_addr; -} kib_md_t; - -typedef struct -{ - __u32 rd_key; /* remote key */ - __u32 rd_nob; /* # of bytes */ - __u64 rd_addr; /* remote io vaddr */ -} kib_rdma_desc_t; - - -typedef struct -{ - ptl_hdr_t ibim_hdr; /* portals header */ - char ibim_payload[0]; /* piggy-backed payload */ -} kib_immediate_msg_t; - -typedef struct -{ - ptl_hdr_t ibrm_hdr; /* portals header */ - __u64 ibrm_cookie; /* opaque completion cookie */ - kib_rdma_desc_t ibrm_desc; /* where to suck/blow */ -} kib_rdma_msg_t; - -typedef struct -{ - __u64 ibcm_cookie; /* opaque completion cookie */ - __u32 ibcm_status; /* completion status */ -} kib_completion_msg_t; - -typedef struct -{ - __u32 ibm_magic; /* I'm an openibnal message */ - __u16 ibm_version; /* this is my version number */ - __u8 ibm_type; /* msg type */ - __u8 ibm_credits; /* returned credits */ -#if IBNAL_CKSUM - __u32 ibm_nob; - __u32 ibm_cksum; -#endif - union { - kib_immediate_msg_t immediate; - kib_rdma_msg_t rdma; - kib_completion_msg_t completion; - } ibm_u; -} kib_msg_t; - -#define IBNAL_MSG_MAGIC 0x0be91b91 /* unique magic */ -#define IBNAL_MSG_VERSION 1 /* current protocol version */ - -#define IBNAL_MSG_NOOP 0xd0 /* nothing (just credits) */ -#define IBNAL_MSG_IMMEDIATE 0xd1 /* portals hdr + payload */ -#define IBNAL_MSG_PUT_RDMA 0xd2 /* portals PUT hdr + source rdma desc */ -#define IBNAL_MSG_PUT_DONE 0xd3 /* signal PUT rdma completion */ -#define IBNAL_MSG_GET_RDMA 0xd4 /* portals GET hdr + sink rdma desc */ -#define IBNAL_MSG_GET_DONE 0xd5 /* signal GET rdma completion */ - -/***********************************************************************/ - -typedef struct kib_rx /* receive message */ -{ - struct list_head rx_list; /* queue for attention */ - struct kib_conn *rx_conn; /* owning conn */ - int rx_rdma; /* RDMA completion posted? */ - int rx_posted; /* posted? */ - __u64 rx_vaddr; /* pre-mapped buffer (hca vaddr) */ - kib_msg_t *rx_msg; /* pre-mapped buffer (host vaddr) */ - struct ib_receive_param rx_sp; /* receive work item */ - struct ib_gather_scatter rx_gl; /* and it's memory */ -} kib_rx_t; - -typedef struct kib_tx /* transmit message */ -{ - struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */ - int tx_isnblk; /* I'm reserved for non-blocking sends */ - struct kib_conn *tx_conn; /* owning conn */ - int tx_mapped; /* mapped for RDMA? */ - int tx_sending; /* # tx callbacks outstanding */ - int tx_status; /* completion status */ - unsigned long tx_deadline; /* completion deadline */ - int tx_passive_rdma; /* peer sucks/blows */ - int tx_passive_rdma_wait; /* waiting for peer to complete */ - __u64 tx_passive_rdma_cookie; /* completion cookie */ - lib_msg_t *tx_libmsg[2]; /* lib msgs to finalize on completion */ - kib_md_t tx_md; /* RDMA mapping (active/passive) */ - __u64 tx_vaddr; /* pre-mapped buffer (hca vaddr) */ - kib_msg_t *tx_msg; /* pre-mapped buffer (host vaddr) */ - int tx_nsp; /* # send work items */ - struct ib_send_param tx_sp[2]; /* send work items... */ - struct ib_gather_scatter tx_gl[2]; /* ...and their memory */ -} kib_tx_t; - -#define KIB_TX_UNMAPPED 0 -#define KIB_TX_MAPPED 1 -#define KIB_TX_MAPPED_FMR 2 - -typedef struct kib_wire_connreq -{ - __u32 wcr_magic; /* I'm an openibnal connreq */ - __u16 wcr_version; /* this is my version number */ - __u16 wcr_queue_depth; /* this is my receive queue size */ - __u64 wcr_nid; /* peer's NID */ - __u64 wcr_incarnation; /* peer's incarnation */ -} kib_wire_connreq_t; - -typedef struct kib_connreq -{ - /* connection-in-progress */ - struct kib_conn *cr_conn; - kib_wire_connreq_t cr_wcr; - __u64 cr_tid; - struct ib_common_attrib_service cr_service; - tTS_IB_GID cr_gid; - struct ib_path_record cr_path; - struct ib_cm_active_param cr_connparam; -} kib_connreq_t; - -typedef struct kib_conn -{ - struct kib_peer *ibc_peer; /* owning peer */ - struct list_head ibc_list; /* stash on peer's conn list */ - __u64 ibc_incarnation; /* which instance of the peer */ - atomic_t ibc_refcount; /* # users */ - int ibc_state; /* what's happening */ - atomic_t ibc_nob; /* # bytes buffered */ - int ibc_nsends_posted; /* # uncompleted sends */ - int ibc_credits; /* # credits I have */ - int ibc_outstanding_credits; /* # credits to return */ - struct list_head ibc_tx_queue; /* send queue */ - struct list_head ibc_active_txs; /* active tx awaiting completion */ - spinlock_t ibc_lock; /* serialise */ - kib_rx_t *ibc_rxs; /* the rx descs */ - kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */ - struct ib_qp *ibc_qp; /* queue pair */ - __u32 ibc_qpn; /* queue pair number */ - tTS_IB_CM_COMM_ID ibc_comm_id; /* connection ID? */ - kib_connreq_t *ibc_connreq; /* connection request state */ -} kib_conn_t; - -#define IBNAL_CONN_INIT_NOTHING 0 /* initial state */ -#define IBNAL_CONN_INIT_QP 1 /* ibc_qp set up */ -#define IBNAL_CONN_CONNECTING 2 /* started to connect */ -#define IBNAL_CONN_ESTABLISHED 3 /* connection established */ -#define IBNAL_CONN_DEATHROW 4 /* waiting to be closed */ -#define IBNAL_CONN_ZOMBIE 5 /* waiting to be freed */ - -typedef struct kib_peer -{ - struct list_head ibp_list; /* stash on global peer list */ - struct list_head ibp_connd_list; /* schedule on kib_connd_peers */ - ptl_nid_t ibp_nid; /* who's on the other end(s) */ - atomic_t ibp_refcount; /* # users */ - int ibp_persistence; /* "known" peer refs */ - struct list_head ibp_conns; /* all active connections */ - struct list_head ibp_tx_queue; /* msgs waiting for a conn */ - int ibp_connecting; /* connecting+accepting */ - unsigned long ibp_reconnect_time; /* when reconnect may be attempted */ - unsigned long ibp_reconnect_interval; /* exponential backoff */ -} kib_peer_t; - - -extern lib_nal_t kibnal_lib; -extern kib_data_t kibnal_data; -extern kib_tunables_t kibnal_tunables; - -static inline struct list_head * -kibnal_nid2peerlist (ptl_nid_t nid) -{ - unsigned int hash = ((unsigned int)nid) % kibnal_data.kib_peer_hash_size; - - return (&kibnal_data.kib_peers [hash]); -} - -static inline int -kibnal_peer_active(kib_peer_t *peer) -{ - /* Am I in the peer hash table? */ - return (!list_empty(&peer->ibp_list)); -} - -static inline void -kibnal_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn) -{ - /* CAVEAT EMPTOR: tx takes caller's ref on conn */ - - LASSERT (tx->tx_nsp > 0); /* work items set up */ - LASSERT (tx->tx_conn == NULL); /* only set here */ - - tx->tx_conn = conn; - tx->tx_deadline = jiffies + kibnal_tunables.kib_io_timeout * HZ; - list_add_tail(&tx->tx_list, &conn->ibc_tx_queue); -} - -#define KIBNAL_SERVICE_KEY_MASK (IB_SA_SERVICE_COMP_MASK_NAME | \ - IB_SA_SERVICE_COMP_MASK_DATA8_1 | \ - IB_SA_SERVICE_COMP_MASK_DATA8_2 | \ - IB_SA_SERVICE_COMP_MASK_DATA8_3 | \ - IB_SA_SERVICE_COMP_MASK_DATA8_4 | \ - IB_SA_SERVICE_COMP_MASK_DATA8_5 | \ - IB_SA_SERVICE_COMP_MASK_DATA8_6 | \ - IB_SA_SERVICE_COMP_MASK_DATA8_7 | \ - IB_SA_SERVICE_COMP_MASK_DATA8_8) - -static inline __u64* -kibnal_service_nid_field(struct ib_common_attrib_service *srv) -{ - /* must be consistent with KIBNAL_SERVICE_KEY_MASK */ - return (__u64 *)srv->service_data8; -} - - -static inline void -kibnal_set_service_keys(struct ib_common_attrib_service *srv, ptl_nid_t nid) -{ - LASSERT (strlen (IBNAL_SERVICE_NAME) < sizeof(srv->service_name)); - memset (srv->service_name, 0, sizeof(srv->service_name)); - strcpy (srv->service_name, IBNAL_SERVICE_NAME); - - *kibnal_service_nid_field(srv) = cpu_to_le64(nid); -} - -#if 0 -static inline void -kibnal_show_rdma_attr (kib_conn_t *conn) -{ - struct ib_qp_attribute qp_attr; - int rc; - - memset (&qp_attr, 0, sizeof(qp_attr)); - rc = ib_qp_query(conn->ibc_qp, &qp_attr); - if (rc != 0) { - CERROR ("Can't get qp attrs: %d\n", rc); - return; - } - - CWARN ("RDMA CAPABILITY: write %s read %s\n", - (qp_attr.valid_fields & TS_IB_QP_ATTRIBUTE_RDMA_ATOMIC_ENABLE) ? - (qp_attr.enable_rdma_write ? "enabled" : "disabled") : "invalid", - (qp_attr.valid_fields & TS_IB_QP_ATTRIBUTE_RDMA_ATOMIC_ENABLE) ? - (qp_attr.enable_rdma_read ? "enabled" : "disabled") : "invalid"); -} -#endif - -#if CONFIG_X86 -static inline __u64 -kibnal_page2phys (struct page *p) -{ - __u64 page_number = p - mem_map; - - return (page_number << PAGE_SHIFT); -} -#else -# error "no page->phys" -#endif - -/* CAVEAT EMPTOR: - * We rely on tx/rx descriptor alignment to allow us to use the lowest bit - * of the work request id as a flag to determine if the completion is for a - * transmit or a receive. It seems that that the CQ entry's 'op' field - * isn't always set correctly on completions that occur after QP teardown. */ - -static inline __u64 -kibnal_ptr2wreqid (void *ptr, int isrx) -{ - unsigned long lptr = (unsigned long)ptr; - - LASSERT ((lptr & 1) == 0); - return (__u64)(lptr | (isrx ? 1 : 0)); -} - -static inline void * -kibnal_wreqid2ptr (__u64 wreqid) -{ - return (void *)(((unsigned long)wreqid) & ~1UL); -} - -static inline int -kibnal_wreqid_is_rx (__u64 wreqid) -{ - return (wreqid & 1) != 0; -} - -extern kib_peer_t *kibnal_create_peer (ptl_nid_t nid); -extern void kibnal_put_peer (kib_peer_t *peer); -extern int kibnal_del_peer (ptl_nid_t nid, int single_share); -extern kib_peer_t *kibnal_find_peer_locked (ptl_nid_t nid); -extern void kibnal_unlink_peer_locked (kib_peer_t *peer); -extern int kibnal_close_stale_conns_locked (kib_peer_t *peer, - __u64 incarnation); -extern kib_conn_t *kibnal_create_conn (void); -extern void kibnal_put_conn (kib_conn_t *conn); -extern void kibnal_destroy_conn (kib_conn_t *conn); -extern int kibnal_alloc_pages (kib_pages_t **pp, int npages, int access); -extern void kibnal_free_pages (kib_pages_t *p); - -extern void kibnal_check_sends (kib_conn_t *conn); - -extern tTS_IB_CM_CALLBACK_RETURN -kibnal_conn_callback (tTS_IB_CM_EVENT event, tTS_IB_CM_COMM_ID cid, - void *param, void *arg); -extern tTS_IB_CM_CALLBACK_RETURN -kibnal_passive_conn_callback (tTS_IB_CM_EVENT event, tTS_IB_CM_COMM_ID cid, - void *param, void *arg); - -extern void kibnal_close_conn_locked (kib_conn_t *conn, int error); -extern void kibnal_destroy_conn (kib_conn_t *conn); -extern int kibnal_thread_start (int (*fn)(void *arg), void *arg); -extern int kibnal_scheduler(void *arg); -extern int kibnal_connd (void *arg); -extern void kibnal_callback (struct ib_cq *cq, struct ib_cq_entry *e, void *arg); -extern void kibnal_init_tx_msg (kib_tx_t *tx, int type, int body_nob); -extern int kibnal_close_conn (kib_conn_t *conn, int why); -extern void kibnal_start_active_rdma (int type, int status, - kib_rx_t *rx, lib_msg_t *libmsg, - unsigned int niov, - struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t nob); - - - - - diff --git a/lnet/klnds/openiblnd/openiblnd_cb.c b/lnet/klnds/openiblnd/openiblnd_cb.c deleted file mode 100644 index d774853..0000000 --- a/lnet/klnds/openiblnd/openiblnd_cb.c +++ /dev/null @@ -1,2597 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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. - * - */ - -#include "openibnal.h" - -/* - * LIB functions follow - * - */ -void -kibnal_schedule_tx_done (kib_tx_t *tx) -{ - unsigned long flags; - - spin_lock_irqsave (&kibnal_data.kib_sched_lock, flags); - - list_add_tail(&tx->tx_list, &kibnal_data.kib_sched_txq); - wake_up (&kibnal_data.kib_sched_waitq); - - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, flags); -} - -void -kibnal_tx_done (kib_tx_t *tx) -{ - ptl_err_t ptlrc = (tx->tx_status == 0) ? PTL_OK : PTL_FAIL; - unsigned long flags; - int i; - int rc; - - LASSERT (tx->tx_sending == 0); /* mustn't be awaiting callback */ - LASSERT (!tx->tx_passive_rdma_wait); /* mustn't be awaiting RDMA */ - - switch (tx->tx_mapped) { - default: - LBUG(); - - case KIB_TX_UNMAPPED: - break; - - case KIB_TX_MAPPED: - if (in_interrupt()) { - /* can't deregister memory in IRQ context... */ - kibnal_schedule_tx_done(tx); - return; - } - rc = ib_memory_deregister(tx->tx_md.md_handle.mr); - LASSERT (rc == 0); - tx->tx_mapped = KIB_TX_UNMAPPED; - break; - -#if IBNAL_FMR - case KIB_TX_MAPPED_FMR: - if (in_interrupt() && tx->tx_status != 0) { - /* can't flush FMRs in IRQ context... */ - kibnal_schedule_tx_done(tx); - return; - } - - rc = ib_fmr_deregister(tx->tx_md.md_handle.fmr); - LASSERT (rc == 0); - - if (tx->tx_status != 0) - ib_fmr_pool_force_flush(kibnal_data.kib_fmr_pool); - tx->tx_mapped = KIB_TX_UNMAPPED; - break; -#endif - } - - for (i = 0; i < 2; i++) { - /* tx may have up to 2 libmsgs to finalise */ - if (tx->tx_libmsg[i] == NULL) - continue; - - lib_finalize (&kibnal_lib, NULL, tx->tx_libmsg[i], ptlrc); - tx->tx_libmsg[i] = NULL; - } - - if (tx->tx_conn != NULL) { - kibnal_put_conn (tx->tx_conn); - tx->tx_conn = NULL; - } - - tx->tx_nsp = 0; - tx->tx_passive_rdma = 0; - tx->tx_status = 0; - - spin_lock_irqsave (&kibnal_data.kib_tx_lock, flags); - - if (tx->tx_isnblk) { - list_add_tail (&tx->tx_list, &kibnal_data.kib_idle_nblk_txs); - } else { - list_add_tail (&tx->tx_list, &kibnal_data.kib_idle_txs); - wake_up (&kibnal_data.kib_idle_tx_waitq); - } - - spin_unlock_irqrestore (&kibnal_data.kib_tx_lock, flags); -} - -kib_tx_t * -kibnal_get_idle_tx (int may_block) -{ - unsigned long flags; - kib_tx_t *tx = NULL; - - for (;;) { - spin_lock_irqsave (&kibnal_data.kib_tx_lock, flags); - - /* "normal" descriptor is free */ - if (!list_empty (&kibnal_data.kib_idle_txs)) { - tx = list_entry (kibnal_data.kib_idle_txs.next, - kib_tx_t, tx_list); - break; - } - - if (!may_block) { - /* may dip into reserve pool */ - if (list_empty (&kibnal_data.kib_idle_nblk_txs)) { - CERROR ("reserved tx desc pool exhausted\n"); - break; - } - - tx = list_entry (kibnal_data.kib_idle_nblk_txs.next, - kib_tx_t, tx_list); - break; - } - - /* block for idle tx */ - spin_unlock_irqrestore (&kibnal_data.kib_tx_lock, flags); - - wait_event (kibnal_data.kib_idle_tx_waitq, - !list_empty (&kibnal_data.kib_idle_txs) || - kibnal_data.kib_shutdown); - } - - if (tx != NULL) { - list_del (&tx->tx_list); - - /* Allocate a new passive RDMA completion cookie. It might - * not be needed, but we've got a lock right now and we're - * unlikely to wrap... */ - tx->tx_passive_rdma_cookie = kibnal_data.kib_next_tx_cookie++; - - LASSERT (tx->tx_mapped == KIB_TX_UNMAPPED); - LASSERT (tx->tx_nsp == 0); - LASSERT (tx->tx_sending == 0); - LASSERT (tx->tx_status == 0); - LASSERT (tx->tx_conn == NULL); - LASSERT (!tx->tx_passive_rdma); - LASSERT (!tx->tx_passive_rdma_wait); - LASSERT (tx->tx_libmsg[0] == NULL); - LASSERT (tx->tx_libmsg[1] == NULL); - } - - spin_unlock_irqrestore (&kibnal_data.kib_tx_lock, flags); - - return (tx); -} - -int -kibnal_dist(lib_nal_t *nal, ptl_nid_t nid, unsigned long *dist) -{ - /* I would guess that if kibnal_get_peer (nid) == NULL, - and we're not routing, then 'nid' is very distant :) */ - if ( nal->libnal_ni.ni_pid.nid == nid ) { - *dist = 0; - } else { - *dist = 1; - } - - return 0; -} - -void -kibnal_complete_passive_rdma(kib_conn_t *conn, __u64 cookie, int status) -{ - struct list_head *ttmp; - unsigned long flags; - int idle; - - spin_lock_irqsave (&conn->ibc_lock, flags); - - list_for_each (ttmp, &conn->ibc_active_txs) { - kib_tx_t *tx = list_entry(ttmp, kib_tx_t, tx_list); - - LASSERT (tx->tx_passive_rdma || - !tx->tx_passive_rdma_wait); - - LASSERT (tx->tx_passive_rdma_wait || - tx->tx_sending != 0); - - if (!tx->tx_passive_rdma_wait || - tx->tx_passive_rdma_cookie != cookie) - continue; - - CDEBUG(D_NET, "Complete %p "LPD64": %d\n", tx, cookie, status); - - tx->tx_status = status; - tx->tx_passive_rdma_wait = 0; - idle = (tx->tx_sending == 0); - - if (idle) - list_del (&tx->tx_list); - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - /* I could be racing with tx callbacks. It's whoever - * _makes_ tx idle that frees it */ - if (idle) - kibnal_tx_done (tx); - return; - } - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - CERROR ("Unmatched (late?) RDMA completion "LPX64" from "LPX64"\n", - cookie, conn->ibc_peer->ibp_nid); -} - -void -kibnal_post_rx (kib_rx_t *rx, int do_credits) -{ - kib_conn_t *conn = rx->rx_conn; - int rc; - unsigned long flags; - - rx->rx_gl = (struct ib_gather_scatter) { - .address = rx->rx_vaddr, - .length = IBNAL_MSG_SIZE, - .key = conn->ibc_rx_pages->ibp_lkey, - }; - - rx->rx_sp = (struct ib_receive_param) { - .work_request_id = kibnal_ptr2wreqid(rx, 1), - .scatter_list = &rx->rx_gl, - .num_scatter_entries = 1, - .device_specific = NULL, - .signaled = 1, - }; - - LASSERT (conn->ibc_state >= IBNAL_CONN_ESTABLISHED); - LASSERT (!rx->rx_posted); - rx->rx_posted = 1; - mb(); - - if (conn->ibc_state != IBNAL_CONN_ESTABLISHED) - rc = -ECONNABORTED; - else - rc = ib_receive (conn->ibc_qp, &rx->rx_sp, 1); - - if (rc == 0) { - if (do_credits) { - spin_lock_irqsave(&conn->ibc_lock, flags); - conn->ibc_outstanding_credits++; - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - kibnal_check_sends(conn); - } - return; - } - - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) { - CERROR ("Error posting receive -> "LPX64": %d\n", - conn->ibc_peer->ibp_nid, rc); - kibnal_close_conn (rx->rx_conn, rc); - } else { - CDEBUG (D_NET, "Error posting receive -> "LPX64": %d\n", - conn->ibc_peer->ibp_nid, rc); - } - - /* Drop rx's ref */ - kibnal_put_conn (conn); -} - -#if IBNAL_CKSUM -__u32 kibnal_cksum (void *ptr, int nob) -{ - char *c = ptr; - __u32 sum = 0; - - while (nob-- > 0) - sum = ((sum << 1) | (sum >> 31)) + *c++; - - return (sum); -} -#endif - -void -kibnal_rx_callback (struct ib_cq_entry *e) -{ - kib_rx_t *rx = (kib_rx_t *)kibnal_wreqid2ptr(e->work_request_id); - kib_msg_t *msg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; - int nob = e->bytes_transferred; - const int base_nob = offsetof(kib_msg_t, ibm_u); - int credits; - int flipped; - unsigned long flags; -#if IBNAL_CKSUM - __u32 msg_cksum; - __u32 computed_cksum; -#endif - - CDEBUG (D_NET, "rx %p conn %p\n", rx, conn); - LASSERT (rx->rx_posted); - rx->rx_posted = 0; - mb(); - - /* receives complete with error in any case after we've started - * closing the QP */ - if (conn->ibc_state >= IBNAL_CONN_DEATHROW) - goto failed; - - /* We don't post receives until the conn is established */ - LASSERT (conn->ibc_state == IBNAL_CONN_ESTABLISHED); - - if (e->status != IB_COMPLETION_STATUS_SUCCESS) { - CERROR("Rx from "LPX64" failed: %d\n", - conn->ibc_peer->ibp_nid, e->status); - goto failed; - } - - if (nob < base_nob) { - CERROR ("Short rx from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, nob); - goto failed; - } - - /* Receiver does any byte flipping if necessary... */ - - if (msg->ibm_magic == IBNAL_MSG_MAGIC) { - flipped = 0; - } else { - if (msg->ibm_magic != __swab32(IBNAL_MSG_MAGIC)) { - CERROR ("Unrecognised magic: %08x from "LPX64"\n", - msg->ibm_magic, conn->ibc_peer->ibp_nid); - goto failed; - } - flipped = 1; - __swab16s (&msg->ibm_version); - LASSERT (sizeof(msg->ibm_type) == 1); - LASSERT (sizeof(msg->ibm_credits) == 1); - } - - if (msg->ibm_version != IBNAL_MSG_VERSION) { - CERROR ("Incompatible msg version %d (%d expected)\n", - msg->ibm_version, IBNAL_MSG_VERSION); - goto failed; - } - -#if IBNAL_CKSUM - if (nob != msg->ibm_nob) { - CERROR ("Unexpected # bytes %d (%d expected)\n", nob, msg->ibm_nob); - goto failed; - } - - msg_cksum = le32_to_cpu(msg->ibm_cksum); - msg->ibm_cksum = 0; - computed_cksum = kibnal_cksum (msg, nob); - - if (msg_cksum != computed_cksum) { - CERROR ("Checksum failure %d: (%d expected)\n", - computed_cksum, msg_cksum); - goto failed; - } - CDEBUG(D_NET, "cksum %x, nob %d\n", computed_cksum, nob); -#endif - - /* Have I received credits that will let me send? */ - credits = msg->ibm_credits; - if (credits != 0) { - spin_lock_irqsave(&conn->ibc_lock, flags); - conn->ibc_credits += credits; - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - kibnal_check_sends(conn); - } - - switch (msg->ibm_type) { - case IBNAL_MSG_NOOP: - kibnal_post_rx (rx, 1); - return; - - case IBNAL_MSG_IMMEDIATE: - if (nob < base_nob + sizeof (kib_immediate_msg_t)) { - CERROR ("Short IMMEDIATE from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, nob); - goto failed; - } - break; - - case IBNAL_MSG_PUT_RDMA: - case IBNAL_MSG_GET_RDMA: - if (nob < base_nob + sizeof (kib_rdma_msg_t)) { - CERROR ("Short RDMA msg from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, nob); - goto failed; - } - if (flipped) { - __swab32s(&msg->ibm_u.rdma.ibrm_desc.rd_key); - __swab32s(&msg->ibm_u.rdma.ibrm_desc.rd_nob); - __swab64s(&msg->ibm_u.rdma.ibrm_desc.rd_addr); - } - CDEBUG(D_NET, "%d RDMA: cookie "LPX64", key %x, addr "LPX64", nob %d\n", - msg->ibm_type, msg->ibm_u.rdma.ibrm_cookie, - msg->ibm_u.rdma.ibrm_desc.rd_key, - msg->ibm_u.rdma.ibrm_desc.rd_addr, - msg->ibm_u.rdma.ibrm_desc.rd_nob); - break; - - case IBNAL_MSG_PUT_DONE: - case IBNAL_MSG_GET_DONE: - if (nob < base_nob + sizeof (kib_completion_msg_t)) { - CERROR ("Short COMPLETION msg from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, nob); - goto failed; - } - if (flipped) - __swab32s(&msg->ibm_u.completion.ibcm_status); - - CDEBUG(D_NET, "%d DONE: cookie "LPX64", status %d\n", - msg->ibm_type, msg->ibm_u.completion.ibcm_cookie, - msg->ibm_u.completion.ibcm_status); - - kibnal_complete_passive_rdma (conn, - msg->ibm_u.completion.ibcm_cookie, - msg->ibm_u.completion.ibcm_status); - kibnal_post_rx (rx, 1); - return; - - default: - CERROR ("Can't parse type from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, msg->ibm_type); - goto failed; - } - - /* schedule for kibnal_rx() in thread context */ - spin_lock_irqsave(&kibnal_data.kib_sched_lock, flags); - - list_add_tail (&rx->rx_list, &kibnal_data.kib_sched_rxq); - wake_up (&kibnal_data.kib_sched_waitq); - - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, flags); - return; - - failed: - CDEBUG(D_NET, "rx %p conn %p\n", rx, conn); - kibnal_close_conn(conn, -ECONNABORTED); - - /* Don't re-post rx & drop its ref on conn */ - kibnal_put_conn(conn); -} - -void -kibnal_rx (kib_rx_t *rx) -{ - kib_msg_t *msg = rx->rx_msg; - - /* Clear flag so I can detect if I've sent an RDMA completion */ - rx->rx_rdma = 0; - - switch (msg->ibm_type) { - case IBNAL_MSG_GET_RDMA: - lib_parse(&kibnal_lib, &msg->ibm_u.rdma.ibrm_hdr, rx); - /* If the incoming get was matched, I'll have initiated the - * RDMA and the completion message... */ - if (rx->rx_rdma) - break; - - /* Otherwise, I'll send a failed completion now to prevent - * the peer's GET blocking for the full timeout. */ - CERROR ("Completing unmatched RDMA GET from "LPX64"\n", - rx->rx_conn->ibc_peer->ibp_nid); - kibnal_start_active_rdma (IBNAL_MSG_GET_DONE, -EIO, - rx, NULL, 0, NULL, NULL, 0, 0); - break; - - case IBNAL_MSG_PUT_RDMA: - lib_parse(&kibnal_lib, &msg->ibm_u.rdma.ibrm_hdr, rx); - if (rx->rx_rdma) - break; - /* This is most unusual, since even if lib_parse() didn't - * match anything, it should have asked us to read (and - * discard) the payload. The portals header must be - * inconsistent with this message type, so it's the - * sender's fault for sending garbage and she can time - * herself out... */ - CERROR ("Uncompleted RMDA PUT from "LPX64"\n", - rx->rx_conn->ibc_peer->ibp_nid); - break; - - case IBNAL_MSG_IMMEDIATE: - lib_parse(&kibnal_lib, &msg->ibm_u.immediate.ibim_hdr, rx); - LASSERT (!rx->rx_rdma); - break; - - default: - LBUG(); - break; - } - - kibnal_post_rx (rx, 1); -} - -#if 0 -int -kibnal_kvaddr_to_phys (unsigned long vaddr, __u64 *physp) -{ - struct page *page; - - if (vaddr >= VMALLOC_START && - vaddr < VMALLOC_END) - page = vmalloc_to_page ((void *)vaddr); -#if CONFIG_HIGHMEM - else if (vaddr >= PKMAP_BASE && - vaddr < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE)) - page = vmalloc_to_page ((void *)vaddr); - /* in 2.4 ^ just walks the page tables */ -#endif - else - page = virt_to_page (vaddr); - - if (page == NULL || - !VALID_PAGE (page)) - return (-EFAULT); - - *physp = kibnal_page2phys(page) + (vaddr & (PAGE_SIZE - 1)); - return (0); -} -#endif - -int -kibnal_map_iov (kib_tx_t *tx, enum ib_memory_access access, - int niov, struct iovec *iov, int offset, int nob) - -{ - void *vaddr; - int rc; - - LASSERT (nob > 0); - LASSERT (niov > 0); - LASSERT (tx->tx_mapped == KIB_TX_UNMAPPED); - - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - niov--; - iov++; - LASSERT (niov > 0); - } - - if (nob > iov->iov_len - offset) { - CERROR ("Can't map multiple vaddr fragments\n"); - return (-EMSGSIZE); - } - - vaddr = (void *)(((unsigned long)iov->iov_base) + offset); - tx->tx_md.md_addr = (__u64)((unsigned long)vaddr); - - rc = ib_memory_register (kibnal_data.kib_pd, - vaddr, nob, - access, - &tx->tx_md.md_handle.mr, - &tx->tx_md.md_lkey, - &tx->tx_md.md_rkey); - - if (rc != 0) { - CERROR ("Can't map vaddr: %d\n", rc); - return (rc); - } - - tx->tx_mapped = KIB_TX_MAPPED; - return (0); -} - -int -kibnal_map_kiov (kib_tx_t *tx, enum ib_memory_access access, - int nkiov, ptl_kiov_t *kiov, - int offset, int nob) -{ -#if IBNAL_FMR - __u64 *phys; - const int mapped = KIB_TX_MAPPED_FMR; -#else - struct ib_physical_buffer *phys; - const int mapped = KIB_TX_MAPPED; -#endif - int page_offset; - int nphys; - int resid; - int phys_size; - int rc; - - CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob); - - LASSERT (nob > 0); - LASSERT (nkiov > 0); - LASSERT (tx->tx_mapped == KIB_TX_UNMAPPED); - - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; - nkiov--; - kiov++; - LASSERT (nkiov > 0); - } - - phys_size = nkiov * sizeof (*phys); - PORTAL_ALLOC(phys, phys_size); - if (phys == NULL) { - CERROR ("Can't allocate tmp phys\n"); - return (-ENOMEM); - } - - page_offset = kiov->kiov_offset + offset; -#if IBNAL_FMR - phys[0] = kibnal_page2phys(kiov->kiov_page); -#else - phys[0].address = kibnal_page2phys(kiov->kiov_page); - phys[0].size = PAGE_SIZE; -#endif - nphys = 1; - resid = nob - (kiov->kiov_len - offset); - - while (resid > 0) { - kiov++; - nkiov--; - LASSERT (nkiov > 0); - - if (kiov->kiov_offset != 0 || - ((resid > PAGE_SIZE) && - kiov->kiov_len < PAGE_SIZE)) { - int i; - /* Can't have gaps */ - CERROR ("Can't make payload contiguous in I/O VM:" - "page %d, offset %d, len %d \n", nphys, - kiov->kiov_offset, kiov->kiov_len); - - for (i = -nphys; i < nkiov; i++) - { - CERROR("kiov[%d] %p +%d for %d\n", - i, kiov[i].kiov_page, kiov[i].kiov_offset, kiov[i].kiov_len); - } - - rc = -EINVAL; - goto out; - } - - if (nphys == PTL_MD_MAX_IOV) { - CERROR ("payload too big (%d)\n", nphys); - rc = -EMSGSIZE; - goto out; - } - - LASSERT (nphys * sizeof (*phys) < phys_size); -#if IBNAL_FMR - phys[nphys] = kibnal_page2phys(kiov->kiov_page); -#else - phys[nphys].address = kibnal_page2phys(kiov->kiov_page); - phys[nphys].size = PAGE_SIZE; -#endif - nphys++; - - resid -= PAGE_SIZE; - } - -#if 0 - CWARN ("nphys %d, nob %d, page_offset %d\n", nphys, nob, page_offset); - for (rc = 0; rc < nphys; rc++) - CWARN (" [%d] "LPX64" / %d\n", rc, phys[rc].address, phys[rc].size); -#endif - tx->tx_md.md_addr = IBNAL_RDMA_BASE; - -#if IBNAL_FMR - rc = ib_fmr_register_physical (kibnal_data.kib_fmr_pool, - phys, nphys, - &tx->tx_md.md_addr, - page_offset, - &tx->tx_md.md_handle.fmr, - &tx->tx_md.md_lkey, - &tx->tx_md.md_rkey); -#else - rc = ib_memory_register_physical (kibnal_data.kib_pd, - phys, nphys, - &tx->tx_md.md_addr, - nob, page_offset, - access, - &tx->tx_md.md_handle.mr, - &tx->tx_md.md_lkey, - &tx->tx_md.md_rkey); -#endif - if (rc == 0) { - CDEBUG(D_NET, "Mapped %d pages %d bytes @ offset %d: lkey %x, rkey %x\n", - nphys, nob, page_offset, tx->tx_md.md_lkey, tx->tx_md.md_rkey); - tx->tx_mapped = mapped; - } else { - CERROR ("Can't map phys: %d\n", rc); - rc = -EFAULT; - } - - out: - PORTAL_FREE(phys, phys_size); - return (rc); -} - -kib_conn_t * -kibnal_find_conn_locked (kib_peer_t *peer) -{ - struct list_head *tmp; - - /* just return the first connection */ - list_for_each (tmp, &peer->ibp_conns) { - return (list_entry(tmp, kib_conn_t, ibc_list)); - } - - return (NULL); -} - -void -kibnal_check_sends (kib_conn_t *conn) -{ - unsigned long flags; - kib_tx_t *tx; - int rc; - int i; - int done; - int nwork; - - spin_lock_irqsave (&conn->ibc_lock, flags); - - LASSERT (conn->ibc_nsends_posted <= IBNAL_MSG_QUEUE_SIZE); - - if (list_empty(&conn->ibc_tx_queue) && - conn->ibc_outstanding_credits >= IBNAL_CREDIT_HIGHWATER) { - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - tx = kibnal_get_idle_tx(0); /* don't block */ - if (tx != NULL) - kibnal_init_tx_msg(tx, IBNAL_MSG_NOOP, 0); - - spin_lock_irqsave(&conn->ibc_lock, flags); - - if (tx != NULL) { - atomic_inc(&conn->ibc_refcount); - kibnal_queue_tx_locked(tx, conn); - } - } - - while (!list_empty (&conn->ibc_tx_queue)) { - tx = list_entry (conn->ibc_tx_queue.next, kib_tx_t, tx_list); - - /* We rely on this for QP sizing */ - LASSERT (tx->tx_nsp > 0 && tx->tx_nsp <= 2); - - LASSERT (conn->ibc_outstanding_credits >= 0); - LASSERT (conn->ibc_outstanding_credits <= IBNAL_MSG_QUEUE_SIZE); - LASSERT (conn->ibc_credits >= 0); - LASSERT (conn->ibc_credits <= IBNAL_MSG_QUEUE_SIZE); - - /* Not on ibc_rdma_queue */ - LASSERT (!tx->tx_passive_rdma_wait); - - if (conn->ibc_nsends_posted == IBNAL_MSG_QUEUE_SIZE) - break; - - if (conn->ibc_credits == 0) /* no credits */ - break; - - if (conn->ibc_credits == 1 && /* last credit reserved for */ - conn->ibc_outstanding_credits == 0) /* giving back credits */ - break; - - list_del (&tx->tx_list); - - if (tx->tx_msg->ibm_type == IBNAL_MSG_NOOP && - (!list_empty(&conn->ibc_tx_queue) || - conn->ibc_outstanding_credits < IBNAL_CREDIT_HIGHWATER)) { - /* redundant NOOP */ - spin_unlock_irqrestore(&conn->ibc_lock, flags); - kibnal_tx_done(tx); - spin_lock_irqsave(&conn->ibc_lock, flags); - continue; - } - - tx->tx_msg->ibm_credits = conn->ibc_outstanding_credits; - conn->ibc_outstanding_credits = 0; - - conn->ibc_nsends_posted++; - conn->ibc_credits--; - - tx->tx_sending = tx->tx_nsp; - tx->tx_passive_rdma_wait = tx->tx_passive_rdma; - list_add (&tx->tx_list, &conn->ibc_active_txs); -#if IBNAL_CKSUM - tx->tx_msg->ibm_cksum = 0; - tx->tx_msg->ibm_cksum = kibnal_cksum(tx->tx_msg, tx->tx_msg->ibm_nob); - CDEBUG(D_NET, "cksum %x, nob %d\n", tx->tx_msg->ibm_cksum, tx->tx_msg->ibm_nob); -#endif - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - /* NB the gap between removing tx from the queue and sending it - * allows message re-ordering to occur */ - - LASSERT (tx->tx_nsp > 0); - - rc = -ECONNABORTED; - nwork = 0; - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) { - tx->tx_status = 0; - /* Driver only accepts 1 item at a time */ - for (i = 0; i < tx->tx_nsp; i++) { - rc = ib_send (conn->ibc_qp, &tx->tx_sp[i], 1); - if (rc != 0) - break; - nwork++; - } - } - - spin_lock_irqsave (&conn->ibc_lock, flags); - if (rc != 0) { - /* NB credits are transferred in the actual - * message, which can only be the last work item */ - conn->ibc_outstanding_credits += tx->tx_msg->ibm_credits; - conn->ibc_credits++; - conn->ibc_nsends_posted--; - - tx->tx_status = rc; - tx->tx_passive_rdma_wait = 0; - tx->tx_sending -= tx->tx_nsp - nwork; - - done = (tx->tx_sending == 0); - if (done) - list_del (&tx->tx_list); - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) - CERROR ("Error %d posting transmit to "LPX64"\n", - rc, conn->ibc_peer->ibp_nid); - else - CDEBUG (D_NET, "Error %d posting transmit to " - LPX64"\n", rc, conn->ibc_peer->ibp_nid); - - kibnal_close_conn (conn, rc); - - if (done) - kibnal_tx_done (tx); - return; - } - - } - - spin_unlock_irqrestore (&conn->ibc_lock, flags); -} - -void -kibnal_tx_callback (struct ib_cq_entry *e) -{ - kib_tx_t *tx = (kib_tx_t *)kibnal_wreqid2ptr(e->work_request_id); - kib_conn_t *conn; - unsigned long flags; - int idle; - - conn = tx->tx_conn; - LASSERT (conn != NULL); - LASSERT (tx->tx_sending != 0); - - spin_lock_irqsave(&conn->ibc_lock, flags); - - CDEBUG(D_NET, "conn %p tx %p [%d/%d]: %d\n", conn, tx, - tx->tx_nsp - tx->tx_sending, tx->tx_nsp, - e->status); - - /* I could be racing with rdma completion. Whoever makes 'tx' idle - * gets to free it, which also drops its ref on 'conn'. If it's - * not me, then I take an extra ref on conn so it can't disappear - * under me. */ - - tx->tx_sending--; - idle = (tx->tx_sending == 0) && /* This is the final callback */ - (!tx->tx_passive_rdma_wait); /* Not waiting for RDMA completion */ - if (idle) - list_del(&tx->tx_list); - - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - - if (tx->tx_sending == 0) - conn->ibc_nsends_posted--; - - if (e->status != IB_COMPLETION_STATUS_SUCCESS && - tx->tx_status == 0) - tx->tx_status = -ECONNABORTED; - - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - if (idle) - kibnal_tx_done (tx); - - if (e->status != IB_COMPLETION_STATUS_SUCCESS) { - CERROR ("Tx completion to "LPX64" failed: %d\n", - conn->ibc_peer->ibp_nid, e->status); - kibnal_close_conn (conn, -ENETDOWN); - } else { - /* can I shovel some more sends out the door? */ - kibnal_check_sends(conn); - } - - kibnal_put_conn (conn); -} - -void -kibnal_callback (struct ib_cq *cq, struct ib_cq_entry *e, void *arg) -{ - if (kibnal_wreqid_is_rx(e->work_request_id)) - kibnal_rx_callback (e); - else - kibnal_tx_callback (e); -} - -void -kibnal_init_tx_msg (kib_tx_t *tx, int type, int body_nob) -{ - struct ib_gather_scatter *gl = &tx->tx_gl[tx->tx_nsp]; - struct ib_send_param *sp = &tx->tx_sp[tx->tx_nsp]; - int fence; - int nob = offsetof (kib_msg_t, ibm_u) + body_nob; - - LASSERT (tx->tx_nsp >= 0 && - tx->tx_nsp < sizeof(tx->tx_sp)/sizeof(tx->tx_sp[0])); - LASSERT (nob <= IBNAL_MSG_SIZE); - - tx->tx_msg->ibm_magic = IBNAL_MSG_MAGIC; - tx->tx_msg->ibm_version = IBNAL_MSG_VERSION; - tx->tx_msg->ibm_type = type; -#if IBNAL_CKSUM - tx->tx_msg->ibm_nob = nob; -#endif - /* Fence the message if it's bundled with an RDMA read */ - fence = (tx->tx_nsp > 0) && - (type == IBNAL_MSG_PUT_DONE); - - *gl = (struct ib_gather_scatter) { - .address = tx->tx_vaddr, - .length = nob, - .key = kibnal_data.kib_tx_pages->ibp_lkey, - }; - - /* NB If this is an RDMA read, the completion message must wait for - * the RDMA to complete. Sends wait for previous RDMA writes - * anyway... */ - *sp = (struct ib_send_param) { - .work_request_id = kibnal_ptr2wreqid(tx, 0), - .op = IB_OP_SEND, - .gather_list = gl, - .num_gather_entries = 1, - .device_specific = NULL, - .solicited_event = 1, - .signaled = 1, - .immediate_data_valid = 0, - .fence = fence, - .inline_data = 0, - }; - - tx->tx_nsp++; -} - -void -kibnal_queue_tx (kib_tx_t *tx, kib_conn_t *conn) -{ - unsigned long flags; - - spin_lock_irqsave(&conn->ibc_lock, flags); - - kibnal_queue_tx_locked (tx, conn); - - spin_unlock_irqrestore(&conn->ibc_lock, flags); - - kibnal_check_sends(conn); -} - -void -kibnal_launch_tx (kib_tx_t *tx, ptl_nid_t nid) -{ - unsigned long flags; - kib_peer_t *peer; - kib_conn_t *conn; - rwlock_t *g_lock = &kibnal_data.kib_global_lock; - - /* If I get here, I've committed to send, so I complete the tx with - * failure on any problems */ - - LASSERT (tx->tx_conn == NULL); /* only set when assigned a conn */ - LASSERT (tx->tx_nsp > 0); /* work items have been set up */ - - read_lock (g_lock); - - peer = kibnal_find_peer_locked (nid); - if (peer == NULL) { - read_unlock (g_lock); - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - return; - } - - conn = kibnal_find_conn_locked (peer); - if (conn != NULL) { - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); /* 1 ref for the tx */ - read_unlock (g_lock); - - kibnal_queue_tx (tx, conn); - return; - } - - /* Making one or more connections; I'll need a write lock... */ - read_unlock (g_lock); - write_lock_irqsave (g_lock, flags); - - peer = kibnal_find_peer_locked (nid); - if (peer == NULL) { - write_unlock_irqrestore (g_lock, flags); - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - return; - } - - conn = kibnal_find_conn_locked (peer); - if (conn != NULL) { - /* Connection exists; queue message on it */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); /* 1 ref for the tx */ - write_unlock_irqrestore (g_lock, flags); - - kibnal_queue_tx (tx, conn); - return; - } - - if (peer->ibp_connecting == 0) { - if (!time_after_eq(jiffies, peer->ibp_reconnect_time)) { - write_unlock_irqrestore (g_lock, flags); - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - return; - } - - peer->ibp_connecting = 1; - atomic_inc (&peer->ibp_refcount); /* extra ref for connd */ - - spin_lock (&kibnal_data.kib_connd_lock); - - list_add_tail (&peer->ibp_connd_list, - &kibnal_data.kib_connd_peers); - wake_up (&kibnal_data.kib_connd_waitq); - - spin_unlock (&kibnal_data.kib_connd_lock); - } - - /* A connection is being established; queue the message... */ - list_add_tail (&tx->tx_list, &peer->ibp_tx_queue); - - write_unlock_irqrestore (g_lock, flags); -} - -ptl_err_t -kibnal_start_passive_rdma (int type, ptl_nid_t nid, - lib_msg_t *libmsg, ptl_hdr_t *hdr) -{ - int nob = libmsg->md->length; - kib_tx_t *tx; - kib_msg_t *ibmsg; - int rc; - int access; - - LASSERT (type == IBNAL_MSG_PUT_RDMA || - type == IBNAL_MSG_GET_RDMA); - LASSERT (nob > 0); - LASSERT (!in_interrupt()); /* Mapping could block */ - - if (type == IBNAL_MSG_PUT_RDMA) { - access = IB_ACCESS_REMOTE_READ; - } else { - access = IB_ACCESS_REMOTE_WRITE | - IB_ACCESS_LOCAL_WRITE; - } - - tx = kibnal_get_idle_tx (1); /* May block; caller is an app thread */ - LASSERT (tx != NULL); - - if ((libmsg->md->options & PTL_MD_KIOV) == 0) - rc = kibnal_map_iov (tx, access, - libmsg->md->md_niov, - libmsg->md->md_iov.iov, - 0, nob); - else - rc = kibnal_map_kiov (tx, access, - libmsg->md->md_niov, - libmsg->md->md_iov.kiov, - 0, nob); - - if (rc != 0) { - CERROR ("Can't map RDMA for "LPX64": %d\n", nid, rc); - goto failed; - } - - if (type == IBNAL_MSG_GET_RDMA) { - /* reply gets finalized when tx completes */ - tx->tx_libmsg[1] = lib_create_reply_msg(&kibnal_lib, - nid, libmsg); - if (tx->tx_libmsg[1] == NULL) { - CERROR ("Can't create reply for GET -> "LPX64"\n", - nid); - rc = -ENOMEM; - goto failed; - } - } - - tx->tx_passive_rdma = 1; - - ibmsg = tx->tx_msg; - - ibmsg->ibm_u.rdma.ibrm_hdr = *hdr; - ibmsg->ibm_u.rdma.ibrm_cookie = tx->tx_passive_rdma_cookie; - ibmsg->ibm_u.rdma.ibrm_desc.rd_key = tx->tx_md.md_rkey; - ibmsg->ibm_u.rdma.ibrm_desc.rd_addr = tx->tx_md.md_addr; - ibmsg->ibm_u.rdma.ibrm_desc.rd_nob = nob; - - kibnal_init_tx_msg (tx, type, sizeof (kib_rdma_msg_t)); - - CDEBUG(D_NET, "Passive: %p cookie "LPX64", key %x, addr " - LPX64", nob %d\n", - tx, tx->tx_passive_rdma_cookie, tx->tx_md.md_rkey, - tx->tx_md.md_addr, nob); - - /* libmsg gets finalized when tx completes. */ - tx->tx_libmsg[0] = libmsg; - - kibnal_launch_tx(tx, nid); - return (PTL_OK); - - failed: - tx->tx_status = rc; - kibnal_tx_done (tx); - return (PTL_FAIL); -} - -void -kibnal_start_active_rdma (int type, int status, - kib_rx_t *rx, lib_msg_t *libmsg, - unsigned int niov, - struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t nob) -{ - kib_msg_t *rxmsg = rx->rx_msg; - kib_msg_t *txmsg; - kib_tx_t *tx; - int access; - int rdma_op; - int rc; - - CDEBUG(D_NET, "type %d, status %d, niov %d, offset %d, nob %d\n", - type, status, niov, offset, nob); - - /* Called by scheduler */ - LASSERT (!in_interrupt ()); - - /* Either all pages or all vaddrs */ - LASSERT (!(kiov != NULL && iov != NULL)); - - /* No data if we're completing with failure */ - LASSERT (status == 0 || nob == 0); - - LASSERT (type == IBNAL_MSG_GET_DONE || - type == IBNAL_MSG_PUT_DONE); - - /* Flag I'm completing the RDMA. Even if I fail to send the - * completion message, I will have tried my best so further - * attempts shouldn't be tried. */ - LASSERT (!rx->rx_rdma); - rx->rx_rdma = 1; - - if (type == IBNAL_MSG_GET_DONE) { - access = 0; - rdma_op = IB_OP_RDMA_WRITE; - LASSERT (rxmsg->ibm_type == IBNAL_MSG_GET_RDMA); - } else { - access = IB_ACCESS_LOCAL_WRITE; - rdma_op = IB_OP_RDMA_READ; - LASSERT (rxmsg->ibm_type == IBNAL_MSG_PUT_RDMA); - } - - tx = kibnal_get_idle_tx (0); /* Mustn't block */ - if (tx == NULL) { - CERROR ("tx descs exhausted on RDMA from "LPX64 - " completing locally with failure\n", - rx->rx_conn->ibc_peer->ibp_nid); - lib_finalize (&kibnal_lib, NULL, libmsg, PTL_NO_SPACE); - return; - } - LASSERT (tx->tx_nsp == 0); - - if (nob != 0) { - /* We actually need to transfer some data (the transfer - * size could get truncated to zero when the incoming - * message is matched) */ - - if (kiov != NULL) - rc = kibnal_map_kiov (tx, access, - niov, kiov, offset, nob); - else - rc = kibnal_map_iov (tx, access, - niov, iov, offset, nob); - - if (rc != 0) { - CERROR ("Can't map RDMA -> "LPX64": %d\n", - rx->rx_conn->ibc_peer->ibp_nid, rc); - /* We'll skip the RDMA and complete with failure. */ - status = rc; - nob = 0; - } else { - tx->tx_gl[0] = (struct ib_gather_scatter) { - .address = tx->tx_md.md_addr, - .length = nob, - .key = tx->tx_md.md_lkey, - }; - - tx->tx_sp[0] = (struct ib_send_param) { - .work_request_id = kibnal_ptr2wreqid(tx, 0), - .op = rdma_op, - .gather_list = &tx->tx_gl[0], - .num_gather_entries = 1, - .remote_address = rxmsg->ibm_u.rdma.ibrm_desc.rd_addr, - .rkey = rxmsg->ibm_u.rdma.ibrm_desc.rd_key, - .device_specific = NULL, - .solicited_event = 0, - .signaled = 1, - .immediate_data_valid = 0, - .fence = 0, - .inline_data = 0, - }; - - tx->tx_nsp = 1; - } - } - - txmsg = tx->tx_msg; - - txmsg->ibm_u.completion.ibcm_cookie = rxmsg->ibm_u.rdma.ibrm_cookie; - txmsg->ibm_u.completion.ibcm_status = status; - - kibnal_init_tx_msg(tx, type, sizeof (kib_completion_msg_t)); - - if (status == 0 && nob != 0) { - LASSERT (tx->tx_nsp > 1); - /* RDMA: libmsg gets finalized when the tx completes. This - * is after the completion message has been sent, which in - * turn is after the RDMA has finished. */ - tx->tx_libmsg[0] = libmsg; - } else { - LASSERT (tx->tx_nsp == 1); - /* No RDMA: local completion happens now! */ - CDEBUG(D_WARNING,"No data: immediate completion\n"); - lib_finalize (&kibnal_lib, NULL, libmsg, - status == 0 ? PTL_OK : PTL_FAIL); - } - - /* +1 ref for this tx... */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - rx->rx_conn, rx->rx_conn->ibc_state, - rx->rx_conn->ibc_peer->ibp_nid, - atomic_read (&rx->rx_conn->ibc_refcount)); - atomic_inc (&rx->rx_conn->ibc_refcount); - /* ...and queue it up */ - kibnal_queue_tx(tx, rx->rx_conn); -} - -ptl_err_t -kibnal_sendmsg(lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - struct iovec *payload_iov, - ptl_kiov_t *payload_kiov, - size_t payload_offset, - size_t payload_nob) -{ - kib_msg_t *ibmsg; - kib_tx_t *tx; - int nob; - - /* NB 'private' is different depending on what we're sending.... */ - - CDEBUG(D_NET, "sending "LPSZ" bytes in %d frags to nid:"LPX64 - " pid %d\n", payload_nob, payload_niov, nid , pid); - - LASSERT (payload_nob == 0 || payload_niov > 0); - LASSERT (payload_niov <= PTL_MD_MAX_IOV); - - /* Thread context if we're sending payload */ - LASSERT (!in_interrupt() || payload_niov == 0); - /* payload is either all vaddrs or all pages */ - LASSERT (!(payload_kiov != NULL && payload_iov != NULL)); - - switch (type) { - default: - LBUG(); - return (PTL_FAIL); - - case PTL_MSG_REPLY: { - /* reply's 'private' is the incoming receive */ - kib_rx_t *rx = private; - - /* RDMA reply expected? */ - if (rx->rx_msg->ibm_type == IBNAL_MSG_GET_RDMA) { - kibnal_start_active_rdma(IBNAL_MSG_GET_DONE, 0, - rx, libmsg, payload_niov, - payload_iov, payload_kiov, - payload_offset, payload_nob); - return (PTL_OK); - } - - /* Incoming message consistent with immediate reply? */ - if (rx->rx_msg->ibm_type != IBNAL_MSG_IMMEDIATE) { - CERROR ("REPLY to "LPX64" bad opbm type %d!!!\n", - nid, rx->rx_msg->ibm_type); - return (PTL_FAIL); - } - - /* Will it fit in a message? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob]); - if (nob >= IBNAL_MSG_SIZE) { - CERROR("REPLY for "LPX64" too big (RDMA not requested): %d\n", - nid, payload_nob); - return (PTL_FAIL); - } - break; - } - - case PTL_MSG_GET: - /* might the REPLY message be big enough to need RDMA? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[libmsg->md->length]); - if (nob > IBNAL_MSG_SIZE) - return (kibnal_start_passive_rdma(IBNAL_MSG_GET_RDMA, - nid, libmsg, hdr)); - break; - - case PTL_MSG_ACK: - LASSERT (payload_nob == 0); - break; - - case PTL_MSG_PUT: - /* Is the payload big enough to need RDMA? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob]); - if (nob > IBNAL_MSG_SIZE) - return (kibnal_start_passive_rdma(IBNAL_MSG_PUT_RDMA, - nid, libmsg, hdr)); - - break; - } - - tx = kibnal_get_idle_tx(!(type == PTL_MSG_ACK || - type == PTL_MSG_REPLY || - in_interrupt())); - if (tx == NULL) { - CERROR ("Can't send %d to "LPX64": tx descs exhausted%s\n", - type, nid, in_interrupt() ? " (intr)" : ""); - return (PTL_NO_SPACE); - } - - ibmsg = tx->tx_msg; - ibmsg->ibm_u.immediate.ibim_hdr = *hdr; - - if (payload_nob > 0) { - if (payload_kiov != NULL) - lib_copy_kiov2buf(ibmsg->ibm_u.immediate.ibim_payload, - payload_niov, payload_kiov, - payload_offset, payload_nob); - else - lib_copy_iov2buf(ibmsg->ibm_u.immediate.ibim_payload, - payload_niov, payload_iov, - payload_offset, payload_nob); - } - - kibnal_init_tx_msg (tx, IBNAL_MSG_IMMEDIATE, - offsetof(kib_immediate_msg_t, - ibim_payload[payload_nob])); - - /* libmsg gets finalized when tx completes */ - tx->tx_libmsg[0] = libmsg; - - kibnal_launch_tx(tx, nid); - return (PTL_OK); -} - -ptl_err_t -kibnal_send (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, struct iovec *payload_iov, - size_t payload_offset, size_t payload_len) -{ - return (kibnal_sendmsg(nal, private, cookie, - hdr, type, nid, pid, - payload_niov, payload_iov, NULL, - payload_offset, payload_len)); -} - -ptl_err_t -kibnal_send_pages (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, ptl_kiov_t *payload_kiov, - size_t payload_offset, size_t payload_len) -{ - return (kibnal_sendmsg(nal, private, cookie, - hdr, type, nid, pid, - payload_niov, NULL, payload_kiov, - payload_offset, payload_len)); -} - -ptl_err_t -kibnal_recvmsg (lib_nal_t *nal, void *private, lib_msg_t *libmsg, - unsigned int niov, struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t mlen, size_t rlen) -{ - kib_rx_t *rx = private; - kib_msg_t *rxmsg = rx->rx_msg; - int msg_nob; - - LASSERT (mlen <= rlen); - LASSERT (!in_interrupt ()); - /* Either all pages or all vaddrs */ - LASSERT (!(kiov != NULL && iov != NULL)); - - switch (rxmsg->ibm_type) { - default: - LBUG(); - return (PTL_FAIL); - - case IBNAL_MSG_IMMEDIATE: - msg_nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[rlen]); - if (msg_nob > IBNAL_MSG_SIZE) { - CERROR ("Immediate message from "LPX64" too big: %d\n", - rxmsg->ibm_u.immediate.ibim_hdr.src_nid, rlen); - return (PTL_FAIL); - } - - if (kiov != NULL) - lib_copy_buf2kiov(niov, kiov, offset, - rxmsg->ibm_u.immediate.ibim_payload, - mlen); - else - lib_copy_buf2iov(niov, iov, offset, - rxmsg->ibm_u.immediate.ibim_payload, - mlen); - - lib_finalize (nal, NULL, libmsg, PTL_OK); - return (PTL_OK); - - case IBNAL_MSG_GET_RDMA: - /* We get called here just to discard any junk after the - * GET hdr. */ - LASSERT (libmsg == NULL); - lib_finalize (nal, NULL, libmsg, PTL_OK); - return (PTL_OK); - - case IBNAL_MSG_PUT_RDMA: - kibnal_start_active_rdma (IBNAL_MSG_PUT_DONE, 0, - rx, libmsg, - niov, iov, kiov, offset, mlen); - return (PTL_OK); - } -} - -ptl_err_t -kibnal_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, struct iovec *iov, - size_t offset, size_t mlen, size_t rlen) -{ - return (kibnal_recvmsg (nal, private, msg, niov, iov, NULL, - offset, mlen, rlen)); -} - -ptl_err_t -kibnal_recv_pages (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, ptl_kiov_t *kiov, - size_t offset, size_t mlen, size_t rlen) -{ - return (kibnal_recvmsg (nal, private, msg, niov, NULL, kiov, - offset, mlen, rlen)); -} - -int -kibnal_thread_start (int (*fn)(void *arg), void *arg) -{ - long pid = kernel_thread (fn, arg, 0); - - if (pid < 0) - return ((int)pid); - - atomic_inc (&kibnal_data.kib_nthreads); - return (0); -} - -void -kibnal_thread_fini (void) -{ - atomic_dec (&kibnal_data.kib_nthreads); -} - -void -kibnal_close_conn_locked (kib_conn_t *conn, int error) -{ - /* This just does the immmediate housekeeping, and schedules the - * connection for the connd to finish off. - * Caller holds kib_global_lock exclusively in irq context */ - kib_peer_t *peer = conn->ibc_peer; - - CDEBUG (error == 0 ? D_NET : D_ERROR, - "closing conn to "LPX64": error %d\n", peer->ibp_nid, error); - - LASSERT (conn->ibc_state == IBNAL_CONN_ESTABLISHED || - conn->ibc_state == IBNAL_CONN_CONNECTING); - - if (conn->ibc_state == IBNAL_CONN_ESTABLISHED) { - /* kib_connd_conns takes ibc_list's ref */ - list_del (&conn->ibc_list); - } else { - /* new ref for kib_connd_conns */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - } - - if (list_empty (&peer->ibp_conns) && - peer->ibp_persistence == 0) { - /* Non-persistent peer with no more conns... */ - kibnal_unlink_peer_locked (peer); - } - - conn->ibc_state = IBNAL_CONN_DEATHROW; - - /* Schedule conn for closing/destruction */ - spin_lock (&kibnal_data.kib_connd_lock); - - list_add_tail (&conn->ibc_list, &kibnal_data.kib_connd_conns); - wake_up (&kibnal_data.kib_connd_waitq); - - spin_unlock (&kibnal_data.kib_connd_lock); -} - -int -kibnal_close_conn (kib_conn_t *conn, int why) -{ - unsigned long flags; - int count = 0; - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - LASSERT (conn->ibc_state >= IBNAL_CONN_CONNECTING); - - if (conn->ibc_state <= IBNAL_CONN_ESTABLISHED) { - count = 1; - kibnal_close_conn_locked (conn, why); - } - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - return (count); -} - -void -kibnal_peer_connect_failed (kib_peer_t *peer, int active, int rc) -{ - LIST_HEAD (zombies); - kib_tx_t *tx; - unsigned long flags; - - LASSERT (rc != 0); - LASSERT (peer->ibp_reconnect_interval >= IBNAL_MIN_RECONNECT_INTERVAL); - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - LASSERT (peer->ibp_connecting != 0); - peer->ibp_connecting--; - - if (peer->ibp_connecting != 0) { - /* another connection attempt under way (loopback?)... */ - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - return; - } - - if (list_empty(&peer->ibp_conns)) { - /* Say when active connection can be re-attempted */ - peer->ibp_reconnect_time = jiffies + peer->ibp_reconnect_interval; - /* Increase reconnection interval */ - peer->ibp_reconnect_interval = MIN (peer->ibp_reconnect_interval * 2, - IBNAL_MAX_RECONNECT_INTERVAL); - - /* Take peer's blocked blocked transmits; I'll complete - * them with error */ - while (!list_empty (&peer->ibp_tx_queue)) { - tx = list_entry (peer->ibp_tx_queue.next, - kib_tx_t, tx_list); - - list_del (&tx->tx_list); - list_add_tail (&tx->tx_list, &zombies); - } - - if (kibnal_peer_active(peer) && - (peer->ibp_persistence == 0)) { - /* failed connection attempt on non-persistent peer */ - kibnal_unlink_peer_locked (peer); - } - } else { - /* Can't have blocked transmits if there are connections */ - LASSERT (list_empty(&peer->ibp_tx_queue)); - } - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - if (!list_empty (&zombies)) - CERROR ("Deleting messages for "LPX64": connection failed\n", - peer->ibp_nid); - - while (!list_empty (&zombies)) { - tx = list_entry (zombies.next, kib_tx_t, tx_list); - - list_del (&tx->tx_list); - /* complete now */ - tx->tx_status = -EHOSTUNREACH; - kibnal_tx_done (tx); - } -} - -void -kibnal_connreq_done (kib_conn_t *conn, int active, int status) -{ - int state = conn->ibc_state; - kib_peer_t *peer = conn->ibc_peer; - kib_tx_t *tx; - unsigned long flags; - int rc; - int i; - - /* passive connection has no connreq & vice versa */ - LASSERT (!active == !(conn->ibc_connreq != NULL)); - if (active) { - PORTAL_FREE (conn->ibc_connreq, sizeof (*conn->ibc_connreq)); - conn->ibc_connreq = NULL; - } - - if (state == IBNAL_CONN_CONNECTING) { - /* Install common (active/passive) callback for - * disconnect/idle notification if I got as far as getting - * a CM comm_id */ - rc = tsIbCmCallbackModify(conn->ibc_comm_id, - kibnal_conn_callback, conn); - LASSERT (rc == 0); - } - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - LASSERT (peer->ibp_connecting != 0); - - if (status == 0) { - /* connection established... */ - LASSERT (state == IBNAL_CONN_CONNECTING); - conn->ibc_state = IBNAL_CONN_ESTABLISHED; - - if (!kibnal_peer_active(peer)) { - /* ...but peer deleted meantime */ - status = -ECONNABORTED; - } - } else { - LASSERT (state == IBNAL_CONN_INIT_QP || - state == IBNAL_CONN_CONNECTING); - } - - if (status == 0) { - /* Everything worked! */ - - peer->ibp_connecting--; - - /* +1 ref for ibc_list; caller(== CM)'s ref remains until - * the IB_CM_IDLE callback */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - list_add (&conn->ibc_list, &peer->ibp_conns); - - /* reset reconnect interval for next attempt */ - peer->ibp_reconnect_interval = IBNAL_MIN_RECONNECT_INTERVAL; - - /* post blocked sends to the new connection */ - spin_lock (&conn->ibc_lock); - - while (!list_empty (&peer->ibp_tx_queue)) { - tx = list_entry (peer->ibp_tx_queue.next, - kib_tx_t, tx_list); - - list_del (&tx->tx_list); - - /* +1 ref for each tx */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - kibnal_queue_tx_locked (tx, conn); - } - - spin_unlock (&conn->ibc_lock); - - /* Nuke any dangling conns from a different peer instance... */ - kibnal_close_stale_conns_locked (conn->ibc_peer, - conn->ibc_incarnation); - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - /* queue up all the receives */ - for (i = 0; i < IBNAL_RX_MSGS; i++) { - /* +1 ref for rx desc */ - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_inc (&conn->ibc_refcount); - - CDEBUG(D_NET, "RX[%d] %p->%p - "LPX64"\n", - i, &conn->ibc_rxs[i], conn->ibc_rxs[i].rx_msg, - conn->ibc_rxs[i].rx_vaddr); - - kibnal_post_rx (&conn->ibc_rxs[i], 0); - } - - kibnal_check_sends (conn); - return; - } - - /* connection failed */ - if (state == IBNAL_CONN_CONNECTING) { - /* schedule for connd to close */ - kibnal_close_conn_locked (conn, status); - } else { - /* Don't have a CM comm_id; just wait for refs to drain */ - conn->ibc_state = IBNAL_CONN_ZOMBIE; - } - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - kibnal_peer_connect_failed (conn->ibc_peer, active, status); - - if (state != IBNAL_CONN_CONNECTING) { - /* drop caller's ref if we're not waiting for the - * IB_CM_IDLE callback */ - kibnal_put_conn (conn); - } -} - -int -kibnal_accept (kib_conn_t **connp, tTS_IB_CM_COMM_ID cid, - ptl_nid_t nid, __u64 incarnation, int queue_depth) -{ - kib_conn_t *conn = kibnal_create_conn(); - kib_peer_t *peer; - kib_peer_t *peer2; - unsigned long flags; - - if (conn == NULL) - return (-ENOMEM); - - if (queue_depth != IBNAL_MSG_QUEUE_SIZE) { - CERROR("Can't accept "LPX64": bad queue depth %d (%d expected)\n", - nid, queue_depth, IBNAL_MSG_QUEUE_SIZE); - return (-EPROTO); - } - - /* assume 'nid' is a new peer */ - peer = kibnal_create_peer (nid); - if (peer == NULL) { - CDEBUG(D_NET, "--conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, conn->ibc_peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - atomic_dec (&conn->ibc_refcount); - kibnal_destroy_conn(conn); - return (-ENOMEM); - } - - write_lock_irqsave (&kibnal_data.kib_global_lock, flags); - - peer2 = kibnal_find_peer_locked(nid); - if (peer2 == NULL) { - /* peer table takes my ref on peer */ - list_add_tail (&peer->ibp_list, - kibnal_nid2peerlist(nid)); - } else { - kibnal_put_peer (peer); - peer = peer2; - } - - /* +1 ref for conn */ - atomic_inc (&peer->ibp_refcount); - peer->ibp_connecting++; - - write_unlock_irqrestore (&kibnal_data.kib_global_lock, flags); - - conn->ibc_peer = peer; - conn->ibc_state = IBNAL_CONN_CONNECTING; - conn->ibc_comm_id = cid; - conn->ibc_incarnation = incarnation; - conn->ibc_credits = IBNAL_MSG_QUEUE_SIZE; - - *connp = conn; - return (0); -} - -tTS_IB_CM_CALLBACK_RETURN -kibnal_idle_conn_callback (tTS_IB_CM_EVENT event, - tTS_IB_CM_COMM_ID cid, - void *param, - void *arg) -{ - /* Shouldn't ever get a callback after TS_IB_CM_IDLE */ - CERROR ("Unexpected event %d: conn %p\n", event, arg); - LBUG (); - return TS_IB_CM_CALLBACK_PROCEED; -} - -tTS_IB_CM_CALLBACK_RETURN -kibnal_conn_callback (tTS_IB_CM_EVENT event, - tTS_IB_CM_COMM_ID cid, - void *param, - void *arg) -{ - kib_conn_t *conn = arg; - LIST_HEAD (zombies); - struct list_head *tmp; - struct list_head *nxt; - kib_tx_t *tx; - unsigned long flags; - int done; - int rc; - - /* Established Connection Notifier */ - - switch (event) { - default: - CERROR("Connection %p -> "LPX64" ERROR %d\n", - conn, conn->ibc_peer->ibp_nid, event); - kibnal_close_conn (conn, -ECONNABORTED); - break; - - case TS_IB_CM_DISCONNECTED: - CDEBUG(D_WARNING, "Connection %p -> "LPX64" DISCONNECTED.\n", - conn, conn->ibc_peer->ibp_nid); - kibnal_close_conn (conn, 0); - break; - - case TS_IB_CM_IDLE: - CDEBUG(D_NET, "Connection %p -> "LPX64" IDLE.\n", - conn, conn->ibc_peer->ibp_nid); - kibnal_put_conn (conn); /* Lose CM's ref */ - - /* LASSERT (no further callbacks) */ - rc = tsIbCmCallbackModify(cid, - kibnal_idle_conn_callback, conn); - LASSERT (rc == 0); - - /* NB we wait until the connection has closed before - * completing outstanding passive RDMAs so we can be sure - * the network can't touch the mapped memory any more. */ - - spin_lock_irqsave (&conn->ibc_lock, flags); - - /* grab passive RDMAs not waiting for the tx callback */ - list_for_each_safe (tmp, nxt, &conn->ibc_active_txs) { - tx = list_entry (tmp, kib_tx_t, tx_list); - - LASSERT (tx->tx_passive_rdma || - !tx->tx_passive_rdma_wait); - - LASSERT (tx->tx_passive_rdma_wait || - tx->tx_sending != 0); - - /* still waiting for tx callback? */ - if (!tx->tx_passive_rdma_wait) - continue; - - tx->tx_status = -ECONNABORTED; - tx->tx_passive_rdma_wait = 0; - done = (tx->tx_sending == 0); - - if (!done) - continue; - - list_del (&tx->tx_list); - list_add (&tx->tx_list, &zombies); - } - - /* grab all blocked transmits */ - list_for_each_safe (tmp, nxt, &conn->ibc_tx_queue) { - tx = list_entry (tmp, kib_tx_t, tx_list); - - list_del (&tx->tx_list); - list_add (&tx->tx_list, &zombies); - } - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - while (!list_empty(&zombies)) { - tx = list_entry (zombies.next, kib_tx_t, tx_list); - - list_del(&tx->tx_list); - kibnal_tx_done (tx); - } - break; - } - - return TS_IB_CM_CALLBACK_PROCEED; -} - -tTS_IB_CM_CALLBACK_RETURN -kibnal_passive_conn_callback (tTS_IB_CM_EVENT event, - tTS_IB_CM_COMM_ID cid, - void *param, - void *arg) -{ - kib_conn_t *conn = arg; - int rc; - - switch (event) { - default: - if (conn == NULL) { - /* no connection yet */ - CERROR ("Unexpected event: %d\n", event); - return TS_IB_CM_CALLBACK_ABORT; - } - - CERROR ("Unexpected event %p -> "LPX64": %d\n", - conn, conn->ibc_peer->ibp_nid, event); - kibnal_connreq_done (conn, 0, -ECONNABORTED); - break; - - case TS_IB_CM_REQ_RECEIVED: { - struct ib_cm_req_received_param *req = param; - kib_wire_connreq_t *wcr = req->remote_private_data; - - LASSERT (conn == NULL); - - CDEBUG(D_NET, "REQ from "LPX64"\n", le64_to_cpu(wcr->wcr_nid)); - - if (req->remote_private_data_len < sizeof (*wcr)) { - CERROR("Connect from remote LID %04x: too short %d\n", - req->dlid, req->remote_private_data_len); - return TS_IB_CM_CALLBACK_ABORT; - } - - if (wcr->wcr_magic != cpu_to_le32(IBNAL_MSG_MAGIC)) { - CERROR ("Can't accept LID %04x: bad magic %08x\n", - req->dlid, le32_to_cpu(wcr->wcr_magic)); - return TS_IB_CM_CALLBACK_ABORT; - } - - if (wcr->wcr_version != cpu_to_le16(IBNAL_MSG_VERSION)) { - CERROR ("Can't accept LID %04x: bad version %d\n", - req->dlid, le16_to_cpu(wcr->wcr_magic)); - return TS_IB_CM_CALLBACK_ABORT; - } - - rc = kibnal_accept(&conn, - cid, - le64_to_cpu(wcr->wcr_nid), - le64_to_cpu(wcr->wcr_incarnation), - le16_to_cpu(wcr->wcr_queue_depth)); - if (rc != 0) { - CERROR ("Can't accept "LPX64": %d\n", - le64_to_cpu(wcr->wcr_nid), rc); - return TS_IB_CM_CALLBACK_ABORT; - } - - /* update 'arg' for next callback */ - rc = tsIbCmCallbackModify(cid, - kibnal_passive_conn_callback, conn); - LASSERT (rc == 0); - - req->accept_param.qp = conn->ibc_qp; - *((kib_wire_connreq_t *)req->accept_param.reply_private_data) - = (kib_wire_connreq_t) { - .wcr_magic = cpu_to_le32(IBNAL_MSG_MAGIC), - .wcr_version = cpu_to_le16(IBNAL_MSG_VERSION), - .wcr_queue_depth = cpu_to_le32(IBNAL_MSG_QUEUE_SIZE), - .wcr_nid = cpu_to_le64(kibnal_data.kib_nid), - .wcr_incarnation = cpu_to_le64(kibnal_data.kib_incarnation), - }; - req->accept_param.reply_private_data_len = sizeof(kib_wire_connreq_t); - req->accept_param.responder_resources = IBNAL_RESPONDER_RESOURCES; - req->accept_param.initiator_depth = IBNAL_RESPONDER_RESOURCES; - req->accept_param.rnr_retry_count = IBNAL_RNR_RETRY; - req->accept_param.flow_control = IBNAL_FLOW_CONTROL; - - CDEBUG(D_NET, "Proceeding\n"); - break; - } - - case TS_IB_CM_ESTABLISHED: - LASSERT (conn != NULL); - CDEBUG(D_WARNING, "Connection %p -> "LPX64" ESTABLISHED.\n", - conn, conn->ibc_peer->ibp_nid); - - kibnal_connreq_done (conn, 0, 0); - break; - } - - /* NB if the connreq is done, we switch to kibnal_conn_callback */ - return TS_IB_CM_CALLBACK_PROCEED; -} - -tTS_IB_CM_CALLBACK_RETURN -kibnal_active_conn_callback (tTS_IB_CM_EVENT event, - tTS_IB_CM_COMM_ID cid, - void *param, - void *arg) -{ - kib_conn_t *conn = arg; - - switch (event) { - case TS_IB_CM_REP_RECEIVED: { - struct ib_cm_rep_received_param *rep = param; - kib_wire_connreq_t *wcr = rep->remote_private_data; - - if (rep->remote_private_data_len < sizeof (*wcr)) { - CERROR ("Short reply from "LPX64": %d\n", - conn->ibc_peer->ibp_nid, - rep->remote_private_data_len); - kibnal_connreq_done (conn, 1, -EPROTO); - break; - } - - if (wcr->wcr_magic != cpu_to_le32(IBNAL_MSG_MAGIC)) { - CERROR ("Can't connect "LPX64": bad magic %08x\n", - conn->ibc_peer->ibp_nid, le32_to_cpu(wcr->wcr_magic)); - kibnal_connreq_done (conn, 1, -EPROTO); - break; - } - - if (wcr->wcr_version != cpu_to_le16(IBNAL_MSG_VERSION)) { - CERROR ("Can't connect "LPX64": bad version %d\n", - conn->ibc_peer->ibp_nid, le16_to_cpu(wcr->wcr_magic)); - kibnal_connreq_done (conn, 1, -EPROTO); - break; - } - - if (wcr->wcr_queue_depth != cpu_to_le16(IBNAL_MSG_QUEUE_SIZE)) { - CERROR ("Can't connect "LPX64": bad queue depth %d\n", - conn->ibc_peer->ibp_nid, le16_to_cpu(wcr->wcr_queue_depth)); - kibnal_connreq_done (conn, 1, -EPROTO); - break; - } - - if (le64_to_cpu(wcr->wcr_nid) != conn->ibc_peer->ibp_nid) { - CERROR ("Unexpected NID "LPX64" from "LPX64"\n", - le64_to_cpu(wcr->wcr_nid), conn->ibc_peer->ibp_nid); - kibnal_connreq_done (conn, 1, -EPROTO); - break; - } - - CDEBUG(D_NET, "Connection %p -> "LPX64" REP_RECEIVED.\n", - conn, conn->ibc_peer->ibp_nid); - - conn->ibc_incarnation = le64_to_cpu(wcr->wcr_incarnation); - conn->ibc_credits = IBNAL_MSG_QUEUE_SIZE; - break; - } - - case TS_IB_CM_ESTABLISHED: - CDEBUG(D_WARNING, "Connection %p -> "LPX64" Established\n", - conn, conn->ibc_peer->ibp_nid); - - kibnal_connreq_done (conn, 1, 0); - break; - - case TS_IB_CM_IDLE: - CERROR("Connection %p -> "LPX64" IDLE\n", - conn, conn->ibc_peer->ibp_nid); - /* Back out state change: I'm disengaged from CM */ - conn->ibc_state = IBNAL_CONN_INIT_QP; - - kibnal_connreq_done (conn, 1, -ECONNABORTED); - break; - - default: - CERROR("Connection %p -> "LPX64" ERROR %d\n", - conn, conn->ibc_peer->ibp_nid, event); - kibnal_connreq_done (conn, 1, -ECONNABORTED); - break; - } - - /* NB if the connreq is done, we switch to kibnal_conn_callback */ - return TS_IB_CM_CALLBACK_PROCEED; -} - -int -kibnal_pathreq_callback (tTS_IB_CLIENT_QUERY_TID tid, int status, - struct ib_path_record *resp, int remaining, - void *arg) -{ - kib_conn_t *conn = arg; - - if (status != 0) { - CERROR ("status %d\n", status); - kibnal_connreq_done (conn, 1, status); - goto out; - } - - conn->ibc_connreq->cr_path = *resp; - - conn->ibc_connreq->cr_wcr = (kib_wire_connreq_t) { - .wcr_magic = cpu_to_le32(IBNAL_MSG_MAGIC), - .wcr_version = cpu_to_le16(IBNAL_MSG_VERSION), - .wcr_queue_depth = cpu_to_le16(IBNAL_MSG_QUEUE_SIZE), - .wcr_nid = cpu_to_le64(kibnal_data.kib_nid), - .wcr_incarnation = cpu_to_le64(kibnal_data.kib_incarnation), - }; - - conn->ibc_connreq->cr_connparam = (struct ib_cm_active_param) { - .qp = conn->ibc_qp, - .req_private_data = &conn->ibc_connreq->cr_wcr, - .req_private_data_len = sizeof(conn->ibc_connreq->cr_wcr), - .responder_resources = IBNAL_RESPONDER_RESOURCES, - .initiator_depth = IBNAL_RESPONDER_RESOURCES, - .retry_count = IBNAL_RETRY, - .rnr_retry_count = IBNAL_RNR_RETRY, - .cm_response_timeout = kibnal_tunables.kib_io_timeout, - .max_cm_retries = IBNAL_CM_RETRY, - .flow_control = IBNAL_FLOW_CONTROL, - }; - - /* XXX set timeout just like SDP!!!*/ - conn->ibc_connreq->cr_path.packet_life = 13; - - /* Flag I'm getting involved with the CM... */ - conn->ibc_state = IBNAL_CONN_CONNECTING; - - CDEBUG(D_NET, "Connecting to, service id "LPX64", on "LPX64"\n", - conn->ibc_connreq->cr_service.service_id, - *kibnal_service_nid_field(&conn->ibc_connreq->cr_service)); - - /* kibnal_connect_callback gets my conn ref */ - status = ib_cm_connect (&conn->ibc_connreq->cr_connparam, - &conn->ibc_connreq->cr_path, NULL, - conn->ibc_connreq->cr_service.service_id, 0, - kibnal_active_conn_callback, conn, - &conn->ibc_comm_id); - if (status != 0) { - CERROR ("Connect: %d\n", status); - /* Back out state change: I've not got a CM comm_id yet... */ - conn->ibc_state = IBNAL_CONN_INIT_QP; - kibnal_connreq_done (conn, 1, status); - } - - out: - /* return non-zero to prevent further callbacks */ - return 1; -} - -void -kibnal_service_get_callback (tTS_IB_CLIENT_QUERY_TID tid, int status, - struct ib_common_attrib_service *resp, void *arg) -{ - kib_conn_t *conn = arg; - - if (status != 0) { - CERROR ("status %d\n", status); - kibnal_connreq_done (conn, 1, status); - return; - } - - CDEBUG(D_NET, "Got status %d, service id "LPX64", on "LPX64"\n", - status, resp->service_id, - *kibnal_service_nid_field(resp)); - - conn->ibc_connreq->cr_service = *resp; - - status = ib_cached_gid_get(kibnal_data.kib_device, - kibnal_data.kib_port, 0, - conn->ibc_connreq->cr_gid); - LASSERT (status == 0); - - /* kibnal_pathreq_callback gets my conn ref */ - status = tsIbPathRecordRequest (kibnal_data.kib_device, - kibnal_data.kib_port, - conn->ibc_connreq->cr_gid, - conn->ibc_connreq->cr_service.service_gid, - conn->ibc_connreq->cr_service.service_pkey, - 0, - kibnal_tunables.kib_io_timeout * HZ, - 0, - kibnal_pathreq_callback, conn, - &conn->ibc_connreq->cr_tid); - - if (status == 0) - return; - - CERROR ("Path record request: %d\n", status); - kibnal_connreq_done (conn, 1, status); -} - -void -kibnal_connect_peer (kib_peer_t *peer) -{ - kib_conn_t *conn = kibnal_create_conn(); - int rc; - - LASSERT (peer->ibp_connecting != 0); - - if (conn == NULL) { - CERROR ("Can't allocate conn\n"); - kibnal_peer_connect_failed (peer, 1, -ENOMEM); - return; - } - - conn->ibc_peer = peer; - atomic_inc (&peer->ibp_refcount); - - PORTAL_ALLOC (conn->ibc_connreq, sizeof (*conn->ibc_connreq)); - if (conn->ibc_connreq == NULL) { - CERROR ("Can't allocate connreq\n"); - kibnal_connreq_done (conn, 1, -ENOMEM); - return; - } - - memset(conn->ibc_connreq, 0, sizeof (*conn->ibc_connreq)); - - kibnal_set_service_keys(&conn->ibc_connreq->cr_service, peer->ibp_nid); - - /* kibnal_service_get_callback gets my conn ref */ - rc = ib_service_get (kibnal_data.kib_device, - kibnal_data.kib_port, - &conn->ibc_connreq->cr_service, - KIBNAL_SERVICE_KEY_MASK, - kibnal_tunables.kib_io_timeout * HZ, - kibnal_service_get_callback, conn, - &conn->ibc_connreq->cr_tid); - - if (rc == 0) - return; - - CERROR ("ib_service_get: %d\n", rc); - kibnal_connreq_done (conn, 1, rc); -} - -int -kibnal_conn_timed_out (kib_conn_t *conn) -{ - kib_tx_t *tx; - struct list_head *ttmp; - unsigned long flags; - - spin_lock_irqsave (&conn->ibc_lock, flags); - - list_for_each (ttmp, &conn->ibc_tx_queue) { - tx = list_entry (ttmp, kib_tx_t, tx_list); - - LASSERT (!tx->tx_passive_rdma_wait); - LASSERT (tx->tx_sending == 0); - - if (time_after_eq (jiffies, tx->tx_deadline)) { - spin_unlock_irqrestore (&conn->ibc_lock, flags); - return 1; - } - } - - list_for_each (ttmp, &conn->ibc_active_txs) { - tx = list_entry (ttmp, kib_tx_t, tx_list); - - LASSERT (tx->tx_passive_rdma || - !tx->tx_passive_rdma_wait); - - LASSERT (tx->tx_passive_rdma_wait || - tx->tx_sending != 0); - - if (time_after_eq (jiffies, tx->tx_deadline)) { - spin_unlock_irqrestore (&conn->ibc_lock, flags); - return 1; - } - } - - spin_unlock_irqrestore (&conn->ibc_lock, flags); - - return 0; -} - -void -kibnal_check_conns (int idx) -{ - struct list_head *peers = &kibnal_data.kib_peers[idx]; - struct list_head *ptmp; - kib_peer_t *peer; - kib_conn_t *conn; - struct list_head *ctmp; - - again: - /* NB. We expect to have a look at all the peers and not find any - * rdmas to time out, so we just use a shared lock while we - * take a look... */ - read_lock (&kibnal_data.kib_global_lock); - - list_for_each (ptmp, peers) { - peer = list_entry (ptmp, kib_peer_t, ibp_list); - - list_for_each (ctmp, &peer->ibp_conns) { - conn = list_entry (ctmp, kib_conn_t, ibc_list); - - LASSERT (conn->ibc_state == IBNAL_CONN_ESTABLISHED); - - - /* In case we have enough credits to return via a - * NOOP, but there were no non-blocking tx descs - * free to do it last time... */ - kibnal_check_sends(conn); - - if (!kibnal_conn_timed_out(conn)) - continue; - - CDEBUG(D_NET, "++conn[%p] state %d -> "LPX64" (%d)\n", - conn, conn->ibc_state, peer->ibp_nid, - atomic_read (&conn->ibc_refcount)); - - atomic_inc (&conn->ibc_refcount); - read_unlock (&kibnal_data.kib_global_lock); - - CERROR("Timed out RDMA with "LPX64"\n", - peer->ibp_nid); - - kibnal_close_conn (conn, -ETIMEDOUT); - kibnal_put_conn (conn); - - /* start again now I've dropped the lock */ - goto again; - } - } - - read_unlock (&kibnal_data.kib_global_lock); -} - -void -kibnal_terminate_conn (kib_conn_t *conn) -{ - int rc; - - CDEBUG(D_NET, "conn %p\n", conn); - LASSERT (conn->ibc_state == IBNAL_CONN_DEATHROW); - conn->ibc_state = IBNAL_CONN_ZOMBIE; - - rc = ib_cm_disconnect (conn->ibc_comm_id); - if (rc != 0) - CERROR ("Error %d disconnecting conn %p -> "LPX64"\n", - rc, conn, conn->ibc_peer->ibp_nid); -} - -int -kibnal_connd (void *arg) -{ - wait_queue_t wait; - unsigned long flags; - kib_conn_t *conn; - kib_peer_t *peer; - int timeout; - int i; - int peer_index = 0; - unsigned long deadline = jiffies; - - kportal_daemonize ("kibnal_connd"); - kportal_blockallsigs (); - - init_waitqueue_entry (&wait, current); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - - for (;;) { - if (!list_empty (&kibnal_data.kib_connd_conns)) { - conn = list_entry (kibnal_data.kib_connd_conns.next, - kib_conn_t, ibc_list); - list_del (&conn->ibc_list); - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - - switch (conn->ibc_state) { - case IBNAL_CONN_DEATHROW: - LASSERT (conn->ibc_comm_id != TS_IB_CM_COMM_ID_INVALID); - /* Disconnect: conn becomes a zombie in the - * callback and last ref reschedules it - * here... */ - kibnal_terminate_conn(conn); - kibnal_put_conn (conn); - break; - - case IBNAL_CONN_ZOMBIE: - kibnal_destroy_conn (conn); - break; - - default: - CERROR ("Bad conn %p state: %d\n", - conn, conn->ibc_state); - LBUG(); - } - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - continue; - } - - if (!list_empty (&kibnal_data.kib_connd_peers)) { - peer = list_entry (kibnal_data.kib_connd_peers.next, - kib_peer_t, ibp_connd_list); - - list_del_init (&peer->ibp_connd_list); - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - - kibnal_connect_peer (peer); - kibnal_put_peer (peer); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - } - - /* shut down and nobody left to reap... */ - if (kibnal_data.kib_shutdown && - atomic_read(&kibnal_data.kib_nconns) == 0) - break; - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - - /* careful with the jiffy wrap... */ - while ((timeout = (int)(deadline - jiffies)) <= 0) { - const int n = 4; - const int p = 1; - int chunk = kibnal_data.kib_peer_hash_size; - - /* Time to check for RDMA timeouts on a few more - * peers: I do checks every 'p' seconds on a - * proportion of the peer table and I need to check - * every connection 'n' times within a timeout - * interval, to ensure I detect a timeout on any - * connection within (n+1)/n times the timeout - * interval. */ - - if (kibnal_tunables.kib_io_timeout > n * p) - chunk = (chunk * n * p) / - kibnal_tunables.kib_io_timeout; - if (chunk == 0) - chunk = 1; - - for (i = 0; i < chunk; i++) { - kibnal_check_conns (peer_index); - peer_index = (peer_index + 1) % - kibnal_data.kib_peer_hash_size; - } - - deadline += p * HZ; - } - - kibnal_data.kib_connd_waketime = jiffies + timeout; - - set_current_state (TASK_INTERRUPTIBLE); - add_wait_queue (&kibnal_data.kib_connd_waitq, &wait); - - if (!kibnal_data.kib_shutdown && - list_empty (&kibnal_data.kib_connd_conns) && - list_empty (&kibnal_data.kib_connd_peers)) - schedule_timeout (timeout); - - set_current_state (TASK_RUNNING); - remove_wait_queue (&kibnal_data.kib_connd_waitq, &wait); - - spin_lock_irqsave (&kibnal_data.kib_connd_lock, flags); - } - - spin_unlock_irqrestore (&kibnal_data.kib_connd_lock, flags); - - kibnal_thread_fini (); - return (0); -} - -int -kibnal_scheduler(void *arg) -{ - long id = (long)arg; - char name[16]; - kib_rx_t *rx; - kib_tx_t *tx; - unsigned long flags; - int rc; - int counter = 0; - int did_something; - - snprintf(name, sizeof(name), "kibnal_sd_%02ld", id); - kportal_daemonize(name); - kportal_blockallsigs(); - - spin_lock_irqsave(&kibnal_data.kib_sched_lock, flags); - - for (;;) { - did_something = 0; - - while (!list_empty(&kibnal_data.kib_sched_txq)) { - tx = list_entry(kibnal_data.kib_sched_txq.next, - kib_tx_t, tx_list); - list_del(&tx->tx_list); - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, - flags); - kibnal_tx_done(tx); - - spin_lock_irqsave(&kibnal_data.kib_sched_lock, - flags); - } - - if (!list_empty(&kibnal_data.kib_sched_rxq)) { - rx = list_entry(kibnal_data.kib_sched_rxq.next, - kib_rx_t, rx_list); - list_del(&rx->rx_list); - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, - flags); - - kibnal_rx(rx); - - did_something = 1; - spin_lock_irqsave(&kibnal_data.kib_sched_lock, - flags); - } - - /* shut down and no receives to complete... */ - if (kibnal_data.kib_shutdown && - atomic_read(&kibnal_data.kib_nconns) == 0) - break; - - /* nothing to do or hogging CPU */ - if (!did_something || counter++ == IBNAL_RESCHED) { - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, - flags); - counter = 0; - - if (!did_something) { - rc = wait_event_interruptible( - kibnal_data.kib_sched_waitq, - !list_empty(&kibnal_data.kib_sched_txq) || - !list_empty(&kibnal_data.kib_sched_rxq) || - (kibnal_data.kib_shutdown && - atomic_read (&kibnal_data.kib_nconns) == 0)); - } else { - our_cond_resched(); - } - - spin_lock_irqsave(&kibnal_data.kib_sched_lock, - flags); - } - } - - spin_unlock_irqrestore(&kibnal_data.kib_sched_lock, flags); - - kibnal_thread_fini(); - return (0); -} - - -lib_nal_t kibnal_lib = { - libnal_data: &kibnal_data, /* NAL private data */ - libnal_send: kibnal_send, - libnal_send_pages: kibnal_send_pages, - libnal_recv: kibnal_recv, - libnal_recv_pages: kibnal_recv_pages, - libnal_dist: kibnal_dist -}; diff --git a/lnet/klnds/qswlnd/.cvsignore b/lnet/klnds/qswlnd/.cvsignore deleted file mode 100644 index 48b17e9..0000000 --- a/lnet/klnds/qswlnd/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.*.cmd -.tmp_versions -.depend diff --git a/lnet/klnds/qswlnd/Makefile.in b/lnet/klnds/qswlnd/Makefile.in deleted file mode 100644 index d27240c..0000000 --- a/lnet/klnds/qswlnd/Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -MODULES := kqswnal -kqswnal-objs := qswnal.o qswnal_cb.o - -EXTRA_POST_CFLAGS := @QSWCPPFLAGS@ -I/usr/include - -@INCLUDE_RULES@ diff --git a/lnet/klnds/qswlnd/autoMakefile.am b/lnet/klnds/qswlnd/autoMakefile.am deleted file mode 100644 index b5b2e07..0000000 --- a/lnet/klnds/qswlnd/autoMakefile.am +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if !CRAY_PORTALS -if BUILD_QSWNAL -modulenet_DATA = kqswnal$(KMODEXT) -endif -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(kqswnal-objs:%.o=%.c) qswnal.h diff --git a/lnet/klnds/qswlnd/qswlnd.c b/lnet/klnds/qswlnd/qswlnd.c deleted file mode 100644 index 5aff4e9..0000000 --- a/lnet/klnds/qswlnd/qswlnd.c +++ /dev/null @@ -1,800 +0,0 @@ -/* - * Copyright (C) 2002 Cluster File Systems, Inc. - * Author: Eric Barton - * - * Copyright (C) 2002, Lawrence Livermore National Labs (LLNL) - * W. Marcus Miller - Based on ksocknal - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include "qswnal.h" - -nal_t kqswnal_api; -kqswnal_data_t kqswnal_data; -ptl_handle_ni_t kqswnal_ni; -kqswnal_tunables_t kqswnal_tunables; - -kpr_nal_interface_t kqswnal_router_interface = { - kprni_nalid: QSWNAL, - kprni_arg: NULL, - kprni_fwd: kqswnal_fwd_packet, - kprni_notify: NULL, /* we're connectionless */ -}; - -#if CONFIG_SYSCTL -#define QSWNAL_SYSCTL 201 - -#define QSWNAL_SYSCTL_OPTIMIZED_GETS 1 -#define QSWNAL_SYSCTL_OPTIMIZED_PUTS 2 - -static ctl_table kqswnal_ctl_table[] = { - {QSWNAL_SYSCTL_OPTIMIZED_PUTS, "optimized_puts", - &kqswnal_tunables.kqn_optimized_puts, sizeof (int), - 0644, NULL, &proc_dointvec}, - {QSWNAL_SYSCTL_OPTIMIZED_GETS, "optimized_gets", - &kqswnal_tunables.kqn_optimized_gets, sizeof (int), - 0644, NULL, &proc_dointvec}, - {0} -}; - -static ctl_table kqswnal_top_ctl_table[] = { - {QSWNAL_SYSCTL, "qswnal", NULL, 0, 0555, kqswnal_ctl_table}, - {0} -}; -#endif - -int -kqswnal_get_tx_desc (struct portals_cfg *pcfg) -{ - unsigned long flags; - struct list_head *tmp; - kqswnal_tx_t *ktx; - ptl_hdr_t *hdr; - int index = pcfg->pcfg_count; - int rc = -ENOENT; - - spin_lock_irqsave (&kqswnal_data.kqn_idletxd_lock, flags); - - list_for_each (tmp, &kqswnal_data.kqn_activetxds) { - if (index-- != 0) - continue; - - ktx = list_entry (tmp, kqswnal_tx_t, ktx_list); - hdr = (ptl_hdr_t *)ktx->ktx_buffer; - - pcfg->pcfg_pbuf1 = (char *)ktx; - pcfg->pcfg_count = le32_to_cpu(hdr->type); - pcfg->pcfg_size = le32_to_cpu(hdr->payload_length); - pcfg->pcfg_nid = le64_to_cpu(hdr->dest_nid); - pcfg->pcfg_nid2 = ktx->ktx_nid; - pcfg->pcfg_misc = ktx->ktx_launcher; - pcfg->pcfg_flags = (list_empty (&ktx->ktx_delayed_list) ? 0 : 1) | - (!ktx->ktx_isnblk ? 0 : 2) | - (ktx->ktx_state << 2); - rc = 0; - break; - } - - spin_unlock_irqrestore (&kqswnal_data.kqn_idletxd_lock, flags); - return (rc); -} - -int -kqswnal_cmd (struct portals_cfg *pcfg, void *private) -{ - LASSERT (pcfg != NULL); - - switch (pcfg->pcfg_command) { - case NAL_CMD_GET_TXDESC: - return (kqswnal_get_tx_desc (pcfg)); - - case NAL_CMD_REGISTER_MYNID: - CDEBUG (D_IOCTL, "setting NID offset to "LPX64" (was "LPX64")\n", - pcfg->pcfg_nid - kqswnal_data.kqn_elanid, - kqswnal_data.kqn_nid_offset); - kqswnal_data.kqn_nid_offset = - pcfg->pcfg_nid - kqswnal_data.kqn_elanid; - kqswnal_lib.libnal_ni.ni_pid.nid = pcfg->pcfg_nid; - return (0); - - default: - return (-EINVAL); - } -} - -static void -kqswnal_shutdown(nal_t *nal) -{ - unsigned long flags; - kqswnal_tx_t *ktx; - kqswnal_rx_t *krx; - int do_lib_fini = 0; - - /* NB The first ref was this module! */ - if (nal->nal_refct != 0) { - PORTAL_MODULE_UNUSE; - return; - } - - CDEBUG (D_NET, "shutdown\n"); - LASSERT (nal == &kqswnal_api); - - switch (kqswnal_data.kqn_init) - { - default: - LASSERT (0); - - case KQN_INIT_ALL: - libcfs_nal_cmd_unregister(QSWNAL); - /* fall through */ - - case KQN_INIT_LIB: - do_lib_fini = 1; - /* fall through */ - - case KQN_INIT_DATA: - break; - - case KQN_INIT_NOTHING: - return; - } - - /**********************************************************************/ - /* Tell router we're shutting down. Any router calls my threads - * make will now fail immediately and the router will stop calling - * into me. */ - kpr_shutdown (&kqswnal_data.kqn_router); - - /**********************************************************************/ - /* Signal the start of shutdown... */ - spin_lock_irqsave(&kqswnal_data.kqn_idletxd_lock, flags); - kqswnal_data.kqn_shuttingdown = 1; - spin_unlock_irqrestore(&kqswnal_data.kqn_idletxd_lock, flags); - - wake_up_all(&kqswnal_data.kqn_idletxd_waitq); - - /**********************************************************************/ - /* wait for sends that have allocated a tx desc to launch or give up */ - while (atomic_read (&kqswnal_data.kqn_pending_txs) != 0) { - CDEBUG(D_NET, "waiting for %d pending sends\n", - atomic_read (&kqswnal_data.kqn_pending_txs)); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - } - - /**********************************************************************/ - /* close elan comms */ -#if MULTIRAIL_EKC - /* Shut down receivers first; rx callbacks might try sending... */ - if (kqswnal_data.kqn_eprx_small != NULL) - ep_free_rcvr (kqswnal_data.kqn_eprx_small); - - if (kqswnal_data.kqn_eprx_large != NULL) - ep_free_rcvr (kqswnal_data.kqn_eprx_large); - - /* NB ep_free_rcvr() returns only after we've freed off all receive - * buffers (see shutdown handling in kqswnal_requeue_rx()). This - * means we must have completed any messages we passed to - * lib_parse() or kpr_fwd_start(). */ - - if (kqswnal_data.kqn_eptx != NULL) - ep_free_xmtr (kqswnal_data.kqn_eptx); - - /* NB ep_free_xmtr() returns only after all outstanding transmits - * have called their callback... */ - LASSERT(list_empty(&kqswnal_data.kqn_activetxds)); -#else - /* "Old" EKC just pretends to shutdown cleanly but actually - * provides no guarantees */ - if (kqswnal_data.kqn_eprx_small != NULL) - ep_remove_large_rcvr (kqswnal_data.kqn_eprx_small); - - if (kqswnal_data.kqn_eprx_large != NULL) - ep_remove_large_rcvr (kqswnal_data.kqn_eprx_large); - - /* wait for transmits to complete */ - while (!list_empty(&kqswnal_data.kqn_activetxds)) { - CWARN("waiting for active transmits to complete\n"); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ); - } - - if (kqswnal_data.kqn_eptx != NULL) - ep_free_large_xmtr (kqswnal_data.kqn_eptx); -#endif - /**********************************************************************/ - /* flag threads to terminate, wake them and wait for them to die */ - kqswnal_data.kqn_shuttingdown = 2; - wake_up_all (&kqswnal_data.kqn_sched_waitq); - - while (atomic_read (&kqswnal_data.kqn_nthreads) != 0) { - CDEBUG(D_NET, "waiting for %d threads to terminate\n", - atomic_read (&kqswnal_data.kqn_nthreads)); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - } - - /**********************************************************************/ - /* No more threads. No more portals, router or comms callbacks! - * I control the horizontals and the verticals... - */ - -#if MULTIRAIL_EKC - LASSERT (list_empty (&kqswnal_data.kqn_readyrxds)); - LASSERT (list_empty (&kqswnal_data.kqn_delayedtxds)); - LASSERT (list_empty (&kqswnal_data.kqn_delayedfwds)); -#endif - - /**********************************************************************/ - /* Complete any blocked forwarding packets, with error - */ - - while (!list_empty (&kqswnal_data.kqn_idletxd_fwdq)) - { - kpr_fwd_desc_t *fwd = list_entry (kqswnal_data.kqn_idletxd_fwdq.next, - kpr_fwd_desc_t, kprfd_list); - list_del (&fwd->kprfd_list); - kpr_fwd_done (&kqswnal_data.kqn_router, fwd, -ESHUTDOWN); - } - - /**********************************************************************/ - /* finalise router and portals lib */ - - kpr_deregister (&kqswnal_data.kqn_router); - - if (do_lib_fini) - lib_fini (&kqswnal_lib); - - /**********************************************************************/ - /* Unmap message buffers and free all descriptors and buffers - */ - -#if MULTIRAIL_EKC - /* FTTB, we need to unmap any remaining mapped memory. When - * ep_dvma_release() get fixed (and releases any mappings in the - * region), we can delete all the code from here --------> */ - - for (ktx = kqswnal_data.kqn_txds; ktx != NULL; ktx = ktx->ktx_alloclist) { - /* If ktx has a buffer, it got mapped; unmap now. NB only - * the pre-mapped stuff is still mapped since all tx descs - * must be idle */ - - if (ktx->ktx_buffer != NULL) - ep_dvma_unload(kqswnal_data.kqn_ep, - kqswnal_data.kqn_ep_tx_nmh, - &ktx->ktx_ebuffer); - } - - for (krx = kqswnal_data.kqn_rxds; krx != NULL; krx = krx->krx_alloclist) { - /* If krx_kiov[0].kiov_page got allocated, it got mapped. - * NB subsequent pages get merged */ - - if (krx->krx_kiov[0].kiov_page != NULL) - ep_dvma_unload(kqswnal_data.kqn_ep, - kqswnal_data.kqn_ep_rx_nmh, - &krx->krx_elanbuffer); - } - /* <----------- to here */ - - if (kqswnal_data.kqn_ep_rx_nmh != NULL) - ep_dvma_release(kqswnal_data.kqn_ep, kqswnal_data.kqn_ep_rx_nmh); - - if (kqswnal_data.kqn_ep_tx_nmh != NULL) - ep_dvma_release(kqswnal_data.kqn_ep, kqswnal_data.kqn_ep_tx_nmh); -#else - if (kqswnal_data.kqn_eprxdmahandle != NULL) - { - elan3_dvma_unload(kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eprxdmahandle, 0, - KQSW_NRXMSGPAGES_SMALL * KQSW_NRXMSGS_SMALL + - KQSW_NRXMSGPAGES_LARGE * KQSW_NRXMSGS_LARGE); - - elan3_dma_release(kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eprxdmahandle); - } - - if (kqswnal_data.kqn_eptxdmahandle != NULL) - { - elan3_dvma_unload(kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eptxdmahandle, 0, - KQSW_NTXMSGPAGES * (KQSW_NTXMSGS + - KQSW_NNBLK_TXMSGS)); - - elan3_dma_release(kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eptxdmahandle); - } -#endif - - while (kqswnal_data.kqn_txds != NULL) { - ktx = kqswnal_data.kqn_txds; - - if (ktx->ktx_buffer != NULL) - PORTAL_FREE(ktx->ktx_buffer, KQSW_TX_BUFFER_SIZE); - - kqswnal_data.kqn_txds = ktx->ktx_alloclist; - PORTAL_FREE(ktx, sizeof(*ktx)); - } - - while (kqswnal_data.kqn_rxds != NULL) { - int i; - - krx = kqswnal_data.kqn_rxds; - for (i = 0; i < krx->krx_npages; i++) - if (krx->krx_kiov[i].kiov_page != NULL) - __free_page (krx->krx_kiov[i].kiov_page); - - kqswnal_data.kqn_rxds = krx->krx_alloclist; - PORTAL_FREE(krx, sizeof (*krx)); - } - - /* resets flags, pointers to NULL etc */ - memset(&kqswnal_data, 0, sizeof (kqswnal_data)); - - CDEBUG (D_MALLOC, "done kmem %d\n", atomic_read(&portal_kmemory)); - - printk (KERN_INFO "Lustre: Routing QSW NAL unloaded (final mem %d)\n", - atomic_read(&portal_kmemory)); -} - -static int -kqswnal_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ -#if MULTIRAIL_EKC - EP_RAILMASK all_rails = EP_RAILMASK_ALL; -#else - ELAN3_DMA_REQUEST dmareq; -#endif - int rc; - int i; - kqswnal_rx_t *krx; - kqswnal_tx_t *ktx; - int elan_page_idx; - ptl_process_id_t my_process_id; - int pkmem = atomic_read(&portal_kmemory); - - LASSERT (nal == &kqswnal_api); - - if (nal->nal_refct != 0) { - if (actual_limits != NULL) - *actual_limits = kqswnal_lib.libnal_ni.ni_actual_limits; - /* This module got the first ref */ - PORTAL_MODULE_USE; - return (PTL_OK); - } - - LASSERT (kqswnal_data.kqn_init == KQN_INIT_NOTHING); - - CDEBUG (D_MALLOC, "start kmem %d\n", atomic_read(&portal_kmemory)); - - /* ensure all pointers NULL etc */ - memset (&kqswnal_data, 0, sizeof (kqswnal_data)); - - INIT_LIST_HEAD (&kqswnal_data.kqn_idletxds); - INIT_LIST_HEAD (&kqswnal_data.kqn_nblk_idletxds); - INIT_LIST_HEAD (&kqswnal_data.kqn_activetxds); - spin_lock_init (&kqswnal_data.kqn_idletxd_lock); - init_waitqueue_head (&kqswnal_data.kqn_idletxd_waitq); - INIT_LIST_HEAD (&kqswnal_data.kqn_idletxd_fwdq); - - INIT_LIST_HEAD (&kqswnal_data.kqn_delayedfwds); - INIT_LIST_HEAD (&kqswnal_data.kqn_delayedtxds); - INIT_LIST_HEAD (&kqswnal_data.kqn_readyrxds); - - spin_lock_init (&kqswnal_data.kqn_sched_lock); - init_waitqueue_head (&kqswnal_data.kqn_sched_waitq); - - /* Leave kqn_rpc_success zeroed */ -#if MULTIRAIL_EKC - kqswnal_data.kqn_rpc_failed.Data[0] = -ECONNREFUSED; -#else - kqswnal_data.kqn_rpc_failed.Status = -ECONNREFUSED; -#endif - - /* pointers/lists/locks initialised */ - kqswnal_data.kqn_init = KQN_INIT_DATA; - -#if MULTIRAIL_EKC - kqswnal_data.kqn_ep = ep_system(); - if (kqswnal_data.kqn_ep == NULL) { - CERROR("Can't initialise EKC\n"); - kqswnal_shutdown(nal); - return (PTL_IFACE_INVALID); - } - - if (ep_waitfor_nodeid(kqswnal_data.kqn_ep) == ELAN_INVALID_NODE) { - CERROR("Can't get elan ID\n"); - kqswnal_shutdown(nal); - return (PTL_IFACE_INVALID); - } -#else - /**********************************************************************/ - /* Find the first Elan device */ - - kqswnal_data.kqn_ep = ep_device (0); - if (kqswnal_data.kqn_ep == NULL) - { - CERROR ("Can't get elan device 0\n"); - kqswnal_shutdown(nal); - return (PTL_IFACE_INVALID); - } -#endif - - kqswnal_data.kqn_nid_offset = 0; - kqswnal_data.kqn_nnodes = ep_numnodes (kqswnal_data.kqn_ep); - kqswnal_data.kqn_elanid = ep_nodeid (kqswnal_data.kqn_ep); - - /**********************************************************************/ - /* Get the transmitter */ - - kqswnal_data.kqn_eptx = ep_alloc_xmtr (kqswnal_data.kqn_ep); - if (kqswnal_data.kqn_eptx == NULL) - { - CERROR ("Can't allocate transmitter\n"); - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } - - /**********************************************************************/ - /* Get the receivers */ - - kqswnal_data.kqn_eprx_small = ep_alloc_rcvr (kqswnal_data.kqn_ep, - EP_MSG_SVC_PORTALS_SMALL, - KQSW_EP_ENVELOPES_SMALL); - if (kqswnal_data.kqn_eprx_small == NULL) - { - CERROR ("Can't install small msg receiver\n"); - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } - - kqswnal_data.kqn_eprx_large = ep_alloc_rcvr (kqswnal_data.kqn_ep, - EP_MSG_SVC_PORTALS_LARGE, - KQSW_EP_ENVELOPES_LARGE); - if (kqswnal_data.kqn_eprx_large == NULL) - { - CERROR ("Can't install large msg receiver\n"); - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } - - /**********************************************************************/ - /* Reserve Elan address space for transmit descriptors NB we may - * either send the contents of associated buffers immediately, or - * map them for the peer to suck/blow... */ -#if MULTIRAIL_EKC - kqswnal_data.kqn_ep_tx_nmh = - ep_dvma_reserve(kqswnal_data.kqn_ep, - KQSW_NTXMSGPAGES*(KQSW_NTXMSGS+KQSW_NNBLK_TXMSGS), - EP_PERM_WRITE); - if (kqswnal_data.kqn_ep_tx_nmh == NULL) { - CERROR("Can't reserve tx dma space\n"); - kqswnal_shutdown(nal); - return (PTL_NO_SPACE); - } -#else - dmareq.Waitfn = DDI_DMA_SLEEP; - dmareq.ElanAddr = (E3_Addr) 0; - dmareq.Attr = PTE_LOAD_LITTLE_ENDIAN; - dmareq.Perm = ELAN_PERM_REMOTEWRITE; - - rc = elan3_dma_reserve(kqswnal_data.kqn_ep->DmaState, - KQSW_NTXMSGPAGES*(KQSW_NTXMSGS+KQSW_NNBLK_TXMSGS), - &dmareq, &kqswnal_data.kqn_eptxdmahandle); - if (rc != DDI_SUCCESS) - { - CERROR ("Can't reserve rx dma space\n"); - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } -#endif - /**********************************************************************/ - /* Reserve Elan address space for receive buffers */ -#if MULTIRAIL_EKC - kqswnal_data.kqn_ep_rx_nmh = - ep_dvma_reserve(kqswnal_data.kqn_ep, - KQSW_NRXMSGPAGES_SMALL * KQSW_NRXMSGS_SMALL + - KQSW_NRXMSGPAGES_LARGE * KQSW_NRXMSGS_LARGE, - EP_PERM_WRITE); - if (kqswnal_data.kqn_ep_tx_nmh == NULL) { - CERROR("Can't reserve rx dma space\n"); - kqswnal_shutdown(nal); - return (PTL_NO_SPACE); - } -#else - dmareq.Waitfn = DDI_DMA_SLEEP; - dmareq.ElanAddr = (E3_Addr) 0; - dmareq.Attr = PTE_LOAD_LITTLE_ENDIAN; - dmareq.Perm = ELAN_PERM_REMOTEWRITE; - - rc = elan3_dma_reserve (kqswnal_data.kqn_ep->DmaState, - KQSW_NRXMSGPAGES_SMALL * KQSW_NRXMSGS_SMALL + - KQSW_NRXMSGPAGES_LARGE * KQSW_NRXMSGS_LARGE, - &dmareq, &kqswnal_data.kqn_eprxdmahandle); - if (rc != DDI_SUCCESS) - { - CERROR ("Can't reserve rx dma space\n"); - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } -#endif - /**********************************************************************/ - /* Allocate/Initialise transmit descriptors */ - - kqswnal_data.kqn_txds = NULL; - for (i = 0; i < (KQSW_NTXMSGS + KQSW_NNBLK_TXMSGS); i++) - { - int premapped_pages; - int basepage = i * KQSW_NTXMSGPAGES; - - PORTAL_ALLOC (ktx, sizeof(*ktx)); - if (ktx == NULL) { - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } - - memset(ktx, 0, sizeof(*ktx)); /* NULL pointers; zero flags */ - ktx->ktx_alloclist = kqswnal_data.kqn_txds; - kqswnal_data.kqn_txds = ktx; - - PORTAL_ALLOC (ktx->ktx_buffer, KQSW_TX_BUFFER_SIZE); - if (ktx->ktx_buffer == NULL) - { - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } - - /* Map pre-allocated buffer NOW, to save latency on transmit */ - premapped_pages = kqswnal_pages_spanned(ktx->ktx_buffer, - KQSW_TX_BUFFER_SIZE); -#if MULTIRAIL_EKC - ep_dvma_load(kqswnal_data.kqn_ep, NULL, - ktx->ktx_buffer, KQSW_TX_BUFFER_SIZE, - kqswnal_data.kqn_ep_tx_nmh, basepage, - &all_rails, &ktx->ktx_ebuffer); -#else - elan3_dvma_kaddr_load (kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eptxdmahandle, - ktx->ktx_buffer, KQSW_TX_BUFFER_SIZE, - basepage, &ktx->ktx_ebuffer); -#endif - ktx->ktx_basepage = basepage + premapped_pages; /* message mapping starts here */ - ktx->ktx_npages = KQSW_NTXMSGPAGES - premapped_pages; /* for this many pages */ - - INIT_LIST_HEAD (&ktx->ktx_delayed_list); - - ktx->ktx_state = KTX_IDLE; -#if MULTIRAIL_EKC - ktx->ktx_rail = -1; /* unset rail */ -#endif - ktx->ktx_isnblk = (i >= KQSW_NTXMSGS); - list_add_tail (&ktx->ktx_list, - ktx->ktx_isnblk ? &kqswnal_data.kqn_nblk_idletxds : - &kqswnal_data.kqn_idletxds); - } - - /**********************************************************************/ - /* Allocate/Initialise receive descriptors */ - kqswnal_data.kqn_rxds = NULL; - elan_page_idx = 0; - for (i = 0; i < KQSW_NRXMSGS_SMALL + KQSW_NRXMSGS_LARGE; i++) - { -#if MULTIRAIL_EKC - EP_NMD elanbuffer; -#else - E3_Addr elanbuffer; -#endif - int j; - - PORTAL_ALLOC(krx, sizeof(*krx)); - if (krx == NULL) { - kqswnal_shutdown(nal); - return (PTL_NO_SPACE); - } - - memset(krx, 0, sizeof(*krx)); /* clear flags, null pointers etc */ - krx->krx_alloclist = kqswnal_data.kqn_rxds; - kqswnal_data.kqn_rxds = krx; - - if (i < KQSW_NRXMSGS_SMALL) - { - krx->krx_npages = KQSW_NRXMSGPAGES_SMALL; - krx->krx_eprx = kqswnal_data.kqn_eprx_small; - } - else - { - krx->krx_npages = KQSW_NRXMSGPAGES_LARGE; - krx->krx_eprx = kqswnal_data.kqn_eprx_large; - } - - LASSERT (krx->krx_npages > 0); - for (j = 0; j < krx->krx_npages; j++) - { - struct page *page = alloc_page(GFP_KERNEL); - - if (page == NULL) { - kqswnal_shutdown (nal); - return (PTL_NO_SPACE); - } - - krx->krx_kiov[j].kiov_page = page; - LASSERT(page_address(page) != NULL); - -#if MULTIRAIL_EKC - ep_dvma_load(kqswnal_data.kqn_ep, NULL, - page_address(page), - PAGE_SIZE, kqswnal_data.kqn_ep_rx_nmh, - elan_page_idx, &all_rails, &elanbuffer); - - if (j == 0) { - krx->krx_elanbuffer = elanbuffer; - } else { - rc = ep_nmd_merge(&krx->krx_elanbuffer, - &krx->krx_elanbuffer, - &elanbuffer); - /* NB contiguous mapping */ - LASSERT(rc); - } -#else - elan3_dvma_kaddr_load(kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eprxdmahandle, - page_address(page), - PAGE_SIZE, elan_page_idx, - &elanbuffer); - if (j == 0) - krx->krx_elanbuffer = elanbuffer; - - /* NB contiguous mapping */ - LASSERT (elanbuffer == krx->krx_elanbuffer + j * PAGE_SIZE); -#endif - elan_page_idx++; - - } - } - LASSERT (elan_page_idx == - (KQSW_NRXMSGS_SMALL * KQSW_NRXMSGPAGES_SMALL) + - (KQSW_NRXMSGS_LARGE * KQSW_NRXMSGPAGES_LARGE)); - - /**********************************************************************/ - /* Network interface ready to initialise */ - - my_process_id.nid = kqswnal_elanid2nid(kqswnal_data.kqn_elanid); - my_process_id.pid = requested_pid; - - rc = lib_init(&kqswnal_lib, nal, my_process_id, - requested_limits, actual_limits); - if (rc != PTL_OK) - { - CERROR ("lib_init failed %d\n", rc); - kqswnal_shutdown (nal); - return (rc); - } - - kqswnal_data.kqn_init = KQN_INIT_LIB; - - /**********************************************************************/ - /* Queue receives, now that it's OK to run their completion callbacks */ - - for (krx = kqswnal_data.kqn_rxds; krx != NULL; krx = krx->krx_alloclist) { - /* NB this enqueue can allocate/sleep (attr == 0) */ - krx->krx_state = KRX_POSTED; -#if MULTIRAIL_EKC - rc = ep_queue_receive(krx->krx_eprx, kqswnal_rxhandler, krx, - &krx->krx_elanbuffer, 0); -#else - rc = ep_queue_receive(krx->krx_eprx, kqswnal_rxhandler, krx, - krx->krx_elanbuffer, - krx->krx_npages * PAGE_SIZE, 0); -#endif - if (rc != EP_SUCCESS) - { - CERROR ("failed ep_queue_receive %d\n", rc); - kqswnal_shutdown (nal); - return (PTL_FAIL); - } - } - - /**********************************************************************/ - /* Spawn scheduling threads */ - for (i = 0; i < num_online_cpus(); i++) { - rc = kqswnal_thread_start (kqswnal_scheduler, NULL); - if (rc != 0) - { - CERROR ("failed to spawn scheduling thread: %d\n", rc); - kqswnal_shutdown (nal); - return (PTL_FAIL); - } - } - - /**********************************************************************/ - /* Connect to the router */ - rc = kpr_register (&kqswnal_data.kqn_router, &kqswnal_router_interface); - CDEBUG(D_NET, "Can't initialise routing interface (rc = %d): not routing\n",rc); - - rc = libcfs_nal_cmd_register (QSWNAL, &kqswnal_cmd, NULL); - if (rc != 0) { - CERROR ("Can't initialise command interface (rc = %d)\n", rc); - kqswnal_shutdown (nal); - return (PTL_FAIL); - } - - kqswnal_data.kqn_init = KQN_INIT_ALL; - - printk(KERN_INFO "Lustre: Routing QSW NAL loaded on node %d of %d " - "(Routing %s, initial mem %d)\n", - kqswnal_data.kqn_elanid, kqswnal_data.kqn_nnodes, - kpr_routing (&kqswnal_data.kqn_router) ? "enabled" : "disabled", - pkmem); - - return (PTL_OK); -} - -void __exit -kqswnal_finalise (void) -{ -#if CONFIG_SYSCTL - if (kqswnal_tunables.kqn_sysctl != NULL) - unregister_sysctl_table (kqswnal_tunables.kqn_sysctl); -#endif - PtlNIFini(kqswnal_ni); - - ptl_unregister_nal(QSWNAL); -} - -static int __init -kqswnal_initialise (void) -{ - int rc; - - kqswnal_api.nal_ni_init = kqswnal_startup; - kqswnal_api.nal_ni_fini = kqswnal_shutdown; - - /* Initialise dynamic tunables to defaults once only */ - kqswnal_tunables.kqn_optimized_puts = KQSW_OPTIMIZED_PUTS; - kqswnal_tunables.kqn_optimized_gets = KQSW_OPTIMIZED_GETS; - - rc = ptl_register_nal(QSWNAL, &kqswnal_api); - if (rc != PTL_OK) { - CERROR("Can't register QSWNAL: %d\n", rc); - return (-ENOMEM); /* or something... */ - } - - /* Pure gateways, and the workaround for 'EKC blocks forever until - * the service is active' want the NAL started up at module load - * time... */ - rc = PtlNIInit(QSWNAL, LUSTRE_SRV_PTL_PID, NULL, NULL, &kqswnal_ni); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) { - ptl_unregister_nal(QSWNAL); - return (-ENODEV); - } - -#if CONFIG_SYSCTL - /* Press on regardless even if registering sysctl doesn't work */ - kqswnal_tunables.kqn_sysctl = - register_sysctl_table (kqswnal_top_ctl_table, 0); -#endif - return (0); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Kernel Quadrics/Elan NAL v1.01"); -MODULE_LICENSE("GPL"); - -module_init (kqswnal_initialise); -module_exit (kqswnal_finalise); diff --git a/lnet/klnds/qswlnd/qswlnd.h b/lnet/klnds/qswlnd/qswlnd.h deleted file mode 100644 index 6e04752..0000000 --- a/lnet/klnds/qswlnd/qswlnd.h +++ /dev/null @@ -1,376 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * 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. - * - * Basic library routines. - * - */ - -#ifndef _QSWNAL_H -#define _QSWNAL_H -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#undef printf /* nasty QSW #define */ - -#include -#include - -#if MULTIRAIL_EKC -# include -#else -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif - -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include /* wait_on_buffer */ -#else -#include /* wait_on_buffer */ -#endif -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_NAL - -#include -#include -#include -#include -#include - -#define KQSW_CHECKSUM 0 -#if KQSW_CHECKSUM -typedef unsigned long kqsw_csum_t; -#define KQSW_CSUM_SIZE (2 * sizeof (kqsw_csum_t)) -#else -#define KQSW_CSUM_SIZE 0 -#endif -#define KQSW_HDR_SIZE (sizeof (ptl_hdr_t) + KQSW_CSUM_SIZE) - -/* - * Performance Tuning defines - * NB no mention of PAGE_SIZE for interoperability - */ -#define KQSW_MAXPAYLOAD PTL_MTU -#define KQSW_SMALLPAYLOAD ((4<<10) - KQSW_HDR_SIZE) /* small/large ep receiver breakpoint */ - -#define KQSW_TX_MAXCONTIG (1<<10) /* largest payload that gets made contiguous on transmit */ - -#define KQSW_NTXMSGS 8 /* # normal transmit messages */ -#define KQSW_NNBLK_TXMSGS (PAGE_SIZE == 4096 ? 512 : 256) /* # reserved transmit messages if can't block */ /* avoid qsnet crash b=5291 */ - -#define KQSW_NRXMSGS_LARGE 64 /* # large receive buffers */ -#define KQSW_EP_ENVELOPES_LARGE 256 /* # large ep envelopes */ - -#define KQSW_NRXMSGS_SMALL 256 /* # small receive buffers */ -#define KQSW_EP_ENVELOPES_SMALL 2048 /* # small ep envelopes */ - -#define KQSW_RESCHED 100 /* # busy loops that forces scheduler to yield */ - -#define KQSW_OPTIMIZED_GETS 1 /* optimize gets >= this size */ -#define KQSW_OPTIMIZED_PUTS (32<<10) /* optimize puts >= this size */ -#define KQSW_COPY_SMALL_FWD 0 /* copy small fwd messages to pre-mapped buffer? */ - -/* - * derived constants - */ - -#define KQSW_TX_BUFFER_SIZE (KQSW_HDR_SIZE + KQSW_TX_MAXCONTIG) -/* The pre-allocated tx buffer (hdr + small payload) */ - -#define KQSW_NTXMSGPAGES (btopr(KQSW_TX_BUFFER_SIZE) + 1 + btopr(KQSW_MAXPAYLOAD) + 1) -/* Reserve elan address space for pre-allocated and pre-mapped transmit - * buffer and a full payload too. Extra pages allow for page alignment */ - -#define KQSW_NRXMSGPAGES_SMALL (btopr(KQSW_HDR_SIZE + KQSW_SMALLPAYLOAD)) -/* receive hdr/payload always contiguous and page aligned */ -#define KQSW_NRXMSGBYTES_SMALL (KQSW_NRXMSGPAGES_SMALL * PAGE_SIZE) - -#define KQSW_NRXMSGPAGES_LARGE (btopr(KQSW_HDR_SIZE + KQSW_MAXPAYLOAD)) -/* receive hdr/payload always contiguous and page aligned */ -#define KQSW_NRXMSGBYTES_LARGE (KQSW_NRXMSGPAGES_LARGE * PAGE_SIZE) -/* biggest complete packet we can receive (or transmit) */ - -/* Remote memory descriptor */ -typedef struct -{ - __u32 kqrmd_nfrag; /* # frags */ -#if MULTIRAIL_EKC - EP_NMD kqrmd_frag[0]; /* actual frags */ -#else - EP_IOVEC kqrmd_frag[0]; /* actual frags */ -#endif -} kqswnal_remotemd_t; - -typedef struct kqswnal_rx -{ - struct list_head krx_list; /* enqueue -> thread */ - struct kqswnal_rx *krx_alloclist; /* stack in kqn_rxds */ - EP_RCVR *krx_eprx; /* port to post receives to */ - EP_RXD *krx_rxd; /* receive descriptor (for repost) */ -#if MULTIRAIL_EKC - EP_NMD krx_elanbuffer; /* contiguous Elan buffer */ -#else - E3_Addr krx_elanbuffer; /* contiguous Elan buffer */ -#endif - int krx_npages; /* # pages in receive buffer */ - int krx_nob; /* Number Of Bytes received into buffer */ - int krx_rpc_reply_needed; /* peer waiting for EKC RPC reply */ - int krx_rpc_reply_status; /* what status to send */ - int krx_state; /* what this RX is doing */ - atomic_t krx_refcount; /* how to tell when rpc is done */ - kpr_fwd_desc_t krx_fwd; /* embedded forwarding descriptor */ - ptl_kiov_t krx_kiov[KQSW_NRXMSGPAGES_LARGE]; /* buffer frags */ -} kqswnal_rx_t; - -#define KRX_POSTED 1 /* receiving */ -#define KRX_PARSE 2 /* ready to be parsed */ -#define KRX_COMPLETING 3 /* waiting to be completed */ - - -typedef struct kqswnal_tx -{ - struct list_head ktx_list; /* enqueue idle/active */ - struct list_head ktx_delayed_list; /* enqueue delayedtxds */ - struct kqswnal_tx *ktx_alloclist; /* stack in kqn_txds */ - unsigned int ktx_isnblk:1; /* reserved descriptor? */ - unsigned int ktx_state:7; /* What I'm doing */ - unsigned int ktx_firsttmpfrag:1; /* ktx_frags[0] is in my ebuffer ? 0 : 1 */ - uint32_t ktx_basepage; /* page offset in reserved elan tx vaddrs for mapping pages */ - int ktx_npages; /* pages reserved for mapping messages */ - int ktx_nmappedpages; /* # pages mapped for current message */ - int ktx_port; /* destination ep port */ - ptl_nid_t ktx_nid; /* destination node */ - void *ktx_args[3]; /* completion passthru */ - char *ktx_buffer; /* pre-allocated contiguous buffer for hdr + small payloads */ - unsigned long ktx_launchtime; /* when (in jiffies) the transmit was launched */ - - /* debug/info fields */ - pid_t ktx_launcher; /* pid of launching process */ - - int ktx_nfrag; /* # message frags */ -#if MULTIRAIL_EKC - int ktx_rail; /* preferred rail */ - EP_NMD ktx_ebuffer; /* elan mapping of ktx_buffer */ - EP_NMD ktx_frags[EP_MAXFRAG];/* elan mapping of msg frags */ -#else - E3_Addr ktx_ebuffer; /* elan address of ktx_buffer */ - EP_IOVEC ktx_frags[EP_MAXFRAG];/* msg frags (elan vaddrs) */ -#endif -} kqswnal_tx_t; - -#define KTX_IDLE 0 /* on kqn_(nblk_)idletxds */ -#define KTX_FORWARDING 1 /* sending a forwarded packet */ -#define KTX_SENDING 2 /* normal send */ -#define KTX_GETTING 3 /* sending optimised get */ -#define KTX_PUTTING 4 /* sending optimised put */ -#define KTX_RDMAING 5 /* handling optimised put/get */ - -typedef struct -{ - /* dynamic tunables... */ - int kqn_optimized_puts; /* optimized PUTs? */ - int kqn_optimized_gets; /* optimized GETs? */ -#if CONFIG_SYSCTL - struct ctl_table_header *kqn_sysctl; /* sysctl interface */ -#endif -} kqswnal_tunables_t; - -typedef struct -{ - char kqn_init; /* what's been initialised */ - char kqn_shuttingdown; /* I'm trying to shut down */ - atomic_t kqn_nthreads; /* # threads running */ - - kqswnal_rx_t *kqn_rxds; /* stack of all the receive descriptors */ - kqswnal_tx_t *kqn_txds; /* stack of all the transmit descriptors */ - - struct list_head kqn_idletxds; /* transmit descriptors free to use */ - struct list_head kqn_nblk_idletxds; /* reserved free transmit descriptors */ - struct list_head kqn_activetxds; /* transmit descriptors being used */ - spinlock_t kqn_idletxd_lock; /* serialise idle txd access */ - wait_queue_head_t kqn_idletxd_waitq; /* sender blocks here waiting for idle txd */ - struct list_head kqn_idletxd_fwdq; /* forwarded packets block here waiting for idle txd */ - atomic_t kqn_pending_txs; /* # transmits being prepped */ - - spinlock_t kqn_sched_lock; /* serialise packet schedulers */ - wait_queue_head_t kqn_sched_waitq; /* scheduler blocks here */ - - struct list_head kqn_readyrxds; /* rxds full of data */ - struct list_head kqn_delayedfwds; /* delayed forwards */ - struct list_head kqn_delayedtxds; /* delayed transmits */ - -#if MULTIRAIL_EKC - EP_SYS *kqn_ep; /* elan system */ - EP_NMH *kqn_ep_tx_nmh; /* elan reserved tx vaddrs */ - EP_NMH *kqn_ep_rx_nmh; /* elan reserved rx vaddrs */ -#else - EP_DEV *kqn_ep; /* elan device */ - ELAN3_DMA_HANDLE *kqn_eptxdmahandle; /* elan reserved tx vaddrs */ - ELAN3_DMA_HANDLE *kqn_eprxdmahandle; /* elan reserved rx vaddrs */ -#endif - EP_XMTR *kqn_eptx; /* elan transmitter */ - EP_RCVR *kqn_eprx_small; /* elan receiver (small messages) */ - EP_RCVR *kqn_eprx_large; /* elan receiver (large messages) */ - kpr_router_t kqn_router; /* connection to Kernel Portals Router module */ - - ptl_nid_t kqn_nid_offset; /* this cluster's NID offset */ - int kqn_nnodes; /* this cluster's size */ - int kqn_elanid; /* this nodes's elan ID */ - - EP_STATUSBLK kqn_rpc_success; /* preset RPC reply status blocks */ - EP_STATUSBLK kqn_rpc_failed; -} kqswnal_data_t; - -/* kqn_init state */ -#define KQN_INIT_NOTHING 0 /* MUST BE ZERO so zeroed state is initialised OK */ -#define KQN_INIT_DATA 1 -#define KQN_INIT_LIB 2 -#define KQN_INIT_ALL 3 - -extern lib_nal_t kqswnal_lib; -extern nal_t kqswnal_api; -extern kqswnal_tunables_t kqswnal_tunables; -extern kqswnal_data_t kqswnal_data; - -extern int kqswnal_thread_start (int (*fn)(void *arg), void *arg); -extern void kqswnal_rxhandler(EP_RXD *rxd); -extern int kqswnal_scheduler (void *); -extern void kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd); -extern void kqswnal_rx_done (kqswnal_rx_t *krx); - -static inline ptl_nid_t -kqswnal_elanid2nid (int elanid) -{ - return (kqswnal_data.kqn_nid_offset + elanid); -} - -static inline int -kqswnal_nid2elanid (ptl_nid_t nid) -{ - /* not in this cluster? */ - if (nid < kqswnal_data.kqn_nid_offset || - nid >= kqswnal_data.kqn_nid_offset + kqswnal_data.kqn_nnodes) - return (-1); - - return (nid - kqswnal_data.kqn_nid_offset); -} - -static inline ptl_nid_t -kqswnal_rx_nid(kqswnal_rx_t *krx) -{ - return (kqswnal_elanid2nid(ep_rxd_node(krx->krx_rxd))); -} - -static inline int -kqswnal_pages_spanned (void *base, int nob) -{ - unsigned long first_page = ((unsigned long)base) >> PAGE_SHIFT; - unsigned long last_page = (((unsigned long)base) + (nob - 1)) >> PAGE_SHIFT; - - LASSERT (last_page >= first_page); /* can't wrap address space */ - return (last_page - first_page + 1); -} - -#if KQSW_CHECKSUM -static inline kqsw_csum_t kqsw_csum (kqsw_csum_t sum, void *base, int nob) -{ - unsigned char *ptr = (unsigned char *)base; - - while (nob-- > 0) - sum += *ptr++; - - return (sum); -} -#endif - -static inline void kqswnal_rx_decref (kqswnal_rx_t *krx) -{ - LASSERT (atomic_read (&krx->krx_refcount) > 0); - if (atomic_dec_and_test (&krx->krx_refcount)) - kqswnal_rx_done(krx); -} - -#if MULTIRAIL_EKC -# ifndef EP_RAILMASK_ALL -# error "old (unsupported) version of EKC headers" -# endif -#else -/* multirail defines these in */ -#define EP_MSG_SVC_PORTALS_SMALL (0x10) /* Portals over elan port number (large payloads) */ -#define EP_MSG_SVC_PORTALS_LARGE (0x11) /* Portals over elan port number (small payloads) */ -/* NB small/large message sizes are GLOBAL constants */ - -/* A minimal attempt to minimise inline #ifdeffing */ - -#define EP_SUCCESS ESUCCESS -#define EP_ENOMEM ENOMEM - -static inline EP_XMTR * -ep_alloc_xmtr(EP_DEV *e) -{ - return (ep_alloc_large_xmtr(e)); -} - -static inline EP_RCVR * -ep_alloc_rcvr(EP_DEV *e, int svc, int nenv) -{ - return (ep_install_large_rcvr(e, svc, nenv)); -} - -static inline void -ep_free_xmtr(EP_XMTR *x) -{ - ep_free_large_xmtr(x); -} - -static inline void -ep_free_rcvr(EP_RCVR *r) -{ - ep_remove_large_rcvr(r); -} -#endif - -#endif /* _QSWNAL_H */ diff --git a/lnet/klnds/qswlnd/qswlnd_cb.c b/lnet/klnds/qswlnd/qswlnd_cb.c deleted file mode 100644 index 7aee376..0000000 --- a/lnet/klnds/qswlnd/qswlnd_cb.c +++ /dev/null @@ -1,2008 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * Author: Eric Barton - * - * Copyright (C) 2002, Lawrence Livermore National Labs (LLNL) - * W. Marcus Miller - Based on ksocknal - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include "qswnal.h" - -/* - * LIB functions follow - * - */ -static int -kqswnal_dist(lib_nal_t *nal, ptl_nid_t nid, unsigned long *dist) -{ - if (nid == nal->libnal_ni.ni_pid.nid) - *dist = 0; /* it's me */ - else if (kqswnal_nid2elanid (nid) >= 0) - *dist = 1; /* it's my peer */ - else - *dist = 2; /* via router */ - return (0); -} - -void -kqswnal_notify_peer_down(kqswnal_tx_t *ktx) -{ - struct timeval now; - time_t then; - - do_gettimeofday (&now); - then = now.tv_sec - (jiffies - ktx->ktx_launchtime)/HZ; - - kpr_notify(&kqswnal_data.kqn_router, ktx->ktx_nid, 0, then); -} - -void -kqswnal_unmap_tx (kqswnal_tx_t *ktx) -{ -#if MULTIRAIL_EKC - int i; - - ktx->ktx_rail = -1; /* unset rail */ -#endif - - if (ktx->ktx_nmappedpages == 0) - return; - -#if MULTIRAIL_EKC - CDEBUG(D_NET, "%p unloading %d frags starting at %d\n", - ktx, ktx->ktx_nfrag, ktx->ktx_firsttmpfrag); - - for (i = ktx->ktx_firsttmpfrag; i < ktx->ktx_nfrag; i++) - ep_dvma_unload(kqswnal_data.kqn_ep, - kqswnal_data.kqn_ep_tx_nmh, - &ktx->ktx_frags[i]); -#else - CDEBUG (D_NET, "%p[%d] unloading pages %d for %d\n", - ktx, ktx->ktx_nfrag, ktx->ktx_basepage, ktx->ktx_nmappedpages); - - LASSERT (ktx->ktx_nmappedpages <= ktx->ktx_npages); - LASSERT (ktx->ktx_basepage + ktx->ktx_nmappedpages <= - kqswnal_data.kqn_eptxdmahandle->NumDvmaPages); - - elan3_dvma_unload(kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eptxdmahandle, - ktx->ktx_basepage, ktx->ktx_nmappedpages); -#endif - ktx->ktx_nmappedpages = 0; -} - -int -kqswnal_map_tx_kiov (kqswnal_tx_t *ktx, int offset, int nob, int niov, ptl_kiov_t *kiov) -{ - int nfrags = ktx->ktx_nfrag; - int nmapped = ktx->ktx_nmappedpages; - int maxmapped = ktx->ktx_npages; - uint32_t basepage = ktx->ktx_basepage + nmapped; - char *ptr; -#if MULTIRAIL_EKC - EP_RAILMASK railmask; - int rail; - - if (ktx->ktx_rail < 0) - ktx->ktx_rail = ep_xmtr_prefrail(kqswnal_data.kqn_eptx, - EP_RAILMASK_ALL, - kqswnal_nid2elanid(ktx->ktx_nid)); - rail = ktx->ktx_rail; - if (rail < 0) { - CERROR("No rails available for "LPX64"\n", ktx->ktx_nid); - return (-ENETDOWN); - } - railmask = 1 << rail; -#endif - LASSERT (nmapped <= maxmapped); - LASSERT (nfrags >= ktx->ktx_firsttmpfrag); - LASSERT (nfrags <= EP_MAXFRAG); - LASSERT (niov > 0); - LASSERT (nob > 0); - - /* skip complete frags before 'offset' */ - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; - kiov++; - niov--; - LASSERT (niov > 0); - } - - do { - int fraglen = kiov->kiov_len - offset; - - /* each page frag is contained in one page */ - LASSERT (kiov->kiov_offset + kiov->kiov_len <= PAGE_SIZE); - - if (fraglen > nob) - fraglen = nob; - - nmapped++; - if (nmapped > maxmapped) { - CERROR("Can't map message in %d pages (max %d)\n", - nmapped, maxmapped); - return (-EMSGSIZE); - } - - if (nfrags == EP_MAXFRAG) { - CERROR("Message too fragmented in Elan VM (max %d frags)\n", - EP_MAXFRAG); - return (-EMSGSIZE); - } - - /* XXX this is really crap, but we'll have to kmap until - * EKC has a page (rather than vaddr) mapping interface */ - - ptr = ((char *)kmap (kiov->kiov_page)) + kiov->kiov_offset + offset; - - CDEBUG(D_NET, - "%p[%d] loading %p for %d, page %d, %d total\n", - ktx, nfrags, ptr, fraglen, basepage, nmapped); - -#if MULTIRAIL_EKC - ep_dvma_load(kqswnal_data.kqn_ep, NULL, - ptr, fraglen, - kqswnal_data.kqn_ep_tx_nmh, basepage, - &railmask, &ktx->ktx_frags[nfrags]); - - if (nfrags == ktx->ktx_firsttmpfrag || - !ep_nmd_merge(&ktx->ktx_frags[nfrags - 1], - &ktx->ktx_frags[nfrags - 1], - &ktx->ktx_frags[nfrags])) { - /* new frag if this is the first or can't merge */ - nfrags++; - } -#else - elan3_dvma_kaddr_load (kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eptxdmahandle, - ptr, fraglen, - basepage, &ktx->ktx_frags[nfrags].Base); - - if (nfrags > 0 && /* previous frag mapped */ - ktx->ktx_frags[nfrags].Base == /* contiguous with this one */ - (ktx->ktx_frags[nfrags-1].Base + ktx->ktx_frags[nfrags-1].Len)) - /* just extend previous */ - ktx->ktx_frags[nfrags - 1].Len += fraglen; - else { - ktx->ktx_frags[nfrags].Len = fraglen; - nfrags++; /* new frag */ - } -#endif - - kunmap (kiov->kiov_page); - - /* keep in loop for failure case */ - ktx->ktx_nmappedpages = nmapped; - - basepage++; - kiov++; - niov--; - nob -= fraglen; - offset = 0; - - /* iov must not run out before end of data */ - LASSERT (nob == 0 || niov > 0); - - } while (nob > 0); - - ktx->ktx_nfrag = nfrags; - CDEBUG (D_NET, "%p got %d frags over %d pages\n", - ktx, ktx->ktx_nfrag, ktx->ktx_nmappedpages); - - return (0); -} - -int -kqswnal_map_tx_iov (kqswnal_tx_t *ktx, int offset, int nob, - int niov, struct iovec *iov) -{ - int nfrags = ktx->ktx_nfrag; - int nmapped = ktx->ktx_nmappedpages; - int maxmapped = ktx->ktx_npages; - uint32_t basepage = ktx->ktx_basepage + nmapped; -#if MULTIRAIL_EKC - EP_RAILMASK railmask; - int rail; - - if (ktx->ktx_rail < 0) - ktx->ktx_rail = ep_xmtr_prefrail(kqswnal_data.kqn_eptx, - EP_RAILMASK_ALL, - kqswnal_nid2elanid(ktx->ktx_nid)); - rail = ktx->ktx_rail; - if (rail < 0) { - CERROR("No rails available for "LPX64"\n", ktx->ktx_nid); - return (-ENETDOWN); - } - railmask = 1 << rail; -#endif - LASSERT (nmapped <= maxmapped); - LASSERT (nfrags >= ktx->ktx_firsttmpfrag); - LASSERT (nfrags <= EP_MAXFRAG); - LASSERT (niov > 0); - LASSERT (nob > 0); - - /* skip complete frags before offset */ - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - iov++; - niov--; - LASSERT (niov > 0); - } - - do { - int fraglen = iov->iov_len - offset; - long npages; - - if (fraglen > nob) - fraglen = nob; - npages = kqswnal_pages_spanned (iov->iov_base, fraglen); - - nmapped += npages; - if (nmapped > maxmapped) { - CERROR("Can't map message in %d pages (max %d)\n", - nmapped, maxmapped); - return (-EMSGSIZE); - } - - if (nfrags == EP_MAXFRAG) { - CERROR("Message too fragmented in Elan VM (max %d frags)\n", - EP_MAXFRAG); - return (-EMSGSIZE); - } - - CDEBUG(D_NET, - "%p[%d] loading %p for %d, pages %d for %ld, %d total\n", - ktx, nfrags, iov->iov_base + offset, fraglen, - basepage, npages, nmapped); - -#if MULTIRAIL_EKC - ep_dvma_load(kqswnal_data.kqn_ep, NULL, - iov->iov_base + offset, fraglen, - kqswnal_data.kqn_ep_tx_nmh, basepage, - &railmask, &ktx->ktx_frags[nfrags]); - - if (nfrags == ktx->ktx_firsttmpfrag || - !ep_nmd_merge(&ktx->ktx_frags[nfrags - 1], - &ktx->ktx_frags[nfrags - 1], - &ktx->ktx_frags[nfrags])) { - /* new frag if this is the first or can't merge */ - nfrags++; - } -#else - elan3_dvma_kaddr_load (kqswnal_data.kqn_ep->DmaState, - kqswnal_data.kqn_eptxdmahandle, - iov->iov_base + offset, fraglen, - basepage, &ktx->ktx_frags[nfrags].Base); - - if (nfrags > 0 && /* previous frag mapped */ - ktx->ktx_frags[nfrags].Base == /* contiguous with this one */ - (ktx->ktx_frags[nfrags-1].Base + ktx->ktx_frags[nfrags-1].Len)) - /* just extend previous */ - ktx->ktx_frags[nfrags - 1].Len += fraglen; - else { - ktx->ktx_frags[nfrags].Len = fraglen; - nfrags++; /* new frag */ - } -#endif - - /* keep in loop for failure case */ - ktx->ktx_nmappedpages = nmapped; - - basepage += npages; - iov++; - niov--; - nob -= fraglen; - offset = 0; - - /* iov must not run out before end of data */ - LASSERT (nob == 0 || niov > 0); - - } while (nob > 0); - - ktx->ktx_nfrag = nfrags; - CDEBUG (D_NET, "%p got %d frags over %d pages\n", - ktx, ktx->ktx_nfrag, ktx->ktx_nmappedpages); - - return (0); -} - - -void -kqswnal_put_idle_tx (kqswnal_tx_t *ktx) -{ - kpr_fwd_desc_t *fwd = NULL; - unsigned long flags; - - kqswnal_unmap_tx (ktx); /* release temporary mappings */ - ktx->ktx_state = KTX_IDLE; - - spin_lock_irqsave (&kqswnal_data.kqn_idletxd_lock, flags); - - list_del (&ktx->ktx_list); /* take off active list */ - - if (ktx->ktx_isnblk) { - /* reserved for non-blocking tx */ - list_add (&ktx->ktx_list, &kqswnal_data.kqn_nblk_idletxds); - spin_unlock_irqrestore (&kqswnal_data.kqn_idletxd_lock, flags); - return; - } - - list_add (&ktx->ktx_list, &kqswnal_data.kqn_idletxds); - - /* anything blocking for a tx descriptor? */ - if (!kqswnal_data.kqn_shuttingdown && - !list_empty(&kqswnal_data.kqn_idletxd_fwdq)) /* forwarded packet? */ - { - CDEBUG(D_NET,"wakeup fwd\n"); - - fwd = list_entry (kqswnal_data.kqn_idletxd_fwdq.next, - kpr_fwd_desc_t, kprfd_list); - list_del (&fwd->kprfd_list); - } - - wake_up (&kqswnal_data.kqn_idletxd_waitq); - - spin_unlock_irqrestore (&kqswnal_data.kqn_idletxd_lock, flags); - - if (fwd == NULL) - return; - - /* schedule packet for forwarding again */ - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - - list_add_tail (&fwd->kprfd_list, &kqswnal_data.kqn_delayedfwds); - wake_up (&kqswnal_data.kqn_sched_waitq); - - spin_unlock_irqrestore (&kqswnal_data.kqn_sched_lock, flags); -} - -kqswnal_tx_t * -kqswnal_get_idle_tx (kpr_fwd_desc_t *fwd, int may_block) -{ - unsigned long flags; - kqswnal_tx_t *ktx = NULL; - - for (;;) { - spin_lock_irqsave (&kqswnal_data.kqn_idletxd_lock, flags); - - if (kqswnal_data.kqn_shuttingdown) - break; - - /* "normal" descriptor is free */ - if (!list_empty (&kqswnal_data.kqn_idletxds)) { - ktx = list_entry (kqswnal_data.kqn_idletxds.next, - kqswnal_tx_t, ktx_list); - break; - } - - if (fwd != NULL) /* forwarded packet? */ - break; - - /* doing a local transmit */ - if (!may_block) { - if (list_empty (&kqswnal_data.kqn_nblk_idletxds)) { - CERROR ("intr tx desc pool exhausted\n"); - break; - } - - ktx = list_entry (kqswnal_data.kqn_nblk_idletxds.next, - kqswnal_tx_t, ktx_list); - break; - } - - /* block for idle tx */ - - spin_unlock_irqrestore (&kqswnal_data.kqn_idletxd_lock, flags); - - CDEBUG (D_NET, "blocking for tx desc\n"); - wait_event (kqswnal_data.kqn_idletxd_waitq, - !list_empty (&kqswnal_data.kqn_idletxds) || - kqswnal_data.kqn_shuttingdown); - } - - if (ktx != NULL) { - list_del (&ktx->ktx_list); - list_add (&ktx->ktx_list, &kqswnal_data.kqn_activetxds); - ktx->ktx_launcher = current->pid; - atomic_inc(&kqswnal_data.kqn_pending_txs); - } else if (fwd != NULL) { - /* queue forwarded packet until idle txd available */ - CDEBUG (D_NET, "blocked fwd [%p]\n", fwd); - list_add_tail (&fwd->kprfd_list, - &kqswnal_data.kqn_idletxd_fwdq); - } - - spin_unlock_irqrestore (&kqswnal_data.kqn_idletxd_lock, flags); - - /* Idle descs can't have any mapped (as opposed to pre-mapped) pages */ - LASSERT (ktx == NULL || ktx->ktx_nmappedpages == 0); - - return (ktx); -} - -void -kqswnal_tx_done (kqswnal_tx_t *ktx, int error) -{ - switch (ktx->ktx_state) { - case KTX_FORWARDING: /* router asked me to forward this packet */ - kpr_fwd_done (&kqswnal_data.kqn_router, - (kpr_fwd_desc_t *)ktx->ktx_args[0], error); - break; - - case KTX_RDMAING: /* optimized GET/PUT handled */ - case KTX_PUTTING: /* optimized PUT sent */ - case KTX_SENDING: /* normal send */ - lib_finalize (&kqswnal_lib, NULL, - (lib_msg_t *)ktx->ktx_args[1], - (error == 0) ? PTL_OK : PTL_FAIL); - break; - - case KTX_GETTING: /* optimized GET sent & REPLY received */ - /* Complete the GET with success since we can't avoid - * delivering a REPLY event; we committed to it when we - * launched the GET */ - lib_finalize (&kqswnal_lib, NULL, - (lib_msg_t *)ktx->ktx_args[1], PTL_OK); - lib_finalize (&kqswnal_lib, NULL, - (lib_msg_t *)ktx->ktx_args[2], - (error == 0) ? PTL_OK : PTL_FAIL); - break; - - default: - LASSERT (0); - } - - kqswnal_put_idle_tx (ktx); -} - -static void -kqswnal_txhandler(EP_TXD *txd, void *arg, int status) -{ - kqswnal_tx_t *ktx = (kqswnal_tx_t *)arg; - - LASSERT (txd != NULL); - LASSERT (ktx != NULL); - - CDEBUG(D_NET, "txd %p, arg %p status %d\n", txd, arg, status); - - if (status != EP_SUCCESS) { - - CERROR ("Tx completion to "LPX64" failed: %d\n", - ktx->ktx_nid, status); - - kqswnal_notify_peer_down(ktx); - status = -EHOSTDOWN; - - } else switch (ktx->ktx_state) { - - case KTX_GETTING: - case KTX_PUTTING: - /* RPC completed OK; but what did our peer put in the status - * block? */ -#if MULTIRAIL_EKC - status = ep_txd_statusblk(txd)->Data[0]; -#else - status = ep_txd_statusblk(txd)->Status; -#endif - break; - - case KTX_FORWARDING: - case KTX_SENDING: - status = 0; - break; - - default: - LBUG(); - break; - } - - kqswnal_tx_done (ktx, status); -} - -int -kqswnal_launch (kqswnal_tx_t *ktx) -{ - /* Don't block for transmit descriptor if we're in interrupt context */ - int attr = in_interrupt() ? (EP_NO_SLEEP | EP_NO_ALLOC) : 0; - int dest = kqswnal_nid2elanid (ktx->ktx_nid); - unsigned long flags; - int rc; - - ktx->ktx_launchtime = jiffies; - - if (kqswnal_data.kqn_shuttingdown) - return (-ESHUTDOWN); - - LASSERT (dest >= 0); /* must be a peer */ - -#if MULTIRAIL_EKC - if (ktx->ktx_nmappedpages != 0) - attr = EP_SET_PREFRAIL(attr, ktx->ktx_rail); -#endif - - switch (ktx->ktx_state) { - case KTX_GETTING: - case KTX_PUTTING: - /* NB ktx_frag[0] is the GET/PUT hdr + kqswnal_remotemd_t. - * The other frags are the payload, awaiting RDMA */ - rc = ep_transmit_rpc(kqswnal_data.kqn_eptx, dest, - ktx->ktx_port, attr, - kqswnal_txhandler, ktx, - NULL, ktx->ktx_frags, 1); - break; - - case KTX_FORWARDING: - case KTX_SENDING: -#if MULTIRAIL_EKC - rc = ep_transmit_message(kqswnal_data.kqn_eptx, dest, - ktx->ktx_port, attr, - kqswnal_txhandler, ktx, - NULL, ktx->ktx_frags, ktx->ktx_nfrag); -#else - rc = ep_transmit_large(kqswnal_data.kqn_eptx, dest, - ktx->ktx_port, attr, - kqswnal_txhandler, ktx, - ktx->ktx_frags, ktx->ktx_nfrag); -#endif - break; - - default: - LBUG(); - rc = -EINVAL; /* no compiler warning please */ - break; - } - - switch (rc) { - case EP_SUCCESS: /* success */ - return (0); - - case EP_ENOMEM: /* can't allocate ep txd => queue for later */ - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - - list_add_tail (&ktx->ktx_delayed_list, &kqswnal_data.kqn_delayedtxds); - wake_up (&kqswnal_data.kqn_sched_waitq); - - spin_unlock_irqrestore (&kqswnal_data.kqn_sched_lock, flags); - return (0); - - default: /* fatal error */ - CERROR ("Tx to "LPX64" failed: %d\n", ktx->ktx_nid, rc); - kqswnal_notify_peer_down(ktx); - return (-EHOSTUNREACH); - } -} - -#if 0 -static char * -hdr_type_string (ptl_hdr_t *hdr) -{ - switch (hdr->type) { - case PTL_MSG_ACK: - return ("ACK"); - case PTL_MSG_PUT: - return ("PUT"); - case PTL_MSG_GET: - return ("GET"); - case PTL_MSG_REPLY: - return ("REPLY"); - default: - return (""); - } -} - -static void -kqswnal_cerror_hdr(ptl_hdr_t * hdr) -{ - char *type_str = hdr_type_string (hdr); - - CERROR("P3 Header at %p of type %s length %d\n", hdr, type_str, - le32_to_cpu(hdr->payload_length)); - CERROR(" From nid/pid "LPU64"/%u\n", le64_to_cpu(hdr->src_nid), - le32_to_cpu(hdr->src_pid)); - CERROR(" To nid/pid "LPU64"/%u\n", le64_to_cpu(hdr->dest_nid), - le32_to_cpu(hdr->dest_pid)); - - switch (le32_to_cpu(hdr->type)) { - case PTL_MSG_PUT: - CERROR(" Ptl index %d, ack md "LPX64"."LPX64", " - "match bits "LPX64"\n", - le32_to_cpu(hdr->msg.put.ptl_index), - hdr->msg.put.ack_wmd.wh_interface_cookie, - hdr->msg.put.ack_wmd.wh_object_cookie, - le64_to_cpu(hdr->msg.put.match_bits)); - CERROR(" offset %d, hdr data "LPX64"\n", - le32_to_cpu(hdr->msg.put.offset), - hdr->msg.put.hdr_data); - break; - - case PTL_MSG_GET: - CERROR(" Ptl index %d, return md "LPX64"."LPX64", " - "match bits "LPX64"\n", - le32_to_cpu(hdr->msg.get.ptl_index), - hdr->msg.get.return_wmd.wh_interface_cookie, - hdr->msg.get.return_wmd.wh_object_cookie, - hdr->msg.get.match_bits); - CERROR(" Length %d, src offset %d\n", - le32_to_cpu(hdr->msg.get.sink_length), - le32_to_cpu(hdr->msg.get.src_offset)); - break; - - case PTL_MSG_ACK: - CERROR(" dst md "LPX64"."LPX64", manipulated length %d\n", - hdr->msg.ack.dst_wmd.wh_interface_cookie, - hdr->msg.ack.dst_wmd.wh_object_cookie, - le32_to_cpu(hdr->msg.ack.mlength)); - break; - - case PTL_MSG_REPLY: - CERROR(" dst md "LPX64"."LPX64"\n", - hdr->msg.reply.dst_wmd.wh_interface_cookie, - hdr->msg.reply.dst_wmd.wh_object_cookie); - } - -} /* end of print_hdr() */ -#endif - -#if !MULTIRAIL_EKC -void -kqswnal_print_eiov (int how, char *str, int n, EP_IOVEC *iov) -{ - int i; - - CDEBUG (how, "%s: %d\n", str, n); - for (i = 0; i < n; i++) { - CDEBUG (how, " %08x for %d\n", iov[i].Base, iov[i].Len); - } -} - -int -kqswnal_eiovs2datav (int ndv, EP_DATAVEC *dv, - int nsrc, EP_IOVEC *src, - int ndst, EP_IOVEC *dst) -{ - int count; - int nob; - - LASSERT (ndv > 0); - LASSERT (nsrc > 0); - LASSERT (ndst > 0); - - for (count = 0; count < ndv; count++, dv++) { - - if (nsrc == 0 || ndst == 0) { - if (nsrc != ndst) { - /* For now I'll barf on any left over entries */ - CERROR ("mismatched src and dst iovs\n"); - return (-EINVAL); - } - return (count); - } - - nob = (src->Len < dst->Len) ? src->Len : dst->Len; - dv->Len = nob; - dv->Source = src->Base; - dv->Dest = dst->Base; - - if (nob >= src->Len) { - src++; - nsrc--; - } else { - src->Len -= nob; - src->Base += nob; - } - - if (nob >= dst->Len) { - dst++; - ndst--; - } else { - src->Len -= nob; - src->Base += nob; - } - } - - CERROR ("DATAVEC too small\n"); - return (-E2BIG); -} -#else -int -kqswnal_check_rdma (int nlfrag, EP_NMD *lfrag, - int nrfrag, EP_NMD *rfrag) -{ - int i; - - if (nlfrag != nrfrag) { - CERROR("Can't cope with unequal # frags: %d local %d remote\n", - nlfrag, nrfrag); - return (-EINVAL); - } - - for (i = 0; i < nlfrag; i++) - if (lfrag[i].nmd_len != rfrag[i].nmd_len) { - CERROR("Can't cope with unequal frags %d(%d):" - " %d local %d remote\n", - i, nlfrag, lfrag[i].nmd_len, rfrag[i].nmd_len); - return (-EINVAL); - } - - return (0); -} -#endif - -kqswnal_remotemd_t * -kqswnal_parse_rmd (kqswnal_rx_t *krx, int type, ptl_nid_t expected_nid) -{ - char *buffer = (char *)page_address(krx->krx_kiov[0].kiov_page); - ptl_hdr_t *hdr = (ptl_hdr_t *)buffer; - kqswnal_remotemd_t *rmd = (kqswnal_remotemd_t *)(buffer + KQSW_HDR_SIZE); - ptl_nid_t nid = kqswnal_rx_nid(krx); - - /* Note (1) lib_parse has already flipped hdr. - * (2) RDMA addresses are sent in native endian-ness. When - * EKC copes with different endian nodes, I'll fix this (and - * eat my hat :) */ - - LASSERT (krx->krx_nob >= sizeof(*hdr)); - - if (hdr->type != type) { - CERROR ("Unexpected optimized get/put type %d (%d expected)" - "from "LPX64"\n", hdr->type, type, nid); - return (NULL); - } - - if (hdr->src_nid != nid) { - CERROR ("Unexpected optimized get/put source NID " - LPX64" from "LPX64"\n", hdr->src_nid, nid); - return (NULL); - } - - LASSERT (nid == expected_nid); - - if (buffer + krx->krx_nob < (char *)(rmd + 1)) { - /* msg too small to discover rmd size */ - CERROR ("Incoming message [%d] too small for RMD (%d needed)\n", - krx->krx_nob, (int)(((char *)(rmd + 1)) - buffer)); - return (NULL); - } - - if (buffer + krx->krx_nob < (char *)&rmd->kqrmd_frag[rmd->kqrmd_nfrag]) { - /* rmd doesn't fit in the incoming message */ - CERROR ("Incoming message [%d] too small for RMD[%d] (%d needed)\n", - krx->krx_nob, rmd->kqrmd_nfrag, - (int)(((char *)&rmd->kqrmd_frag[rmd->kqrmd_nfrag]) - buffer)); - return (NULL); - } - - return (rmd); -} - -void -kqswnal_rdma_store_complete (EP_RXD *rxd) -{ - int status = ep_rxd_status(rxd); - kqswnal_tx_t *ktx = (kqswnal_tx_t *)ep_rxd_arg(rxd); - kqswnal_rx_t *krx = (kqswnal_rx_t *)ktx->ktx_args[0]; - - CDEBUG((status == EP_SUCCESS) ? D_NET : D_ERROR, - "rxd %p, ktx %p, status %d\n", rxd, ktx, status); - - LASSERT (ktx->ktx_state == KTX_RDMAING); - LASSERT (krx->krx_rxd == rxd); - LASSERT (krx->krx_rpc_reply_needed); - - krx->krx_rpc_reply_needed = 0; - kqswnal_rx_decref (krx); - - /* free ktx & finalize() its lib_msg_t */ - kqswnal_tx_done(ktx, (status == EP_SUCCESS) ? 0 : -ECONNABORTED); -} - -void -kqswnal_rdma_fetch_complete (EP_RXD *rxd) -{ - /* Completed fetching the PUT data */ - int status = ep_rxd_status(rxd); - kqswnal_tx_t *ktx = (kqswnal_tx_t *)ep_rxd_arg(rxd); - kqswnal_rx_t *krx = (kqswnal_rx_t *)ktx->ktx_args[0]; - unsigned long flags; - - CDEBUG((status == EP_SUCCESS) ? D_NET : D_ERROR, - "rxd %p, ktx %p, status %d\n", rxd, ktx, status); - - LASSERT (ktx->ktx_state == KTX_RDMAING); - LASSERT (krx->krx_rxd == rxd); - /* RPC completes with failure by default */ - LASSERT (krx->krx_rpc_reply_needed); - LASSERT (krx->krx_rpc_reply_status != 0); - - if (status == EP_SUCCESS) { - status = krx->krx_rpc_reply_status = 0; - } else { - /* Abandon RPC since get failed */ - krx->krx_rpc_reply_needed = 0; - status = -ECONNABORTED; - } - - /* free ktx & finalize() its lib_msg_t */ - kqswnal_tx_done(ktx, status); - - if (!in_interrupt()) { - /* OK to complete the RPC now (iff I had the last ref) */ - kqswnal_rx_decref (krx); - return; - } - - LASSERT (krx->krx_state == KRX_PARSE); - krx->krx_state = KRX_COMPLETING; - - /* Complete the RPC in thread context */ - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - - list_add_tail (&krx->krx_list, &kqswnal_data.kqn_readyrxds); - wake_up (&kqswnal_data.kqn_sched_waitq); - - spin_unlock_irqrestore (&kqswnal_data.kqn_sched_lock, flags); -} - -int -kqswnal_rdma (kqswnal_rx_t *krx, lib_msg_t *libmsg, int type, - int niov, struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t len) -{ - kqswnal_remotemd_t *rmd; - kqswnal_tx_t *ktx; - int eprc; - int rc; -#if !MULTIRAIL_EKC - EP_DATAVEC datav[EP_MAXFRAG]; - int ndatav; -#endif - - LASSERT (type == PTL_MSG_GET || type == PTL_MSG_PUT); - /* Not both mapped and paged payload */ - LASSERT (iov == NULL || kiov == NULL); - /* RPC completes with failure by default */ - LASSERT (krx->krx_rpc_reply_needed); - LASSERT (krx->krx_rpc_reply_status != 0); - - rmd = kqswnal_parse_rmd(krx, type, libmsg->ev.initiator.nid); - if (rmd == NULL) - return (-EPROTO); - - if (len == 0) { - /* data got truncated to nothing. */ - lib_finalize(&kqswnal_lib, krx, libmsg, PTL_OK); - /* Let kqswnal_rx_done() complete the RPC with success */ - krx->krx_rpc_reply_status = 0; - return (0); - } - - /* NB I'm using 'ktx' just to map the local RDMA buffers; I'm not - actually sending a portals message with it */ - ktx = kqswnal_get_idle_tx(NULL, 0); - if (ktx == NULL) { - CERROR ("Can't get txd for RDMA with "LPX64"\n", - libmsg->ev.initiator.nid); - return (-ENOMEM); - } - - ktx->ktx_state = KTX_RDMAING; - ktx->ktx_nid = libmsg->ev.initiator.nid; - ktx->ktx_args[0] = krx; - ktx->ktx_args[1] = libmsg; - -#if MULTIRAIL_EKC - /* Map on the rail the RPC prefers */ - ktx->ktx_rail = ep_rcvr_prefrail(krx->krx_eprx, - ep_rxd_railmask(krx->krx_rxd)); -#endif - - /* Start mapping at offset 0 (we're not mapping any headers) */ - ktx->ktx_nfrag = ktx->ktx_firsttmpfrag = 0; - - if (kiov != NULL) - rc = kqswnal_map_tx_kiov(ktx, offset, len, niov, kiov); - else - rc = kqswnal_map_tx_iov(ktx, offset, len, niov, iov); - - if (rc != 0) { - CERROR ("Can't map local RDMA data: %d\n", rc); - goto out; - } - -#if MULTIRAIL_EKC - rc = kqswnal_check_rdma (ktx->ktx_nfrag, ktx->ktx_frags, - rmd->kqrmd_nfrag, rmd->kqrmd_frag); - if (rc != 0) { - CERROR ("Incompatible RDMA descriptors\n"); - goto out; - } -#else - switch (type) { - default: - LBUG(); - - case PTL_MSG_GET: - ndatav = kqswnal_eiovs2datav(EP_MAXFRAG, datav, - ktx->ktx_nfrag, ktx->ktx_frags, - rmd->kqrmd_nfrag, rmd->kqrmd_frag); - break; - - case PTL_MSG_PUT: - ndatav = kqswnal_eiovs2datav(EP_MAXFRAG, datav, - rmd->kqrmd_nfrag, rmd->kqrmd_frag, - ktx->ktx_nfrag, ktx->ktx_frags); - break; - } - - if (ndatav < 0) { - CERROR ("Can't create datavec: %d\n", ndatav); - rc = ndatav; - goto out; - } -#endif - - LASSERT (atomic_read(&krx->krx_refcount) > 0); - /* Take an extra ref for the completion callback */ - atomic_inc(&krx->krx_refcount); - - switch (type) { - default: - LBUG(); - - case PTL_MSG_GET: -#if MULTIRAIL_EKC - eprc = ep_complete_rpc(krx->krx_rxd, - kqswnal_rdma_store_complete, ktx, - &kqswnal_data.kqn_rpc_success, - ktx->ktx_frags, rmd->kqrmd_frag, rmd->kqrmd_nfrag); -#else - eprc = ep_complete_rpc (krx->krx_rxd, - kqswnal_rdma_store_complete, ktx, - &kqswnal_data.kqn_rpc_success, - datav, ndatav); - if (eprc != EP_SUCCESS) /* "old" EKC destroys rxd on failed completion */ - krx->krx_rxd = NULL; -#endif - if (eprc != EP_SUCCESS) { - CERROR("can't complete RPC: %d\n", eprc); - /* don't re-attempt RPC completion */ - krx->krx_rpc_reply_needed = 0; - rc = -ECONNABORTED; - } - break; - - case PTL_MSG_PUT: -#if MULTIRAIL_EKC - eprc = ep_rpc_get (krx->krx_rxd, - kqswnal_rdma_fetch_complete, ktx, - rmd->kqrmd_frag, ktx->ktx_frags, ktx->ktx_nfrag); -#else - eprc = ep_rpc_get (krx->krx_rxd, - kqswnal_rdma_fetch_complete, ktx, - datav, ndatav); -#endif - if (eprc != EP_SUCCESS) { - CERROR("ep_rpc_get failed: %d\n", eprc); - /* Don't attempt RPC completion: - * EKC nuked it when the get failed */ - krx->krx_rpc_reply_needed = 0; - rc = -ECONNABORTED; - } - break; - } - - out: - if (rc != 0) { - kqswnal_rx_decref(krx); /* drop callback's ref */ - kqswnal_put_idle_tx (ktx); - } - - atomic_dec(&kqswnal_data.kqn_pending_txs); - return (rc); -} - -static ptl_err_t -kqswnal_sendmsg (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - struct iovec *payload_iov, - ptl_kiov_t *payload_kiov, - size_t payload_offset, - size_t payload_nob) -{ - kqswnal_tx_t *ktx; - int rc; - ptl_nid_t targetnid; -#if KQSW_CHECKSUM - int i; - kqsw_csum_t csum; - int sumoff; - int sumnob; -#endif - /* NB 1. hdr is in network byte order */ - /* 2. 'private' depends on the message type */ - - CDEBUG(D_NET, "sending "LPSZ" bytes in %d frags to nid: "LPX64 - " pid %u\n", payload_nob, payload_niov, nid, pid); - - LASSERT (payload_nob == 0 || payload_niov > 0); - LASSERT (payload_niov <= PTL_MD_MAX_IOV); - - /* It must be OK to kmap() if required */ - LASSERT (payload_kiov == NULL || !in_interrupt ()); - /* payload is either all vaddrs or all pages */ - LASSERT (!(payload_kiov != NULL && payload_iov != NULL)); - - if (payload_nob > KQSW_MAXPAYLOAD) { - CERROR ("request exceeds MTU size "LPSZ" (max %u).\n", - payload_nob, KQSW_MAXPAYLOAD); - return (PTL_FAIL); - } - - if (type == PTL_MSG_REPLY && /* can I look in 'private' */ - ((kqswnal_rx_t *)private)->krx_rpc_reply_needed) { /* is it an RPC */ - /* Must be a REPLY for an optimized GET */ - rc = kqswnal_rdma ((kqswnal_rx_t *)private, libmsg, PTL_MSG_GET, - payload_niov, payload_iov, payload_kiov, - payload_offset, payload_nob); - return ((rc == 0) ? PTL_OK : PTL_FAIL); - } - - targetnid = nid; - if (kqswnal_nid2elanid (nid) < 0) { /* Can't send direct: find gateway? */ - rc = kpr_lookup (&kqswnal_data.kqn_router, nid, - sizeof (ptl_hdr_t) + payload_nob, &targetnid); - if (rc != 0) { - CERROR("Can't route to "LPX64": router error %d\n", - nid, rc); - return (PTL_FAIL); - } - if (kqswnal_nid2elanid (targetnid) < 0) { - CERROR("Bad gateway "LPX64" for "LPX64"\n", - targetnid, nid); - return (PTL_FAIL); - } - } - - /* I may not block for a transmit descriptor if I might block the - * receiver, or an interrupt handler. */ - ktx = kqswnal_get_idle_tx(NULL, !(type == PTL_MSG_ACK || - type == PTL_MSG_REPLY || - in_interrupt())); - if (ktx == NULL) { - CERROR ("Can't get txd for msg type %d for "LPX64"\n", - type, libmsg->ev.initiator.nid); - return (PTL_NO_SPACE); - } - - ktx->ktx_state = KTX_SENDING; - ktx->ktx_nid = targetnid; - ktx->ktx_args[0] = private; - ktx->ktx_args[1] = libmsg; - ktx->ktx_args[2] = NULL; /* set when a GET commits to REPLY */ - - memcpy (ktx->ktx_buffer, hdr, sizeof (*hdr)); /* copy hdr from caller's stack */ - -#if KQSW_CHECKSUM - csum = kqsw_csum (0, (char *)hdr, sizeof (*hdr)); - memcpy (ktx->ktx_buffer + sizeof (*hdr), &csum, sizeof (csum)); - for (csum = 0, i = 0, sumoff = payload_offset, sumnob = payload_nob; sumnob > 0; i++) { - LASSERT(i < niov); - if (payload_kiov != NULL) { - ptl_kiov_t *kiov = &payload_kiov[i]; - - if (sumoff >= kiov->kiov_len) { - sumoff -= kiov->kiov_len; - } else { - char *addr = ((char *)kmap (kiov->kiov_page)) + - kiov->kiov_offset + sumoff; - int fragnob = kiov->kiov_len - sumoff; - - csum = kqsw_csum(csum, addr, MIN(sumnob, fragnob)); - sumnob -= fragnob; - sumoff = 0; - kunmap(kiov->kiov_page); - } - } else { - struct iovec *iov = &payload_iov[i]; - - if (sumoff > iov->iov_len) { - sumoff -= iov->iov_len; - } else { - char *addr = iov->iov_base + sumoff; - int fragnob = iov->iov_len - sumoff; - - csum = kqsw_csum(csum, addr, MIN(sumnob, fragnob)); - sumnob -= fragnob; - sumoff = 0; - } - } - } - memcpy(ktx->ktx_buffer + sizeof(*hdr) + sizeof(csum), &csum, sizeof(csum)); -#endif - - /* The first frag will be the pre-mapped buffer for (at least) the - * portals header. */ - ktx->ktx_nfrag = ktx->ktx_firsttmpfrag = 1; - - if (nid == targetnid && /* not forwarding */ - ((type == PTL_MSG_GET && /* optimize GET? */ - kqswnal_tunables.kqn_optimized_gets != 0 && - le32_to_cpu(hdr->msg.get.sink_length) >= kqswnal_tunables.kqn_optimized_gets) || - (type == PTL_MSG_PUT && /* optimize PUT? */ - kqswnal_tunables.kqn_optimized_puts != 0 && - payload_nob >= kqswnal_tunables.kqn_optimized_puts))) { - lib_md_t *md = libmsg->md; - kqswnal_remotemd_t *rmd = (kqswnal_remotemd_t *)(ktx->ktx_buffer + KQSW_HDR_SIZE); - - /* Optimised path: I send over the Elan vaddrs of the local - * buffers, and my peer DMAs directly to/from them. - * - * First I set up ktx as if it was going to send this - * payload, (it needs to map it anyway). This fills - * ktx_frags[1] and onward with the network addresses - * of the GET sink frags. I copy these into ktx_buffer, - * immediately after the header, and send that as my - * message. */ - - ktx->ktx_state = (type == PTL_MSG_PUT) ? KTX_PUTTING : KTX_GETTING; - - if ((libmsg->md->options & PTL_MD_KIOV) != 0) - rc = kqswnal_map_tx_kiov (ktx, 0, md->length, - md->md_niov, md->md_iov.kiov); - else - rc = kqswnal_map_tx_iov (ktx, 0, md->length, - md->md_niov, md->md_iov.iov); - if (rc != 0) - goto out; - - rmd->kqrmd_nfrag = ktx->ktx_nfrag - 1; - - payload_nob = offsetof(kqswnal_remotemd_t, - kqrmd_frag[rmd->kqrmd_nfrag]); - LASSERT (KQSW_HDR_SIZE + payload_nob <= KQSW_TX_BUFFER_SIZE); - -#if MULTIRAIL_EKC - memcpy(&rmd->kqrmd_frag[0], &ktx->ktx_frags[1], - rmd->kqrmd_nfrag * sizeof(EP_NMD)); - - ep_nmd_subset(&ktx->ktx_frags[0], &ktx->ktx_ebuffer, - 0, KQSW_HDR_SIZE + payload_nob); -#else - memcpy(&rmd->kqrmd_frag[0], &ktx->ktx_frags[1], - rmd->kqrmd_nfrag * sizeof(EP_IOVEC)); - - ktx->ktx_frags[0].Base = ktx->ktx_ebuffer; - ktx->ktx_frags[0].Len = KQSW_HDR_SIZE + payload_nob; -#endif - if (type == PTL_MSG_GET) { - /* Allocate reply message now while I'm in thread context */ - ktx->ktx_args[2] = lib_create_reply_msg (&kqswnal_lib, - nid, libmsg); - if (ktx->ktx_args[2] == NULL) - goto out; - - /* NB finalizing the REPLY message is my - * responsibility now, whatever happens. */ - } - - } else if (payload_nob <= KQSW_TX_MAXCONTIG) { - - /* small message: single frag copied into the pre-mapped buffer */ - -#if MULTIRAIL_EKC - ep_nmd_subset(&ktx->ktx_frags[0], &ktx->ktx_ebuffer, - 0, KQSW_HDR_SIZE + payload_nob); -#else - ktx->ktx_frags[0].Base = ktx->ktx_ebuffer; - ktx->ktx_frags[0].Len = KQSW_HDR_SIZE + payload_nob; -#endif - if (payload_nob > 0) { - if (payload_kiov != NULL) - lib_copy_kiov2buf (ktx->ktx_buffer + KQSW_HDR_SIZE, - payload_niov, payload_kiov, - payload_offset, payload_nob); - else - lib_copy_iov2buf (ktx->ktx_buffer + KQSW_HDR_SIZE, - payload_niov, payload_iov, - payload_offset, payload_nob); - } - } else { - - /* large message: multiple frags: first is hdr in pre-mapped buffer */ - -#if MULTIRAIL_EKC - ep_nmd_subset(&ktx->ktx_frags[0], &ktx->ktx_ebuffer, - 0, KQSW_HDR_SIZE); -#else - ktx->ktx_frags[0].Base = ktx->ktx_ebuffer; - ktx->ktx_frags[0].Len = KQSW_HDR_SIZE; -#endif - if (payload_kiov != NULL) - rc = kqswnal_map_tx_kiov (ktx, payload_offset, payload_nob, - payload_niov, payload_kiov); - else - rc = kqswnal_map_tx_iov (ktx, payload_offset, payload_nob, - payload_niov, payload_iov); - if (rc != 0) - goto out; - } - - ktx->ktx_port = (payload_nob <= KQSW_SMALLPAYLOAD) ? - EP_MSG_SVC_PORTALS_SMALL : EP_MSG_SVC_PORTALS_LARGE; - - rc = kqswnal_launch (ktx); - - out: - CDEBUG(rc == 0 ? D_NET : D_ERROR, - "%s "LPSZ" bytes to "LPX64" via "LPX64": rc %d\n", - rc == 0 ? "Sent" : "Failed to send", - payload_nob, nid, targetnid, rc); - - if (rc != 0) { - if (ktx->ktx_state == KTX_GETTING && - ktx->ktx_args[2] != NULL) { - /* We committed to reply, but there was a problem - * launching the GET. We can't avoid delivering a - * REPLY event since we committed above, so we - * pretend the GET succeeded but the REPLY - * failed. */ - rc = 0; - lib_finalize (&kqswnal_lib, private, libmsg, PTL_OK); - lib_finalize (&kqswnal_lib, private, - (lib_msg_t *)ktx->ktx_args[2], PTL_FAIL); - } - - kqswnal_put_idle_tx (ktx); - } - - atomic_dec(&kqswnal_data.kqn_pending_txs); - return (rc == 0 ? PTL_OK : PTL_FAIL); -} - -static ptl_err_t -kqswnal_send (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - struct iovec *payload_iov, - size_t payload_offset, - size_t payload_nob) -{ - return (kqswnal_sendmsg (nal, private, libmsg, hdr, type, nid, pid, - payload_niov, payload_iov, NULL, - payload_offset, payload_nob)); -} - -static ptl_err_t -kqswnal_send_pages (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - ptl_kiov_t *payload_kiov, - size_t payload_offset, - size_t payload_nob) -{ - return (kqswnal_sendmsg (nal, private, libmsg, hdr, type, nid, pid, - payload_niov, NULL, payload_kiov, - payload_offset, payload_nob)); -} - -void -kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd) -{ - int rc; - kqswnal_tx_t *ktx; - ptl_kiov_t *kiov = fwd->kprfd_kiov; - int niov = fwd->kprfd_niov; - int nob = fwd->kprfd_nob; - ptl_nid_t nid = fwd->kprfd_gateway_nid; - -#if KQSW_CHECKSUM - CERROR ("checksums for forwarded packets not implemented\n"); - LBUG (); -#endif - /* The router wants this NAL to forward a packet */ - CDEBUG (D_NET, "forwarding [%p] to "LPX64", payload: %d frags %d bytes\n", - fwd, nid, niov, nob); - - ktx = kqswnal_get_idle_tx (fwd, 0); - if (ktx == NULL) /* can't get txd right now */ - return; /* fwd will be scheduled when tx desc freed */ - - if (nid == kqswnal_lib.libnal_ni.ni_pid.nid) /* gateway is me */ - nid = fwd->kprfd_target_nid; /* target is final dest */ - - if (kqswnal_nid2elanid (nid) < 0) { - CERROR("Can't forward [%p] to "LPX64": not a peer\n", fwd, nid); - rc = -EHOSTUNREACH; - goto out; - } - - /* copy hdr into pre-mapped buffer */ - memcpy(ktx->ktx_buffer, fwd->kprfd_hdr, sizeof(ptl_hdr_t)); - - ktx->ktx_port = (nob <= KQSW_SMALLPAYLOAD) ? - EP_MSG_SVC_PORTALS_SMALL : EP_MSG_SVC_PORTALS_LARGE; - ktx->ktx_nid = nid; - ktx->ktx_state = KTX_FORWARDING; - ktx->ktx_args[0] = fwd; - ktx->ktx_nfrag = ktx->ktx_firsttmpfrag = 1; - - if (nob <= KQSW_TX_MAXCONTIG) - { - /* send payload from ktx's pre-mapped contiguous buffer */ -#if MULTIRAIL_EKC - ep_nmd_subset(&ktx->ktx_frags[0], &ktx->ktx_ebuffer, - 0, KQSW_HDR_SIZE + nob); -#else - ktx->ktx_frags[0].Base = ktx->ktx_ebuffer; - ktx->ktx_frags[0].Len = KQSW_HDR_SIZE + nob; -#endif - if (nob > 0) - lib_copy_kiov2buf(ktx->ktx_buffer + KQSW_HDR_SIZE, - niov, kiov, 0, nob); - } - else - { - /* zero copy payload */ -#if MULTIRAIL_EKC - ep_nmd_subset(&ktx->ktx_frags[0], &ktx->ktx_ebuffer, - 0, KQSW_HDR_SIZE); -#else - ktx->ktx_frags[0].Base = ktx->ktx_ebuffer; - ktx->ktx_frags[0].Len = KQSW_HDR_SIZE; -#endif - rc = kqswnal_map_tx_kiov (ktx, 0, nob, niov, kiov); - if (rc != 0) - goto out; - } - - rc = kqswnal_launch (ktx); - out: - if (rc != 0) { - CERROR ("Failed to forward [%p] to "LPX64": %d\n", fwd, nid, rc); - - /* complete now (with failure) */ - kqswnal_tx_done (ktx, rc); - } - - atomic_dec(&kqswnal_data.kqn_pending_txs); -} - -void -kqswnal_fwd_callback (void *arg, int error) -{ - kqswnal_rx_t *krx = (kqswnal_rx_t *)arg; - - /* The router has finished forwarding this packet */ - - if (error != 0) - { - ptl_hdr_t *hdr = (ptl_hdr_t *)page_address (krx->krx_kiov[0].kiov_page); - - CERROR("Failed to route packet from "LPX64" to "LPX64": %d\n", - le64_to_cpu(hdr->src_nid), le64_to_cpu(hdr->dest_nid),error); - } - - LASSERT (atomic_read(&krx->krx_refcount) == 1); - kqswnal_rx_decref (krx); -} - -void -kqswnal_requeue_rx (kqswnal_rx_t *krx) -{ - LASSERT (atomic_read(&krx->krx_refcount) == 0); - LASSERT (!krx->krx_rpc_reply_needed); - - krx->krx_state = KRX_POSTED; - -#if MULTIRAIL_EKC - if (kqswnal_data.kqn_shuttingdown) { - /* free EKC rxd on shutdown */ - ep_complete_receive(krx->krx_rxd); - } else { - /* repost receive */ - ep_requeue_receive(krx->krx_rxd, - kqswnal_rxhandler, krx, - &krx->krx_elanbuffer, 0); - } -#else - if (kqswnal_data.kqn_shuttingdown) - return; - - if (krx->krx_rxd == NULL) { - /* We had a failed ep_complete_rpc() which nukes the - * descriptor in "old" EKC */ - int eprc = ep_queue_receive(krx->krx_eprx, - kqswnal_rxhandler, krx, - krx->krx_elanbuffer, - krx->krx_npages * PAGE_SIZE, 0); - LASSERT (eprc == EP_SUCCESS); - /* We don't handle failure here; it's incredibly rare - * (never reported?) and only happens with "old" EKC */ - } else { - ep_requeue_receive(krx->krx_rxd, kqswnal_rxhandler, krx, - krx->krx_elanbuffer, - krx->krx_npages * PAGE_SIZE); - } -#endif -} - -void -kqswnal_rpc_complete (EP_RXD *rxd) -{ - int status = ep_rxd_status(rxd); - kqswnal_rx_t *krx = (kqswnal_rx_t *)ep_rxd_arg(rxd); - - CDEBUG((status == EP_SUCCESS) ? D_NET : D_ERROR, - "rxd %p, krx %p, status %d\n", rxd, krx, status); - - LASSERT (krx->krx_rxd == rxd); - LASSERT (krx->krx_rpc_reply_needed); - - krx->krx_rpc_reply_needed = 0; - kqswnal_requeue_rx (krx); -} - -void -kqswnal_rx_done (kqswnal_rx_t *krx) -{ - int rc; - EP_STATUSBLK *sblk; - - LASSERT (atomic_read(&krx->krx_refcount) == 0); - - if (krx->krx_rpc_reply_needed) { - /* We've not completed the peer's RPC yet... */ - sblk = (krx->krx_rpc_reply_status == 0) ? - &kqswnal_data.kqn_rpc_success : - &kqswnal_data.kqn_rpc_failed; - - LASSERT (!in_interrupt()); -#if MULTIRAIL_EKC - rc = ep_complete_rpc(krx->krx_rxd, - kqswnal_rpc_complete, krx, - sblk, NULL, NULL, 0); - if (rc == EP_SUCCESS) - return; -#else - rc = ep_complete_rpc(krx->krx_rxd, - kqswnal_rpc_complete, krx, - sblk, NULL, 0); - if (rc == EP_SUCCESS) - return; - - /* "old" EKC destroys rxd on failed completion */ - krx->krx_rxd = NULL; -#endif - CERROR("can't complete RPC: %d\n", rc); - krx->krx_rpc_reply_needed = 0; - } - - kqswnal_requeue_rx(krx); -} - -void -kqswnal_parse (kqswnal_rx_t *krx) -{ - ptl_hdr_t *hdr = (ptl_hdr_t *) page_address(krx->krx_kiov[0].kiov_page); - ptl_nid_t dest_nid = le64_to_cpu(hdr->dest_nid); - int payload_nob; - int nob; - int niov; - - LASSERT (atomic_read(&krx->krx_refcount) == 1); - - if (dest_nid == kqswnal_lib.libnal_ni.ni_pid.nid) { /* It's for me :) */ - /* I ignore parse errors since I'm not consuming a byte - * stream */ - (void)lib_parse (&kqswnal_lib, hdr, krx); - - /* Drop my ref; any RDMA activity takes an additional ref */ - kqswnal_rx_decref(krx); - return; - } - -#if KQSW_CHECKSUM - LASSERTF (0, "checksums for forwarded packets not implemented\n"); -#endif - - if (kqswnal_nid2elanid (dest_nid) >= 0) /* should have gone direct to peer */ - { - CERROR("dropping packet from "LPX64" for "LPX64 - ": target is peer\n", le64_to_cpu(hdr->src_nid), dest_nid); - - kqswnal_rx_decref (krx); - return; - } - - nob = payload_nob = krx->krx_nob - KQSW_HDR_SIZE; - niov = 0; - if (nob > 0) { - krx->krx_kiov[0].kiov_offset = KQSW_HDR_SIZE; - krx->krx_kiov[0].kiov_len = MIN(PAGE_SIZE - KQSW_HDR_SIZE, nob); - niov = 1; - nob -= PAGE_SIZE - KQSW_HDR_SIZE; - - while (nob > 0) { - LASSERT (niov < krx->krx_npages); - - krx->krx_kiov[niov].kiov_offset = 0; - krx->krx_kiov[niov].kiov_len = MIN(PAGE_SIZE, nob); - niov++; - nob -= PAGE_SIZE; - } - } - - kpr_fwd_init (&krx->krx_fwd, dest_nid, - hdr, payload_nob, niov, krx->krx_kiov, - kqswnal_fwd_callback, krx); - - kpr_fwd_start (&kqswnal_data.kqn_router, &krx->krx_fwd); -} - -/* Receive Interrupt Handler: posts to schedulers */ -void -kqswnal_rxhandler(EP_RXD *rxd) -{ - unsigned long flags; - int nob = ep_rxd_len (rxd); - int status = ep_rxd_status (rxd); - kqswnal_rx_t *krx = (kqswnal_rx_t *)ep_rxd_arg (rxd); - - CDEBUG(D_NET, "kqswnal_rxhandler: rxd %p, krx %p, nob %d, status %d\n", - rxd, krx, nob, status); - - LASSERT (krx != NULL); - LASSERT (krx->krx_state = KRX_POSTED); - - krx->krx_state = KRX_PARSE; - krx->krx_rxd = rxd; - krx->krx_nob = nob; - - /* RPC reply iff rpc request received without error */ - krx->krx_rpc_reply_needed = ep_rxd_isrpc(rxd) && - (status == EP_SUCCESS || - status == EP_MSG_TOO_BIG); - - /* Default to failure if an RPC reply is requested but not handled */ - krx->krx_rpc_reply_status = -EPROTO; - atomic_set (&krx->krx_refcount, 1); - - /* must receive a whole header to be able to parse */ - if (status != EP_SUCCESS || nob < sizeof (ptl_hdr_t)) - { - /* receives complete with failure when receiver is removed */ -#if MULTIRAIL_EKC - if (status == EP_SHUTDOWN) - LASSERT (kqswnal_data.kqn_shuttingdown); - else - CERROR("receive status failed with status %d nob %d\n", - ep_rxd_status(rxd), nob); -#else - if (!kqswnal_data.kqn_shuttingdown) - CERROR("receive status failed with status %d nob %d\n", - ep_rxd_status(rxd), nob); -#endif - kqswnal_rx_decref(krx); - return; - } - - if (!in_interrupt()) { - kqswnal_parse(krx); - return; - } - - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - - list_add_tail (&krx->krx_list, &kqswnal_data.kqn_readyrxds); - wake_up (&kqswnal_data.kqn_sched_waitq); - - spin_unlock_irqrestore (&kqswnal_data.kqn_sched_lock, flags); -} - -#if KQSW_CHECKSUM -void -kqswnal_csum_error (kqswnal_rx_t *krx, int ishdr) -{ - ptl_hdr_t *hdr = (ptl_hdr_t *)page_address (krx->krx_kiov[0].kiov_page); - - CERROR ("%s checksum mismatch %p: dnid "LPX64", snid "LPX64 - ", dpid %d, spid %d, type %d\n", - ishdr ? "Header" : "Payload", krx, - le64_to_cpu(hdr->dest_nid), le64_to_cpu(hdr->src_nid) - le32_to_cpu(hdr->dest_pid), le32_to_cpu(hdr->src_pid), - le32_to_cpu(hdr->type)); - - switch (le32_to_cpu(hdr->type)) - { - case PTL_MSG_ACK: - CERROR("ACK: mlen %d dmd "LPX64"."LPX64" match "LPX64 - " len %u\n", - le32_to_cpu(hdr->msg.ack.mlength), - hdr->msg.ack.dst_wmd.handle_cookie, - hdr->msg.ack.dst_wmd.handle_idx, - le64_to_cpu(hdr->msg.ack.match_bits), - le32_to_cpu(hdr->msg.ack.length)); - break; - case PTL_MSG_PUT: - CERROR("PUT: ptl %d amd "LPX64"."LPX64" match "LPX64 - " len %u off %u data "LPX64"\n", - le32_to_cpu(hdr->msg.put.ptl_index), - hdr->msg.put.ack_wmd.handle_cookie, - hdr->msg.put.ack_wmd.handle_idx, - le64_to_cpu(hdr->msg.put.match_bits), - le32_to_cpu(hdr->msg.put.length), - le32_to_cpu(hdr->msg.put.offset), - hdr->msg.put.hdr_data); - break; - case PTL_MSG_GET: - CERROR ("GET: <>\n"); - break; - case PTL_MSG_REPLY: - CERROR ("REPLY: <>\n"); - break; - default: - CERROR ("TYPE?: <>\n"); - } -} -#endif - -static ptl_err_t -kqswnal_recvmsg (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - unsigned int niov, - struct iovec *iov, - ptl_kiov_t *kiov, - size_t offset, - size_t mlen, - size_t rlen) -{ - kqswnal_rx_t *krx = (kqswnal_rx_t *)private; - char *buffer = page_address(krx->krx_kiov[0].kiov_page); - ptl_hdr_t *hdr = (ptl_hdr_t *)buffer; - int page; - char *page_ptr; - int page_nob; - char *iov_ptr; - int iov_nob; - int frag; - int rc; -#if KQSW_CHECKSUM - kqsw_csum_t senders_csum; - kqsw_csum_t payload_csum = 0; - kqsw_csum_t hdr_csum = kqsw_csum(0, hdr, sizeof(*hdr)); - size_t csum_len = mlen; - int csum_frags = 0; - int csum_nob = 0; - static atomic_t csum_counter; - int csum_verbose = (atomic_read(&csum_counter)%1000001) == 0; - - atomic_inc (&csum_counter); - - memcpy (&senders_csum, buffer + sizeof (ptl_hdr_t), sizeof (kqsw_csum_t)); - if (senders_csum != hdr_csum) - kqswnal_csum_error (krx, 1); -#endif - /* NB lib_parse() has already flipped *hdr */ - - CDEBUG(D_NET,"kqswnal_recv, mlen="LPSZ", rlen="LPSZ"\n", mlen, rlen); - - if (krx->krx_rpc_reply_needed && - hdr->type == PTL_MSG_PUT) { - /* This must be an optimized PUT */ - rc = kqswnal_rdma (krx, libmsg, PTL_MSG_PUT, - niov, iov, kiov, offset, mlen); - return (rc == 0 ? PTL_OK : PTL_FAIL); - } - - /* What was actually received must be >= payload. */ - LASSERT (mlen <= rlen); - if (krx->krx_nob < KQSW_HDR_SIZE + mlen) { - CERROR("Bad message size: have %d, need %d + %d\n", - krx->krx_nob, (int)KQSW_HDR_SIZE, (int)mlen); - return (PTL_FAIL); - } - - /* It must be OK to kmap() if required */ - LASSERT (kiov == NULL || !in_interrupt ()); - /* Either all pages or all vaddrs */ - LASSERT (!(kiov != NULL && iov != NULL)); - - if (mlen != 0) { - page = 0; - page_ptr = buffer + KQSW_HDR_SIZE; - page_nob = PAGE_SIZE - KQSW_HDR_SIZE; - - LASSERT (niov > 0); - - if (kiov != NULL) { - /* skip complete frags */ - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; - kiov++; - niov--; - LASSERT (niov > 0); - } - iov_ptr = ((char *)kmap (kiov->kiov_page)) + - kiov->kiov_offset + offset; - iov_nob = kiov->kiov_len - offset; - } else { - /* skip complete frags */ - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - iov++; - niov--; - LASSERT (niov > 0); - } - iov_ptr = iov->iov_base + offset; - iov_nob = iov->iov_len - offset; - } - - for (;;) - { - frag = mlen; - if (frag > page_nob) - frag = page_nob; - if (frag > iov_nob) - frag = iov_nob; - - memcpy (iov_ptr, page_ptr, frag); -#if KQSW_CHECKSUM - payload_csum = kqsw_csum (payload_csum, iov_ptr, frag); - csum_nob += frag; - csum_frags++; -#endif - mlen -= frag; - if (mlen == 0) - break; - - page_nob -= frag; - if (page_nob != 0) - page_ptr += frag; - else - { - page++; - LASSERT (page < krx->krx_npages); - page_ptr = page_address(krx->krx_kiov[page].kiov_page); - page_nob = PAGE_SIZE; - } - - iov_nob -= frag; - if (iov_nob != 0) - iov_ptr += frag; - else if (kiov != NULL) { - kunmap (kiov->kiov_page); - kiov++; - niov--; - LASSERT (niov > 0); - iov_ptr = ((char *)kmap (kiov->kiov_page)) + kiov->kiov_offset; - iov_nob = kiov->kiov_len; - } else { - iov++; - niov--; - LASSERT (niov > 0); - iov_ptr = iov->iov_base; - iov_nob = iov->iov_len; - } - } - - if (kiov != NULL) - kunmap (kiov->kiov_page); - } - -#if KQSW_CHECKSUM - memcpy (&senders_csum, buffer + sizeof(ptl_hdr_t) + sizeof(kqsw_csum_t), - sizeof(kqsw_csum_t)); - - if (csum_len != rlen) - CERROR("Unable to checksum data in user's buffer\n"); - else if (senders_csum != payload_csum) - kqswnal_csum_error (krx, 0); - - if (csum_verbose) - CERROR("hdr csum %lx, payload_csum %lx, csum_frags %d, " - "csum_nob %d\n", - hdr_csum, payload_csum, csum_frags, csum_nob); -#endif - lib_finalize(nal, private, libmsg, PTL_OK); - - return (PTL_OK); -} - -static ptl_err_t -kqswnal_recv(lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - unsigned int niov, - struct iovec *iov, - size_t offset, - size_t mlen, - size_t rlen) -{ - return (kqswnal_recvmsg(nal, private, libmsg, - niov, iov, NULL, - offset, mlen, rlen)); -} - -static ptl_err_t -kqswnal_recv_pages (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - unsigned int niov, - ptl_kiov_t *kiov, - size_t offset, - size_t mlen, - size_t rlen) -{ - return (kqswnal_recvmsg(nal, private, libmsg, - niov, NULL, kiov, - offset, mlen, rlen)); -} - -int -kqswnal_thread_start (int (*fn)(void *arg), void *arg) -{ - long pid = kernel_thread (fn, arg, 0); - - if (pid < 0) - return ((int)pid); - - atomic_inc (&kqswnal_data.kqn_nthreads); - return (0); -} - -void -kqswnal_thread_fini (void) -{ - atomic_dec (&kqswnal_data.kqn_nthreads); -} - -int -kqswnal_scheduler (void *arg) -{ - kqswnal_rx_t *krx; - kqswnal_tx_t *ktx; - kpr_fwd_desc_t *fwd; - unsigned long flags; - int rc; - int counter = 0; - int did_something; - - kportal_daemonize ("kqswnal_sched"); - kportal_blockallsigs (); - - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - - for (;;) - { - did_something = 0; - - if (!list_empty (&kqswnal_data.kqn_readyrxds)) - { - krx = list_entry(kqswnal_data.kqn_readyrxds.next, - kqswnal_rx_t, krx_list); - list_del (&krx->krx_list); - spin_unlock_irqrestore(&kqswnal_data.kqn_sched_lock, - flags); - - switch (krx->krx_state) { - case KRX_PARSE: - kqswnal_parse (krx); - break; - case KRX_COMPLETING: - kqswnal_rx_decref (krx); - break; - default: - LBUG(); - } - - did_something = 1; - spin_lock_irqsave(&kqswnal_data.kqn_sched_lock, flags); - } - - if (!list_empty (&kqswnal_data.kqn_delayedtxds)) - { - ktx = list_entry(kqswnal_data.kqn_delayedtxds.next, - kqswnal_tx_t, ktx_list); - list_del_init (&ktx->ktx_delayed_list); - spin_unlock_irqrestore(&kqswnal_data.kqn_sched_lock, - flags); - - rc = kqswnal_launch (ktx); - if (rc != 0) { - CERROR("Failed delayed transmit to "LPX64 - ": %d\n", ktx->ktx_nid, rc); - kqswnal_tx_done (ktx, rc); - } - atomic_dec (&kqswnal_data.kqn_pending_txs); - - did_something = 1; - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - } - - if (!list_empty (&kqswnal_data.kqn_delayedfwds)) - { - fwd = list_entry (kqswnal_data.kqn_delayedfwds.next, kpr_fwd_desc_t, kprfd_list); - list_del (&fwd->kprfd_list); - spin_unlock_irqrestore (&kqswnal_data.kqn_sched_lock, flags); - - /* If we're shutting down, this will just requeue fwd on kqn_idletxd_fwdq */ - kqswnal_fwd_packet (NULL, fwd); - - did_something = 1; - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - } - - /* nothing to do or hogging CPU */ - if (!did_something || counter++ == KQSW_RESCHED) { - spin_unlock_irqrestore(&kqswnal_data.kqn_sched_lock, - flags); - - counter = 0; - - if (!did_something) { - if (kqswnal_data.kqn_shuttingdown == 2) { - /* We only exit in stage 2 of shutdown when - * there's nothing left to do */ - break; - } - rc = wait_event_interruptible (kqswnal_data.kqn_sched_waitq, - kqswnal_data.kqn_shuttingdown == 2 || - !list_empty(&kqswnal_data.kqn_readyrxds) || - !list_empty(&kqswnal_data.kqn_delayedtxds) || - !list_empty(&kqswnal_data.kqn_delayedfwds)); - LASSERT (rc == 0); - } else if (need_resched()) - schedule (); - - spin_lock_irqsave (&kqswnal_data.kqn_sched_lock, flags); - } - } - - kqswnal_thread_fini (); - return (0); -} - -lib_nal_t kqswnal_lib = -{ - libnal_data: &kqswnal_data, /* NAL private data */ - libnal_send: kqswnal_send, - libnal_send_pages: kqswnal_send_pages, - libnal_recv: kqswnal_recv, - libnal_recv_pages: kqswnal_recv_pages, - libnal_dist: kqswnal_dist -}; diff --git a/lnet/klnds/ralnd/.cvsignore b/lnet/klnds/ralnd/.cvsignore deleted file mode 100644 index 5ed596b..0000000 --- a/lnet/klnds/ralnd/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/klnds/ralnd/Makefile.in b/lnet/klnds/ralnd/Makefile.in deleted file mode 100644 index 1772cc2..0000000 --- a/lnet/klnds/ralnd/Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -MODULES := kranal -kranal-objs := ranal.o ranal_cb.o - -EXTRA_POST_CFLAGS := @RACPPFLAGS@ - -@INCLUDE_RULES@ diff --git a/lnet/klnds/ralnd/autoMakefile.am b/lnet/klnds/ralnd/autoMakefile.am deleted file mode 100644 index f136aa5..0000000 --- a/lnet/klnds/ralnd/autoMakefile.am +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if !CRAY_PORTALS -if BUILD_RANAL -modulenet_DATA = kranal$(KMODEXT) -endif -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(kranal-objs:%.o=%.c) ranal.h diff --git a/lnet/klnds/ralnd/ralnd.c b/lnet/klnds/ralnd/ralnd.c deleted file mode 100644 index c924827..0000000 --- a/lnet/klnds/ralnd/ralnd.c +++ /dev/null @@ -1,1983 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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. - * - */ -#include "ranal.h" - - -nal_t kranal_api; -ptl_handle_ni_t kranal_ni; -kra_data_t kranal_data; -kra_tunables_t kranal_tunables; - -#ifdef CONFIG_SYSCTL -#define RANAL_SYSCTL_TIMEOUT 1 -#define RANAL_SYSCTL_LISTENER_TIMEOUT 2 -#define RANAL_SYSCTL_BACKLOG 3 -#define RANAL_SYSCTL_PORT 4 -#define RANAL_SYSCTL_MAX_IMMEDIATE 5 - -#define RANAL_SYSCTL 202 - -static ctl_table kranal_ctl_table[] = { - {RANAL_SYSCTL_TIMEOUT, "timeout", - &kranal_tunables.kra_timeout, sizeof(int), - 0644, NULL, &proc_dointvec}, - {RANAL_SYSCTL_LISTENER_TIMEOUT, "listener_timeout", - &kranal_tunables.kra_listener_timeout, sizeof(int), - 0644, NULL, &proc_dointvec}, - {RANAL_SYSCTL_BACKLOG, "backlog", - &kranal_tunables.kra_backlog, sizeof(int), - 0644, NULL, kranal_listener_procint}, - {RANAL_SYSCTL_PORT, "port", - &kranal_tunables.kra_port, sizeof(int), - 0644, NULL, kranal_listener_procint}, - {RANAL_SYSCTL_MAX_IMMEDIATE, "max_immediate", - &kranal_tunables.kra_max_immediate, sizeof(int), - 0644, NULL, &proc_dointvec}, - { 0 } -}; - -static ctl_table kranal_top_ctl_table[] = { - {RANAL_SYSCTL, "ranal", NULL, 0, 0555, kranal_ctl_table}, - { 0 } -}; -#endif - -int -kranal_sock_write (struct socket *sock, void *buffer, int nob) -{ - int rc; - mm_segment_t oldmm = get_fs(); - 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 = MSG_DONTWAIT - }; - - /* We've set up the socket's send buffer to be large enough for - * everything we send, so a single non-blocking send should - * complete without error. */ - - set_fs(KERNEL_DS); - rc = sock_sendmsg(sock, &msg, iov.iov_len); - set_fs(oldmm); - - return rc; -} - -int -kranal_sock_read (struct socket *sock, void *buffer, int nob, int timeout) -{ - int rc; - mm_segment_t oldmm = get_fs(); - long ticks = timeout * HZ; - unsigned long then; - struct timeval tv; - - LASSERT (nob > 0); - LASSERT (ticks > 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 - }; - - /* Set receive timeout to remaining time */ - tv = (struct timeval) { - .tv_sec = ticks / HZ, - .tv_usec = ((ticks % HZ) * 1000000) / HZ - }; - set_fs(KERNEL_DS); - rc = sock_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, - (char *)&tv, sizeof(tv)); - set_fs(oldmm); - if (rc != 0) { - CERROR("Can't set socket recv timeout %d: %d\n", - timeout, rc); - return rc; - } - - set_fs(KERNEL_DS); - then = jiffies; - rc = sock_recvmsg(sock, &msg, iov.iov_len, 0); - ticks -= jiffies - then; - set_fs(oldmm); - - if (rc < 0) - return rc; - - if (rc == 0) - return -ECONNABORTED; - - buffer = ((char *)buffer) + rc; - nob -= rc; - - if (nob == 0) - return 0; - - if (ticks <= 0) - return -ETIMEDOUT; - } -} - -int -kranal_create_sock(struct socket **sockp) -{ - struct socket *sock; - int rc; - struct timeval tv; - int option; - mm_segment_t oldmm = get_fs(); - - rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock); - if (rc != 0) { - CERROR("Can't create socket: %d\n", rc); - return rc; - } - - /* Ensure sending connection info doesn't block */ - option = 2 * sizeof(kra_connreq_t); - set_fs(KERNEL_DS); - rc = sock_setsockopt(sock, SOL_SOCKET, SO_SNDBUF, - (char *)&option, sizeof(option)); - set_fs(oldmm); - if (rc != 0) { - CERROR("Can't set send buffer %d: %d\n", option, rc); - goto failed; - } - - option = 1; - set_fs(KERNEL_DS); - rc = sock_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&option, sizeof(option)); - set_fs(oldmm); - if (rc != 0) { - CERROR("Can't set SO_REUSEADDR: %d\n", rc); - goto failed; - } - - *sockp = sock; - return 0; - - failed: - sock_release(sock); - return rc; -} - -void -kranal_pause(int ticks) -{ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(ticks); -} - -void -kranal_pack_connreq(kra_connreq_t *connreq, kra_conn_t *conn) -{ - RAP_RETURN rrc; - - memset(connreq, 0, sizeof(*connreq)); - - connreq->racr_magic = RANAL_MSG_MAGIC; - connreq->racr_version = RANAL_MSG_VERSION; - connreq->racr_devid = conn->rac_device->rad_id; - connreq->racr_nid = kranal_lib.libnal_ni.ni_pid.nid; - connreq->racr_timeout = conn->rac_timeout; - connreq->racr_incarnation = conn->rac_my_incarnation; - - rrc = RapkGetRiParams(conn->rac_rihandle, &connreq->racr_riparams); - LASSERT(rrc == RAP_SUCCESS); -} - -int -kranal_recv_connreq(struct socket *sock, kra_connreq_t *connreq, int timeout) -{ - int i; - int rc; - - rc = kranal_sock_read(sock, connreq, sizeof(*connreq), timeout); - if (rc != 0) { - CERROR("Read failed: %d\n", rc); - return rc; - } - - if (connreq->racr_magic != RANAL_MSG_MAGIC) { - if (__swab32(connreq->racr_magic) != RANAL_MSG_MAGIC) { - CERROR("Unexpected magic %08x\n", connreq->racr_magic); - return -EPROTO; - } - - __swab32s(&connreq->racr_magic); - __swab16s(&connreq->racr_version); - __swab16s(&connreq->racr_devid); - __swab64s(&connreq->racr_nid); - __swab64s(&connreq->racr_incarnation); - __swab32s(&connreq->racr_timeout); - - __swab32s(&connreq->racr_riparams.FmaDomainHndl); - __swab32s(&connreq->racr_riparams.RcvCqHndl); - __swab32s(&connreq->racr_riparams.PTag); - __swab32s(&connreq->racr_riparams.CompletionCookie); - } - - if (connreq->racr_version != RANAL_MSG_VERSION) { - CERROR("Unexpected version %d\n", connreq->racr_version); - return -EPROTO; - } - - if (connreq->racr_nid == PTL_NID_ANY) { - CERROR("Received PTL_NID_ANY\n"); - return -EPROTO; - } - - if (connreq->racr_timeout < RANAL_MIN_TIMEOUT) { - CERROR("Received timeout %d < MIN %d\n", - connreq->racr_timeout, RANAL_MIN_TIMEOUT); - return -EPROTO; - } - - for (i = 0; i < kranal_data.kra_ndevs; i++) - if (connreq->racr_devid == - kranal_data.kra_devices[i].rad_id) - break; - - if (i == kranal_data.kra_ndevs) { - CERROR("Can't match device %d\n", connreq->racr_devid); - return -ENODEV; - } - - return 0; -} - -int -kranal_conn_isdup_locked(kra_peer_t *peer, __u64 incarnation) -{ - kra_conn_t *conn; - struct list_head *tmp; - int loopback = 0; - - list_for_each(tmp, &peer->rap_conns) { - conn = list_entry(tmp, kra_conn_t, rac_list); - - if (conn->rac_peer_incarnation < incarnation) { - /* Conns with an older incarnation get culled later */ - continue; - } - - if (!loopback && - conn->rac_peer_incarnation == incarnation && - peer->rap_nid == kranal_lib.libnal_ni.ni_pid.nid) { - /* loopback creates 2 conns */ - loopback = 1; - continue; - } - - return 1; - } - - return 0; -} - -void -kranal_set_conn_uniqueness (kra_conn_t *conn) -{ - unsigned long flags; - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - conn->rac_my_incarnation = kranal_data.kra_next_incarnation++; - - do { /* allocate a unique cqid */ - conn->rac_cqid = kranal_data.kra_next_cqid++; - } while (kranal_cqid2conn_locked(conn->rac_cqid) != NULL); - - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); -} - -int -kranal_alloc_conn(kra_conn_t **connp, kra_device_t *dev) -{ - kra_conn_t *conn; - RAP_RETURN rrc; - - LASSERT (!in_interrupt()); - PORTAL_ALLOC(conn, sizeof(*conn)); - - if (conn == NULL) - return -ENOMEM; - - memset(conn, 0, sizeof(*conn)); - atomic_set(&conn->rac_refcount, 1); - INIT_LIST_HEAD(&conn->rac_list); - INIT_LIST_HEAD(&conn->rac_hashlist); - INIT_LIST_HEAD(&conn->rac_fmaq); - INIT_LIST_HEAD(&conn->rac_rdmaq); - INIT_LIST_HEAD(&conn->rac_replyq); - spin_lock_init(&conn->rac_lock); - - kranal_set_conn_uniqueness(conn); - - conn->rac_timeout = MAX(kranal_tunables.kra_timeout, RANAL_MIN_TIMEOUT); - kranal_update_reaper_timeout(conn->rac_timeout); - - rrc = RapkCreateRi(dev->rad_handle, conn->rac_cqid, - dev->rad_ptag, - dev->rad_rdma_cq, dev->rad_fma_cq, - &conn->rac_rihandle); - if (rrc != RAP_SUCCESS) { - CERROR("RapkCreateRi failed: %d\n", rrc); - PORTAL_FREE(conn, sizeof(*conn)); - return -ENETDOWN; - } - - atomic_inc(&kranal_data.kra_nconns); - *connp = conn; - return 0; -} - -void -__kranal_conn_decref(kra_conn_t *conn) -{ - kra_tx_t *tx; - RAP_RETURN rrc; - - LASSERT (!in_interrupt()); - LASSERT (!conn->rac_scheduled); - LASSERT (list_empty(&conn->rac_list)); - LASSERT (list_empty(&conn->rac_hashlist)); - LASSERT (atomic_read(&conn->rac_refcount) == 0); - - while (!list_empty(&conn->rac_fmaq)) { - tx = list_entry(conn->rac_fmaq.next, kra_tx_t, tx_list); - - list_del(&tx->tx_list); - kranal_tx_done(tx, -ECONNABORTED); - } - - /* We may not destroy this connection while it has RDMAs outstanding */ - LASSERT (list_empty(&conn->rac_rdmaq)); - - while (!list_empty(&conn->rac_replyq)) { - tx = list_entry(conn->rac_replyq.next, kra_tx_t, tx_list); - - list_del(&tx->tx_list); - kranal_tx_done(tx, -ECONNABORTED); - } - - rrc = RapkDestroyRi(conn->rac_device->rad_handle, - conn->rac_rihandle); - LASSERT (rrc == RAP_SUCCESS); - - if (conn->rac_peer != NULL) - kranal_peer_decref(conn->rac_peer); - - PORTAL_FREE(conn, sizeof(*conn)); - atomic_dec(&kranal_data.kra_nconns); -} - -void -kranal_terminate_conn_locked (kra_conn_t *conn) -{ - kra_peer_t *peer = conn->rac_peer; - - LASSERT (!in_interrupt()); - LASSERT (conn->rac_closing); - LASSERT (!list_empty(&conn->rac_hashlist)); - LASSERT (list_empty(&conn->rac_list)); - - /* Remove from conn hash table (no new callbacks) */ - list_del_init(&conn->rac_hashlist); - kranal_conn_decref(conn); - - /* Conn is now just waiting for remaining refs to go */ -} - -void -kranal_close_conn_locked (kra_conn_t *conn, int error) -{ - kra_peer_t *peer = conn->rac_peer; - - CDEBUG(error == 0 ? D_NET : D_ERROR, - "closing conn to "LPX64": error %d\n", peer->rap_nid, error); - - LASSERT (!in_interrupt()); - LASSERT (!conn->rac_closing); - LASSERT (!list_empty(&conn->rac_hashlist)); - LASSERT (!list_empty(&conn->rac_list)); - - list_del_init(&conn->rac_list); - - if (list_empty(&peer->rap_conns) && - peer->rap_persistence == 0) { - /* Non-persistent peer with no more conns... */ - kranal_unlink_peer_locked(peer); - } - - conn->rac_closing = 1; - kranal_schedule_conn(conn); - - kranal_conn_decref(conn); /* lose peer's ref */ -} - -void -kranal_close_conn (kra_conn_t *conn, int error) -{ - unsigned long flags; - - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - if (!conn->rac_closing) - kranal_close_conn_locked(conn, error); - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); -} - -int -kranal_passive_conn_handshake (struct socket *sock, - ptl_nid_t *peer_nidp, kra_conn_t **connp) -{ - struct sockaddr_in addr; - __u32 peer_ip; - unsigned int peer_port; - kra_connreq_t connreq; - ptl_nid_t peer_nid; - kra_conn_t *conn; - kra_device_t *dev; - RAP_RETURN rrc; - int rc; - int len; - int i; - - len = sizeof(addr); - rc = sock->ops->getname(sock, (struct sockaddr *)&addr, &len, 2); - if (rc != 0) { - CERROR("Can't get peer's IP: %d\n", rc); - return rc; - } - - peer_ip = ntohl(addr.sin_addr.s_addr); - peer_port = ntohs(addr.sin_port); - - if (peer_port >= 1024) { - CERROR("Refusing unprivileged connection from %u.%u.%u.%u/%d\n", - HIPQUAD(peer_ip), peer_port); - return -ECONNREFUSED; - } - - rc = kranal_recv_connreq(sock, &connreq, - kranal_tunables.kra_listener_timeout); - if (rc != 0) { - CERROR("Can't rx connreq from %u.%u.%u.%u/%d: %d\n", - HIPQUAD(peer_ip), peer_port, rc); - return rc; - } - - peer_nid = connreq.racr_nid; - LASSERT (peer_nid != PTL_NID_ANY); - - for (i = 0;;i++) { - LASSERT(i < kranal_data.kra_ndevs); - dev = &kranal_data.kra_devices[i]; - if (dev->rad_id == connreq.racr_devid) - break; - } - - rc = kranal_alloc_conn(&conn, dev); - if (rc != 0) - return rc; - - conn->rac_peer_incarnation = connreq.racr_incarnation; - conn->rac_keepalive = RANAL_TIMEOUT2KEEPALIVE(connreq.racr_timeout); - kranal_update_reaper_timeout(conn->rac_keepalive); - - rrc = RapkSetRiParams(conn->rac_rihandle, &connreq.racr_riparams); - if (rrc != RAP_SUCCESS) { - CERROR("Can't set riparams for "LPX64": %d\n", peer_nid, rrc); - kranal_conn_decref(conn); - return -EPROTO; - } - - kranal_pack_connreq(&connreq, conn); - - rc = kranal_sock_write(sock, &connreq, sizeof(connreq)); - if (rc != 0) { - CERROR("Can't tx connreq to %u.%u.%u.%u/%d: %d\n", - HIPQUAD(peer_ip), peer_port, rc); - kranal_conn_decref(conn); - return rc; - } - - *connp = conn; - *peer_nidp = peer_nid; - return 0; -} - -int -ranal_connect_sock(kra_peer_t *peer, struct socket **sockp) -{ - struct sockaddr_in locaddr; - struct sockaddr_in srvaddr; - struct socket *sock; - unsigned int port; - int rc; - int option; - mm_segment_t oldmm = get_fs(); - struct timeval tv; - - for (port = 1023; port >= 512; port--) { - - memset(&locaddr, 0, sizeof(locaddr)); - locaddr.sin_family = AF_INET; - locaddr.sin_port = htons(port); - locaddr.sin_addr.s_addr = htonl(INADDR_ANY); - - memset (&srvaddr, 0, sizeof (srvaddr)); - srvaddr.sin_family = AF_INET; - srvaddr.sin_port = htons (peer->rap_port); - srvaddr.sin_addr.s_addr = htonl (peer->rap_ip); - - rc = kranal_create_sock(&sock); - if (rc != 0) - return rc; - - rc = sock->ops->bind(sock, - (struct sockaddr *)&locaddr, sizeof(locaddr)); - if (rc != 0) { - sock_release(sock); - - if (rc == -EADDRINUSE) { - CDEBUG(D_NET, "Port %d already in use\n", port); - continue; - } - - CERROR("Can't bind to reserved port %d: %d\n", port, rc); - return rc; - } - - rc = sock->ops->connect(sock, - (struct sockaddr *)&srvaddr, sizeof(srvaddr), - 0); - if (rc == 0) { - *sockp = sock; - return 0; - } - - sock_release(sock); - - if (rc != -EADDRNOTAVAIL) { - CERROR("Can't connect port %d to %u.%u.%u.%u/%d: %d\n", - port, HIPQUAD(peer->rap_ip), peer->rap_port, rc); - return rc; - } - - CDEBUG(D_NET, "Port %d not available for %u.%u.%u.%u/%d\n", - port, HIPQUAD(peer->rap_ip), peer->rap_port); - } - - /* all ports busy */ - return -EHOSTUNREACH; -} - - -int -kranal_active_conn_handshake(kra_peer_t *peer, kra_conn_t **connp) -{ - struct sockaddr_in dstaddr; - kra_connreq_t connreq; - kra_conn_t *conn; - kra_device_t *dev; - struct socket *sock; - RAP_RETURN rrc; - int rc; - int idx; - - idx = peer->rap_nid & 0x7fffffff; - dev = &kranal_data.kra_devices[idx % kranal_data.kra_ndevs]; - - rc = kranal_alloc_conn(&conn, dev); - if (rc != 0) - return rc; - - kranal_pack_connreq(&connreq, conn); - - rc = ranal_connect_sock(peer, &sock); - if (rc != 0) - goto failed_0; - - /* CAVEAT EMPTOR: the passive side receives with a SHORT rx timeout - * immediately after accepting a connection, so we connect and then - * send immediately. */ - - rc = kranal_sock_write(sock, &connreq, sizeof(connreq)); - if (rc != 0) { - CERROR("Can't tx connreq to %u.%u.%u.%u/%d: %d\n", - HIPQUAD(peer->rap_ip), peer->rap_port, rc); - goto failed_1; - } - - rc = kranal_recv_connreq(sock, &connreq, kranal_tunables.kra_timeout); - if (rc != 0) { - CERROR("Can't rx connreq from %u.%u.%u.%u/%d: %d\n", - HIPQUAD(peer->rap_ip), peer->rap_port, rc); - goto failed_1; - } - - sock_release(sock); - rc = -EPROTO; - - if (connreq.racr_nid != peer->rap_nid) { - CERROR("Unexpected nid from %u.%u.%u.%u/%d: " - "received "LPX64" expected "LPX64"\n", - HIPQUAD(peer->rap_ip), peer->rap_port, - connreq.racr_nid, peer->rap_nid); - goto failed_0; - } - - if (connreq.racr_devid != dev->rad_id) { - CERROR("Unexpected device id from %u.%u.%u.%u/%d: " - "received %d expected %d\n", - HIPQUAD(peer->rap_ip), peer->rap_port, - connreq.racr_devid, dev->rad_id); - goto failed_0; - } - - conn->rac_peer_incarnation = connreq.racr_incarnation; - conn->rac_keepalive = RANAL_TIMEOUT2KEEPALIVE(connreq.racr_timeout); - kranal_update_reaper_timeout(conn->rac_keepalive); - - rc = -ENETDOWN; - rrc = RapkSetRiParams(conn->rac_rihandle, &connreq.racr_riparams); - if (rrc != RAP_SUCCESS) { - CERROR("Can't set riparams for "LPX64": %d\n", - peer->rap_nid, rrc); - goto failed_0; - } - - *connp = conn; - return 0; - - failed_1: - sock_release(sock); - failed_0: - kranal_conn_decref(conn); - return rc; -} - -int -kranal_conn_handshake (struct socket *sock, kra_peer_t *peer) -{ - kra_peer_t *peer2; - kra_tx_t *tx; - ptl_nid_t peer_nid; - unsigned long flags; - unsigned long timeout; - kra_conn_t *conn; - int rc; - int nstale; - - if (sock != NULL) { - /* passive: listener accepted sock */ - LASSERT (peer == NULL); - - rc = kranal_passive_conn_handshake(sock, &peer_nid, &conn); - if (rc != 0) - return rc; - - /* assume this is a new peer */ - peer = kranal_create_peer(peer_nid); - if (peer == NULL) { - CERROR("Can't allocate peer for "LPX64"\n", peer_nid); - kranal_conn_decref(conn); - return -ENOMEM; - } - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - peer2 = kranal_find_peer_locked(peer_nid); - if (peer2 == NULL) { - /* peer table takes my initial ref on peer */ - list_add_tail(&peer->rap_list, - kranal_nid2peerlist(peer_nid)); - } else { - /* peer_nid already in the peer table */ - kranal_peer_decref(peer); - peer = peer2; - } - /* NB I may now have a non-persistent peer in the peer - * table with no connections: I can't drop the global lock - * until I've given it a connection or removed it, and when - * I do 'peer' can disappear under me. */ - } else { - /* active: connd wants to connect to peer */ - LASSERT (peer != NULL); - LASSERT (peer->rap_connecting); - - rc = kranal_active_conn_handshake(peer, &conn); - if (rc != 0) - return rc; - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - if (!kranal_peer_active(peer)) { - /* raced with peer getting unlinked */ - write_unlock_irqrestore(&kranal_data.kra_global_lock, - flags); - kranal_conn_decref(conn); - return ESTALE; - } - } - - LASSERT (kranal_peer_active(peer)); /* peer is in the peer table */ - peer_nid = peer->rap_nid; - - /* Refuse to duplicate an existing connection (both sides might try - * to connect at once). NB we return success! We _do_ have a - * connection (so we don't need to remove the peer from the peer - * table) and we _don't_ have any blocked txs to complete */ - if (kranal_conn_isdup_locked(peer, conn->rac_peer_incarnation)) { - LASSERT (!list_empty(&peer->rap_conns)); - LASSERT (list_empty(&peer->rap_tx_queue)); - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - CWARN("Not creating duplicate connection to "LPX64"\n", - peer_nid); - kranal_conn_decref(conn); - return 0; - } - - kranal_peer_addref(peer); /* +1 ref for conn */ - conn->rac_peer = peer; - list_add_tail(&conn->rac_list, &peer->rap_conns); - - kranal_conn_addref(conn); /* +1 ref for conn table */ - list_add_tail(&conn->rac_hashlist, - kranal_cqid2connlist(conn->rac_cqid)); - - /* Schedule all packets blocking for a connection */ - while (!list_empty(&peer->rap_tx_queue)) { - tx = list_entry(&peer->rap_tx_queue.next, - kra_tx_t, tx_list); - - list_del(&tx->tx_list); - kranal_post_fma(conn, tx); - } - - nstale = kranal_close_stale_conns_locked(peer, conn->rac_peer_incarnation); - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - - /* CAVEAT EMPTOR: passive peer can disappear NOW */ - - if (nstale != 0) - CWARN("Closed %d stale conns to "LPX64"\n", nstale, peer_nid); - - /* Ensure conn gets checked. Transmits may have been queued and an - * FMA event may have happened before it got in the cq hash table */ - kranal_schedule_conn(conn); - return 0; -} - -void -kranal_connect (kra_peer_t *peer) -{ - kra_tx_t *tx; - unsigned long flags; - struct list_head zombies; - int rc; - - LASSERT (peer->rap_connecting); - - rc = kranal_conn_handshake(NULL, peer); - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - LASSERT (peer->rap_connecting); - peer->rap_connecting = 0; - - if (rc == 0) { - /* kranal_conn_handshake() queues blocked txs immediately on - * success to avoid messages jumping the queue */ - LASSERT (list_empty(&peer->rap_tx_queue)); - - /* reset reconnection timeouts */ - peer->rap_reconnect_interval = RANAL_MIN_RECONNECT_INTERVAL; - peer->rap_reconnect_time = CURRENT_TIME; - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - return; - } - - LASSERT (peer->rap_reconnect_interval != 0); - peer->rap_reconnect_time = CURRENT_TIME + peer->rap_reconnect_interval; - peer->rap_reconnect_interval = MAX(RANAL_MAX_RECONNECT_INTERVAL, - 1 * peer->rap_reconnect_interval); - - /* Grab all blocked packets while we have the global lock */ - list_add(&zombies, &peer->rap_tx_queue); - list_del_init(&peer->rap_tx_queue); - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - - if (list_empty(&zombies)) - return; - - CWARN("Dropping packets for "LPX64": connection failed\n", - peer->rap_nid); - - do { - tx = list_entry(zombies.next, kra_tx_t, tx_list); - - list_del(&tx->tx_list); - kranal_tx_done(tx, -EHOSTUNREACH); - - } while (!list_empty(&zombies)); -} - -int -kranal_listener(void *arg) -{ - struct sockaddr_in addr; - wait_queue_t wait; - struct socket *sock; - struct socket *newsock; - int port; - kra_connreq_t *connreqs; - char name[16]; - int rc; - - /* Parent thread holds kra_nid_mutex, and is, or is about to - * block on kra_listener_signal */ - - port = kranal_tunables.kra_port; - snprintf(name, sizeof(name), "kranal_lstn%03d", port); - kportal_daemonize(name); - kportal_blockallsigs(); - - init_waitqueue_entry(&wait, current); - - rc = -ENOMEM; - PORTAL_ALLOC(connreqs, 2 * sizeof(*connreqs)); - if (connreqs == NULL) - goto out_0; - - rc = kranal_create_sock(&sock); - if (rc != 0) - goto out_1; - - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - addr.sin_addr.s_addr = INADDR_ANY; - - rc = sock->ops->bind(sock, (struct sockaddr *)&addr, sizeof(addr)); - if (rc != 0) { - CERROR("Can't bind to port %d\n", port); - goto out_2; - } - - rc = sock->ops->listen(sock, kranal_tunables.kra_backlog); - if (rc != 0) { - CERROR("Can't set listen backlog %d: %d\n", - kranal_tunables.kra_backlog, rc); - goto out_2; - } - - LASSERT (kranal_data.kra_listener_sock == NULL); - kranal_data.kra_listener_sock = sock; - - /* unblock waiting parent */ - LASSERT (kranal_data.kra_listener_shutdown == 0); - up(&kranal_data.kra_listener_signal); - - /* Wake me any time something happens on my socket */ - add_wait_queue(sock->sk->sk_sleep, &wait); - - while (kranal_data.kra_listener_shutdown == 0) { - - newsock = sock_alloc(); - if (newsock == NULL) { - CERROR("Can't allocate new socket for accept\n"); - kranal_pause(HZ); - continue; - } - - set_current_state(TASK_INTERRUPTIBLE); - - rc = sock->ops->accept(sock, newsock, O_NONBLOCK); - - if (rc == -EAGAIN && - kranal_data.kra_listener_shutdown == 0) - schedule(); - - set_current_state(TASK_RUNNING); - - if (rc != 0) { - sock_release(newsock); - if (rc != -EAGAIN) { - CERROR("Accept failed: %d\n", rc); - kranal_pause(HZ); - } - continue; - } - - kranal_conn_handshake(newsock, NULL); - sock_release(newsock); - } - - rc = 0; - remove_wait_queue(sock->sk->sk_sleep, &wait); - out_2: - sock_release(sock); - kranal_data.kra_listener_sock = NULL; - out_1: - PORTAL_FREE(connreqs, 2 * sizeof(*connreqs)); - out_0: - /* set completion status and unblock thread waiting for me - * (parent on startup failure, executioner on normal shutdown) */ - kranal_data.kra_listener_shutdown = rc; - up(&kranal_data.kra_listener_signal); - - return 0; -} - -int -kranal_start_listener (void) -{ - long pid; - int rc; - - CDEBUG(D_WARNING, "Starting listener\n"); - - /* Called holding kra_nid_mutex: listener stopped */ - LASSERT (kranal_data.kra_listener_sock == NULL); - - kranal_data.kra_listener_shutdown == 0; - pid = kernel_thread(kranal_listener, NULL, 0); - if (pid < 0) { - CERROR("Can't spawn listener: %ld\n", pid); - return (int)pid; - } - - /* Block until listener has started up. */ - down(&kranal_data.kra_listener_signal); - - rc = kranal_data.kra_listener_shutdown; - LASSERT ((rc != 0) == (kranal_data.kra_listener_sock == NULL)); - - CDEBUG(D_WARNING, "Listener %ld started OK\n", pid); - return rc; -} - -void -kranal_stop_listener(void) -{ - CDEBUG(D_WARNING, "Stopping listener\n"); - - /* Called holding kra_nid_mutex: listener running */ - LASSERT (kranal_data.kra_listener_sock != NULL); - - kranal_data.kra_listener_shutdown = 1; - wake_up_all(kranal_data.kra_listener_sock->sk->sk_sleep); - - /* Block until listener has torn down. */ - down(&kranal_data.kra_listener_signal); - - LASSERT (kranal_data.kra_listener_sock == NULL); - CDEBUG(D_WARNING, "Listener stopped\n"); -} - -int -kranal_listener_procint(ctl_table *table, int write, struct file *filp, - void *buffer, size_t *lenp) -{ - int *tunable = (int *)table->data; - int old_val; - int rc; - - down(&kranal_data.kra_nid_mutex); - - LASSERT (tunable == &kranal_tunables.kra_port || - tunable == &kranal_tunables.kra_backlog); - old_val = *tunable; - - rc = proc_dointvec(table, write, filp, buffer, lenp); - - if (write && - (*tunable != old_val || - kranal_data.kra_listener_sock == NULL)) { - - if (kranal_data.kra_listener_sock != NULL) - kranal_stop_listener(); - - rc = kranal_start_listener(); - - if (rc != 0) { - *tunable = old_val; - kranal_start_listener(); - } - } - - up(&kranal_data.kra_nid_mutex); - return rc; -} - -int -kranal_set_mynid(ptl_nid_t nid) -{ - lib_ni_t *ni = &kranal_lib.libnal_ni; - int rc = 0; - - CDEBUG(D_NET, "setting mynid to "LPX64" (old nid="LPX64")\n", - nid, ni->ni_pid.nid); - - down(&kranal_data.kra_nid_mutex); - - if (nid == ni->ni_pid.nid) { - /* no change of NID */ - up(&kranal_data.kra_nid_mutex); - return 0; - } - - if (kranal_data.kra_listener_sock != NULL) - kranal_stop_listener(); - - ni->ni_pid.nid = nid; - - /* Delete all existing peers and their connections after new - * NID/incarnation set to ensure no old connections in our brave - * new world. */ - kranal_del_peer(PTL_NID_ANY, 0); - - if (nid != PTL_NID_ANY) - rc = kranal_start_listener(); - - up(&kranal_data.kra_nid_mutex); - return rc; -} - -kra_peer_t * -kranal_create_peer (ptl_nid_t nid) -{ - kra_peer_t *peer; - - LASSERT (nid != PTL_NID_ANY); - - PORTAL_ALLOC(peer, sizeof(*peer)); - if (peer == NULL) - return NULL; - - memset(peer, 0, sizeof(*peer)); /* zero flags etc */ - - peer->rap_nid = nid; - atomic_set(&peer->rap_refcount, 1); /* 1 ref for caller */ - - INIT_LIST_HEAD(&peer->rap_list); /* not in the peer table yet */ - INIT_LIST_HEAD(&peer->rap_conns); - INIT_LIST_HEAD(&peer->rap_tx_queue); - - peer->rap_reconnect_time = CURRENT_TIME; - peer->rap_reconnect_interval = RANAL_MIN_RECONNECT_INTERVAL; - - atomic_inc(&kranal_data.kra_npeers); - return peer; -} - -void -__kranal_peer_decref (kra_peer_t *peer) -{ - CDEBUG(D_NET, "peer "LPX64" %p deleted\n", peer->rap_nid, peer); - - LASSERT (atomic_read(&peer->rap_refcount) == 0); - LASSERT (peer->rap_persistence == 0); - LASSERT (!kranal_peer_active(peer)); - LASSERT (peer->rap_connecting == 0); - LASSERT (list_empty(&peer->rap_conns)); - LASSERT (list_empty(&peer->rap_tx_queue)); - - PORTAL_FREE(peer, sizeof(*peer)); - - /* NB a peer's connections keep a reference on their peer until - * they are destroyed, so we can be assured that _all_ state to do - * with this peer has been cleaned up when its refcount drops to - * zero. */ - atomic_dec(&kranal_data.kra_npeers); -} - -kra_peer_t * -kranal_find_peer_locked (ptl_nid_t nid) -{ - struct list_head *peer_list = kranal_nid2peerlist(nid); - struct list_head *tmp; - kra_peer_t *peer; - - list_for_each (tmp, peer_list) { - - peer = list_entry(tmp, kra_peer_t, rap_list); - - LASSERT (peer->rap_persistence > 0 || /* persistent peer */ - !list_empty(&peer->rap_conns)); /* active conn */ - - if (peer->rap_nid != nid) - continue; - - CDEBUG(D_NET, "got peer [%p] -> "LPX64" (%d)\n", - peer, nid, atomic_read(&peer->rap_refcount)); - return peer; - } - return NULL; -} - -kra_peer_t * -kranal_find_peer (ptl_nid_t nid) -{ - kra_peer_t *peer; - - read_lock(&kranal_data.kra_global_lock); - peer = kranal_find_peer_locked(nid); - if (peer != NULL) /* +1 ref for caller? */ - kranal_peer_addref(peer); - read_unlock(&kranal_data.kra_global_lock); - - return peer; -} - -void -kranal_unlink_peer_locked (kra_peer_t *peer) -{ - LASSERT (peer->rap_persistence == 0); - LASSERT (list_empty(&peer->rap_conns)); - - LASSERT (kranal_peer_active(peer)); - list_del_init(&peer->rap_list); - - /* lose peerlist's ref */ - kranal_peer_decref(peer); -} - -int -kranal_get_peer_info (int index, ptl_nid_t *nidp, __u32 *ipp, int *portp, - int *persistencep) -{ - kra_peer_t *peer; - struct list_head *ptmp; - int i; - - read_lock(&kranal_data.kra_global_lock); - - for (i = 0; i < kranal_data.kra_peer_hash_size; i++) { - - list_for_each(ptmp, &kranal_data.kra_peers[i]) { - - peer = list_entry(ptmp, kra_peer_t, rap_list); - LASSERT (peer->rap_persistence > 0 || - !list_empty(&peer->rap_conns)); - - if (index-- > 0) - continue; - - *nidp = peer->rap_nid; - *ipp = peer->rap_ip; - *portp = peer->rap_port; - *persistencep = peer->rap_persistence; - - read_unlock(&kranal_data.kra_global_lock); - return 0; - } - } - - read_unlock(&kranal_data.kra_global_lock); - return -ENOENT; -} - -int -kranal_add_persistent_peer (ptl_nid_t nid, __u32 ip, int port) -{ - unsigned long flags; - kra_peer_t *peer; - kra_peer_t *peer2; - - if (nid == PTL_NID_ANY) - return -EINVAL; - - peer = kranal_create_peer(nid); - if (peer == NULL) - return -ENOMEM; - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - peer2 = kranal_find_peer_locked(nid); - if (peer2 != NULL) { - kranal_peer_decref(peer); - peer = peer2; - } else { - /* peer table takes existing ref on peer */ - list_add_tail(&peer->rap_list, - kranal_nid2peerlist(nid)); - } - - peer->rap_ip = ip; - peer->rap_port = port; - peer->rap_persistence++; - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - return 0; -} - -void -kranal_del_peer_locked (kra_peer_t *peer, int single_share) -{ - struct list_head *ctmp; - struct list_head *cnxt; - kra_conn_t *conn; - - if (!single_share) - peer->rap_persistence = 0; - else if (peer->rap_persistence > 0) - peer->rap_persistence--; - - if (peer->rap_persistence != 0) - return; - - if (list_empty(&peer->rap_conns)) { - kranal_unlink_peer_locked(peer); - } else { - list_for_each_safe(ctmp, cnxt, &peer->rap_conns) { - conn = list_entry(ctmp, kra_conn_t, rac_list); - - kranal_close_conn_locked(conn, 0); - } - /* peer unlinks itself when last conn is closed */ - } -} - -int -kranal_del_peer (ptl_nid_t nid, int single_share) -{ - unsigned long flags; - struct list_head *ptmp; - struct list_head *pnxt; - kra_peer_t *peer; - int lo; - int hi; - int i; - int rc = -ENOENT; - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = kranal_nid2peerlist(nid) - kranal_data.kra_peers; - else { - lo = 0; - hi = kranal_data.kra_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &kranal_data.kra_peers[i]) { - peer = list_entry(ptmp, kra_peer_t, rap_list); - LASSERT (peer->rap_persistence > 0 || - !list_empty(&peer->rap_conns)); - - if (!(nid == PTL_NID_ANY || peer->rap_nid == nid)) - continue; - - kranal_del_peer_locked(peer, single_share); - rc = 0; /* matched something */ - - if (single_share) - goto out; - } - } - out: - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - - return rc; -} - -kra_conn_t * -kranal_get_conn_by_idx (int index) -{ - kra_peer_t *peer; - struct list_head *ptmp; - kra_conn_t *conn; - struct list_head *ctmp; - int i; - - read_lock (&kranal_data.kra_global_lock); - - for (i = 0; i < kranal_data.kra_peer_hash_size; i++) { - list_for_each (ptmp, &kranal_data.kra_peers[i]) { - - peer = list_entry(ptmp, kra_peer_t, rap_list); - LASSERT (peer->rap_persistence > 0 || - !list_empty(&peer->rap_conns)); - - list_for_each (ctmp, &peer->rap_conns) { - if (index-- > 0) - continue; - - conn = list_entry(ctmp, kra_conn_t, rac_list); - CDEBUG(D_NET, "++conn[%p] -> "LPX64" (%d)\n", - conn, conn->rac_peer->rap_nid, - atomic_read(&conn->rac_refcount)); - atomic_inc(&conn->rac_refcount); - read_unlock(&kranal_data.kra_global_lock); - return conn; - } - } - } - - read_unlock(&kranal_data.kra_global_lock); - return NULL; -} - -int -kranal_close_peer_conns_locked (kra_peer_t *peer, int why) -{ - kra_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->rap_conns) { - conn = list_entry(ctmp, kra_conn_t, rac_list); - - count++; - kranal_close_conn_locked(conn, why); - } - - return count; -} - -int -kranal_close_stale_conns_locked (kra_peer_t *peer, __u64 incarnation) -{ - kra_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->rap_conns) { - conn = list_entry(ctmp, kra_conn_t, rac_list); - - if (conn->rac_peer_incarnation == incarnation) - continue; - - CDEBUG(D_NET, "Closing stale conn nid:"LPX64" incarnation:"LPX64"("LPX64")\n", - peer->rap_nid, conn->rac_peer_incarnation, incarnation); - LASSERT (conn->rac_peer_incarnation < incarnation); - - count++; - kranal_close_conn_locked(conn, -ESTALE); - } - - return count; -} - -int -kranal_close_matching_conns (ptl_nid_t nid) -{ - unsigned long flags; - kra_peer_t *peer; - struct list_head *ptmp; - struct list_head *pnxt; - int lo; - int hi; - int i; - int count = 0; - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = kranal_nid2peerlist(nid) - kranal_data.kra_peers; - else { - lo = 0; - hi = kranal_data.kra_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &kranal_data.kra_peers[i]) { - - peer = list_entry(ptmp, kra_peer_t, rap_list); - LASSERT (peer->rap_persistence > 0 || - !list_empty(&peer->rap_conns)); - - if (!(nid == PTL_NID_ANY || nid == peer->rap_nid)) - continue; - - count += kranal_close_peer_conns_locked(peer, 0); - } - } - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - - /* wildcards always succeed */ - if (nid == PTL_NID_ANY) - return 0; - - return (count == 0) ? -ENOENT : 0; -} - -int -kranal_cmd(struct portals_cfg *pcfg, void * private) -{ - int rc = -EINVAL; - - LASSERT (pcfg != NULL); - - switch(pcfg->pcfg_command) { - case NAL_CMD_GET_PEER: { - ptl_nid_t nid = 0; - __u32 ip = 0; - int port = 0; - int share_count = 0; - - rc = kranal_get_peer_info(pcfg->pcfg_count, - &nid, &ip, &port, &share_count); - pcfg->pcfg_nid = nid; - pcfg->pcfg_size = 0; - pcfg->pcfg_id = ip; - pcfg->pcfg_misc = port; - pcfg->pcfg_count = 0; - pcfg->pcfg_wait = share_count; - break; - } - case NAL_CMD_ADD_PEER: { - rc = kranal_add_persistent_peer(pcfg->pcfg_nid, - pcfg->pcfg_id, /* IP */ - pcfg->pcfg_misc); /* port */ - break; - } - case NAL_CMD_DEL_PEER: { - rc = kranal_del_peer(pcfg->pcfg_nid, - /* flags == single_share */ - pcfg->pcfg_flags != 0); - break; - } - case NAL_CMD_GET_CONN: { - kra_conn_t *conn = kranal_get_conn_by_idx(pcfg->pcfg_count); - - if (conn == NULL) - rc = -ENOENT; - else { - rc = 0; - pcfg->pcfg_nid = conn->rac_peer->rap_nid; - pcfg->pcfg_id = 0; - pcfg->pcfg_misc = 0; - pcfg->pcfg_flags = 0; - kranal_conn_decref(conn); - } - break; - } - case NAL_CMD_CLOSE_CONNECTION: { - rc = kranal_close_matching_conns(pcfg->pcfg_nid); - break; - } - case NAL_CMD_REGISTER_MYNID: { - if (pcfg->pcfg_nid == PTL_NID_ANY) - rc = -EINVAL; - else - rc = kranal_set_mynid(pcfg->pcfg_nid); - break; - } - } - - return rc; -} - -void -kranal_free_txdescs(struct list_head *freelist) -{ - kra_tx_t *tx; - - while (!list_empty(freelist)) { - tx = list_entry(freelist->next, kra_tx_t, tx_list); - - list_del(&tx->tx_list); - PORTAL_FREE(tx->tx_phys, PTL_MD_MAX_IOV * sizeof(*tx->tx_phys)); - PORTAL_FREE(tx, sizeof(*tx)); - } -} - -int -kranal_alloc_txdescs(struct list_head *freelist, int n) -{ - int isnblk = (freelist == &kranal_data.kra_idle_nblk_txs); - int i; - kra_tx_t *tx; - - LASSERT (freelist == &kranal_data.kra_idle_txs || - freelist == &kranal_data.kra_idle_nblk_txs); - LASSERT (list_empty(freelist)); - - for (i = 0; i < n; i++) { - - PORTAL_ALLOC(tx, sizeof(*tx)); - if (tx == NULL) { - CERROR("Can't allocate %stx[%d]\n", - isnblk ? "nblk " : "", i); - kranal_free_txdescs(freelist); - return -ENOMEM; - } - - PORTAL_ALLOC(tx->tx_phys, - PTL_MD_MAX_IOV * sizeof(*tx->tx_phys)); - if (tx->tx_phys == NULL) { - CERROR("Can't allocate %stx[%d]->tx_phys\n", - isnblk ? "nblk " : "", i); - - PORTAL_FREE(tx, sizeof(*tx)); - kranal_free_txdescs(freelist); - return -ENOMEM; - } - - tx->tx_isnblk = isnblk; - tx->tx_buftype = RANAL_BUF_NONE; - - list_add(&tx->tx_list, freelist); - } - - return 0; -} - -int -kranal_device_init(int id, kra_device_t *dev) -{ - const int total_ntx = RANAL_NTX + RANAL_NTX_NBLK; - RAP_RETURN rrc; - - dev->rad_id = id; - rrc = RapkGetDeviceByIndex(id, kranal_device_callback, - &dev->rad_handle); - if (rrc != RAP_SUCCESS) { - CERROR("Can't get Rapidarray Device %d: %d\n", id, rrc); - goto failed_0; - } - - rrc = RapkReserveRdma(dev->rad_handle, total_ntx); - if (rrc != RAP_SUCCESS) { - CERROR("Can't reserve %d RDMA descriptors" - " for device %d: %d\n", total_ntx, id, rrc); - goto failed_1; - } - - rrc = RapkCreatePtag(dev->rad_handle, - &dev->rad_ptag); - if (rrc != RAP_SUCCESS) { - CERROR("Can't create ptag" - " for device %d: %d\n", id, rrc); - goto failed_1; - } - - rrc = RapkCreateCQ(dev->rad_handle, total_ntx, dev->rad_ptag, - &dev->rad_rdma_cq); - if (rrc != RAP_SUCCESS) { - CERROR("Can't create rdma cq size %d" - " for device %d: %d\n", total_ntx, id, rrc); - goto failed_2; - } - - rrc = RapkCreateCQ(dev->rad_handle, RANAL_FMA_CQ_SIZE, - dev->rad_ptag, &dev->rad_fma_cq); - if (rrc != RAP_SUCCESS) { - CERROR("Can't create fma cq size %d" - " for device %d: %d\n", RANAL_FMA_CQ_SIZE, id, rrc); - goto failed_3; - } - - return 0; - - failed_3: - RapkDestroyCQ(dev->rad_handle, dev->rad_rdma_cq, dev->rad_ptag); - failed_2: - RapkDestroyPtag(dev->rad_handle, dev->rad_ptag); - failed_1: - RapkReleaseDevice(dev->rad_handle); - failed_0: - return -ENODEV; -} - -void -kranal_device_fini(kra_device_t *dev) -{ - RapkDestroyCQ(dev->rad_handle, dev->rad_fma_cq, dev->rad_ptag); - RapkDestroyCQ(dev->rad_handle, dev->rad_rdma_cq, dev->rad_ptag); - RapkDestroyPtag(dev->rad_handle, dev->rad_ptag); - RapkReleaseDevice(dev->rad_handle); -} - -void -kranal_api_shutdown (nal_t *nal) -{ - int i; - int rc; - unsigned long flags; - - if (nal->nal_refct != 0) { - /* This module got the first ref */ - PORTAL_MODULE_UNUSE; - return; - } - - CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n", - atomic_read(&portal_kmemory)); - - LASSERT (nal == &kranal_api); - - switch (kranal_data.kra_init) { - default: - CERROR("Unexpected state %d\n", kranal_data.kra_init); - LBUG(); - - case RANAL_INIT_ALL: - /* stop calls to nal_cmd */ - libcfs_nal_cmd_unregister(RANAL); - /* No new persistent peers */ - - /* resetting my NID to unadvertises me, removes my - * listener and nukes all current peers */ - kranal_set_mynid(PTL_NID_ANY); - /* no new peers or conns */ - - /* Wait for all peer/conn state to clean up */ - i = 2; - while (atomic_read(&kranal_data.kra_nconns) != 0 || - atomic_read(&kranal_data.kra_npeers) != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "waiting for %d peers and %d conns to close down\n", - atomic_read(&kranal_data.kra_npeers), - atomic_read(&kranal_data.kra_nconns)); - kranal_pause(HZ); - } - /* fall through */ - - case RANAL_INIT_LIB: - lib_fini(&kranal_lib); - /* fall through */ - - case RANAL_INIT_DATA: - break; - } - - /* flag threads to terminate; wake and wait for them to die */ - kranal_data.kra_shutdown = 1; - - for (i = 0; i < kranal_data.kra_ndevs; i++) { - kra_device_t *dev = &kranal_data.kra_devices[i]; - - LASSERT (list_empty(&dev->rad_connq)); - - spin_lock_irqsave(&dev->rad_lock, flags); - wake_up(&dev->rad_waitq); - spin_unlock_irqrestore(&dev->rad_lock, flags); - } - - spin_lock_irqsave(&kranal_data.kra_reaper_lock, flags); - wake_up_all(&kranal_data.kra_reaper_waitq); - spin_unlock_irqrestore(&kranal_data.kra_reaper_lock, flags); - - LASSERT (list_empty(&kranal_data.kra_connd_peers)); - spin_lock_irqsave(&kranal_data.kra_connd_lock, flags); - wake_up_all(&kranal_data.kra_connd_waitq); - spin_unlock_irqrestore(&kranal_data.kra_connd_lock, flags); - - i = 2; - while (atomic_read(&kranal_data.kra_nthreads) != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "Waiting for %d threads to terminate\n", - atomic_read(&kranal_data.kra_nthreads)); - kranal_pause(HZ); - } - - LASSERT (atomic_read(&kranal_data.kra_npeers) == 0); - if (kranal_data.kra_peers != NULL) { - for (i = 0; i < kranal_data.kra_peer_hash_size; i++) - LASSERT (list_empty(&kranal_data.kra_peers[i])); - - PORTAL_FREE(kranal_data.kra_peers, - sizeof (struct list_head) * - kranal_data.kra_peer_hash_size); - } - - LASSERT (atomic_read(&kranal_data.kra_nconns) == 0); - if (kranal_data.kra_conns != NULL) { - for (i = 0; i < kranal_data.kra_conn_hash_size; i++) - LASSERT (list_empty(&kranal_data.kra_conns[i])); - - PORTAL_FREE(kranal_data.kra_conns, - sizeof (struct list_head) * - kranal_data.kra_conn_hash_size); - } - - for (i = 0; i < kranal_data.kra_ndevs; i++) - kranal_device_fini(&kranal_data.kra_devices[i]); - - kranal_free_txdescs(&kranal_data.kra_idle_txs); - kranal_free_txdescs(&kranal_data.kra_idle_nblk_txs); - - CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n", - atomic_read(&portal_kmemory)); - printk(KERN_INFO "Lustre: RapidArray NAL unloaded (final mem %d)\n", - atomic_read(&portal_kmemory)); - - kranal_data.kra_init = RANAL_INIT_NOTHING; -} - -int -kranal_api_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - static int device_ids[] = {RAPK_MAIN_DEVICE_ID, - RAPK_EXPANSION_DEVICE_ID}; - struct timeval tv; - ptl_process_id_t process_id; - int pkmem = atomic_read(&portal_kmemory); - int rc; - int i; - kra_device_t *dev; - - LASSERT (nal == &kranal_api); - - if (nal->nal_refct != 0) { - if (actual_limits != NULL) - *actual_limits = kranal_lib.libnal_ni.ni_actual_limits; - /* This module got the first ref */ - PORTAL_MODULE_USE; - return PTL_OK; - } - - LASSERT (kranal_data.kra_init == RANAL_INIT_NOTHING); - - memset(&kranal_data, 0, sizeof(kranal_data)); /* zero pointers, flags etc */ - - /* CAVEAT EMPTOR: Every 'Fma' message includes the sender's NID and - * a unique (for all time) incarnation so we can uniquely identify - * the sender. The incarnation is an incrementing counter - * initialised with seconds + microseconds at startup time. So we - * rely on NOT creating connections more frequently on average than - * 1MHz to ensure we don't use old incarnations when we reboot. */ - do_gettimeofday(&tv); - kranal_data.kra_next_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; - - init_MUTEX(&kranal_data.kra_nid_mutex); - init_MUTEX_LOCKED(&kranal_data.kra_listener_signal); - - rwlock_init(&kranal_data.kra_global_lock); - - for (i = 0; i < RANAL_MAXDEVS; i++ ) { - kra_device_t *dev = &kranal_data.kra_devices[i]; - - dev->rad_idx = i; - INIT_LIST_HEAD(&dev->rad_connq); - init_waitqueue_head(&dev->rad_waitq); - spin_lock_init(&dev->rad_lock); - } - - init_waitqueue_head(&kranal_data.kra_reaper_waitq); - spin_lock_init(&kranal_data.kra_reaper_lock); - - INIT_LIST_HEAD(&kranal_data.kra_connd_peers); - init_waitqueue_head(&kranal_data.kra_connd_waitq); - spin_lock_init(&kranal_data.kra_connd_lock); - - INIT_LIST_HEAD(&kranal_data.kra_idle_txs); - INIT_LIST_HEAD(&kranal_data.kra_idle_nblk_txs); - init_waitqueue_head(&kranal_data.kra_idle_tx_waitq); - spin_lock_init(&kranal_data.kra_tx_lock); - - /* OK to call kranal_api_shutdown() to cleanup now */ - kranal_data.kra_init = RANAL_INIT_DATA; - - kranal_data.kra_peer_hash_size = RANAL_PEER_HASH_SIZE; - PORTAL_ALLOC(kranal_data.kra_peers, - sizeof(struct list_head) * kranal_data.kra_peer_hash_size); - if (kranal_data.kra_peers == NULL) - goto failed; - - for (i = 0; i < kranal_data.kra_peer_hash_size; i++) - INIT_LIST_HEAD(&kranal_data.kra_peers[i]); - - kranal_data.kra_conn_hash_size = RANAL_PEER_HASH_SIZE; - PORTAL_ALLOC(kranal_data.kra_conns, - sizeof(struct list_head) * kranal_data.kra_conn_hash_size); - if (kranal_data.kra_conns == NULL) - goto failed; - - for (i = 0; i < kranal_data.kra_conn_hash_size; i++) - INIT_LIST_HEAD(&kranal_data.kra_conns[i]); - - rc = kranal_alloc_txdescs(&kranal_data.kra_idle_txs, RANAL_NTX); - if (rc != 0) - goto failed; - - rc = kranal_alloc_txdescs(&kranal_data.kra_idle_nblk_txs,RANAL_NTX_NBLK); - if (rc != 0) - goto failed; - - process_id.pid = requested_pid; - process_id.nid = PTL_NID_ANY; /* don't know my NID yet */ - - rc = lib_init(&kranal_lib, nal, process_id, - requested_limits, actual_limits); - if (rc != PTL_OK) { - CERROR("lib_init failed: error %d\n", rc); - goto failed; - } - - /* lib interface initialised */ - kranal_data.kra_init = RANAL_INIT_LIB; - /*****************************************************/ - - rc = kranal_thread_start(kranal_reaper, NULL); - if (rc != 0) { - CERROR("Can't spawn ranal reaper: %d\n", rc); - goto failed; - } - - for (i = 0; i < RANAL_N_CONND; i++) { - rc = kranal_thread_start(kranal_connd, (void *)i); - if (rc != 0) { - CERROR("Can't spawn ranal connd[%d]: %d\n", - i, rc); - goto failed; - } - } - - LASSERT(kranal_data.kra_ndevs == 0); - for (i = 0; i < sizeof(device_ids)/sizeof(device_ids[0]); i++) { - dev = &kranal_data.kra_devices[kranal_data.kra_ndevs]; - - rc = kranal_device_init(device_ids[i], dev); - if (rc == 0) - kranal_data.kra_ndevs++; - - rc = kranal_thread_start(kranal_scheduler, dev); - if (rc != 0) { - CERROR("Can't spawn ranal scheduler[%d]: %d\n", - i, rc); - goto failed; - } - } - - if (kranal_data.kra_ndevs == 0) - goto failed; - - rc = libcfs_nal_cmd_register(RANAL, &kranal_cmd, NULL); - if (rc != 0) { - CERROR("Can't initialise command interface (rc = %d)\n", rc); - goto failed; - } - - /* flag everything initialised */ - kranal_data.kra_init = RANAL_INIT_ALL; - /*****************************************************/ - - CDEBUG(D_MALLOC, "initial kmem %d\n", atomic_read(&portal_kmemory)); - printk(KERN_INFO "Lustre: RapidArray NAL loaded " - "(initial mem %d)\n", pkmem); - - return PTL_OK; - - failed: - kranal_api_shutdown(&kranal_api); - return PTL_FAIL; -} - -void __exit -kranal_module_fini (void) -{ -#ifdef CONFIG_SYSCTL - if (kranal_tunables.kra_sysctl != NULL) - unregister_sysctl_table(kranal_tunables.kra_sysctl); -#endif - PtlNIFini(kranal_ni); - - ptl_unregister_nal(RANAL); -} - -int __init -kranal_module_init (void) -{ - int rc; - - /* the following must be sizeof(int) for - * proc_dointvec/kranal_listener_procint() */ - LASSERT (sizeof(kranal_tunables.kra_timeout) == sizeof(int)); - LASSERT (sizeof(kranal_tunables.kra_listener_timeout) == sizeof(int)); - LASSERT (sizeof(kranal_tunables.kra_backlog) == sizeof(int)); - LASSERT (sizeof(kranal_tunables.kra_port) == sizeof(int)); - LASSERT (sizeof(kranal_tunables.kra_max_immediate) == sizeof(int)); - - kranal_api.nal_ni_init = kranal_api_startup; - kranal_api.nal_ni_fini = kranal_api_shutdown; - - /* Initialise dynamic tunables to defaults once only */ - kranal_tunables.kra_timeout = RANAL_TIMEOUT; - - rc = ptl_register_nal(RANAL, &kranal_api); - if (rc != PTL_OK) { - CERROR("Can't register RANAL: %d\n", rc); - return -ENOMEM; /* or something... */ - } - - /* Pure gateways want the NAL started up at module load time... */ - rc = PtlNIInit(RANAL, LUSTRE_SRV_PTL_PID, NULL, NULL, &kranal_ni); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) { - ptl_unregister_nal(RANAL); - return -ENODEV; - } - -#ifdef CONFIG_SYSCTL - /* Press on regardless even if registering sysctl doesn't work */ - kranal_tunables.kra_sysctl = - register_sysctl_table(kranal_top_ctl_table, 0); -#endif - return 0; -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Kernel RapidArray NAL v0.01"); -MODULE_LICENSE("GPL"); - -module_init(kranal_module_init); -module_exit(kranal_module_fini); diff --git a/lnet/klnds/ralnd/ralnd.h b/lnet/klnds/ralnd/ralnd.h deleted file mode 100644 index fe130b7..0000000 --- a/lnet/klnds/ralnd/ralnd.h +++ /dev/null @@ -1,477 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#define DEBUG_SUBSYSTEM S_NAL - -#include -#include -#include -#include - -#include - -#if CONFIG_SMP -# define RANAL_N_SCHED num_online_cpus() /* # schedulers */ -#else -# define RANAL_N_SCHED 1 /* # schedulers */ -#endif - -#define RANAL_MAXDEVS 2 /* max # devices RapidArray supports */ - -#define RANAL_N_CONND 4 /* # connection daemons */ - -#define RANAL_MIN_RECONNECT_INTERVAL 1 /* first failed connection retry (seconds)... */ -#define RANAL_MAX_RECONNECT_INTERVAL 60 /* ...exponentially increasing to this */ - -#define RANAL_FMA_PREFIX_LEN 232 /* size of FMA "Prefix" */ -#define RANAL_FMA_MAX_DATA_LEN ((7<<10)-256) /* Max FMA MSG is 7K including prefix */ - -#define RANAL_PEER_HASH_SIZE 101 /* # peer lists */ -#define RANAL_CONN_HASH_SIZE 101 /* # conn lists */ - -#define RANAL_NTX 64 /* # tx descs */ -#define RANAL_NTX_NBLK 256 /* # reserved tx descs */ - -#define RANAL_FMA_CQ_SIZE 8192 /* # entries in receive CQ - * (overflow is a performance hit) */ - -#define RANAL_RESCHED 100 /* # scheduler loops before reschedule */ - -#define RANAL_MIN_TIMEOUT 5 /* minimum timeout interval (seconds) */ -#define RANAL_TIMEOUT2KEEPALIVE(t) (((t)+1)/2) /* timeout -> keepalive interval */ - -/* default vals for runtime tunables */ -#define RANAL_TIMEOUT 30 /* comms timeout (seconds) */ -#define RANAL_LISTENER_TIMEOUT 5 /* listener timeout (seconds) */ -#define RANAL_MAX_IMMEDIATE (2<<10) /* biggest immediate payload */ - -typedef struct -{ - int kra_timeout; /* comms timeout (seconds) */ - int kra_listener_timeout; /* max time the listener can block */ - int kra_backlog; /* listener's backlog */ - int kra_port; /* listener's TCP/IP port */ - int kra_max_immediate; /* biggest immediate payload */ - struct ctl_table_header *kra_sysctl; /* sysctl interface */ -} kra_tunables_t; - -typedef struct -{ - RAP_PVOID rad_handle; /* device handle */ - RAP_PROTECTION_HANDLE rad_ptag; /* protection tag */ - RAP_CQ_HANDLE rad_fma_cq; /* FMA (small message) completion queue */ - RAP_CQ_HANDLE rad_rdma_cq; /* rdma completion queue */ - int rad_id; /* device id */ - int rad_idx; /* index in kra_devices */ - int rad_ready; /* set by device callback */ - struct list_head rad_connq; /* connections requiring attention */ - wait_queue_head_t rad_waitq; /* scheduler waits here */ - spinlock_t rad_lock; /* serialise */ -} kra_device_t; - -typedef struct -{ - int kra_init; /* initialisation state */ - int kra_shutdown; /* shut down? */ - atomic_t kra_nthreads; /* # live threads */ - - struct semaphore kra_nid_mutex; /* serialise NID/listener ops */ - struct semaphore kra_listener_signal; /* block for listener startup/shutdown */ - struct socket *kra_listener_sock; /* listener's socket */ - int kra_listener_shutdown; /* ask listener to close */ - - kra_device_t kra_devices[RANAL_MAXDEVS]; /* device/ptag/cq etc */ - int kra_ndevs; /* # devices */ - - rwlock_t kra_global_lock; /* stabilize peer/conn ops */ - - struct list_head *kra_peers; /* hash table of all my known peers */ - int kra_peer_hash_size; /* size of kra_peers */ - atomic_t kra_npeers; /* # peers extant */ - - struct list_head *kra_conns; /* conns hashed by cqid */ - int kra_conn_hash_size; /* size of kra_conns */ - __u64 kra_next_incarnation; /* conn incarnation # generator */ - int kra_next_cqid; /* cqid generator */ - atomic_t kra_nconns; /* # connections extant */ - - long kra_new_min_timeout; /* minimum timeout on any new conn */ - wait_queue_head_t kra_reaper_waitq; /* reaper sleeps here */ - spinlock_t kra_reaper_lock; /* serialise */ - - struct list_head kra_connd_peers; /* peers waiting for a connection */ - wait_queue_head_t kra_connd_waitq; /* connection daemons sleep here */ - spinlock_t kra_connd_lock; /* serialise */ - - struct list_head kra_idle_txs; /* idle tx descriptors */ - struct list_head kra_idle_nblk_txs; /* idle reserved tx descriptors */ - __u64 kra_next_tx_cookie; /* RDMA completion cookie */ - wait_queue_head_t kra_idle_tx_waitq; /* block here for tx descriptor */ - spinlock_t kra_tx_lock; /* serialise */ -} kra_data_t; - -#define RANAL_INIT_NOTHING 0 -#define RANAL_INIT_DATA 1 -#define RANAL_INIT_LIB 2 -#define RANAL_INIT_ALL 3 - -/************************************************************************ - * Wire message structs. These are sent in sender's byte order - * (i.e. receiver checks magic and flips if required). - */ - -typedef struct kra_connreq /* connection request/response */ -{ /* (sent via socket) */ - __u32 racr_magic; /* I'm an ranal connreq */ - __u16 racr_version; /* this is my version number */ - __u16 racr_devid; /* which device to connect on */ - __u64 racr_nid; /* my NID */ - __u64 racr_incarnation; /* my incarnation */ - __u32 racr_timeout; /* my timeout */ - RAP_RI_PARAMETERS racr_riparams; /* my endpoint info */ -} kra_connreq_t; - -typedef struct -{ - RAP_MEM_KEY rard_key; - RAP_PVOID64 rard_addr; - RAP_UINT32 rard_nob; -} kra_rdma_desc_t; - -typedef struct -{ - ptl_hdr_t raim_hdr; /* portals header */ - /* Portals payload is in FMA "Message Data" */ -} kra_immediate_msg_t; - -typedef struct -{ - ptl_hdr_t raprm_hdr; /* portals header */ - __u64 raprm_cookie; /* opaque completion cookie */ -} kra_putreq_msg_t; - -typedef struct -{ - __u64 rapam_src_cookie; /* reflected completion cookie */ - __u64 rapam_dst_cookie; /* opaque completion cookie */ - kra_rdma_desc_t rapam_desc; /* sender's sink buffer */ -} kra_putack_msg_t; - -typedef struct -{ - ptl_hdr_t ragm_hdr; /* portals header */ - __u64 ragm_cookie; /* opaque completion cookie */ - kra_rdma_desc_t ragm_desc; /* sender's sink buffer */ -} kra_get_msg_t; - -typedef struct -{ - __u64 racm_cookie; /* reflected completion cookie */ -} kra_completion_msg_t; - -typedef struct /* NB must fit in FMA "Prefix" */ -{ - __u32 ram_magic; /* I'm an ranal message */ - __u16 ram_version; /* this is my version number */ - __u16 ram_type; /* msg type */ - __u64 ram_srcnid; /* sender's NID */ - __u64 ram_incarnation; /* sender's connection incarnation */ - union { - kra_immediate_msg_t immediate; - kra_putreq_msg_t putreq; - kra_putack_msg_t putack; - kra_get_msg_t get; - kra_completion_msg_t completion; - } ram_u; - __u32 ram_seq; /* incrementing sequence number */ -} kra_msg_t; - -#define RANAL_MSG_MAGIC 0x0be91b92 /* unique magic */ -#define RANAL_MSG_VERSION 1 /* current protocol version */ - -#define RANAL_MSG_FENCE 0x80 /* fence RDMA */ - -#define RANAL_MSG_NONE 0x00 /* illegal message */ -#define RANAL_MSG_NOOP 0x01 /* empty ram_u (keepalive) */ -#define RANAL_MSG_IMMEDIATE 0x02 /* ram_u.immediate */ -#define RANAL_MSG_PUT_REQ 0x03 /* ram_u.putreq (src->sink) */ -#define RANAL_MSG_PUT_NAK 0x04 /* ram_u.completion (no PUT match: sink->src) */ -#define RANAL_MSG_PUT_ACK 0x05 /* ram_u.putack (PUT matched: sink->src) */ -#define RANAL_MSG_PUT_DONE 0x86 /* ram_u.completion (src->sink) */ -#define RANAL_MSG_GET_REQ 0x07 /* ram_u.get (sink->src) */ -#define RANAL_MSG_GET_NAK 0x08 /* ram_u.completion (no GET match: src->sink) */ -#define RANAL_MSG_GET_DONE 0x89 /* ram_u.completion (src->sink) */ -#define RANAL_MSG_CLOSE 0x8a /* empty ram_u */ - -/***********************************************************************/ - -typedef struct kra_tx /* message descriptor */ -{ - struct list_head tx_list; /* queue on idle_txs/rac_sendq/rac_waitq */ - struct kra_conn *tx_conn; /* owning conn */ - lib_msg_t *tx_libmsg[2]; /* lib msgs to finalize on completion */ - unsigned long tx_qtime; /* when tx started to wait for something */ - int tx_isnblk; /* I'm reserved for non-blocking sends */ - int tx_nob; /* # bytes of payload */ - int tx_buftype; /* payload buffer type */ - void *tx_buffer; /* source/sink buffer */ - int tx_phys_offset; /* first page offset (if phys) */ - int tx_phys_npages; /* # physical pages */ - RAP_PHYS_REGION *tx_phys; /* page descriptors */ - RAP_MEM_KEY tx_map_key; /* mapping key */ - RAP_RDMA_DESCRIPTOR tx_rdma_desc; /* rdma descriptor */ - __u64 tx_cookie; /* identify this tx to peer */ - kra_msg_t tx_msg; /* FMA message buffer */ -} kra_tx_t; - -#define RANAL_BUF_NONE 0 /* buffer type not set */ -#define RANAL_BUF_IMMEDIATE 1 /* immediate data */ -#define RANAL_BUF_PHYS_UNMAPPED 2 /* physical: not mapped yet */ -#define RANAL_BUF_PHYS_MAPPED 3 /* physical: mapped already */ -#define RANAL_BUF_VIRT_UNMAPPED 4 /* virtual: not mapped yet */ -#define RANAL_BUF_VIRT_MAPPED 5 /* virtual: mapped already */ - -#define RANAL_TX_IDLE 0x00 /* on freelist */ -#define RANAL_TX_SIMPLE 0x10 /* about to send a simple message */ -#define RANAL_TX_PUTI_REQ 0x20 /* PUT initiator about to send PUT_REQ */ -#define RANAL_TX_PUTI_WAIT_ACK 0x21 /* PUT initiator waiting for PUT_ACK */ -#define RANAL_TX_PUTI_RDMA 0x22 /* PUT initiator waiting for RDMA to complete */ -#define RANAL_TX_PUTI_DONE 0x23 /* PUT initiator about to send PUT_DONE */ -#define RANAL_TX_PUTT_NAK 0x30 /* PUT target about to send PUT_NAK */ -#define RANAL_TX_PUTT_ACK 0x30 /* PUT target about to send PUT_ACK */ -#define RANAL_TX_PUTT_WAIT_DONE 0x31 /* PUT target waiting for PUT_DONE */ -#define RANAL_TX_GETI_REQ 0x40 /* GET initiator about to send GET_REQ */ -#define RANAL_TX_GETI_WAIT_DONE 0x41 /* GET initiator waiting for GET_DONE */ -#define RANAL_TX_GETT_NAK 0x50 /* GET target about to send PUT_NAK */ -#define RANAL_TX_GETT_RDMA 0x51 /* GET target waiting for RDMA to complete */ -#define RANAL_TX_GETT_DONE 0x52 /* GET target about to send GET_DONE */ - -typedef struct kra_conn -{ - struct kra_peer *rac_peer; /* owning peer */ - struct list_head rac_list; /* stash on peer's conn list */ - struct list_head rac_hashlist; /* stash in connection hash table */ - struct list_head rac_schedlist; /* queue for scheduler */ - struct list_head rac_fmaq; /* txs queued for FMA */ - struct list_head rac_rdmaq; /* txs awaiting RDMA completion */ - struct list_head rac_replyq; /* txs awaiting replies */ - __u64 rac_peer_incarnation; /* peer's unique connection stamp */ - __u64 rac_my_incarnation; /* my unique connection stamp */ - unsigned long rac_last_tx; /* when I last sent an FMA message */ - unsigned long rac_last_rx; /* when I last received an FMA messages */ - long rac_keepalive; /* keepalive interval */ - long rac_timeout; /* infer peer death on (last_rx + timout > now) */ - __u32 rac_cqid; /* my completion callback id (non-unique) */ - __u32 rac_tx_seq; /* tx msg sequence number */ - __u32 rac_rx_seq; /* rx msg sequence number */ - atomic_t rac_refcount; /* # users */ - unsigned int rac_close_sent; /* I've sent CLOSE */ - unsigned int rac_close_recvd; /* I've received CLOSE */ - unsigned int rac_closing; /* connection being torn down */ - unsigned int rac_scheduled; /* being attented to */ - spinlock_t rac_lock; /* serialise */ - kra_device_t *rac_device; /* which device */ - RAP_PVOID rac_rihandle; /* RA endpoint */ - kra_msg_t *rac_rxmsg; /* incoming message (FMA prefix) */ - kra_msg_t rac_msg; /* keepalive/CLOSE message buffer */ -} kra_conn_t; - -typedef struct kra_peer -{ - struct list_head rap_list; /* stash on global peer list */ - struct list_head rap_connd_list; /* schedule on kra_connd_peers */ - struct list_head rap_conns; /* all active connections */ - struct list_head rap_tx_queue; /* msgs waiting for a conn */ - ptl_nid_t rap_nid; /* who's on the other end(s) */ - __u32 rap_ip; /* IP address of peer */ - int rap_port; /* port on which peer listens */ - atomic_t rap_refcount; /* # users */ - int rap_persistence; /* "known" peer refs */ - int rap_connecting; /* connection forming */ - unsigned long rap_reconnect_time; /* CURRENT_TIME when reconnect OK */ - unsigned long rap_reconnect_interval; /* exponential backoff */ -} kra_peer_t; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) -# define sk_allocation allocation -# define sk_data_ready data_ready -# define sk_write_space write_space -# define sk_user_data user_data -# define sk_prot prot -# define sk_sndbuf sndbuf -# define sk_socket socket -# define sk_wmem_queued wmem_queued -# define sk_err err -# define sk_sleep sleep -#endif - -extern lib_nal_t kranal_lib; -extern kra_data_t kranal_data; -extern kra_tunables_t kranal_tunables; - -extern void __kranal_peer_decref(kra_peer_t *peer); -extern void __kranal_conn_decref(kra_conn_t *conn); - -static inline void -kranal_peer_addref(kra_peer_t *peer) -{ - CDEBUG(D_NET, "%p->"LPX64"\n", peer, peer->rap_nid); - LASSERT(atomic_read(&peer->rap_refcount) > 0); - atomic_inc(&peer->rap_refcount); -} - -static inline void -kranal_peer_decref(kra_peer_t *peer) -{ - CDEBUG(D_NET, "%p->"LPX64"\n", peer, peer->rap_nid); - LASSERT(atomic_read(&peer->rap_refcount) > 0); - if (atomic_dec_and_test(&peer->rap_refcount)) - __kranal_peer_decref(peer); -} - -static inline struct list_head * -kranal_nid2peerlist (ptl_nid_t nid) -{ - unsigned int hash = ((unsigned int)nid) % kranal_data.kra_peer_hash_size; - - return (&kranal_data.kra_peers [hash]); -} - -static inline int -kranal_peer_active(kra_peer_t *peer) -{ - /* Am I in the peer hash table? */ - return (!list_empty(&peer->rap_list)); -} - -static inline void -kranal_conn_addref(kra_conn_t *conn) -{ - CDEBUG(D_NET, "%p->"LPX64"\n", conn, conn->rac_peer->rap_nid); - LASSERT(atomic_read(&conn->rac_refcount) > 0); - atomic_inc(&conn->rac_refcount); -} - -static inline void -kranal_conn_decref(kra_conn_t *conn) -{ - CDEBUG(D_NET, "%p->"LPX64"\n", conn, conn->rac_peer->rap_nid); - LASSERT(atomic_read(&conn->rac_refcount) > 0); - if (atomic_dec_and_test(&conn->rac_refcount)) - __kranal_conn_decref(conn); -} - -static inline struct list_head * -kranal_cqid2connlist (__u32 cqid) -{ - unsigned int hash = cqid % kranal_data.kra_conn_hash_size; - - return (&kranal_data.kra_conns [hash]); -} - -static inline kra_conn_t * -kranal_cqid2conn_locked (__u32 cqid) -{ - struct list_head *conns = kranal_cqid2connlist(cqid); - struct list_head *tmp; - kra_conn_t *conn; - - list_for_each(tmp, conns) { - conn = list_entry(tmp, kra_conn_t, rac_hashlist); - - if (conn->rac_cqid == cqid) - return conn; - } - - return NULL; -} - -static inline int -kranal_tx_mapped (kra_tx_t *tx) -{ - return (tx->tx_buftype == RANAL_BUF_VIRT_MAPPED || - tx->tx_buftype == RANAL_BUF_PHYS_MAPPED); -} - -#if CONFIG_X86 -static inline __u64 -kranal_page2phys (struct page *p) -{ - __u64 page_number = p - mem_map; - - return (page_number << PAGE_SHIFT); -} -#else -# error "no page->phys" -#endif - -extern int kranal_listener_procint(ctl_table *table, - int write, struct file *filp, - void *buffer, size_t *lenp); -extern int kranal_close_stale_conns_locked (kra_peer_t *peer, - __u64 incarnation); -extern void kranal_update_reaper_timeout(long timeout); -extern void kranal_tx_done (kra_tx_t *tx, int completion); -extern void kranal_unlink_peer_locked (kra_peer_t *peer); -extern void kranal_schedule_conn(kra_conn_t *conn); -extern kra_peer_t *kranal_create_peer (ptl_nid_t nid); -extern kra_peer_t *kranal_find_peer_locked (ptl_nid_t nid); -extern void kranal_post_fma (kra_conn_t *conn, kra_tx_t *tx); -extern int kranal_del_peer (ptl_nid_t nid, int single_share); -extern void kranal_device_callback(RAP_INT32 devid); -extern int kranal_thread_start (int(*fn)(void *arg), void *arg); -extern int kranal_connd (void *arg); -extern int kranal_reaper (void *arg); -extern int kranal_scheduler (void *arg); -extern void kranal_close_conn_locked (kra_conn_t *conn, int error); -extern void kranal_terminate_conn_locked (kra_conn_t *conn); -extern void kranal_connect (kra_peer_t *peer); diff --git a/lnet/klnds/ralnd/ralnd_cb.c b/lnet/klnds/ralnd/ralnd_cb.c deleted file mode 100644 index 9490b56..0000000 --- a/lnet/klnds/ralnd/ralnd_cb.c +++ /dev/null @@ -1,1766 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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. - * - */ - -#include "ranal.h" - -int -kranal_dist(lib_nal_t *nal, ptl_nid_t nid, unsigned long *dist) -{ - /* I would guess that if kranal_get_peer (nid) == NULL, - and we're not routing, then 'nid' is very distant :) */ - if ( nal->libnal_ni.ni_pid.nid == nid ) { - *dist = 0; - } else { - *dist = 1; - } - - return 0; -} - -void -kranal_device_callback(RAP_INT32 devid) -{ - kra_device_t *dev; - int i; - unsigned long flags; - - for (i = 0; i < kranal_data.kra_ndevs; i++) { - - dev = &kranal_data.kra_devices[i]; - if (dev->rad_id != devid) - continue; - - spin_lock_irqsave(&dev->rad_lock, flags); - - if (!dev->rad_ready) { - dev->rad_ready = 1; - wake_up(&dev->rad_waitq); - } - - spin_unlock_irqrestore(&dev->rad_lock, flags); - return; - } - - CWARN("callback for unknown device %d\n", devid); -} - -void -kranal_schedule_conn(kra_conn_t *conn) -{ - kra_device_t *dev = conn->rac_device; - unsigned long flags; - - spin_lock_irqsave(&dev->rad_lock, flags); - - if (!conn->rac_scheduled) { - kranal_conn_addref(conn); /* +1 ref for scheduler */ - conn->rac_scheduled = 1; - list_add_tail(&conn->rac_schedlist, &dev->rad_connq); - wake_up(&dev->rad_waitq); - } - - spin_unlock_irqrestore(&dev->rad_lock, flags); -} - -void -kranal_schedule_cqid (__u32 cqid) -{ - kra_conn_t *conn; - struct list_head *conns; - struct list_head *tmp; - - conns = kranal_cqid2connlist(cqid); - - read_lock(&kranal_data.kra_global_lock); - - conn = kranal_cqid2conn_locked(cqid); - - if (conn == NULL) - CWARN("no cqid %x\n", cqid); - else - kranal_schedule_conn(conn); - - read_unlock(&kranal_data.kra_global_lock); -} - -void -kranal_schedule_dev(kra_device_t *dev) -{ - kra_conn_t *conn; - struct list_head *conns; - struct list_head *tmp; - int i; - - /* Don't do this in IRQ context (servers may have 1000s of clients) */ - LASSERT (!in_interrupt()); - - CWARN("Scheduling ALL conns on device %d\n", dev->rad_id); - - for (i = 0; i < kranal_data.kra_conn_hash_size; i++) { - - /* Drop the lock on each hash bucket to ensure we don't - * block anyone for too long at IRQ priority on another CPU */ - - read_lock(&kranal_data.kra_global_lock); - - conns = &kranal_data.kra_conns[i]; - - list_for_each (tmp, conns) { - conn = list_entry(tmp, kra_conn_t, rac_hashlist); - - if (conn->rac_device == dev) - kranal_schedule_conn(conn); - } - read_unlock(&kranal_data.kra_global_lock); - } -} - -void -kranal_tx_done (kra_tx_t *tx, int completion) -{ - ptl_err_t ptlrc = (completion == 0) ? PTL_OK : PTL_FAIL; - kra_device_t *dev; - unsigned long flags; - int i; - RAP_RETURN rrc; - - LASSERT (!in_interrupt()); - - switch (tx->tx_buftype) { - default: - LBUG(); - - case RANAL_BUF_NONE: - case RANAL_BUF_IMMEDIATE: - case RANAL_BUF_PHYS_UNMAPPED: - case RANAL_BUF_VIRT_UNMAPPED: - break; - - case RANAL_BUF_PHYS_MAPPED: - LASSERT (tx->tx_conn != NULL); - dev = tx->tx_conn->rac_device; - rrc = RapkDeregisterMemory(dev->rad_handle, NULL, - dev->rad_ptag, &tx->tx_map_key); - LASSERT (rrc == RAP_SUCCESS); - break; - - case RANAL_BUF_VIRT_MAPPED: - LASSERT (tx->tx_conn != NULL); - dev = tx->tx_conn->rac_device; - rrc = RapkDeregisterMemory(dev->rad_handle, tx->tx_buffer, - dev->rad_ptag, &tx->tx_map_key); - LASSERT (rrc == RAP_SUCCESS); - break; - } - - for (i = 0; i < 2; i++) { - /* tx may have up to 2 libmsgs to finalise */ - if (tx->tx_libmsg[i] == NULL) - continue; - - lib_finalize(&kranal_lib, NULL, tx->tx_libmsg[i], ptlrc); - tx->tx_libmsg[i] = NULL; - } - - tx->tx_buftype = RANAL_BUF_NONE; - tx->tx_msg.ram_type = RANAL_MSG_NONE; - tx->tx_conn = NULL; - - spin_lock_irqsave(&kranal_data.kra_tx_lock, flags); - - if (tx->tx_isnblk) { - list_add_tail(&tx->tx_list, &kranal_data.kra_idle_nblk_txs); - } else { - list_add_tail(&tx->tx_list, &kranal_data.kra_idle_txs); - wake_up(&kranal_data.kra_idle_tx_waitq); - } - - spin_unlock_irqrestore(&kranal_data.kra_tx_lock, flags); -} - -kra_tx_t * -kranal_get_idle_tx (int may_block) -{ - unsigned long flags; - kra_tx_t *tx = NULL; - - for (;;) { - spin_lock_irqsave(&kranal_data.kra_tx_lock, flags); - - /* "normal" descriptor is free */ - if (!list_empty(&kranal_data.kra_idle_txs)) { - tx = list_entry(kranal_data.kra_idle_txs.next, - kra_tx_t, tx_list); - break; - } - - if (!may_block) { - /* may dip into reserve pool */ - if (list_empty(&kranal_data.kra_idle_nblk_txs)) { - CERROR("reserved tx desc pool exhausted\n"); - break; - } - - tx = list_entry(kranal_data.kra_idle_nblk_txs.next, - kra_tx_t, tx_list); - break; - } - - /* block for idle tx */ - spin_unlock_irqrestore(&kranal_data.kra_tx_lock, flags); - - wait_event(kranal_data.kra_idle_tx_waitq, - !list_empty(&kranal_data.kra_idle_txs)); - } - - if (tx != NULL) { - list_del(&tx->tx_list); - - /* Allocate a new completion cookie. It might not be - * needed, but we've got a lock right now... */ - tx->tx_cookie = kranal_data.kra_next_tx_cookie++; - - LASSERT (tx->tx_buftype == RANAL_BUF_NONE); - LASSERT (tx->tx_msg.ram_type == RANAL_MSG_NONE); - LASSERT (tx->tx_conn == NULL); - LASSERT (tx->tx_libmsg[0] == NULL); - LASSERT (tx->tx_libmsg[1] == NULL); - } - - spin_unlock_irqrestore(&kranal_data.kra_tx_lock, flags); - - return tx; -} - -void -kranal_init_msg(kra_msg_t *msg, int type) -{ - msg->ram_magic = RANAL_MSG_MAGIC; - msg->ram_version = RANAL_MSG_VERSION; - msg->ram_type = type; - msg->ram_srcnid = kranal_lib.libnal_ni.ni_pid.nid; - /* ram_incarnation gets set when FMA is sent */ -} - -kra_tx_t * -kranal_new_tx_msg (int may_block, int type) -{ - kra_tx_t *tx = kranal_get_idle_tx(may_block); - - if (tx == NULL) - return NULL; - - kranal_init_msg(&tx->tx_msg, type); - return tx; -} - -int -kranal_setup_immediate_buffer (kra_tx_t *tx, int niov, struct iovec *iov, - int offset, int nob) - -{ - LASSERT (nob > 0); - LASSERT (niov > 0); - LASSERT (tx->tx_buftype == RANAL_BUF_NONE); - - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - niov--; - iov++; - LASSERT (niov > 0); - } - - if (nob > iov->iov_len - offset) { - CERROR("Can't handle multiple vaddr fragments\n"); - return -EMSGSIZE; - } - - tx->tx_buftype = RANAL_BUF_IMMEDIATE; - tx->tx_nob = nob; - tx->tx_buffer = (void *)(((unsigned long)iov->iov_base) + offset); - return 0; -} - -int -kranal_setup_virt_buffer (kra_tx_t *tx, int niov, struct iovec *iov, - int offset, int nob) - -{ - LASSERT (nob > 0); - LASSERT (niov > 0); - LASSERT (tx->tx_buftype == RANAL_BUF_NONE); - - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - niov--; - iov++; - LASSERT (niov > 0); - } - - if (nob > iov->iov_len - offset) { - CERROR("Can't handle multiple vaddr fragments\n"); - return -EMSGSIZE; - } - - tx->tx_buftype = RANAL_BUF_VIRT_UNMAPPED; - tx->tx_nob = nob; - tx->tx_buffer = (void *)(((unsigned long)iov->iov_base) + offset); - return 0; -} - -int -kranal_setup_phys_buffer (kra_tx_t *tx, int nkiov, ptl_kiov_t *kiov, - int offset, int nob) -{ - RAP_PHYS_REGION *phys = tx->tx_phys; - int resid; - - CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob); - - LASSERT (nob > 0); - LASSERT (nkiov > 0); - LASSERT (tx->tx_buftype == RANAL_BUF_NONE); - - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; - nkiov--; - kiov++; - LASSERT (nkiov > 0); - } - - tx->tx_buftype = RANAL_BUF_PHYS_UNMAPPED; - tx->tx_nob = nob; - tx->tx_buffer = (void *)((unsigned long)(kiov->kiov_offset + offset)); - - phys->Address = kranal_page2phys(kiov->kiov_page); - phys->Length = PAGE_SIZE; - phys++; - - resid = nob - (kiov->kiov_len - offset); - while (resid > 0) { - kiov++; - nkiov--; - LASSERT (nkiov > 0); - - if (kiov->kiov_offset != 0 || - ((resid > PAGE_SIZE) && - kiov->kiov_len < PAGE_SIZE)) { - int i; - /* Can't have gaps */ - CERROR("Can't make payload contiguous in I/O VM:" - "page %d, offset %d, len %d \n", - phys - tx->tx_phys, - kiov->kiov_offset, kiov->kiov_len); - return -EINVAL; - } - - if ((phys - tx->tx_phys) == PTL_MD_MAX_IOV) { - CERROR ("payload too big (%d)\n", phys - tx->tx_phys); - return -EMSGSIZE; - } - - phys->Address = kranal_page2phys(kiov->kiov_page); - phys->Length = PAGE_SIZE; - phys++; - - resid -= PAGE_SIZE; - } - - tx->tx_phys_npages = phys - tx->tx_phys; - return 0; -} - -static inline int -kranal_setup_buffer (kra_tx_t *tx, int niov, - struct iovec *iov, ptl_kiov_t *kiov, - int offset, int nob) -{ - LASSERT ((iov == NULL) != (kiov == NULL)); - - if (kiov != NULL) - return kranal_setup_phys_buffer(tx, niov, kiov, offset, nob); - - return kranal_setup_virt_buffer(tx, niov, iov, offset, nob); -} - -void -kranal_map_buffer (kra_tx_t *tx) -{ - kra_conn_t *conn = tx->tx_conn; - kra_device_t *dev = conn->rac_device; - RAP_RETURN rrc; - - switch (tx->tx_buftype) { - default: - - case RANAL_BUF_PHYS_UNMAPPED: - rrc = RapkRegisterPhys(conn->rac_device->rad_handle, - tx->tx_phys, tx->tx_phys_npages, - conn->rac_device->rad_ptag, - &tx->tx_map_key); - LASSERT (rrc == RAP_SUCCESS); - tx->tx_buftype = RANAL_BUF_PHYS_MAPPED; - return; - - case RANAL_BUF_VIRT_UNMAPPED: - rrc = RapkRegisterMemory(conn->rac_device->rad_handle, - tx->tx_buffer, tx->tx_nob, - conn->rac_device->rad_ptag, - &tx->tx_map_key); - LASSERT (rrc == RAP_SUCCESS); - tx->tx_buftype = RANAL_BUF_VIRT_MAPPED; - return; - } -} - -kra_conn_t * -kranal_find_conn_locked (kra_peer_t *peer) -{ - struct list_head *tmp; - - /* just return the first connection */ - list_for_each (tmp, &peer->rap_conns) { - return list_entry(tmp, kra_conn_t, rac_list); - } - - return NULL; -} - -void -kranal_post_fma (kra_conn_t *conn, kra_tx_t *tx) -{ - unsigned long flags; - - tx->tx_conn = conn; - - spin_lock_irqsave(&conn->rac_lock, flags); - list_add_tail(&tx->tx_list, &conn->rac_fmaq); - tx->tx_qtime = jiffies; - spin_unlock_irqrestore(&conn->rac_lock, flags); - - kranal_schedule_conn(conn); -} - -void -kranal_launch_tx (kra_tx_t *tx, ptl_nid_t nid) -{ - unsigned long flags; - kra_peer_t *peer; - kra_conn_t *conn; - unsigned long now; - rwlock_t *g_lock = &kranal_data.kra_global_lock; - - /* If I get here, I've committed to send, so I complete the tx with - * failure on any problems */ - - LASSERT (tx->tx_conn == NULL); /* only set when assigned a conn */ - - read_lock(g_lock); - - peer = kranal_find_peer_locked(nid); - if (peer == NULL) { - read_unlock(g_lock); - kranal_tx_done(tx, -EHOSTUNREACH); - return; - } - - conn = kranal_find_conn_locked(peer); - if (conn != NULL) { - kranal_post_fma(conn, tx); - read_unlock(g_lock); - return; - } - - /* Making one or more connections; I'll need a write lock... */ - read_unlock(g_lock); - write_lock_irqsave(g_lock, flags); - - peer = kranal_find_peer_locked(nid); - if (peer == NULL) { - write_unlock_irqrestore(g_lock, flags); - kranal_tx_done(tx, -EHOSTUNREACH); - return; - } - - conn = kranal_find_conn_locked(peer); - if (conn != NULL) { - /* Connection exists; queue message on it */ - kranal_post_fma(conn, tx); - write_unlock_irqrestore(g_lock, flags); - return; - } - - LASSERT (peer->rap_persistence > 0); - - if (!peer->rap_connecting) { - now = CURRENT_TIME; - if (now < peer->rap_reconnect_time) { - write_unlock_irqrestore(g_lock, flags); - kranal_tx_done(tx, -EHOSTUNREACH); - return; - } - - peer->rap_connecting = 1; - kranal_peer_addref(peer); /* extra ref for connd */ - - spin_lock(&kranal_data.kra_connd_lock); - - list_add_tail(&peer->rap_connd_list, - &kranal_data.kra_connd_peers); - wake_up(&kranal_data.kra_connd_waitq); - - spin_unlock(&kranal_data.kra_connd_lock); - } - - /* A connection is being established; queue the message... */ - list_add_tail(&tx->tx_list, &peer->rap_tx_queue); - - write_unlock_irqrestore(g_lock, flags); -} - -static void -kranal_rdma(kra_tx_t *tx, int type, - kra_rdma_desc_t *rard, int nob, __u64 cookie) -{ - kra_conn_t *conn = tx->tx_conn; - RAP_RETURN rrc; - unsigned long flags; - - /* prep final completion message */ - kranal_init_msg(&tx->tx_msg, type); - tx->tx_msg.ram_u.completion.racm_cookie = cookie; - - LASSERT (tx->tx_buftype == RANAL_BUF_PHYS_MAPPED || - tx->tx_buftype == RANAL_BUF_VIRT_MAPPED); - LASSERT (nob <= rard->rard_nob); - - memset(&tx->tx_rdma_desc, 0, sizeof(tx->tx_rdma_desc)); - tx->tx_rdma_desc.SrcPtr.AddressBits = (__u64)((unsigned long)tx->tx_buffer); - tx->tx_rdma_desc.SrcKey = tx->tx_map_key; - tx->tx_rdma_desc.DstPtr = rard->rard_addr; - tx->tx_rdma_desc.DstKey = rard->rard_key; - tx->tx_rdma_desc.Length = nob; - tx->tx_rdma_desc.AppPtr = tx; - - if (nob == 0) { /* Immediate completion */ - kranal_post_fma(conn, tx); - return; - } - - rrc = RapkPostRdma(conn->rac_rihandle, &tx->tx_rdma_desc); - LASSERT (rrc == RAP_SUCCESS); - - spin_lock_irqsave(&conn->rac_lock, flags); - list_add_tail(&tx->tx_list, &conn->rac_rdmaq); - tx->tx_qtime = jiffies; - spin_unlock_irqrestore(&conn->rac_lock, flags); -} - -int -kranal_consume_rxmsg (kra_conn_t *conn, void *buffer, int nob) -{ - __u32 nob_received = nob; - RAP_RETURN rrc; - - LASSERT (conn->rac_rxmsg != NULL); - - rrc = RapkFmaCopyToUser(conn->rac_rihandle, buffer, - &nob_received, sizeof(kra_msg_t)); - LASSERT (rrc == RAP_SUCCESS); - - conn->rac_rxmsg = NULL; - - if (nob_received != nob) { - CWARN("Expected %d immediate bytes but got %d\n", - nob, nob_received); - return -EPROTO; - } - - return 0; -} - -ptl_err_t -kranal_do_send (lib_nal_t *nal, - void *private, - lib_msg_t *libmsg, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int niov, - struct iovec *iov, - ptl_kiov_t *kiov, - size_t offset, - size_t nob) -{ - kra_conn_t *conn; - kra_tx_t *tx; - int rc; - - /* NB 'private' is different depending on what we're sending.... */ - - CDEBUG(D_NET, "sending "LPSZ" bytes in %d frags to nid:"LPX64 - " pid %d\n", nob, niov, nid , pid); - - LASSERT (nob == 0 || niov > 0); - LASSERT (niov <= PTL_MD_MAX_IOV); - - LASSERT (!in_interrupt()); - /* payload is either all vaddrs or all pages */ - LASSERT (!(kiov != NULL && iov != NULL)); - - switch(type) { - default: - LBUG(); - - case PTL_MSG_REPLY: { - /* reply's 'private' is the conn that received the GET_REQ */ - conn = private; - LASSERT (conn->rac_rxmsg != NULL); - - if (conn->rac_rxmsg->ram_type == RANAL_MSG_IMMEDIATE) { - if (nob > RANAL_MAX_IMMEDIATE) { - CERROR("Can't REPLY IMMEDIATE %d to "LPX64"\n", - nob, nid); - return PTL_FAIL; - } - break; /* RDMA not expected */ - } - - /* Incoming message consistent with immediate reply? */ - if (conn->rac_rxmsg->ram_type != RANAL_MSG_GET_REQ) { - CERROR("REPLY to "LPX64" bad msg type %x!!!\n", - nid, conn->rac_rxmsg->ram_type); - return PTL_FAIL; - } - - tx = kranal_get_idle_tx(0); - if (tx == NULL) - return PTL_FAIL; - - rc = kranal_setup_buffer(tx, niov, iov, kiov, offset, nob); - if (rc != 0) { - kranal_tx_done(tx, rc); - return PTL_FAIL; - } - - tx->tx_conn = conn; - tx->tx_libmsg[0] = libmsg; - - kranal_map_buffer(tx); - kranal_rdma(tx, RANAL_MSG_GET_DONE, - &conn->rac_rxmsg->ram_u.get.ragm_desc, nob, - conn->rac_rxmsg->ram_u.get.ragm_cookie); - return PTL_OK; - } - - case PTL_MSG_GET: - if (kiov == NULL && /* not paged */ - nob <= RANAL_MAX_IMMEDIATE && /* small enough */ - nob <= kranal_tunables.kra_max_immediate) - break; /* send IMMEDIATE */ - - tx = kranal_new_tx_msg(0, RANAL_MSG_GET_REQ); - if (tx == NULL) - return PTL_NO_SPACE; - - rc = kranal_setup_buffer(tx, niov, iov, kiov, offset, nob); - if (rc != 0) { - kranal_tx_done(tx, rc); - return PTL_FAIL; - } - - tx->tx_libmsg[1] = lib_create_reply_msg(&kranal_lib, nid, libmsg); - if (tx->tx_libmsg[1] == NULL) { - CERROR("Can't create reply for GET to "LPX64"\n", nid); - kranal_tx_done(tx, rc); - return PTL_FAIL; - } - - tx->tx_libmsg[0] = libmsg; - tx->tx_msg.ram_u.get.ragm_hdr = *hdr; - /* rest of tx_msg is setup just before it is sent */ - kranal_launch_tx(tx, nid); - return PTL_OK; - - case PTL_MSG_ACK: - LASSERT (nob == 0); - break; - - case PTL_MSG_PUT: - if (kiov == NULL && /* not paged */ - nob <= RANAL_MAX_IMMEDIATE && /* small enough */ - nob <= kranal_tunables.kra_max_immediate) - break; /* send IMMEDIATE */ - - tx = kranal_new_tx_msg(!in_interrupt(), RANAL_MSG_PUT_REQ); - if (tx == NULL) - return PTL_NO_SPACE; - - rc = kranal_setup_buffer(tx, niov, iov, kiov, offset, nob); - if (rc != 0) { - kranal_tx_done(tx, rc); - return PTL_FAIL; - } - - tx->tx_libmsg[0] = libmsg; - tx->tx_msg.ram_u.putreq.raprm_hdr = *hdr; - /* rest of tx_msg is setup just before it is sent */ - kranal_launch_tx(tx, nid); - return PTL_OK; - } - - LASSERT (kiov == NULL); - LASSERT (nob <= RANAL_MAX_IMMEDIATE); - - tx = kranal_new_tx_msg(!(type == PTL_MSG_ACK || - type == PTL_MSG_REPLY || - in_interrupt()), - RANAL_MSG_IMMEDIATE); - if (tx == NULL) - return PTL_NO_SPACE; - - rc = kranal_setup_immediate_buffer(tx, niov, iov, offset, nob); - if (rc != 0) { - kranal_tx_done(tx, rc); - return PTL_FAIL; - } - - tx->tx_msg.ram_u.immediate.raim_hdr = *hdr; - tx->tx_libmsg[0] = libmsg; - kranal_launch_tx(tx, nid); - return PTL_OK; -} - -ptl_err_t -kranal_send (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int niov, struct iovec *iov, - size_t offset, size_t len) -{ - return kranal_do_send(nal, private, cookie, - hdr, type, nid, pid, - niov, iov, NULL, - offset, len); -} - -ptl_err_t -kranal_send_pages (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int niov, ptl_kiov_t *kiov, - size_t offset, size_t len) -{ - return kranal_do_send(nal, private, cookie, - hdr, type, nid, pid, - niov, NULL, kiov, - offset, len); -} - -ptl_err_t -kranal_recvmsg (lib_nal_t *nal, void *private, lib_msg_t *libmsg, - unsigned int niov, struct iovec *iov, ptl_kiov_t *kiov, - size_t offset, size_t mlen, size_t rlen) -{ - kra_conn_t *conn = private; - kra_msg_t *rxmsg = conn->rac_rxmsg; - kra_tx_t *tx; - void *buffer; - int rc; - - LASSERT (mlen <= rlen); - LASSERT (!in_interrupt()); - /* Either all pages or all vaddrs */ - LASSERT (!(kiov != NULL && iov != NULL)); - - switch(rxmsg->ram_type) { - default: - LBUG(); - return PTL_FAIL; - - case RANAL_MSG_IMMEDIATE: - if (mlen == 0) { - buffer = NULL; - } else if (kiov != NULL) { - CERROR("Can't recv immediate into paged buffer\n"); - return PTL_FAIL; - } else { - LASSERT (niov > 0); - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - iov++; - niov--; - LASSERT (niov > 0); - } - if (mlen > iov->iov_len - offset) { - CERROR("Can't handle immediate frags\n"); - return PTL_FAIL; - } - buffer = ((char *)iov->iov_base) + offset; - } - rc = kranal_consume_rxmsg(conn, buffer, mlen); - lib_finalize(nal, NULL, libmsg, (rc == 0) ? PTL_OK : PTL_FAIL); - return PTL_OK; - - case RANAL_MSG_GET_REQ: - /* If the GET matched, we've already handled it in - * kranal_do_send which is called to send the REPLY. We're - * only called here to complete the GET receive (if we needed - * it which we don't, but I digress...) */ - LASSERT (libmsg == NULL); - lib_finalize(nal, NULL, libmsg, PTL_OK); - return PTL_OK; - - case RANAL_MSG_PUT_REQ: - if (libmsg == NULL) { /* PUT didn't match... */ - lib_finalize(nal, NULL, libmsg, PTL_OK); - return PTL_OK; - } - - tx = kranal_new_tx_msg(0, RANAL_MSG_PUT_ACK); - if (tx == NULL) - return PTL_NO_SPACE; - - rc = kranal_setup_buffer(tx, niov, iov, kiov, offset, mlen); - if (rc != 0) { - kranal_tx_done(tx, rc); - return PTL_FAIL; - } - - kranal_map_buffer(tx); - - tx->tx_msg.ram_u.putack.rapam_src_cookie = - conn->rac_rxmsg->ram_u.putreq.raprm_cookie; - tx->tx_msg.ram_u.putack.rapam_dst_cookie = tx->tx_cookie; - tx->tx_msg.ram_u.putack.rapam_desc.rard_key = tx->tx_map_key; - tx->tx_msg.ram_u.putack.rapam_desc.rard_addr.AddressBits = - (__u64)((unsigned long)tx->tx_buffer); - tx->tx_msg.ram_u.putack.rapam_desc.rard_nob = mlen; - - tx->tx_libmsg[0] = libmsg; /* finalize this on RDMA_DONE */ - - kranal_post_fma(conn, tx); - - /* flag matched by consuming rx message */ - kranal_consume_rxmsg(conn, NULL, 0); - return PTL_OK; - } -} - -ptl_err_t -kranal_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, struct iovec *iov, - size_t offset, size_t mlen, size_t rlen) -{ - return kranal_recvmsg(nal, private, msg, niov, iov, NULL, - offset, mlen, rlen); -} - -ptl_err_t -kranal_recv_pages (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, ptl_kiov_t *kiov, - size_t offset, size_t mlen, size_t rlen) -{ - return kranal_recvmsg(nal, private, msg, niov, NULL, kiov, - offset, mlen, rlen); -} - -int -kranal_thread_start (int(*fn)(void *arg), void *arg) -{ - long pid = kernel_thread(fn, arg, 0); - - if (pid < 0) - return(int)pid; - - atomic_inc(&kranal_data.kra_nthreads); - return 0; -} - -void -kranal_thread_fini (void) -{ - atomic_dec(&kranal_data.kra_nthreads); -} - -int -kranal_check_conn (kra_conn_t *conn) -{ - kra_tx_t *tx; - struct list_head *ttmp; - unsigned long flags; - long timeout; - unsigned long now = jiffies; - - if (!conn->rac_closing && - time_after_eq(now, conn->rac_last_tx + conn->rac_keepalive * HZ)) { - /* not sent in a while; schedule conn so scheduler sends a keepalive */ - kranal_schedule_conn(conn); - } - - /* wait twice as long for CLOSE to be sure peer is dead */ - timeout = (conn->rac_closing ? 1 : 2) * conn->rac_timeout * HZ; - - if (!conn->rac_close_recvd && - time_after_eq(now, conn->rac_last_rx + timeout)) { - CERROR("Nothing received from "LPX64" within %lu seconds\n", - conn->rac_peer->rap_nid, (now - conn->rac_last_rx)/HZ); - return -ETIMEDOUT; - } - - if (conn->rac_closing) - return 0; - - /* Check the conn's queues are moving. These are "belt+braces" checks, - * in case of hardware/software errors that make this conn seem - * responsive even though it isn't progressing its message queues. */ - - spin_lock_irqsave(&conn->rac_lock, flags); - - list_for_each (ttmp, &conn->rac_fmaq) { - tx = list_entry(ttmp, kra_tx_t, tx_list); - - if (time_after_eq(now, tx->tx_qtime + timeout)) { - spin_unlock_irqrestore(&conn->rac_lock, flags); - CERROR("tx on fmaq for "LPX64" blocked %lu seconds\n", - conn->rac_peer->rap_nid, (now - tx->tx_qtime)/HZ); - return -ETIMEDOUT; - } - } - - list_for_each (ttmp, &conn->rac_rdmaq) { - tx = list_entry(ttmp, kra_tx_t, tx_list); - - if (time_after_eq(now, tx->tx_qtime + timeout)) { - spin_unlock_irqrestore(&conn->rac_lock, flags); - CERROR("tx on rdmaq for "LPX64" blocked %lu seconds\n", - conn->rac_peer->rap_nid, (now - tx->tx_qtime)/HZ); - return -ETIMEDOUT; - } - } - - list_for_each (ttmp, &conn->rac_replyq) { - tx = list_entry(ttmp, kra_tx_t, tx_list); - - if (time_after_eq(now, tx->tx_qtime + timeout)) { - spin_unlock_irqrestore(&conn->rac_lock, flags); - CERROR("tx on replyq for "LPX64" blocked %lu seconds\n", - conn->rac_peer->rap_nid, (now - tx->tx_qtime)/HZ); - return -ETIMEDOUT; - } - } - - spin_unlock_irqrestore(&conn->rac_lock, flags); - return 0; -} - -void -kranal_check_conns (int idx, unsigned long *min_timeoutp) -{ - struct list_head *conns = &kranal_data.kra_conns[idx]; - struct list_head *ctmp; - kra_conn_t *conn; - unsigned long flags; - int rc; - - again: - /* NB. We expect to check all the conns and not find any problems, so - * we just use a shared lock while we take a look... */ - read_lock(&kranal_data.kra_global_lock); - - list_for_each (ctmp, conns) { - conn = list_entry(ctmp, kra_conn_t, rac_hashlist); - - if (conn->rac_timeout < *min_timeoutp ) - *min_timeoutp = conn->rac_timeout; - if (conn->rac_keepalive < *min_timeoutp ) - *min_timeoutp = conn->rac_keepalive; - - rc = kranal_check_conn(conn); - if (rc == 0) - continue; - - kranal_conn_addref(conn); - read_unlock(&kranal_data.kra_global_lock); - - CERROR("Check on conn to "LPX64"failed: %d\n", - conn->rac_peer->rap_nid, rc); - - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - if (!conn->rac_closing) - kranal_close_conn_locked(conn, -ETIMEDOUT); - else - kranal_terminate_conn_locked(conn); - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - - kranal_conn_decref(conn); - - /* start again now I've dropped the lock */ - goto again; - } - - read_unlock(&kranal_data.kra_global_lock); -} - -int -kranal_connd (void *arg) -{ - char name[16]; - wait_queue_t wait; - unsigned long flags; - kra_peer_t *peer; - int i; - - snprintf(name, sizeof(name), "kranal_connd_%02ld", (long)arg); - kportal_daemonize(name); - kportal_blockallsigs(); - - init_waitqueue_entry(&wait, current); - - spin_lock_irqsave(&kranal_data.kra_connd_lock, flags); - - while (!kranal_data.kra_shutdown) { - /* Safe: kra_shutdown only set when quiescent */ - - if (!list_empty(&kranal_data.kra_connd_peers)) { - peer = list_entry(kranal_data.kra_connd_peers.next, - kra_peer_t, rap_connd_list); - - list_del_init(&peer->rap_connd_list); - spin_unlock_irqrestore(&kranal_data.kra_connd_lock, flags); - - kranal_connect(peer); - kranal_peer_decref(peer); - - spin_lock_irqsave(&kranal_data.kra_connd_lock, flags); - continue; - } - - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&kranal_data.kra_connd_waitq, &wait); - - spin_unlock_irqrestore(&kranal_data.kra_connd_lock, flags); - - schedule (); - - set_current_state(TASK_RUNNING); - remove_wait_queue(&kranal_data.kra_connd_waitq, &wait); - - spin_lock_irqsave(&kranal_data.kra_connd_lock, flags); - } - - spin_unlock_irqrestore(&kranal_data.kra_connd_lock, flags); - - kranal_thread_fini(); - return 0; -} - -void -kranal_update_reaper_timeout(long timeout) -{ - unsigned long flags; - - LASSERT (timeout > 0); - - spin_lock_irqsave(&kranal_data.kra_reaper_lock, flags); - - if (timeout < kranal_data.kra_new_min_timeout) - kranal_data.kra_new_min_timeout = timeout; - - spin_unlock_irqrestore(&kranal_data.kra_reaper_lock, flags); -} - -int -kranal_reaper (void *arg) -{ - wait_queue_t wait; - unsigned long flags; - kra_conn_t *conn; - kra_peer_t *peer; - long timeout; - int i; - int conn_entries = kranal_data.kra_conn_hash_size; - int conn_index = 0; - int base_index = conn_entries - 1; - unsigned long next_check_time = jiffies; - long next_min_timeout = MAX_SCHEDULE_TIMEOUT; - long current_min_timeout = 1; - - kportal_daemonize("kranal_reaper"); - kportal_blockallsigs(); - - init_waitqueue_entry(&wait, current); - - spin_lock_irqsave(&kranal_data.kra_reaper_lock, flags); - kranal_data.kra_new_min_timeout = 1; - - while (!kranal_data.kra_shutdown) { - - /* careful with the jiffy wrap... */ - timeout = (long)(next_check_time - jiffies); - if (timeout <= 0) { - - /* I wake up every 'p' seconds to check for - * timeouts on some more peers. I try to check - * every connection 'n' times within the global - * minimum of all keepalive and timeout intervals, - * to ensure I attend to every connection within - * (n+1)/n times its timeout intervals. */ - - const int p = 1; - const int n = 3; - unsigned long min_timeout; - int chunk; - - if (kranal_data.kra_new_min_timeout != MAX_SCHEDULE_TIMEOUT) { - /* new min timeout set: restart min timeout scan */ - next_min_timeout = MAX_SCHEDULE_TIMEOUT; - base_index = conn_index - 1; - if (base_index < 0) - base_index = conn_entries - 1; - - if (kranal_data.kra_new_min_timeout < current_min_timeout) { - current_min_timeout = kranal_data.kra_new_min_timeout; - CWARN("Set new min timeout %ld\n", - current_min_timeout); - } - - kranal_data.kra_new_min_timeout = MAX_SCHEDULE_TIMEOUT; - } - min_timeout = current_min_timeout; - - spin_unlock_irqrestore(&kranal_data.kra_reaper_lock, - flags); - - LASSERT (min_timeout > 0); - - /* Compute how many table entries to check now so I - * get round the whole table fast enough (NB I do - * this at fixed intervals of 'p' seconds) */ - chunk = conn_entries; - if (min_timeout > n * p) - chunk = (chunk * n * p) / min_timeout; - if (chunk == 0) - chunk = 1; - - for (i = 0; i < chunk; i++) { - kranal_check_conns(conn_index, - &next_min_timeout); - conn_index = (conn_index + 1) % conn_entries; - } - - next_check_time += p * HZ; - - spin_lock_irqsave(&kranal_data.kra_reaper_lock, flags); - - if (((conn_index - chunk <= base_index && - base_index < conn_index) || - (conn_index - conn_entries - chunk <= base_index && - base_index < conn_index - conn_entries))) { - - /* Scanned all conns: set current_min_timeout... */ - if (current_min_timeout != next_min_timeout) { - current_min_timeout = next_min_timeout; - CWARN("Set new min timeout %ld\n", - current_min_timeout); - } - - /* ...and restart min timeout scan */ - next_min_timeout = MAX_SCHEDULE_TIMEOUT; - base_index = conn_index - 1; - if (base_index < 0) - base_index = conn_entries - 1; - } - } - - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&kranal_data.kra_reaper_waitq, &wait); - - spin_unlock_irqrestore(&kranal_data.kra_reaper_lock, flags); - - schedule_timeout(timeout); - - spin_lock_irqsave(&kranal_data.kra_reaper_lock, flags); - - set_current_state(TASK_RUNNING); - remove_wait_queue(&kranal_data.kra_reaper_waitq, &wait); - } - - kranal_thread_fini(); - return 0; -} - -void -kranal_process_rdmaq (__u32 cqid) -{ - kra_conn_t *conn; - kra_tx_t *tx; - RAP_RETURN rrc; - unsigned long flags; - RAP_RDMA_DESCRIPTOR *desc; - - read_lock(&kranal_data.kra_global_lock); - - conn = kranal_cqid2conn_locked(cqid); - LASSERT (conn != NULL); - - rrc = RapkRdmaDone(conn->rac_rihandle, &desc); - LASSERT (rrc == RAP_SUCCESS); - - spin_lock_irqsave(&conn->rac_lock, flags); - - LASSERT (!list_empty(&conn->rac_rdmaq)); - tx = list_entry(conn->rac_rdmaq.next, kra_tx_t, tx_list); - list_del(&tx->tx_list); - - LASSERT(desc->AppPtr == (void *)tx); - LASSERT(tx->tx_msg.ram_type == RANAL_MSG_PUT_DONE || - tx->tx_msg.ram_type == RANAL_MSG_GET_DONE); - - list_add_tail(&tx->tx_list, &conn->rac_fmaq); - tx->tx_qtime = jiffies; - - spin_unlock_irqrestore(&conn->rac_lock, flags); - - /* Get conn's fmaq processed, now I've just put something there */ - kranal_schedule_conn(conn); - - read_unlock(&kranal_data.kra_global_lock); -} - -int -kranal_sendmsg(kra_conn_t *conn, kra_msg_t *msg, - void *immediate, int immediatenob) -{ - int sync = (msg->ram_type & RANAL_MSG_FENCE) != 0; - RAP_RETURN rrc; - - LASSERT (sizeof(*msg) <= RANAL_FMA_PREFIX_LEN); - LASSERT ((msg->ram_type == RANAL_MSG_IMMEDIATE) ? - immediatenob <= RANAL_FMA_MAX_DATA_LEN : - immediatenob == 0); - - msg->ram_incarnation = conn->rac_my_incarnation; - msg->ram_seq = conn->rac_tx_seq; - - if (sync) - rrc = RapkFmaSyncSend(conn->rac_device->rad_handle, - immediate, immediatenob, - msg, sizeof(*msg)); - else - rrc = RapkFmaSend(conn->rac_device->rad_handle, - immediate, immediatenob, - msg, sizeof(*msg)); - - switch (rrc) { - default: - LBUG(); - - case RAP_SUCCESS: - conn->rac_last_tx = jiffies; - conn->rac_tx_seq++; - return 0; - - case RAP_NOT_DONE: - return -EAGAIN; - } -} - -int -kranal_process_fmaq (kra_conn_t *conn) -{ - unsigned long flags; - int more_to_do; - kra_tx_t *tx; - int rc; - int expect_reply; - - /* NB I will be rescheduled some via a rad_fma_cq event if my FMA is - * out of credits when I try to send right now... */ - - if (conn->rac_closing) { - - if (!list_empty(&conn->rac_rdmaq)) { - /* Can't send CLOSE yet; I'm still waiting for RDMAs I - * posted to finish */ - LASSERT (!conn->rac_close_sent); - kranal_init_msg(&conn->rac_msg, RANAL_MSG_NOOP); - kranal_sendmsg(conn, &conn->rac_msg, NULL, 0); - return 0; - } - - if (conn->rac_close_sent) - return 0; - - kranal_init_msg(&conn->rac_msg, RANAL_MSG_CLOSE); - rc = kranal_sendmsg(conn, &conn->rac_msg, NULL, 0); - conn->rac_close_sent = (rc == 0); - return 0; - } - - spin_lock_irqsave(&conn->rac_lock, flags); - - if (list_empty(&conn->rac_fmaq)) { - - spin_unlock_irqrestore(&conn->rac_lock, flags); - - if (time_after_eq(jiffies, - conn->rac_last_tx + conn->rac_keepalive)) { - kranal_init_msg(&conn->rac_msg, RANAL_MSG_NOOP); - kranal_sendmsg(conn, &conn->rac_msg, NULL, 0); - } - return 0; - } - - tx = list_entry(conn->rac_fmaq.next, kra_tx_t, tx_list); - list_del(&tx->tx_list); - more_to_do = !list_empty(&conn->rac_fmaq); - - spin_unlock_irqrestore(&conn->rac_lock, flags); - - expect_reply = 0; - switch (tx->tx_msg.ram_type) { - default: - LBUG(); - - case RANAL_MSG_IMMEDIATE: - case RANAL_MSG_PUT_NAK: - case RANAL_MSG_PUT_DONE: - case RANAL_MSG_GET_NAK: - case RANAL_MSG_GET_DONE: - rc = kranal_sendmsg(conn, &tx->tx_msg, - tx->tx_buffer, tx->tx_nob); - expect_reply = 0; - break; - - case RANAL_MSG_PUT_REQ: - tx->tx_msg.ram_u.putreq.raprm_cookie = tx->tx_cookie; - rc = kranal_sendmsg(conn, &tx->tx_msg, NULL, 0); - kranal_map_buffer(tx); - expect_reply = 1; - break; - - case RANAL_MSG_PUT_ACK: - rc = kranal_sendmsg(conn, &tx->tx_msg, NULL, 0); - expect_reply = 1; - break; - - case RANAL_MSG_GET_REQ: - kranal_map_buffer(tx); - tx->tx_msg.ram_u.get.ragm_cookie = tx->tx_cookie; - tx->tx_msg.ram_u.get.ragm_desc.rard_key = tx->tx_map_key; - tx->tx_msg.ram_u.get.ragm_desc.rard_addr.AddressBits = - (__u64)((unsigned long)tx->tx_buffer); - tx->tx_msg.ram_u.get.ragm_desc.rard_nob = tx->tx_nob; - rc = kranal_sendmsg(conn, &tx->tx_msg, NULL, 0); - expect_reply = 1; - break; - } - - if (rc == -EAGAIN) { - /* replace at the head of the list for later */ - spin_lock_irqsave(&conn->rac_lock, flags); - list_add(&tx->tx_list, &conn->rac_fmaq); - spin_unlock_irqrestore(&conn->rac_lock, flags); - - return 0; - } - - LASSERT (rc == 0); - - if (!expect_reply) { - kranal_tx_done(tx, 0); - } else { - spin_lock_irqsave(&conn->rac_lock, flags); - list_add_tail(&tx->tx_list, &conn->rac_replyq); - tx->tx_qtime = jiffies; - spin_unlock_irqrestore(&conn->rac_lock, flags); - } - - return more_to_do; -} - -static inline void -kranal_swab_rdma_desc (kra_rdma_desc_t *d) -{ - __swab64s(&d->rard_key.Key); - __swab16s(&d->rard_key.Cookie); - __swab16s(&d->rard_key.MdHandle); - __swab32s(&d->rard_key.Flags); - __swab64s(&d->rard_addr.AddressBits); - __swab32s(&d->rard_nob); -} - -kra_tx_t * -kranal_match_reply(kra_conn_t *conn, int type, __u64 cookie) -{ - unsigned long flags; - struct list_head *ttmp; - kra_tx_t *tx; - - list_for_each(ttmp, &conn->rac_replyq) { - tx = list_entry(ttmp, kra_tx_t, tx_list); - - if (tx->tx_cookie != cookie) - continue; - - if (tx->tx_msg.ram_type != type) { - CWARN("Unexpected type %x (%x expected) " - "matched reply from "LPX64"\n", - tx->tx_msg.ram_type, type, - conn->rac_peer->rap_nid); - return NULL; - } - } - - CWARN("Unmatched reply from "LPX64"\n", conn->rac_peer->rap_nid); - return NULL; -} - -int -kranal_process_receives(kra_conn_t *conn) -{ - unsigned long flags; - __u32 seq; - __u32 nob; - kra_tx_t *tx; - kra_msg_t *msg; - void *prefix; - RAP_RETURN rrc = RapkFmaGetPrefix(conn->rac_rihandle, &prefix); - kra_peer_t *peer = conn->rac_peer; - - if (rrc == RAP_NOT_DONE) - return 0; - - LASSERT (rrc == RAP_SUCCESS); - conn->rac_last_rx = jiffies; - seq = conn->rac_rx_seq++; - msg = (kra_msg_t *)prefix; - - if (msg->ram_magic != RANAL_MSG_MAGIC) { - if (__swab32(msg->ram_magic) != RANAL_MSG_MAGIC) { - CERROR("Unexpected magic %08x from "LPX64"\n", - msg->ram_magic, peer->rap_nid); - goto out; - } - - __swab32s(&msg->ram_magic); - __swab16s(&msg->ram_version); - __swab16s(&msg->ram_type); - __swab64s(&msg->ram_srcnid); - __swab64s(&msg->ram_incarnation); - __swab32s(&msg->ram_seq); - - /* NB message type checked below; NOT here... */ - switch (msg->ram_type) { - case RANAL_MSG_PUT_ACK: - kranal_swab_rdma_desc(&msg->ram_u.putack.rapam_desc); - break; - - case RANAL_MSG_GET_REQ: - kranal_swab_rdma_desc(&msg->ram_u.get.ragm_desc); - break; - - default: - break; - } - } - - if (msg->ram_version != RANAL_MSG_VERSION) { - CERROR("Unexpected protocol version %d from "LPX64"\n", - msg->ram_version, peer->rap_nid); - goto out; - } - - if (msg->ram_srcnid != peer->rap_nid) { - CERROR("Unexpected peer "LPX64" from "LPX64"\n", - msg->ram_srcnid, peer->rap_nid); - goto out; - } - - if (msg->ram_incarnation != conn->rac_peer_incarnation) { - CERROR("Unexpected incarnation "LPX64"("LPX64 - " expected) from "LPX64"\n", - msg->ram_incarnation, conn->rac_peer_incarnation, - peer->rap_nid); - goto out; - } - - if (msg->ram_seq != seq) { - CERROR("Unexpected sequence number %d(%d expected) from " - LPX64"\n", msg->ram_seq, seq, peer->rap_nid); - goto out; - } - - if ((msg->ram_type & RANAL_MSG_FENCE) != 0) { - /* This message signals RDMA completion: wait now... */ - rrc = RapkFmaSyncWait(conn->rac_rihandle); - LASSERT (rrc == RAP_SUCCESS); - } - - if (msg->ram_type == RANAL_MSG_CLOSE) { - conn->rac_close_recvd = 1; - write_lock_irqsave(&kranal_data.kra_global_lock, flags); - - if (!conn->rac_closing) - kranal_close_conn_locked(conn, -ETIMEDOUT); - else if (conn->rac_close_sent) - kranal_terminate_conn_locked(conn); - - write_unlock_irqrestore(&kranal_data.kra_global_lock, flags); - goto out; - } - - if (conn->rac_closing) - goto out; - - conn->rac_rxmsg = msg; /* stash message for portals callbacks */ - /* they'll NULL rac_rxmsg if they consume it */ - switch (msg->ram_type) { - case RANAL_MSG_NOOP: - /* Nothing to do; just a keepalive */ - break; - - case RANAL_MSG_IMMEDIATE: - lib_parse(&kranal_lib, &msg->ram_u.immediate.raim_hdr, conn); - break; - - case RANAL_MSG_PUT_REQ: - lib_parse(&kranal_lib, &msg->ram_u.putreq.raprm_hdr, conn); - - if (conn->rac_rxmsg == NULL) /* lib_parse matched something */ - break; - - tx = kranal_new_tx_msg(0, RANAL_MSG_PUT_NAK); - if (tx == NULL) - break; - - tx->tx_msg.ram_u.completion.racm_cookie = - msg->ram_u.putreq.raprm_cookie; - kranal_post_fma(conn, tx); - break; - - case RANAL_MSG_PUT_NAK: - tx = kranal_match_reply(conn, RANAL_MSG_PUT_REQ, - msg->ram_u.completion.racm_cookie); - if (tx == NULL) - break; - - LASSERT (tx->tx_buftype == RANAL_BUF_PHYS_MAPPED || - tx->tx_buftype == RANAL_BUF_VIRT_MAPPED); - kranal_tx_done(tx, -ENOENT); /* no match */ - break; - - case RANAL_MSG_PUT_ACK: - tx = kranal_match_reply(conn, RANAL_MSG_PUT_REQ, - msg->ram_u.putack.rapam_src_cookie); - if (tx == NULL) - break; - - kranal_rdma(tx, RANAL_MSG_PUT_DONE, - &msg->ram_u.putack.rapam_desc, - msg->ram_u.putack.rapam_desc.rard_nob, - msg->ram_u.putack.rapam_dst_cookie); - break; - - case RANAL_MSG_PUT_DONE: - tx = kranal_match_reply(conn, RANAL_MSG_PUT_ACK, - msg->ram_u.completion.racm_cookie); - if (tx == NULL) - break; - - LASSERT (tx->tx_buftype == RANAL_BUF_PHYS_MAPPED || - tx->tx_buftype == RANAL_BUF_VIRT_MAPPED); - kranal_tx_done(tx, 0); - break; - - case RANAL_MSG_GET_REQ: - lib_parse(&kranal_lib, &msg->ram_u.get.ragm_hdr, conn); - - if (conn->rac_rxmsg == NULL) /* lib_parse matched something */ - break; - - tx = kranal_new_tx_msg(0, RANAL_MSG_GET_NAK); - if (tx == NULL) - break; - - tx->tx_msg.ram_u.completion.racm_cookie = msg->ram_u.get.ragm_cookie; - kranal_post_fma(conn, tx); - break; - - case RANAL_MSG_GET_NAK: - tx = kranal_match_reply(conn, RANAL_MSG_GET_REQ, - msg->ram_u.completion.racm_cookie); - if (tx == NULL) - break; - - LASSERT (tx->tx_buftype == RANAL_BUF_PHYS_MAPPED || - tx->tx_buftype == RANAL_BUF_VIRT_MAPPED); - kranal_tx_done(tx, -ENOENT); /* no match */ - break; - - case RANAL_MSG_GET_DONE: - tx = kranal_match_reply(conn, RANAL_MSG_GET_REQ, - msg->ram_u.completion.racm_cookie); - if (tx == NULL) - break; - - LASSERT (tx->tx_buftype == RANAL_BUF_PHYS_MAPPED || - tx->tx_buftype == RANAL_BUF_VIRT_MAPPED); - kranal_tx_done(tx, 0); - break; - } - - out: - if (conn->rac_rxmsg != NULL) - kranal_consume_rxmsg(conn, NULL, 0); - - return 1; -} - -int -kranal_scheduler (void *arg) -{ - kra_device_t *dev = (kra_device_t *)arg; - wait_queue_t wait; - char name[16]; - kra_conn_t *conn; - unsigned long flags; - RAP_RETURN rrc; - int rc; - int resched; - int i; - __u32 cqid; - __u32 event_type; - int did_something; - int busy_loops = 0; - - snprintf(name, sizeof(name), "kranal_sd_%02d", dev->rad_idx); - kportal_daemonize(name); - kportal_blockallsigs(); - - init_waitqueue_entry(&wait, current); - - spin_lock_irqsave(&dev->rad_lock, flags); - - while (!kranal_data.kra_shutdown) { - /* Safe: kra_shutdown only set when quiescent */ - - if (busy_loops++ >= RANAL_RESCHED) { - spin_unlock_irqrestore(&dev->rad_lock, flags); - - our_cond_resched(); - busy_loops = 0; - - spin_lock_irqsave(&dev->rad_lock, flags); - } - - did_something = 0; - - if (dev->rad_ready) { - dev->rad_ready = 0; - spin_unlock_irqrestore(&dev->rad_lock, flags); - - rrc = RapkCQDone(dev->rad_rdma_cq, &cqid, &event_type); - - LASSERT (rrc == RAP_SUCCESS || rrc == RAP_NOT_DONE); - LASSERT ((event_type & RAPK_CQ_EVENT_OVERRUN) == 0); - - if (rrc == RAP_SUCCESS) { - kranal_process_rdmaq(cqid); - did_something = 1; - } - - rrc = RapkCQDone(dev->rad_fma_cq, &cqid, &event_type); - LASSERT (rrc == RAP_SUCCESS || rrc == RAP_NOT_DONE); - - if (rrc == RAP_SUCCESS) { - if ((event_type & RAPK_CQ_EVENT_OVERRUN) != 0) - kranal_schedule_dev(dev); - else - kranal_schedule_cqid(cqid); - did_something = 1; - } - - spin_lock_irqsave(&dev->rad_lock, flags); - - /* If there were no completions to handle, I leave - * rad_ready clear. NB I cleared it BEFORE I checked - * the completion queues since I'm racing with the - * device callback. */ - - if (did_something) - dev->rad_ready = 1; - } - - if (!list_empty(&dev->rad_connq)) { - conn = list_entry(dev->rad_connq.next, - kra_conn_t, rac_schedlist); - list_del(&conn->rac_schedlist); - spin_unlock_irqrestore(&dev->rad_lock, flags); - - LASSERT (conn->rac_scheduled); - - resched = kranal_process_fmaq(conn); - resched |= kranal_process_receives(conn); - did_something = 1; - - spin_lock_irqsave(&dev->rad_lock, flags); - if (resched) - list_add_tail(&conn->rac_schedlist, - &dev->rad_connq); - } - - if (did_something) - continue; - - add_wait_queue(&dev->rad_waitq, &wait); - set_current_state(TASK_INTERRUPTIBLE); - - spin_unlock_irqrestore(&dev->rad_lock, flags); - - busy_loops = 0; - schedule(); - - set_current_state(TASK_RUNNING); - remove_wait_queue(&dev->rad_waitq, &wait); - - spin_lock_irqsave(&dev->rad_lock, flags); - } - - spin_unlock_irqrestore(&dev->rad_lock, flags); - - kranal_thread_fini(); - return 0; -} - - -lib_nal_t kranal_lib = { - libnal_data: &kranal_data, /* NAL private data */ - libnal_send: kranal_send, - libnal_send_pages: kranal_send_pages, - libnal_recv: kranal_recv, - libnal_recv_pages: kranal_recv_pages, - libnal_dist: kranal_dist -}; diff --git a/lnet/klnds/socklnd/.cvsignore b/lnet/klnds/socklnd/.cvsignore deleted file mode 100644 index 5ed596b..0000000 --- a/lnet/klnds/socklnd/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/klnds/socklnd/Makefile.in b/lnet/klnds/socklnd/Makefile.in deleted file mode 100644 index 633b455..0000000 --- a/lnet/klnds/socklnd/Makefile.in +++ /dev/null @@ -1,8 +0,0 @@ -MODULES := ksocknal -ksocknal-objs := socknal.o socknal_cb.o - -# If you don't build with -O2, your modules won't insert, becahse htonl is -# just special that way. -EXTRA_POST_CFLAGS := -O2 - -@INCLUDE_RULES@ diff --git a/lnet/klnds/socklnd/Makefile.mk b/lnet/klnds/socklnd/Makefile.mk deleted file mode 100644 index 5c1b366..0000000 --- a/lnet/klnds/socklnd/Makefile.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include $(src)/../../Kernelenv - -obj-y += ksocknal.o -ksocknal-objs := socknal.o socknal_cb.o - diff --git a/lnet/klnds/socklnd/autoMakefile.am b/lnet/klnds/socklnd/autoMakefile.am deleted file mode 100644 index 070b649..0000000 --- a/lnet/klnds/socklnd/autoMakefile.am +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if !CRAY_PORTALS -modulenet_DATA = ksocknal$(KMODEXT) -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(ksocknal-objs:%.o=%.c) socknal.h diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c deleted file mode 100644 index 7642770..0000000 --- a/lnet/klnds/socklnd/socklnd.c +++ /dev/null @@ -1,2531 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * Author: Zach Brown - * Author: Peter J. Braam - * Author: Phil Schwan - * Author: Eric Barton - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "socknal.h" - -nal_t ksocknal_api; -ksock_nal_data_t ksocknal_data; -ptl_handle_ni_t ksocknal_ni; -ksock_tunables_t ksocknal_tunables; - -kpr_nal_interface_t ksocknal_router_interface = { - kprni_nalid: SOCKNAL, - kprni_arg: &ksocknal_data, - kprni_fwd: ksocknal_fwd_packet, - kprni_notify: ksocknal_notify, -}; - -#ifdef CONFIG_SYSCTL -#define SOCKNAL_SYSCTL 200 - -#define SOCKNAL_SYSCTL_TIMEOUT 1 -#define SOCKNAL_SYSCTL_EAGER_ACK 2 -#define SOCKNAL_SYSCTL_ZERO_COPY 3 -#define SOCKNAL_SYSCTL_TYPED 4 -#define SOCKNAL_SYSCTL_MIN_BULK 5 -#define SOCKNAL_SYSCTL_BUFFER_SIZE 6 -#define SOCKNAL_SYSCTL_NAGLE 7 -#define SOCKNAL_SYSCTL_IRQ_AFFINITY 8 -#define SOCKNAL_SYSCTL_KEEPALIVE_IDLE 9 -#define SOCKNAL_SYSCTL_KEEPALIVE_COUNT 10 -#define SOCKNAL_SYSCTL_KEEPALIVE_INTVL 11 - -static ctl_table ksocknal_ctl_table[] = { - {SOCKNAL_SYSCTL_TIMEOUT, "timeout", - &ksocknal_tunables.ksnd_io_timeout, sizeof (int), - 0644, NULL, &proc_dointvec}, - {SOCKNAL_SYSCTL_EAGER_ACK, "eager_ack", - &ksocknal_tunables.ksnd_eager_ack, sizeof (int), - 0644, NULL, &proc_dointvec}, -#if SOCKNAL_ZC - {SOCKNAL_SYSCTL_ZERO_COPY, "zero_copy", - &ksocknal_tunables.ksnd_zc_min_frag, sizeof (int), - 0644, NULL, &proc_dointvec}, -#endif - {SOCKNAL_SYSCTL_TYPED, "typed", - &ksocknal_tunables.ksnd_typed_conns, sizeof (int), - 0644, NULL, &proc_dointvec}, - {SOCKNAL_SYSCTL_MIN_BULK, "min_bulk", - &ksocknal_tunables.ksnd_min_bulk, sizeof (int), - 0644, NULL, &proc_dointvec}, - {SOCKNAL_SYSCTL_BUFFER_SIZE, "buffer_size", - &ksocknal_tunables.ksnd_buffer_size, sizeof(int), - 0644, NULL, &proc_dointvec}, - {SOCKNAL_SYSCTL_NAGLE, "nagle", - &ksocknal_tunables.ksnd_nagle, sizeof(int), - 0644, NULL, &proc_dointvec}, -#if CPU_AFFINITY - {SOCKNAL_SYSCTL_IRQ_AFFINITY, "irq_affinity", - &ksocknal_tunables.ksnd_irq_affinity, sizeof(int), - 0644, NULL, &proc_dointvec}, -#endif - {SOCKNAL_SYSCTL_KEEPALIVE_IDLE, "keepalive_idle", - &ksocknal_tunables.ksnd_keepalive_idle, sizeof(int), - 0644, NULL, &proc_dointvec}, - {SOCKNAL_SYSCTL_KEEPALIVE_COUNT, "keepalive_count", - &ksocknal_tunables.ksnd_keepalive_count, sizeof(int), - 0644, NULL, &proc_dointvec}, - {SOCKNAL_SYSCTL_KEEPALIVE_INTVL, "keepalive_intvl", - &ksocknal_tunables.ksnd_keepalive_intvl, sizeof(int), - 0644, NULL, &proc_dointvec}, - { 0 } -}; - -static ctl_table ksocknal_top_ctl_table[] = { - {SOCKNAL_SYSCTL, "socknal", NULL, 0, 0555, ksocknal_ctl_table}, - { 0 } -}; -#endif - -int -ksocknal_set_mynid(ptl_nid_t nid) -{ - lib_ni_t *ni = &ksocknal_lib.libnal_ni; - - /* FIXME: we have to do this because we call lib_init() at module - * insertion time, which is before we have 'mynid' available. lib_init - * sets the NAL's nid, which it uses to tell other nodes where packets - * are coming from. This is not a very graceful solution to this - * problem. */ - - CDEBUG(D_IOCTL, "setting mynid to "LPX64" (old nid="LPX64")\n", - nid, ni->ni_pid.nid); - - ni->ni_pid.nid = nid; - return (0); -} - -void -ksocknal_bind_irq (unsigned int irq) -{ -#if (defined(CONFIG_SMP) && CPU_AFFINITY) - int bind; - int cpu; - unsigned long flags; - char cmdline[64]; - ksock_irqinfo_t *info; - char *argv[] = {"/bin/sh", - "-c", - cmdline, - NULL}; - char *envp[] = {"HOME=/", - "PATH=/sbin:/bin:/usr/sbin:/usr/bin", - NULL}; - - LASSERT (irq < NR_IRQS); - if (irq == 0) /* software NIC or affinity disabled */ - return; - - info = &ksocknal_data.ksnd_irqinfo[irq]; - - write_lock_irqsave (&ksocknal_data.ksnd_global_lock, flags); - - LASSERT (info->ksni_valid); - bind = !info->ksni_bound; - info->ksni_bound = 1; - - write_unlock_irqrestore (&ksocknal_data.ksnd_global_lock, flags); - - if (!bind) /* bound already */ - return; - - cpu = ksocknal_irqsched2cpu(info->ksni_sched); - snprintf (cmdline, sizeof (cmdline), - "echo %d > /proc/irq/%u/smp_affinity", 1 << cpu, irq); - - printk (KERN_INFO "Lustre: Binding irq %u to CPU %d with cmd: %s\n", - irq, cpu, cmdline); - - /* FIXME: Find a better method of setting IRQ affinity... - */ - - USERMODEHELPER(argv[0], argv, envp); -#endif -} - -ksock_interface_t * -ksocknal_ip2iface(__u32 ip) -{ - int i; - ksock_interface_t *iface; - - for (i = 0; i < ksocknal_data.ksnd_ninterfaces; i++) { - LASSERT(i < SOCKNAL_MAX_INTERFACES); - iface = &ksocknal_data.ksnd_interfaces[i]; - - if (iface->ksni_ipaddr == ip) - return (iface); - } - - return (NULL); -} - -ksock_route_t * -ksocknal_create_route (__u32 ipaddr, int port) -{ - ksock_route_t *route; - - PORTAL_ALLOC (route, sizeof (*route)); - if (route == NULL) - return (NULL); - - atomic_set (&route->ksnr_refcount, 1); - route->ksnr_peer = NULL; - route->ksnr_timeout = jiffies; - route->ksnr_retry_interval = SOCKNAL_MIN_RECONNECT_INTERVAL; - route->ksnr_ipaddr = ipaddr; - route->ksnr_port = port; - route->ksnr_connecting = 0; - route->ksnr_connected = 0; - route->ksnr_deleted = 0; - route->ksnr_conn_count = 0; - route->ksnr_share_count = 0; - - return (route); -} - -void -ksocknal_destroy_route (ksock_route_t *route) -{ - if (route->ksnr_peer != NULL) - ksocknal_put_peer (route->ksnr_peer); - - PORTAL_FREE (route, sizeof (*route)); -} - -void -ksocknal_put_route (ksock_route_t *route) -{ - CDEBUG (D_OTHER, "putting route[%p] (%d)\n", - route, atomic_read (&route->ksnr_refcount)); - - LASSERT (atomic_read (&route->ksnr_refcount) > 0); - if (!atomic_dec_and_test (&route->ksnr_refcount)) - return; - - ksocknal_destroy_route (route); -} - -ksock_peer_t * -ksocknal_create_peer (ptl_nid_t nid) -{ - ksock_peer_t *peer; - - LASSERT (nid != PTL_NID_ANY); - - PORTAL_ALLOC (peer, sizeof (*peer)); - if (peer == NULL) - return (NULL); - - memset (peer, 0, sizeof (*peer)); /* NULL pointers/clear flags etc */ - - peer->ksnp_nid = nid; - atomic_set (&peer->ksnp_refcount, 1); /* 1 ref for caller */ - peer->ksnp_closing = 0; - INIT_LIST_HEAD (&peer->ksnp_conns); - INIT_LIST_HEAD (&peer->ksnp_routes); - INIT_LIST_HEAD (&peer->ksnp_tx_queue); - - atomic_inc (&ksocknal_data.ksnd_npeers); - return (peer); -} - -void -ksocknal_destroy_peer (ksock_peer_t *peer) -{ - CDEBUG (D_NET, "peer "LPX64" %p deleted\n", peer->ksnp_nid, peer); - - LASSERT (atomic_read (&peer->ksnp_refcount) == 0); - LASSERT (list_empty (&peer->ksnp_conns)); - LASSERT (list_empty (&peer->ksnp_routes)); - LASSERT (list_empty (&peer->ksnp_tx_queue)); - - PORTAL_FREE (peer, sizeof (*peer)); - - /* NB a peer's connections and autoconnect routes keep a reference - * on their peer until they are destroyed, so we can be assured - * that _all_ state to do with this peer has been cleaned up when - * its refcount drops to zero. */ - atomic_dec (&ksocknal_data.ksnd_npeers); -} - -void -ksocknal_put_peer (ksock_peer_t *peer) -{ - CDEBUG (D_OTHER, "putting peer[%p] -> "LPX64" (%d)\n", - peer, peer->ksnp_nid, - atomic_read (&peer->ksnp_refcount)); - - LASSERT (atomic_read (&peer->ksnp_refcount) > 0); - if (!atomic_dec_and_test (&peer->ksnp_refcount)) - return; - - ksocknal_destroy_peer (peer); -} - -ksock_peer_t * -ksocknal_find_peer_locked (ptl_nid_t nid) -{ - struct list_head *peer_list = ksocknal_nid2peerlist (nid); - struct list_head *tmp; - ksock_peer_t *peer; - - list_for_each (tmp, peer_list) { - - peer = list_entry (tmp, ksock_peer_t, ksnp_list); - - LASSERT (!peer->ksnp_closing); - - if (peer->ksnp_nid != nid) - continue; - - CDEBUG(D_NET, "got peer [%p] -> "LPX64" (%d)\n", - peer, nid, atomic_read (&peer->ksnp_refcount)); - return (peer); - } - return (NULL); -} - -ksock_peer_t * -ksocknal_get_peer (ptl_nid_t nid) -{ - ksock_peer_t *peer; - - read_lock (&ksocknal_data.ksnd_global_lock); - peer = ksocknal_find_peer_locked (nid); - if (peer != NULL) /* +1 ref for caller? */ - atomic_inc (&peer->ksnp_refcount); - read_unlock (&ksocknal_data.ksnd_global_lock); - - return (peer); -} - -void -ksocknal_unlink_peer_locked (ksock_peer_t *peer) -{ - int i; - __u32 ip; - - for (i = 0; i < peer->ksnp_n_passive_ips; i++) { - LASSERT (i < SOCKNAL_MAX_INTERFACES); - ip = peer->ksnp_passive_ips[i]; - - ksocknal_ip2iface(ip)->ksni_npeers--; - } - - LASSERT (list_empty(&peer->ksnp_conns)); - LASSERT (list_empty(&peer->ksnp_routes)); - LASSERT (!peer->ksnp_closing); - peer->ksnp_closing = 1; - list_del (&peer->ksnp_list); - /* lose peerlist's ref */ - ksocknal_put_peer (peer); -} - -int -ksocknal_get_peer_info (int index, ptl_nid_t *nid, - __u32 *myip, __u32 *peer_ip, int *port, - int *conn_count, int *share_count) -{ - ksock_peer_t *peer; - struct list_head *ptmp; - ksock_route_t *route; - struct list_head *rtmp; - int i; - int j; - int rc = -ENOENT; - - read_lock (&ksocknal_data.ksnd_global_lock); - - for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { - - list_for_each (ptmp, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry (ptmp, ksock_peer_t, ksnp_list); - - if (peer->ksnp_n_passive_ips == 0 && - list_empty(&peer->ksnp_routes)) { - if (index-- > 0) - continue; - - *nid = peer->ksnp_nid; - *myip = 0; - *peer_ip = 0; - *port = 0; - *conn_count = 0; - *share_count = 0; - rc = 0; - goto out; - } - - for (j = 0; j < peer->ksnp_n_passive_ips; j++) { - if (index-- > 0) - continue; - - *nid = peer->ksnp_nid; - *myip = peer->ksnp_passive_ips[j]; - *peer_ip = 0; - *port = 0; - *conn_count = 0; - *share_count = 0; - rc = 0; - goto out; - } - - list_for_each (rtmp, &peer->ksnp_routes) { - if (index-- > 0) - continue; - - route = list_entry(rtmp, ksock_route_t, - ksnr_list); - - *nid = peer->ksnp_nid; - *myip = route->ksnr_myipaddr; - *peer_ip = route->ksnr_ipaddr; - *port = route->ksnr_port; - *conn_count = route->ksnr_conn_count; - *share_count = route->ksnr_share_count; - rc = 0; - goto out; - } - } - } - out: - read_unlock (&ksocknal_data.ksnd_global_lock); - return (rc); -} - -void -ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) -{ - ksock_peer_t *peer = route->ksnr_peer; - int type = conn->ksnc_type; - ksock_interface_t *iface; - - conn->ksnc_route = route; - atomic_inc (&route->ksnr_refcount); - - if (route->ksnr_myipaddr != conn->ksnc_myipaddr) { - if (route->ksnr_myipaddr == 0) { - /* route wasn't bound locally yet (the initial route) */ - CWARN("Binding "LPX64" %u.%u.%u.%u to %u.%u.%u.%u\n", - peer->ksnp_nid, - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(conn->ksnc_myipaddr)); - } else { - CWARN("Rebinding "LPX64" %u.%u.%u.%u from " - "%u.%u.%u.%u to %u.%u.%u.%u\n", - peer->ksnp_nid, - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(route->ksnr_myipaddr), - HIPQUAD(conn->ksnc_myipaddr)); - - iface = ksocknal_ip2iface(route->ksnr_myipaddr); - if (iface != NULL) - iface->ksni_nroutes--; - } - route->ksnr_myipaddr = conn->ksnc_myipaddr; - iface = ksocknal_ip2iface(route->ksnr_myipaddr); - if (iface != NULL) - iface->ksni_nroutes++; - } - - route->ksnr_connected |= (1<ksnr_connecting &= ~(1<ksnr_conn_count++; - - /* Successful connection => further attempts can - * proceed immediately */ - route->ksnr_timeout = jiffies; - route->ksnr_retry_interval = SOCKNAL_MIN_RECONNECT_INTERVAL; -} - -void -ksocknal_add_route_locked (ksock_peer_t *peer, ksock_route_t *route) -{ - struct list_head *tmp; - ksock_conn_t *conn; - int type; - ksock_route_t *route2; - - LASSERT (route->ksnr_peer == NULL); - LASSERT (route->ksnr_connecting == 0); - LASSERT (route->ksnr_connected == 0); - - /* LASSERT(unique) */ - list_for_each(tmp, &peer->ksnp_routes) { - route2 = list_entry(tmp, ksock_route_t, ksnr_list); - - if (route2->ksnr_ipaddr == route->ksnr_ipaddr) { - CERROR ("Duplicate route "LPX64" %u.%u.%u.%u\n", - peer->ksnp_nid, HIPQUAD(route->ksnr_ipaddr)); - LBUG(); - } - } - - route->ksnr_peer = peer; - atomic_inc (&peer->ksnp_refcount); - /* peer's routelist takes over my ref on 'route' */ - list_add_tail(&route->ksnr_list, &peer->ksnp_routes); - - list_for_each(tmp, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); - type = conn->ksnc_type; - - if (conn->ksnc_ipaddr != route->ksnr_ipaddr) - continue; - - ksocknal_associate_route_conn_locked(route, conn); - /* keep going (typed routes) */ - } -} - -void -ksocknal_del_route_locked (ksock_route_t *route) -{ - ksock_peer_t *peer = route->ksnr_peer; - ksock_interface_t *iface; - ksock_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - - LASSERT (!route->ksnr_deleted); - - /* Close associated conns */ - list_for_each_safe (ctmp, cnxt, &peer->ksnp_conns) { - conn = list_entry(ctmp, ksock_conn_t, ksnc_list); - - if (conn->ksnc_route != route) - continue; - - ksocknal_close_conn_locked (conn, 0); - } - - if (route->ksnr_myipaddr != 0) { - iface = ksocknal_ip2iface(route->ksnr_myipaddr); - if (iface != NULL) - iface->ksni_nroutes--; - } - - route->ksnr_deleted = 1; - list_del (&route->ksnr_list); - ksocknal_put_route (route); /* drop peer's ref */ - - if (list_empty (&peer->ksnp_routes) && - list_empty (&peer->ksnp_conns)) { - /* I've just removed the last autoconnect route of a peer - * with no active connections */ - ksocknal_unlink_peer_locked (peer); - } -} - -int -ksocknal_add_peer (ptl_nid_t nid, __u32 ipaddr, int port) -{ - unsigned long flags; - struct list_head *tmp; - ksock_peer_t *peer; - ksock_peer_t *peer2; - ksock_route_t *route; - ksock_route_t *route2; - - if (nid == PTL_NID_ANY) - return (-EINVAL); - - /* Have a brand new peer ready... */ - peer = ksocknal_create_peer (nid); - if (peer == NULL) - return (-ENOMEM); - - route = ksocknal_create_route (ipaddr, port); - if (route == NULL) { - ksocknal_put_peer (peer); - return (-ENOMEM); - } - - write_lock_irqsave (&ksocknal_data.ksnd_global_lock, flags); - - peer2 = ksocknal_find_peer_locked (nid); - if (peer2 != NULL) { - ksocknal_put_peer (peer); - peer = peer2; - } else { - /* peer table takes my ref on peer */ - list_add_tail (&peer->ksnp_list, - ksocknal_nid2peerlist (nid)); - } - - route2 = NULL; - list_for_each (tmp, &peer->ksnp_routes) { - route2 = list_entry(tmp, ksock_route_t, ksnr_list); - - if (route2->ksnr_ipaddr == ipaddr) - break; - - route2 = NULL; - } - if (route2 == NULL) { - ksocknal_add_route_locked(peer, route); - route->ksnr_share_count++; - } else { - ksocknal_put_route(route); - route2->ksnr_share_count++; - } - - write_unlock_irqrestore (&ksocknal_data.ksnd_global_lock, flags); - - return (0); -} - -void -ksocknal_del_peer_locked (ksock_peer_t *peer, __u32 ip, int single_share) -{ - ksock_conn_t *conn; - ksock_route_t *route; - struct list_head *tmp; - struct list_head *nxt; - int nshared; - - LASSERT (!peer->ksnp_closing); - - list_for_each_safe (tmp, nxt, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); - - if (single_share && route->ksnr_share_count == 0) - continue; - - /* no match */ - if (!(ip == 0 || route->ksnr_ipaddr == ip)) - continue; - - if (!single_share) - route->ksnr_share_count = 0; - else if (route->ksnr_share_count > 0) - route->ksnr_share_count--; - - if (route->ksnr_share_count == 0) { - /* This deletes associated conns too */ - ksocknal_del_route_locked (route); - } - - if (single_share) - break; - } - - nshared = 0; - list_for_each_safe (tmp, nxt, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); - nshared += route->ksnr_share_count; - } - - if (nshared == 0) { - /* remove everything else if there are no explicit entries - * left */ - - list_for_each_safe (tmp, nxt, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); - - /* we should only be removing auto-entries */ - LASSERT(route->ksnr_share_count == 0); - ksocknal_del_route_locked (route); - } - - list_for_each_safe (tmp, nxt, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); - - ksocknal_close_conn_locked(conn, 0); - } - } - - /* NB peer unlinks itself when last conn/route is removed */ -} - -int -ksocknal_del_peer (ptl_nid_t nid, __u32 ip, int single_share) -{ - unsigned long flags; - struct list_head *ptmp; - struct list_head *pnxt; - ksock_peer_t *peer; - int lo; - int hi; - int i; - int rc = -ENOENT; - - write_lock_irqsave (&ksocknal_data.ksnd_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = ksocknal_nid2peerlist(nid) - ksocknal_data.ksnd_peers; - else { - lo = 0; - hi = ksocknal_data.ksnd_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry (ptmp, ksock_peer_t, ksnp_list); - - if (!(nid == PTL_NID_ANY || peer->ksnp_nid == nid)) - continue; - - ksocknal_del_peer_locked (peer, ip, single_share); - rc = 0; /* matched! */ - - if (single_share) - break; - } - } - - write_unlock_irqrestore (&ksocknal_data.ksnd_global_lock, flags); - - return (rc); -} - -ksock_conn_t * -ksocknal_get_conn_by_idx (int index) -{ - ksock_peer_t *peer; - struct list_head *ptmp; - ksock_conn_t *conn; - struct list_head *ctmp; - int i; - - read_lock (&ksocknal_data.ksnd_global_lock); - - for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { - list_for_each (ptmp, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry (ptmp, ksock_peer_t, ksnp_list); - - LASSERT (!peer->ksnp_closing); - - list_for_each (ctmp, &peer->ksnp_conns) { - if (index-- > 0) - continue; - - conn = list_entry (ctmp, ksock_conn_t, ksnc_list); - atomic_inc (&conn->ksnc_refcount); - read_unlock (&ksocknal_data.ksnd_global_lock); - return (conn); - } - } - } - - read_unlock (&ksocknal_data.ksnd_global_lock); - return (NULL); -} - -int -ksocknal_get_conn_addrs (ksock_conn_t *conn) -{ - struct sockaddr_in sin; - int len = sizeof (sin); - int rc; - - rc = conn->ksnc_sock->ops->getname (conn->ksnc_sock, - (struct sockaddr *)&sin, &len, 2); - /* 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; - } - - conn->ksnc_ipaddr = ntohl (sin.sin_addr.s_addr); - conn->ksnc_port = ntohs (sin.sin_port); - - rc = conn->ksnc_sock->ops->getname (conn->ksnc_sock, - (struct sockaddr *)&sin, &len, 0); - if (rc != 0) { - CERROR ("Error %d getting sock local IP\n", rc); - return rc; - } - - conn->ksnc_myipaddr = ntohl (sin.sin_addr.s_addr); - - return 0; -} - -unsigned int -ksocknal_sock_irq (struct socket *sock) -{ - int irq = 0; - struct dst_entry *dst; - - if (!ksocknal_tunables.ksnd_irq_affinity) - return 0; - - dst = sk_dst_get (sock->sk); - if (dst != NULL) { - if (dst->dev != NULL) { - irq = dst->dev->irq; - if (irq >= NR_IRQS) { - CERROR ("Unexpected IRQ %x\n", irq); - irq = 0; - } - } - dst_release (dst); - } - - return (irq); -} - -ksock_sched_t * -ksocknal_choose_scheduler_locked (unsigned int irq) -{ - ksock_sched_t *sched; - ksock_irqinfo_t *info; - int i; - - LASSERT (irq < NR_IRQS); - info = &ksocknal_data.ksnd_irqinfo[irq]; - - if (irq != 0 && /* hardware NIC */ - info->ksni_valid) { /* already set up */ - return (&ksocknal_data.ksnd_schedulers[info->ksni_sched]); - } - - /* software NIC (irq == 0) || not associated with a scheduler yet. - * Choose the CPU with the fewest connections... */ - sched = &ksocknal_data.ksnd_schedulers[0]; - for (i = 1; i < ksocknal_data.ksnd_nschedulers; i++) - if (sched->kss_nconns > - ksocknal_data.ksnd_schedulers[i].kss_nconns) - sched = &ksocknal_data.ksnd_schedulers[i]; - - if (irq != 0) { /* Hardware NIC */ - info->ksni_valid = 1; - info->ksni_sched = sched - ksocknal_data.ksnd_schedulers; - - /* no overflow... */ - LASSERT (info->ksni_sched == sched - ksocknal_data.ksnd_schedulers); - } - - return (sched); -} - -int -ksocknal_local_ipvec (__u32 *ipaddrs) -{ - int i; - int nip; - - read_lock (&ksocknal_data.ksnd_global_lock); - - nip = ksocknal_data.ksnd_ninterfaces; - for (i = 0; i < nip; i++) { - LASSERT (i < SOCKNAL_MAX_INTERFACES); - - ipaddrs[i] = ksocknal_data.ksnd_interfaces[i].ksni_ipaddr; - LASSERT (ipaddrs[i] != 0); - } - - read_unlock (&ksocknal_data.ksnd_global_lock); - return (nip); -} - -int -ksocknal_match_peerip (ksock_interface_t *iface, __u32 *ips, int nips) -{ - int best_netmatch = 0; - int best_xor = 0; - int best = -1; - int this_xor; - int this_netmatch; - int i; - - for (i = 0; i < nips; i++) { - if (ips[i] == 0) - continue; - - this_xor = (ips[i] ^ iface->ksni_ipaddr); - this_netmatch = ((this_xor & iface->ksni_netmask) == 0) ? 1 : 0; - - if (!(best < 0 || - best_netmatch < this_netmatch || - (best_netmatch == this_netmatch && - best_xor > this_xor))) - continue; - - best = i; - best_netmatch = this_netmatch; - best_xor = this_xor; - } - - LASSERT (best >= 0); - return (best); -} - -int -ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips) -{ - rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; - unsigned long flags; - ksock_interface_t *iface; - ksock_interface_t *best_iface; - int n_ips; - int i; - int j; - int k; - __u32 ip; - __u32 xor; - int this_netmatch; - int best_netmatch; - int best_npeers; - - /* CAVEAT EMPTOR: We do all our interface matching with an - * exclusive hold of global lock at IRQ priority. We're only - * expecting to be dealing with small numbers of interfaces, so the - * O(n**3)-ness shouldn't matter */ - - /* Also note that I'm not going to return more than n_peerips - * interfaces, even if I have more myself */ - - write_lock_irqsave(global_lock, flags); - - LASSERT (n_peerips <= SOCKNAL_MAX_INTERFACES); - LASSERT (ksocknal_data.ksnd_ninterfaces <= SOCKNAL_MAX_INTERFACES); - - n_ips = MIN(n_peerips, ksocknal_data.ksnd_ninterfaces); - - for (i = 0; peer->ksnp_n_passive_ips < n_ips; i++) { - /* ^ yes really... */ - - /* If we have any new interfaces, first tick off all the - * peer IPs that match old interfaces, then choose new - * interfaces to match the remaining peer IPS. - * We don't forget interfaces we've stopped using; we might - * start using them again... */ - - if (i < peer->ksnp_n_passive_ips) { - /* Old interface. */ - ip = peer->ksnp_passive_ips[i]; - best_iface = ksocknal_ip2iface(ip); - - /* peer passive ips are kept up to date */ - LASSERT(best_iface != NULL); - } else { - /* choose a new interface */ - LASSERT (i == peer->ksnp_n_passive_ips); - - best_iface = NULL; - best_netmatch = 0; - best_npeers = 0; - - for (j = 0; j < ksocknal_data.ksnd_ninterfaces; j++) { - iface = &ksocknal_data.ksnd_interfaces[j]; - ip = iface->ksni_ipaddr; - - for (k = 0; k < peer->ksnp_n_passive_ips; k++) - if (peer->ksnp_passive_ips[k] == ip) - break; - - if (k < peer->ksnp_n_passive_ips) /* using it already */ - continue; - - k = ksocknal_match_peerip(iface, peerips, n_peerips); - xor = (ip ^ peerips[k]); - this_netmatch = ((xor & iface->ksni_netmask) == 0) ? 1 : 0; - - if (!(best_iface == NULL || - best_netmatch < this_netmatch || - (best_netmatch == this_netmatch && - best_npeers > iface->ksni_npeers))) - continue; - - best_iface = iface; - best_netmatch = this_netmatch; - best_npeers = iface->ksni_npeers; - } - - best_iface->ksni_npeers++; - ip = best_iface->ksni_ipaddr; - peer->ksnp_passive_ips[i] = ip; - peer->ksnp_n_passive_ips = i+1; - } - - LASSERT (best_iface != NULL); - - /* mark the best matching peer IP used */ - j = ksocknal_match_peerip(best_iface, peerips, n_peerips); - peerips[j] = 0; - } - - /* Overwrite input peer IP addresses */ - memcpy(peerips, peer->ksnp_passive_ips, n_ips * sizeof(*peerips)); - - write_unlock_irqrestore(global_lock, flags); - - return (n_ips); -} - -void -ksocknal_create_routes(ksock_peer_t *peer, int port, - __u32 *peer_ipaddrs, int npeer_ipaddrs) -{ - ksock_route_t *newroute = NULL; - rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; - unsigned long flags; - struct list_head *rtmp; - ksock_route_t *route; - ksock_interface_t *iface; - ksock_interface_t *best_iface; - int best_netmatch; - int this_netmatch; - int best_nroutes; - int i; - int j; - - /* CAVEAT EMPTOR: We do all our interface matching with an - * exclusive hold of global lock at IRQ priority. We're only - * expecting to be dealing with small numbers of interfaces, so the - * O(n**3)-ness here shouldn't matter */ - - write_lock_irqsave(global_lock, flags); - - LASSERT (npeer_ipaddrs <= SOCKNAL_MAX_INTERFACES); - - for (i = 0; i < npeer_ipaddrs; i++) { - if (newroute != NULL) { - newroute->ksnr_ipaddr = peer_ipaddrs[i]; - } else { - write_unlock_irqrestore(global_lock, flags); - - newroute = ksocknal_create_route(peer_ipaddrs[i], port); - if (newroute == NULL) - return; - - write_lock_irqsave(global_lock, flags); - } - - /* Already got a route? */ - route = NULL; - list_for_each(rtmp, &peer->ksnp_routes) { - route = list_entry(rtmp, ksock_route_t, ksnr_list); - - if (route->ksnr_ipaddr == newroute->ksnr_ipaddr) - break; - - route = NULL; - } - if (route != NULL) - continue; - - best_iface = NULL; - best_nroutes = 0; - best_netmatch = 0; - - LASSERT (ksocknal_data.ksnd_ninterfaces <= SOCKNAL_MAX_INTERFACES); - - /* Select interface to connect from */ - for (j = 0; j < ksocknal_data.ksnd_ninterfaces; j++) { - iface = &ksocknal_data.ksnd_interfaces[j]; - - /* Using this interface already? */ - list_for_each(rtmp, &peer->ksnp_routes) { - route = list_entry(rtmp, ksock_route_t, ksnr_list); - - if (route->ksnr_myipaddr == iface->ksni_ipaddr) - break; - - route = NULL; - } - if (route != NULL) - continue; - - this_netmatch = (((iface->ksni_ipaddr ^ - newroute->ksnr_ipaddr) & - iface->ksni_netmask) == 0) ? 1 : 0; - - if (!(best_iface == NULL || - best_netmatch < this_netmatch || - (best_netmatch == this_netmatch && - best_nroutes > iface->ksni_nroutes))) - continue; - - best_iface = iface; - best_netmatch = this_netmatch; - best_nroutes = iface->ksni_nroutes; - } - - if (best_iface == NULL) - continue; - - newroute->ksnr_myipaddr = best_iface->ksni_ipaddr; - best_iface->ksni_nroutes++; - - ksocknal_add_route_locked(peer, newroute); - newroute = NULL; - } - - write_unlock_irqrestore(global_lock, flags); - if (newroute != NULL) - ksocknal_put_route(newroute); -} - -int -ksocknal_create_conn (ksock_route_t *route, struct socket *sock, int type) -{ - int passive = (type == SOCKNAL_CONN_NONE); - rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; - __u32 ipaddrs[SOCKNAL_MAX_INTERFACES]; - int nipaddrs; - ptl_nid_t nid; - struct list_head *tmp; - __u64 incarnation; - unsigned long flags; - ksock_conn_t *conn; - ksock_conn_t *conn2; - ksock_peer_t *peer = NULL; - ksock_peer_t *peer2; - ksock_sched_t *sched; - unsigned int irq; - ksock_tx_t *tx; - int rc; - - /* NB, sock has an associated file since (a) this connection might - * have been created in userland and (b) we need to refcount the - * socket so that we don't close it while I/O is being done on - * it, and sock->file has that pre-cooked... */ - LASSERT (sock->file != NULL); - LASSERT (file_count(sock->file) > 0); - LASSERT (route == NULL || !passive); - - rc = ksocknal_setup_sock (sock); - if (rc != 0) - return (rc); - - irq = ksocknal_sock_irq (sock); - - PORTAL_ALLOC(conn, sizeof(*conn)); - if (conn == NULL) - return (-ENOMEM); - - memset (conn, 0, sizeof (*conn)); - conn->ksnc_peer = NULL; - conn->ksnc_route = NULL; - conn->ksnc_sock = sock; - conn->ksnc_type = type; - conn->ksnc_saved_data_ready = sock->sk->sk_data_ready; - conn->ksnc_saved_write_space = sock->sk->sk_write_space; - atomic_set (&conn->ksnc_refcount, 1); /* 1 ref for me */ - - conn->ksnc_rx_ready = 0; - conn->ksnc_rx_scheduled = 0; - ksocknal_new_packet (conn, 0); - - INIT_LIST_HEAD (&conn->ksnc_tx_queue); - conn->ksnc_tx_ready = 0; - conn->ksnc_tx_scheduled = 0; - atomic_set (&conn->ksnc_tx_nob, 0); - - /* stash conn's local and remote addrs */ - rc = ksocknal_get_conn_addrs (conn); - if (rc != 0) - goto failed_0; - - if (!passive) { - /* Active connection sends HELLO eagerly */ - rc = ksocknal_local_ipvec(ipaddrs); - if (rc < 0) - goto failed_0; - nipaddrs = rc; - - rc = ksocknal_send_hello (conn, ipaddrs, nipaddrs); - if (rc != 0) - goto failed_0; - } - - /* Find out/confirm peer's NID and connection type and get the - * vector of interfaces she's willing to let me connect to */ - nid = (route == NULL) ? PTL_NID_ANY : route->ksnr_peer->ksnp_nid; - rc = ksocknal_recv_hello (conn, &nid, &incarnation, ipaddrs); - if (rc < 0) - goto failed_0; - nipaddrs = rc; - LASSERT (nid != PTL_NID_ANY); - - if (route != NULL) { - peer = route->ksnr_peer; - atomic_inc(&peer->ksnp_refcount); - } else { - peer = ksocknal_create_peer(nid); - if (peer == NULL) { - rc = -ENOMEM; - goto failed_0; - } - - write_lock_irqsave(global_lock, flags); - - peer2 = ksocknal_find_peer_locked(nid); - if (peer2 == NULL) { - /* NB this puts an "empty" peer in the peer - * table (which takes my ref) */ - list_add_tail(&peer->ksnp_list, - ksocknal_nid2peerlist(nid)); - } else { - ksocknal_put_peer(peer); - peer = peer2; - } - /* +1 ref for me */ - atomic_inc(&peer->ksnp_refcount); - - write_unlock_irqrestore(global_lock, flags); - } - - if (!passive) { - ksocknal_create_routes(peer, conn->ksnc_port, - ipaddrs, nipaddrs); - rc = 0; - } else { - rc = ksocknal_select_ips(peer, ipaddrs, nipaddrs); - LASSERT (rc >= 0); - rc = ksocknal_send_hello (conn, ipaddrs, rc); - } - if (rc < 0) - goto failed_1; - - write_lock_irqsave (global_lock, flags); - - if (peer->ksnp_closing || - (route != NULL && route->ksnr_deleted)) { - /* route/peer got closed under me */ - rc = -ESTALE; - goto failed_2; - } - - /* Refuse to duplicate an existing connection (both sides might - * autoconnect at once), unless this is a loopback connection */ - if (conn->ksnc_ipaddr != conn->ksnc_myipaddr) { - list_for_each(tmp, &peer->ksnp_conns) { - conn2 = list_entry(tmp, ksock_conn_t, ksnc_list); - - if (conn2->ksnc_ipaddr != conn->ksnc_ipaddr || - conn2->ksnc_myipaddr != conn->ksnc_myipaddr || - conn2->ksnc_type != conn->ksnc_type || - conn2->ksnc_incarnation != incarnation) - continue; - - CWARN("Not creating duplicate connection to " - "%u.%u.%u.%u type %d\n", - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_type); - rc = -EALREADY; - goto failed_2; - } - } - - /* If the connection created by this route didn't bind to the IP - * address the route connected to, the connection/route matching - * code below probably isn't going to work. */ - if (route != NULL && - route->ksnr_ipaddr != conn->ksnc_ipaddr) { - CERROR("Route "LPX64" %u.%u.%u.%u connected to %u.%u.%u.%u\n", - peer->ksnp_nid, - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(conn->ksnc_ipaddr)); - } - - /* Search for a route corresponding to the new connection and - * create an association. This allows incoming connections created - * by routes in my peer to match my own route entries so I don't - * continually create duplicate routes. */ - list_for_each (tmp, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); - - if (route->ksnr_ipaddr != conn->ksnc_ipaddr) - continue; - - ksocknal_associate_route_conn_locked(route, conn); - break; - } - - /* Give conn a ref on sock->file since we're going to return success */ - get_file(sock->file); - - conn->ksnc_peer = peer; /* conn takes my ref on peer */ - conn->ksnc_incarnation = incarnation; - peer->ksnp_last_alive = jiffies; - peer->ksnp_error = 0; - - sched = ksocknal_choose_scheduler_locked (irq); - sched->kss_nconns++; - conn->ksnc_scheduler = sched; - - /* Set the deadline for the outgoing HELLO to drain */ - conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued; - conn->ksnc_tx_deadline = jiffies + - ksocknal_tunables.ksnd_io_timeout * HZ; - mb(); /* order with adding to peer's conn list */ - - list_add (&conn->ksnc_list, &peer->ksnp_conns); - atomic_inc (&conn->ksnc_refcount); - - /* NB my callbacks block while I hold ksnd_global_lock */ - sock->sk->sk_user_data = conn; - sock->sk->sk_data_ready = ksocknal_data_ready; - sock->sk->sk_write_space = ksocknal_write_space; - - /* Take all the packets blocking for a connection. - * NB, it might be nicer to share these blocked packets among any - * other connections that are becoming established. */ - while (!list_empty (&peer->ksnp_tx_queue)) { - tx = list_entry (peer->ksnp_tx_queue.next, - ksock_tx_t, tx_list); - - list_del (&tx->tx_list); - ksocknal_queue_tx_locked (tx, conn); - } - - rc = ksocknal_close_stale_conns_locked(peer, incarnation); - if (rc != 0) - CERROR ("Closed %d stale conns to nid "LPX64" ip %d.%d.%d.%d\n", - rc, conn->ksnc_peer->ksnp_nid, - HIPQUAD(conn->ksnc_ipaddr)); - - write_unlock_irqrestore (global_lock, flags); - - ksocknal_bind_irq (irq); - - /* Call the callbacks right now to get things going. */ - if (ksocknal_getconnsock(conn) == 0) { - ksocknal_data_ready (sock->sk, 0); - ksocknal_write_space (sock->sk); - ksocknal_putconnsock(conn); - } - - CWARN("New conn nid:"LPX64" %u.%u.%u.%u -> %u.%u.%u.%u/%d" - " incarnation:"LPX64" sched[%d]/%d\n", - nid, HIPQUAD(conn->ksnc_myipaddr), - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port, incarnation, - (int)(conn->ksnc_scheduler - ksocknal_data.ksnd_schedulers), irq); - - ksocknal_put_conn (conn); - return (0); - - failed_2: - if (!peer->ksnp_closing && - list_empty (&peer->ksnp_conns) && - list_empty (&peer->ksnp_routes)) - ksocknal_unlink_peer_locked(peer); - write_unlock_irqrestore(global_lock, flags); - - failed_1: - ksocknal_put_peer (peer); - - failed_0: - PORTAL_FREE (conn, sizeof(*conn)); - - LASSERT (rc != 0); - return (rc); -} - -void -ksocknal_close_conn_locked (ksock_conn_t *conn, int error) -{ - /* This just does the immmediate housekeeping, and queues the - * connection for the reaper to terminate. - * Caller holds ksnd_global_lock exclusively in irq context */ - ksock_peer_t *peer = conn->ksnc_peer; - ksock_route_t *route; - ksock_conn_t *conn2; - struct list_head *tmp; - - LASSERT (peer->ksnp_error == 0); - LASSERT (!conn->ksnc_closing); - conn->ksnc_closing = 1; - atomic_inc (&ksocknal_data.ksnd_nclosing_conns); - - /* ksnd_deathrow_conns takes over peer's ref */ - list_del (&conn->ksnc_list); - - route = conn->ksnc_route; - if (route != NULL) { - /* dissociate conn from route... */ - LASSERT (!route->ksnr_deleted); - LASSERT ((route->ksnr_connecting & (1 << conn->ksnc_type)) == 0); - LASSERT ((route->ksnr_connected & (1 << conn->ksnc_type)) != 0); - - conn2 = NULL; - list_for_each(tmp, &peer->ksnp_conns) { - conn2 = list_entry(tmp, ksock_conn_t, ksnc_list); - - if (conn2->ksnc_route == route && - conn2->ksnc_type == conn->ksnc_type) - break; - - conn2 = NULL; - } - if (conn2 == NULL) - route->ksnr_connected &= ~(1 << conn->ksnc_type); - - conn->ksnc_route = NULL; - -#if 0 /* irrelevent with only eager routes */ - list_del (&route->ksnr_list); /* make route least favourite */ - list_add_tail (&route->ksnr_list, &peer->ksnp_routes); -#endif - ksocknal_put_route (route); /* drop conn's ref on route */ - } - - if (list_empty (&peer->ksnp_conns)) { - /* No more connections to this peer */ - - peer->ksnp_error = error; /* stash last conn close reason */ - - if (list_empty (&peer->ksnp_routes)) { - /* I've just closed last conn belonging to a - * non-autoconnecting peer */ - ksocknal_unlink_peer_locked (peer); - } - } - - spin_lock (&ksocknal_data.ksnd_reaper_lock); - - list_add_tail (&conn->ksnc_list, &ksocknal_data.ksnd_deathrow_conns); - wake_up (&ksocknal_data.ksnd_reaper_waitq); - - spin_unlock (&ksocknal_data.ksnd_reaper_lock); -} - -void -ksocknal_terminate_conn (ksock_conn_t *conn) -{ - /* This gets called by the reaper (guaranteed thread context) to - * disengage the socket from its callbacks and close it. - * ksnc_refcount will eventually hit zero, and then the reaper will - * destroy it. */ - unsigned long flags; - ksock_peer_t *peer = conn->ksnc_peer; - ksock_sched_t *sched = conn->ksnc_scheduler; - struct timeval now; - time_t then = 0; - int notify = 0; - - LASSERT(conn->ksnc_closing); - - /* wake up the scheduler to "send" all remaining packets to /dev/null */ - spin_lock_irqsave(&sched->kss_lock, flags); - - if (!conn->ksnc_tx_scheduled && - !list_empty(&conn->ksnc_tx_queue)){ - list_add_tail (&conn->ksnc_tx_list, - &sched->kss_tx_conns); - /* a closing conn is always ready to tx */ - conn->ksnc_tx_ready = 1; - conn->ksnc_tx_scheduled = 1; - /* extra ref for scheduler */ - atomic_inc (&conn->ksnc_refcount); - - wake_up (&sched->kss_waitq); - } - - spin_unlock_irqrestore (&sched->kss_lock, flags); - - /* serialise with callbacks */ - write_lock_irqsave (&ksocknal_data.ksnd_global_lock, flags); - - /* Remove conn's network callbacks. - * NB I _have_ to restore the callback, rather than storing a noop, - * since the socket could survive past this module being unloaded!! */ - conn->ksnc_sock->sk->sk_data_ready = conn->ksnc_saved_data_ready; - conn->ksnc_sock->sk->sk_write_space = conn->ksnc_saved_write_space; - - /* A callback could be in progress already; they hold a read lock - * on ksnd_global_lock (to serialise with me) and NOOP if - * sk_user_data is NULL. */ - conn->ksnc_sock->sk->sk_user_data = NULL; - - /* OK, so this conn may not be completely disengaged from its - * scheduler yet, but it _has_ committed to terminate... */ - conn->ksnc_scheduler->kss_nconns--; - - if (peer->ksnp_error != 0) { - /* peer's last conn closed in error */ - LASSERT (list_empty (&peer->ksnp_conns)); - - /* convert peer's last-known-alive timestamp from jiffies */ - do_gettimeofday (&now); - then = now.tv_sec - (jiffies - peer->ksnp_last_alive)/HZ; - notify = 1; - } - - write_unlock_irqrestore (&ksocknal_data.ksnd_global_lock, flags); - - /* The socket is closed on the final put; either here, or in - * ksocknal_{send,recv}msg(). Since we set up the linger2 option - * when the connection was established, this will close the socket - * immediately, aborting anything buffered in it. Any hung - * zero-copy transmits will therefore complete in finite time. */ - ksocknal_putconnsock (conn); - - if (notify) - kpr_notify (&ksocknal_data.ksnd_router, peer->ksnp_nid, - 0, then); -} - -void -ksocknal_destroy_conn (ksock_conn_t *conn) -{ - /* Final coup-de-grace of the reaper */ - CDEBUG (D_NET, "connection %p\n", conn); - - LASSERT (atomic_read (&conn->ksnc_refcount) == 0); - LASSERT (conn->ksnc_route == NULL); - LASSERT (!conn->ksnc_tx_scheduled); - LASSERT (!conn->ksnc_rx_scheduled); - LASSERT (list_empty(&conn->ksnc_tx_queue)); - - /* complete current receive if any */ - switch (conn->ksnc_rx_state) { - case SOCKNAL_RX_BODY: - CERROR("Completing partial receive from "LPX64 - ", ip %d.%d.%d.%d:%d, with error\n", - conn->ksnc_peer->ksnp_nid, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); - lib_finalize (&ksocknal_lib, NULL, conn->ksnc_cookie, PTL_FAIL); - break; - case SOCKNAL_RX_BODY_FWD: - ksocknal_fmb_callback (conn->ksnc_cookie, -ECONNABORTED); - break; - case SOCKNAL_RX_HEADER: - case SOCKNAL_RX_SLOP: - break; - default: - LBUG (); - break; - } - - ksocknal_put_peer (conn->ksnc_peer); - - PORTAL_FREE (conn, sizeof (*conn)); - atomic_dec (&ksocknal_data.ksnd_nclosing_conns); -} - -void -ksocknal_put_conn (ksock_conn_t *conn) -{ - unsigned long flags; - - CDEBUG (D_OTHER, "putting conn[%p] -> "LPX64" (%d)\n", - conn, conn->ksnc_peer->ksnp_nid, - atomic_read (&conn->ksnc_refcount)); - - LASSERT (atomic_read (&conn->ksnc_refcount) > 0); - if (!atomic_dec_and_test (&conn->ksnc_refcount)) - return; - - spin_lock_irqsave (&ksocknal_data.ksnd_reaper_lock, flags); - - list_add (&conn->ksnc_list, &ksocknal_data.ksnd_zombie_conns); - wake_up (&ksocknal_data.ksnd_reaper_waitq); - - spin_unlock_irqrestore (&ksocknal_data.ksnd_reaper_lock, flags); -} - -int -ksocknal_close_peer_conns_locked (ksock_peer_t *peer, __u32 ipaddr, int why) -{ - ksock_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->ksnp_conns) { - conn = list_entry (ctmp, ksock_conn_t, ksnc_list); - - if (ipaddr == 0 || - conn->ksnc_ipaddr == ipaddr) { - count++; - ksocknal_close_conn_locked (conn, why); - } - } - - return (count); -} - -int -ksocknal_close_stale_conns_locked (ksock_peer_t *peer, __u64 incarnation) -{ - ksock_conn_t *conn; - struct list_head *ctmp; - struct list_head *cnxt; - int count = 0; - - list_for_each_safe (ctmp, cnxt, &peer->ksnp_conns) { - conn = list_entry (ctmp, ksock_conn_t, ksnc_list); - - if (conn->ksnc_incarnation == incarnation) - continue; - - CWARN("Closing stale conn nid:"LPX64" ip:%08x/%d " - "incarnation:"LPX64"("LPX64")\n", - peer->ksnp_nid, conn->ksnc_ipaddr, conn->ksnc_port, - conn->ksnc_incarnation, incarnation); - - count++; - ksocknal_close_conn_locked (conn, -ESTALE); - } - - return (count); -} - -int -ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why) -{ - ksock_peer_t *peer = conn->ksnc_peer; - __u32 ipaddr = conn->ksnc_ipaddr; - unsigned long flags; - int count; - - write_lock_irqsave (&ksocknal_data.ksnd_global_lock, flags); - - count = ksocknal_close_peer_conns_locked (peer, ipaddr, why); - - write_unlock_irqrestore (&ksocknal_data.ksnd_global_lock, flags); - - return (count); -} - -int -ksocknal_close_matching_conns (ptl_nid_t nid, __u32 ipaddr) -{ - unsigned long flags; - ksock_peer_t *peer; - struct list_head *ptmp; - struct list_head *pnxt; - int lo; - int hi; - int i; - int count = 0; - - write_lock_irqsave (&ksocknal_data.ksnd_global_lock, flags); - - if (nid != PTL_NID_ANY) - lo = hi = ksocknal_nid2peerlist(nid) - ksocknal_data.ksnd_peers; - else { - lo = 0; - hi = ksocknal_data.ksnd_peer_hash_size - 1; - } - - for (i = lo; i <= hi; i++) { - list_for_each_safe (ptmp, pnxt, &ksocknal_data.ksnd_peers[i]) { - - peer = list_entry (ptmp, ksock_peer_t, ksnp_list); - - if (!(nid == PTL_NID_ANY || nid == peer->ksnp_nid)) - continue; - - count += ksocknal_close_peer_conns_locked (peer, ipaddr, 0); - } - } - - write_unlock_irqrestore (&ksocknal_data.ksnd_global_lock, flags); - - /* wildcards always succeed */ - if (nid == PTL_NID_ANY || ipaddr == 0) - return (0); - - return (count == 0 ? -ENOENT : 0); -} - -void -ksocknal_notify (void *arg, ptl_nid_t gw_nid, int alive) -{ - /* The router is telling me she's been notified of a change in - * gateway state.... */ - - CDEBUG (D_NET, "gw "LPX64" %s\n", gw_nid, alive ? "up" : "down"); - - if (!alive) { - /* If the gateway crashed, close all open connections... */ - ksocknal_close_matching_conns (gw_nid, 0); - return; - } - - /* ...otherwise do nothing. We can only establish new connections - * if we have autroutes, and these connect on demand. */ -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -struct tcp_opt *sock2tcp_opt(struct sock *sk) -{ - return &(sk->tp_pinfo.af_tcp); -} -#else -struct tcp_opt *sock2tcp_opt(struct sock *sk) -{ - struct tcp_sock *s = (struct tcp_sock *)sk; - return &s->tcp; -} -#endif - -void -ksocknal_push_conn (ksock_conn_t *conn) -{ - struct sock *sk; - struct tcp_opt *tp; - int nonagle; - int val = 1; - int rc; - mm_segment_t oldmm; - - rc = ksocknal_getconnsock (conn); - if (rc != 0) /* being shut down */ - return; - - sk = conn->ksnc_sock->sk; - tp = sock2tcp_opt(sk); - - lock_sock (sk); - nonagle = tp->nonagle; - tp->nonagle = 1; - release_sock (sk); - - oldmm = get_fs (); - set_fs (KERNEL_DS); - - rc = sk->sk_prot->setsockopt (sk, SOL_TCP, TCP_NODELAY, - (char *)&val, sizeof (val)); - LASSERT (rc == 0); - - set_fs (oldmm); - - lock_sock (sk); - tp->nonagle = nonagle; - release_sock (sk); - - ksocknal_putconnsock (conn); -} - -void -ksocknal_push_peer (ksock_peer_t *peer) -{ - int index; - int i; - struct list_head *tmp; - ksock_conn_t *conn; - - for (index = 0; ; index++) { - read_lock (&ksocknal_data.ksnd_global_lock); - - i = 0; - conn = NULL; - - list_for_each (tmp, &peer->ksnp_conns) { - if (i++ == index) { - conn = list_entry (tmp, ksock_conn_t, ksnc_list); - atomic_inc (&conn->ksnc_refcount); - break; - } - } - - read_unlock (&ksocknal_data.ksnd_global_lock); - - if (conn == NULL) - break; - - ksocknal_push_conn (conn); - ksocknal_put_conn (conn); - } -} - -int -ksocknal_push (ptl_nid_t nid) -{ - ksock_peer_t *peer; - struct list_head *tmp; - int index; - int i; - int j; - int rc = -ENOENT; - - if (nid != PTL_NID_ANY) { - peer = ksocknal_get_peer (nid); - - if (peer != NULL) { - rc = 0; - ksocknal_push_peer (peer); - ksocknal_put_peer (peer); - } - return (rc); - } - - for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { - for (j = 0; ; j++) { - read_lock (&ksocknal_data.ksnd_global_lock); - - index = 0; - peer = NULL; - - list_for_each (tmp, &ksocknal_data.ksnd_peers[i]) { - if (index++ == j) { - peer = list_entry(tmp, ksock_peer_t, - ksnp_list); - atomic_inc (&peer->ksnp_refcount); - break; - } - } - - read_unlock (&ksocknal_data.ksnd_global_lock); - - if (peer != NULL) { - rc = 0; - ksocknal_push_peer (peer); - ksocknal_put_peer (peer); - } - } - - } - - return (rc); -} - -int -ksocknal_add_interface(__u32 ipaddress, __u32 netmask) -{ - unsigned long flags; - ksock_interface_t *iface; - int rc; - int i; - int j; - struct list_head *ptmp; - ksock_peer_t *peer; - struct list_head *rtmp; - ksock_route_t *route; - - if (ipaddress == 0 || - netmask == 0) - return (-EINVAL); - - write_lock_irqsave(&ksocknal_data.ksnd_global_lock, flags); - - iface = ksocknal_ip2iface(ipaddress); - if (iface != NULL) { - /* silently ignore dups */ - rc = 0; - } else if (ksocknal_data.ksnd_ninterfaces == SOCKNAL_MAX_INTERFACES) { - rc = -ENOSPC; - } else { - iface = &ksocknal_data.ksnd_interfaces[ksocknal_data.ksnd_ninterfaces++]; - - iface->ksni_ipaddr = ipaddress; - iface->ksni_netmask = netmask; - iface->ksni_nroutes = 0; - iface->ksni_npeers = 0; - - for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { - list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry(ptmp, ksock_peer_t, ksnp_list); - - for (j = 0; i < peer->ksnp_n_passive_ips; j++) - if (peer->ksnp_passive_ips[j] == ipaddress) - iface->ksni_npeers++; - - list_for_each(rtmp, &peer->ksnp_routes) { - route = list_entry(rtmp, ksock_route_t, ksnr_list); - - if (route->ksnr_myipaddr == ipaddress) - iface->ksni_nroutes++; - } - } - } - - rc = 0; - /* NB only new connections will pay attention to the new interface! */ - } - - write_unlock_irqrestore(&ksocknal_data.ksnd_global_lock, flags); - - return (rc); -} - -void -ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr) -{ - struct list_head *tmp; - struct list_head *nxt; - ksock_route_t *route; - ksock_conn_t *conn; - int i; - int j; - - for (i = 0; i < peer->ksnp_n_passive_ips; i++) - if (peer->ksnp_passive_ips[i] == ipaddr) { - for (j = i+1; j < peer->ksnp_n_passive_ips; j++) - peer->ksnp_passive_ips[j-1] = - peer->ksnp_passive_ips[j]; - peer->ksnp_n_passive_ips--; - break; - } - - list_for_each_safe(tmp, nxt, &peer->ksnp_routes) { - route = list_entry (tmp, ksock_route_t, ksnr_list); - - if (route->ksnr_myipaddr != ipaddr) - continue; - - if (route->ksnr_share_count != 0) { - /* Manually created; keep, but unbind */ - route->ksnr_myipaddr = 0; - } else { - ksocknal_del_route_locked(route); - } - } - - list_for_each_safe(tmp, nxt, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); - - if (conn->ksnc_myipaddr == ipaddr) - ksocknal_close_conn_locked (conn, 0); - } -} - -int -ksocknal_del_interface(__u32 ipaddress) -{ - int rc = -ENOENT; - unsigned long flags; - struct list_head *tmp; - struct list_head *nxt; - ksock_peer_t *peer; - __u32 this_ip; - int i; - int j; - - write_lock_irqsave(&ksocknal_data.ksnd_global_lock, flags); - - for (i = 0; i < ksocknal_data.ksnd_ninterfaces; i++) { - this_ip = ksocknal_data.ksnd_interfaces[i].ksni_ipaddr; - - if (!(ipaddress == 0 || - ipaddress == this_ip)) - continue; - - rc = 0; - - for (j = i+1; j < ksocknal_data.ksnd_ninterfaces; j++) - ksocknal_data.ksnd_interfaces[j-1] = - ksocknal_data.ksnd_interfaces[j]; - - ksocknal_data.ksnd_ninterfaces--; - - for (j = 0; j < ksocknal_data.ksnd_peer_hash_size; j++) { - list_for_each_safe(tmp, nxt, &ksocknal_data.ksnd_peers[j]) { - peer = list_entry(tmp, ksock_peer_t, ksnp_list); - - ksocknal_peer_del_interface_locked(peer, this_ip); - } - } - } - - write_unlock_irqrestore(&ksocknal_data.ksnd_global_lock, flags); - - return (rc); -} - -int -ksocknal_cmd(struct portals_cfg *pcfg, void * private) -{ - int rc; - - switch(pcfg->pcfg_command) { - case NAL_CMD_GET_INTERFACE: { - ksock_interface_t *iface; - - read_lock (&ksocknal_data.ksnd_global_lock); - - if (pcfg->pcfg_count < 0 || - pcfg->pcfg_count >= ksocknal_data.ksnd_ninterfaces) { - rc = -ENOENT; - } else { - rc = 0; - iface = &ksocknal_data.ksnd_interfaces[pcfg->pcfg_count]; - - pcfg->pcfg_id = iface->ksni_ipaddr; - pcfg->pcfg_misc = iface->ksni_netmask; - pcfg->pcfg_fd = iface->ksni_npeers; - pcfg->pcfg_count = iface->ksni_nroutes; - } - - read_unlock (&ksocknal_data.ksnd_global_lock); - break; - } - case NAL_CMD_ADD_INTERFACE: { - rc = ksocknal_add_interface(pcfg->pcfg_id, /* IP address */ - pcfg->pcfg_misc); /* net mask */ - break; - } - case NAL_CMD_DEL_INTERFACE: { - rc = ksocknal_del_interface(pcfg->pcfg_id); /* IP address */ - break; - } - case NAL_CMD_GET_PEER: { - ptl_nid_t nid = 0; - __u32 myip = 0; - __u32 ip = 0; - int port = 0; - int conn_count = 0; - int share_count = 0; - - rc = ksocknal_get_peer_info(pcfg->pcfg_count, &nid, - &myip, &ip, &port, - &conn_count, &share_count); - pcfg->pcfg_nid = nid; - pcfg->pcfg_size = myip; - pcfg->pcfg_id = ip; - pcfg->pcfg_misc = port; - pcfg->pcfg_count = conn_count; - pcfg->pcfg_wait = share_count; - break; - } - case NAL_CMD_ADD_PEER: { - rc = ksocknal_add_peer (pcfg->pcfg_nid, - pcfg->pcfg_id, /* IP */ - pcfg->pcfg_misc); /* port */ - break; - } - case NAL_CMD_DEL_PEER: { - rc = ksocknal_del_peer (pcfg->pcfg_nid, - pcfg->pcfg_id, /* IP */ - pcfg->pcfg_flags); /* single_share? */ - break; - } - case NAL_CMD_GET_CONN: { - ksock_conn_t *conn = ksocknal_get_conn_by_idx (pcfg->pcfg_count); - - if (conn == NULL) - rc = -ENOENT; - else { - int txmem; - int rxmem; - int nagle; - - ksocknal_get_conn_tunables(conn, &txmem, &rxmem, &nagle); - - rc = 0; - pcfg->pcfg_nid = conn->ksnc_peer->ksnp_nid; - pcfg->pcfg_id = conn->ksnc_ipaddr; - pcfg->pcfg_misc = conn->ksnc_port; - pcfg->pcfg_fd = conn->ksnc_myipaddr; - pcfg->pcfg_flags = conn->ksnc_type; - pcfg->pcfg_gw_nal = conn->ksnc_scheduler - - ksocknal_data.ksnd_schedulers; - pcfg->pcfg_count = txmem; - pcfg->pcfg_size = rxmem; - pcfg->pcfg_wait = nagle; - ksocknal_put_conn (conn); - } - break; - } - case NAL_CMD_REGISTER_PEER_FD: { - struct socket *sock = sockfd_lookup (pcfg->pcfg_fd, &rc); - int type = pcfg->pcfg_misc; - - if (sock == NULL) - break; - - switch (type) { - case SOCKNAL_CONN_NONE: - case SOCKNAL_CONN_ANY: - case SOCKNAL_CONN_CONTROL: - case SOCKNAL_CONN_BULK_IN: - case SOCKNAL_CONN_BULK_OUT: - rc = ksocknal_create_conn(NULL, sock, type); - break; - default: - rc = -EINVAL; - break; - } - fput (sock->file); - break; - } - case NAL_CMD_CLOSE_CONNECTION: { - rc = ksocknal_close_matching_conns (pcfg->pcfg_nid, - pcfg->pcfg_id); - break; - } - case NAL_CMD_REGISTER_MYNID: { - rc = ksocknal_set_mynid (pcfg->pcfg_nid); - break; - } - case NAL_CMD_PUSH_CONNECTION: { - rc = ksocknal_push (pcfg->pcfg_nid); - break; - } - default: - rc = -EINVAL; - break; - } - - return rc; -} - -void -ksocknal_free_fmbs (ksock_fmb_pool_t *p) -{ - int npages = p->fmp_buff_pages; - ksock_fmb_t *fmb; - int i; - - LASSERT (list_empty(&p->fmp_blocked_conns)); - LASSERT (p->fmp_nactive_fmbs == 0); - - while (!list_empty(&p->fmp_idle_fmbs)) { - - fmb = list_entry(p->fmp_idle_fmbs.next, - ksock_fmb_t, fmb_list); - - for (i = 0; i < npages; i++) - if (fmb->fmb_kiov[i].kiov_page != NULL) - __free_page(fmb->fmb_kiov[i].kiov_page); - - list_del(&fmb->fmb_list); - PORTAL_FREE(fmb, offsetof(ksock_fmb_t, fmb_kiov[npages])); - } -} - -void -ksocknal_free_buffers (void) -{ - ksocknal_free_fmbs(&ksocknal_data.ksnd_small_fmp); - ksocknal_free_fmbs(&ksocknal_data.ksnd_large_fmp); - - LASSERT (atomic_read(&ksocknal_data.ksnd_nactive_ltxs) == 0); - - if (ksocknal_data.ksnd_schedulers != NULL) - PORTAL_FREE (ksocknal_data.ksnd_schedulers, - sizeof (ksock_sched_t) * ksocknal_data.ksnd_nschedulers); - - PORTAL_FREE (ksocknal_data.ksnd_peers, - sizeof (struct list_head) * - ksocknal_data.ksnd_peer_hash_size); -} - -void -ksocknal_api_shutdown (nal_t *nal) -{ - ksock_sched_t *sched; - int i; - - if (nal->nal_refct != 0) { - /* This module got the first ref */ - PORTAL_MODULE_UNUSE; - return; - } - - CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n", - atomic_read (&portal_kmemory)); - - LASSERT(nal == &ksocknal_api); - - switch (ksocknal_data.ksnd_init) { - default: - LASSERT (0); - - case SOCKNAL_INIT_ALL: - libcfs_nal_cmd_unregister(SOCKNAL); - - ksocknal_data.ksnd_init = SOCKNAL_INIT_LIB; - /* fall through */ - - case SOCKNAL_INIT_LIB: - /* No more calls to ksocknal_cmd() to create new - * autoroutes/connections since we're being unloaded. */ - - /* Delete all peers */ - ksocknal_del_peer(PTL_NID_ANY, 0, 0); - - /* Wait for all peer state to clean up */ - i = 2; - while (atomic_read (&ksocknal_data.ksnd_npeers) != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "waiting for %d peers to disconnect\n", - atomic_read (&ksocknal_data.ksnd_npeers)); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - } - - /* Tell lib we've stopped calling into her. */ - lib_fini(&ksocknal_lib); - - ksocknal_data.ksnd_init = SOCKNAL_INIT_DATA; - /* fall through */ - - case SOCKNAL_INIT_DATA: - LASSERT (atomic_read (&ksocknal_data.ksnd_npeers) == 0); - LASSERT (ksocknal_data.ksnd_peers != NULL); - for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { - LASSERT (list_empty (&ksocknal_data.ksnd_peers[i])); - } - LASSERT (list_empty (&ksocknal_data.ksnd_enomem_conns)); - LASSERT (list_empty (&ksocknal_data.ksnd_zombie_conns)); - LASSERT (list_empty (&ksocknal_data.ksnd_autoconnectd_routes)); - LASSERT (list_empty (&ksocknal_data.ksnd_small_fmp.fmp_blocked_conns)); - LASSERT (list_empty (&ksocknal_data.ksnd_large_fmp.fmp_blocked_conns)); - - if (ksocknal_data.ksnd_schedulers != NULL) - for (i = 0; i < ksocknal_data.ksnd_nschedulers; i++) { - ksock_sched_t *kss = - &ksocknal_data.ksnd_schedulers[i]; - - LASSERT (list_empty (&kss->kss_tx_conns)); - LASSERT (list_empty (&kss->kss_rx_conns)); - LASSERT (kss->kss_nconns == 0); - } - - /* stop router calling me */ - kpr_shutdown (&ksocknal_data.ksnd_router); - - /* flag threads to terminate; wake and wait for them to die */ - ksocknal_data.ksnd_shuttingdown = 1; - wake_up_all (&ksocknal_data.ksnd_autoconnectd_waitq); - wake_up_all (&ksocknal_data.ksnd_reaper_waitq); - - for (i = 0; i < ksocknal_data.ksnd_nschedulers; i++) { - sched = &ksocknal_data.ksnd_schedulers[i]; - wake_up_all(&sched->kss_waitq); - } - - i = 4; - read_lock(&ksocknal_data.ksnd_global_lock); - while (ksocknal_data.ksnd_nthreads != 0) { - i++; - CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ - "waiting for %d threads to terminate\n", - ksocknal_data.ksnd_nthreads); - read_unlock(&ksocknal_data.ksnd_global_lock); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - read_lock(&ksocknal_data.ksnd_global_lock); - } - read_unlock(&ksocknal_data.ksnd_global_lock); - - kpr_deregister (&ksocknal_data.ksnd_router); - - ksocknal_free_buffers(); - - ksocknal_data.ksnd_init = SOCKNAL_INIT_NOTHING; - /* fall through */ - - case SOCKNAL_INIT_NOTHING: - break; - } - - CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n", - atomic_read (&portal_kmemory)); - - printk(KERN_INFO "Lustre: Routing socket NAL unloaded (final mem %d)\n", - atomic_read(&portal_kmemory)); -} - - -void -ksocknal_init_incarnation (void) -{ - struct timeval tv; - - /* The incarnation number is the time this module loaded and it - * identifies this particular instance of the socknal. Hopefully - * we won't be able to reboot more frequently than 1MHz for the - * forseeable future :) */ - - do_gettimeofday(&tv); - - ksocknal_data.ksnd_incarnation = - (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; -} - -int -ksocknal_api_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - ptl_process_id_t process_id; - int pkmem = atomic_read(&portal_kmemory); - int rc; - int i; - int j; - - LASSERT (nal == &ksocknal_api); - - if (nal->nal_refct != 0) { - if (actual_limits != NULL) - *actual_limits = ksocknal_lib.libnal_ni.ni_actual_limits; - /* This module got the first ref */ - PORTAL_MODULE_USE; - return (PTL_OK); - } - - LASSERT (ksocknal_data.ksnd_init == SOCKNAL_INIT_NOTHING); - - memset (&ksocknal_data, 0, sizeof (ksocknal_data)); /* zero pointers */ - - ksocknal_init_incarnation(); - - ksocknal_data.ksnd_peer_hash_size = SOCKNAL_PEER_HASH_SIZE; - PORTAL_ALLOC (ksocknal_data.ksnd_peers, - sizeof (struct list_head) * ksocknal_data.ksnd_peer_hash_size); - if (ksocknal_data.ksnd_peers == NULL) - return (-ENOMEM); - - for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) - INIT_LIST_HEAD(&ksocknal_data.ksnd_peers[i]); - - rwlock_init(&ksocknal_data.ksnd_global_lock); - - spin_lock_init(&ksocknal_data.ksnd_small_fmp.fmp_lock); - INIT_LIST_HEAD(&ksocknal_data.ksnd_small_fmp.fmp_idle_fmbs); - INIT_LIST_HEAD(&ksocknal_data.ksnd_small_fmp.fmp_blocked_conns); - ksocknal_data.ksnd_small_fmp.fmp_buff_pages = SOCKNAL_SMALL_FWD_PAGES; - - spin_lock_init(&ksocknal_data.ksnd_large_fmp.fmp_lock); - INIT_LIST_HEAD(&ksocknal_data.ksnd_large_fmp.fmp_idle_fmbs); - INIT_LIST_HEAD(&ksocknal_data.ksnd_large_fmp.fmp_blocked_conns); - ksocknal_data.ksnd_large_fmp.fmp_buff_pages = SOCKNAL_LARGE_FWD_PAGES; - - spin_lock_init (&ksocknal_data.ksnd_reaper_lock); - INIT_LIST_HEAD (&ksocknal_data.ksnd_enomem_conns); - INIT_LIST_HEAD (&ksocknal_data.ksnd_zombie_conns); - INIT_LIST_HEAD (&ksocknal_data.ksnd_deathrow_conns); - init_waitqueue_head(&ksocknal_data.ksnd_reaper_waitq); - - spin_lock_init (&ksocknal_data.ksnd_autoconnectd_lock); - INIT_LIST_HEAD (&ksocknal_data.ksnd_autoconnectd_routes); - init_waitqueue_head(&ksocknal_data.ksnd_autoconnectd_waitq); - - /* NB memset above zeros whole of ksocknal_data, including - * ksocknal_data.ksnd_irqinfo[all].ksni_valid */ - - /* flag lists/ptrs/locks initialised */ - ksocknal_data.ksnd_init = SOCKNAL_INIT_DATA; - - ksocknal_data.ksnd_nschedulers = ksocknal_nsched(); - PORTAL_ALLOC(ksocknal_data.ksnd_schedulers, - sizeof(ksock_sched_t) * ksocknal_data.ksnd_nschedulers); - if (ksocknal_data.ksnd_schedulers == NULL) { - ksocknal_api_shutdown (nal); - return (-ENOMEM); - } - - for (i = 0; i < ksocknal_data.ksnd_nschedulers; i++) { - ksock_sched_t *kss = &ksocknal_data.ksnd_schedulers[i]; - - spin_lock_init (&kss->kss_lock); - INIT_LIST_HEAD (&kss->kss_rx_conns); - INIT_LIST_HEAD (&kss->kss_tx_conns); -#if SOCKNAL_ZC - INIT_LIST_HEAD (&kss->kss_zctxdone_list); -#endif - init_waitqueue_head (&kss->kss_waitq); - } - - /* NB we have to wait to be told our true NID... */ - process_id.pid = requested_pid; - process_id.nid = 0; - - rc = lib_init(&ksocknal_lib, nal, process_id, - requested_limits, actual_limits); - if (rc != PTL_OK) { - CERROR("lib_init failed: error %d\n", rc); - ksocknal_api_shutdown (nal); - return (rc); - } - - ksocknal_data.ksnd_init = SOCKNAL_INIT_LIB; // flag lib_init() called - - for (i = 0; i < ksocknal_data.ksnd_nschedulers; i++) { - rc = ksocknal_thread_start (ksocknal_scheduler, - &ksocknal_data.ksnd_schedulers[i]); - if (rc != 0) { - CERROR("Can't spawn socknal scheduler[%d]: %d\n", - i, rc); - ksocknal_api_shutdown (nal); - return (rc); - } - } - - for (i = 0; i < SOCKNAL_N_AUTOCONNECTD; i++) { - rc = ksocknal_thread_start (ksocknal_autoconnectd, (void *)((long)i)); - if (rc != 0) { - CERROR("Can't spawn socknal autoconnectd: %d\n", rc); - ksocknal_api_shutdown (nal); - return (rc); - } - } - - rc = ksocknal_thread_start (ksocknal_reaper, NULL); - if (rc != 0) { - CERROR ("Can't spawn socknal reaper: %d\n", rc); - ksocknal_api_shutdown (nal); - return (rc); - } - - rc = kpr_register(&ksocknal_data.ksnd_router, - &ksocknal_router_interface); - if (rc != 0) { - CDEBUG(D_NET, "Can't initialise routing interface " - "(rc = %d): not routing\n", rc); - } else { - /* Only allocate forwarding buffers if there's a router */ - - for (i = 0; i < (SOCKNAL_SMALL_FWD_NMSGS + - SOCKNAL_LARGE_FWD_NMSGS); i++) { - ksock_fmb_t *fmb; - ksock_fmb_pool_t *pool; - - - if (i < SOCKNAL_SMALL_FWD_NMSGS) - pool = &ksocknal_data.ksnd_small_fmp; - else - pool = &ksocknal_data.ksnd_large_fmp; - - PORTAL_ALLOC(fmb, offsetof(ksock_fmb_t, - fmb_kiov[pool->fmp_buff_pages])); - if (fmb == NULL) { - ksocknal_api_shutdown(nal); - return (-ENOMEM); - } - - fmb->fmb_pool = pool; - - for (j = 0; j < pool->fmp_buff_pages; j++) { - fmb->fmb_kiov[j].kiov_page = alloc_page(GFP_KERNEL); - - if (fmb->fmb_kiov[j].kiov_page == NULL) { - ksocknal_api_shutdown (nal); - return (-ENOMEM); - } - - LASSERT(page_address(fmb->fmb_kiov[j].kiov_page) != NULL); - } - - list_add(&fmb->fmb_list, &pool->fmp_idle_fmbs); - } - } - - rc = libcfs_nal_cmd_register(SOCKNAL, &ksocknal_cmd, NULL); - if (rc != 0) { - CERROR ("Can't initialise command interface (rc = %d)\n", rc); - ksocknal_api_shutdown (nal); - return (rc); - } - - /* flag everything initialised */ - ksocknal_data.ksnd_init = SOCKNAL_INIT_ALL; - - printk(KERN_INFO "Lustre: Routing socket NAL loaded " - "(Routing %s, initial mem %d, incarnation "LPX64")\n", - kpr_routing (&ksocknal_data.ksnd_router) ? - "enabled" : "disabled", pkmem, ksocknal_data.ksnd_incarnation); - - return (0); -} - -void __exit -ksocknal_module_fini (void) -{ -#ifdef CONFIG_SYSCTL - if (ksocknal_tunables.ksnd_sysctl != NULL) - unregister_sysctl_table (ksocknal_tunables.ksnd_sysctl); -#endif - PtlNIFini(ksocknal_ni); - - ptl_unregister_nal(SOCKNAL); -} - -int __init -ksocknal_module_init (void) -{ - int rc; - - /* packet descriptor must fit in a router descriptor's scratchpad */ - LASSERT(sizeof (ksock_tx_t) <= sizeof (kprfd_scratch_t)); - /* the following must be sizeof(int) for proc_dointvec() */ - LASSERT(sizeof (ksocknal_tunables.ksnd_io_timeout) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_eager_ack) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_typed_conns) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_min_bulk) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_buffer_size) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_nagle) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_keepalive_idle) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_keepalive_count) == sizeof (int)); - LASSERT(sizeof (ksocknal_tunables.ksnd_keepalive_intvl) == sizeof (int)); -#if CPU_AFFINITY - LASSERT(sizeof (ksocknal_tunables.ksnd_irq_affinity) == sizeof (int)); -#endif -#if SOCKNAL_ZC - LASSERT(sizeof (ksocknal_tunables.ksnd_zc_min_frag) == sizeof (int)); -#endif - /* check ksnr_connected/connecting field large enough */ - LASSERT(SOCKNAL_CONN_NTYPES <= 4); - - ksocknal_api.nal_ni_init = ksocknal_api_startup; - ksocknal_api.nal_ni_fini = ksocknal_api_shutdown; - - /* Initialise dynamic tunables to defaults once only */ - ksocknal_tunables.ksnd_io_timeout = SOCKNAL_IO_TIMEOUT; - ksocknal_tunables.ksnd_eager_ack = SOCKNAL_EAGER_ACK; - ksocknal_tunables.ksnd_typed_conns = SOCKNAL_TYPED_CONNS; - ksocknal_tunables.ksnd_min_bulk = SOCKNAL_MIN_BULK; - ksocknal_tunables.ksnd_buffer_size = SOCKNAL_BUFFER_SIZE; - ksocknal_tunables.ksnd_nagle = SOCKNAL_NAGLE; - ksocknal_tunables.ksnd_keepalive_idle = SOCKNAL_KEEPALIVE_IDLE; - ksocknal_tunables.ksnd_keepalive_count = SOCKNAL_KEEPALIVE_COUNT; - ksocknal_tunables.ksnd_keepalive_intvl = SOCKNAL_KEEPALIVE_INTVL; -#if CPU_AFFINITY - ksocknal_tunables.ksnd_irq_affinity = SOCKNAL_IRQ_AFFINITY; -#endif -#if SOCKNAL_ZC - ksocknal_tunables.ksnd_zc_min_frag = SOCKNAL_ZC_MIN_FRAG; -#endif - - rc = ptl_register_nal(SOCKNAL, &ksocknal_api); - if (rc != PTL_OK) { - CERROR("Can't register SOCKNAL: %d\n", rc); - return (-ENOMEM); /* or something... */ - } - - /* Pure gateways want the NAL started up at module load time... */ - rc = PtlNIInit(SOCKNAL, LUSTRE_SRV_PTL_PID, NULL, NULL, &ksocknal_ni); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) { - ptl_unregister_nal(SOCKNAL); - return (-ENODEV); - } - -#ifdef CONFIG_SYSCTL - /* Press on regardless even if registering sysctl doesn't work */ - ksocknal_tunables.ksnd_sysctl = - register_sysctl_table (ksocknal_top_ctl_table, 0); -#endif - return (0); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Kernel TCP Socket NAL v0.01"); -MODULE_LICENSE("GPL"); - -module_init(ksocknal_module_init); -module_exit(ksocknal_module_fini); - diff --git a/lnet/klnds/socklnd/socklnd.h b/lnet/klnds/socklnd/socklnd.h deleted file mode 100644 index 9cfe858..0000000 --- a/lnet/klnds/socklnd/socklnd.h +++ /dev/null @@ -1,526 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * Author: Zach Brown - * Author: Peter J. Braam - * Author: Phil Schwan - * Author: Eric Barton - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#define DEBUG_PORTAL_ALLOC -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#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 - -#define DEBUG_SUBSYSTEM S_NAL - -#include -#include -#include -#include -#include -#include -#include - -#define SOCKNAL_N_AUTOCONNECTD 4 /* # socknal autoconnect daemons */ - -#define SOCKNAL_MIN_RECONNECT_INTERVAL HZ /* first failed connection retry... */ -#define SOCKNAL_MAX_RECONNECT_INTERVAL (60*HZ) /* ...exponentially increasing to this */ - -/* default vals for runtime tunables */ -#define SOCKNAL_IO_TIMEOUT 50 /* default comms timeout (seconds) */ -#define SOCKNAL_EAGER_ACK 0 /* default eager ack (boolean) */ -#define SOCKNAL_TYPED_CONNS 1 /* unidirectional large, bidirectional small? */ -#define SOCKNAL_ZC_MIN_FRAG (2<<10) /* default smallest zerocopy fragment */ -#define SOCKNAL_MIN_BULK (1<<10) /* smallest "large" message */ -#define SOCKNAL_BUFFER_SIZE (8<<20) /* default socket buffer size */ -#define SOCKNAL_NAGLE 0 /* enable/disable NAGLE? */ -#define SOCKNAL_IRQ_AFFINITY 1 /* enable/disable IRQ affinity? */ -#define SOCKNAL_KEEPALIVE_IDLE 0 /* # seconds idle before 1st probe */ -#define SOCKNAL_KEEPALIVE_COUNT 10 /* # unanswered probes to determine peer death */ -#define SOCKNAL_KEEPALIVE_INTVL 1 /* seconds between probes */ - -#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */ - -#define SOCKNAL_SMALL_FWD_NMSGS 128 /* # small messages I can be forwarding at any time */ -#define SOCKNAL_LARGE_FWD_NMSGS 64 /* # large messages I can be forwarding at any time */ - -#define SOCKNAL_SMALL_FWD_PAGES 1 /* # pages in a small message fwd buffer */ - -#define SOCKNAL_LARGE_FWD_PAGES (PAGE_ALIGN(PTL_MTU) >> PAGE_SHIFT) - /* # pages in a large message fwd buffer */ - -#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ -#define SOCKNAL_ENOMEM_RETRY 1 /* jiffies between retries */ - -#define SOCKNAL_MAX_INTERFACES 16 /* Largest number of interfaces we bind */ - -#define SOCKNAL_ROUND_ROBIN 0 /* round robin / load balance */ - -#define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sk_sndbuf*8)/10) - -#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */ -#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */ -#define SOCKNAL_RISK_KMAP_DEADLOCK 0 /* risk kmap deadlock on multi-frag I/O - * (backs off to single-frag if disabled) */ - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72)) -# define sk_allocation allocation -# define sk_data_ready data_ready -# define sk_write_space write_space -# define sk_user_data user_data -# define sk_prot prot -# define sk_sndbuf sndbuf -# define sk_socket socket -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) -# define sk_wmem_queued wmem_queued -# define sk_err err -#endif - -typedef struct /* pool of forwarding buffers */ -{ - spinlock_t fmp_lock; /* serialise */ - struct list_head fmp_idle_fmbs; /* free buffers */ - struct list_head fmp_blocked_conns; /* connections waiting for a buffer */ - int fmp_nactive_fmbs; /* # buffers in use */ - int fmp_buff_pages; /* # pages per buffer */ -} ksock_fmb_pool_t; - - -typedef struct /* per scheduler state */ -{ - spinlock_t kss_lock; /* serialise */ - struct list_head kss_rx_conns; /* conn waiting to be read */ - struct list_head kss_tx_conns; /* conn waiting to be written */ -#if SOCKNAL_ZC - struct list_head kss_zctxdone_list; /* completed ZC transmits */ -#endif - wait_queue_head_t kss_waitq; /* where scheduler sleeps */ - int kss_nconns; /* # connections assigned to this scheduler */ -} ksock_sched_t; - -typedef struct -{ - int ksni_valid:1; /* been set yet? */ - int ksni_bound:1; /* bound to a cpu yet? */ - int ksni_sched:6; /* which scheduler (assumes < 64) */ -} ksock_irqinfo_t; - -typedef struct -{ - __u32 ksni_ipaddr; /* interface's IP address */ - __u32 ksni_netmask; /* interface's network mask */ - int ksni_nroutes; /* # routes using (active) */ - int ksni_npeers; /* # peers using (passive) */ -} ksock_interface_t; - -typedef struct -{ - int ksnd_io_timeout; /* "stuck" socket timeout (seconds) */ - int ksnd_eager_ack; /* make TCP ack eagerly? */ - int ksnd_typed_conns; /* drive sockets by type? */ - int ksnd_min_bulk; /* smallest "large" message */ - int ksnd_buffer_size; /* socket buffer size */ - int ksnd_nagle; /* enable NAGLE? */ - int ksnd_irq_affinity; /* enable IRQ affinity? */ - int ksnd_keepalive_idle; /* # idle secs before 1st probe */ - int ksnd_keepalive_count; /* # probes */ - int ksnd_keepalive_intvl; /* time between probes */ -#if SOCKNAL_ZC - unsigned int ksnd_zc_min_frag; /* minimum zero copy frag size */ -#endif - struct ctl_table_header *ksnd_sysctl; /* sysctl interface */ -} ksock_tunables_t; - -typedef struct -{ - int ksnd_init; /* initialisation state */ - __u64 ksnd_incarnation; /* my epoch */ - - rwlock_t ksnd_global_lock; /* stabilize peer/conn ops */ - struct list_head *ksnd_peers; /* hash table of all my known peers */ - int ksnd_peer_hash_size; /* size of ksnd_peers */ - - int ksnd_nthreads; /* # live threads */ - int ksnd_shuttingdown; /* tell threads to exit */ - int ksnd_nschedulers; /* # schedulers */ - ksock_sched_t *ksnd_schedulers; /* their state */ - - atomic_t ksnd_npeers; /* total # peers extant */ - atomic_t ksnd_nclosing_conns; /* # closed conns extant */ - - kpr_router_t ksnd_router; /* THE router */ - - ksock_fmb_pool_t ksnd_small_fmp; /* small message forwarding buffers */ - ksock_fmb_pool_t ksnd_large_fmp; /* large message forwarding buffers */ - - atomic_t ksnd_nactive_ltxs; /* #active ltxs */ - - struct list_head ksnd_deathrow_conns; /* conns to be closed */ - struct list_head ksnd_zombie_conns; /* conns to be freed */ - struct list_head ksnd_enomem_conns; /* conns to be retried */ - wait_queue_head_t ksnd_reaper_waitq; /* reaper sleeps here */ - unsigned long ksnd_reaper_waketime; /* when reaper will wake */ - spinlock_t ksnd_reaper_lock; /* serialise */ - - int ksnd_enomem_tx; /* test ENOMEM sender */ - int ksnd_stall_tx; /* test sluggish sender */ - int ksnd_stall_rx; /* test sluggish receiver */ - - struct list_head ksnd_autoconnectd_routes; /* routes waiting to be connected */ - wait_queue_head_t ksnd_autoconnectd_waitq; /* autoconnectds sleep here */ - spinlock_t ksnd_autoconnectd_lock; /* serialise */ - - ksock_irqinfo_t ksnd_irqinfo[NR_IRQS];/* irq->scheduler lookup */ - - int ksnd_ninterfaces; - ksock_interface_t ksnd_interfaces[SOCKNAL_MAX_INTERFACES]; /* published interfaces */ -} ksock_nal_data_t; - -#define SOCKNAL_INIT_NOTHING 0 -#define SOCKNAL_INIT_DATA 1 -#define SOCKNAL_INIT_LIB 2 -#define SOCKNAL_INIT_ALL 3 - -/* A packet just assembled for transmission is represented by 1 or more - * struct iovec fragments (the first frag contains the portals header), - * followed by 0 or more ptl_kiov_t fragments. - * - * On the receive side, initially 1 struct iovec fragment is posted for - * receive (the header). Once the header has been received, the payload is - * received into either struct iovec or ptl_kiov_t fragments, depending on - * what the header matched or whether the message needs forwarding. */ - -struct ksock_conn; /* forward ref */ -struct ksock_peer; /* forward ref */ -struct ksock_route; /* forward ref */ - -typedef struct /* transmit packet */ -{ - struct list_head tx_list; /* queue on conn for transmission etc */ - char tx_isfwd; /* forwarding / sourced here */ - int tx_nob; /* # packet bytes */ - int tx_resid; /* residual bytes */ - int tx_niov; /* # packet iovec frags */ - struct iovec *tx_iov; /* packet iovec frags */ - int tx_nkiov; /* # packet page frags */ - ptl_kiov_t *tx_kiov; /* packet page frags */ - struct ksock_conn *tx_conn; /* owning conn */ - ptl_hdr_t *tx_hdr; /* packet header (for debug only) */ -#if SOCKNAL_ZC - zccd_t tx_zccd; /* zero copy callback descriptor */ -#endif -} ksock_tx_t; - -typedef struct /* forwarded packet */ -{ - ksock_tx_t ftx_tx; /* send info */ - struct iovec ftx_iov; /* hdr iovec */ -} ksock_ftx_t; - -#define KSOCK_ZCCD_2_TX(ptr) list_entry (ptr, ksock_tx_t, tx_zccd) -/* network zero copy callback descriptor embedded in ksock_tx_t */ - -typedef struct /* locally transmitted packet */ -{ - ksock_tx_t ltx_tx; /* send info */ - void *ltx_private; /* lib_finalize() callback arg */ - void *ltx_cookie; /* lib_finalize() callback arg */ - ptl_hdr_t ltx_hdr; /* buffer for packet header */ - int ltx_desc_size; /* bytes allocated for this desc */ - struct iovec ltx_iov[1]; /* iov for hdr + payload */ - ptl_kiov_t ltx_kiov[0]; /* kiov for payload */ -} ksock_ltx_t; - -#define KSOCK_TX_2_KPR_FWD_DESC(ptr) list_entry ((kprfd_scratch_t *)ptr, kpr_fwd_desc_t, kprfd_scratch) -/* forwarded packets (router->socknal) embedded in kpr_fwd_desc_t::kprfd_scratch */ - -#define KSOCK_TX_2_KSOCK_LTX(ptr) list_entry (ptr, ksock_ltx_t, ltx_tx) -/* local packets (lib->socknal) embedded in ksock_ltx_t::ltx_tx */ - -/* NB list_entry() is used here as convenient macro for calculating a - * pointer to a struct from the address of a member. */ - -typedef struct /* Kernel portals Socket Forwarding message buffer */ -{ /* (socknal->router) */ - struct list_head fmb_list; /* queue idle */ - kpr_fwd_desc_t fmb_fwd; /* router's descriptor */ - ksock_fmb_pool_t *fmb_pool; /* owning pool */ - struct ksock_peer *fmb_peer; /* peer received from */ - ptl_hdr_t fmb_hdr; /* message header */ - ptl_kiov_t fmb_kiov[0]; /* payload frags */ -} ksock_fmb_t; - -/* space for the rx frag descriptors; we either read a single contiguous - * header, or up to PTL_MD_MAX_IOV frags of payload of either type. */ -typedef union { - struct iovec iov[PTL_MD_MAX_IOV]; - ptl_kiov_t kiov[PTL_MD_MAX_IOV]; -} ksock_rxiovspace_t; - -#define SOCKNAL_RX_HEADER 1 /* reading header */ -#define SOCKNAL_RX_BODY 2 /* reading body (to deliver here) */ -#define SOCKNAL_RX_BODY_FWD 3 /* reading body (to forward) */ -#define SOCKNAL_RX_SLOP 4 /* skipping body */ -#define SOCKNAL_RX_GET_FMB 5 /* scheduled for forwarding */ -#define SOCKNAL_RX_FMB_SLEEP 6 /* blocked waiting for a fwd desc */ - -typedef struct ksock_conn -{ - struct ksock_peer *ksnc_peer; /* owning peer */ - struct ksock_route *ksnc_route; /* owning route */ - struct list_head ksnc_list; /* stash on peer's conn list */ - struct socket *ksnc_sock; /* actual socket */ - void *ksnc_saved_data_ready; /* socket's original data_ready() callback */ - void *ksnc_saved_write_space; /* socket's original write_space() callback */ - atomic_t ksnc_refcount; /* # users */ - ksock_sched_t *ksnc_scheduler; /* who schedules this connection */ - __u32 ksnc_myipaddr; /* my IP */ - __u32 ksnc_ipaddr; /* peer's IP */ - int ksnc_port; /* peer's port */ - int ksnc_closing; /* being shut down */ - int ksnc_type; /* type of connection */ - __u64 ksnc_incarnation; /* peer's incarnation */ - - /* reader */ - struct list_head ksnc_rx_list; /* where I enq waiting input or a forwarding descriptor */ - unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times out */ - int ksnc_rx_started; /* started receiving a message */ - int ksnc_rx_ready; /* data ready to read */ - int ksnc_rx_scheduled; /* being progressed */ - int ksnc_rx_state; /* what is being read */ - int ksnc_rx_nob_left; /* # bytes to next hdr/body */ - int ksnc_rx_nob_wanted; /* bytes actually wanted */ - int ksnc_rx_niov; /* # iovec frags */ - struct iovec *ksnc_rx_iov; /* the iovec frags */ - int ksnc_rx_nkiov; /* # page frags */ - ptl_kiov_t *ksnc_rx_kiov; /* the page frags */ - ksock_rxiovspace_t ksnc_rx_iov_space; /* space for frag descriptors */ - void *ksnc_cookie; /* rx lib_finalize passthru arg */ - ptl_hdr_t ksnc_hdr; /* where I read headers into */ - - /* WRITER */ - struct list_head ksnc_tx_list; /* where I enq waiting for output space */ - struct list_head ksnc_tx_queue; /* packets waiting to be sent */ - unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out */ - int ksnc_tx_bufnob; /* send buffer marker */ - atomic_t ksnc_tx_nob; /* # bytes queued */ - int ksnc_tx_ready; /* write space */ - int ksnc_tx_scheduled; /* being progressed */ - -#if !SOCKNAL_SINGLE_FRAG_RX - struct iovec ksnc_rx_scratch_iov[PTL_MD_MAX_IOV]; -#endif -#if !SOCKNAL_SINGLE_FRAG_TX - struct iovec ksnc_tx_scratch_iov[PTL_MD_MAX_IOV]; -#endif -} ksock_conn_t; - -#define KSNR_TYPED_ROUTES ((1 << SOCKNAL_CONN_CONTROL) | \ - (1 << SOCKNAL_CONN_BULK_IN) | \ - (1 << SOCKNAL_CONN_BULK_OUT)) - -typedef struct ksock_route -{ - struct list_head ksnr_list; /* chain on peer route list */ - struct list_head ksnr_connect_list; /* chain on autoconnect list */ - struct ksock_peer *ksnr_peer; /* owning peer */ - atomic_t ksnr_refcount; /* # users */ - unsigned long ksnr_timeout; /* when (in jiffies) reconnection can happen next */ - unsigned int ksnr_retry_interval; /* how long between retries */ - __u32 ksnr_myipaddr; /* my IP */ - __u32 ksnr_ipaddr; /* IP address to connect to */ - int ksnr_port; /* port to connect to */ - unsigned int ksnr_connecting:4; /* autoconnects in progress by type */ - unsigned int ksnr_connected:4; /* connections established by type */ - unsigned int ksnr_deleted:1; /* been removed from peer? */ - unsigned int ksnr_share_count; /* created explicitly? */ - int ksnr_conn_count; /* # conns established by this route */ -} ksock_route_t; - -typedef struct ksock_peer -{ - struct list_head ksnp_list; /* stash on global peer list */ - ptl_nid_t ksnp_nid; /* who's on the other end(s) */ - atomic_t ksnp_refcount; /* # users */ - int ksnp_sharecount; /* lconf usage counter */ - int ksnp_closing; /* being closed */ - int ksnp_error; /* errno on closing last conn */ - struct list_head ksnp_conns; /* all active connections */ - struct list_head ksnp_routes; /* routes */ - struct list_head ksnp_tx_queue; /* waiting packets */ - unsigned long ksnp_last_alive; /* when (in jiffies) I was last alive */ - int ksnp_n_passive_ips; /* # of... */ - __u32 ksnp_passive_ips[SOCKNAL_MAX_INTERFACES]; /* preferred local interfaces */ -} ksock_peer_t; - - -extern lib_nal_t ksocknal_lib; -extern ksock_nal_data_t ksocknal_data; -extern ksock_tunables_t ksocknal_tunables; - -static inline struct list_head * -ksocknal_nid2peerlist (ptl_nid_t nid) -{ - unsigned int hash = ((unsigned int)nid) % ksocknal_data.ksnd_peer_hash_size; - - return (&ksocknal_data.ksnd_peers [hash]); -} - -static inline int -ksocknal_getconnsock (ksock_conn_t *conn) -{ - int rc = -ESHUTDOWN; - - read_lock (&ksocknal_data.ksnd_global_lock); - if (!conn->ksnc_closing) { - rc = 0; - get_file (conn->ksnc_sock->file); - } - read_unlock (&ksocknal_data.ksnd_global_lock); - - return (rc); -} - -static inline void -ksocknal_putconnsock (ksock_conn_t *conn) -{ - fput (conn->ksnc_sock->file); -} - -#ifndef CONFIG_SMP -static inline -int ksocknal_nsched(void) -{ - return 1; -} -#else -#include -# if !(defined(CONFIG_X86) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,21))) || defined(CONFIG_X86_64) || (LUSTRE_KERNEL_VERSION < 39) || ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && !defined(CONFIG_X86_HT)) -static inline int -ksocknal_nsched(void) -{ - return num_online_cpus(); -} - -static inline int -ksocknal_sched2cpu(int i) -{ - return i; -} - -static inline int -ksocknal_irqsched2cpu(int i) -{ - return i; -} -# else -static inline int -ksocknal_nsched(void) -{ - if (smp_num_siblings == 1) - return (num_online_cpus()); - - /* We need to know if this assumption is crap */ - LASSERT (smp_num_siblings == 2); - return (num_online_cpus()/2); -} - -static inline int -ksocknal_sched2cpu(int i) -{ - if (smp_num_siblings == 1) - return i; - - return (i * 2); -} - -static inline int -ksocknal_irqsched2cpu(int i) -{ - return (ksocknal_sched2cpu(i) + 1); -} -# endif -#endif - -extern void ksocknal_put_route (ksock_route_t *route); -extern void ksocknal_put_peer (ksock_peer_t *peer); -extern ksock_peer_t *ksocknal_find_peer_locked (ptl_nid_t nid); -extern ksock_peer_t *ksocknal_get_peer (ptl_nid_t nid); -extern int ksocknal_del_route (ptl_nid_t nid, __u32 ipaddr, - int single, int keep_conn); -extern int ksocknal_create_conn (ksock_route_t *route, - struct socket *sock, int type); -extern void ksocknal_close_conn_locked (ksock_conn_t *conn, int why); -extern void ksocknal_terminate_conn (ksock_conn_t *conn); -extern void ksocknal_destroy_conn (ksock_conn_t *conn); -extern void ksocknal_put_conn (ksock_conn_t *conn); -extern int ksocknal_close_stale_conns_locked (ksock_peer_t *peer, __u64 incarnation); -extern int ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why); -extern int ksocknal_close_matching_conns (ptl_nid_t nid, __u32 ipaddr); - -extern void ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn); -extern void ksocknal_tx_done (ksock_tx_t *tx, int asynch); -extern void ksocknal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd); -extern void ksocknal_fmb_callback (void *arg, int error); -extern void ksocknal_notify (void *arg, ptl_nid_t gw_nid, int alive); -extern int ksocknal_thread_start (int (*fn)(void *arg), void *arg); -extern int ksocknal_new_packet (ksock_conn_t *conn, int skip); -extern int ksocknal_scheduler (void *arg); -extern void ksocknal_data_ready(struct sock *sk, int n); -extern void ksocknal_write_space(struct sock *sk); -extern int ksocknal_autoconnectd (void *arg); -extern int ksocknal_reaper (void *arg); -extern int ksocknal_get_conn_tunables (ksock_conn_t *conn, int *txmem, - int *rxmem, int *nagle); -extern int ksocknal_setup_sock (struct socket *sock); -extern int ksocknal_send_hello (ksock_conn_t *conn, __u32 *ipaddrs, int nipaddrs); -extern int ksocknal_recv_hello (ksock_conn_t *conn, - ptl_nid_t *nid, __u64 *incarnation, __u32 *ipaddrs); diff --git a/lnet/klnds/socklnd/socklnd_cb.c b/lnet/klnds/socklnd/socklnd_cb.c deleted file mode 100644 index ed91f94..0000000 --- a/lnet/klnds/socklnd/socklnd_cb.c +++ /dev/null @@ -1,2934 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * Author: Zach Brown - * Author: Peter J. Braam - * Author: Phil Schwan - * Author: Eric Barton - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "socknal.h" -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) -# include -#endif - -/* - * LIB functions follow - * - */ -int -ksocknal_dist(lib_nal_t *nal, ptl_nid_t nid, unsigned long *dist) -{ - /* I would guess that if ksocknal_get_peer (nid) == NULL, - and we're not routing, then 'nid' is very distant :) */ - if (nal->libnal_ni.ni_pid.nid == nid) { - *dist = 0; - } else { - *dist = 1; - } - - return 0; -} - -void -ksocknal_free_ltx (ksock_ltx_t *ltx) -{ - atomic_dec(&ksocknal_data.ksnd_nactive_ltxs); - PORTAL_FREE(ltx, ltx->ltx_desc_size); -} - -#if (SOCKNAL_ZC && SOCKNAL_VADDR_ZC) -struct page * -ksocknal_kvaddr_to_page (unsigned long vaddr) -{ - struct page *page; - - if (vaddr >= VMALLOC_START && - vaddr < VMALLOC_END) - page = vmalloc_to_page ((void *)vaddr); -#if CONFIG_HIGHMEM - else if (vaddr >= PKMAP_BASE && - vaddr < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE)) - page = vmalloc_to_page ((void *)vaddr); - /* in 2.4 ^ just walks the page tables */ -#endif - else - page = virt_to_page (vaddr); - - if (page == NULL || - !VALID_PAGE (page)) - return (NULL); - - return (page); -} -#endif - -int -ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) -{ - struct socket *sock = conn->ksnc_sock; - struct iovec *iov = tx->tx_iov; -#if (SOCKNAL_ZC && SOCKNAL_VADDR_ZC) - unsigned long vaddr = (unsigned long)iov->iov_base - int offset = vaddr & (PAGE_SIZE - 1); - int zcsize = MIN (iov->iov_len, PAGE_SIZE - offset); - struct page *page; -#endif - int nob; - int rc; - - /* NB we can't trust socket ops to either consume our iovs - * or leave them alone. */ - LASSERT (tx->tx_niov > 0); - -#if (SOCKNAL_ZC && SOCKNAL_VADDR_ZC) - if (zcsize >= ksocknal_data.ksnd_zc_min_frag && - (sock->sk->route_caps & NETIF_F_SG) && - (sock->sk->route_caps & (NETIF_F_IP_CSUM | NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)) && - (page = ksocknal_kvaddr_to_page (vaddr)) != NULL) { - int msgflg = MSG_DONTWAIT; - - CDEBUG(D_NET, "vaddr %p, page %p->%p + offset %x for %d\n", - (void *)vaddr, page, page_address(page), offset, zcsize); - - if (!list_empty (&conn->ksnc_tx_queue) || - zcsize < tx->tx_resid) - msgflg |= MSG_MORE; - - rc = tcp_sendpage_zccd(sock, page, offset, zcsize, msgflg, &tx->tx_zccd); - } else -#endif - { -#if SOCKNAL_SINGLE_FRAG_TX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_tx_scratch_iov; - 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 - }; - mm_segment_t oldmm = get_fs(); - int i; - - for (nob = i = 0; i < niov; i++) { - scratchiov[i] = tx->tx_iov[i]; - nob += scratchiov[i].iov_len; - } - - if (!list_empty(&conn->ksnc_tx_queue) || - nob < tx->tx_resid) - msg.msg_flags |= MSG_MORE; - - set_fs (KERNEL_DS); - rc = sock_sendmsg(sock, &msg, nob); - set_fs (oldmm); - } - - if (rc <= 0) /* sent nothing? */ - return (rc); - - nob = rc; - LASSERT (nob <= tx->tx_resid); - tx->tx_resid -= nob; - - /* "consume" iov */ - do { - LASSERT (tx->tx_niov > 0); - - if (nob < iov->iov_len) { - iov->iov_base = (void *)(((unsigned long)(iov->iov_base)) + nob); - iov->iov_len -= nob; - return (rc); - } - - nob -= iov->iov_len; - tx->tx_iov = ++iov; - tx->tx_niov--; - } while (nob != 0); - - return (rc); -} - -int -ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx) -{ - struct socket *sock = conn->ksnc_sock; - ptl_kiov_t *kiov = tx->tx_kiov; - int rc; - int nob; - - /* NB we can't trust socket ops to either consume our iovs - * or leave them alone. */ - LASSERT (tx->tx_niov == 0); - LASSERT (tx->tx_nkiov > 0); - -#if SOCKNAL_ZC - if (kiov->kiov_len >= ksocknal_tunables.ksnd_zc_min_frag && - (sock->sk->route_caps & NETIF_F_SG) && - (sock->sk->route_caps & (NETIF_F_IP_CSUM | NETIF_F_NO_CSUM | NETIF_F_HW_CSUM))) { - struct page *page = kiov->kiov_page; - int offset = kiov->kiov_offset; - int fragsize = kiov->kiov_len; - int msgflg = MSG_DONTWAIT; - - CDEBUG(D_NET, "page %p + offset %x for %d\n", - page, offset, kiov->kiov_len); - - if (!list_empty(&conn->ksnc_tx_queue) || - fragsize < tx->tx_resid) - msgflg |= MSG_MORE; - - rc = tcp_sendpage_zccd(sock, page, offset, fragsize, msgflg, - &tx->tx_zccd); - } else -#endif - { -#if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK - struct iovec scratch; - struct iovec *scratchiov = &scratch; - int niov = 1; -#else -#warning "XXX risk of kmap deadlock on multiple frags..." - struct iovec *scratchiov = conn->ksnc_tx_scratch_iov; - 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 - }; - mm_segment_t oldmm = get_fs(); - 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; - } - - if (!list_empty(&conn->ksnc_tx_queue) || - nob < tx->tx_resid) - msg.msg_flags |= MSG_DONTWAIT; - - set_fs (KERNEL_DS); - rc = sock_sendmsg(sock, &msg, nob); - set_fs (oldmm); - - for (i = 0; i < niov; i++) - kunmap(kiov[i].kiov_page); - } - - if (rc <= 0) /* sent nothing? */ - return (rc); - - nob = rc; - LASSERT (nob <= tx->tx_resid); - tx->tx_resid -= nob; - - do { - LASSERT(tx->tx_nkiov > 0); - - if (nob < kiov->kiov_len) { - kiov->kiov_offset += nob; - kiov->kiov_len -= nob; - return rc; - } - - nob -= kiov->kiov_len; - tx->tx_kiov = ++kiov; - tx->tx_nkiov--; - } while (nob != 0); - - return (rc); -} - -int -ksocknal_transmit (ksock_conn_t *conn, ksock_tx_t *tx) -{ - int rc; - int bufnob; - - if (ksocknal_data.ksnd_stall_tx != 0) { - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (ksocknal_data.ksnd_stall_tx * HZ); - } - - LASSERT (tx->tx_resid != 0); - - rc = ksocknal_getconnsock (conn); - if (rc != 0) { - LASSERT (conn->ksnc_closing); - return (-ESHUTDOWN); - } - - do { - if (ksocknal_data.ksnd_enomem_tx > 0) { - /* testing... */ - ksocknal_data.ksnd_enomem_tx--; - rc = -EAGAIN; - } else if (tx->tx_niov != 0) { - rc = ksocknal_send_iov (conn, tx); - } else { - rc = ksocknal_send_kiov (conn, tx); - } - - bufnob = conn->ksnc_sock->sk->sk_wmem_queued; - if (rc > 0) /* sent something? */ - conn->ksnc_tx_bufnob += rc; /* account it */ - - if (bufnob < conn->ksnc_tx_bufnob) { - /* allocated send buffer bytes < computed; infer - * something got ACKed */ - conn->ksnc_tx_deadline = jiffies + - ksocknal_tunables.ksnd_io_timeout * HZ; - conn->ksnc_peer->ksnp_last_alive = jiffies; - conn->ksnc_tx_bufnob = bufnob; - mb(); - } - - if (rc <= 0) { /* Didn't write anything? */ - unsigned long flags; - ksock_sched_t *sched; - - if (rc == 0) /* some stacks return 0 instead of -EAGAIN */ - rc = -EAGAIN; - - if (rc != -EAGAIN) - break; - - /* Check if EAGAIN is due to memory pressure */ - - sched = conn->ksnc_scheduler; - spin_lock_irqsave(&sched->kss_lock, flags); - - if (!test_bit(SOCK_NOSPACE, &conn->ksnc_sock->flags) && - !conn->ksnc_tx_ready) { - /* SOCK_NOSPACE is set when the socket fills - * and cleared in the write_space callback - * (which also sets ksnc_tx_ready). If - * SOCK_NOSPACE and ksnc_tx_ready are BOTH - * zero, I didn't fill the socket and - * write_space won't reschedule me, so I - * return -ENOMEM to get my caller to retry - * after a timeout */ - rc = -ENOMEM; - } - - spin_unlock_irqrestore(&sched->kss_lock, flags); - break; - } - - /* socket's wmem_queued now includes 'rc' bytes */ - atomic_sub (rc, &conn->ksnc_tx_nob); - rc = 0; - - } while (tx->tx_resid != 0); - - ksocknal_putconnsock (conn); - return (rc); -} - -void -ksocknal_eager_ack (ksock_conn_t *conn) -{ - int opt = 1; - mm_segment_t oldmm = get_fs(); - struct socket *sock = conn->ksnc_sock; - - /* Remind the socket to ACK eagerly. If I don't, the socket might - * think I'm about to send something it could piggy-back the ACK - * on, introducing delay in completing zero-copy sends in my - * peer. */ - - set_fs(KERNEL_DS); - sock->ops->setsockopt (sock, SOL_TCP, TCP_QUICKACK, - (char *)&opt, sizeof (opt)); - set_fs(oldmm); -} - -int -ksocknal_recv_iov (ksock_conn_t *conn) -{ -#if SOCKNAL_SINGLE_FRAG_RX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_rx_scratch_iov; - 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 - }; - mm_segment_t oldmm = get_fs(); - int nob; - int i; - int rc; - - /* NB we can't trust socket ops to either consume our iovs - * or leave them alone. */ - 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); - - set_fs (KERNEL_DS); - rc = sock_recvmsg (conn->ksnc_sock, &msg, nob, MSG_DONTWAIT); - /* NB this is just a boolean..........................^ */ - set_fs (oldmm); - - if (rc <= 0) - return (rc); - - /* received something... */ - nob = rc; - - conn->ksnc_peer->ksnp_last_alive = jiffies; - conn->ksnc_rx_deadline = jiffies + - ksocknal_tunables.ksnd_io_timeout * HZ; - mb(); /* order with setting rx_started */ - conn->ksnc_rx_started = 1; - - conn->ksnc_rx_nob_wanted -= nob; - conn->ksnc_rx_nob_left -= nob; - - do { - LASSERT (conn->ksnc_rx_niov > 0); - - if (nob < iov->iov_len) { - iov->iov_len -= nob; - iov->iov_base = (void *)(((unsigned long)iov->iov_base) + nob); - return (-EAGAIN); - } - - nob -= iov->iov_len; - conn->ksnc_rx_iov = ++iov; - conn->ksnc_rx_niov--; - } while (nob != 0); - - return (rc); -} - -int -ksocknal_recv_kiov (ksock_conn_t *conn) -{ -#if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK - struct iovec scratch; - struct iovec *scratchiov = &scratch; - int niov = 1; -#else -#warning "XXX risk of kmap deadlock on multiple frags..." - struct iovec *scratchiov = conn->ksnc_rx_scratch_iov; - int niov = conn->ksnc_rx_nkiov; -#endif - ptl_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 - }; - mm_segment_t oldmm = get_fs(); - int nob; - int i; - int rc; - - LASSERT (conn->ksnc_rx_nkiov > 0); - - /* 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); - - set_fs (KERNEL_DS); - rc = sock_recvmsg (conn->ksnc_sock, &msg, nob, MSG_DONTWAIT); - /* NB this is just a boolean.......................^ */ - set_fs (oldmm); - - for (i = 0; i < niov; i++) - kunmap(kiov[i].kiov_page); - - if (rc <= 0) - return (rc); - - /* received something... */ - nob = rc; - - conn->ksnc_peer->ksnp_last_alive = jiffies; - conn->ksnc_rx_deadline = jiffies + - ksocknal_tunables.ksnd_io_timeout * HZ; - mb(); /* order with setting rx_started */ - conn->ksnc_rx_started = 1; - - conn->ksnc_rx_nob_wanted -= nob; - conn->ksnc_rx_nob_left -= nob; - - do { - LASSERT (conn->ksnc_rx_nkiov > 0); - - if (nob < kiov->kiov_len) { - kiov->kiov_offset += nob; - kiov->kiov_len -= nob; - return -EAGAIN; - } - - nob -= kiov->kiov_len; - conn->ksnc_rx_kiov = ++kiov; - conn->ksnc_rx_nkiov--; - } while (nob != 0); - - return 1; -} - -int -ksocknal_receive (ksock_conn_t *conn) -{ - /* Return 1 on success, 0 on EOF, < 0 on error. - * Caller checks ksnc_rx_nob_wanted to determine - * progress/completion. */ - int rc; - ENTRY; - - if (ksocknal_data.ksnd_stall_rx != 0) { - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (ksocknal_data.ksnd_stall_rx * HZ); - } - - rc = ksocknal_getconnsock (conn); - if (rc != 0) { - LASSERT (conn->ksnc_closing); - return (-ESHUTDOWN); - } - - for (;;) { - if (conn->ksnc_rx_niov != 0) - rc = ksocknal_recv_iov (conn); - else - rc = ksocknal_recv_kiov (conn); - - if (rc <= 0) { - /* error/EOF or partial receive */ - if (rc == -EAGAIN) { - rc = 1; - } else if (rc == 0 && conn->ksnc_rx_started) { - /* EOF in the middle of a message */ - rc = -EPROTO; - } - break; - } - - /* Completed a fragment */ - - if (conn->ksnc_rx_nob_wanted == 0) { - /* Completed a message segment (header or payload) */ - if ((ksocknal_tunables.ksnd_eager_ack & conn->ksnc_type) != 0 && - (conn->ksnc_rx_state == SOCKNAL_RX_BODY || - conn->ksnc_rx_state == SOCKNAL_RX_BODY_FWD)) { - /* Remind the socket to ack eagerly... */ - ksocknal_eager_ack(conn); - } - rc = 1; - break; - } - } - - ksocknal_putconnsock (conn); - RETURN (rc); -} - -#if SOCKNAL_ZC -void -ksocknal_zc_callback (zccd_t *zcd) -{ - ksock_tx_t *tx = KSOCK_ZCCD_2_TX(zcd); - ksock_sched_t *sched = tx->tx_conn->ksnc_scheduler; - unsigned long flags; - ENTRY; - - /* Schedule tx for cleanup (can't do it now due to lock conflicts) */ - - spin_lock_irqsave (&sched->kss_lock, flags); - - list_add_tail (&tx->tx_list, &sched->kss_zctxdone_list); - wake_up (&sched->kss_waitq); - - spin_unlock_irqrestore (&sched->kss_lock, flags); - EXIT; -} -#endif - -void -ksocknal_tx_done (ksock_tx_t *tx, int asynch) -{ - ksock_ltx_t *ltx; - ENTRY; - - if (tx->tx_conn != NULL) { -#if SOCKNAL_ZC - /* zero copy completion isn't always from - * process_transmit() so it needs to keep a ref on - * tx_conn... */ - if (asynch) - ksocknal_put_conn (tx->tx_conn); -#else - LASSERT (!asynch); -#endif - } - - if (tx->tx_isfwd) { /* was a forwarded packet? */ - kpr_fwd_done (&ksocknal_data.ksnd_router, - KSOCK_TX_2_KPR_FWD_DESC (tx), - (tx->tx_resid == 0) ? 0 : -ECONNABORTED); - EXIT; - return; - } - - /* local send */ - ltx = KSOCK_TX_2_KSOCK_LTX (tx); - - lib_finalize (&ksocknal_lib, ltx->ltx_private, ltx->ltx_cookie, - (tx->tx_resid == 0) ? PTL_OK : PTL_FAIL); - - ksocknal_free_ltx (ltx); - EXIT; -} - -void -ksocknal_tx_launched (ksock_tx_t *tx) -{ -#if SOCKNAL_ZC - if (atomic_read (&tx->tx_zccd.zccd_count) != 1) { - ksock_conn_t *conn = tx->tx_conn; - - /* zccd skbufs are still in-flight. First take a ref on - * conn, so it hangs about for ksocknal_tx_done... */ - atomic_inc (&conn->ksnc_refcount); - - /* ...then drop the initial ref on zccd, so the zero copy - * callback can occur */ - zccd_put (&tx->tx_zccd); - return; - } -#endif - /* Any zero-copy-ness (if any) has completed; I can complete the - * transmit now, avoiding an extra schedule */ - ksocknal_tx_done (tx, 0); -} - -int -ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) -{ - unsigned long flags; - int rc; - - rc = ksocknal_transmit (conn, tx); - - CDEBUG (D_NET, "send(%d) %d\n", tx->tx_resid, rc); - - if (tx->tx_resid == 0) { - /* Sent everything OK */ - LASSERT (rc == 0); - - ksocknal_tx_launched (tx); - return (0); - } - - if (rc == -EAGAIN) - return (rc); - - if (rc == -ENOMEM) { - static int counter; - - counter++; /* exponential backoff warnings */ - if ((counter & (-counter)) == counter) - CWARN("%d ENOMEM tx %p\n", counter, conn); - - /* Queue on ksnd_enomem_conns for retry after a timeout */ - spin_lock_irqsave(&ksocknal_data.ksnd_reaper_lock, flags); - - /* enomem list takes over scheduler's ref... */ - LASSERT (conn->ksnc_tx_scheduled); - list_add_tail(&conn->ksnc_tx_list, - &ksocknal_data.ksnd_enomem_conns); - if (!time_after_eq(jiffies + SOCKNAL_ENOMEM_RETRY, - ksocknal_data.ksnd_reaper_waketime)) - wake_up (&ksocknal_data.ksnd_reaper_waitq); - - spin_unlock_irqrestore(&ksocknal_data.ksnd_reaper_lock, flags); - return (rc); - } - - /* Actual error */ - LASSERT (rc < 0); - - if (!conn->ksnc_closing) - CERROR("[%p] Error %d on write to "LPX64 - " ip %d.%d.%d.%d:%d\n", conn, rc, - conn->ksnc_peer->ksnp_nid, - HIPQUAD(conn->ksnc_ipaddr), - conn->ksnc_port); - - ksocknal_close_conn_and_siblings (conn, rc); - ksocknal_tx_launched (tx); - - return (rc); -} - -void -ksocknal_launch_autoconnect_locked (ksock_route_t *route) -{ - unsigned long flags; - - /* called holding write lock on ksnd_global_lock */ - - LASSERT (!route->ksnr_deleted); - LASSERT ((route->ksnr_connected & (1 << SOCKNAL_CONN_ANY)) == 0); - LASSERT ((route->ksnr_connected & KSNR_TYPED_ROUTES) != KSNR_TYPED_ROUTES); - LASSERT (route->ksnr_connecting == 0); - - if (ksocknal_tunables.ksnd_typed_conns) - route->ksnr_connecting = - KSNR_TYPED_ROUTES & ~route->ksnr_connected; - else - route->ksnr_connecting = (1 << SOCKNAL_CONN_ANY); - - atomic_inc (&route->ksnr_refcount); /* extra ref for asynchd */ - - spin_lock_irqsave (&ksocknal_data.ksnd_autoconnectd_lock, flags); - - list_add_tail (&route->ksnr_connect_list, - &ksocknal_data.ksnd_autoconnectd_routes); - wake_up (&ksocknal_data.ksnd_autoconnectd_waitq); - - spin_unlock_irqrestore (&ksocknal_data.ksnd_autoconnectd_lock, flags); -} - -ksock_peer_t * -ksocknal_find_target_peer_locked (ksock_tx_t *tx, ptl_nid_t nid) -{ - char ipbuf[PTL_NALFMT_SIZE]; - ptl_nid_t target_nid; - int rc; - ksock_peer_t *peer = ksocknal_find_peer_locked (nid); - - if (peer != NULL) - return (peer); - - if (tx->tx_isfwd) { - CERROR ("Can't send packet to "LPX64 - " %s: routed target is not a peer\n", - nid, portals_nid2str(SOCKNAL, nid, ipbuf)); - return (NULL); - } - - rc = kpr_lookup (&ksocknal_data.ksnd_router, nid, tx->tx_nob, - &target_nid); - if (rc != 0) { - CERROR ("Can't route to "LPX64" %s: router error %d\n", - nid, portals_nid2str(SOCKNAL, nid, ipbuf), rc); - return (NULL); - } - - peer = ksocknal_find_peer_locked (target_nid); - if (peer != NULL) - return (peer); - - CERROR ("Can't send packet to "LPX64" %s: no peer entry\n", - target_nid, portals_nid2str(SOCKNAL, target_nid, ipbuf)); - return (NULL); -} - -ksock_conn_t * -ksocknal_find_conn_locked (ksock_tx_t *tx, ksock_peer_t *peer) -{ - struct list_head *tmp; - ksock_conn_t *typed = NULL; - int tnob = 0; - ksock_conn_t *fallback = NULL; - int fnob = 0; - ksock_conn_t *conn; - - list_for_each (tmp, &peer->ksnp_conns) { - ksock_conn_t *c = list_entry(tmp, ksock_conn_t, ksnc_list); -#if SOCKNAL_ROUND_ROBIN - const int nob = 0; -#else - int nob = atomic_read(&c->ksnc_tx_nob) + - c->ksnc_sock->sk->sk_wmem_queued; -#endif - LASSERT (!c->ksnc_closing); - - if (fallback == NULL || nob < fnob) { - fallback = c; - fnob = nob; - } - - if (!ksocknal_tunables.ksnd_typed_conns) - continue; - - switch (c->ksnc_type) { - default: - LBUG(); - case SOCKNAL_CONN_ANY: - break; - case SOCKNAL_CONN_BULK_IN: - continue; - case SOCKNAL_CONN_BULK_OUT: - if (tx->tx_nob < ksocknal_tunables.ksnd_min_bulk) - continue; - break; - case SOCKNAL_CONN_CONTROL: - if (tx->tx_nob >= ksocknal_tunables.ksnd_min_bulk) - continue; - break; - } - - if (typed == NULL || nob < tnob) { - typed = c; - tnob = nob; - } - } - - /* prefer the typed selection */ - conn = (typed != NULL) ? typed : fallback; - -#if SOCKNAL_ROUND_ROBIN - if (conn != NULL) { - /* round-robin all else being equal */ - list_del (&conn->ksnc_list); - list_add_tail (&conn->ksnc_list, &peer->ksnp_conns); - } -#endif - return conn; -} - -void -ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) -{ - unsigned long flags; - ksock_sched_t *sched = conn->ksnc_scheduler; - - /* called holding global lock (read or irq-write) and caller may - * not have dropped this lock between finding conn and calling me, - * so we don't need the {get,put}connsock dance to deref - * ksnc_sock... */ - LASSERT(!conn->ksnc_closing); - LASSERT(tx->tx_resid == tx->tx_nob); - - CDEBUG (D_NET, "Sending to "LPX64" ip %d.%d.%d.%d:%d\n", - conn->ksnc_peer->ksnp_nid, - HIPQUAD(conn->ksnc_ipaddr), - conn->ksnc_port); - - atomic_add (tx->tx_nob, &conn->ksnc_tx_nob); - tx->tx_conn = conn; - -#if SOCKNAL_ZC - zccd_init (&tx->tx_zccd, ksocknal_zc_callback); - /* NB this sets 1 ref on zccd, so the callback can only occur after - * I've released this ref. */ -#endif - spin_lock_irqsave (&sched->kss_lock, flags); - - if (list_empty(&conn->ksnc_tx_queue) && - conn->ksnc_sock->sk->sk_wmem_queued == 0) { - /* First packet starts the timeout */ - conn->ksnc_tx_deadline = jiffies + - ksocknal_tunables.ksnd_io_timeout * HZ; - conn->ksnc_tx_bufnob = 0; - mb(); /* order with adding to tx_queue */ - } - - list_add_tail (&tx->tx_list, &conn->ksnc_tx_queue); - - if (conn->ksnc_tx_ready && /* able to send */ - !conn->ksnc_tx_scheduled) { /* not scheduled to send */ - /* +1 ref for scheduler */ - atomic_inc (&conn->ksnc_refcount); - list_add_tail (&conn->ksnc_tx_list, - &sched->kss_tx_conns); - conn->ksnc_tx_scheduled = 1; - wake_up (&sched->kss_waitq); - } - - spin_unlock_irqrestore (&sched->kss_lock, flags); -} - -ksock_route_t * -ksocknal_find_connectable_route_locked (ksock_peer_t *peer) -{ - struct list_head *tmp; - ksock_route_t *route; - int bits; - - list_for_each (tmp, &peer->ksnp_routes) { - route = list_entry (tmp, ksock_route_t, ksnr_list); - bits = route->ksnr_connected; - - /* All typed connections established? */ - if ((bits & KSNR_TYPED_ROUTES) == KSNR_TYPED_ROUTES) - continue; - - /* Untyped connection established? */ - if ((bits & (1 << SOCKNAL_CONN_ANY)) != 0) - continue; - - /* connection being established? */ - if (route->ksnr_connecting != 0) - continue; - - /* too soon to retry this guy? */ - if (!time_after_eq (jiffies, route->ksnr_timeout)) - continue; - - return (route); - } - - return (NULL); -} - -ksock_route_t * -ksocknal_find_connecting_route_locked (ksock_peer_t *peer) -{ - struct list_head *tmp; - ksock_route_t *route; - - list_for_each (tmp, &peer->ksnp_routes) { - route = list_entry (tmp, ksock_route_t, ksnr_list); - - if (route->ksnr_connecting != 0) - return (route); - } - - return (NULL); -} - -int -ksocknal_launch_packet (ksock_tx_t *tx, ptl_nid_t nid) -{ - unsigned long flags; - ksock_peer_t *peer; - ksock_conn_t *conn; - ksock_route_t *route; - rwlock_t *g_lock; - - /* Ensure the frags we've been given EXACTLY match the number of - * bytes we want to send. Many TCP/IP stacks disregard any total - * size parameters passed to them and just look at the frags. - * - * We always expect at least 1 mapped fragment containing the - * complete portals header. */ - LASSERT (lib_iov_nob (tx->tx_niov, tx->tx_iov) + - lib_kiov_nob (tx->tx_nkiov, tx->tx_kiov) == tx->tx_nob); - LASSERT (tx->tx_niov >= 1); - LASSERT (tx->tx_iov[0].iov_len >= sizeof (ptl_hdr_t)); - - CDEBUG (D_NET, "packet %p type %d, nob %d niov %d nkiov %d\n", - tx, ((ptl_hdr_t *)tx->tx_iov[0].iov_base)->type, - tx->tx_nob, tx->tx_niov, tx->tx_nkiov); - - tx->tx_conn = NULL; /* only set when assigned a conn */ - tx->tx_resid = tx->tx_nob; - tx->tx_hdr = (ptl_hdr_t *)tx->tx_iov[0].iov_base; - - g_lock = &ksocknal_data.ksnd_global_lock; -#if !SOCKNAL_ROUND_ROBIN - read_lock (g_lock); - - peer = ksocknal_find_target_peer_locked (tx, nid); - if (peer == NULL) { - read_unlock (g_lock); - return (-EHOSTUNREACH); - } - - if (ksocknal_find_connectable_route_locked(peer) == NULL) { - conn = ksocknal_find_conn_locked (tx, peer); - if (conn != NULL) { - /* I've got no autoconnect routes that need to be - * connecting and I do have an actual connection... */ - ksocknal_queue_tx_locked (tx, conn); - read_unlock (g_lock); - return (0); - } - } - - /* I'll need a write lock... */ - read_unlock (g_lock); -#endif - write_lock_irqsave(g_lock, flags); - - peer = ksocknal_find_target_peer_locked (tx, nid); - if (peer == NULL) { - write_unlock_irqrestore(g_lock, flags); - return (-EHOSTUNREACH); - } - - for (;;) { - /* launch any/all autoconnections that need it */ - route = ksocknal_find_connectable_route_locked (peer); - if (route == NULL) - break; - - ksocknal_launch_autoconnect_locked (route); - } - - conn = ksocknal_find_conn_locked (tx, peer); - if (conn != NULL) { - /* Connection exists; queue message on it */ - ksocknal_queue_tx_locked (tx, conn); - write_unlock_irqrestore (g_lock, flags); - return (0); - } - - route = ksocknal_find_connecting_route_locked (peer); - if (route != NULL) { - /* At least 1 connection is being established; queue the - * message... */ - list_add_tail (&tx->tx_list, &peer->ksnp_tx_queue); - write_unlock_irqrestore (g_lock, flags); - return (0); - } - - write_unlock_irqrestore (g_lock, flags); - return (-EHOSTUNREACH); -} - -ptl_err_t -ksocknal_sendmsg(lib_nal_t *nal, - void *private, - lib_msg_t *cookie, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int payload_niov, - struct iovec *payload_iov, - ptl_kiov_t *payload_kiov, - size_t payload_offset, - size_t payload_nob) -{ - ksock_ltx_t *ltx; - int desc_size; - int rc; - - /* NB 'private' is different depending on what we're sending. - * Just ignore it... */ - - CDEBUG(D_NET, "sending "LPSZ" bytes in %d frags to nid:"LPX64 - " pid %d\n", payload_nob, payload_niov, nid , pid); - - LASSERT (payload_nob == 0 || payload_niov > 0); - LASSERT (payload_niov <= PTL_MD_MAX_IOV); - - /* It must be OK to kmap() if required */ - LASSERT (payload_kiov == NULL || !in_interrupt ()); - /* payload is either all vaddrs or all pages */ - LASSERT (!(payload_kiov != NULL && payload_iov != NULL)); - - if (payload_iov != NULL) - desc_size = offsetof(ksock_ltx_t, ltx_iov[1 + payload_niov]); - else - desc_size = offsetof(ksock_ltx_t, ltx_kiov[payload_niov]); - - if (in_interrupt() || - type == PTL_MSG_ACK || - type == PTL_MSG_REPLY) { - /* Can't block if in interrupt or responding to an incoming - * message */ - PORTAL_ALLOC_ATOMIC(ltx, desc_size); - } else { - PORTAL_ALLOC(ltx, desc_size); - } - - if (ltx == NULL) { - CERROR("Can't allocate tx desc type %d size %d %s\n", - type, desc_size, in_interrupt() ? "(intr)" : ""); - return (PTL_NO_SPACE); - } - - atomic_inc(&ksocknal_data.ksnd_nactive_ltxs); - - ltx->ltx_desc_size = desc_size; - - /* We always have 1 mapped frag for the header */ - ltx->ltx_tx.tx_iov = ltx->ltx_iov; - ltx->ltx_iov[0].iov_base = <x->ltx_hdr; - ltx->ltx_iov[0].iov_len = sizeof(*hdr); - ltx->ltx_hdr = *hdr; - - ltx->ltx_private = private; - ltx->ltx_cookie = cookie; - - ltx->ltx_tx.tx_isfwd = 0; - ltx->ltx_tx.tx_nob = sizeof (*hdr) + payload_nob; - - if (payload_iov != NULL) { - /* payload is all mapped */ - ltx->ltx_tx.tx_kiov = NULL; - ltx->ltx_tx.tx_nkiov = 0; - - ltx->ltx_tx.tx_niov = - 1 + lib_extract_iov(payload_niov, <x->ltx_iov[1], - payload_niov, payload_iov, - payload_offset, payload_nob); - } else { - /* payload is all pages */ - ltx->ltx_tx.tx_niov = 1; - - ltx->ltx_tx.tx_kiov = ltx->ltx_kiov; - ltx->ltx_tx.tx_nkiov = - lib_extract_kiov(payload_niov, ltx->ltx_kiov, - payload_niov, payload_kiov, - payload_offset, payload_nob); - } - - rc = ksocknal_launch_packet(<x->ltx_tx, nid); - if (rc == 0) - return (PTL_OK); - - ksocknal_free_ltx(ltx); - return (PTL_FAIL); -} - -ptl_err_t -ksocknal_send (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, struct iovec *payload_iov, - size_t payload_offset, size_t payload_len) -{ - return (ksocknal_sendmsg(nal, private, cookie, - hdr, type, nid, pid, - payload_niov, payload_iov, NULL, - payload_offset, payload_len)); -} - -ptl_err_t -ksocknal_send_pages (lib_nal_t *nal, void *private, lib_msg_t *cookie, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - unsigned int payload_niov, ptl_kiov_t *payload_kiov, - size_t payload_offset, size_t payload_len) -{ - return (ksocknal_sendmsg(nal, private, cookie, - hdr, type, nid, pid, - payload_niov, NULL, payload_kiov, - payload_offset, payload_len)); -} - -void -ksocknal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd) -{ - ptl_nid_t nid = fwd->kprfd_gateway_nid; - ksock_ftx_t *ftx = (ksock_ftx_t *)&fwd->kprfd_scratch; - int rc; - - CDEBUG (D_NET, "Forwarding [%p] -> "LPX64" ("LPX64"))\n", fwd, - fwd->kprfd_gateway_nid, fwd->kprfd_target_nid); - - /* I'm the gateway; must be the last hop */ - if (nid == ksocknal_lib.libnal_ni.ni_pid.nid) - nid = fwd->kprfd_target_nid; - - /* setup iov for hdr */ - ftx->ftx_iov.iov_base = fwd->kprfd_hdr; - ftx->ftx_iov.iov_len = sizeof(ptl_hdr_t); - - ftx->ftx_tx.tx_isfwd = 1; /* This is a forwarding packet */ - ftx->ftx_tx.tx_nob = sizeof(ptl_hdr_t) + fwd->kprfd_nob; - ftx->ftx_tx.tx_niov = 1; - ftx->ftx_tx.tx_iov = &ftx->ftx_iov; - ftx->ftx_tx.tx_nkiov = fwd->kprfd_niov; - ftx->ftx_tx.tx_kiov = fwd->kprfd_kiov; - - rc = ksocknal_launch_packet (&ftx->ftx_tx, nid); - if (rc != 0) - kpr_fwd_done (&ksocknal_data.ksnd_router, fwd, rc); -} - -int -ksocknal_thread_start (int (*fn)(void *arg), void *arg) -{ - long pid = kernel_thread (fn, arg, 0); - unsigned long flags; - - if (pid < 0) - return ((int)pid); - - write_lock_irqsave(&ksocknal_data.ksnd_global_lock, flags); - ksocknal_data.ksnd_nthreads++; - write_unlock_irqrestore(&ksocknal_data.ksnd_global_lock, flags); - return (0); -} - -void -ksocknal_thread_fini (void) -{ - unsigned long flags; - - write_lock_irqsave(&ksocknal_data.ksnd_global_lock, flags); - ksocknal_data.ksnd_nthreads--; - write_unlock_irqrestore(&ksocknal_data.ksnd_global_lock, flags); -} - -void -ksocknal_fmb_callback (void *arg, int error) -{ - ksock_fmb_t *fmb = (ksock_fmb_t *)arg; - ksock_fmb_pool_t *fmp = fmb->fmb_pool; - ptl_hdr_t *hdr = &fmb->fmb_hdr; - ksock_conn_t *conn = NULL; - ksock_sched_t *sched; - unsigned long flags; - char ipbuf[PTL_NALFMT_SIZE]; - char ipbuf2[PTL_NALFMT_SIZE]; - - if (error != 0) - CERROR("Failed to route packet from " - LPX64" %s to "LPX64" %s: %d\n", - le64_to_cpu(hdr->src_nid), - portals_nid2str(SOCKNAL, le64_to_cpu(hdr->src_nid), ipbuf), - le64_to_cpu(hdr->dest_nid), - portals_nid2str(SOCKNAL, le64_to_cpu(hdr->dest_nid), ipbuf2), - error); - else - CDEBUG (D_NET, "routed packet from "LPX64" to "LPX64": OK\n", - le64_to_cpu(hdr->src_nid), le64_to_cpu(hdr->dest_nid)); - - /* drop peer ref taken on init */ - ksocknal_put_peer (fmb->fmb_peer); - - spin_lock_irqsave (&fmp->fmp_lock, flags); - - list_add (&fmb->fmb_list, &fmp->fmp_idle_fmbs); - fmp->fmp_nactive_fmbs--; - - if (!list_empty (&fmp->fmp_blocked_conns)) { - conn = list_entry (fmb->fmb_pool->fmp_blocked_conns.next, - ksock_conn_t, ksnc_rx_list); - list_del (&conn->ksnc_rx_list); - } - - spin_unlock_irqrestore (&fmp->fmp_lock, flags); - - if (conn == NULL) - return; - - CDEBUG (D_NET, "Scheduling conn %p\n", conn); - LASSERT (conn->ksnc_rx_scheduled); - LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_FMB_SLEEP); - - conn->ksnc_rx_state = SOCKNAL_RX_GET_FMB; - - sched = conn->ksnc_scheduler; - - spin_lock_irqsave (&sched->kss_lock, flags); - - list_add_tail (&conn->ksnc_rx_list, &sched->kss_rx_conns); - wake_up (&sched->kss_waitq); - - spin_unlock_irqrestore (&sched->kss_lock, flags); -} - -ksock_fmb_t * -ksocknal_get_idle_fmb (ksock_conn_t *conn) -{ - int payload_nob = conn->ksnc_rx_nob_left; - unsigned long flags; - ksock_fmb_pool_t *pool; - ksock_fmb_t *fmb; - - LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_GET_FMB); - LASSERT (kpr_routing(&ksocknal_data.ksnd_router)); - - if (payload_nob <= SOCKNAL_SMALL_FWD_PAGES * PAGE_SIZE) - pool = &ksocknal_data.ksnd_small_fmp; - else - pool = &ksocknal_data.ksnd_large_fmp; - - spin_lock_irqsave (&pool->fmp_lock, flags); - - if (!list_empty (&pool->fmp_idle_fmbs)) { - fmb = list_entry(pool->fmp_idle_fmbs.next, - ksock_fmb_t, fmb_list); - list_del (&fmb->fmb_list); - pool->fmp_nactive_fmbs++; - spin_unlock_irqrestore (&pool->fmp_lock, flags); - - return (fmb); - } - - /* deschedule until fmb free */ - - conn->ksnc_rx_state = SOCKNAL_RX_FMB_SLEEP; - - list_add_tail (&conn->ksnc_rx_list, - &pool->fmp_blocked_conns); - - spin_unlock_irqrestore (&pool->fmp_lock, flags); - return (NULL); -} - -int -ksocknal_init_fmb (ksock_conn_t *conn, ksock_fmb_t *fmb) -{ - int payload_nob = conn->ksnc_rx_nob_left; - ptl_nid_t dest_nid = le64_to_cpu(conn->ksnc_hdr.dest_nid); - int niov = 0; - int nob = payload_nob; - - LASSERT (conn->ksnc_rx_scheduled); - LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_GET_FMB); - LASSERT (conn->ksnc_rx_nob_wanted == conn->ksnc_rx_nob_left); - LASSERT (payload_nob >= 0); - LASSERT (payload_nob <= fmb->fmb_pool->fmp_buff_pages * PAGE_SIZE); - LASSERT (sizeof (ptl_hdr_t) < PAGE_SIZE); - LASSERT (fmb->fmb_kiov[0].kiov_offset == 0); - - /* Take a ref on the conn's peer to prevent module unload before - * forwarding completes. */ - fmb->fmb_peer = conn->ksnc_peer; - atomic_inc (&conn->ksnc_peer->ksnp_refcount); - - /* Copy the header we just read into the forwarding buffer. If - * there's payload, start reading reading it into the buffer, - * otherwise the forwarding buffer can be kicked off - * immediately. */ - fmb->fmb_hdr = conn->ksnc_hdr; - - while (nob > 0) { - LASSERT (niov < fmb->fmb_pool->fmp_buff_pages); - LASSERT (fmb->fmb_kiov[niov].kiov_offset == 0); - fmb->fmb_kiov[niov].kiov_len = MIN (PAGE_SIZE, nob); - nob -= PAGE_SIZE; - niov++; - } - - kpr_fwd_init(&fmb->fmb_fwd, dest_nid, &fmb->fmb_hdr, - payload_nob, niov, fmb->fmb_kiov, - ksocknal_fmb_callback, fmb); - - if (payload_nob == 0) { /* got complete packet already */ - CDEBUG (D_NET, "%p "LPX64"->"LPX64" fwd_start (immediate)\n", - conn, le64_to_cpu(conn->ksnc_hdr.src_nid), dest_nid); - - kpr_fwd_start (&ksocknal_data.ksnd_router, &fmb->fmb_fwd); - - ksocknal_new_packet (conn, 0); /* on to next packet */ - return (1); - } - - conn->ksnc_cookie = fmb; /* stash fmb for later */ - conn->ksnc_rx_state = SOCKNAL_RX_BODY_FWD; /* read in the payload */ - - /* Set up conn->ksnc_rx_kiov to read the payload into fmb's kiov-ed - * buffer */ - LASSERT (niov <= sizeof(conn->ksnc_rx_iov_space)/sizeof(ptl_kiov_t)); - - conn->ksnc_rx_niov = 0; - conn->ksnc_rx_nkiov = niov; - conn->ksnc_rx_kiov = conn->ksnc_rx_iov_space.kiov; - memcpy(conn->ksnc_rx_kiov, fmb->fmb_kiov, niov * sizeof(ptl_kiov_t)); - - CDEBUG (D_NET, "%p "LPX64"->"LPX64" %d reading body\n", conn, - le64_to_cpu(conn->ksnc_hdr.src_nid), dest_nid, payload_nob); - return (0); -} - -void -ksocknal_fwd_parse (ksock_conn_t *conn) -{ - ksock_peer_t *peer; - ptl_nid_t dest_nid = le64_to_cpu(conn->ksnc_hdr.dest_nid); - ptl_nid_t src_nid = le64_to_cpu(conn->ksnc_hdr.src_nid); - int body_len = le32_to_cpu(conn->ksnc_hdr.payload_length); - char str[PTL_NALFMT_SIZE]; - char str2[PTL_NALFMT_SIZE]; - - CDEBUG (D_NET, "%p "LPX64"->"LPX64" %d parsing header\n", conn, - src_nid, dest_nid, conn->ksnc_rx_nob_left); - - LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_HEADER); - LASSERT (conn->ksnc_rx_scheduled); - - if (body_len < 0) { /* length corrupt (overflow) */ - CERROR("dropping packet from "LPX64" (%s) for "LPX64" (%s): " - "packet size %d illegal\n", - src_nid, portals_nid2str(TCPNAL, src_nid, str), - dest_nid, portals_nid2str(TCPNAL, dest_nid, str2), - body_len); - - ksocknal_new_packet (conn, 0); /* on to new packet */ - return; - } - - if (!kpr_routing(&ksocknal_data.ksnd_router)) { /* not forwarding */ - CERROR("dropping packet from "LPX64" (%s) for "LPX64 - " (%s): not forwarding\n", - src_nid, portals_nid2str(TCPNAL, src_nid, str), - dest_nid, portals_nid2str(TCPNAL, dest_nid, str2)); - /* on to new packet (skip this one's body) */ - ksocknal_new_packet (conn, body_len); - return; - } - - if (body_len > PTL_MTU) { /* too big to forward */ - CERROR ("dropping packet from "LPX64" (%s) for "LPX64 - "(%s): packet size %d too big\n", - src_nid, portals_nid2str(TCPNAL, src_nid, str), - dest_nid, portals_nid2str(TCPNAL, dest_nid, str2), - body_len); - /* on to new packet (skip this one's body) */ - ksocknal_new_packet (conn, body_len); - return; - } - - /* should have gone direct */ - peer = ksocknal_get_peer (conn->ksnc_hdr.dest_nid); - if (peer != NULL) { - CERROR ("dropping packet from "LPX64" (%s) for "LPX64 - "(%s): target is a peer\n", - src_nid, portals_nid2str(TCPNAL, src_nid, str), - dest_nid, portals_nid2str(TCPNAL, dest_nid, str2)); - ksocknal_put_peer (peer); /* drop ref from get above */ - - /* on to next packet (skip this one's body) */ - ksocknal_new_packet (conn, body_len); - return; - } - - conn->ksnc_rx_state = SOCKNAL_RX_GET_FMB; /* Getting FMB now */ - conn->ksnc_rx_nob_left = body_len; /* stash packet size */ - conn->ksnc_rx_nob_wanted = body_len; /* (no slop) */ -} - -int -ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip) -{ - static char ksocknal_slop_buffer[4096]; - - int nob; - int niov; - int skipped; - - if (nob_to_skip == 0) { /* right at next packet boundary now */ - conn->ksnc_rx_started = 0; - mb (); /* racing with timeout thread */ - - conn->ksnc_rx_state = SOCKNAL_RX_HEADER; - conn->ksnc_rx_nob_wanted = sizeof (ptl_hdr_t); - conn->ksnc_rx_nob_left = sizeof (ptl_hdr_t); - - conn->ksnc_rx_iov = (struct iovec *)&conn->ksnc_rx_iov_space; - conn->ksnc_rx_iov[0].iov_base = (char *)&conn->ksnc_hdr; - conn->ksnc_rx_iov[0].iov_len = sizeof (ptl_hdr_t); - conn->ksnc_rx_niov = 1; - - conn->ksnc_rx_kiov = NULL; - conn->ksnc_rx_nkiov = 0; - return (1); - } - - /* Set up to skip as much a possible now. If there's more left - * (ran out of iov entries) we'll get called again */ - - conn->ksnc_rx_state = SOCKNAL_RX_SLOP; - conn->ksnc_rx_nob_left = nob_to_skip; - conn->ksnc_rx_iov = (struct iovec *)&conn->ksnc_rx_iov_space; - skipped = 0; - niov = 0; - - do { - nob = MIN (nob_to_skip, sizeof (ksocknal_slop_buffer)); - - conn->ksnc_rx_iov[niov].iov_base = ksocknal_slop_buffer; - conn->ksnc_rx_iov[niov].iov_len = nob; - niov++; - skipped += nob; - nob_to_skip -=nob; - - } while (nob_to_skip != 0 && /* mustn't overflow conn's rx iov */ - niov < sizeof(conn->ksnc_rx_iov_space) / sizeof (struct iovec)); - - conn->ksnc_rx_niov = niov; - conn->ksnc_rx_kiov = NULL; - conn->ksnc_rx_nkiov = 0; - conn->ksnc_rx_nob_wanted = skipped; - return (0); -} - -int -ksocknal_process_receive (ksock_conn_t *conn) -{ - ksock_fmb_t *fmb; - int rc; - - LASSERT (atomic_read (&conn->ksnc_refcount) > 0); - - /* doesn't need a forwarding buffer */ - if (conn->ksnc_rx_state != SOCKNAL_RX_GET_FMB) - goto try_read; - - get_fmb: - fmb = ksocknal_get_idle_fmb (conn); - if (fmb == NULL) { - /* conn descheduled waiting for idle fmb */ - return (0); - } - - if (ksocknal_init_fmb (conn, fmb)) { - /* packet forwarded */ - return (0); - } - - try_read: - /* NB: sched lock NOT held */ - LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_HEADER || - conn->ksnc_rx_state == SOCKNAL_RX_BODY || - conn->ksnc_rx_state == SOCKNAL_RX_BODY_FWD || - conn->ksnc_rx_state == SOCKNAL_RX_SLOP); - - LASSERT (conn->ksnc_rx_nob_wanted > 0); - - rc = ksocknal_receive(conn); - - if (rc <= 0) { - LASSERT (rc != -EAGAIN); - - if (rc == 0) - CWARN ("[%p] EOF from "LPX64" ip %d.%d.%d.%d:%d\n", - conn, conn->ksnc_peer->ksnp_nid, - HIPQUAD(conn->ksnc_ipaddr), - conn->ksnc_port); - else if (!conn->ksnc_closing) - CERROR ("[%p] Error %d on read from "LPX64 - " ip %d.%d.%d.%d:%d\n", - conn, rc, conn->ksnc_peer->ksnp_nid, - HIPQUAD(conn->ksnc_ipaddr), - conn->ksnc_port); - - ksocknal_close_conn_and_siblings (conn, rc); - return (rc == 0 ? -ESHUTDOWN : rc); - } - - if (conn->ksnc_rx_nob_wanted != 0) { - /* short read */ - return (-EAGAIN); - } - - switch (conn->ksnc_rx_state) { - case SOCKNAL_RX_HEADER: - if (conn->ksnc_hdr.type != cpu_to_le32(PTL_MSG_HELLO) && - le64_to_cpu(conn->ksnc_hdr.dest_nid) != - ksocknal_lib.libnal_ni.ni_pid.nid) { - /* This packet isn't for me */ - ksocknal_fwd_parse (conn); - switch (conn->ksnc_rx_state) { - case SOCKNAL_RX_HEADER: /* skipped (zero payload) */ - return (0); /* => come back later */ - case SOCKNAL_RX_SLOP: /* skipping packet's body */ - goto try_read; /* => go read it */ - case SOCKNAL_RX_GET_FMB: /* forwarding */ - goto get_fmb; /* => go get a fwd msg buffer */ - default: - LBUG (); - } - /* Not Reached */ - } - - /* sets wanted_len, iovs etc */ - rc = lib_parse(&ksocknal_lib, &conn->ksnc_hdr, conn); - - if (rc != PTL_OK) { - /* I just received garbage: give up on this conn */ - ksocknal_close_conn_and_siblings (conn, rc); - return (-EPROTO); - } - - if (conn->ksnc_rx_nob_wanted != 0) { /* need to get payload? */ - conn->ksnc_rx_state = SOCKNAL_RX_BODY; - goto try_read; /* go read the payload */ - } - /* Fall through (completed packet for me) */ - - case SOCKNAL_RX_BODY: - /* payload all received */ - lib_finalize(&ksocknal_lib, NULL, conn->ksnc_cookie, PTL_OK); - /* Fall through */ - - case SOCKNAL_RX_SLOP: - /* starting new packet? */ - if (ksocknal_new_packet (conn, conn->ksnc_rx_nob_left)) - return (0); /* come back later */ - goto try_read; /* try to finish reading slop now */ - - case SOCKNAL_RX_BODY_FWD: - /* payload all received */ - CDEBUG (D_NET, "%p "LPX64"->"LPX64" %d fwd_start (got body)\n", - conn, le64_to_cpu(conn->ksnc_hdr.src_nid), - le64_to_cpu(conn->ksnc_hdr.dest_nid), - conn->ksnc_rx_nob_left); - - /* forward the packet. NB ksocknal_init_fmb() put fmb into - * conn->ksnc_cookie */ - fmb = (ksock_fmb_t *)conn->ksnc_cookie; - kpr_fwd_start (&ksocknal_data.ksnd_router, &fmb->fmb_fwd); - - /* no slop in forwarded packets */ - LASSERT (conn->ksnc_rx_nob_left == 0); - - ksocknal_new_packet (conn, 0); /* on to next packet */ - return (0); /* (later) */ - - default: - break; - } - - /* Not Reached */ - LBUG (); - return (-EINVAL); /* keep gcc happy */ -} - -ptl_err_t -ksocknal_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, struct iovec *iov, - size_t offset, size_t mlen, size_t rlen) -{ - ksock_conn_t *conn = (ksock_conn_t *)private; - - LASSERT (mlen <= rlen); - LASSERT (niov <= PTL_MD_MAX_IOV); - - conn->ksnc_cookie = msg; - conn->ksnc_rx_nob_wanted = mlen; - conn->ksnc_rx_nob_left = rlen; - - conn->ksnc_rx_nkiov = 0; - conn->ksnc_rx_kiov = NULL; - conn->ksnc_rx_iov = conn->ksnc_rx_iov_space.iov; - conn->ksnc_rx_niov = - lib_extract_iov(PTL_MD_MAX_IOV, conn->ksnc_rx_iov, - niov, iov, offset, mlen); - - LASSERT (mlen == - lib_iov_nob (conn->ksnc_rx_niov, conn->ksnc_rx_iov) + - lib_kiov_nob (conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov)); - - return (PTL_OK); -} - -ptl_err_t -ksocknal_recv_pages (lib_nal_t *nal, void *private, lib_msg_t *msg, - unsigned int niov, ptl_kiov_t *kiov, - size_t offset, size_t mlen, size_t rlen) -{ - ksock_conn_t *conn = (ksock_conn_t *)private; - - LASSERT (mlen <= rlen); - LASSERT (niov <= PTL_MD_MAX_IOV); - - conn->ksnc_cookie = msg; - conn->ksnc_rx_nob_wanted = mlen; - conn->ksnc_rx_nob_left = rlen; - - conn->ksnc_rx_niov = 0; - conn->ksnc_rx_iov = NULL; - conn->ksnc_rx_kiov = conn->ksnc_rx_iov_space.kiov; - conn->ksnc_rx_nkiov = - lib_extract_kiov(PTL_MD_MAX_IOV, conn->ksnc_rx_kiov, - niov, kiov, offset, mlen); - - LASSERT (mlen == - lib_iov_nob (conn->ksnc_rx_niov, conn->ksnc_rx_iov) + - lib_kiov_nob (conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov)); - - return (PTL_OK); -} - -static inline int -ksocknal_sched_cansleep(ksock_sched_t *sched) -{ - unsigned long flags; - int rc; - - spin_lock_irqsave(&sched->kss_lock, flags); - - rc = (!ksocknal_data.ksnd_shuttingdown && -#if SOCKNAL_ZC - list_empty(&sched->kss_zctxdone_list) && -#endif - list_empty(&sched->kss_rx_conns) && - list_empty(&sched->kss_tx_conns)); - - spin_unlock_irqrestore(&sched->kss_lock, flags); - return (rc); -} - -int ksocknal_scheduler (void *arg) -{ - ksock_sched_t *sched = (ksock_sched_t *)arg; - ksock_conn_t *conn; - ksock_tx_t *tx; - unsigned long flags; - int rc; - int nloops = 0; - int id = sched - ksocknal_data.ksnd_schedulers; - char name[16]; - - snprintf (name, sizeof (name),"ksocknald_%02d", id); - kportal_daemonize (name); - kportal_blockallsigs (); - -#if (CONFIG_SMP && CPU_AFFINITY) - id = ksocknal_sched2cpu(id); - if (cpu_online(id)) { - cpumask_t m; - cpu_set(id, m); - set_cpus_allowed(current, m); - } else { - CERROR ("Can't set CPU affinity for %s to %d\n", name, id); - } -#endif /* CONFIG_SMP && CPU_AFFINITY */ - - spin_lock_irqsave (&sched->kss_lock, flags); - - while (!ksocknal_data.ksnd_shuttingdown) { - int did_something = 0; - - /* Ensure I progress everything semi-fairly */ - - if (!list_empty (&sched->kss_rx_conns)) { - conn = list_entry(sched->kss_rx_conns.next, - ksock_conn_t, ksnc_rx_list); - list_del(&conn->ksnc_rx_list); - - LASSERT(conn->ksnc_rx_scheduled); - LASSERT(conn->ksnc_rx_ready); - - /* clear rx_ready in case receive isn't complete. - * Do it BEFORE we call process_recv, since - * data_ready can set it any time after we release - * kss_lock. */ - conn->ksnc_rx_ready = 0; - spin_unlock_irqrestore(&sched->kss_lock, flags); - - rc = ksocknal_process_receive(conn); - - spin_lock_irqsave(&sched->kss_lock, flags); - - /* I'm the only one that can clear this flag */ - LASSERT(conn->ksnc_rx_scheduled); - - /* Did process_receive get everything it wanted? */ - if (rc == 0) - conn->ksnc_rx_ready = 1; - - if (conn->ksnc_rx_state == SOCKNAL_RX_FMB_SLEEP || - conn->ksnc_rx_state == SOCKNAL_RX_GET_FMB) { - /* Conn blocked for a forwarding buffer. - * It will get queued for my attention when - * one becomes available (and it might just - * already have been!). Meanwhile my ref - * on it stays put. */ - } else if (conn->ksnc_rx_ready) { - /* reschedule for rx */ - list_add_tail (&conn->ksnc_rx_list, - &sched->kss_rx_conns); - } else { - conn->ksnc_rx_scheduled = 0; - /* drop my ref */ - ksocknal_put_conn(conn); - } - - did_something = 1; - } - - if (!list_empty (&sched->kss_tx_conns)) { - conn = list_entry(sched->kss_tx_conns.next, - ksock_conn_t, ksnc_tx_list); - list_del (&conn->ksnc_tx_list); - - LASSERT(conn->ksnc_tx_scheduled); - LASSERT(conn->ksnc_tx_ready); - LASSERT(!list_empty(&conn->ksnc_tx_queue)); - - tx = list_entry(conn->ksnc_tx_queue.next, - ksock_tx_t, tx_list); - /* dequeue now so empty list => more to send */ - list_del(&tx->tx_list); - - /* Clear tx_ready in case send isn't complete. Do - * it BEFORE we call process_transmit, since - * write_space can set it any time after we release - * kss_lock. */ - conn->ksnc_tx_ready = 0; - spin_unlock_irqrestore (&sched->kss_lock, flags); - - rc = ksocknal_process_transmit(conn, tx); - - spin_lock_irqsave (&sched->kss_lock, flags); - - if (rc == -ENOMEM || rc == -EAGAIN) { - /* Incomplete send: replace tx on HEAD of tx_queue */ - list_add (&tx->tx_list, &conn->ksnc_tx_queue); - } else { - /* Complete send; assume space for more */ - conn->ksnc_tx_ready = 1; - } - - if (rc == -ENOMEM) { - /* Do nothing; after a short timeout, this - * conn will be reposted on kss_tx_conns. */ - } else if (conn->ksnc_tx_ready && - !list_empty (&conn->ksnc_tx_queue)) { - /* reschedule for tx */ - list_add_tail (&conn->ksnc_tx_list, - &sched->kss_tx_conns); - } else { - conn->ksnc_tx_scheduled = 0; - /* drop my ref */ - ksocknal_put_conn (conn); - } - - did_something = 1; - } -#if SOCKNAL_ZC - if (!list_empty (&sched->kss_zctxdone_list)) { - ksock_tx_t *tx = - list_entry(sched->kss_zctxdone_list.next, - ksock_tx_t, tx_list); - did_something = 1; - - list_del (&tx->tx_list); - spin_unlock_irqrestore (&sched->kss_lock, flags); - - ksocknal_tx_done (tx, 1); - - spin_lock_irqsave (&sched->kss_lock, flags); - } -#endif - if (!did_something || /* nothing to do */ - ++nloops == SOCKNAL_RESCHED) { /* hogging CPU? */ - spin_unlock_irqrestore (&sched->kss_lock, flags); - - nloops = 0; - - if (!did_something) { /* wait for something to do */ - rc = wait_event_interruptible (sched->kss_waitq, - !ksocknal_sched_cansleep(sched)); - LASSERT (rc == 0); - } else - our_cond_resched(); - - spin_lock_irqsave (&sched->kss_lock, flags); - } - } - - spin_unlock_irqrestore (&sched->kss_lock, flags); - ksocknal_thread_fini (); - return (0); -} - -void -ksocknal_data_ready (struct sock *sk, int n) -{ - unsigned long flags; - ksock_conn_t *conn; - ksock_sched_t *sched; - ENTRY; - - /* interleave correctly with closing sockets... */ - read_lock (&ksocknal_data.ksnd_global_lock); - - conn = sk->sk_user_data; - if (conn == NULL) { /* raced with ksocknal_terminate_conn */ - LASSERT (sk->sk_data_ready != &ksocknal_data_ready); - sk->sk_data_ready (sk, n); - } else { - sched = conn->ksnc_scheduler; - - spin_lock_irqsave (&sched->kss_lock, flags); - - conn->ksnc_rx_ready = 1; - - if (!conn->ksnc_rx_scheduled) { /* not being progressed */ - list_add_tail(&conn->ksnc_rx_list, - &sched->kss_rx_conns); - conn->ksnc_rx_scheduled = 1; - /* extra ref for scheduler */ - atomic_inc (&conn->ksnc_refcount); - - wake_up (&sched->kss_waitq); - } - - spin_unlock_irqrestore (&sched->kss_lock, flags); - } - - read_unlock (&ksocknal_data.ksnd_global_lock); - - EXIT; -} - -void -ksocknal_write_space (struct sock *sk) -{ - unsigned long flags; - ksock_conn_t *conn; - ksock_sched_t *sched; - - /* interleave correctly with closing sockets... */ - read_lock (&ksocknal_data.ksnd_global_lock); - - conn = sk->sk_user_data; - - CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n", - sk, tcp_wspace(sk), SOCKNAL_TX_LOW_WATER(sk), conn, - (conn == NULL) ? "" : (conn->ksnc_tx_ready ? - " ready" : " blocked"), - (conn == NULL) ? "" : (conn->ksnc_tx_scheduled ? - " scheduled" : " idle"), - (conn == NULL) ? "" : (list_empty (&conn->ksnc_tx_queue) ? - " empty" : " queued")); - - if (conn == NULL) { /* raced with ksocknal_terminate_conn */ - LASSERT (sk->sk_write_space != &ksocknal_write_space); - sk->sk_write_space (sk); - - read_unlock (&ksocknal_data.ksnd_global_lock); - return; - } - - if (tcp_wspace(sk) >= SOCKNAL_TX_LOW_WATER(sk)) { /* got enough space */ - sched = conn->ksnc_scheduler; - - spin_lock_irqsave (&sched->kss_lock, flags); - - clear_bit (SOCK_NOSPACE, &sk->sk_socket->flags); - conn->ksnc_tx_ready = 1; - - if (!conn->ksnc_tx_scheduled && // not being progressed - !list_empty(&conn->ksnc_tx_queue)){//packets to send - list_add_tail (&conn->ksnc_tx_list, - &sched->kss_tx_conns); - conn->ksnc_tx_scheduled = 1; - /* extra ref for scheduler */ - atomic_inc (&conn->ksnc_refcount); - - wake_up (&sched->kss_waitq); - } - - spin_unlock_irqrestore (&sched->kss_lock, flags); - } - - read_unlock (&ksocknal_data.ksnd_global_lock); -} - -int -ksocknal_sock_write (struct socket *sock, void *buffer, int nob) -{ - int rc; - mm_segment_t oldmm = get_fs(); - - while (nob > 0) { - 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 - }; - - set_fs (KERNEL_DS); - rc = sock_sendmsg (sock, &msg, iov.iov_len); - set_fs (oldmm); - - if (rc < 0) - return (rc); - - if (rc == 0) { - CERROR ("Unexpected zero rc\n"); - return (-ECONNABORTED); - } - - buffer = ((char *)buffer) + rc; - nob -= rc; - } - - return (0); -} - -int -ksocknal_sock_read (struct socket *sock, void *buffer, int nob) -{ - int rc; - mm_segment_t oldmm = get_fs(); - - while (nob > 0) { - 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 - }; - - set_fs (KERNEL_DS); - rc = sock_recvmsg (sock, &msg, iov.iov_len, 0); - set_fs (oldmm); - - if (rc < 0) - return (rc); - - if (rc == 0) - return (-ECONNABORTED); - - buffer = ((char *)buffer) + rc; - nob -= rc; - } - - return (0); -} - -int -ksocknal_send_hello (ksock_conn_t *conn, __u32 *ipaddrs, int nipaddrs) -{ - /* CAVEAT EMPTOR: this byte flips 'ipaddrs' */ - struct socket *sock = conn->ksnc_sock; - ptl_hdr_t hdr; - ptl_magicversion_t *hmv = (ptl_magicversion_t *)&hdr.dest_nid; - int i; - int rc; - - LASSERT (conn->ksnc_type != SOCKNAL_CONN_NONE); - LASSERT (nipaddrs <= SOCKNAL_MAX_INTERFACES); - - /* No need for getconnsock/putconnsock */ - LASSERT (!conn->ksnc_closing); - - LASSERT (sizeof (*hmv) == sizeof (hdr.dest_nid)); - hmv->magic = cpu_to_le32 (PORTALS_PROTO_MAGIC); - hmv->version_major = cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR); - hmv->version_minor = cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR); - - hdr.src_nid = cpu_to_le64 (ksocknal_lib.libnal_ni.ni_pid.nid); - hdr.type = cpu_to_le32 (PTL_MSG_HELLO); - hdr.payload_length = cpu_to_le32 (nipaddrs * sizeof(*ipaddrs)); - - hdr.msg.hello.type = cpu_to_le32 (conn->ksnc_type); - hdr.msg.hello.incarnation = - cpu_to_le64 (ksocknal_data.ksnd_incarnation); - - /* Receiver is eager */ - rc = ksocknal_sock_write (sock, &hdr, sizeof(hdr)); - if (rc != 0) { - CERROR ("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n", - rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); - return (rc); - } - - if (nipaddrs == 0) - return (0); - - for (i = 0; i < nipaddrs; i++) { - ipaddrs[i] = __cpu_to_le32 (ipaddrs[i]); - } - - rc = ksocknal_sock_write (sock, ipaddrs, nipaddrs * sizeof(*ipaddrs)); - if (rc != 0) - CERROR ("Error %d sending HELLO payload (%d)" - " to %u.%u.%u.%u/%d\n", rc, nipaddrs, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); - return (rc); -} - -int -ksocknal_invert_type(int type) -{ - switch (type) - { - case SOCKNAL_CONN_ANY: - case SOCKNAL_CONN_CONTROL: - return (type); - case SOCKNAL_CONN_BULK_IN: - return SOCKNAL_CONN_BULK_OUT; - case SOCKNAL_CONN_BULK_OUT: - return SOCKNAL_CONN_BULK_IN; - default: - return (SOCKNAL_CONN_NONE); - } -} - -int -ksocknal_recv_hello (ksock_conn_t *conn, ptl_nid_t *nid, - __u64 *incarnation, __u32 *ipaddrs) -{ - struct socket *sock = conn->ksnc_sock; - int rc; - int nips; - int i; - int type; - ptl_hdr_t hdr; - ptl_magicversion_t *hmv; - - hmv = (ptl_magicversion_t *)&hdr.dest_nid; - LASSERT (sizeof (*hmv) == sizeof (hdr.dest_nid)); - - rc = ksocknal_sock_read (sock, hmv, sizeof (*hmv)); - if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - return (rc); - } - - if (hmv->magic != le32_to_cpu (PORTALS_PROTO_MAGIC)) { - CERROR ("Bad magic %#08x (%#08x expected) from %u.%u.%u.%u\n", - __cpu_to_le32 (hmv->magic), PORTALS_PROTO_MAGIC, - HIPQUAD(conn->ksnc_ipaddr)); - return (-EPROTO); - } - - if (hmv->version_major != cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR) || - hmv->version_minor != cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR)) { - CERROR ("Incompatible protocol version %d.%d (%d.%d expected)" - " from %u.%u.%u.%u\n", - le16_to_cpu (hmv->version_major), - le16_to_cpu (hmv->version_minor), - PORTALS_PROTO_VERSION_MAJOR, - PORTALS_PROTO_VERSION_MINOR, - HIPQUAD(conn->ksnc_ipaddr)); - return (-EPROTO); - } - -#if (PORTALS_PROTO_VERSION_MAJOR != 1) -# error "This code only understands protocol version 1.x" -#endif - /* version 1 sends magic/version as the dest_nid of a 'hello' - * header, followed by payload full of interface IP addresses. - * Read the rest of it in now... */ - - rc = ksocknal_sock_read (sock, hmv + 1, sizeof (hdr) - sizeof (*hmv)); - if (rc != 0) { - CERROR ("Error %d reading rest of HELLO hdr from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - return (rc); - } - - /* ...and check we got what we expected */ - if (hdr.type != cpu_to_le32 (PTL_MSG_HELLO)) { - CERROR ("Expecting a HELLO hdr," - " but got type %d from %u.%u.%u.%u\n", - le32_to_cpu (hdr.type), - HIPQUAD(conn->ksnc_ipaddr)); - return (-EPROTO); - } - - if (le64_to_cpu(hdr.src_nid) == PTL_NID_ANY) { - CERROR("Expecting a HELLO hdr with a NID, but got PTL_NID_ANY" - "from %u.%u.%u.%u\n", HIPQUAD(conn->ksnc_ipaddr)); - return (-EPROTO); - } - - if (*nid == PTL_NID_ANY) { /* don't know peer's nid yet */ - *nid = le64_to_cpu(hdr.src_nid); - } else if (*nid != le64_to_cpu (hdr.src_nid)) { - CERROR ("Connected to nid "LPX64"@%u.%u.%u.%u " - "but expecting "LPX64"\n", - le64_to_cpu (hdr.src_nid), - HIPQUAD(conn->ksnc_ipaddr), *nid); - return (-EPROTO); - } - - type = __le32_to_cpu(hdr.msg.hello.type); - - if (conn->ksnc_type == SOCKNAL_CONN_NONE) { - /* I've accepted this connection; peer determines type */ - conn->ksnc_type = ksocknal_invert_type(type); - if (conn->ksnc_type == SOCKNAL_CONN_NONE) { - CERROR ("Unexpected type %d from "LPX64"@%u.%u.%u.%u\n", - type, *nid, HIPQUAD(conn->ksnc_ipaddr)); - return (-EPROTO); - } - } else if (ksocknal_invert_type(type) != conn->ksnc_type) { - CERROR ("Mismatched types: me %d, "LPX64"@%u.%u.%u.%u %d\n", - conn->ksnc_type, *nid, HIPQUAD(conn->ksnc_ipaddr), - le32_to_cpu(hdr.msg.hello.type)); - return (-EPROTO); - } - - *incarnation = le64_to_cpu(hdr.msg.hello.incarnation); - - nips = __le32_to_cpu (hdr.payload_length) / sizeof (__u32); - - if (nips > SOCKNAL_MAX_INTERFACES || - nips * sizeof(__u32) != __le32_to_cpu (hdr.payload_length)) { - CERROR("Bad payload length %d from "LPX64"@%u.%u.%u.%u\n", - __le32_to_cpu (hdr.payload_length), - *nid, HIPQUAD(conn->ksnc_ipaddr)); - } - - if (nips == 0) - return (0); - - rc = ksocknal_sock_read (sock, ipaddrs, nips * sizeof(*ipaddrs)); - if (rc != 0) { - CERROR ("Error %d reading IPs from "LPX64"@%u.%u.%u.%u\n", - rc, *nid, HIPQUAD(conn->ksnc_ipaddr)); - return (rc); - } - - for (i = 0; i < nips; i++) { - ipaddrs[i] = __le32_to_cpu(ipaddrs[i]); - - if (ipaddrs[i] == 0) { - CERROR("Zero IP[%d] from "LPX64"@%u.%u.%u.%u\n", - i, *nid, HIPQUAD(conn->ksnc_ipaddr)); - return (-EPROTO); - } - } - - return (nips); -} - -int -ksocknal_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle) -{ - mm_segment_t oldmm = get_fs (); - struct socket *sock = conn->ksnc_sock; - int len; - int rc; - - rc = ksocknal_getconnsock (conn); - if (rc != 0) { - LASSERT (conn->ksnc_closing); - *txmem = *rxmem = *nagle = 0; - return (-ESHUTDOWN); - } - - set_fs (KERNEL_DS); - - len = sizeof(*txmem); - rc = sock_getsockopt(sock, SOL_SOCKET, SO_SNDBUF, - (char *)txmem, &len); - if (rc == 0) { - len = sizeof(*rxmem); - rc = sock_getsockopt(sock, SOL_SOCKET, SO_RCVBUF, - (char *)rxmem, &len); - } - if (rc == 0) { - len = sizeof(*nagle); - rc = sock->ops->getsockopt(sock, SOL_TCP, TCP_NODELAY, - (char *)nagle, &len); - } - - set_fs (oldmm); - ksocknal_putconnsock (conn); - - if (rc == 0) - *nagle = !*nagle; - else - *txmem = *rxmem = *nagle = 0; - - return (rc); -} - -int -ksocknal_setup_sock (struct socket *sock) -{ - mm_segment_t oldmm = get_fs (); - int rc; - int option; - int keep_idle; - int keep_intvl; - int keep_count; - int do_keepalive; - struct linger linger; - - sock->sk->sk_allocation = GFP_NOFS; - - /* Ensure this socket aborts active sends immediately when we close - * it. */ - - linger.l_onoff = 0; - linger.l_linger = 0; - - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_LINGER, - (char *)&linger, sizeof (linger)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set SO_LINGER: %d\n", rc); - return (rc); - } - - option = -1; - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_LINGER2, - (char *)&option, sizeof (option)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set SO_LINGER2: %d\n", rc); - return (rc); - } - - if (!ksocknal_tunables.ksnd_nagle) { - option = 1; - - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_NODELAY, - (char *)&option, sizeof (option)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't disable nagle: %d\n", rc); - return (rc); - } - } - - if (ksocknal_tunables.ksnd_buffer_size > 0) { - option = ksocknal_tunables.ksnd_buffer_size; - - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, - (char *)&option, sizeof (option)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set send buffer %d: %d\n", - option, rc); - return (rc); - } - - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, - (char *)&option, sizeof (option)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set receive buffer %d: %d\n", - option, 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); - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_KEEPALIVE, - (char *)&option, sizeof (option)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set SO_KEEPALIVE: %d\n", rc); - return (rc); - } - - if (!do_keepalive) - return (0); - - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPIDLE, - (char *)&keep_idle, sizeof (keep_idle)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set TCP_KEEPIDLE: %d\n", rc); - return (rc); - } - - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPINTVL, - (char *)&keep_intvl, sizeof (keep_intvl)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set TCP_KEEPINTVL: %d\n", rc); - return (rc); - } - - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPCNT, - (char *)&keep_count, sizeof (keep_count)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set TCP_KEEPCNT: %d\n", rc); - return (rc); - } - - return (0); -} - -static int -ksocknal_connect_sock(struct socket **sockp, int *may_retry, - ksock_route_t *route, int local_port) -{ - struct sockaddr_in locaddr; - struct sockaddr_in srvaddr; - struct socket *sock; - int rc; - int option; - mm_segment_t oldmm = get_fs(); - struct timeval tv; - - memset(&locaddr, 0, sizeof(locaddr)); - locaddr.sin_family = AF_INET; - locaddr.sin_port = htons(local_port); - locaddr.sin_addr.s_addr = - (route->ksnr_myipaddr != 0) ? htonl(route->ksnr_myipaddr) - : INADDR_ANY; - - memset (&srvaddr, 0, sizeof (srvaddr)); - srvaddr.sin_family = AF_INET; - srvaddr.sin_port = htons (route->ksnr_port); - srvaddr.sin_addr.s_addr = htonl (route->ksnr_ipaddr); - - *may_retry = 0; - - rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); - *sockp = sock; - if (rc != 0) { - CERROR ("Can't create autoconnect socket: %d\n", rc); - return (rc); - } - - /* Ugh; have to map_fd for compatibility with sockets passed in - * from userspace. And we actually need the sock->file refcounting - * that this gives you :) */ - - rc = sock_map_fd (sock); - if (rc < 0) { - sock_release (sock); - CERROR ("sock_map_fd error %d\n", rc); - return (rc); - } - - /* NB the file descriptor (rc) now owns the ref on sock->file */ - LASSERT (sock->file != NULL); - LASSERT (file_count(sock->file) == 1); - - get_file(sock->file); /* extra ref makes sock->file */ - sys_close(rc); /* survive this close */ - - /* Still got a single ref on sock->file */ - LASSERT (file_count(sock->file) == 1); - - /* Set the socket timeouts, so our connection attempt completes in - * finite time */ - tv.tv_sec = ksocknal_tunables.ksnd_io_timeout; - tv.tv_usec = 0; - - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, - (char *)&tv, sizeof (tv)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set send timeout %d: %d\n", - ksocknal_tunables.ksnd_io_timeout, rc); - goto failed; - } - - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, - (char *)&tv, sizeof (tv)); - set_fs (oldmm); - if (rc != 0) { - CERROR ("Can't set receive timeout %d: %d\n", - ksocknal_tunables.ksnd_io_timeout, rc); - goto failed; - } - - set_fs (KERNEL_DS); - option = 1; - rc = sock_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&option, sizeof (option)); - set_fs (oldmm); - if (rc != 0) { - CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc); - goto failed; - } - - rc = sock->ops->bind(sock, - (struct sockaddr *)&locaddr, sizeof(locaddr)); - if (rc == -EADDRINUSE) { - CDEBUG(D_NET, "Port %d already in use\n", local_port); - *may_retry = 1; - goto failed; - } - if (rc != 0) { - CERROR("Error trying to bind to reserved port %d: %d\n", - local_port, rc); - goto failed; - } - - rc = sock->ops->connect(sock, - (struct sockaddr *)&srvaddr, sizeof(srvaddr), - sock->file->f_flags); - if (rc == 0) - return 0; - - /* EADDRNOTAVAIL probably means we're already connected to the same - * peer/port on the same local port on a differently typed - * connection. Let our caller retry with a different local - * port... */ - *may_retry = (rc == -EADDRNOTAVAIL); - - CDEBUG(*may_retry ? D_NET : D_ERROR, - "Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc, - HIPQUAD(route->ksnr_myipaddr), local_port, - HIPQUAD(route->ksnr_ipaddr), route->ksnr_port); - - failed: - fput(sock->file); - return rc; -} - -int -ksocknal_connect_peer (ksock_route_t *route, int type) -{ - struct socket *sock; - int rc; - int port; - int may_retry; - - /* Iterate through reserved ports. When typed connections are - * used, we will need to bind to multiple ports, but we only know - * this at connect time. But, by that time we've already called - * bind() so we need a new socket. */ - - for (port = 1023; port > 512; --port) { - - rc = ksocknal_connect_sock(&sock, &may_retry, route, port); - - if (rc == 0) { - rc = ksocknal_create_conn(route, sock, type); - fput(sock->file); - return rc; - } - - if (!may_retry) - return rc; - } - - CERROR("Out of ports trying to bind to a reserved port\n"); - return (-EADDRINUSE); -} - -void -ksocknal_autoconnect (ksock_route_t *route) -{ - LIST_HEAD (zombies); - ksock_tx_t *tx; - ksock_peer_t *peer; - unsigned long flags; - int rc; - int type; - - for (;;) { - for (type = 0; type < SOCKNAL_CONN_NTYPES; type++) - if ((route->ksnr_connecting & (1 << type)) != 0) - break; - LASSERT (type < SOCKNAL_CONN_NTYPES); - - rc = ksocknal_connect_peer (route, type); - if (rc != 0) - break; - - /* successfully autoconnected: create_conn did the - * route/conn binding and scheduled any blocked packets */ - - if (route->ksnr_connecting == 0) { - /* No more connections required */ - return; - } - } - - /* Connection attempt failed */ - - write_lock_irqsave (&ksocknal_data.ksnd_global_lock, flags); - - peer = route->ksnr_peer; - route->ksnr_connecting = 0; - - /* This is a retry rather than a new connection */ - LASSERT (route->ksnr_retry_interval != 0); - route->ksnr_timeout = jiffies + route->ksnr_retry_interval; - route->ksnr_retry_interval = MIN (route->ksnr_retry_interval * 2, - SOCKNAL_MAX_RECONNECT_INTERVAL); - - if (!list_empty (&peer->ksnp_tx_queue) && - ksocknal_find_connecting_route_locked (peer) == NULL) { - LASSERT (list_empty (&peer->ksnp_conns)); - - /* None of the connections that the blocked packets are - * waiting for have been successful. Complete them now... */ - do { - tx = list_entry (peer->ksnp_tx_queue.next, - ksock_tx_t, tx_list); - list_del (&tx->tx_list); - list_add_tail (&tx->tx_list, &zombies); - } while (!list_empty (&peer->ksnp_tx_queue)); - } - -#if 0 /* irrelevent with only eager routes */ - if (!route->ksnr_deleted) { - /* make this route least-favourite for re-selection */ - list_del(&route->ksnr_list); - list_add_tail(&route->ksnr_list, &peer->ksnp_routes); - } -#endif - write_unlock_irqrestore (&ksocknal_data.ksnd_global_lock, flags); - - while (!list_empty (&zombies)) { - char ipbuf[PTL_NALFMT_SIZE]; - char ipbuf2[PTL_NALFMT_SIZE]; - tx = list_entry (zombies.next, ksock_tx_t, tx_list); - - CERROR ("Deleting packet type %d len %d ("LPX64" %s->"LPX64" %s)\n", - le32_to_cpu (tx->tx_hdr->type), - le32_to_cpu (tx->tx_hdr->payload_length), - le64_to_cpu (tx->tx_hdr->src_nid), - portals_nid2str(SOCKNAL, - le64_to_cpu(tx->tx_hdr->src_nid), - ipbuf), - le64_to_cpu (tx->tx_hdr->dest_nid), - portals_nid2str(SOCKNAL, - le64_to_cpu(tx->tx_hdr->src_nid), - ipbuf2)); - - list_del (&tx->tx_list); - /* complete now */ - ksocknal_tx_done (tx, 0); - } -} - -int -ksocknal_autoconnectd (void *arg) -{ - long id = (long)arg; - char name[16]; - unsigned long flags; - ksock_route_t *route; - int rc; - - snprintf (name, sizeof (name), "ksocknal_ad%02ld", id); - kportal_daemonize (name); - kportal_blockallsigs (); - - spin_lock_irqsave (&ksocknal_data.ksnd_autoconnectd_lock, flags); - - while (!ksocknal_data.ksnd_shuttingdown) { - - if (!list_empty (&ksocknal_data.ksnd_autoconnectd_routes)) { - route = list_entry (ksocknal_data.ksnd_autoconnectd_routes.next, - ksock_route_t, ksnr_connect_list); - - list_del (&route->ksnr_connect_list); - spin_unlock_irqrestore (&ksocknal_data.ksnd_autoconnectd_lock, flags); - - ksocknal_autoconnect (route); - ksocknal_put_route (route); - - spin_lock_irqsave(&ksocknal_data.ksnd_autoconnectd_lock, - flags); - continue; - } - - spin_unlock_irqrestore(&ksocknal_data.ksnd_autoconnectd_lock, - flags); - - rc = wait_event_interruptible(ksocknal_data.ksnd_autoconnectd_waitq, - ksocknal_data.ksnd_shuttingdown || - !list_empty(&ksocknal_data.ksnd_autoconnectd_routes)); - - spin_lock_irqsave(&ksocknal_data.ksnd_autoconnectd_lock, flags); - } - - spin_unlock_irqrestore (&ksocknal_data.ksnd_autoconnectd_lock, flags); - - ksocknal_thread_fini (); - return (0); -} - -ksock_conn_t * -ksocknal_find_timed_out_conn (ksock_peer_t *peer) -{ - /* We're called with a shared lock on ksnd_global_lock */ - ksock_conn_t *conn; - struct list_head *ctmp; - - list_for_each (ctmp, &peer->ksnp_conns) { - conn = list_entry (ctmp, ksock_conn_t, ksnc_list); - - /* Don't need the {get,put}connsock dance to deref ksnc_sock... */ - LASSERT (!conn->ksnc_closing); - - if (conn->ksnc_sock->sk->sk_err != 0) { - /* Something (e.g. failed keepalive) set the socket error */ - atomic_inc (&conn->ksnc_refcount); - CERROR ("Socket error %d: "LPX64" %p %d.%d.%d.%d\n", - conn->ksnc_sock->sk->sk_err, peer->ksnp_nid, - conn, HIPQUAD(conn->ksnc_ipaddr)); - return (conn); - } - - if (conn->ksnc_rx_started && - time_after_eq (jiffies, conn->ksnc_rx_deadline)) { - /* Timed out incomplete incoming message */ - atomic_inc (&conn->ksnc_refcount); - CERROR ("Timed out RX from "LPX64" %p %d.%d.%d.%d\n", - peer->ksnp_nid,conn,HIPQUAD(conn->ksnc_ipaddr)); - return (conn); - } - - if ((!list_empty (&conn->ksnc_tx_queue) || - conn->ksnc_sock->sk->sk_wmem_queued != 0) && - time_after_eq (jiffies, conn->ksnc_tx_deadline)) { - /* Timed out messages queued for sending or - * buffered in the socket's send buffer */ - atomic_inc (&conn->ksnc_refcount); - CERROR ("Timed out TX to "LPX64" %s%d %p %d.%d.%d.%d\n", - peer->ksnp_nid, - list_empty (&conn->ksnc_tx_queue) ? "" : "Q ", - conn->ksnc_sock->sk->sk_wmem_queued, conn, - HIPQUAD(conn->ksnc_ipaddr)); - return (conn); - } - } - - return (NULL); -} - -void -ksocknal_check_peer_timeouts (int idx) -{ - struct list_head *peers = &ksocknal_data.ksnd_peers[idx]; - struct list_head *ptmp; - ksock_peer_t *peer; - ksock_conn_t *conn; - - again: - /* NB. We expect to have a look at all the peers and not find any - * connections to time out, so we just use a shared lock while we - * take a look... */ - read_lock (&ksocknal_data.ksnd_global_lock); - - list_for_each (ptmp, peers) { - peer = list_entry (ptmp, ksock_peer_t, ksnp_list); - conn = ksocknal_find_timed_out_conn (peer); - - if (conn != NULL) { - read_unlock (&ksocknal_data.ksnd_global_lock); - - CERROR ("Timeout out conn->"LPX64" ip %d.%d.%d.%d:%d\n", - peer->ksnp_nid, - HIPQUAD(conn->ksnc_ipaddr), - conn->ksnc_port); - ksocknal_close_conn_and_siblings (conn, -ETIMEDOUT); - - /* NB we won't find this one again, but we can't - * just proceed with the next peer, since we dropped - * ksnd_global_lock and it might be dead already! */ - ksocknal_put_conn (conn); - goto again; - } - } - - read_unlock (&ksocknal_data.ksnd_global_lock); -} - -int -ksocknal_reaper (void *arg) -{ - wait_queue_t wait; - unsigned long flags; - ksock_conn_t *conn; - ksock_sched_t *sched; - struct list_head enomem_conns; - int nenomem_conns; - int timeout; - int i; - int peer_index = 0; - unsigned long deadline = jiffies; - - kportal_daemonize ("ksocknal_reaper"); - kportal_blockallsigs (); - - INIT_LIST_HEAD(&enomem_conns); - init_waitqueue_entry (&wait, current); - - spin_lock_irqsave (&ksocknal_data.ksnd_reaper_lock, flags); - - while (!ksocknal_data.ksnd_shuttingdown) { - - if (!list_empty (&ksocknal_data.ksnd_deathrow_conns)) { - conn = list_entry (ksocknal_data.ksnd_deathrow_conns.next, - ksock_conn_t, ksnc_list); - list_del (&conn->ksnc_list); - - spin_unlock_irqrestore (&ksocknal_data.ksnd_reaper_lock, flags); - - ksocknal_terminate_conn (conn); - ksocknal_put_conn (conn); - - spin_lock_irqsave (&ksocknal_data.ksnd_reaper_lock, flags); - continue; - } - - if (!list_empty (&ksocknal_data.ksnd_zombie_conns)) { - conn = list_entry (ksocknal_data.ksnd_zombie_conns.next, - ksock_conn_t, ksnc_list); - list_del (&conn->ksnc_list); - - spin_unlock_irqrestore (&ksocknal_data.ksnd_reaper_lock, flags); - - ksocknal_destroy_conn (conn); - - spin_lock_irqsave (&ksocknal_data.ksnd_reaper_lock, flags); - continue; - } - - if (!list_empty (&ksocknal_data.ksnd_enomem_conns)) { - list_add(&enomem_conns, &ksocknal_data.ksnd_enomem_conns); - list_del_init(&ksocknal_data.ksnd_enomem_conns); - } - - spin_unlock_irqrestore (&ksocknal_data.ksnd_reaper_lock, flags); - - /* reschedule all the connections that stalled with ENOMEM... */ - nenomem_conns = 0; - while (!list_empty (&enomem_conns)) { - conn = list_entry (enomem_conns.next, - ksock_conn_t, ksnc_tx_list); - list_del (&conn->ksnc_tx_list); - - sched = conn->ksnc_scheduler; - - spin_lock_irqsave (&sched->kss_lock, flags); - - LASSERT (conn->ksnc_tx_scheduled); - conn->ksnc_tx_ready = 1; - list_add_tail (&conn->ksnc_tx_list, &sched->kss_tx_conns); - wake_up (&sched->kss_waitq); - - spin_unlock_irqrestore (&sched->kss_lock, flags); - nenomem_conns++; - } - - /* careful with the jiffy wrap... */ - while ((timeout = (int)(deadline - jiffies)) <= 0) { - const int n = 4; - const int p = 1; - int chunk = ksocknal_data.ksnd_peer_hash_size; - - /* Time to check for timeouts on a few more peers: I do - * checks every 'p' seconds on a proportion of the peer - * table and I need to check every connection 'n' times - * within a timeout interval, to ensure I detect a - * timeout on any connection within (n+1)/n times the - * timeout interval. */ - - if (ksocknal_tunables.ksnd_io_timeout > n * p) - chunk = (chunk * n * p) / - ksocknal_tunables.ksnd_io_timeout; - if (chunk == 0) - chunk = 1; - - for (i = 0; i < chunk; i++) { - ksocknal_check_peer_timeouts (peer_index); - peer_index = (peer_index + 1) % - ksocknal_data.ksnd_peer_hash_size; - } - - deadline += p * HZ; - } - - if (nenomem_conns != 0) { - /* Reduce my timeout if I rescheduled ENOMEM conns. - * This also prevents me getting woken immediately - * if any go back on my enomem list. */ - timeout = SOCKNAL_ENOMEM_RETRY; - } - ksocknal_data.ksnd_reaper_waketime = jiffies + timeout; - - set_current_state (TASK_INTERRUPTIBLE); - add_wait_queue (&ksocknal_data.ksnd_reaper_waitq, &wait); - - if (!ksocknal_data.ksnd_shuttingdown && - list_empty (&ksocknal_data.ksnd_deathrow_conns) && - list_empty (&ksocknal_data.ksnd_zombie_conns)) - schedule_timeout (timeout); - - set_current_state (TASK_RUNNING); - remove_wait_queue (&ksocknal_data.ksnd_reaper_waitq, &wait); - - spin_lock_irqsave (&ksocknal_data.ksnd_reaper_lock, flags); - } - - spin_unlock_irqrestore (&ksocknal_data.ksnd_reaper_lock, flags); - - ksocknal_thread_fini (); - return (0); -} - -lib_nal_t ksocknal_lib = { - libnal_data: &ksocknal_data, /* NAL private data */ - libnal_send: ksocknal_send, - libnal_send_pages: ksocknal_send_pages, - libnal_recv: ksocknal_recv, - libnal_recv_pages: ksocknal_recv_pages, - libnal_dist: ksocknal_dist -}; diff --git a/lnet/libcfs/.cvsignore b/lnet/libcfs/.cvsignore deleted file mode 100644 index c6f0aa4..0000000 --- a/lnet/libcfs/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -Makefile -link-stamp -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/libcfs/Makefile.in b/lnet/libcfs/Makefile.in deleted file mode 100644 index 15fff12..0000000 --- a/lnet/libcfs/Makefile.in +++ /dev/null @@ -1,4 +0,0 @@ -MODULES = libcfs -libcfs-objs := debug.o lwt.o module.o proc.o tracefile.o watchdog.o - -@INCLUDE_RULES@ diff --git a/lnet/libcfs/Makefile.mk b/lnet/libcfs/Makefile.mk deleted file mode 100644 index 8ecf3c9..0000000 --- a/lnet/libcfs/Makefile.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include fs/lustre/portals/Kernelenv - -obj-y += libcfs.o -libcfs-objs := module.o proc.o debug.o lwt.o tracefile.o diff --git a/lnet/libcfs/autoMakefile.am b/lnet/libcfs/autoMakefile.am deleted file mode 100644 index 9c27693..0000000 --- a/lnet/libcfs/autoMakefile.am +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (C) 2001, 2002 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -modulenet_DATA := libcfs$(KMODEXT) -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(libcfs-objs:%.o=%.c) tracefile.h diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c deleted file mode 100644 index b5286fc..0000000 --- a/lnet/libcfs/debug.c +++ /dev/null @@ -1,336 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * Author: Phil Schwan - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -# define DEBUG_SUBSYSTEM S_PORTALS - -#include -#include -#include - -#include "tracefile.h" - -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) -#include -#endif - -unsigned int portal_subsystem_debug = ~0 - (S_PORTALS | S_NAL); -EXPORT_SYMBOL(portal_subsystem_debug); - -unsigned int portal_debug = (D_WARNING | D_DLMTRACE | D_ERROR | D_EMERG | D_HA | - D_RPCTRACE | D_VFSTRACE); -EXPORT_SYMBOL(portal_debug); - -unsigned int portal_printk; -EXPORT_SYMBOL(portal_printk); - -unsigned int portal_stack; -EXPORT_SYMBOL(portal_stack); - -#ifdef __KERNEL__ -atomic_t portal_kmemory = ATOMIC_INIT(0); -EXPORT_SYMBOL(portal_kmemory); -#endif - -static DECLARE_WAIT_QUEUE_HEAD(debug_ctlwq); - -char debug_file_path[1024] = "/tmp/lustre-log"; -static char debug_file_name[1024]; -static int handled_panic; /* to avoid recursive calls to notifiers */ -char portals_upcall[1024] = "/usr/lib/lustre/portals_upcall"; - -void portals_debug_dumplog_internal(void *arg) -{ - void *journal_info = current->journal_info; - current->journal_info = NULL; - - snprintf(debug_file_name, sizeof(debug_file_path) - 1, - "%s.%ld.%ld", debug_file_path, CURRENT_SECONDS, (long)arg); - printk(KERN_ALERT "LustreError: dumping log to %s\n", debug_file_name); - tracefile_dump_all_pages(debug_file_name); - - current->journal_info = journal_info; -} - -int portals_debug_dumplog_thread(void *arg) -{ - kportal_daemonize(""); - reparent_to_init(); - portals_debug_dumplog_internal(arg); - wake_up(&debug_ctlwq); - return 0; -} - -void portals_debug_dumplog(void) -{ - int rc; - DECLARE_WAITQUEUE(wait, current); - ENTRY; - - /* we're being careful to ensure that the kernel thread is - * able to set our state to running as it exits before we - * get to schedule() */ - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&debug_ctlwq, &wait); - - rc = kernel_thread(portals_debug_dumplog_thread, - (void *)(long)current->pid, - CLONE_VM | CLONE_FS | CLONE_FILES); - if (rc < 0) - printk(KERN_ERR "LustreError: cannot start log dump thread: " - "%d\n", rc); - else - schedule(); - - /* be sure to teardown if kernel_thread() failed */ - remove_wait_queue(&debug_ctlwq, &wait); - set_current_state(TASK_RUNNING); -} - -static int panic_dumplog(struct notifier_block *self, unsigned long unused1, - void *unused2) -{ - if (handled_panic) - return 0; - else - handled_panic = 1; - - if (in_interrupt()) { - trace_debug_print(); - return 0; - } - - while (current->lock_depth >= 0) - unlock_kernel(); - portals_debug_dumplog(); - return 0; -} - -static struct notifier_block lustre_panic_notifier = { - notifier_call : panic_dumplog, - next : NULL, - priority : 10000 -}; - -int portals_debug_init(unsigned long bufsize) -{ - notifier_chain_register(&panic_notifier_list, &lustre_panic_notifier); - return tracefile_init(); -} - -int portals_debug_cleanup(void) -{ - tracefile_exit(); - notifier_chain_unregister(&panic_notifier_list, &lustre_panic_notifier); - return 0; -} - -int portals_debug_clear_buffer(void) -{ - trace_flush_pages(); - return 0; -} - -/* Debug markers, although printed by S_PORTALS - * should not be be marked as such. */ -#undef DEBUG_SUBSYSTEM -#define DEBUG_SUBSYSTEM S_UNDEFINED -int portals_debug_mark_buffer(char *text) -{ - CDEBUG(D_TRACE,"***************************************************\n"); - CDEBUG(D_WARNING, "DEBUG MARKER: %s\n", text); - CDEBUG(D_TRACE,"***************************************************\n"); - - return 0; -} -#undef DEBUG_SUBSYSTEM -#define DEBUG_SUBSYSTEM S_PORTALS - -void portals_debug_set_level(unsigned int debug_level) -{ - printk(KERN_WARNING "Lustre: Setting portals debug level to %08x\n", - debug_level); - portal_debug = debug_level; -} - -void portals_run_upcall(char **argv) -{ - int rc; - int argc; - char *envp[] = { - "HOME=/", - "PATH=/sbin:/bin:/usr/sbin:/usr/bin", - NULL}; - ENTRY; - - argv[0] = portals_upcall; - argc = 1; - while (argv[argc] != NULL) - argc++; - - LASSERT(argc >= 2); - - rc = USERMODEHELPER(argv[0], argv, envp); - if (rc < 0) { - CERROR("Error %d invoking portals upcall %s %s%s%s%s%s%s%s%s; " - "check /proc/sys/portals/upcall\n", - rc, argv[0], argv[1], - argc < 3 ? "" : ",", argc < 3 ? "" : argv[2], - argc < 4 ? "" : ",", argc < 4 ? "" : argv[3], - argc < 5 ? "" : ",", argc < 5 ? "" : argv[4], - argc < 6 ? "" : ",..."); - } else { - CERROR("Invoked portals upcall %s %s%s%s%s%s%s%s%s\n", - argv[0], argv[1], - argc < 3 ? "" : ",", argc < 3 ? "" : argv[2], - argc < 4 ? "" : ",", argc < 4 ? "" : argv[3], - argc < 5 ? "" : ",", argc < 5 ? "" : argv[4], - argc < 6 ? "" : ",..."); - } -} - -void portals_run_lbug_upcall(char *file, const char *fn, const int line) -{ - char *argv[6]; - char buf[32]; - - ENTRY; - snprintf (buf, sizeof buf, "%d", line); - - argv[1] = "LBUG"; - argv[2] = file; - argv[3] = (char *)fn; - argv[4] = buf; - argv[5] = NULL; - - portals_run_upcall (argv); -} - -char *portals_nid2str(int nal, ptl_nid_t nid, char *str) -{ - if (nid == PTL_NID_ANY) { - snprintf(str, PTL_NALFMT_SIZE, "%s", "PTL_NID_ANY"); - return str; - } - - switch(nal){ -/* XXX this could be a nal method of some sort, 'cept it's config - * dependent whether (say) socknal NIDs are actually IP addresses... */ -#if !CRAY_PORTALS - case TCPNAL: - /* userspace NAL */ - case IIBNAL: - case OPENIBNAL: - case RANAL: - case SOCKNAL: - snprintf(str, PTL_NALFMT_SIZE, "%u:%u.%u.%u.%u", - (__u32)(nid >> 32), HIPQUAD(nid)); - break; - case QSWNAL: - case GMNAL: - case LONAL: - snprintf(str, PTL_NALFMT_SIZE, "%u:%u", - (__u32)(nid >> 32), (__u32)nid); - break; -#endif - default: - snprintf(str, PTL_NALFMT_SIZE, "?%x? %llx", - nal, (long long)nid); - break; - } - return str; -} - -char *portals_id2str(int nal, ptl_process_id_t id, char *str) -{ - int len; - - portals_nid2str(nal, id.nid, str); - len = strlen(str); - snprintf(str + len, PTL_NALFMT_SIZE - len, "-%u", id.pid); - return str; -} - -#ifdef __KERNEL__ - -void portals_debug_dumpstack(struct task_struct *tsk) -{ -#if defined(__arch_um__) - if (tsk != NULL) - CWARN("stack dump for pid %d (%d) requested; wake up gdb.\n", - tsk->pid, UML_PID(tsk)); - asm("int $3"); -#elif defined(HAVE_SHOW_TASK) - /* this is exported by lustre kernel version 42 */ - extern void show_task(struct task_struct *); - - if (tsk == NULL) - tsk = current; - CWARN("showing stack for process %d\n", tsk->pid); - show_task(tsk); -#else - CWARN("can't show stack: kernel doesn't export show_task\n"); -#endif -} - -struct task_struct *portals_current(void) -{ - CWARN("current task struct is %p\n", current); - return current; -} - -EXPORT_SYMBOL(portals_debug_dumpstack); -EXPORT_SYMBOL(portals_current); -#endif /* __KERNEL__ */ - -EXPORT_SYMBOL(portals_debug_dumplog); -EXPORT_SYMBOL(portals_debug_set_level); -EXPORT_SYMBOL(portals_run_upcall); -EXPORT_SYMBOL(portals_run_lbug_upcall); -EXPORT_SYMBOL(portals_nid2str); -EXPORT_SYMBOL(portals_id2str); diff --git a/lnet/libcfs/lwt.c b/lnet/libcfs/lwt.c deleted file mode 100644 index 3f6a9c2..0000000 --- a/lnet/libcfs/lwt.c +++ /dev/null @@ -1,268 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2003 Cluster File Systems, Inc. - * Author: Eric Barton - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_PORTALS - -#include - -#if LWT_SUPPORT - -#if !KLWT_SUPPORT -int lwt_enabled; -lwt_cpu_t lwt_cpus[NR_CPUS]; -#endif - -int lwt_pages_per_cpu; - -/* NB only root is allowed to retrieve LWT info; it's an open door into the - * kernel... */ - -int -lwt_lookup_string (int *size, char *knl_ptr, - char *user_ptr, int user_size) -{ - int maxsize = 128; - - /* knl_ptr was retrieved from an LWT snapshot and the caller wants to - * turn it into a string. NB we can crash with an access violation - * trying to determine the string length, so we're trusting our - * caller... */ - - if (!capable(CAP_SYS_ADMIN)) - return (-EPERM); - - if (user_size > 0 && - maxsize > user_size) - maxsize = user_size; - - *size = strnlen (knl_ptr, maxsize - 1) + 1; - - if (user_ptr != NULL) { - if (user_size < 4) - return (-EINVAL); - - if (copy_to_user (user_ptr, knl_ptr, *size)) - return (-EFAULT); - - /* Did I truncate the string? */ - if (knl_ptr[*size - 1] != 0) - copy_to_user (user_ptr + *size - 4, "...", 4); - } - - return (0); -} - -int -lwt_control (int enable, int clear) -{ - lwt_page_t *p; - int i; - int j; - - if (!capable(CAP_SYS_ADMIN)) - return (-EPERM); - - if (!enable) { - LWT_EVENT(0,0,0,0); - lwt_enabled = 0; - mb(); - /* give people some time to stop adding traces */ - schedule_timeout(10); - } - - for (i = 0; i < num_online_cpus(); i++) { - p = lwt_cpus[i].lwtc_current_page; - - if (p == NULL) - return (-ENODATA); - - if (!clear) - continue; - - for (j = 0; j < lwt_pages_per_cpu; j++) { - memset (p->lwtp_events, 0, PAGE_SIZE); - - p = list_entry (p->lwtp_list.next, - lwt_page_t, lwtp_list); - } - } - - if (enable) { - lwt_enabled = 1; - mb(); - LWT_EVENT(0,0,0,0); - } - - return (0); -} - -int -lwt_snapshot (cycles_t *now, int *ncpu, int *total_size, - void *user_ptr, int user_size) -{ - const int events_per_page = PAGE_SIZE / sizeof(lwt_event_t); - const int bytes_per_page = events_per_page * sizeof(lwt_event_t); - lwt_page_t *p; - int i; - int j; - - if (!capable(CAP_SYS_ADMIN)) - return (-EPERM); - - *ncpu = num_online_cpus(); - *total_size = num_online_cpus() * lwt_pages_per_cpu * bytes_per_page; - *now = get_cycles(); - - if (user_ptr == NULL) - return (0); - - for (i = 0; i < num_online_cpus(); i++) { - p = lwt_cpus[i].lwtc_current_page; - - if (p == NULL) - return (-ENODATA); - - for (j = 0; j < lwt_pages_per_cpu; j++) { - if (copy_to_user(user_ptr, p->lwtp_events, - bytes_per_page)) - return (-EFAULT); - - user_ptr = ((char *)user_ptr) + bytes_per_page; - p = list_entry(p->lwtp_list.next, - lwt_page_t, lwtp_list); - - } - } - - return (0); -} - -int -lwt_init () -{ - int i; - int j; - - for (i = 0; i < num_online_cpus(); i++) - if (lwt_cpus[i].lwtc_current_page != NULL) - return (-EALREADY); - - LASSERT (!lwt_enabled); - - /* NULL pointers, zero scalars */ - memset (lwt_cpus, 0, sizeof (lwt_cpus)); - lwt_pages_per_cpu = LWT_MEMORY / (num_online_cpus() * PAGE_SIZE); - - for (i = 0; i < num_online_cpus(); i++) - for (j = 0; j < lwt_pages_per_cpu; j++) { - struct page *page = alloc_page (GFP_KERNEL); - lwt_page_t *lwtp; - - if (page == NULL) { - CERROR ("Can't allocate page\n"); - lwt_fini (); - return (-ENOMEM); - } - - PORTAL_ALLOC(lwtp, sizeof (*lwtp)); - if (lwtp == NULL) { - CERROR ("Can't allocate lwtp\n"); - __free_page(page); - lwt_fini (); - return (-ENOMEM); - } - - lwtp->lwtp_page = page; - lwtp->lwtp_events = page_address(page); - memset (lwtp->lwtp_events, 0, PAGE_SIZE); - - if (j == 0) { - INIT_LIST_HEAD (&lwtp->lwtp_list); - lwt_cpus[i].lwtc_current_page = lwtp; - } else { - list_add (&lwtp->lwtp_list, - &lwt_cpus[i].lwtc_current_page->lwtp_list); - } - } - - lwt_enabled = 1; - mb(); - - LWT_EVENT(0,0,0,0); - - return (0); -} - -void -lwt_fini () -{ - int i; - - lwt_control(0, 0); - - for (i = 0; i < num_online_cpus(); i++) - while (lwt_cpus[i].lwtc_current_page != NULL) { - lwt_page_t *lwtp = lwt_cpus[i].lwtc_current_page; - - if (list_empty (&lwtp->lwtp_list)) { - lwt_cpus[i].lwtc_current_page = NULL; - } else { - lwt_cpus[i].lwtc_current_page = - list_entry (lwtp->lwtp_list.next, - lwt_page_t, lwtp_list); - - list_del (&lwtp->lwtp_list); - } - - __free_page (lwtp->lwtp_page); - PORTAL_FREE (lwtp, sizeof (*lwtp)); - } -} - -EXPORT_SYMBOL(lwt_enabled); -EXPORT_SYMBOL(lwt_cpus); - -EXPORT_SYMBOL(lwt_init); -EXPORT_SYMBOL(lwt_fini); -EXPORT_SYMBOL(lwt_lookup_string); -EXPORT_SYMBOL(lwt_control); -EXPORT_SYMBOL(lwt_snapshot); -#endif diff --git a/lnet/libcfs/module.c b/lnet/libcfs/module.c deleted file mode 100644 index 2a8e6f6..0000000 --- a/lnet/libcfs/module.c +++ /dev/null @@ -1,608 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif -#define DEBUG_SUBSYSTEM S_PORTALS - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define PORTAL_MINOR 240 - -struct nal_cmd_handler { - int nch_number; - nal_cmd_handler_fn *nch_handler; - void *nch_private; -}; - -static struct nal_cmd_handler nal_cmd[16]; -static DECLARE_MUTEX(nal_cmd_sem); - -#ifdef PORTAL_DEBUG -void kportal_assertion_failed(char *expr, char *file, const char *func, - const int line) -{ - portals_debug_msg(0, D_EMERG, file, func, line, CDEBUG_STACK, - "ASSERTION(%s) failed\n", expr); - LBUG_WITH_LOC(file, func, line); -} -#endif - -void -kportal_daemonize (char *str) -{ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,63)) - daemonize(str); -#else - daemonize(); - snprintf (current->comm, sizeof (current->comm), "%s", str); -#endif -} - -void -kportal_memhog_free (struct portals_device_userstate *pdu) -{ - struct page **level0p = &pdu->pdu_memhog_root_page; - struct page **level1p; - struct page **level2p; - int count1; - int count2; - - if (*level0p != NULL) { - - level1p = (struct page **)page_address(*level0p); - count1 = 0; - - while (count1 < PAGE_SIZE/sizeof(struct page *) && - *level1p != NULL) { - - level2p = (struct page **)page_address(*level1p); - count2 = 0; - - while (count2 < PAGE_SIZE/sizeof(struct page *) && - *level2p != NULL) { - - __free_page(*level2p); - pdu->pdu_memhog_pages--; - level2p++; - count2++; - } - - __free_page(*level1p); - pdu->pdu_memhog_pages--; - level1p++; - count1++; - } - - __free_page(*level0p); - pdu->pdu_memhog_pages--; - - *level0p = NULL; - } - - LASSERT (pdu->pdu_memhog_pages == 0); -} - -int -kportal_memhog_alloc (struct portals_device_userstate *pdu, int npages, int flags) -{ - struct page **level0p; - struct page **level1p; - struct page **level2p; - int count1; - int count2; - - LASSERT (pdu->pdu_memhog_pages == 0); - LASSERT (pdu->pdu_memhog_root_page == NULL); - - if (npages < 0) - return -EINVAL; - - if (npages == 0) - return 0; - - level0p = &pdu->pdu_memhog_root_page; - *level0p = alloc_page(flags); - if (*level0p == NULL) - return -ENOMEM; - pdu->pdu_memhog_pages++; - - level1p = (struct page **)page_address(*level0p); - count1 = 0; - memset(level1p, 0, PAGE_SIZE); - - while (pdu->pdu_memhog_pages < npages && - count1 < PAGE_SIZE/sizeof(struct page *)) { - - if (signal_pending(current)) - return (-EINTR); - - *level1p = alloc_page(flags); - if (*level1p == NULL) - return -ENOMEM; - pdu->pdu_memhog_pages++; - - level2p = (struct page **)page_address(*level1p); - count2 = 0; - memset(level2p, 0, PAGE_SIZE); - - while (pdu->pdu_memhog_pages < npages && - count2 < PAGE_SIZE/sizeof(struct page *)) { - - if (signal_pending(current)) - return (-EINTR); - - *level2p = alloc_page(flags); - if (*level2p == NULL) - return (-ENOMEM); - pdu->pdu_memhog_pages++; - - level2p++; - count2++; - } - - level1p++; - count1++; - } - - return 0; -} - -void -kportal_blockallsigs () -{ - unsigned long flags; - - SIGNAL_MASK_LOCK(current, flags); - sigfillset(¤t->blocked); - RECALC_SIGPENDING; - SIGNAL_MASK_UNLOCK(current, flags); -} - -/* called when opening /dev/device */ -static int libcfs_psdev_open(struct inode * inode, struct file * file) -{ - struct portals_device_userstate *pdu; - ENTRY; - - if (!inode) - RETURN(-EINVAL); - - PORTAL_MODULE_USE; - - PORTAL_ALLOC(pdu, sizeof(*pdu)); - if (pdu != NULL) { - pdu->pdu_memhog_pages = 0; - pdu->pdu_memhog_root_page = NULL; - } - file->private_data = pdu; - - RETURN(0); -} - -/* called when closing /dev/device */ -static int libcfs_psdev_release(struct inode * inode, struct file * file) -{ - struct portals_device_userstate *pdu; - ENTRY; - - if (!inode) - RETURN(-EINVAL); - - pdu = file->private_data; - if (pdu != NULL) { - kportal_memhog_free(pdu); - PORTAL_FREE(pdu, sizeof(*pdu)); - } - - PORTAL_MODULE_UNUSE; - RETURN(0); -} - -static inline void freedata(void *data, int len) -{ - PORTAL_FREE(data, len); -} - -struct nal_cmd_handler * -libcfs_find_nal_cmd_handler(int nal) -{ - int i; - - for (i = 0; i < sizeof(nal_cmd)/sizeof(nal_cmd[0]); i++) - if (nal_cmd[i].nch_handler != NULL && - nal_cmd[i].nch_number == nal) - return (&nal_cmd[i]); - - return (NULL); -} - -int -libcfs_nal_cmd_register(int nal, nal_cmd_handler_fn *handler, void *private) -{ - struct nal_cmd_handler *cmd; - int i; - int rc; - - CDEBUG(D_IOCTL, "Register NAL %x, handler: %p\n", nal, handler); - - down(&nal_cmd_sem); - - if (libcfs_find_nal_cmd_handler(nal) != NULL) { - up (&nal_cmd_sem); - return (-EBUSY); - } - - cmd = NULL; - for (i = 0; i < sizeof(nal_cmd)/sizeof(nal_cmd[0]); i++) - if (nal_cmd[i].nch_handler == NULL) { - cmd = &nal_cmd[i]; - break; - } - - if (cmd == NULL) { - rc = -EBUSY; - } else { - rc = 0; - cmd->nch_number = nal; - cmd->nch_handler = handler; - cmd->nch_private = private; - } - - up(&nal_cmd_sem); - - return rc; -} -EXPORT_SYMBOL(libcfs_nal_cmd_register); - -void -libcfs_nal_cmd_unregister(int nal) -{ - struct nal_cmd_handler *cmd; - - CDEBUG(D_IOCTL, "Unregister NAL %x\n", nal); - - down(&nal_cmd_sem); - cmd = libcfs_find_nal_cmd_handler(nal); - LASSERT (cmd != NULL); - cmd->nch_handler = NULL; - cmd->nch_private = NULL; - up(&nal_cmd_sem); -} -EXPORT_SYMBOL(libcfs_nal_cmd_unregister); - -int -libcfs_nal_cmd(struct portals_cfg *pcfg) -{ -#if CRAY_PORTALS - /* pretend success */ - RETURN(0); -#else - struct nal_cmd_handler *cmd; - __u32 nal = pcfg->pcfg_nal; - int rc = -EINVAL; - ENTRY; - - down(&nal_cmd_sem); - cmd = libcfs_find_nal_cmd_handler(nal); - if (cmd != NULL) { - CDEBUG(D_IOCTL, "calling handler nal: %x, cmd: %d\n", nal, - pcfg->pcfg_command); - rc = cmd->nch_handler(pcfg, cmd->nch_private); - } else { - CERROR("invalid nal: %x, cmd: %d\n", nal, pcfg->pcfg_command); - } - up(&nal_cmd_sem); - - RETURN(rc); -#endif -} -EXPORT_SYMBOL(libcfs_nal_cmd); - -static DECLARE_RWSEM(ioctl_list_sem); -static LIST_HEAD(ioctl_list); - -int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand) -{ - int rc = 0; - down_read(&ioctl_list_sem); - if (!list_empty(&hand->item)) - rc = -EBUSY; - up_read(&ioctl_list_sem); - - if (rc == 0) { - down_write(&ioctl_list_sem); - list_add_tail(&hand->item, &ioctl_list); - up_write(&ioctl_list_sem); - } - RETURN(0); -} -EXPORT_SYMBOL(libcfs_register_ioctl); - -int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand) -{ - int rc = 0; - down_read(&ioctl_list_sem); - if (list_empty(&hand->item)) - rc = -ENOENT; - up_read(&ioctl_list_sem); - - if (rc == 0) { - down_write(&ioctl_list_sem); - list_del_init(&hand->item); - up_write(&ioctl_list_sem); - } - RETURN(0); -} -EXPORT_SYMBOL(libcfs_deregister_ioctl); - -static int libcfs_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - int err = -EINVAL; - char buf[1024]; - struct portal_ioctl_data *data; - ENTRY; - - if (current->fsuid != 0) - RETURN(err = -EACCES); - - if ( _IOC_TYPE(cmd) != IOC_PORTAL_TYPE || - _IOC_NR(cmd) < IOC_PORTAL_MIN_NR || - _IOC_NR(cmd) > IOC_PORTAL_MAX_NR ) { - CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n", - _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd)); - RETURN(-EINVAL); - } - - if (portal_ioctl_getdata(buf, buf + 800, (void *)arg)) { - CERROR("PORTALS ioctl: data error\n"); - RETURN(-EINVAL); - } - - data = (struct portal_ioctl_data *)buf; - - switch (cmd) { - case IOC_PORTAL_CLEAR_DEBUG: - portals_debug_clear_buffer(); - RETURN(0); - case IOC_PORTAL_PANIC: - if (!capable (CAP_SYS_BOOT)) - RETURN (-EPERM); - panic("debugctl-invoked panic"); - RETURN(0); - case IOC_PORTAL_MARK_DEBUG: - if (data->ioc_inlbuf1 == NULL || - data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') - RETURN(-EINVAL); - portals_debug_mark_buffer(data->ioc_inlbuf1); - RETURN(0); -#if LWT_SUPPORT - case IOC_PORTAL_LWT_CONTROL: - err = lwt_control (data->ioc_flags, data->ioc_misc); - break; - - case IOC_PORTAL_LWT_SNAPSHOT: { - cycles_t now; - int ncpu; - int total_size; - - err = lwt_snapshot (&now, &ncpu, &total_size, - data->ioc_pbuf1, data->ioc_plen1); - data->ioc_nid = now; - data->ioc_count = ncpu; - data->ioc_misc = total_size; - - /* Hedge against broken user/kernel typedefs (e.g. cycles_t) */ - data->ioc_nid2 = sizeof(lwt_event_t); - data->ioc_nid3 = offsetof(lwt_event_t, lwte_where); - - if (err == 0 && - copy_to_user((char *)arg, data, sizeof (*data))) - err = -EFAULT; - break; - } - - case IOC_PORTAL_LWT_LOOKUP_STRING: - err = lwt_lookup_string (&data->ioc_count, data->ioc_pbuf1, - data->ioc_pbuf2, data->ioc_plen2); - if (err == 0 && - copy_to_user((char *)arg, data, sizeof (*data))) - err = -EFAULT; - break; -#endif - case IOC_PORTAL_NAL_CMD: { - struct portals_cfg pcfg; - - if (data->ioc_plen1 != sizeof(pcfg)) { - CERROR("Bad ioc_plen1 %d (wanted %d)\n", - data->ioc_plen1, sizeof(pcfg)); - err = -EINVAL; - break; - } - - if (copy_from_user(&pcfg, (void *)data->ioc_pbuf1, - sizeof(pcfg))) { - err = -EFAULT; - break; - } - - CDEBUG (D_IOCTL, "nal command nal %x cmd %d\n", pcfg.pcfg_nal, - pcfg.pcfg_command); - err = libcfs_nal_cmd(&pcfg); - - if (err == 0 && - copy_to_user((char *)data->ioc_pbuf1, &pcfg, - sizeof (pcfg))) - err = -EFAULT; - break; - } - - case IOC_PORTAL_MEMHOG: - if (!capable (CAP_SYS_ADMIN)) - err = -EPERM; - else if (file->private_data == NULL) { - err = -EINVAL; - } else { - kportal_memhog_free(file->private_data); - err = kportal_memhog_alloc(file->private_data, - data->ioc_count, - data->ioc_flags); - if (err != 0) - kportal_memhog_free(file->private_data); - } - break; - - default: { - struct libcfs_ioctl_handler *hand; - err = -EINVAL; - down_read(&ioctl_list_sem); - list_for_each_entry(hand, &ioctl_list, item) { - err = hand->handle_ioctl(data, cmd, arg); - if (err != -EINVAL) - break; - } - up_read(&ioctl_list_sem); - } break; - } - - RETURN(err); -} - - -static struct file_operations libcfs_fops = { - ioctl: libcfs_ioctl, - open: libcfs_psdev_open, - release: libcfs_psdev_release -}; - - -static struct miscdevice libcfs_dev = { - PORTAL_MINOR, - "portals", - &libcfs_fops -}; - -extern int insert_proc(void); -extern void remove_proc(void); -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Portals v3.1"); -MODULE_LICENSE("GPL"); - -static int init_libcfs_module(void) -{ - int rc; - - rc = portals_debug_init(5 * 1024 * 1024); - if (rc < 0) { - printk(KERN_ERR "LustreError: portals_debug_init: %d\n", rc); - return (rc); - } - -#if LWT_SUPPORT - rc = lwt_init(); - if (rc != 0) { - CERROR("lwt_init: error %d\n", rc); - goto cleanup_debug; - } -#endif - rc = misc_register(&libcfs_dev); - if (rc) { - CERROR("misc_register: error %d\n", rc); - goto cleanup_lwt; - } - - rc = insert_proc(); - if (rc) { - CERROR("insert_proc: error %d\n", rc); - goto cleanup_deregister; - } - - CDEBUG (D_OTHER, "portals setup OK\n"); - return (0); - - cleanup_deregister: - misc_deregister(&libcfs_dev); - cleanup_lwt: -#if LWT_SUPPORT - lwt_fini(); - cleanup_debug: -#endif - portals_debug_cleanup(); - return rc; -} - -static void exit_libcfs_module(void) -{ - int rc; - - remove_proc(); - - CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n", - atomic_read(&portal_kmemory)); - - rc = misc_deregister(&libcfs_dev); - if (rc) - CERROR("misc_deregister error %d\n", rc); - -#if LWT_SUPPORT - lwt_fini(); -#endif - - if (atomic_read(&portal_kmemory) != 0) - CERROR("Portals memory leaked: %d bytes\n", - atomic_read(&portal_kmemory)); - - rc = portals_debug_cleanup(); - if (rc) - printk(KERN_ERR "LustreError: portals_debug_cleanup: %d\n", rc); -} - -EXPORT_SYMBOL(kportal_daemonize); -EXPORT_SYMBOL(kportal_blockallsigs); -EXPORT_SYMBOL(kportal_assertion_failed); - -module_init(init_libcfs_module); -module_exit(exit_libcfs_module); diff --git a/lnet/libcfs/proc.c b/lnet/libcfs/proc.c deleted file mode 100644 index 08446a0..0000000 --- a/lnet/libcfs/proc.c +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * Author: Zach Brown - * Author: Peter J. Braam - * Author: Phil Schwan - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -# define DEBUG_SUBSYSTEM S_PORTALS - -#include -#include -#include "tracefile.h" - -static struct ctl_table_header *portals_table_header = NULL; -extern char debug_file_path[1024]; -extern char portals_upcall[1024]; - -#define PSDEV_PORTALS (0x100) -enum { - PSDEV_DEBUG = 1, /* control debugging */ - PSDEV_SUBSYSTEM_DEBUG, /* control debugging */ - PSDEV_PRINTK, /* force all errors to console */ - PSDEV_CONSOLE, /* allow _any_ messages to console */ - PSDEV_DEBUG_PATH, /* crashdump log location */ - PSDEV_DEBUG_DUMP_PATH, /* crashdump tracelog location */ - PSDEV_PORTALS_UPCALL, /* User mode upcall script */ - PSDEV_PORTALS_MEMUSED, /* bytes currently PORTAL_ALLOCated */ -}; - -static struct ctl_table portals_table[] = { - {PSDEV_DEBUG, "debug", &portal_debug, sizeof(int), 0644, NULL, - &proc_dointvec}, - {PSDEV_SUBSYSTEM_DEBUG, "subsystem_debug", &portal_subsystem_debug, - sizeof(int), 0644, NULL, &proc_dointvec}, - {PSDEV_PRINTK, "printk", &portal_printk, sizeof(int), 0644, NULL, - &proc_dointvec}, - {PSDEV_DEBUG_PATH, "debug_path", debug_file_path, - sizeof(debug_file_path), 0644, NULL, &proc_dostring, &sysctl_string}, - {PSDEV_PORTALS_UPCALL, "upcall", portals_upcall, - sizeof(portals_upcall), 0644, NULL, &proc_dostring, - &sysctl_string}, - {PSDEV_PORTALS_MEMUSED, "memused", (int *)&portal_kmemory.counter, - sizeof(int), 0644, NULL, &proc_dointvec}, - {0} -}; - -static struct ctl_table top_table[2] = { - {PSDEV_PORTALS, "portals", NULL, 0, 0555, portals_table}, - {0} -}; - - -#ifdef PORTALS_PROFILING -/* - * profiling stuff. we do this statically for now 'cause its simple, - * but we could do some tricks with elf sections to have this array - * automatically built. - */ -#define def_prof(FOO) [PROF__##FOO] = {#FOO, 0, } - -struct prof_ent prof_ents[] = { - def_prof(our_recvmsg), - def_prof(our_sendmsg), - def_prof(socknal_recv), - def_prof(lib_parse), - def_prof(conn_list_walk), - def_prof(memcpy), - def_prof(lib_finalize), - def_prof(pingcli_time), - def_prof(gmnal_send), - def_prof(gmnal_recv), -}; - -EXPORT_SYMBOL(prof_ents); - -/* - * this function is as crazy as the proc filling api - * requires. - * - * buffer: page allocated for us to scribble in. the - * data returned to the user will be taken from here. - * *start: address of the pointer that will tell the - * caller where in buffer the data the user wants is. - * ppos: offset in the entire /proc file that the user - * currently wants. - * wanted: the amount of data the user wants. - * - * while going, 'curpos' is the offset in the entire - * file where we currently are. We only actually - * start filling buffer when we get to a place in - * the file that the user cares about. - * - * we take care to only sprintf when the user cares because - * we're holding a lock while we do this. - * - * we're smart and know that we generate fixed size lines. - * we only start writing to the buffer when the user cares. - * This is unpredictable because we don't snapshot the - * list between calls that are filling in a file from - * the list. The list could change mid read and the - * output will look very weird indeed. oh well. - */ - -static int prof_read_proc(char *buffer, char **start, off_t ppos, int wanted, - int *eof, void *data) -{ - int len = 0, i; - int curpos; - char *header = "Interval Cycles_per (Starts Finishes Total)\n"; - int header_len = strlen(header); - char *format = "%-15s %.12Ld (%.12d %.12d %.12Ld)"; - int line_len = (15 + 1 + 12 + 2 + 12 + 1 + 12 + 1 + 12 + 1); - - *start = buffer; - - if (ppos < header_len) { - int diff = MIN(header_len, wanted); - memcpy(buffer, header + ppos, diff); - len += diff; - ppos += diff; - } - - if (len >= wanted) - goto out; - - curpos = header_len; - - for ( i = 0; i < MAX_PROFS ; i++) { - int copied; - struct prof_ent *pe = &prof_ents[i]; - long long cycles_per; - /* - * find the part of the array that the buffer wants - */ - if (ppos >= (curpos + line_len)) { - curpos += line_len; - continue; - } - /* the clever caller split a line */ - if (ppos > curpos) { - *start = buffer + (ppos - curpos); - } - - if (pe->finishes == 0) - cycles_per = 0; - else - { - cycles_per = pe->total_cycles; - do_div (cycles_per, pe->finishes); - } - - copied = sprintf(buffer + len, format, pe->str, cycles_per, - pe->starts, pe->finishes, pe->total_cycles); - - len += copied; - - /* pad to line len, -1 for \n */ - if ((copied < line_len-1)) { - int diff = (line_len-1) - copied; - memset(buffer + len, ' ', diff); - len += diff; - copied += diff; - } - - buffer[len++]= '\n'; - - /* bail if we have enough */ - if (((buffer + len) - *start) >= wanted) - break; - - curpos += line_len; - } - - /* lameness */ - if (i == MAX_PROFS) - *eof = 1; - out: - - return MIN(((buffer + len) - *start), wanted); -} - -/* - * all kids love /proc :/ - */ -static unsigned char basedir[]="net/portals"; -#endif /* PORTALS_PROFILING */ - -int insert_proc(void) -{ - struct proc_dir_entry *ent; -#if PORTALS_PROFILING - unsigned char dir[128]; - - if (ARRAY_SIZE(prof_ents) != MAX_PROFS) { - CERROR("profiling enum and array are out of sync.\n"); - return -1; - } - - /* - * This is pretty lame. assuming that failure just - * means that they already existed. - */ - strcat(dir, basedir); - create_proc_entry(dir, S_IFDIR, 0); - - strcat(dir, "/cycles"); - ent = create_proc_entry(dir, 0, 0); - if (!ent) { - CERROR("couldn't register %s?\n", dir); - return -1; - } - - ent->data = NULL; - ent->read_proc = prof_read_proc; -#endif /* PORTALS_PROFILING */ - -#ifdef CONFIG_SYSCTL - if (!portals_table_header) - portals_table_header = register_sysctl_table(top_table, 0); -#endif - - ent = create_proc_entry("sys/portals/dump_kernel", 0, NULL); - if (ent == NULL) { - CERROR("couldn't register dump_kernel\n"); - return -1; - } - ent->write_proc = trace_dk; - - ent = create_proc_entry("sys/portals/daemon_file", 0, NULL); - if (ent == NULL) { - CERROR("couldn't register daemon_file\n"); - return -1; - } - ent->write_proc = trace_write_daemon_file; - ent->read_proc = trace_read_daemon_file; - - ent = create_proc_entry("sys/portals/debug_mb", 0, NULL); - if (ent == NULL) { - CERROR("couldn't register debug_mb\n"); - return -1; - } - ent->write_proc = trace_write_debug_mb; - ent->read_proc = trace_read_debug_mb; - - return 0; -} - -void remove_proc(void) -{ -#if PORTALS_PROFILING - unsigned char dir[128]; - int end; - - dir[0]='\0'; - strcat(dir, basedir); - - end = strlen(dir); - - strcat(dir, "/cycles"); - remove_proc_entry(dir, 0); - - dir[end] = '\0'; - remove_proc_entry(dir, 0); -#endif /* PORTALS_PROFILING */ - - remove_proc_entry("sys/portals/dump_kernel", NULL); - remove_proc_entry("sys/portals/daemon_file", NULL); - remove_proc_entry("sys/portals/debug_mb", NULL); - -#ifdef CONFIG_SYSCTL - if (portals_table_header) - unregister_sysctl_table(portals_table_header); - portals_table_header = NULL; -#endif -} diff --git a/lnet/libcfs/tracefile.c b/lnet/libcfs/tracefile.c deleted file mode 100644 index f0c06e5..0000000 --- a/lnet/libcfs/tracefile.c +++ /dev/null @@ -1,876 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Zach Brown - * Author: Phil Schwan - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_MM_INLINE -#include -#endif - -#define DEBUG_SUBSYSTEM S_PORTALS - -#include -#include -#include - -#define TCD_MAX_PAGES (5 << (20 - PAGE_SHIFT)) - -/* XXX move things up to the top, comment */ - -static union { - struct trace_cpu_data { - struct list_head tcd_pages; - unsigned long tcd_cur_pages; - - struct list_head tcd_daemon_pages; - unsigned long tcd_cur_daemon_pages; - - unsigned long tcd_max_pages; - int tcd_shutting_down; - } tcd; - char __pad[SMP_CACHE_BYTES]; -} trace_data[NR_CPUS] __cacheline_aligned; - -struct page_collection { - struct list_head pc_pages; - spinlock_t pc_lock; - int pc_want_daemon_pages; -}; - -struct tracefiled_ctl { - struct completion tctl_start; - struct completion tctl_stop; - wait_queue_head_t tctl_waitq; - pid_t tctl_pid; - atomic_t tctl_shutdown; -}; - -#define TRACEFILE_SIZE (500 << 20) -static DECLARE_RWSEM(tracefile_sem); -static char *tracefile = NULL; -static long long tracefile_size = TRACEFILE_SIZE; -static struct tracefiled_ctl trace_tctl; -static DECLARE_MUTEX(trace_thread_sem); -static int thread_running = 0; - -#ifndef get_cpu -#define get_cpu() smp_processor_id() -#define put_cpu() do { } while (0) -#endif - -#define trace_get_tcd(FLAGS) ({ \ - struct trace_cpu_data *__ret; \ - int __cpu = get_cpu(); \ - local_irq_save(FLAGS); \ - __ret = &trace_data[__cpu].tcd; \ - __ret; \ -}) - -#define trace_put_tcd(TCD, FLAGS) do { \ - local_irq_restore(FLAGS); \ - put_cpu(); \ -} while (0) - -static void put_pages_on_daemon_list_on_cpu(void *info); - -/* return a page that has 'len' bytes left at the end */ -static struct page *trace_get_page(struct trace_cpu_data *tcd, - unsigned long len) -{ - struct page *page = NULL; - - if (len > PAGE_SIZE) { - printk(KERN_ERR "cowardly refusing to write %lu bytes in a " - "page\n", len); - return NULL; - } - - if (!list_empty(&tcd->tcd_pages)) { - page = list_entry(tcd->tcd_pages.prev, struct page, - PAGE_LIST_ENTRY); - if (page->index + len <= PAGE_SIZE) - return page; - } - - if (tcd->tcd_cur_pages < tcd->tcd_max_pages) { - page = alloc_page(GFP_ATOMIC); - if (page == NULL) { - /* the kernel should print a message for us. fall back - * to using the last page in the ring buffer. */ - goto ring_buffer; - } - page->index = 0; - page->mapping = (void *)(long)smp_processor_id(); - list_add_tail(&PAGE_LIST(page), &tcd->tcd_pages); - tcd->tcd_cur_pages++; - - if (tcd->tcd_cur_pages > 8 && thread_running) { - struct tracefiled_ctl *tctl = &trace_tctl; - wake_up(&tctl->tctl_waitq); - } - return page; - } - - ring_buffer: - if (thread_running) { - int pgcount = tcd->tcd_cur_pages / 10; - struct page_collection pc; - struct list_head *pos, *tmp; - printk(KERN_WARNING "debug daemon buffer overflowed; discarding" - " 10%% of pages (%d)\n", pgcount + 1); - - INIT_LIST_HEAD(&pc.pc_pages); - spin_lock_init(&pc.pc_lock); - - list_for_each_safe(pos, tmp, &tcd->tcd_pages) { - struct page *page; - - if (pgcount-- == 0) - break; - - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - list_del(&PAGE_LIST(page)); - list_add_tail(&PAGE_LIST(page), &pc.pc_pages); - tcd->tcd_cur_pages--; - } - put_pages_on_daemon_list_on_cpu(&pc); - } - LASSERT(!list_empty(&tcd->tcd_pages)); - - page = list_entry(tcd->tcd_pages.next, struct page, PAGE_LIST_ENTRY); - page->index = 0; - - list_del(&PAGE_LIST(page)); - list_add_tail(&PAGE_LIST(page), &tcd->tcd_pages); - return page; -} - -static void print_to_console(struct ptldebug_header *hdr, int mask, char *buf, - int len, char *file, const char *fn) -{ - char *prefix = NULL, *ptype = NULL; - - 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 (portal_printk) { - prefix = "Lustre"; - ptype = KERN_INFO; - } - - 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); -} - -void portals_debug_msg(int subsys, int mask, char *file, const char *fn, - const int line, unsigned long stack, char *format, ...) -{ - struct trace_cpu_data *tcd; - struct ptldebug_header header; - struct page *page; - char *debug_buf = format; - int known_size, needed = 85 /* average message length */, max_nob; - va_list ap; - unsigned long flags; - struct timeval tv; - - if (*(format + strlen(format) - 1) != '\n') - printk(KERN_INFO "format at %s:%d:%s doesn't end in newline\n", - file, line, fn); - - tcd = trace_get_tcd(flags); - if (tcd->tcd_shutting_down) - goto out; - - do_gettimeofday(&tv); - - header.ph_subsys = subsys; - header.ph_mask = mask; - header.ph_cpu_id = smp_processor_id(); - 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; - -#if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)) - header.ph_extern_pid = current->thread.extern_pid; -#elif defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - header.ph_extern_pid = current->thread.mode.tt.extern_pid; -#else - header.ph_extern_pid = 0; -#endif - - known_size = sizeof(header) + strlen(file) + strlen(fn) + 2; // nulls - - retry: - page = trace_get_page(tcd, needed + known_size); - if (page == NULL) { - debug_buf = format; - if (needed + known_size > PAGE_SIZE) - mask |= D_ERROR; - needed = strlen(format); - goto out; - } - - debug_buf = page_address(page) + page->index + known_size; - - max_nob = PAGE_SIZE - page->index - known_size; - LASSERT(max_nob > 0); - va_start(ap, format); - needed = vsnprintf(debug_buf, max_nob, format, ap); - va_end(ap); - - if (needed > max_nob) /* overflow. oh poop. */ - goto retry; - - header.ph_len = known_size + needed; - debug_buf = page_address(page) + page->index; - - memcpy(debug_buf, &header, sizeof(header)); - page->index += sizeof(header); - debug_buf += sizeof(header); - - strcpy(debug_buf, file); - page->index += strlen(file) + 1; - debug_buf += strlen(file) + 1; - - strcpy(debug_buf, fn); - page->index += strlen(fn) + 1; - debug_buf += strlen(fn) + 1; - - page->index += needed; - if (page->index > PAGE_SIZE) - printk(KERN_EMERG "page->index == %lu in portals_debug_msg\n", - page->index); - - out: - if ((mask & (D_EMERG | D_ERROR | D_WARNING)) || portal_printk) - print_to_console(&header, mask, debug_buf, needed, file, fn); - - trace_put_tcd(tcd, flags); -} -EXPORT_SYMBOL(portals_debug_msg); - -static void collect_pages_on_cpu(void *info) -{ - struct trace_cpu_data *tcd; - unsigned long flags; - struct page_collection *pc = info; - - tcd = trace_get_tcd(flags); - - spin_lock(&pc->pc_lock); - list_splice(&tcd->tcd_pages, &pc->pc_pages); - INIT_LIST_HEAD(&tcd->tcd_pages); - tcd->tcd_cur_pages = 0; - if (pc->pc_want_daemon_pages) { - list_splice(&tcd->tcd_daemon_pages, &pc->pc_pages); - INIT_LIST_HEAD(&tcd->tcd_daemon_pages); - tcd->tcd_cur_daemon_pages = 0; - } - spin_unlock(&pc->pc_lock); - - trace_put_tcd(tcd, flags); -} - -static void collect_pages(struct page_collection *pc) -{ - /* needs to be fixed up for preempt */ - INIT_LIST_HEAD(&pc->pc_pages); - collect_pages_on_cpu(pc); - smp_call_function(collect_pages_on_cpu, pc, 0, 1); -} - -static void put_pages_back_on_cpu(void *info) -{ - struct page_collection *pc = info; - struct trace_cpu_data *tcd; - struct list_head *pos, *tmp, *cur_head; - unsigned long flags; - - tcd = trace_get_tcd(flags); - - cur_head = tcd->tcd_pages.next; - - spin_lock(&pc->pc_lock); - list_for_each_safe(pos, tmp, &pc->pc_pages) { - struct page *page; - - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - if ((unsigned long)page->mapping != smp_processor_id()) - continue; - - list_del(&PAGE_LIST(page)); - list_add_tail(&PAGE_LIST(page), cur_head); - tcd->tcd_cur_pages++; - } - spin_unlock(&pc->pc_lock); - - trace_put_tcd(tcd, flags); -} - -static void put_pages_back(struct page_collection *pc) -{ - /* needs to be fixed up for preempt */ - put_pages_back_on_cpu(pc); - smp_call_function(put_pages_back_on_cpu, pc, 0, 1); -} - -/* Add pages to a per-cpu debug daemon ringbuffer. This buffer makes sure that - * we have a good amount of data at all times for dumping during an LBUG, even - * if we have been steadily writing (and otherwise discarding) pages via the - * debug daemon. */ -static void put_pages_on_daemon_list_on_cpu(void *info) -{ - struct page_collection *pc = info; - struct trace_cpu_data *tcd; - struct list_head *pos, *tmp; - unsigned long flags; - - tcd = trace_get_tcd(flags); - - spin_lock(&pc->pc_lock); - list_for_each_safe(pos, tmp, &pc->pc_pages) { - struct page *page; - - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - if ((unsigned long)page->mapping != smp_processor_id()) - continue; - - list_del(&PAGE_LIST(page)); - list_add_tail(&PAGE_LIST(page), &tcd->tcd_daemon_pages); - tcd->tcd_cur_daemon_pages++; - - if (tcd->tcd_cur_daemon_pages > tcd->tcd_max_pages) { - LASSERT(!list_empty(&tcd->tcd_daemon_pages)); - page = list_entry(tcd->tcd_daemon_pages.next, - struct page, PAGE_LIST_ENTRY); - - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - page->index = 0; - list_del(&PAGE_LIST(page)); - page->mapping = NULL; - __free_page(page); - tcd->tcd_cur_daemon_pages--; - } - } - spin_unlock(&pc->pc_lock); - - trace_put_tcd(tcd, flags); -} - -static void put_pages_on_daemon_list(struct page_collection *pc) -{ - put_pages_on_daemon_list_on_cpu(pc); - smp_call_function(put_pages_on_daemon_list_on_cpu, pc, 0, 1); -} - -void trace_debug_print(void) -{ - struct page_collection pc; - struct list_head *pos, *tmp; - - spin_lock_init(&pc.pc_lock); - - collect_pages(&pc); - list_for_each_safe(pos, tmp, &pc.pc_pages) { - struct page *page; - char *p, *file, *fn; - - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - p = page_address(page); - while (p < ((char *)page_address(page) + PAGE_SIZE)) { - struct ptldebug_header *hdr; - int len; - hdr = (void *)p; - p += sizeof(*hdr); - file = p; - p += strlen(file) + 1; - fn = p; - p += strlen(fn) + 1; - len = hdr->ph_len - (p - (char *)hdr); - - print_to_console(hdr, D_EMERG, p, len, file, fn); - } - - list_del(&PAGE_LIST(page)); - page->mapping = NULL; - __free_page(page); - } -} - -int tracefile_dump_all_pages(char *filename) -{ - struct page_collection pc; - struct file *filp; - struct list_head *pos, *tmp; - mm_segment_t oldfs; - int rc; - - down_write(&tracefile_sem); - - filp = filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600); - if (IS_ERR(filp)) { - rc = PTR_ERR(filp); - printk(KERN_ERR "LustreError: can't open %s for dump: rc %d\n", - filename, rc); - goto out; - } - - spin_lock_init(&pc.pc_lock); - pc.pc_want_daemon_pages = 1; - collect_pages(&pc); - if (list_empty(&pc.pc_pages)) { - rc = 0; - goto close; - } - - /* ok, for now, just write the pages. in the future we'll be building - * iobufs with the pages and calling generic_direct_IO */ - oldfs = get_fs(); - set_fs(get_ds()); - list_for_each_safe(pos, tmp, &pc.pc_pages) { - struct page *page; - - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - rc = filp->f_op->write(filp, page_address(page), page->index, - &filp->f_pos); - if (rc != page->index) { - printk(KERN_WARNING "wanted to write %lu but wrote " - "%d\n", page->index, rc); - put_pages_back(&pc); - break; - } - list_del(&PAGE_LIST(page)); - page->mapping = NULL; - __free_page(page); - } - set_fs(oldfs); - rc = filp->f_op->fsync(filp, filp->f_dentry, 1); - if (rc) - printk(KERN_ERR "sync returns %d\n", rc); - close: - filp_close(filp, 0); - out: - up_write(&tracefile_sem); - return rc; -} - -void trace_flush_pages(void) -{ - struct page_collection pc; - struct list_head *pos, *tmp; - - spin_lock_init(&pc.pc_lock); - - collect_pages(&pc); - list_for_each_safe(pos, tmp, &pc.pc_pages) { - struct page *page; - - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - list_del(&PAGE_LIST(page)); - page->mapping = NULL; - __free_page(page); - } -} - -int trace_dk(struct file *file, const char *buffer, unsigned long count, - void *data) -{ - char *name; - unsigned long off; - int rc; - - name = kmalloc(count + 1, GFP_KERNEL); - if (name == NULL) - return -ENOMEM; - - if (copy_from_user(name, buffer, count)) { - rc = -EFAULT; - goto out; - } - - if (name[0] != '/') { - rc = -EINVAL; - goto out; - } - - /* be nice and strip out trailing '\n' */ - for (off = count ; off > 2 && isspace(name[off - 1]); off--) - ; - - name[off] = '\0'; - rc = tracefile_dump_all_pages(name); -out: - if (name) - kfree(name); - return count; -} -EXPORT_SYMBOL(trace_dk); - -static int tracefiled(void *arg) -{ - struct page_collection pc; - struct tracefiled_ctl *tctl = arg; - struct list_head *pos, *tmp; - struct ptldebug_header *hdr; - struct file *filp; - struct page *page; - mm_segment_t oldfs; - int rc; - - /* we're started late enough that we pick up init's fs context */ - /* this is so broken in uml? what on earth is going on? */ - kportal_daemonize("ktracefiled"); - reparent_to_init(); - - spin_lock_init(&pc.pc_lock); - complete(&tctl->tctl_start); - - while (1) { - wait_queue_t __wait; - - init_waitqueue_entry(&__wait, current); - add_wait_queue(&tctl->tctl_waitq, &__wait); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ); - remove_wait_queue(&tctl->tctl_waitq, &__wait); - - if (atomic_read(&tctl->tctl_shutdown)) - break; - - pc.pc_want_daemon_pages = 0; - collect_pages(&pc); - if (list_empty(&pc.pc_pages)) - continue; - - filp = NULL; - down_read(&tracefile_sem); - if (tracefile != NULL) { - filp = filp_open(tracefile, O_CREAT|O_RDWR|O_LARGEFILE, - 0600); - if (IS_ERR(filp)) { - printk("couldn't open %s: %ld\n", tracefile, - PTR_ERR(filp)); - filp = NULL; - } - } - up_read(&tracefile_sem); - if (filp == NULL) { - put_pages_on_daemon_list(&pc); - continue; - } - - oldfs = get_fs(); - set_fs(get_ds()); - - /* mark the first header, so we can sort in chunks */ - page = list_entry(pc.pc_pages.next, struct page, - PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - hdr = page_address(page); - hdr->ph_flags |= PH_FLAG_FIRST_RECORD; - - list_for_each_safe(pos, tmp, &pc.pc_pages) { - static loff_t f_pos; - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - if (f_pos >= tracefile_size) - f_pos = 0; - else if (f_pos > filp->f_dentry->d_inode->i_size) - f_pos = filp->f_dentry->d_inode->i_size; - - rc = filp->f_op->write(filp, page_address(page), - page->index, &f_pos); - if (rc != page->index) { - printk(KERN_WARNING "wanted to write %lu but " - "wrote %d\n", page->index, rc); - put_pages_back(&pc); - } - } - set_fs(oldfs); - filp_close(filp, 0); - - put_pages_on_daemon_list(&pc); - } - complete(&tctl->tctl_stop); - return 0; -} - -int trace_start_thread(void) -{ - struct tracefiled_ctl *tctl = &trace_tctl; - int rc = 0; - - down(&trace_thread_sem); - if (thread_running) - goto out; - - init_completion(&tctl->tctl_start); - init_completion(&tctl->tctl_stop); - init_waitqueue_head(&tctl->tctl_waitq); - atomic_set(&tctl->tctl_shutdown, 0); - - if (kernel_thread(tracefiled, tctl, 0) < 0) { - rc = -ECHILD; - goto out; - } - - wait_for_completion(&tctl->tctl_start); - thread_running = 1; -out: - up(&trace_thread_sem); - return rc; -} - -void trace_stop_thread(void) -{ - struct tracefiled_ctl *tctl = &trace_tctl; - - down(&trace_thread_sem); - if (thread_running) { - printk(KERN_INFO "Shutting down debug daemon thread...\n"); - atomic_set(&tctl->tctl_shutdown, 1); - wait_for_completion(&tctl->tctl_stop); - thread_running = 0; - } - up(&trace_thread_sem); -} - -int trace_write_daemon_file(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - char *name; - unsigned long off; - int rc; - - name = kmalloc(count + 1, GFP_KERNEL); - if (name == NULL) - return -ENOMEM; - - if (copy_from_user(name, buffer, count)) { - rc = -EFAULT; - goto out; - } - - /* be nice and strip out trailing '\n' */ - for (off = count ; off > 2 && isspace(name[off - 1]); off--) - ; - - name[off] = '\0'; - - down_write(&tracefile_sem); - if (strcmp(name, "stop") == 0) { - tracefile = NULL; - trace_stop_thread(); - goto out_sem; - } else if (strncmp(name, "size=", 5) == 0) { - tracefile_size = simple_strtoul(name + 5, NULL, 0); - if (tracefile_size < 10 || tracefile_size > 20480) - tracefile_size = TRACEFILE_SIZE; - else - tracefile_size <<= 20; - goto out_sem; - } - - if (name[0] != '/') { - rc = -EINVAL; - goto out_sem; - } - - if (tracefile != NULL) - kfree(tracefile); - - tracefile = name; - name = NULL; - - printk(KERN_INFO "Lustre: debug daemon will attempt to start writing " - "to %s (%lukB max)\n", tracefile, (long)(tracefile_size >> 10)); - - trace_start_thread(); - - out_sem: - up_write(&tracefile_sem); - - out: - kfree(name); - return count; -} - -int trace_read_daemon_file(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - int rc; - - down_read(&tracefile_sem); - rc = snprintf(page, count, "%s", tracefile); - up_read(&tracefile_sem); - - return rc; -} - -int trace_write_debug_mb(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - char string[32]; - int i; - unsigned max; - - if (count >= sizeof(string)) { - printk(KERN_ERR "Lustre: value too large (length %lu bytes)\n", - count); - return -EOVERFLOW; - } - - if (copy_from_user(string, buffer, count)) - return -EFAULT; - - max = simple_strtoul(string, NULL, 0); - if (max == 0) - return -EINVAL; - - if (max > (num_physpages >> (20 - 2 - PAGE_SHIFT)) / 5 || max >= 512) { - printk(KERN_ERR "Lustre: Refusing to set debug buffer size to " - "%dMB, which is more than 80%% of available RAM (%lu)\n", - max, (num_physpages >> (20 - 2 - PAGE_SHIFT)) / 5); - return -EINVAL; - } - - max /= smp_num_cpus; - - for (i = 0; i < NR_CPUS; i++) { - struct trace_cpu_data *tcd; - tcd = &trace_data[i].tcd; - tcd->tcd_max_pages = max << (20 - PAGE_SHIFT); - } - return count; -} - -int trace_read_debug_mb(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - struct trace_cpu_data *tcd; - unsigned long flags; - int rc; - - tcd = trace_get_tcd(flags); - rc = snprintf(page, count, "%lu\n", - (tcd->tcd_max_pages >> (20 - PAGE_SHIFT)) * smp_num_cpus); - trace_put_tcd(tcd, flags); - - return rc; -} - -int tracefile_init(void) -{ - struct trace_cpu_data *tcd; - int i; - - for (i = 0; i < NR_CPUS; i++) { - tcd = &trace_data[i].tcd; - INIT_LIST_HEAD(&tcd->tcd_pages); - INIT_LIST_HEAD(&tcd->tcd_daemon_pages); - tcd->tcd_cur_pages = 0; - tcd->tcd_cur_daemon_pages = 0; - tcd->tcd_max_pages = TCD_MAX_PAGES; - tcd->tcd_shutting_down = 0; - } - return 0; -} - -static void trace_cleanup_on_cpu(void *info) -{ - struct trace_cpu_data *tcd; - struct list_head *pos, *tmp; - unsigned long flags; - - tcd = trace_get_tcd(flags); - - tcd->tcd_shutting_down = 1; - - list_for_each_safe(pos, tmp, &tcd->tcd_pages) { - struct page *page; - - page = list_entry(pos, struct page, PAGE_LIST_ENTRY); - LASSERT(page->index <= PAGE_SIZE); - LASSERT(page_count(page) > 0); - - list_del(&PAGE_LIST(page)); - page->mapping = NULL; - __free_page(page); - } - tcd->tcd_cur_pages = 0; - - trace_put_tcd(tcd, flags); -} - -static void trace_cleanup(void) -{ - struct page_collection pc; - - INIT_LIST_HEAD(&pc.pc_pages); - spin_lock_init(&pc.pc_lock); - - trace_cleanup_on_cpu(&pc); - smp_call_function(trace_cleanup_on_cpu, &pc, 0, 1); -} - -void tracefile_exit(void) -{ - trace_stop_thread(); - trace_cleanup(); -} diff --git a/lnet/libcfs/tracefile.h b/lnet/libcfs/tracefile.h deleted file mode 100644 index f581257..0000000 --- a/lnet/libcfs/tracefile.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __PORTALS_TRACEFILE_H -#define __PORTALS_TRACEFILE_H - -int tracefile_dump_all_pages(char *filename); -void trace_debug_print(void); -void trace_flush_pages(void); -int trace_start_thread(void); -void trace_stop_thread(void); -int tracefile_init(void); -void tracefile_exit(void); -int trace_write_daemon_file(struct file *file, const char *buffer, - unsigned long count, void *data); -int trace_read_daemon_file(char *page, char **start, off_t off, int count, - int *eof, void *data); -int trace_write_debug_mb(struct file *file, const char *buffer, - unsigned long count, void *data); -int trace_read_debug_mb(char *page, char **start, off_t off, int count, - int *eof, void *data); -int trace_dk(struct file *file, const char *buffer, unsigned long count, - void *data); - -#endif /* __PORTALS_TRACEFILE_H */ diff --git a/lnet/libcfs/watchdog.c b/lnet/libcfs/watchdog.c deleted file mode 100644 index 844845a..0000000 --- a/lnet/libcfs/watchdog.c +++ /dev/null @@ -1,402 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2004 Cluster File Systems, Inc. - * Author: Jacob Berkman - * - * 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. - */ - -#define DEBUG_SUBSYSTEM S_PORTALS - -#include -#include -#include - - - -struct lc_watchdog { - struct timer_list lcw_timer; /* kernel timer */ - struct list_head lcw_list; - struct timeval lcw_last_touched; - struct task_struct *lcw_task; - - void (*lcw_callback)(struct lc_watchdog *, - struct task_struct *, - void *data); - void *lcw_data; - - int lcw_pid; - int lcw_time; /* time until watchdog fires, in ms */ - - enum { - LC_WATCHDOG_DISABLED, - LC_WATCHDOG_ENABLED, - LC_WATCHDOG_EXPIRED - } lcw_state; -}; - -/* - * The dispatcher will complete lcw_start_completion when it starts, - * and lcw_stop_completion when it exits. - * Wake lcw_event_waitq to signal timer callback dispatches. - */ -static struct completion lcw_start_completion; -static struct completion lcw_stop_completion; -static wait_queue_head_t lcw_event_waitq; - -/* - * Set this and wake lcw_event_waitq to stop the dispatcher. - */ -enum { - LCW_FLAG_STOP = 0 -}; -static unsigned long lcw_flags = 0; - -/* - * Number of outstanding watchdogs. - * When it hits 1, we start the dispatcher. - * When it hits 0, we stop the distpatcher. - */ -static __u32 lcw_refcount = 0; -static DECLARE_MUTEX(lcw_refcount_sem); - -/* - * List of timers that have fired that need their callbacks run by the - * dispatcher. - */ -static spinlock_t lcw_pending_timers_lock = SPIN_LOCK_UNLOCKED; -static struct list_head lcw_pending_timers = \ - LIST_HEAD_INIT(lcw_pending_timers); - -static struct task_struct *lcw_lookup_task(struct lc_watchdog *lcw) -{ - struct task_struct *tsk; - unsigned long flags; - ENTRY; - - read_lock_irqsave(&tasklist_lock, flags); - tsk = find_task_by_pid(lcw->lcw_pid); - read_unlock_irqrestore(&tasklist_lock, flags); - if (!tsk) { - CWARN("Process %d was not found in the task list; " - "watchdog callback may be incomplete\n", lcw->lcw_pid); - } else if (tsk != lcw->lcw_task) { - tsk = NULL; - CWARN("The current process %d did not set the watchdog; " - "watchdog callback may be incomplete\n", lcw->lcw_pid); - } - - RETURN(tsk); -} - -static void lcw_cb(unsigned long data) -{ - struct lc_watchdog *lcw = (struct lc_watchdog *)data; - struct task_struct *tsk; - unsigned long flags; - - ENTRY; - - if (lcw->lcw_state != LC_WATCHDOG_ENABLED) { - EXIT; - return; - } - - lcw->lcw_state = LC_WATCHDOG_EXPIRED; - - CWARN("Watchdog triggered for pid %d: it was inactive for %dus\n", - lcw->lcw_pid, (lcw->lcw_time * 1000) / HZ); - - tsk = lcw_lookup_task(lcw); - if (tsk != NULL) - portals_debug_dumpstack(tsk); - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - if (list_empty(&lcw->lcw_list)) { - list_add(&lcw->lcw_list, &lcw_pending_timers); - wake_up(&lcw_event_waitq); - } - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - - EXIT; -} - -static int is_watchdog_fired(void) -{ - unsigned long flags; - int rc; - - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) - return 1; - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - return rc; -} - -static int lcw_dispatch_main(void *data) -{ - int rc = 0; - unsigned long flags; - struct lc_watchdog *lcw; - struct task_struct *tsk; - - ENTRY; - - kportal_daemonize("lc_watchdogd"); - - SIGNAL_MASK_LOCK(current, flags); - sigfillset(¤t->blocked); - RECALC_SIGPENDING; - SIGNAL_MASK_UNLOCK(current, flags); - - complete(&lcw_start_completion); - - while (1) { - wait_event_interruptible(lcw_event_waitq, is_watchdog_fired()); - CDEBUG(D_INFO, "Watchdog got woken up...\n"); - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) { - CDEBUG(D_INFO, "LCW_FLAG_STOP was set, shutting down...\n"); - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - if (rc) { - CERROR("pending timers list was not empty at " - "time of watchdog dispatch shutdown\n"); - } - break; - } - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - while (!list_empty(&lcw_pending_timers)) { - - lcw = list_entry(lcw_pending_timers.next, - struct lc_watchdog, - lcw_list); - list_del_init(&lcw->lcw_list); - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - - CDEBUG(D_INFO, "found lcw for pid %d\n", lcw->lcw_pid); - - if (lcw->lcw_state != LC_WATCHDOG_DISABLED) { - /* - * sanity check the task against our - * watchdog - */ - tsk = lcw_lookup_task(lcw); - lcw->lcw_callback(lcw, tsk, lcw->lcw_data); - } - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - } - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - } - - complete(&lcw_stop_completion); - - RETURN(rc); -} - -static void lcw_dispatch_start(void) -{ - int rc; - - ENTRY; - LASSERT(lcw_refcount == 1); - - init_completion(&lcw_stop_completion); - init_completion(&lcw_start_completion); - init_waitqueue_head(&lcw_event_waitq); - - CDEBUG(D_INFO, "starting dispatch thread\n"); - rc = kernel_thread(lcw_dispatch_main, NULL, 0); - if (rc < 0) { - CERROR("error spawning watchdog dispatch thread: %d\n", rc); - EXIT; - return; - } - wait_for_completion(&lcw_start_completion); - CDEBUG(D_INFO, "watchdog dispatcher initialization complete.\n"); - - EXIT; -} - -static void lcw_dispatch_stop(void) -{ - ENTRY; - LASSERT(lcw_refcount == 0); - - CDEBUG(D_INFO, "trying to stop watchdog dispatcher.\n"); - - set_bit(LCW_FLAG_STOP, &lcw_flags); - wake_up(&lcw_event_waitq); - - wait_for_completion(&lcw_stop_completion); - - CDEBUG(D_INFO, "watchdog dispatcher has shut down.\n"); - - EXIT; -} - -struct lc_watchdog *lc_watchdog_add(int time, - void (*callback)(struct lc_watchdog *, - struct task_struct *, - void *), - void *data) -{ - struct lc_watchdog *lcw = NULL; - ENTRY; - - PORTAL_ALLOC(lcw, sizeof(*lcw)); - if (!lcw) { - CDEBUG(D_INFO, "Could not allocate new lc_watchdog\n"); - RETURN(ERR_PTR(-ENOMEM)); - } - - lcw->lcw_task = current; - lcw->lcw_pid = current->pid; - lcw->lcw_time = (time * HZ) / 1000; - lcw->lcw_callback = callback ? callback : lc_watchdog_dumplog; - lcw->lcw_data = data; - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - INIT_LIST_HEAD(&lcw->lcw_list); - - lcw->lcw_timer.function = lcw_cb; - lcw->lcw_timer.data = (unsigned long)lcw; - lcw->lcw_timer.expires = jiffies + lcw->lcw_time; - init_timer(&lcw->lcw_timer); - - down(&lcw_refcount_sem); - if (++lcw_refcount == 1) - lcw_dispatch_start(); - up(&lcw_refcount_sem); - - /* Keep this working in case we enable them by default */ - if (lcw->lcw_state == LC_WATCHDOG_ENABLED) { - do_gettimeofday(&lcw->lcw_last_touched); - add_timer(&lcw->lcw_timer); - } - - RETURN(lcw); -} -EXPORT_SYMBOL(lc_watchdog_add); - -static long -timeval_sub(struct timeval *large, struct timeval *small) -{ - return (large->tv_sec - small->tv_sec) * 1000000 + - (large->tv_usec - small->tv_usec); -} - -static void lcw_update_time(struct lc_watchdog *lcw, const char *message) -{ - struct timeval newtime; - unsigned long timediff; - - do_gettimeofday(&newtime); - if (lcw->lcw_state == LC_WATCHDOG_EXPIRED) { - timediff = timeval_sub(&newtime, &lcw->lcw_last_touched); - CWARN("Expired watchdog for pid %d %s after %lu.%.4lus\n", - lcw->lcw_pid, - message, - timediff / 1000000, - (timediff % 1000000) / 100); - } - lcw->lcw_last_touched = newtime; -} - -void lc_watchdog_touch(struct lc_watchdog *lcw) -{ - unsigned long flags; - ENTRY; - LASSERT(lcw != NULL); - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - if (!list_empty(&lcw->lcw_list)) - list_del_init(&lcw->lcw_list); - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - - lcw_update_time(lcw, "touched"); - lcw->lcw_state = LC_WATCHDOG_ENABLED; - - mod_timer(&lcw->lcw_timer, jiffies + lcw->lcw_time); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_touch); - -void lc_watchdog_disable(struct lc_watchdog *lcw) -{ - unsigned long flags; - ENTRY; - LASSERT(lcw != NULL); - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - if (!list_empty(&lcw->lcw_list)) - list_del_init(&lcw->lcw_list); - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - - lcw_update_time(lcw, "disabled"); - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_disable); - -void lc_watchdog_delete(struct lc_watchdog *lcw) -{ - unsigned long flags; - ENTRY; - LASSERT(lcw != NULL); - - del_timer(&lcw->lcw_timer); - - lcw_update_time(lcw, "deleted"); - - spin_lock_irqsave(&lcw_pending_timers_lock, flags); - if (!list_empty(&lcw->lcw_list)) - list_del_init(&lcw->lcw_list); - spin_unlock_irqrestore(&lcw_pending_timers_lock, flags); - - down(&lcw_refcount_sem); - if (--lcw_refcount == 0) - lcw_dispatch_stop(); - up(&lcw_refcount_sem); - - PORTAL_FREE(lcw, sizeof(*lcw)); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_delete); - -/* - * Provided watchdog handlers - */ - -extern void portals_debug_dumplog_internal(void *arg); - -void lc_watchdog_dumplog(struct lc_watchdog *lcw, - struct task_struct *tsk, - void *data) -{ - tsk = tsk ? tsk : current; - portals_debug_dumplog_internal((void *)(long)tsk->pid); -} -EXPORT_SYMBOL(lc_watchdog_dumplog); diff --git a/lnet/lnet/.cvsignore b/lnet/lnet/.cvsignore deleted file mode 100644 index 5ed596b..0000000 --- a/lnet/lnet/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/lnet/Makefile.in b/lnet/lnet/Makefile.in deleted file mode 100644 index c0f2e71..0000000 --- a/lnet/lnet/Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -MODULES := portals -portals-objs := api-errno.o api-ni.o api-wrap.o -portals-objs += lib-init.o lib-me.o lib-msg.o lib-eq.o lib-md.o -portals-objs += lib-move.o lib-ni.o lib-pid.o module.o - -@INCLUDE_RULES@ diff --git a/lnet/lnet/Makefile.mk b/lnet/lnet/Makefile.mk deleted file mode 100644 index 088902a..0000000 --- a/lnet/lnet/Makefile.mk +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include $(src)/../Kernelenv - -obj-y += portals.o -portals-objs := lib-eq.o lib-init.o lib-md.o lib-me.o \ - lib-move.o lib-msg.o lib-ni.o lib-pid.o \ - api-errno.o api-ni.o api-wrap.o \ - module.o diff --git a/lnet/lnet/api-errno.c b/lnet/lnet/api-errno.c deleted file mode 100644 index 9a4e5ac..0000000 --- a/lnet/lnet/api-errno.c +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * api/api-errno.c - * Instantiate the string table of errors - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - */ - -/* If you change these, you must update the number table in portals/errno.h */ -const char *ptl_err_str[] = { - "PTL_OK", - "PTL_SEGV", - - "PTL_NO_SPACE", - "PTL_ME_IN_USE", - "PTL_VAL_FAILED", - - "PTL_NAL_FAILED", - "PTL_NO_INIT", - "PTL_IFACE_DUP", - "PTL_IFACE_INVALID", - - "PTL_HANDLE_INVALID", - "PTL_MD_INVALID", - "PTL_ME_INVALID", -/* If you change these, you must update the number table in portals/errno.h */ - "PTL_PROCESS_INVALID", - "PTL_PT_INDEX_INVALID", - - "PTL_SR_INDEX_INVALID", - "PTL_EQ_INVALID", - "PTL_EQ_DROPPED", - - "PTL_EQ_EMPTY", - "PTL_MD_NO_UPDATE", - "PTL_FAIL", - - "PTL_IOV_INVALID", - - "PTL_EQ_IN_USE", - - "PTL_NI_INVALID", - "PTL_MD_ILLEGAL", - - "PTL_MAX_ERRNO" -}; -/* If you change these, you must update the number table in portals/errno.h */ diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c deleted file mode 100644 index 7e92256..0000000 --- a/lnet/lnet/api-ni.c +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * api/api-ni.c - * Network Interface code - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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. - */ - -#define DEBUG_SUBSYSTEM S_PORTALS -#include - -int ptl_init; - -/* Put some magic in the NI handle so uninitialised/zeroed handles are easy - * to spot */ -#define NI_HANDLE_MAGIC 0xebc0de00 -#define NI_HANDLE_MASK 0x000000ff - -static struct nal_t *ptl_nal_table[NAL_MAX_NR + 1]; - -#ifdef __KERNEL__ -DECLARE_MUTEX(ptl_mutex); - -static void ptl_mutex_enter (void) -{ - down (&ptl_mutex); -} - -static void ptl_mutex_exit (void) -{ - up (&ptl_mutex); -} -#else -static void ptl_mutex_enter (void) -{ -} - -static void ptl_mutex_exit (void) -{ -} -#endif - -nal_t *ptl_hndl2nal(ptl_handle_any_t *handle) -{ - unsigned int idx = handle->nal_idx; - - /* XXX we really rely on the caller NOT racing with interface - * setup/teardown. That ensures her NI handle can't get - * invalidated out from under her (or worse, swapped for a - * completely different interface!) */ - - LASSERT (ptl_init); - - if (((idx ^ NI_HANDLE_MAGIC) & ~NI_HANDLE_MASK) != 0) - return NULL; - - idx &= NI_HANDLE_MASK; - - if (idx > NAL_MAX_NR || - ptl_nal_table[idx] == NULL || - ptl_nal_table[idx]->nal_refct == 0) - return NULL; - - return ptl_nal_table[idx]; -} - -int ptl_register_nal (ptl_interface_t interface, nal_t *nal) -{ - int rc; - - ptl_mutex_enter(); - - if (interface < 0 || interface > NAL_MAX_NR) - rc = PTL_IFACE_INVALID; - else if (ptl_nal_table[interface] != NULL) - rc = PTL_IFACE_DUP; - else { - rc = PTL_OK; - ptl_nal_table[interface] = nal; - LASSERT(nal->nal_refct == 0); - } - - ptl_mutex_exit(); - return (rc); -} - -void ptl_unregister_nal (ptl_interface_t interface) -{ - LASSERT(interface >= 0 && interface <= NAL_MAX_NR); - LASSERT(ptl_nal_table[interface] != NULL); - LASSERT(ptl_nal_table[interface]->nal_refct == 0); - - ptl_mutex_enter(); - - ptl_nal_table[interface] = NULL; - - ptl_mutex_exit(); -} - -int PtlInit(int *max_interfaces) -{ - LASSERT(!strcmp(ptl_err_str[PTL_MAX_ERRNO], "PTL_MAX_ERRNO")); - - /* If this assertion fails, we need more bits in NI_HANDLE_MASK and - * to shift NI_HANDLE_MAGIC left appropriately */ - LASSERT (NAL_MAX_NR < (NI_HANDLE_MASK + 1)); - - if (max_interfaces != NULL) - *max_interfaces = NAL_MAX_NR + 1; - - ptl_mutex_enter(); - - if (!ptl_init) { - /* NULL pointers, clear flags */ - memset(ptl_nal_table, 0, sizeof(ptl_nal_table)); -#ifndef __KERNEL__ - /* Kernel NALs register themselves when their module loads, - * and unregister themselves when their module is unloaded. - * Userspace NALs, are plugged in explicitly here... */ - { - extern nal_t procapi_nal; - - /* XXX pretend it's socknal to keep liblustre happy... */ - ptl_nal_table[SOCKNAL] = &procapi_nal; - LASSERT (procapi_nal.nal_refct == 0); - } -#endif - ptl_init = 1; - } - - ptl_mutex_exit(); - - return PTL_OK; -} - -void PtlFini(void) -{ - nal_t *nal; - int i; - - ptl_mutex_enter(); - - if (ptl_init) { - for (i = 0; i <= NAL_MAX_NR; i++) { - - nal = ptl_nal_table[i]; - if (nal == NULL) - continue; - - if (nal->nal_refct != 0) { - CWARN("NAL %x has outstanding refcount %d\n", - i, nal->nal_refct); - nal->nal_ni_fini(nal); - } - - ptl_nal_table[i] = NULL; - } - - ptl_init = 0; - } - - ptl_mutex_exit(); -} - -int PtlNIInit(ptl_interface_t interface, ptl_pid_t requested_pid, - ptl_ni_limits_t *desired_limits, ptl_ni_limits_t *actual_limits, - ptl_handle_ni_t *handle) -{ - nal_t *nal; - int i; - int rc; - - if (!ptl_init) - return PTL_NO_INIT; - - ptl_mutex_enter (); - - if (interface == PTL_IFACE_DEFAULT) { - for (i = 0; i <= NAL_MAX_NR; i++) - if (ptl_nal_table[i] != NULL) { - interface = i; - break; - } - /* NB if no interfaces are registered, 'interface' will - * fail the valid test below */ - } - - if (interface < 0 || - interface > NAL_MAX_NR || - ptl_nal_table[interface] == NULL) { - GOTO(out, rc = PTL_IFACE_INVALID); - } - - nal = ptl_nal_table[interface]; - nal->nal_handle.nal_idx = (NI_HANDLE_MAGIC & ~NI_HANDLE_MASK) | interface; - nal->nal_handle.cookie = 0; - - CDEBUG(D_OTHER, "Starting up NAL (%x) refs %d\n", interface, nal->nal_refct); - rc = nal->nal_ni_init(nal, requested_pid, desired_limits, actual_limits); - - if (rc != PTL_OK) { - CERROR("Error %d starting up NAL %x, refs %d\n", rc, - interface, nal->nal_refct); - GOTO(out, rc); - } - - if (nal->nal_refct != 0) { - /* Caller gets to know if this was the first ref or not */ - rc = PTL_IFACE_DUP; - } - - nal->nal_refct++; - *handle = nal->nal_handle; - - out: - ptl_mutex_exit (); - - return rc; -} - -int PtlNIFini(ptl_handle_ni_t ni) -{ - nal_t *nal; - int idx; - - if (!ptl_init) - return PTL_NO_INIT; - - ptl_mutex_enter (); - - nal = ptl_hndl2nal (&ni); - if (nal == NULL) { - ptl_mutex_exit (); - return PTL_HANDLE_INVALID; - } - - idx = ni.nal_idx & NI_HANDLE_MASK; - - LASSERT(nal->nal_refct > 0); - - nal->nal_refct--; - - /* nal_refct == 0 tells nal->shutdown to really shut down */ - nal->nal_ni_fini(nal); - - ptl_mutex_exit (); - return PTL_OK; -} diff --git a/lnet/lnet/api-wrap.c b/lnet/lnet/api-wrap.c deleted file mode 100644 index 37f6c0b..0000000 --- a/lnet/lnet/api-wrap.c +++ /dev/null @@ -1,366 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * api/api-wrap.c - * User-level wrappers that dispatch across the protection boundaries - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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. - */ - -# define DEBUG_SUBSYSTEM S_PORTALS -#include - -void PtlSnprintHandle(char *str, int len, ptl_handle_any_t h) -{ - snprintf(str, len, "0x%lx."LPX64, h.nal_idx, h.cookie); -} - -int PtlNIHandle(ptl_handle_any_t handle_in, ptl_handle_ni_t *ni_out) -{ - if (!ptl_init) - return PTL_NO_INIT; - - if (ptl_hndl2nal(&handle_in) == NULL) - return PTL_HANDLE_INVALID; - - *ni_out = handle_in; - return PTL_OK; -} - -int PtlGetId(ptl_handle_ni_t ni_handle, ptl_process_id_t *id) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&ni_handle); - if (nal == NULL) - return PTL_NI_INVALID; - - return nal->nal_get_id(nal, id); -} - -int PtlGetUid(ptl_handle_ni_t ni_handle, ptl_uid_t *uid) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&ni_handle); - if (nal == NULL) - return PTL_NI_INVALID; - - /* We don't support different uids yet */ - *uid = 0; - return PTL_OK; -} - -int PtlFailNid (ptl_handle_ni_t interface, ptl_nid_t nid, unsigned int threshold) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&interface); - if (nal == NULL) - return PTL_NI_INVALID; - - return nal->nal_fail_nid(nal, nid, threshold); -} - -int PtlNIStatus(ptl_handle_ni_t interface_in, ptl_sr_index_t register_in, - ptl_sr_value_t *status_out) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&interface_in); - if (nal == NULL) - return PTL_NI_INVALID; - - return nal->nal_ni_status(nal, register_in, status_out); -} - -int PtlNIDist(ptl_handle_ni_t interface_in, ptl_process_id_t process_in, - unsigned long *distance_out) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&interface_in); - if (nal == NULL) - return PTL_NI_INVALID; - - return nal->nal_ni_dist(nal, &process_in, distance_out); -} - -int PtlMEAttach(ptl_handle_ni_t interface_in, ptl_pt_index_t index_in, - ptl_process_id_t match_id_in, ptl_match_bits_t match_bits_in, - ptl_match_bits_t ignore_bits_in, ptl_unlink_t unlink_in, - ptl_ins_pos_t pos_in, ptl_handle_me_t *handle_out) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&interface_in); - if (nal == NULL) - return PTL_NI_INVALID; - - return nal->nal_me_attach(nal, index_in, match_id_in, - match_bits_in, ignore_bits_in, - unlink_in, pos_in, handle_out); -} - -int PtlMEInsert(ptl_handle_me_t current_in, ptl_process_id_t match_id_in, - ptl_match_bits_t match_bits_in, ptl_match_bits_t ignore_bits_in, - ptl_unlink_t unlink_in, ptl_ins_pos_t position_in, - ptl_handle_me_t * handle_out) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(¤t_in); - if (nal == NULL) - return PTL_ME_INVALID; - - return nal->nal_me_insert(nal, ¤t_in, match_id_in, - match_bits_in, ignore_bits_in, - unlink_in, position_in, handle_out); -} - -int PtlMEUnlink(ptl_handle_me_t current_in) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(¤t_in); - if (nal == NULL) - return PTL_ME_INVALID; - - return nal->nal_me_unlink(nal, ¤t_in); -} - -int PtlMDAttach(ptl_handle_me_t me_in, ptl_md_t md_in, - ptl_unlink_t unlink_in, ptl_handle_md_t * handle_out) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&me_in); - if (nal == NULL) - return PTL_ME_INVALID; - - if (!PtlHandleIsEqual(md_in.eq_handle, PTL_EQ_NONE) && - ptl_hndl2nal(&md_in.eq_handle) != nal) - return PTL_MD_ILLEGAL; - - return (nal->nal_md_attach)(nal, &me_in, &md_in, - unlink_in, handle_out); -} - -int PtlMDBind(ptl_handle_ni_t ni_in, ptl_md_t md_in, - ptl_unlink_t unlink_in, ptl_handle_md_t *handle_out) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&ni_in); - if (nal == NULL) - return PTL_NI_INVALID; - - if (!PtlHandleIsEqual(md_in.eq_handle, PTL_EQ_NONE) && - ptl_hndl2nal(&md_in.eq_handle) != nal) - return PTL_MD_ILLEGAL; - - return (nal->nal_md_bind)(nal, &md_in, unlink_in, handle_out); -} - -int PtlMDUpdate(ptl_handle_md_t md_in, ptl_md_t *old_inout, - ptl_md_t *new_inout, ptl_handle_eq_t testq_in) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&md_in); - if (nal == NULL) - return PTL_MD_INVALID; - - if (!PtlHandleIsEqual(testq_in, PTL_EQ_NONE) && - ptl_hndl2nal(&testq_in) != nal) - return PTL_EQ_INVALID; - - return (nal->nal_md_update)(nal, &md_in, - old_inout, new_inout, &testq_in); -} - -int PtlMDUnlink(ptl_handle_md_t md_in) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&md_in); - if (nal == NULL) - return PTL_MD_INVALID; - - return (nal->nal_md_unlink)(nal, &md_in); -} - -int PtlEQAlloc(ptl_handle_ni_t interface, ptl_size_t count, - ptl_eq_handler_t callback, - ptl_handle_eq_t *handle_out) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&interface); - if (nal == NULL) - return PTL_NI_INVALID; - - return (nal->nal_eq_alloc)(nal, count, callback, handle_out); -} - -int PtlEQFree(ptl_handle_eq_t eventq) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&eventq); - if (nal == NULL) - return PTL_EQ_INVALID; - - return (nal->nal_eq_free)(nal, &eventq); -} - -int PtlEQGet(ptl_handle_eq_t eventq, ptl_event_t *ev) -{ - int which; - - return (PtlEQPoll (&eventq, 1, 0, ev, &which)); -} - -int PtlEQWait(ptl_handle_eq_t eventq_in, ptl_event_t *event_out) -{ - int which; - - return (PtlEQPoll (&eventq_in, 1, PTL_TIME_FOREVER, - event_out, &which)); -} - -int PtlEQPoll(ptl_handle_eq_t *eventqs_in, int neq_in, int timeout, - ptl_event_t *event_out, int *which_out) -{ - int i; - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - if (neq_in < 1) - return PTL_EQ_INVALID; - - nal = ptl_hndl2nal(&eventqs_in[0]); - if (nal == NULL) - return PTL_EQ_INVALID; - - for (i = 1; i < neq_in; i++) - if (ptl_hndl2nal(&eventqs_in[i]) != nal) - return PTL_EQ_INVALID; - - return (nal->nal_eq_poll)(nal, eventqs_in, neq_in, timeout, - event_out, which_out); -} - - -int PtlACEntry(ptl_handle_ni_t ni_in, ptl_ac_index_t index_in, - ptl_process_id_t match_id_in, ptl_pt_index_t portal_in) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&ni_in); - if (nal == NULL) - return PTL_NI_INVALID; - - return (nal->nal_ace_entry)(nal, index_in, match_id_in, portal_in); -} - -int PtlPut(ptl_handle_md_t md_in, ptl_ack_req_t ack_req_in, - ptl_process_id_t target_in, ptl_pt_index_t portal_in, - ptl_ac_index_t ac_in, ptl_match_bits_t match_bits_in, - ptl_size_t offset_in, ptl_hdr_data_t hdr_data_in) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&md_in); - if (nal == NULL) - return PTL_MD_INVALID; - - return (nal->nal_put)(nal, &md_in, ack_req_in, - &target_in, portal_in, ac_in, - match_bits_in, offset_in, hdr_data_in); -} - -int PtlGet(ptl_handle_md_t md_in, ptl_process_id_t target_in, - ptl_pt_index_t portal_in, ptl_ac_index_t ac_in, - ptl_match_bits_t match_bits_in, ptl_size_t offset_in) -{ - nal_t *nal; - - if (!ptl_init) - return PTL_NO_INIT; - - nal = ptl_hndl2nal(&md_in); - if (nal == NULL) - return PTL_MD_INVALID; - - return (nal->nal_get)(nal, &md_in, - &target_in, portal_in, ac_in, - match_bits_in, offset_in); -} - diff --git a/lnet/lnet/autoMakefile.am b/lnet/lnet/autoMakefile.am deleted file mode 100644 index 285f8fe..0000000 --- a/lnet/lnet/autoMakefile.am +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2002 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -my_sources = api-errno.c api-ni.c api-wrap.c \ - lib-init.c lib-me.c lib-msg.c lib-eq.c \ - lib-md.c lib-move.c lib-ni.c lib-pid.c - -if !CRAY_PORTALS - -if LIBLUSTRE -noinst_LIBRARIES= libportals.a -libportals_a_SOURCES= $(my_sources) -libportals_a_CPPFLAGS = $(LLCPPFLAGS) -libportals_a_CFLAGS = $(LLCFLAGS) -endif - -if MODULES -modulenet_DATA = portals$(KMODEXT) -endif # MODULES - -endif # CRAY_PORTALS - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(portals-objs:%.o=%.c) diff --git a/lnet/lnet/lib-eq.c b/lnet/lnet/lib-eq.c deleted file mode 100644 index 8ea6fdd..0000000 --- a/lnet/lnet/lib-eq.c +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-eq.c - * Library level Event queue management routines - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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. - */ - -#define DEBUG_SUBSYSTEM S_PORTALS -#include - -int -lib_api_eq_alloc (nal_t *apinal, ptl_size_t count, - ptl_eq_handler_t callback, - ptl_handle_eq_t *handle) -{ - lib_nal_t *nal = apinal->nal_data; - lib_eq_t *eq; - unsigned long flags; - int rc; - - /* We need count to be a power of 2 so that when eq_{enq,deq}_seq - * overflow, they don't skip entries, so the queue has the same - * apparant capacity at all times */ - - if (count != LOWEST_BIT_SET(count)) { /* not a power of 2 already */ - do { /* knock off all but the top bit... */ - count &= ~LOWEST_BIT_SET (count); - } while (count != LOWEST_BIT_SET(count)); - - count <<= 1; /* ...and round up */ - } - - if (count == 0) /* catch bad parameter / overflow on roundup */ - return (PTL_VAL_FAILED); - - eq = lib_eq_alloc (nal); - if (eq == NULL) - return (PTL_NO_SPACE); - - PORTAL_ALLOC(eq->eq_events, count * sizeof(ptl_event_t)); - if (eq->eq_events == NULL) { - LIB_LOCK(nal, flags); - lib_eq_free (nal, eq); - LIB_UNLOCK(nal, flags); - } - - if (nal->libnal_map != NULL) { - struct iovec iov = { - .iov_base = eq->eq_events, - .iov_len = count * sizeof(ptl_event_t)}; - - rc = nal->libnal_map(nal, 1, &iov, &eq->eq_addrkey); - if (rc != PTL_OK) { - LIB_LOCK(nal, flags); - lib_eq_free (nal, eq); - LIB_UNLOCK(nal, flags); - return (rc); - } - } - - /* NB this resets all event sequence numbers to 0, to be earlier - * than eq_deq_seq */ - memset(eq->eq_events, 0, count * sizeof(ptl_event_t)); - - eq->eq_deq_seq = 1; - eq->eq_enq_seq = 1; - eq->eq_size = count; - eq->eq_refcount = 0; - eq->eq_callback = callback; - - LIB_LOCK(nal, flags); - - lib_initialise_handle (nal, &eq->eq_lh, PTL_COOKIE_TYPE_EQ); - list_add (&eq->eq_list, &nal->libnal_ni.ni_active_eqs); - - LIB_UNLOCK(nal, flags); - - ptl_eq2handle(handle, nal, eq); - return (PTL_OK); -} - -int -lib_api_eq_free(nal_t *apinal, ptl_handle_eq_t *eqh) -{ - lib_nal_t *nal = apinal->nal_data; - lib_eq_t *eq; - int size; - ptl_event_t *events; - void *addrkey; - unsigned long flags; - - LIB_LOCK(nal, flags); - - eq = ptl_handle2eq(eqh, nal); - if (eq == NULL) { - LIB_UNLOCK(nal, flags); - return (PTL_EQ_INVALID); - } - - if (eq->eq_refcount != 0) { - LIB_UNLOCK(nal, flags); - return (PTL_EQ_IN_USE); - } - - /* stash for free after lock dropped */ - events = eq->eq_events; - size = eq->eq_size; - addrkey = eq->eq_addrkey; - - lib_invalidate_handle (nal, &eq->eq_lh); - list_del (&eq->eq_list); - lib_eq_free (nal, eq); - - LIB_UNLOCK(nal, flags); - - if (nal->libnal_unmap != NULL) { - struct iovec iov = { - .iov_base = events, - .iov_len = size * sizeof(ptl_event_t)}; - - nal->libnal_unmap(nal, 1, &iov, &addrkey); - } - - PORTAL_FREE(events, size * sizeof (ptl_event_t)); - - return (PTL_OK); -} - -int -lib_get_event (lib_eq_t *eq, ptl_event_t *ev) -{ - int new_index = eq->eq_deq_seq & (eq->eq_size - 1); - ptl_event_t *new_event = &eq->eq_events[new_index]; - int rc; - ENTRY; - - CDEBUG(D_INFO, "event: %p, sequence: %lu, eq->size: %u\n", - new_event, eq->eq_deq_seq, eq->eq_size); - - if (PTL_SEQ_GT (eq->eq_deq_seq, new_event->sequence)) { - RETURN(PTL_EQ_EMPTY); - } - - /* We've got a new event... */ - *ev = *new_event; - - /* ...but did it overwrite an event we've not seen yet? */ - if (eq->eq_deq_seq == new_event->sequence) { - rc = PTL_OK; - } else { - CERROR("Event Queue Overflow: eq seq %lu ev seq %lu\n", - eq->eq_deq_seq, new_event->sequence); - rc = PTL_EQ_DROPPED; - } - - eq->eq_deq_seq = new_event->sequence + 1; - RETURN(rc); -} - - -int -lib_api_eq_poll (nal_t *apinal, - ptl_handle_eq_t *eventqs, int neq, int timeout_ms, - ptl_event_t *event, int *which) -{ - lib_nal_t *nal = apinal->nal_data; - lib_ni_t *ni = &nal->libnal_ni; - unsigned long flags; - int i; - int rc; -#ifdef __KERNEL__ - wait_queue_t wq; - unsigned long now; -#else - struct timeval then; - struct timeval now; - struct timespec ts; -#endif - ENTRY; - - LIB_LOCK(nal, flags); - - for (;;) { - for (i = 0; i < neq; i++) { - lib_eq_t *eq = ptl_handle2eq(&eventqs[i], nal); - - rc = lib_get_event (eq, event); - if (rc != PTL_EQ_EMPTY) { - LIB_UNLOCK(nal, flags); - *which = i; - RETURN(rc); - } - } - - if (timeout_ms == 0) { - LIB_UNLOCK (nal, flags); - RETURN (PTL_EQ_EMPTY); - } - - /* Some architectures force us to do spin locking/unlocking - * in the same stack frame, means we can abstract the - * locking here */ -#ifdef __KERNEL__ - init_waitqueue_entry(&wq, current); - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&ni->ni_waitq, &wq); - - LIB_UNLOCK(nal, flags); - - if (timeout_ms < 0) { - schedule (); - } else { - now = jiffies; - schedule_timeout((timeout_ms * HZ)/1000); - timeout_ms -= ((jiffies - now) * 1000)/HZ; - if (timeout_ms < 0) - timeout_ms = 0; - } - - LIB_LOCK(nal, flags); -#else - if (timeout_ms < 0) { - pthread_cond_wait(&ni->ni_cond, &ni->ni_mutex); - } else { - gettimeofday(&then, NULL); - - ts.tv_sec = then.tv_sec + timeout_ms/1000; - ts.tv_nsec = then.tv_usec * 1000 + - (timeout_ms%1000) * 1000000; - if (ts.tv_nsec >= 1000000000) { - ts.tv_sec++; - ts.tv_nsec -= 1000000000; - } - - pthread_cond_timedwait(&ni->ni_cond, - &ni->ni_mutex, &ts); - - gettimeofday(&now, NULL); - timeout_ms -= (now.tv_sec - then.tv_sec) * 1000 + - (now.tv_usec - then.tv_usec) / 1000; - - if (timeout_ms < 0) - timeout_ms = 0; - } -#endif - } -} diff --git a/lnet/lnet/lib-init.c b/lnet/lnet/lib-init.c deleted file mode 100644 index 9d97bc1..0000000 --- a/lnet/lnet/lib-init.c +++ /dev/null @@ -1,434 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-init.c - * Start up the internal library and clear all structures - * Called by the NAL when it initializes. Safe to call multiple times. - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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. - */ - -# define DEBUG_SUBSYSTEM S_PORTALS -#include - -#ifdef __KERNEL__ -# include /* for memset() */ -# include -# ifdef KERNEL_ADDR_CACHE -# include -# endif -#else -# include -# include -#endif - -#ifndef PTL_USE_LIB_FREELIST - -int -kportal_descriptor_setup (lib_nal_t *nal, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - /* Ignore requested limits! */ - actual_limits->max_mes = INT_MAX; - actual_limits->max_mds = INT_MAX; - actual_limits->max_eqs = INT_MAX; - - return PTL_OK; -} - -void -kportal_descriptor_cleanup (lib_nal_t *nal) -{ -} -#else - -int -lib_freelist_init (lib_nal_t *nal, lib_freelist_t *fl, int n, int size) -{ - char *space; - - LASSERT (n > 0); - - size += offsetof (lib_freeobj_t, fo_contents); - - PORTAL_ALLOC(space, n * size); - if (space == NULL) - return (PTL_NO_SPACE); - - INIT_LIST_HEAD (&fl->fl_list); - fl->fl_objs = space; - fl->fl_nobjs = n; - fl->fl_objsize = size; - - do - { - memset (space, 0, size); - list_add ((struct list_head *)space, &fl->fl_list); - space += size; - } while (--n != 0); - - return (PTL_OK); -} - -void -lib_freelist_fini (lib_nal_t *nal, lib_freelist_t *fl) -{ - struct list_head *el; - int count; - - if (fl->fl_nobjs == 0) - return; - - count = 0; - for (el = fl->fl_list.next; el != &fl->fl_list; el = el->next) - count++; - - LASSERT (count == fl->fl_nobjs); - - PORTAL_FREE(fl->fl_objs, fl->fl_nobjs * fl->fl_objsize); - memset (fl, 0, sizeof (fl)); -} - -int -kportal_descriptor_setup (lib_nal_t *nal, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - /* NB on failure caller must still call kportal_descriptor_cleanup */ - /* ****** */ - lib_ni_t *ni = &nal->libnal_ni; - int rc; - - memset (&ni->ni_free_mes, 0, sizeof (ni->ni_free_mes)); - memset (&ni->ni_free_msgs, 0, sizeof (ni->ni_free_msgs)); - memset (&ni->ni_free_mds, 0, sizeof (ni->ni_free_mds)); - memset (&ni->ni_free_eqs, 0, sizeof (ni->ni_free_eqs)); - - /* Ignore requested limits! */ - actual_limits->max_mes = MAX_MES; - actual_limits->max_mds = MAX_MDS; - actual_limits->max_eqs = MAX_EQS; - /* Hahahah what a load of bollocks. There's nowhere to - * specify the max # messages in-flight */ - - rc = lib_freelist_init (nal, &ni->ni_free_mes, - MAX_MES, sizeof (lib_me_t)); - if (rc != PTL_OK) - return (rc); - - rc = lib_freelist_init (nal, &ni->ni_free_msgs, - MAX_MSGS, sizeof (lib_msg_t)); - if (rc != PTL_OK) - return (rc); - - rc = lib_freelist_init (nal, &ni->ni_free_mds, - MAX_MDS, sizeof (lib_md_t)); - if (rc != PTL_OK) - return (rc); - - rc = lib_freelist_init (nal, &ni->ni_free_eqs, - MAX_EQS, sizeof (lib_eq_t)); - return (rc); -} - -void -kportal_descriptor_cleanup (lib_nal_t *nal) -{ - lib_ni_t *ni = &nal->libnal_ni; - - lib_freelist_fini (nal, &ni->ni_free_mes); - lib_freelist_fini (nal, &ni->ni_free_msgs); - lib_freelist_fini (nal, &ni->ni_free_mds); - lib_freelist_fini (nal, &ni->ni_free_eqs); -} - -#endif - -__u64 -lib_create_interface_cookie (lib_nal_t *nal) -{ - /* NB the interface cookie in wire handles guards against delayed - * replies and ACKs appearing valid in a new instance of the same - * interface. Initialisation time, even if it's only implemented - * to millisecond resolution is probably easily good enough. */ - struct timeval tv; - __u64 cookie; -#ifndef __KERNEL__ - int rc = gettimeofday (&tv, NULL); - LASSERT (rc == 0); -#else - do_gettimeofday(&tv); -#endif - cookie = tv.tv_sec; - cookie *= 1000000; - cookie += tv.tv_usec; - return (cookie); -} - -int -lib_setup_handle_hash (lib_nal_t *nal) -{ - lib_ni_t *ni = &nal->libnal_ni; - int i; - - /* Arbitrary choice of hash table size */ -#ifdef __KERNEL__ - ni->ni_lh_hash_size = PAGE_SIZE / sizeof (struct list_head); -#else - ni->ni_lh_hash_size = (MAX_MES + MAX_MDS + MAX_EQS)/4; -#endif - PORTAL_ALLOC(ni->ni_lh_hash_table, - ni->ni_lh_hash_size * sizeof (struct list_head)); - if (ni->ni_lh_hash_table == NULL) - return (PTL_NO_SPACE); - - for (i = 0; i < ni->ni_lh_hash_size; i++) - INIT_LIST_HEAD (&ni->ni_lh_hash_table[i]); - - ni->ni_next_object_cookie = PTL_COOKIE_TYPES; - - return (PTL_OK); -} - -void -lib_cleanup_handle_hash (lib_nal_t *nal) -{ - lib_ni_t *ni = &nal->libnal_ni; - - if (ni->ni_lh_hash_table == NULL) - return; - - PORTAL_FREE(ni->ni_lh_hash_table, - ni->ni_lh_hash_size * sizeof (struct list_head)); -} - -lib_handle_t * -lib_lookup_cookie (lib_nal_t *nal, __u64 cookie, int type) -{ - /* ALWAYS called with statelock held */ - lib_ni_t *ni = &nal->libnal_ni; - struct list_head *list; - struct list_head *el; - unsigned int hash; - - if ((cookie & (PTL_COOKIE_TYPES - 1)) != type) - return (NULL); - - hash = ((unsigned int)cookie) % ni->ni_lh_hash_size; - list = &ni->ni_lh_hash_table[hash]; - - list_for_each (el, list) { - lib_handle_t *lh = list_entry (el, lib_handle_t, lh_hash_chain); - - if (lh->lh_cookie == cookie) - return (lh); - } - - return (NULL); -} - -void -lib_initialise_handle (lib_nal_t *nal, lib_handle_t *lh, int type) -{ - /* ALWAYS called with statelock held */ - lib_ni_t *ni = &nal->libnal_ni; - unsigned int hash; - - LASSERT (type >= 0 && type < PTL_COOKIE_TYPES); - lh->lh_cookie = ni->ni_next_object_cookie | type; - ni->ni_next_object_cookie += PTL_COOKIE_TYPES; - - hash = ((unsigned int)lh->lh_cookie) % ni->ni_lh_hash_size; - list_add (&lh->lh_hash_chain, &ni->ni_lh_hash_table[hash]); -} - -void -lib_invalidate_handle (lib_nal_t *nal, lib_handle_t *lh) -{ - list_del (&lh->lh_hash_chain); -} - -int -lib_init(lib_nal_t *libnal, nal_t *apinal, - ptl_process_id_t process_id, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - int rc = PTL_OK; - lib_ni_t *ni = &libnal->libnal_ni; - int ptl_size; - int i; - ENTRY; - - /* NB serialised in PtlNIInit() */ - - lib_assert_wire_constants (); - - /* Setup the API nal with the lib API handling functions */ - apinal->nal_get_id = lib_api_get_id; - apinal->nal_ni_status = lib_api_ni_status; - apinal->nal_ni_dist = lib_api_ni_dist; - apinal->nal_fail_nid = lib_api_fail_nid; - apinal->nal_me_attach = lib_api_me_attach; - apinal->nal_me_insert = lib_api_me_insert; - apinal->nal_me_unlink = lib_api_me_unlink; - apinal->nal_md_attach = lib_api_md_attach; - apinal->nal_md_bind = lib_api_md_bind; - apinal->nal_md_unlink = lib_api_md_unlink; - apinal->nal_md_update = lib_api_md_update; - apinal->nal_eq_alloc = lib_api_eq_alloc; - apinal->nal_eq_free = lib_api_eq_free; - apinal->nal_eq_poll = lib_api_eq_poll; - apinal->nal_put = lib_api_put; - apinal->nal_get = lib_api_get; - - apinal->nal_data = libnal; - ni->ni_api = apinal; - - rc = kportal_descriptor_setup (libnal, requested_limits, - &ni->ni_actual_limits); - if (rc != PTL_OK) - goto out; - - memset(&ni->ni_counters, 0, sizeof(lib_counters_t)); - - INIT_LIST_HEAD (&ni->ni_active_msgs); - INIT_LIST_HEAD (&ni->ni_active_mds); - INIT_LIST_HEAD (&ni->ni_active_eqs); - INIT_LIST_HEAD (&ni->ni_test_peers); - -#ifdef __KERNEL__ - spin_lock_init (&ni->ni_lock); - init_waitqueue_head (&ni->ni_waitq); -#else - pthread_mutex_init(&ni->ni_mutex, NULL); - pthread_cond_init(&ni->ni_cond, NULL); -#endif - - ni->ni_interface_cookie = lib_create_interface_cookie (libnal); - ni->ni_next_object_cookie = 0; - rc = lib_setup_handle_hash (libnal); - if (rc != PTL_OK) - goto out; - - ni->ni_pid = process_id; - - if (requested_limits != NULL) - ptl_size = requested_limits->max_pt_index + 1; - else - ptl_size = 64; - - ni->ni_portals.size = ptl_size; - PORTAL_ALLOC(ni->ni_portals.tbl, - ptl_size * sizeof(struct list_head)); - if (ni->ni_portals.tbl == NULL) { - rc = PTL_NO_SPACE; - goto out; - } - - for (i = 0; i < ptl_size; i++) - INIT_LIST_HEAD(&(ni->ni_portals.tbl[i])); - - /* max_{mes,mds,eqs} set in kportal_descriptor_setup */ - - /* We don't have an access control table! */ - ni->ni_actual_limits.max_ac_index = -1; - - ni->ni_actual_limits.max_pt_index = ptl_size - 1; - ni->ni_actual_limits.max_md_iovecs = PTL_MD_MAX_IOV; - ni->ni_actual_limits.max_me_list = INT_MAX; - - /* We don't support PtlGetPut! */ - ni->ni_actual_limits.max_getput_md = 0; - - if (actual_limits != NULL) - *actual_limits = ni->ni_actual_limits; - - out: - if (rc != PTL_OK) { - lib_cleanup_handle_hash (libnal); - kportal_descriptor_cleanup (libnal); - } - - RETURN (rc); -} - -int -lib_fini(lib_nal_t *nal) -{ - lib_ni_t *ni = &nal->libnal_ni; - int idx; - - /* NB no state_lock() since this is the last reference. The NAL - * should have shut down already, so it should be safe to unlink - * and free all descriptors, even those that appear committed to a - * network op (eg MD with non-zero pending count) - */ - - for (idx = 0; idx < ni->ni_portals.size; idx++) - while (!list_empty (&ni->ni_portals.tbl[idx])) { - lib_me_t *me = list_entry (ni->ni_portals.tbl[idx].next, - lib_me_t, me_list); - - CERROR ("Active me %p on exit\n", me); - list_del (&me->me_list); - lib_me_free (nal, me); - } - - while (!list_empty (&ni->ni_active_mds)) { - lib_md_t *md = list_entry (ni->ni_active_mds.next, - lib_md_t, md_list); - - CERROR ("Active md %p on exit\n", md); - list_del (&md->md_list); - lib_md_free (nal, md); - } - - while (!list_empty (&ni->ni_active_eqs)) { - lib_eq_t *eq = list_entry (ni->ni_active_eqs.next, - lib_eq_t, eq_list); - - CERROR ("Active eq %p on exit\n", eq); - list_del (&eq->eq_list); - lib_eq_free (nal, eq); - } - - while (!list_empty (&ni->ni_active_msgs)) { - lib_msg_t *msg = list_entry (ni->ni_active_msgs.next, - lib_msg_t, msg_list); - - CERROR ("Active msg %p on exit\n", msg); - list_del (&msg->msg_list); - lib_msg_free (nal, msg); - } - - PORTAL_FREE(ni->ni_portals.tbl, - ni->ni_portals.size * sizeof(struct list_head)); - - lib_cleanup_handle_hash (nal); - kportal_descriptor_cleanup (nal); - -#ifndef __KERNEL__ - pthread_mutex_destroy(&ni->ni_mutex); - pthread_cond_destroy(&ni->ni_cond); -#endif - - return (PTL_OK); -} diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c deleted file mode 100644 index 6deadb8..0000000 --- a/lnet/lnet/lib-md.c +++ /dev/null @@ -1,426 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-md.c - * Memory Descriptor management routines - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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 __KERNEL__ -# include -#else -# define DEBUG_SUBSYSTEM S_PORTALS -# include -#endif - -#include - -/* must be called with state lock held */ -void -lib_md_unlink(lib_nal_t *nal, lib_md_t *md) -{ - if ((md->md_flags & PTL_MD_FLAG_ZOMBIE) == 0) { - /* first unlink attempt... */ - lib_me_t *me = md->me; - - md->md_flags |= PTL_MD_FLAG_ZOMBIE; - - /* Disassociate from ME (if any), and unlink it if it was created - * with PTL_UNLINK */ - if (me != NULL) { - me->md = NULL; - if (me->unlink == PTL_UNLINK) - lib_me_unlink(nal, me); - } - - /* emsure all future handle lookups fail */ - lib_invalidate_handle(nal, &md->md_lh); - } - - if (md->pending != 0) { - CDEBUG(D_NET, "Queueing unlink of md %p\n", md); - return; - } - - CDEBUG(D_NET, "Unlinking md %p\n", md); - - if ((md->options & PTL_MD_KIOV) != 0) { - if (nal->libnal_unmap_pages != NULL) - nal->libnal_unmap_pages (nal, - md->md_niov, - md->md_iov.kiov, - &md->md_addrkey); - } else if (nal->libnal_unmap != NULL) { - nal->libnal_unmap (nal, - md->md_niov, md->md_iov.iov, - &md->md_addrkey); - } - - if (md->eq != NULL) { - md->eq->eq_refcount--; - LASSERT (md->eq->eq_refcount >= 0); - } - - list_del (&md->md_list); - lib_md_free(nal, md); -} - -/* must be called with state lock held */ -static int -lib_md_build(lib_nal_t *nal, lib_md_t *lmd, ptl_md_t *umd, int unlink) -{ - lib_eq_t *eq = NULL; - int rc; - int i; - int niov; - int total_length = 0; - - /* NB we are passed an allocated, but uninitialised/active md. - * if we return success, caller may lib_md_unlink() it. - * otherwise caller may only lib_md_free() it. - */ - - if (!PtlHandleIsEqual (umd->eq_handle, PTL_EQ_NONE)) { - eq = ptl_handle2eq(&umd->eq_handle, nal); - if (eq == NULL) - return PTL_EQ_INVALID; - } - - /* This implementation doesn't know how to create START events or - * disable END events. Best to LASSERT our caller is compliant so - * we find out quickly... */ - LASSERT (eq == NULL || - ((umd->options & PTL_MD_EVENT_START_DISABLE) != 0 && - (umd->options & PTL_MD_EVENT_END_DISABLE) == 0)); - - lmd->me = NULL; - lmd->start = umd->start; - lmd->offset = 0; - lmd->max_size = umd->max_size; - lmd->options = umd->options; - lmd->user_ptr = umd->user_ptr; - lmd->eq = eq; - lmd->threshold = umd->threshold; - lmd->pending = 0; - lmd->md_flags = (unlink == PTL_UNLINK) ? PTL_MD_FLAG_AUTO_UNLINK : 0; - - if ((umd->options & PTL_MD_IOVEC) != 0) { - - if ((umd->options & PTL_MD_KIOV) != 0) /* Can't specify both */ - return PTL_MD_ILLEGAL; - - lmd->md_niov = niov = umd->length; - memcpy(lmd->md_iov.iov, umd->start, - niov * sizeof (lmd->md_iov.iov[0])); - - for (i = 0; i < niov; i++) { - /* We take the base address on trust */ - if (lmd->md_iov.iov[i].iov_len <= 0) /* invalid length */ - return PTL_MD_ILLEGAL; - - total_length += lmd->md_iov.iov[i].iov_len; - } - - lmd->length = total_length; - - if ((umd->options & PTL_MD_MAX_SIZE) != 0 && /* max size used */ - (umd->max_size < 0 || - umd->max_size > total_length)) // illegal max_size - return PTL_MD_ILLEGAL; - - if (nal->libnal_map != NULL) { - rc = nal->libnal_map (nal, niov, lmd->md_iov.iov, - &lmd->md_addrkey); - if (rc != PTL_OK) - return (rc); - } - } else if ((umd->options & PTL_MD_KIOV) != 0) { -#ifndef __KERNEL__ - return PTL_MD_ILLEGAL; -#else - /* Trap attempt to use paged I/O if unsupported early. */ - if (nal->libnal_send_pages == NULL || - nal->libnal_recv_pages == NULL) - return PTL_MD_INVALID; - - lmd->md_niov = niov = umd->length; - memcpy(lmd->md_iov.kiov, umd->start, - niov * sizeof (lmd->md_iov.kiov[0])); - - for (i = 0; i < niov; i++) { - /* We take the page pointer on trust */ - if (lmd->md_iov.kiov[i].kiov_offset + - lmd->md_iov.kiov[i].kiov_len > PAGE_SIZE ) - return PTL_VAL_FAILED; /* invalid length */ - - total_length += lmd->md_iov.kiov[i].kiov_len; - } - - lmd->length = total_length; - - if ((umd->options & PTL_MD_MAX_SIZE) != 0 && /* max size used */ - (umd->max_size < 0 || - umd->max_size > total_length)) // illegal max_size - return PTL_MD_ILLEGAL; - - if (nal->libnal_map_pages != NULL) { - rc = nal->libnal_map_pages (nal, niov, lmd->md_iov.kiov, - &lmd->md_addrkey); - if (rc != PTL_OK) - return (rc); - } -#endif - } else { /* contiguous */ - lmd->length = umd->length; - lmd->md_niov = niov = 1; - lmd->md_iov.iov[0].iov_base = umd->start; - lmd->md_iov.iov[0].iov_len = umd->length; - - if ((umd->options & PTL_MD_MAX_SIZE) != 0 && /* max size used */ - (umd->max_size < 0 || - umd->max_size > umd->length)) // illegal max_size - return PTL_MD_ILLEGAL; - - if (nal->libnal_map != NULL) { - rc = nal->libnal_map (nal, niov, lmd->md_iov.iov, - &lmd->md_addrkey); - if (rc != PTL_OK) - return (rc); - } - } - - if (eq != NULL) - eq->eq_refcount++; - - /* It's good; let handle2md succeed and add to active mds */ - lib_initialise_handle (nal, &lmd->md_lh, PTL_COOKIE_TYPE_MD); - list_add (&lmd->md_list, &nal->libnal_ni.ni_active_mds); - - return PTL_OK; -} - -/* must be called with state lock held */ -void -lib_md_deconstruct(lib_nal_t *nal, lib_md_t *lmd, ptl_md_t *umd) -{ - /* NB this doesn't copy out all the iov entries so when a - * discontiguous MD is copied out, the target gets to know the - * original iov pointer (in start) and the number of entries it had - * and that's all. - */ - umd->start = lmd->start; - umd->length = ((lmd->options & (PTL_MD_IOVEC | PTL_MD_KIOV)) == 0) ? - lmd->length : lmd->md_niov; - umd->threshold = lmd->threshold; - umd->max_size = lmd->max_size; - umd->options = lmd->options; - umd->user_ptr = lmd->user_ptr; - ptl_eq2handle(&umd->eq_handle, nal, lmd->eq); -} - -int -lib_api_md_attach(nal_t *apinal, ptl_handle_me_t *meh, - ptl_md_t *umd, ptl_unlink_t unlink, - ptl_handle_md_t *handle) -{ - lib_nal_t *nal = apinal->nal_data; - lib_me_t *me; - lib_md_t *md; - unsigned long flags; - int rc; - - if ((umd->options & (PTL_MD_KIOV | PTL_MD_IOVEC)) != 0 && - umd->length > PTL_MD_MAX_IOV) /* too many fragments */ - return PTL_IOV_INVALID; - - md = lib_md_alloc(nal, umd); - if (md == NULL) - return PTL_NO_SPACE; - - LIB_LOCK(nal, flags); - - me = ptl_handle2me(meh, nal); - if (me == NULL) { - rc = PTL_ME_INVALID; - } else if (me->md != NULL) { - rc = PTL_ME_IN_USE; - } else { - rc = lib_md_build(nal, md, umd, unlink); - if (rc == PTL_OK) { - me->md = md; - md->me = me; - - ptl_md2handle(handle, nal, md); - - LIB_UNLOCK(nal, flags); - return (PTL_OK); - } - } - - lib_md_free (nal, md); - - LIB_UNLOCK(nal, flags); - return (rc); -} - -int -lib_api_md_bind(nal_t *apinal, - ptl_md_t *umd, ptl_unlink_t unlink, - ptl_handle_md_t *handle) -{ - lib_nal_t *nal = apinal->nal_data; - lib_md_t *md; - unsigned long flags; - int rc; - - if ((umd->options & (PTL_MD_KIOV | PTL_MD_IOVEC)) != 0 && - umd->length > PTL_MD_MAX_IOV) /* too many fragments */ - return PTL_IOV_INVALID; - - md = lib_md_alloc(nal, umd); - if (md == NULL) - return PTL_NO_SPACE; - - LIB_LOCK(nal, flags); - - rc = lib_md_build(nal, md, umd, unlink); - - if (rc == PTL_OK) { - ptl_md2handle(handle, nal, md); - - LIB_UNLOCK(nal, flags); - return (PTL_OK); - } - - lib_md_free (nal, md); - - LIB_UNLOCK(nal, flags); - return (rc); -} - -int -lib_api_md_unlink (nal_t *apinal, ptl_handle_md_t *mdh) -{ - lib_nal_t *nal = apinal->nal_data; - ptl_event_t ev; - lib_md_t *md; - unsigned long flags; - - LIB_LOCK(nal, flags); - - md = ptl_handle2md(mdh, nal); - if (md == NULL) { - LIB_UNLOCK(nal, flags); - return PTL_MD_INVALID; - } - - /* If the MD is busy, lib_md_unlink just marks it for deletion, and - * when the NAL is done, the completion event flags that the MD was - * unlinked. Otherwise, we enqueue an event now... */ - - if (md->eq != NULL && - md->pending == 0) { - memset(&ev, 0, sizeof(ev)); - - ev.type = PTL_EVENT_UNLINK; - ev.ni_fail_type = PTL_OK; - ev.unlinked = 1; - lib_md_deconstruct(nal, md, &ev.md); - ptl_md2handle(&ev.md_handle, nal, md); - - lib_enq_event_locked(nal, NULL, md->eq, &ev); - } - - lib_md_unlink(nal, md); - - LIB_UNLOCK(nal, flags); - return PTL_OK; -} - -int -lib_api_md_update (nal_t *apinal, - ptl_handle_md_t *mdh, - ptl_md_t *oldumd, ptl_md_t *newumd, - ptl_handle_eq_t *testqh) -{ - lib_nal_t *nal = apinal->nal_data; - lib_md_t *md; - lib_eq_t *test_eq = NULL; - unsigned long flags; - int rc; - - LIB_LOCK(nal, flags); - - md = ptl_handle2md(mdh, nal); - if (md == NULL) { - rc = PTL_MD_INVALID; - goto out; - } - - if (oldumd != NULL) - lib_md_deconstruct(nal, md, oldumd); - - if (newumd == NULL) { - rc = PTL_OK; - goto out; - } - - /* XXX fttb, the new MD must be the same "shape" wrt fragmentation, - * since we simply overwrite the old lib-md */ - if ((((newumd->options ^ md->options) & - (PTL_MD_IOVEC | PTL_MD_KIOV)) != 0) || - ((newumd->options & (PTL_MD_IOVEC | PTL_MD_KIOV)) != 0 && - newumd->length != md->md_niov)) { - rc = PTL_IOV_INVALID; - goto out; - } - - if (!PtlHandleIsEqual (*testqh, PTL_EQ_NONE)) { - test_eq = ptl_handle2eq(testqh, nal); - if (test_eq == NULL) { - rc = PTL_EQ_INVALID; - goto out; - } - } - - if (md->pending != 0) { - rc = PTL_MD_NO_UPDATE; - goto out; - } - - if (test_eq == NULL || - test_eq->eq_deq_seq == test_eq->eq_enq_seq) { - lib_me_t *me = md->me; - int unlink = (md->md_flags & PTL_MD_FLAG_AUTO_UNLINK) ? - PTL_UNLINK : PTL_RETAIN; - - // #warning this does not track eq refcounts properly - rc = lib_md_build(nal, md, newumd, unlink); - - md->me = me; - } else { - rc = PTL_MD_NO_UPDATE; - } - - out: - LIB_UNLOCK(nal, flags); - - return rc; -} diff --git a/lnet/lnet/lib-me.c b/lnet/lnet/lib-me.c deleted file mode 100644 index 9665b4f..0000000 --- a/lnet/lnet/lib-me.c +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-me.c - * Match Entry management routines - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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 __KERNEL__ -# include -#else -# define DEBUG_SUBSYSTEM S_PORTALS -# include -#endif - -#include - -int -lib_api_me_attach(nal_t *apinal, - ptl_pt_index_t portal, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, - ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle) -{ - lib_nal_t *nal = apinal->nal_data; - lib_ni_t *ni = &nal->libnal_ni; - lib_ptl_t *tbl = &ni->ni_portals; - lib_me_t *me; - unsigned long flags; - - if (portal >= tbl->size) - return PTL_PT_INDEX_INVALID; - - /* Should check for valid matchid, but not yet */ - - me = lib_me_alloc (nal); - if (me == NULL) - return PTL_NO_SPACE; - - LIB_LOCK(nal, flags); - - me->match_id = match_id; - me->match_bits = match_bits; - me->ignore_bits = ignore_bits; - me->unlink = unlink; - me->md = NULL; - - lib_initialise_handle (nal, &me->me_lh, PTL_COOKIE_TYPE_ME); - - if (pos == PTL_INS_AFTER) - list_add_tail(&me->me_list, &(tbl->tbl[portal])); - else - list_add(&me->me_list, &(tbl->tbl[portal])); - - ptl_me2handle(handle, nal, me); - - LIB_UNLOCK(nal, flags); - - return PTL_OK; -} - -int -lib_api_me_insert(nal_t *apinal, - ptl_handle_me_t *current_meh, - ptl_process_id_t match_id, - ptl_match_bits_t match_bits, - ptl_match_bits_t ignore_bits, - ptl_unlink_t unlink, ptl_ins_pos_t pos, - ptl_handle_me_t *handle) -{ - lib_nal_t *nal = apinal->nal_data; - lib_me_t *current_me; - lib_me_t *new_me; - unsigned long flags; - - new_me = lib_me_alloc (nal); - if (new_me == NULL) - return PTL_NO_SPACE; - - /* Should check for valid matchid, but not yet */ - - LIB_LOCK(nal, flags); - - current_me = ptl_handle2me(current_meh, nal); - if (current_me == NULL) { - lib_me_free (nal, new_me); - - LIB_UNLOCK(nal, flags); - return PTL_ME_INVALID; - } - - new_me->match_id = match_id; - new_me->match_bits = match_bits; - new_me->ignore_bits = ignore_bits; - new_me->unlink = unlink; - new_me->md = NULL; - - lib_initialise_handle (nal, &new_me->me_lh, PTL_COOKIE_TYPE_ME); - - if (pos == PTL_INS_AFTER) - list_add_tail(&new_me->me_list, ¤t_me->me_list); - else - list_add(&new_me->me_list, ¤t_me->me_list); - - ptl_me2handle(handle, nal, new_me); - - LIB_UNLOCK(nal, flags); - - return PTL_OK; -} - -int -lib_api_me_unlink (nal_t *apinal, ptl_handle_me_t *meh) -{ - lib_nal_t *nal = apinal->nal_data; - unsigned long flags; - lib_me_t *me; - int rc; - - LIB_LOCK(nal, flags); - - me = ptl_handle2me(meh, nal); - if (me == NULL) { - rc = PTL_ME_INVALID; - } else { - lib_me_unlink(nal, me); - rc = PTL_OK; - } - - LIB_UNLOCK(nal, flags); - - return (rc); -} - -/* call with state_lock please */ -void -lib_me_unlink(lib_nal_t *nal, lib_me_t *me) -{ - list_del (&me->me_list); - - if (me->md) { - me->md->me = NULL; - lib_md_unlink(nal, me->md); - } - - lib_invalidate_handle (nal, &me->me_lh); - lib_me_free(nal, me); -} - -#if 0 -static void -lib_me_dump(lib_nal_t *nal, lib_me_t * me) -{ - CWARN("Match Entry %p ("LPX64")\n", me, - me->me_lh.lh_cookie); - - CWARN("\tMatch/Ignore\t= %016lx / %016lx\n", - me->match_bits, me->ignore_bits); - - CWARN("\tMD\t= %p\n", me->md); - CWARN("\tprev\t= %p\n", - list_entry(me->me_list.prev, lib_me_t, me_list)); - CWARN("\tnext\t= %p\n", - list_entry(me->me_list.next, lib_me_t, me_list)); -} -#endif diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c deleted file mode 100644 index d584f1c..0000000 --- a/lnet/lnet/lib-move.c +++ /dev/null @@ -1,1427 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-move.c - * Data movement routines - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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 __KERNEL__ -# include -#else -# define DEBUG_SUBSYSTEM S_PORTALS -# include -#endif -#include -#include - -/* forward ref */ -static void lib_commit_md (lib_nal_t *nal, lib_md_t *md, lib_msg_t *msg); - -static lib_md_t * -lib_match_md(lib_nal_t *nal, int index, int op_mask, - ptl_nid_t src_nid, ptl_pid_t src_pid, - ptl_size_t rlength, ptl_size_t roffset, - ptl_match_bits_t match_bits, lib_msg_t *msg, - ptl_size_t *mlength_out, ptl_size_t *offset_out) -{ - lib_ni_t *ni = &nal->libnal_ni; - struct list_head *match_list = &ni->ni_portals.tbl[index]; - struct list_head *tmp; - lib_me_t *me; - lib_md_t *md; - ptl_size_t mlength; - ptl_size_t offset; - ENTRY; - - CDEBUG (D_NET, "Request from "LPU64".%d of length %d into portal %d " - "MB="LPX64"\n", src_nid, src_pid, rlength, index, match_bits); - - if (index < 0 || index >= ni->ni_portals.size) { - CERROR("Invalid portal %d not in [0-%d]\n", - index, ni->ni_portals.size); - goto failed; - } - - list_for_each (tmp, match_list) { - me = list_entry(tmp, lib_me_t, me_list); - md = me->md; - - /* ME attached but MD not attached yet */ - if (md == NULL) - continue; - - LASSERT (me == md->me); - - /* mismatched MD op */ - if ((md->options & op_mask) == 0) - continue; - - /* MD exhausted */ - if (lib_md_exhausted(md)) - continue; - - /* mismatched ME nid/pid? */ - if (me->match_id.nid != PTL_NID_ANY && - me->match_id.nid != src_nid) - continue; - - CDEBUG(D_NET, "match_id.pid [%x], src_pid [%x]\n", - me->match_id.pid, src_pid); - - if (me->match_id.pid != PTL_PID_ANY && - me->match_id.pid != src_pid) - continue; - - /* mismatched ME matchbits? */ - if (((me->match_bits ^ match_bits) & ~me->ignore_bits) != 0) - continue; - - /* Hurrah! This _is_ a match; check it out... */ - - if ((md->options & PTL_MD_MANAGE_REMOTE) == 0) - offset = md->offset; - else - offset = roffset; - - if ((md->options & PTL_MD_MAX_SIZE) != 0) { - mlength = md->max_size; - LASSERT (md->offset + mlength <= md->length); - } else { - mlength = md->length - offset; - } - - if (rlength <= mlength) { /* fits in allowed space */ - mlength = rlength; - } else if ((md->options & PTL_MD_TRUNCATE) == 0) { - /* this packet _really_ is too big */ - CERROR("Matching packet %d too big: %d left, " - "%d allowed\n", rlength, md->length - offset, - mlength); - goto failed; - } - - /* Commit to this ME/MD */ - CDEBUG(D_NET, "Incoming %s index %x from "LPU64"/%u of " - "length %d/%d into md "LPX64" [%d] + %d\n", - (op_mask == PTL_MD_OP_PUT) ? "put" : "get", - index, src_nid, src_pid, mlength, rlength, - md->md_lh.lh_cookie, md->md_niov, offset); - - lib_commit_md(nal, md, msg); - md->offset = offset + mlength; - - /* NB Caller sets ev.type and ev.hdr_data */ - msg->ev.initiator.nid = src_nid; - msg->ev.initiator.pid = src_pid; - msg->ev.pt_index = index; - msg->ev.match_bits = match_bits; - msg->ev.rlength = rlength; - msg->ev.mlength = mlength; - msg->ev.offset = offset; - - lib_md_deconstruct(nal, md, &msg->ev.md); - ptl_md2handle(&msg->ev.md_handle, nal, md); - - *offset_out = offset; - *mlength_out = mlength; - - /* Auto-unlink NOW, so the ME gets unlinked if required. - * We bumped md->pending above so the MD just gets flagged - * for unlink when it is finalized. */ - if ((md->md_flags & PTL_MD_FLAG_AUTO_UNLINK) != 0 && - lib_md_exhausted(md)) - lib_md_unlink(nal, md); - - RETURN (md); - } - - failed: - CERROR (LPU64": Dropping %s from "LPU64".%d portal %d match "LPX64 - " offset %d length %d: no match\n", - ni->ni_pid.nid, (op_mask == PTL_MD_OP_GET) ? "GET" : "PUT", - src_nid, src_pid, index, match_bits, roffset, rlength); - RETURN(NULL); -} - -int lib_api_fail_nid (nal_t *apinal, ptl_nid_t nid, unsigned int threshold) -{ - lib_nal_t *nal = apinal->nal_data; - lib_test_peer_t *tp; - unsigned long flags; - struct list_head *el; - struct list_head *next; - struct list_head cull; - - if (threshold != 0) { - /* Adding a new entry */ - PORTAL_ALLOC(tp, sizeof(*tp)); - if (tp == NULL) - return PTL_NO_SPACE; - - tp->tp_nid = nid; - tp->tp_threshold = threshold; - - LIB_LOCK(nal, flags); - list_add_tail (&tp->tp_list, &nal->libnal_ni.ni_test_peers); - LIB_UNLOCK(nal, flags); - return PTL_OK; - } - - /* removing entries */ - INIT_LIST_HEAD (&cull); - - LIB_LOCK(nal, flags); - - list_for_each_safe (el, next, &nal->libnal_ni.ni_test_peers) { - tp = list_entry (el, lib_test_peer_t, tp_list); - - if (tp->tp_threshold == 0 || /* needs culling anyway */ - nid == PTL_NID_ANY || /* removing all entries */ - tp->tp_nid == nid) /* matched this one */ - { - list_del (&tp->tp_list); - list_add (&tp->tp_list, &cull); - } - } - - LIB_UNLOCK(nal, flags); - - while (!list_empty (&cull)) { - tp = list_entry (cull.next, lib_test_peer_t, tp_list); - - list_del (&tp->tp_list); - PORTAL_FREE(tp, sizeof (*tp)); - } - return PTL_OK; -} - -static int -fail_peer (lib_nal_t *nal, ptl_nid_t nid, int outgoing) -{ - lib_test_peer_t *tp; - struct list_head *el; - struct list_head *next; - unsigned long flags; - struct list_head cull; - int fail = 0; - - INIT_LIST_HEAD (&cull); - - LIB_LOCK (nal, flags); - - list_for_each_safe (el, next, &nal->libnal_ni.ni_test_peers) { - tp = list_entry (el, lib_test_peer_t, tp_list); - - if (tp->tp_threshold == 0) { - /* zombie entry */ - if (outgoing) { - /* only cull zombies on outgoing tests, - * since we may be at interrupt priority on - * incoming messages. */ - list_del (&tp->tp_list); - list_add (&tp->tp_list, &cull); - } - continue; - } - - if (tp->tp_nid == PTL_NID_ANY || /* fail every peer */ - nid == tp->tp_nid) { /* fail this peer */ - fail = 1; - - if (tp->tp_threshold != PTL_MD_THRESH_INF) { - tp->tp_threshold--; - if (outgoing && - tp->tp_threshold == 0) { - /* see above */ - list_del (&tp->tp_list); - list_add (&tp->tp_list, &cull); - } - } - break; - } - } - - LIB_UNLOCK (nal, flags); - - while (!list_empty (&cull)) { - tp = list_entry (cull.next, lib_test_peer_t, tp_list); - list_del (&tp->tp_list); - - PORTAL_FREE(tp, sizeof (*tp)); - } - - return (fail); -} - -ptl_size_t -lib_iov_nob (int niov, struct iovec *iov) -{ - ptl_size_t nob = 0; - - while (niov-- > 0) - nob += (iov++)->iov_len; - - return (nob); -} - -void -lib_copy_iov2buf (char *dest, int niov, struct iovec *iov, - ptl_size_t offset, ptl_size_t len) -{ - ptl_size_t nob; - - if (len == 0) - return; - - /* skip complete frags before 'offset' */ - LASSERT (niov > 0); - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - iov++; - niov--; - LASSERT (niov > 0); - } - - do { - LASSERT (niov > 0); - nob = MIN (iov->iov_len - offset, len); - memcpy (dest, iov->iov_base + offset, nob); - - len -= nob; - dest += nob; - niov--; - iov++; - offset = 0; - } while (len > 0); -} - -void -lib_copy_buf2iov (int niov, struct iovec *iov, ptl_size_t offset, - char *src, ptl_size_t len) -{ - ptl_size_t nob; - - if (len == 0) - return; - - /* skip complete frags before 'offset' */ - LASSERT (niov > 0); - while (offset >= iov->iov_len) { - offset -= iov->iov_len; - iov++; - niov--; - LASSERT (niov > 0); - } - - do { - LASSERT (niov > 0); - nob = MIN (iov->iov_len - offset, len); - memcpy (iov->iov_base + offset, src, nob); - - len -= nob; - src += nob; - niov--; - iov++; - offset = 0; - } while (len > 0); -} - -int -lib_extract_iov (int dst_niov, struct iovec *dst, - int src_niov, struct iovec *src, - ptl_size_t offset, ptl_size_t len) -{ - /* Initialise 'dst' to the subset of 'src' starting at 'offset', - * for exactly 'len' bytes, and return the number of entries. - * NB not destructive to 'src' */ - ptl_size_t frag_len; - int niov; - - if (len == 0) /* no data => */ - return (0); /* no frags */ - - LASSERT (src_niov > 0); - while (offset >= src->iov_len) { /* skip initial frags */ - offset -= src->iov_len; - src_niov--; - src++; - LASSERT (src_niov > 0); - } - - niov = 1; - for (;;) { - LASSERT (src_niov > 0); - LASSERT (niov <= dst_niov); - - frag_len = src->iov_len - offset; - dst->iov_base = ((char *)src->iov_base) + offset; - - if (len <= frag_len) { - dst->iov_len = len; - return (niov); - } - - dst->iov_len = frag_len; - - len -= frag_len; - dst++; - src++; - niov++; - src_niov--; - offset = 0; - } -} - -#ifndef __KERNEL__ -ptl_size_t -lib_kiov_nob (int niov, ptl_kiov_t *kiov) -{ - LASSERT (0); - return (0); -} - -void -lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *kiov, - ptl_size_t offset, ptl_size_t len) -{ - LASSERT (0); -} - -void -lib_copy_buf2kiov (int niov, ptl_kiov_t *kiov, ptl_size_t offset, - char *src, ptl_size_t len) -{ - LASSERT (0); -} - -int -lib_extract_kiov (int dst_niov, ptl_kiov_t *dst, - int src_niov, ptl_kiov_t *src, - ptl_size_t offset, ptl_size_t len) -{ - LASSERT (0); -} - -#else - -ptl_size_t -lib_kiov_nob (int niov, ptl_kiov_t *kiov) -{ - ptl_size_t nob = 0; - - while (niov-- > 0) - nob += (kiov++)->kiov_len; - - return (nob); -} - -void -lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *kiov, - ptl_size_t offset, ptl_size_t len) -{ - ptl_size_t nob; - char *addr; - - if (len == 0) - return; - - LASSERT (!in_interrupt ()); - - LASSERT (niov > 0); - while (offset > kiov->kiov_len) { - offset -= kiov->kiov_len; - kiov++; - niov--; - LASSERT (niov > 0); - } - - do{ - LASSERT (niov > 0); - nob = MIN (kiov->kiov_len - offset, len); - - addr = ((char *)kmap (kiov->kiov_page)) + kiov->kiov_offset + offset; - memcpy (dest, addr, nob); - kunmap (kiov->kiov_page); - - len -= nob; - dest += nob; - niov--; - kiov++; - offset = 0; - } while (len > 0); -} - -void -lib_copy_buf2kiov (int niov, ptl_kiov_t *kiov, ptl_size_t offset, - char *src, ptl_size_t len) -{ - ptl_size_t nob; - char *addr; - - if (len == 0) - return; - - LASSERT (!in_interrupt ()); - - LASSERT (niov > 0); - while (offset >= kiov->kiov_len) { - offset -= kiov->kiov_len; - kiov++; - niov--; - LASSERT (niov > 0); - } - - do { - LASSERT (niov > 0); - nob = MIN (kiov->kiov_len - offset, len); - - addr = ((char *)kmap (kiov->kiov_page)) + kiov->kiov_offset + offset; - memcpy (addr, src, nob); - kunmap (kiov->kiov_page); - - len -= nob; - src += nob; - niov--; - kiov++; - offset = 0; - } while (len > 0); -} - -int -lib_extract_kiov (int dst_niov, ptl_kiov_t *dst, - int src_niov, ptl_kiov_t *src, - ptl_size_t offset, ptl_size_t len) -{ - /* Initialise 'dst' to the subset of 'src' starting at 'offset', - * for exactly 'len' bytes, and return the number of entries. - * NB not destructive to 'src' */ - ptl_size_t frag_len; - int niov; - - if (len == 0) /* no data => */ - return (0); /* no frags */ - - LASSERT (src_niov > 0); - while (offset >= src->kiov_len) { /* skip initial frags */ - offset -= src->kiov_len; - src_niov--; - src++; - LASSERT (src_niov > 0); - } - - niov = 1; - for (;;) { - LASSERT (src_niov > 0); - LASSERT (niov <= dst_niov); - - frag_len = src->kiov_len - offset; - dst->kiov_page = src->kiov_page; - dst->kiov_offset = src->kiov_offset + offset; - - if (len <= frag_len) { - dst->kiov_len = len; - LASSERT (dst->kiov_offset + dst->kiov_len <= PAGE_SIZE); - return (niov); - } - - dst->kiov_len = frag_len; - LASSERT (dst->kiov_offset + dst->kiov_len <= PAGE_SIZE); - - len -= frag_len; - dst++; - src++; - niov++; - src_niov--; - offset = 0; - } -} -#endif - -ptl_err_t -lib_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, lib_md_t *md, - ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen) -{ - if (mlen == 0) - return (nal->libnal_recv(nal, private, msg, - 0, NULL, - offset, mlen, rlen)); - - if ((md->options & PTL_MD_KIOV) == 0) - return (nal->libnal_recv(nal, private, msg, - md->md_niov, md->md_iov.iov, - offset, mlen, rlen)); - - return (nal->libnal_recv_pages(nal, private, msg, - md->md_niov, md->md_iov.kiov, - offset, mlen, rlen)); -} - -ptl_err_t -lib_send (lib_nal_t *nal, void *private, lib_msg_t *msg, - ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid, - lib_md_t *md, ptl_size_t offset, ptl_size_t len) -{ - if (len == 0) - return (nal->libnal_send(nal, private, msg, - hdr, type, nid, pid, - 0, NULL, - offset, len)); - - if ((md->options & PTL_MD_KIOV) == 0) - return (nal->libnal_send(nal, private, msg, - hdr, type, nid, pid, - md->md_niov, md->md_iov.iov, - offset, len)); - - return (nal->libnal_send_pages(nal, private, msg, - hdr, type, nid, pid, - md->md_niov, md->md_iov.kiov, - offset, len)); -} - -static void -lib_commit_md (lib_nal_t *nal, lib_md_t *md, lib_msg_t *msg) -{ - /* ALWAYS called holding the LIB_LOCK */ - lib_counters_t *counters = &nal->libnal_ni.ni_counters; - - /* Here, we commit the MD to a network OP by marking it busy and - * decrementing its threshold. Come what may, the network "owns" - * the MD until a call to lib_finalize() signals completion. */ - msg->md = md; - - md->pending++; - if (md->threshold != PTL_MD_THRESH_INF) { - LASSERT (md->threshold > 0); - md->threshold--; - } - - counters->msgs_alloc++; - if (counters->msgs_alloc > counters->msgs_max) - counters->msgs_max = counters->msgs_alloc; - - list_add (&msg->msg_list, &nal->libnal_ni.ni_active_msgs); -} - -static void -lib_drop_message (lib_nal_t *nal, void *private, ptl_hdr_t *hdr) -{ - unsigned long flags; - - /* CAVEAT EMPTOR: this only drops messages that we've not committed - * to receive (init_msg() not called) and therefore can't cause an - * event. */ - - LIB_LOCK(nal, flags); - nal->libnal_ni.ni_counters.drop_count++; - nal->libnal_ni.ni_counters.drop_length += hdr->payload_length; - LIB_UNLOCK(nal, flags); - - /* NULL msg => if NAL calls lib_finalize it will be a noop */ - (void) lib_recv(nal, private, NULL, NULL, 0, 0, hdr->payload_length); -} - -/* - * Incoming messages have a ptl_msg_t object associated with them - * by the library. This object encapsulates the state of the - * message and allows the NAL to do non-blocking receives or sends - * of long messages. - * - */ -static ptl_err_t -parse_put(lib_nal_t *nal, ptl_hdr_t *hdr, void *private, lib_msg_t *msg) -{ - lib_ni_t *ni = &nal->libnal_ni; - ptl_size_t mlength = 0; - ptl_size_t offset = 0; - ptl_err_t rc; - lib_md_t *md; - unsigned long flags; - - /* Convert put fields to host byte order */ - hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits); - hdr->msg.put.ptl_index = le32_to_cpu(hdr->msg.put.ptl_index); - hdr->msg.put.offset = le32_to_cpu(hdr->msg.put.offset); - - LIB_LOCK(nal, flags); - - md = lib_match_md(nal, hdr->msg.put.ptl_index, PTL_MD_OP_PUT, - hdr->src_nid, hdr->src_pid, - hdr->payload_length, hdr->msg.put.offset, - hdr->msg.put.match_bits, msg, - &mlength, &offset); - if (md == NULL) { - LIB_UNLOCK(nal, flags); - return (PTL_FAIL); - } - - msg->ev.type = PTL_EVENT_PUT_END; - msg->ev.hdr_data = hdr->msg.put.hdr_data; - - if (!ptl_is_wire_handle_none(&hdr->msg.put.ack_wmd) && - !(md->options & PTL_MD_ACK_DISABLE)) { - msg->ack_wmd = hdr->msg.put.ack_wmd; - } - - ni->ni_counters.recv_count++; - ni->ni_counters.recv_length += mlength; - - LIB_UNLOCK(nal, flags); - - rc = lib_recv(nal, private, msg, md, offset, mlength, - hdr->payload_length); - if (rc != PTL_OK) - CERROR(LPU64": error on receiving PUT from "LPU64": %d\n", - ni->ni_pid.nid, hdr->src_nid, rc); - - return (rc); -} - -static ptl_err_t -parse_get(lib_nal_t *nal, ptl_hdr_t *hdr, void *private, lib_msg_t *msg) -{ - lib_ni_t *ni = &nal->libnal_ni; - ptl_size_t mlength = 0; - ptl_size_t offset = 0; - lib_md_t *md; - ptl_hdr_t reply; - unsigned long flags; - int rc; - - /* Convert get fields to host byte order */ - hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits); - hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index); - hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length); - hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset); - - LIB_LOCK(nal, flags); - - md = lib_match_md(nal, hdr->msg.get.ptl_index, PTL_MD_OP_GET, - hdr->src_nid, hdr->src_pid, - hdr->msg.get.sink_length, hdr->msg.get.src_offset, - hdr->msg.get.match_bits, msg, - &mlength, &offset); - if (md == NULL) { - LIB_UNLOCK(nal, flags); - return (PTL_FAIL); - } - - msg->ev.type = PTL_EVENT_GET_END; - msg->ev.hdr_data = 0; - - ni->ni_counters.send_count++; - ni->ni_counters.send_length += mlength; - - LIB_UNLOCK(nal, flags); - - memset (&reply, 0, sizeof (reply)); - reply.type = cpu_to_le32(PTL_MSG_REPLY); - reply.dest_nid = cpu_to_le64(hdr->src_nid); - reply.dest_pid = cpu_to_le32(hdr->src_pid); - reply.src_nid = cpu_to_le64(ni->ni_pid.nid); - reply.src_pid = cpu_to_le32(ni->ni_pid.pid); - reply.payload_length = cpu_to_le32(mlength); - - reply.msg.reply.dst_wmd = hdr->msg.get.return_wmd; - - /* NB call lib_send() _BEFORE_ lib_recv() completes the incoming - * message. Some NALs _require_ this to implement optimized GET */ - - rc = lib_send (nal, private, msg, &reply, PTL_MSG_REPLY, - hdr->src_nid, hdr->src_pid, md, offset, mlength); - if (rc != PTL_OK) - CERROR(LPU64": Unable to send REPLY for GET from "LPU64": %d\n", - ni->ni_pid.nid, hdr->src_nid, rc); - - /* Discard any junk after the hdr */ - (void) lib_recv(nal, private, NULL, NULL, 0, 0, hdr->payload_length); - - return (rc); -} - -static ptl_err_t -parse_reply(lib_nal_t *nal, ptl_hdr_t *hdr, void *private, lib_msg_t *msg) -{ - lib_ni_t *ni = &nal->libnal_ni; - lib_md_t *md; - int rlength; - int length; - unsigned long flags; - ptl_err_t rc; - - LIB_LOCK(nal, flags); - - /* NB handles only looked up by creator (no flips) */ - md = ptl_wire_handle2md(&hdr->msg.reply.dst_wmd, nal); - if (md == NULL || md->threshold == 0) { - CERROR (LPU64": Dropping REPLY from "LPU64" for %s MD "LPX64"."LPX64"\n", - ni->ni_pid.nid, hdr->src_nid, - md == NULL ? "invalid" : "inactive", - hdr->msg.reply.dst_wmd.wh_interface_cookie, - hdr->msg.reply.dst_wmd.wh_object_cookie); - - LIB_UNLOCK(nal, flags); - return (PTL_FAIL); - } - - LASSERT (md->offset == 0); - - length = rlength = hdr->payload_length; - - if (length > md->length) { - if ((md->options & PTL_MD_TRUNCATE) == 0) { - CERROR (LPU64": Dropping REPLY from "LPU64 - " length %d for MD "LPX64" would overflow (%d)\n", - ni->ni_pid.nid, hdr->src_nid, length, - hdr->msg.reply.dst_wmd.wh_object_cookie, - md->length); - LIB_UNLOCK(nal, flags); - return (PTL_FAIL); - } - length = md->length; - } - - CDEBUG(D_NET, "Reply from "LPU64" of length %d/%d into md "LPX64"\n", - hdr->src_nid, length, rlength, - hdr->msg.reply.dst_wmd.wh_object_cookie); - - lib_commit_md(nal, md, msg); - - msg->ev.type = PTL_EVENT_REPLY_END; - msg->ev.initiator.nid = hdr->src_nid; - msg->ev.initiator.pid = hdr->src_pid; - msg->ev.rlength = rlength; - msg->ev.mlength = length; - msg->ev.offset = 0; - - lib_md_deconstruct(nal, md, &msg->ev.md); - ptl_md2handle(&msg->ev.md_handle, nal, md); - - ni->ni_counters.recv_count++; - ni->ni_counters.recv_length += length; - - LIB_UNLOCK(nal, flags); - - rc = lib_recv(nal, private, msg, md, 0, length, rlength); - if (rc != PTL_OK) - CERROR(LPU64": error on receiving REPLY from "LPU64": %d\n", - ni->ni_pid.nid, hdr->src_nid, rc); - - return (rc); -} - -static ptl_err_t -parse_ack(lib_nal_t *nal, ptl_hdr_t *hdr, void *private, lib_msg_t *msg) -{ - lib_ni_t *ni = &nal->libnal_ni; - lib_md_t *md; - unsigned long flags; - - /* Convert ack fields to host byte order */ - hdr->msg.ack.match_bits = le64_to_cpu(hdr->msg.ack.match_bits); - hdr->msg.ack.mlength = le32_to_cpu(hdr->msg.ack.mlength); - - LIB_LOCK(nal, flags); - - /* NB handles only looked up by creator (no flips) */ - md = ptl_wire_handle2md(&hdr->msg.ack.dst_wmd, nal); - if (md == NULL || md->threshold == 0) { - CDEBUG(D_INFO, LPU64": Dropping ACK from "LPU64" to %s MD " - LPX64"."LPX64"\n", ni->ni_pid.nid, hdr->src_nid, - (md == NULL) ? "invalid" : "inactive", - hdr->msg.ack.dst_wmd.wh_interface_cookie, - hdr->msg.ack.dst_wmd.wh_object_cookie); - - LIB_UNLOCK(nal, flags); - return (PTL_FAIL); - } - - CDEBUG(D_NET, LPU64": ACK from "LPU64" into md "LPX64"\n", - ni->ni_pid.nid, hdr->src_nid, - hdr->msg.ack.dst_wmd.wh_object_cookie); - - lib_commit_md(nal, md, msg); - - msg->ev.type = PTL_EVENT_ACK; - msg->ev.initiator.nid = hdr->src_nid; - msg->ev.initiator.pid = hdr->src_pid; - msg->ev.mlength = hdr->msg.ack.mlength; - msg->ev.match_bits = hdr->msg.ack.match_bits; - - lib_md_deconstruct(nal, md, &msg->ev.md); - ptl_md2handle(&msg->ev.md_handle, nal, md); - - ni->ni_counters.recv_count++; - - LIB_UNLOCK(nal, flags); - - /* We have received and matched up the ack OK, create the - * completion event now... */ - lib_finalize(nal, private, msg, PTL_OK); - - /* ...and now discard any junk after the hdr */ - (void) lib_recv(nal, private, NULL, NULL, 0, 0, hdr->payload_length); - - return (PTL_OK); -} - -static char * -hdr_type_string (ptl_hdr_t *hdr) -{ - switch (hdr->type) { - case PTL_MSG_ACK: - return ("ACK"); - case PTL_MSG_PUT: - return ("PUT"); - case PTL_MSG_GET: - return ("GET"); - case PTL_MSG_REPLY: - return ("REPLY"); - case PTL_MSG_HELLO: - return ("HELLO"); - default: - return (""); - } -} - -void print_hdr(lib_nal_t *nal, ptl_hdr_t * hdr) -{ - char *type_str = hdr_type_string (hdr); - - CWARN("P3 Header at %p of type %s\n", hdr, type_str); - CWARN(" From nid/pid "LPX64"/%u", hdr->src_nid, hdr->src_pid); - CWARN(" To nid/pid "LPX64"/%u\n", hdr->dest_nid, hdr->dest_pid); - - switch (hdr->type) { - default: - break; - - case PTL_MSG_PUT: - CWARN(" Ptl index %d, ack md "LPX64"."LPX64", " - "match bits "LPX64"\n", - hdr->msg.put.ptl_index, - hdr->msg.put.ack_wmd.wh_interface_cookie, - hdr->msg.put.ack_wmd.wh_object_cookie, - hdr->msg.put.match_bits); - CWARN(" Length %d, offset %d, hdr data "LPX64"\n", - hdr->payload_length, hdr->msg.put.offset, - hdr->msg.put.hdr_data); - break; - - case PTL_MSG_GET: - CWARN(" Ptl index %d, return md "LPX64"."LPX64", " - "match bits "LPX64"\n", hdr->msg.get.ptl_index, - hdr->msg.get.return_wmd.wh_interface_cookie, - hdr->msg.get.return_wmd.wh_object_cookie, - hdr->msg.get.match_bits); - CWARN(" Length %d, src offset %d\n", - hdr->msg.get.sink_length, - hdr->msg.get.src_offset); - break; - - case PTL_MSG_ACK: - CWARN(" dst md "LPX64"."LPX64", " - "manipulated length %d\n", - hdr->msg.ack.dst_wmd.wh_interface_cookie, - hdr->msg.ack.dst_wmd.wh_object_cookie, - hdr->msg.ack.mlength); - break; - - case PTL_MSG_REPLY: - CWARN(" dst md "LPX64"."LPX64", " - "length %d\n", - hdr->msg.reply.dst_wmd.wh_interface_cookie, - hdr->msg.reply.dst_wmd.wh_object_cookie, - hdr->payload_length); - } - -} /* end of print_hdr() */ - - -ptl_err_t -lib_parse(lib_nal_t *nal, ptl_hdr_t *hdr, void *private) -{ - unsigned long flags; - ptl_err_t rc; - lib_msg_t *msg; - - /* NB we return PTL_OK if we manage to parse the header and believe - * it looks OK. Anything that goes wrong with receiving the - * message after that point is the responsibility of the NAL */ - - /* convert common fields to host byte order */ - hdr->type = le32_to_cpu(hdr->type); - hdr->src_nid = le64_to_cpu(hdr->src_nid); - hdr->src_pid = le32_to_cpu(hdr->src_pid); - hdr->dest_pid = le32_to_cpu(hdr->dest_pid); - hdr->payload_length = le32_to_cpu(hdr->payload_length); - - switch (hdr->type) { - case PTL_MSG_HELLO: { - /* dest_nid is really ptl_magicversion_t */ - ptl_magicversion_t *mv = (ptl_magicversion_t *)&hdr->dest_nid; - - mv->magic = le32_to_cpu(mv->magic); - mv->version_major = le16_to_cpu(mv->version_major); - mv->version_minor = le16_to_cpu(mv->version_minor); - - if (mv->magic == PORTALS_PROTO_MAGIC && - mv->version_major == PORTALS_PROTO_VERSION_MAJOR && - mv->version_minor == PORTALS_PROTO_VERSION_MINOR) { - CWARN (LPU64": Dropping unexpected HELLO message: " - "magic %d, version %d.%d from "LPD64"\n", - nal->libnal_ni.ni_pid.nid, mv->magic, - mv->version_major, mv->version_minor, - hdr->src_nid); - - /* it's good but we don't want it */ - lib_drop_message(nal, private, hdr); - return PTL_OK; - } - - /* we got garbage */ - CERROR (LPU64": Bad HELLO message: " - "magic %d, version %d.%d from "LPD64"\n", - nal->libnal_ni.ni_pid.nid, mv->magic, - mv->version_major, mv->version_minor, - hdr->src_nid); - return PTL_FAIL; - } - - case PTL_MSG_ACK: - case PTL_MSG_PUT: - case PTL_MSG_GET: - case PTL_MSG_REPLY: - hdr->dest_nid = le64_to_cpu(hdr->dest_nid); - if (hdr->dest_nid != nal->libnal_ni.ni_pid.nid) { - CERROR(LPU64": BAD dest NID in %s message from" - LPU64" to "LPU64" (not me)\n", - nal->libnal_ni.ni_pid.nid, hdr_type_string (hdr), - hdr->src_nid, hdr->dest_nid); - return PTL_FAIL; - } - break; - - default: - CERROR(LPU64": Bad message type 0x%x from "LPU64"\n", - nal->libnal_ni.ni_pid.nid, hdr->type, hdr->src_nid); - return PTL_FAIL; - } - - /* We've decided we're not receiving garbage since we can parse the - * header. We will return PTL_OK come what may... */ - - if (!list_empty (&nal->libnal_ni.ni_test_peers) && /* normally we don't */ - fail_peer (nal, hdr->src_nid, 0)) /* shall we now? */ - { - CERROR(LPU64": Dropping incoming %s from "LPU64 - ": simulated failure\n", - nal->libnal_ni.ni_pid.nid, hdr_type_string (hdr), - hdr->src_nid); - lib_drop_message(nal, private, hdr); - return PTL_OK; - } - - msg = lib_msg_alloc(nal); - if (msg == NULL) { - CERROR(LPU64": Dropping incoming %s from "LPU64 - ": can't allocate a lib_msg_t\n", - nal->libnal_ni.ni_pid.nid, hdr_type_string (hdr), - hdr->src_nid); - lib_drop_message(nal, private, hdr); - return PTL_OK; - } - - switch (hdr->type) { - case PTL_MSG_ACK: - rc = parse_ack(nal, hdr, private, msg); - break; - case PTL_MSG_PUT: - rc = parse_put(nal, hdr, private, msg); - break; - case PTL_MSG_GET: - rc = parse_get(nal, hdr, private, msg); - break; - case PTL_MSG_REPLY: - rc = parse_reply(nal, hdr, private, msg); - break; - default: - LASSERT(0); - rc = PTL_FAIL; /* no compiler warning please */ - break; - } - - if (rc != PTL_OK) { - if (msg->md != NULL) { - /* committed... */ - lib_finalize(nal, private, msg, rc); - } else { - LIB_LOCK(nal, flags); - lib_msg_free(nal, msg); /* expects LIB_LOCK held */ - LIB_UNLOCK(nal, flags); - - lib_drop_message(nal, private, hdr); - } - } - - return PTL_OK; - /* That's "OK I can parse it", not "OK I like it" :) */ -} - -int -lib_api_put(nal_t *apinal, ptl_handle_md_t *mdh, - ptl_ack_req_t ack, ptl_process_id_t *id, - ptl_pt_index_t portal, ptl_ac_index_t ac, - ptl_match_bits_t match_bits, - ptl_size_t offset, ptl_hdr_data_t hdr_data) -{ - lib_nal_t *nal = apinal->nal_data; - lib_ni_t *ni = &nal->libnal_ni; - lib_msg_t *msg; - ptl_hdr_t hdr; - lib_md_t *md; - unsigned long flags; - int rc; - - if (!list_empty (&ni->ni_test_peers) && /* normally we don't */ - fail_peer (nal, id->nid, 1)) /* shall we now? */ - { - CERROR("Dropping PUT to "LPU64": simulated failure\n", - id->nid); - return PTL_PROCESS_INVALID; - } - - msg = lib_msg_alloc(nal); - if (msg == NULL) { - CERROR(LPU64": Dropping PUT to "LPU64": ENOMEM on lib_msg_t\n", - ni->ni_pid.nid, id->nid); - return PTL_NO_SPACE; - } - - LIB_LOCK(nal, flags); - - md = ptl_handle2md(mdh, nal); - if (md == NULL || md->threshold == 0) { - lib_msg_free(nal, msg); - LIB_UNLOCK(nal, flags); - - return PTL_MD_INVALID; - } - - CDEBUG(D_NET, "PtlPut -> "LPX64"\n", id->nid); - - memset (&hdr, 0, sizeof (hdr)); - hdr.type = cpu_to_le32(PTL_MSG_PUT); - hdr.dest_nid = cpu_to_le64(id->nid); - hdr.dest_pid = cpu_to_le32(id->pid); - hdr.src_nid = cpu_to_le64(ni->ni_pid.nid); - hdr.src_pid = cpu_to_le32(ni->ni_pid.pid); - hdr.payload_length = cpu_to_le32(md->length); - - /* NB handles only looked up by creator (no flips) */ - if (ack == PTL_ACK_REQ) { - hdr.msg.put.ack_wmd.wh_interface_cookie = ni->ni_interface_cookie; - hdr.msg.put.ack_wmd.wh_object_cookie = md->md_lh.lh_cookie; - } else { - hdr.msg.put.ack_wmd = PTL_WIRE_HANDLE_NONE; - } - - hdr.msg.put.match_bits = cpu_to_le64(match_bits); - hdr.msg.put.ptl_index = cpu_to_le32(portal); - hdr.msg.put.offset = cpu_to_le32(offset); - hdr.msg.put.hdr_data = hdr_data; - - lib_commit_md(nal, md, msg); - - msg->ev.type = PTL_EVENT_SEND_END; - msg->ev.initiator.nid = ni->ni_pid.nid; - msg->ev.initiator.pid = ni->ni_pid.pid; - msg->ev.pt_index = portal; - msg->ev.match_bits = match_bits; - msg->ev.rlength = md->length; - msg->ev.mlength = md->length; - msg->ev.offset = offset; - msg->ev.hdr_data = hdr_data; - - lib_md_deconstruct(nal, md, &msg->ev.md); - ptl_md2handle(&msg->ev.md_handle, nal, md); - - ni->ni_counters.send_count++; - ni->ni_counters.send_length += md->length; - - LIB_UNLOCK(nal, flags); - - rc = lib_send (nal, NULL, msg, &hdr, PTL_MSG_PUT, - id->nid, id->pid, md, 0, md->length); - if (rc != PTL_OK) { - CERROR("Error sending PUT to "LPX64": %d\n", - id->nid, rc); - lib_finalize (nal, NULL, msg, rc); - } - - /* completion will be signalled by an event */ - return PTL_OK; -} - -lib_msg_t * -lib_create_reply_msg (lib_nal_t *nal, ptl_nid_t peer_nid, lib_msg_t *getmsg) -{ - /* The NAL can DMA direct to the GET md (i.e. no REPLY msg). This - * returns a msg for the NAL to pass to lib_finalize() when the sink - * data has been received. - * - * CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when - * lib_finalize() is called on it, so the NAL must call this first */ - - lib_ni_t *ni = &nal->libnal_ni; - lib_msg_t *msg = lib_msg_alloc(nal); - lib_md_t *getmd = getmsg->md; - unsigned long flags; - - LIB_LOCK(nal, flags); - - LASSERT (getmd->pending > 0); - - if (msg == NULL) { - CERROR ("Dropping REPLY from "LPU64": can't allocate msg\n", - peer_nid); - goto drop; - } - - if (getmd->threshold == 0) { - CERROR ("Dropping REPLY from "LPU64" for inactive MD %p\n", - peer_nid, getmd); - goto drop_msg; - } - - LASSERT (getmd->offset == 0); - - CDEBUG(D_NET, "Reply from "LPU64" md %p\n", peer_nid, getmd); - - lib_commit_md (nal, getmd, msg); - - msg->ev.type = PTL_EVENT_REPLY_END; - msg->ev.initiator.nid = peer_nid; - msg->ev.initiator.pid = 0; /* XXX FIXME!!! */ - msg->ev.rlength = msg->ev.mlength = getmd->length; - msg->ev.offset = 0; - - lib_md_deconstruct(nal, getmd, &msg->ev.md); - ptl_md2handle(&msg->ev.md_handle, nal, getmd); - - ni->ni_counters.recv_count++; - ni->ni_counters.recv_length += getmd->length; - - LIB_UNLOCK(nal, flags); - - return msg; - - drop_msg: - lib_msg_free(nal, msg); - drop: - nal->libnal_ni.ni_counters.drop_count++; - nal->libnal_ni.ni_counters.drop_length += getmd->length; - - LIB_UNLOCK (nal, flags); - - return NULL; -} - -int -lib_api_get(nal_t *apinal, ptl_handle_md_t *mdh, ptl_process_id_t *id, - ptl_pt_index_t portal, ptl_ac_index_t ac, - ptl_match_bits_t match_bits, ptl_size_t offset) -{ - lib_nal_t *nal = apinal->nal_data; - lib_ni_t *ni = &nal->libnal_ni; - lib_msg_t *msg; - ptl_hdr_t hdr; - lib_md_t *md; - unsigned long flags; - int rc; - - if (!list_empty (&ni->ni_test_peers) && /* normally we don't */ - fail_peer (nal, id->nid, 1)) /* shall we now? */ - { - CERROR("Dropping PUT to "LPX64": simulated failure\n", - id->nid); - return PTL_PROCESS_INVALID; - } - - msg = lib_msg_alloc(nal); - if (msg == NULL) { - CERROR("Dropping GET to "LPU64": ENOMEM on lib_msg_t\n", - id->nid); - return PTL_NO_SPACE; - } - - LIB_LOCK(nal, flags); - - md = ptl_handle2md(mdh, nal); - if (md == NULL || !md->threshold) { - lib_msg_free(nal, msg); - LIB_UNLOCK(nal, flags); - - return PTL_MD_INVALID; - } - - CDEBUG(D_NET, "PtlGet -> %Lu: %lu\n", (unsigned long long)id->nid, - (unsigned long)id->pid); - - memset (&hdr, 0, sizeof (hdr)); - hdr.type = cpu_to_le32(PTL_MSG_GET); - hdr.dest_nid = cpu_to_le64(id->nid); - hdr.dest_pid = cpu_to_le32(id->pid); - hdr.src_nid = cpu_to_le64(ni->ni_pid.nid); - hdr.src_pid = cpu_to_le32(ni->ni_pid.pid); - hdr.payload_length = 0; - - /* NB handles only looked up by creator (no flips) */ - hdr.msg.get.return_wmd.wh_interface_cookie = ni->ni_interface_cookie; - hdr.msg.get.return_wmd.wh_object_cookie = md->md_lh.lh_cookie; - - hdr.msg.get.match_bits = cpu_to_le64(match_bits); - hdr.msg.get.ptl_index = cpu_to_le32(portal); - hdr.msg.get.src_offset = cpu_to_le32(offset); - hdr.msg.get.sink_length = cpu_to_le32(md->length); - - lib_commit_md(nal, md, msg); - - msg->ev.type = PTL_EVENT_SEND_END; - msg->ev.initiator = ni->ni_pid; - msg->ev.pt_index = portal; - msg->ev.match_bits = match_bits; - msg->ev.rlength = md->length; - msg->ev.mlength = md->length; - msg->ev.offset = offset; - msg->ev.hdr_data = 0; - - lib_md_deconstruct(nal, md, &msg->ev.md); - ptl_md2handle(&msg->ev.md_handle, nal, md); - - ni->ni_counters.send_count++; - - LIB_UNLOCK(nal, flags); - - rc = lib_send (nal, NULL, msg, &hdr, PTL_MSG_GET, - id->nid, id->pid, NULL, 0, 0); - if (rc != PTL_OK) { - CERROR(LPU64": error sending GET to "LPU64": %d\n", - ni->ni_pid.nid, id->nid, rc); - lib_finalize (nal, NULL, msg, rc); - } - - /* completion will be signalled by an event */ - return PTL_OK; -} - -void lib_assert_wire_constants (void) -{ - /* Wire protocol assertions generated by 'wirecheck' - * running on Linux mdevi 2.4.21-p4smp-55chaos #1 SMP Tue Jun 8 14:38:44 PDT 2004 i686 i686 i - * with gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34) */ - - - /* Constants... */ - LASSERT (PORTALS_PROTO_MAGIC == 0xeebc0ded); - LASSERT (PORTALS_PROTO_VERSION_MAJOR == 1); - LASSERT (PORTALS_PROTO_VERSION_MINOR == 0); - LASSERT (PTL_MSG_ACK == 0); - LASSERT (PTL_MSG_PUT == 1); - LASSERT (PTL_MSG_GET == 2); - LASSERT (PTL_MSG_REPLY == 3); - LASSERT (PTL_MSG_HELLO == 4); - - /* Checks for struct ptl_handle_wire_t */ - LASSERT ((int)sizeof(ptl_handle_wire_t) == 16); - LASSERT ((int)offsetof(ptl_handle_wire_t, wh_interface_cookie) == 0); - LASSERT ((int)sizeof(((ptl_handle_wire_t *)0)->wh_interface_cookie) == 8); - LASSERT ((int)offsetof(ptl_handle_wire_t, wh_object_cookie) == 8); - LASSERT ((int)sizeof(((ptl_handle_wire_t *)0)->wh_object_cookie) == 8); - - /* Checks for struct ptl_magicversion_t */ - LASSERT ((int)sizeof(ptl_magicversion_t) == 8); - LASSERT ((int)offsetof(ptl_magicversion_t, magic) == 0); - LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->magic) == 4); - LASSERT ((int)offsetof(ptl_magicversion_t, version_major) == 4); - LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->version_major) == 2); - LASSERT ((int)offsetof(ptl_magicversion_t, version_minor) == 6); - LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->version_minor) == 2); - - /* Checks for struct ptl_hdr_t */ - LASSERT ((int)sizeof(ptl_hdr_t) == 72); - LASSERT ((int)offsetof(ptl_hdr_t, dest_nid) == 0); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->dest_nid) == 8); - LASSERT ((int)offsetof(ptl_hdr_t, src_nid) == 8); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->src_nid) == 8); - LASSERT ((int)offsetof(ptl_hdr_t, dest_pid) == 16); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->dest_pid) == 4); - LASSERT ((int)offsetof(ptl_hdr_t, src_pid) == 20); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->src_pid) == 4); - LASSERT ((int)offsetof(ptl_hdr_t, type) == 24); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->type) == 4); - LASSERT ((int)offsetof(ptl_hdr_t, payload_length) == 28); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->payload_length) == 4); - LASSERT ((int)offsetof(ptl_hdr_t, msg) == 32); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg) == 40); - - /* Ack */ - LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.dst_wmd) == 32); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.dst_wmd) == 16); - LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.match_bits) == 48); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.match_bits) == 8); - LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.mlength) == 56); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.mlength) == 4); - - /* Put */ - LASSERT ((int)offsetof(ptl_hdr_t, msg.put.ack_wmd) == 32); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.ack_wmd) == 16); - LASSERT ((int)offsetof(ptl_hdr_t, msg.put.match_bits) == 48); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.match_bits) == 8); - LASSERT ((int)offsetof(ptl_hdr_t, msg.put.hdr_data) == 56); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.hdr_data) == 8); - LASSERT ((int)offsetof(ptl_hdr_t, msg.put.ptl_index) == 64); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.ptl_index) == 4); - LASSERT ((int)offsetof(ptl_hdr_t, msg.put.offset) == 68); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.offset) == 4); - - /* Get */ - LASSERT ((int)offsetof(ptl_hdr_t, msg.get.return_wmd) == 32); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.return_wmd) == 16); - LASSERT ((int)offsetof(ptl_hdr_t, msg.get.match_bits) == 48); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.match_bits) == 8); - LASSERT ((int)offsetof(ptl_hdr_t, msg.get.ptl_index) == 56); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.ptl_index) == 4); - LASSERT ((int)offsetof(ptl_hdr_t, msg.get.src_offset) == 60); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.src_offset) == 4); - LASSERT ((int)offsetof(ptl_hdr_t, msg.get.sink_length) == 64); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.sink_length) == 4); - - /* Reply */ - LASSERT ((int)offsetof(ptl_hdr_t, msg.reply.dst_wmd) == 32); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.reply.dst_wmd) == 16); - - /* Hello */ - LASSERT ((int)offsetof(ptl_hdr_t, msg.hello.incarnation) == 32); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.hello.incarnation) == 8); - LASSERT ((int)offsetof(ptl_hdr_t, msg.hello.type) == 40); - LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.hello.type) == 4); -} diff --git a/lnet/lnet/lib-msg.c b/lnet/lnet/lib-msg.c deleted file mode 100644 index 54e89bc..0000000 --- a/lnet/lnet/lib-msg.c +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-msg.c - * Message decoding, parsing and finalizing routines - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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 __KERNEL__ -# include -#else -# define DEBUG_SUBSYSTEM S_PORTALS -# include -#endif - -#include - -void -lib_enq_event_locked (lib_nal_t *nal, void *private, - lib_eq_t *eq, ptl_event_t *ev) -{ - ptl_event_t *eq_slot; - - /* Allocate the next queue slot */ - ev->link = ev->sequence = eq->eq_enq_seq++; - /* NB we don't support START events yet and we don't create a separate - * UNLINK event unless an explicit unlink succeeds, so the link - * sequence is pretty useless */ - - /* We don't support different uid/jids yet */ - ev->uid = 0; - ev->jid = 0; - - /* size must be a power of 2 to handle sequence # overflow */ - LASSERT (eq->eq_size != 0 && - eq->eq_size == LOWEST_BIT_SET (eq->eq_size)); - eq_slot = eq->eq_events + (ev->sequence & (eq->eq_size - 1)); - - /* There is no race since both event consumers and event producers - * take the LIB_LOCK(), so we don't screw around with memory - * barriers, setting the sequence number last or wierd structure - * layout assertions. */ - *eq_slot = *ev; - - /* Call the callback handler (if any) */ - if (eq->eq_callback != NULL) - eq->eq_callback (eq_slot); - - /* Wake anyone sleeping for an event (see lib-eq.c) */ -#ifdef __KERNEL__ - if (waitqueue_active(&nal->libnal_ni.ni_waitq)) - wake_up_all(&nal->libnal_ni.ni_waitq); -#else - pthread_cond_broadcast(&nal->libnal_ni.ni_cond); -#endif -} - -void -lib_finalize (lib_nal_t *nal, void *private, lib_msg_t *msg, ptl_err_t status) -{ - lib_md_t *md; - int unlink; - unsigned long flags; - int rc; - ptl_hdr_t ack; - - if (msg == NULL) - return; - - /* Only send an ACK if the PUT completed successfully */ - if (status == PTL_OK && - !ptl_is_wire_handle_none(&msg->ack_wmd)) { - - LASSERT(msg->ev.type == PTL_EVENT_PUT_END); - - memset (&ack, 0, sizeof (ack)); - ack.type = cpu_to_le32(PTL_MSG_ACK); - ack.dest_nid = cpu_to_le64(msg->ev.initiator.nid); - ack.dest_pid = cpu_to_le32(msg->ev.initiator.pid); - ack.src_nid = cpu_to_le64(nal->libnal_ni.ni_pid.nid); - ack.src_pid = cpu_to_le32(nal->libnal_ni.ni_pid.pid); - ack.payload_length = 0; - - ack.msg.ack.dst_wmd = msg->ack_wmd; - ack.msg.ack.match_bits = msg->ev.match_bits; - ack.msg.ack.mlength = cpu_to_le32(msg->ev.mlength); - - rc = lib_send (nal, private, NULL, &ack, PTL_MSG_ACK, - msg->ev.initiator.nid, msg->ev.initiator.pid, - NULL, 0, 0); - if (rc != PTL_OK) { - /* send failed: there's nothing else to clean up. */ - CERROR("Error %d sending ACK to "LPX64"\n", - rc, msg->ev.initiator.nid); - } - } - - md = msg->md; - - LIB_LOCK(nal, flags); - - /* Now it's safe to drop my caller's ref */ - md->pending--; - LASSERT (md->pending >= 0); - - /* Should I unlink this MD? */ - if (md->pending != 0) /* other refs */ - unlink = 0; - else if ((md->md_flags & PTL_MD_FLAG_ZOMBIE) != 0) - unlink = 1; - else if ((md->md_flags & PTL_MD_FLAG_AUTO_UNLINK) == 0) - unlink = 0; - else - unlink = lib_md_exhausted(md); - - msg->ev.ni_fail_type = status; - msg->ev.unlinked = unlink; - - if (md->eq != NULL) - lib_enq_event_locked(nal, private, md->eq, &msg->ev); - - if (unlink) - lib_md_unlink(nal, md); - - list_del (&msg->msg_list); - nal->libnal_ni.ni_counters.msgs_alloc--; - lib_msg_free(nal, msg); - - LIB_UNLOCK(nal, flags); -} diff --git a/lnet/lnet/lib-ni.c b/lnet/lnet/lib-ni.c deleted file mode 100644 index 0f298a0..0000000 --- a/lnet/lnet/lib-ni.c +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-ni.c - * Network status registers and distance functions. - * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. - * Copyright (c) 2001-2002 Sandia National Laboratories - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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. - */ - -#define DEBUG_SUBSYSTEM S_PORTALS -#include - -#define MAX_DIST 18446744073709551615ULL - -int lib_api_ni_status (nal_t *apinal, ptl_sr_index_t sr_idx, - ptl_sr_value_t *status) -{ - lib_nal_t *nal = apinal->nal_data; - lib_ni_t *ni = &nal->libnal_ni; - lib_counters_t *count = &ni->ni_counters; - - switch (sr_idx) { - case PTL_SR_DROP_COUNT: - *status = count->drop_count; - return PTL_OK; - case PTL_SR_DROP_LENGTH: - *status = count->drop_length; - return PTL_OK; - case PTL_SR_RECV_COUNT: - *status = count->recv_count; - return PTL_OK; - case PTL_SR_RECV_LENGTH: - *status = count->recv_length; - return PTL_OK; - case PTL_SR_SEND_COUNT: - *status = count->send_count; - return PTL_OK; - case PTL_SR_SEND_LENGTH: - *status = count->send_length; - return PTL_OK; - case PTL_SR_MSGS_MAX: - *status = count->msgs_max; - return PTL_OK; - default: - *status = 0; - return PTL_SR_INDEX_INVALID; - } -} - - -int lib_api_ni_dist (nal_t *apinal, ptl_process_id_t *pid, unsigned long *dist) -{ - lib_nal_t *nal = apinal->nal_data; - - return (nal->libnal_dist(nal, pid->nid, dist)); -} diff --git a/lnet/lnet/lib-pid.c b/lnet/lnet/lib-pid.c deleted file mode 100644 index ff2a601..0000000 --- a/lnet/lnet/lib-pid.c +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/lib-pid.c - * - * Process identification routines - * Copyright (C) 2001-2003 Cluster File Systems, Inc. - * Copyright (C) 2001-2003 Cluster File Systems, Inc. - * - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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. - */ - -/* This should be removed. The NAL should have the PID information */ -#define DEBUG_SUBSYSTEM S_PORTALS - -#if defined (__KERNEL__) -# include -extern int getpid(void); -#else -# include -# include -#endif -#include - -int -lib_api_get_id(nal_t *apinal, ptl_process_id_t *pid) -{ - lib_nal_t *nal = apinal->nal_data; - - *pid = nal->libnal_ni.ni_pid; - return PTL_OK; -} diff --git a/lnet/lnet/module.c b/lnet/lnet/module.c deleted file mode 100644 index c1303b7..0000000 --- a/lnet/lnet/module.c +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * 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 EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif -#define DEBUG_SUBSYSTEM S_PORTALS - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -extern void (kping_client)(struct portal_ioctl_data *); - -static int kportal_ioctl(struct portal_ioctl_data *data, - unsigned int cmd, unsigned long arg) -{ - int err; - char str[PTL_NALFMT_SIZE]; - ENTRY; - - switch (cmd) { - case IOC_PORTAL_PING: { - void (*ping)(struct portal_ioctl_data *); - - CDEBUG(D_IOCTL, "doing %d pings to nid "LPX64" (%s)\n", - data->ioc_count, data->ioc_nid, - portals_nid2str(data->ioc_nal, data->ioc_nid, str)); - ping = PORTAL_SYMBOL_GET(kping_client); - if (!ping) - CERROR("PORTAL_SYMBOL_GET failed\n"); - else { - ping(data); - PORTAL_SYMBOL_PUT(kping_client); - } - RETURN(0); - } - - case IOC_PORTAL_GET_NID: { - ptl_handle_ni_t nih; - ptl_process_id_t pid; - - CDEBUG (D_IOCTL, "Getting nid for nal [%x]\n", data->ioc_nal); - - err = PtlNIInit(data->ioc_nal, LUSTRE_SRV_PTL_PID, NULL, - NULL, &nih); - if (!(err == PTL_OK || err == PTL_IFACE_DUP)) - RETURN (-EINVAL); - - err = PtlGetId (nih, &pid); - LASSERT (err == PTL_OK); - - PtlNIFini(nih); - - data->ioc_nid = pid.nid; - if (copy_to_user ((char *)arg, data, sizeof (*data))) - RETURN (-EFAULT); - RETURN(0); - } - - case IOC_PORTAL_FAIL_NID: { - ptl_handle_ni_t nih; - - CDEBUG (D_IOCTL, "fail nid: [%d] "LPU64" count %d\n", - data->ioc_nal, data->ioc_nid, data->ioc_count); - - err = PtlNIInit(data->ioc_nal, LUSTRE_SRV_PTL_PID, NULL, - NULL, &nih); - if (!(err == PTL_OK || err == PTL_IFACE_DUP)) - return (-EINVAL); - - if (err == PTL_OK) { - /* There's no point in failing an interface that - * came into existance just for this */ - err = -EINVAL; - } else { - err = PtlFailNid (nih, data->ioc_nid, data->ioc_count); - if (err != PTL_OK) - err = -EINVAL; - } - - PtlNIFini(nih); - RETURN (err); - } - default: - RETURN(-EINVAL); - } - /* Not Reached */ -} - -DECLARE_IOCTL_HANDLER(kportal_ioctl_handler, kportal_ioctl); - -static int init_kportals_module(void) -{ - int rc; - ENTRY; - - rc = PtlInit(NULL); - if (rc) { - CERROR("PtlInit: error %d\n", rc); - RETURN(rc); - } - - rc = libcfs_register_ioctl(&kportal_ioctl_handler); - LASSERT (rc == 0); - - RETURN(rc); -} - -static void exit_kportals_module(void) -{ - int rc; - - rc = libcfs_deregister_ioctl(&kportal_ioctl_handler); - LASSERT (rc == 0); - - PtlFini(); -} - -EXPORT_SYMBOL(ptl_register_nal); -EXPORT_SYMBOL(ptl_unregister_nal); - -EXPORT_SYMBOL(ptl_err_str); -EXPORT_SYMBOL(PtlMEAttach); -EXPORT_SYMBOL(PtlMEInsert); -EXPORT_SYMBOL(PtlMEUnlink); -EXPORT_SYMBOL(PtlEQAlloc); -EXPORT_SYMBOL(PtlMDAttach); -EXPORT_SYMBOL(PtlMDUnlink); -EXPORT_SYMBOL(PtlNIInit); -EXPORT_SYMBOL(PtlNIFini); -EXPORT_SYMBOL(PtlInit); -EXPORT_SYMBOL(PtlFini); -EXPORT_SYMBOL(PtlSnprintHandle); -EXPORT_SYMBOL(PtlPut); -EXPORT_SYMBOL(PtlGet); -EXPORT_SYMBOL(PtlEQWait); -EXPORT_SYMBOL(PtlEQFree); -EXPORT_SYMBOL(PtlEQGet); -EXPORT_SYMBOL(PtlGetId); -EXPORT_SYMBOL(PtlMDBind); -EXPORT_SYMBOL(lib_iov_nob); -EXPORT_SYMBOL(lib_copy_iov2buf); -EXPORT_SYMBOL(lib_copy_buf2iov); -EXPORT_SYMBOL(lib_extract_iov); -EXPORT_SYMBOL(lib_kiov_nob); -EXPORT_SYMBOL(lib_copy_kiov2buf); -EXPORT_SYMBOL(lib_copy_buf2kiov); -EXPORT_SYMBOL(lib_extract_kiov); -EXPORT_SYMBOL(lib_finalize); -EXPORT_SYMBOL(lib_parse); -EXPORT_SYMBOL(lib_create_reply_msg); -EXPORT_SYMBOL(lib_init); -EXPORT_SYMBOL(lib_fini); - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Portals v3.1"); -MODULE_LICENSE("GPL"); -module_init(init_kportals_module); -module_exit(exit_kportals_module); diff --git a/lnet/packaging/.cvsignore b/lnet/packaging/.cvsignore deleted file mode 100644 index fd1d56a..0000000 --- a/lnet/packaging/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -Makefile.in -aclocal.m4 -config.log -config.status -config.cache -configure -portals.spec diff --git a/lnet/packaging/Makefile.am b/lnet/packaging/Makefile.am deleted file mode 100644 index 126bc69..0000000 --- a/lnet/packaging/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (C) 2002 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -EXTRA_DIST = portals.spec \ No newline at end of file diff --git a/lnet/packaging/portals.spec.in b/lnet/packaging/portals.spec.in deleted file mode 100644 index e196b3f..0000000 --- a/lnet/packaging/portals.spec.in +++ /dev/null @@ -1,116 +0,0 @@ -%define kversion @RELEASE@ -%define linuxdir @LINUX@ -%define version HEAD - -Summary: Sandia Portals Message Passing - utilities -Name: portals -Version: %{version} -Release: 0210101748uml -Copyright: LGPL -Group: Utilities/System -BuildRoot: /var/tmp/portals-%{version}-root -Source: http://sandiaportals.org/portals-%{version}.tar.gz - -%description -Sandia Portals message passing package. Contains kernel modules, libraries and utilities. - -%package -n portals-modules -Summary: Kernel modules and NAL's for portals -Group: Development/Kernel - -%description -n portals-modules -Object-Based Disk storage drivers for Linux %{kversion}. - -%package -n portals-source -Summary: Portals kernel source for rebuilding with other kernels -Group: Development/Kernel - -%description -n portals-source -Portals kernel source for rebuilding with other kernels - -%prep -%setup -n portals-%{version} - -%build -rm -rf $RPM_BUILD_ROOT - -# Create the pristine source directory. -srcdir=$RPM_BUILD_ROOT/usr/src/portals-%{version} -mkdir -p $srcdir -find . -name CVS -prune -o -print | cpio -ap $srcdir - -# Set an explicit path to our Linux tree, if we can. -conf_flag= -linuxdir=%{linuxdir} -test -d $linuxdir && conf_flag=--with-linux=$linuxdir -./configure $conf_flag -make - -%install -make install prefix=$RPM_BUILD_ROOT - -%ifarch alpha -# this hurts me - conf_flag= - linuxdir=%{linuxdir} - test -d $linuxdir && conf_flag=--with-linux=$linuxdir - make clean - ./configure --enable-rtscts-myrinet $conf_flag - make - cp linux/rtscts/rtscts.o $RPM_BUILD_ROOT/lib/modules/%{kversion}/kernel/net/portals/rtscts_myrinet.o - cp user/myrinet_utils/mcpload $RPM_BUILD_ROOT/usr/sbin/mcpload -%endif - - -%files -%attr(-, root, root) %doc COPYING -%attr(-, root, root) /usr/sbin/acceptor -%attr(-, root, root) /usr/sbin/ptlctl -%attr(-, root, root) /usr/sbin/debugctl -%ifarch alpha -%attr(-, root, root) /usr/sbin/mcpload -%endif -%attr(-, root, root) /lib/libmyrnal.a -%attr(-, root, root) /lib/libptlapi.a -%attr(-, root, root) /lib/libptlctl.a -%attr(-, root, root) /lib/libprocbridge.a -%attr(-, root, root) /lib/libptllib.a -%attr(-, root, root) /lib/libtcpnal.a -%attr(-, root, root) /lib/libtcpnalutil.a -%attr(-, root, root) /usr/include/portals/*.h -%attr(-, root, root) /usr/include/portals/base/*.h -%attr(-, root, root) /usr/include/linux/*.h - -%files -n portals-modules -%attr(-, root, root) %doc COPYING -%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/portals/portals.o -%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/portals/kptlrouter.o -%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/portals/kptrxtx.o -%ifarch alpha -%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/portals/p3mod.o -%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/portals/rtscts.o -%endif -%attr(-, root, root) /lib/modules/%{kversion}/kernel/net/portals/*nal.o - -%files -n portals-source -%attr(-, root, root) /usr/src/portals-%{version} - -%post -if [ ! -e /dev/portals ]; then - mknod /dev/portals c 10 240 -fi -depmod -ae || exit 0 - -grep -q portals /etc/modules.conf || \ - echo 'alias char-major-10-240 portals' >> /etc/modules.conf - -grep -q '/dev/portals' /etc/modules.conf || \ - echo 'alias /dev/portals portals' >> /etc/modules.conf - -%postun -depmod -ae || exit 0 - -%clean -#rm -rf $RPM_BUILD_ROOT - -# end of file diff --git a/lnet/router/.cvsignore b/lnet/router/.cvsignore deleted file mode 100644 index 5ed596b..0000000 --- a/lnet/router/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/router/Makefile.in b/lnet/router/Makefile.in deleted file mode 100644 index 3bb6cf7..0000000 --- a/lnet/router/Makefile.in +++ /dev/null @@ -1,4 +0,0 @@ -MODULES := kptlrouter -kptlrouter-objs := router.o proc.o - -@INCLUDE_RULES@ diff --git a/lnet/router/Makefile.mk b/lnet/router/Makefile.mk deleted file mode 100644 index 9b02c03..0000000 --- a/lnet/router/Makefile.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include $(src)/../Kernelenv - -obj-y += kptlrouter.o -kptlrouter-objs := router.o proc.o diff --git a/lnet/router/autoMakefile.am b/lnet/router/autoMakefile.am deleted file mode 100644 index fa11e8c..0000000 --- a/lnet/router/autoMakefile.am +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if !CRAY_PORTALS -modulenet_DATA = kptlrouter$(KMODEXT) -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(kptlrouter-objs:%.o=%.c) router.h diff --git a/lnet/router/proc.c b/lnet/router/proc.c deleted file mode 100644 index 61b6880..0000000 --- a/lnet/router/proc.c +++ /dev/null @@ -1,242 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * - * This file is part of Portals - * http://sourceforge.net/projects/sandiaportals/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include "router.h" - -#define KPR_PROC_ROUTER "sys/portals/router" -#define KPR_PROC_ROUTES "sys/portals/routes" - -/* Used for multi-page route list book keeping */ -struct proc_route_data { - struct list_head *curr; - unsigned int generation; - off_t skip; - rwlock_t proc_route_rwlock; -} kpr_read_routes_data; - -/* nal2name support re-used from utils/portals.c */ -struct name2num { - char *name; - int num; -} nalnames[] = { - { "any", 0}, - { "elan", QSWNAL}, - { "tcp", SOCKNAL}, - { "gm", GMNAL}, - { "ib", OPENIBNAL}, - { "iib", IIBNAL}, - { "lo", LONAL}, - { NULL, -1} -}; - -static struct name2num *name2num_lookup_num(struct name2num *table, int num) -{ - while (table->name != NULL) - if (num == table->num) - return (table); - else - table++; - return (NULL); -} - -static char *nal2name(int nal) -{ - struct name2num *e = name2num_lookup_num(nalnames, nal); - return ((e == NULL) ? "???" : e->name); -} - - -static int kpr_proc_router_read(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - unsigned long long bytes = kpr_fwd_bytes; - unsigned long packets = kpr_fwd_packets; - unsigned long errors = kpr_fwd_errors; - unsigned int qdepth = atomic_read (&kpr_queue_depth); - int len; - - *eof = 1; - if (off != 0) - return (0); - - len = sprintf(page, "%Ld %ld %ld %d\n", bytes, packets, errors, qdepth); - - *start = page; - return (len); -} - -static int kpr_proc_router_write(struct file *file, const char *ubuffer, - unsigned long count, void *data) -{ - /* Ignore what we've been asked to write, and just zero the stats */ - kpr_fwd_bytes = 0; - kpr_fwd_packets = 0; - kpr_fwd_errors = 0; - - return (count); -} - -static int kpr_proc_routes_read(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct proc_route_data *prd = data; - kpr_route_entry_t *re; - kpr_gateway_entry_t *ge; - int chunk_len = 0; - int line_len = 0; - int user_len = 0; - int rc = 0; - - *eof = 1; - *start = page; - - write_lock(&(prd->proc_route_rwlock)); - - if (prd->curr == NULL) { - if (off != 0) - goto routes_read_exit; - - /* First pass, initialize our private data */ - prd->curr = kpr_routes.next; - prd->generation = kpr_routes_generation; - prd->skip = 0; - } else { - /* Abort route list generation change */ - if (prd->generation != kpr_routes_generation) { - prd->curr = NULL; - rc = sprintf(page, "\nError: Routes Changed\n"); - goto routes_read_exit; - } - - /* All the routes have been walked */ - if (prd->curr == &kpr_routes) { - prd->curr = NULL; - goto routes_read_exit; - } - } - - read_lock(&kpr_rwlock); - *start = page + prd->skip; - user_len = -prd->skip; - - while ((prd->curr != NULL) && (prd->curr != &kpr_routes)) { - re = list_entry(prd->curr, kpr_route_entry_t, kpre_list); - ge = re->kpre_gateway; - - line_len = sprintf(page + chunk_len, - "%12s "LPX64" : "LPX64" - "LPX64", %s\n", - nal2name(ge->kpge_nalid), ge->kpge_nid, - re->kpre_lo_nid, re->kpre_hi_nid, - ge->kpge_alive ? "up" : "down"); - chunk_len += line_len; - user_len += line_len; - - /* Abort the route list changed */ - if (prd->curr->next == NULL) { - prd->curr = NULL; - read_unlock(&kpr_rwlock); - rc = sprintf(page, "\nError: Routes Changed\n"); - goto routes_read_exit; - } - - prd->curr = prd->curr->next; - - /* The route table will exceed one page, break the while loop - * so the function can be re-called with a new page. - */ - if ((chunk_len > (PAGE_SIZE - 80)) || (user_len > count)) - break; - } - - *eof = 0; - - /* Caller received only a portion of the last entry, the - * remaining will be delivered in the next page if asked for. - */ - if (user_len > count) { - prd->curr = prd->curr->prev; - prd->skip = line_len - (user_len - count); - read_unlock(&kpr_rwlock); - rc = count; - goto routes_read_exit; - } - - /* Not enough data to entirely satify callers request */ - prd->skip = 0; - read_unlock(&kpr_rwlock); - rc = user_len; - -routes_read_exit: - write_unlock(&(prd->proc_route_rwlock)); - return rc; -} - -static int kpr_proc_routes_write(struct file *file, const char *ubuffer, - unsigned long count, void *data) -{ - /* no-op; lctl should be used to adjust the routes */ - return (count); -} - -void kpr_proc_init(void) -{ - struct proc_dir_entry *router_entry; - struct proc_dir_entry *routes_entry; - - /* Initialize KPR_PROC_ROUTER */ - router_entry = create_proc_entry (KPR_PROC_ROUTER, - S_IFREG | S_IRUGO | S_IWUSR, NULL); - - if (router_entry == NULL) { - CERROR("couldn't create proc entry %s\n", KPR_PROC_ROUTER); - return; - } - - router_entry->data = NULL; - router_entry->read_proc = kpr_proc_router_read; - router_entry->write_proc = kpr_proc_router_write; - - /* Initialize KPR_PROC_ROUTES */ - routes_entry = create_proc_entry (KPR_PROC_ROUTES, - S_IFREG | S_IRUGO | S_IWUSR, NULL); - - if (routes_entry == NULL) { - CERROR("couldn't create proc entry %s\n", KPR_PROC_ROUTES); - return; - } - - kpr_read_routes_data.curr = NULL; - kpr_read_routes_data.generation = 0; - kpr_read_routes_data.skip = 0; - kpr_read_routes_data.proc_route_rwlock = RW_LOCK_UNLOCKED; - - routes_entry->data = &kpr_read_routes_data; - routes_entry->read_proc = kpr_proc_routes_read; - routes_entry->write_proc = kpr_proc_routes_write; -} - -void kpr_proc_fini(void) -{ - remove_proc_entry(KPR_PROC_ROUTER, 0); - remove_proc_entry(KPR_PROC_ROUTES, 0); -} diff --git a/lnet/router/router.c b/lnet/router/router.c deleted file mode 100644 index 7edc5f6..0000000 --- a/lnet/router/router.c +++ /dev/null @@ -1,824 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * - * This file is part of Portals - * http://sourceforge.net/projects/sandiaportals/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include "router.h" - -LIST_HEAD(kpr_routes); -LIST_HEAD(kpr_gateways); -LIST_HEAD(kpr_nals); - -unsigned int kpr_routes_generation; -unsigned long long kpr_fwd_bytes; -unsigned long kpr_fwd_packets; -unsigned long kpr_fwd_errors; -atomic_t kpr_queue_depth; - -/* Mostly the tables are read-only (thread and interrupt context) - * - * Once in a blue moon we register/deregister NALs and add/remove routing - * entries (thread context only)... */ -rwlock_t kpr_rwlock = RW_LOCK_UNLOCKED; - -kpr_router_interface_t kpr_router_interface = { - kprri_register: kpr_register_nal, - kprri_lookup: kpr_lookup_target, - kprri_fwd_start: kpr_forward_packet, - kprri_fwd_done: kpr_complete_packet, - kprri_notify: kpr_nal_notify, - kprri_shutdown: kpr_shutdown_nal, - kprri_deregister: kpr_deregister_nal, -}; - -int -kpr_register_nal (kpr_nal_interface_t *nalif, void **argp) -{ - unsigned long flags; - struct list_head *e; - kpr_nal_entry_t *ne; - - CDEBUG (D_NET, "Registering NAL %x\n", nalif->kprni_nalid); - - PORTAL_ALLOC (ne, sizeof (*ne)); - if (ne == NULL) - return (-ENOMEM); - - memset (ne, 0, sizeof (*ne)); - memcpy ((void *)&ne->kpne_interface, (void *)nalif, sizeof (*nalif)); - - LASSERT (!in_interrupt()); - write_lock_irqsave (&kpr_rwlock, flags); - - for (e = kpr_nals.next; e != &kpr_nals; e = e->next) - { - kpr_nal_entry_t *ne2 = list_entry (e, kpr_nal_entry_t, kpne_list); - - if (ne2->kpne_interface.kprni_nalid == ne->kpne_interface.kprni_nalid) - { - write_unlock_irqrestore (&kpr_rwlock, flags); - - CERROR ("Attempt to register same NAL %x twice\n", ne->kpne_interface.kprni_nalid); - - PORTAL_FREE (ne, sizeof (*ne)); - return (-EEXIST); - } - } - - list_add (&ne->kpne_list, &kpr_nals); - - write_unlock_irqrestore (&kpr_rwlock, flags); - - *argp = ne; - PORTAL_MODULE_USE; - return (0); -} - -void -kpr_do_upcall (void *arg) -{ - kpr_upcall_t *u = (kpr_upcall_t *)arg; - char nalstr[10]; - char nidstr[36]; - char whenstr[36]; - char *argv[] = { - NULL, - "ROUTER_NOTIFY", - nalstr, - nidstr, - u->kpru_alive ? "up" : "down", - whenstr, - NULL}; - - snprintf (nalstr, sizeof(nalstr), "%d", u->kpru_nal_id); - snprintf (nidstr, sizeof(nidstr), LPX64, u->kpru_nid); - snprintf (whenstr, sizeof(whenstr), "%ld", u->kpru_when); - - portals_run_upcall (argv); - - kfree (u); -} - -void -kpr_upcall (int gw_nalid, ptl_nid_t gw_nid, int alive, time_t when) -{ - char str[PTL_NALFMT_SIZE]; - - /* May be in arbitrary context */ - kpr_upcall_t *u = kmalloc (sizeof (kpr_upcall_t), GFP_ATOMIC); - - if (u == NULL) { - CERROR ("Upcall out of memory: nal %x nid "LPX64" (%s) %s\n", - gw_nalid, gw_nid, - portals_nid2str(gw_nalid, gw_nid, str), - alive ? "up" : "down"); - return; - } - - u->kpru_nal_id = gw_nalid; - u->kpru_nid = gw_nid; - u->kpru_alive = alive; - u->kpru_when = when; - - prepare_work (&u->kpru_tq, kpr_do_upcall, u); - schedule_work (&u->kpru_tq); -} - -int -kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, - int alive, time_t when) -{ - unsigned long flags; - int found; - kpr_nal_entry_t *ne = NULL; - kpr_gateway_entry_t *ge = NULL; - struct timeval now; - struct list_head *e; - struct list_head *n; - char str[PTL_NALFMT_SIZE]; - - CDEBUG (D_NET, "%s notifying [%x] "LPX64": %s\n", - byNal ? "NAL" : "userspace", - gateway_nalid, gateway_nid, alive ? "up" : "down"); - - /* can't do predictions... */ - do_gettimeofday (&now); - if (when > now.tv_sec) { - CWARN ("Ignoring prediction from %s of [%x] "LPX64" %s " - "%ld seconds in the future\n", - byNal ? "NAL" : "userspace", - gateway_nalid, gateway_nid, - alive ? "up" : "down", - when - now.tv_sec); - return (EINVAL); - } - - LASSERT (when <= now.tv_sec); - - /* Serialise with lookups (i.e. write lock) */ - write_lock_irqsave(&kpr_rwlock, flags); - - found = 0; - list_for_each_safe (e, n, &kpr_gateways) { - - ge = list_entry(e, kpr_gateway_entry_t, kpge_list); - if ((gateway_nalid != 0 && - ge->kpge_nalid != gateway_nalid) || - ge->kpge_nid != gateway_nid) - continue; - - found = 1; - break; - } - - if (!found) { - /* gateway not found */ - write_unlock_irqrestore(&kpr_rwlock, flags); - CDEBUG (D_NET, "Gateway not found\n"); - return (0); - } - - if (when < ge->kpge_timestamp) { - /* out of date information */ - write_unlock_irqrestore (&kpr_rwlock, flags); - CDEBUG (D_NET, "Out of date\n"); - return (0); - } - - /* update timestamp */ - ge->kpge_timestamp = when; - - if ((!ge->kpge_alive) == (!alive)) { - /* new date for old news */ - write_unlock_irqrestore (&kpr_rwlock, flags); - CDEBUG (D_NET, "Old news\n"); - return (0); - } - - ge->kpge_alive = alive; - CDEBUG(D_NET, "set "LPX64" [%p] %d\n", gateway_nid, ge, alive); - - if (alive) { - /* Reset all gateway weights so the newly-enabled gateway - * doesn't have to play catch-up */ - list_for_each_safe (e, n, &kpr_gateways) { - kpr_gateway_entry_t *ge = list_entry(e, kpr_gateway_entry_t, - kpge_list); - atomic_set (&ge->kpge_weight, 0); - } - } - - found = 0; - if (!byNal) { - /* userland notified me: notify NAL? */ - ne = kpr_find_nal_entry_locked (ge->kpge_nalid); - if (ne != NULL) { - if (!ne->kpne_shutdown && - ne->kpne_interface.kprni_notify != NULL) { - /* take a ref on this NAL until notifying - * it has completed... */ - atomic_inc (&ne->kpne_refcount); - found = 1; - } - } - } - - write_unlock_irqrestore(&kpr_rwlock, flags); - - if (found) { - ne->kpne_interface.kprni_notify (ne->kpne_interface.kprni_arg, - gateway_nid, alive); - /* 'ne' can disappear now... */ - atomic_dec (&ne->kpne_refcount); - } - - if (byNal) { - /* It wasn't userland that notified me... */ - CWARN ("Upcall: NAL %x NID "LPX64" (%s) is %s\n", - gateway_nalid, gateway_nid, - portals_nid2str(gateway_nalid, gateway_nid, str), - alive ? "alive" : "dead"); - kpr_upcall (gateway_nalid, gateway_nid, alive, when); - } else { - CDEBUG (D_NET, " NOT Doing upcall\n"); - } - - return (0); -} - -void -kpr_nal_notify (void *arg, ptl_nid_t peer, int alive, time_t when) -{ - kpr_nal_entry_t *ne = (kpr_nal_entry_t *)arg; - - kpr_do_notify (1, ne->kpne_interface.kprni_nalid, peer, alive, when); -} - -void -kpr_shutdown_nal (void *arg) -{ - unsigned long flags; - kpr_nal_entry_t *ne = (kpr_nal_entry_t *)arg; - - CDEBUG (D_NET, "Shutting down NAL %x\n", ne->kpne_interface.kprni_nalid); - - LASSERT (!ne->kpne_shutdown); - LASSERT (!in_interrupt()); - - write_lock_irqsave (&kpr_rwlock, flags); - ne->kpne_shutdown = 1; - write_unlock_irqrestore (&kpr_rwlock, flags); -} - -void -kpr_deregister_nal (void *arg) -{ - unsigned long flags; - kpr_nal_entry_t *ne = (kpr_nal_entry_t *)arg; - - CDEBUG (D_NET, "Deregister NAL %x\n", ne->kpne_interface.kprni_nalid); - - LASSERT (ne->kpne_shutdown); /* caller must have issued shutdown already */ - LASSERT (!in_interrupt()); - - write_lock_irqsave (&kpr_rwlock, flags); - list_del (&ne->kpne_list); - write_unlock_irqrestore (&kpr_rwlock, flags); - - /* Wait until all outstanding messages/notifications have completed */ - while (atomic_read (&ne->kpne_refcount) != 0) - { - CDEBUG (D_NET, "Waiting for refcount on NAL %x to reach zero (%d)\n", - ne->kpne_interface.kprni_nalid, atomic_read (&ne->kpne_refcount)); - - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - } - - PORTAL_FREE (ne, sizeof (*ne)); - PORTAL_MODULE_UNUSE; -} - -int -kpr_ge_isbetter (kpr_gateway_entry_t *ge1, kpr_gateway_entry_t *ge2) -{ - const int significant_bits = 0x00ffffff; - /* We use atomic_t to record/compare route weights for - * load-balancing. Here we limit ourselves to only using - * 'significant_bits' when we do an 'after' comparison */ - - int diff = (atomic_read (&ge1->kpge_weight) - - atomic_read (&ge2->kpge_weight)) & significant_bits; - int rc = (diff > (significant_bits >> 1)); - - CDEBUG(D_NET, "[%p]"LPX64"=%d %s [%p]"LPX64"=%d\n", - ge1, ge1->kpge_nid, atomic_read (&ge1->kpge_weight), - rc ? ">" : "<", - ge2, ge2->kpge_nid, atomic_read (&ge2->kpge_weight)); - - return (rc); -} - -void -kpr_update_weight (kpr_gateway_entry_t *ge, int nob) -{ - int weight = 1 + (nob + sizeof (ptl_hdr_t)/2)/sizeof (ptl_hdr_t); - - /* We've chosen this route entry (i.e. gateway) to forward payload - * of length 'nob'; update the route's weight to make it less - * favoured. Note that the weight is 1 plus the payload size - * rounded and scaled to the portals header size, so we get better - * use of the significant bits in kpge_weight. */ - - CDEBUG(D_NET, "gateway [%p]"LPX64" += %d\n", ge, - ge->kpge_nid, weight); - - atomic_add (weight, &ge->kpge_weight); -} - -int -kpr_lookup_target (void *arg, ptl_nid_t target_nid, int nob, - ptl_nid_t *gateway_nidp) -{ - kpr_nal_entry_t *ne = (kpr_nal_entry_t *)arg; - struct list_head *e; - kpr_route_entry_t *re; - kpr_gateway_entry_t *ge = NULL; - int rc = -ENOENT; - - /* Caller wants to know if 'target_nid' can be reached via a gateway - * ON HER OWN NETWORK */ - - CDEBUG (D_NET, "lookup "LPX64" from NAL %x\n", target_nid, - ne->kpne_interface.kprni_nalid); - LASSERT (!in_interrupt()); - - read_lock (&kpr_rwlock); - - if (ne->kpne_shutdown) { /* caller is shutting down */ - read_unlock (&kpr_rwlock); - return (-ENOENT); - } - - /* Search routes for one that has a gateway to target_nid on the callers network */ - - list_for_each (e, &kpr_routes) { - re = list_entry (e, kpr_route_entry_t, kpre_list); - - if (re->kpre_lo_nid > target_nid || - re->kpre_hi_nid < target_nid) - continue; - - /* found table entry */ - - if (re->kpre_gateway->kpge_nalid != ne->kpne_interface.kprni_nalid || - !re->kpre_gateway->kpge_alive) { - /* different NAL or gateway down */ - rc = -EHOSTUNREACH; - continue; - } - - if (ge == NULL || - kpr_ge_isbetter (re->kpre_gateway, ge)) - ge = re->kpre_gateway; - } - - if (ge != NULL) { - kpr_update_weight (ge, nob); - *gateway_nidp = ge->kpge_nid; - rc = 0; - } - - read_unlock (&kpr_rwlock); - - /* NB can't deref 're' now; it might have been removed! */ - - CDEBUG (D_NET, "lookup "LPX64" from NAL %x: %d ("LPX64")\n", - target_nid, ne->kpne_interface.kprni_nalid, rc, - (rc == 0) ? *gateway_nidp : (ptl_nid_t)0); - return (rc); -} - -kpr_nal_entry_t * -kpr_find_nal_entry_locked (int nal_id) -{ - struct list_head *e; - - /* Called with kpr_rwlock held */ - - list_for_each (e, &kpr_nals) { - kpr_nal_entry_t *ne = list_entry (e, kpr_nal_entry_t, kpne_list); - - if (nal_id != ne->kpne_interface.kprni_nalid) /* no match */ - continue; - - return (ne); - } - - return (NULL); -} - -void -kpr_forward_packet (void *arg, kpr_fwd_desc_t *fwd) -{ - kpr_nal_entry_t *src_ne = (kpr_nal_entry_t *)arg; - ptl_nid_t target_nid = fwd->kprfd_target_nid; - int nob = fwd->kprfd_nob; - kpr_gateway_entry_t *ge = NULL; - kpr_nal_entry_t *dst_ne = NULL; - struct list_head *e; - kpr_route_entry_t *re; - kpr_nal_entry_t *tmp_ne; - int rc; - - CDEBUG (D_NET, "forward [%p] "LPX64" from NAL %x\n", fwd, - target_nid, src_ne->kpne_interface.kprni_nalid); - - LASSERT (nob == lib_kiov_nob (fwd->kprfd_niov, fwd->kprfd_kiov)); - LASSERT (!in_interrupt()); - - read_lock (&kpr_rwlock); - - kpr_fwd_packets++; /* (loose) stats accounting */ - kpr_fwd_bytes += nob + sizeof(ptl_hdr_t); - - if (src_ne->kpne_shutdown) { /* caller is shutting down */ - rc = -ESHUTDOWN; - goto out; - } - - fwd->kprfd_router_arg = src_ne; /* stash caller's nal entry */ - - /* Search routes for one that has a gateway to target_nid NOT on the caller's network */ - - list_for_each (e, &kpr_routes) { - re = list_entry (e, kpr_route_entry_t, kpre_list); - - if (re->kpre_lo_nid > target_nid || /* no match */ - re->kpre_hi_nid < target_nid) - continue; - - if (re->kpre_gateway->kpge_nalid == src_ne->kpne_interface.kprni_nalid) - continue; /* don't route to same NAL */ - - if (!re->kpre_gateway->kpge_alive) - continue; /* gateway is dead */ - - tmp_ne = kpr_find_nal_entry_locked (re->kpre_gateway->kpge_nalid); - - if (tmp_ne == NULL || - tmp_ne->kpne_shutdown) { - /* NAL must be registered and not shutting down */ - continue; - } - - if (ge == NULL || - kpr_ge_isbetter (re->kpre_gateway, ge)) { - ge = re->kpre_gateway; - dst_ne = tmp_ne; - } - } - - if (ge != NULL) { - LASSERT (dst_ne != NULL); - - kpr_update_weight (ge, nob); - - fwd->kprfd_gateway_nid = ge->kpge_nid; - atomic_inc (&src_ne->kpne_refcount); /* source and dest nals are */ - atomic_inc (&dst_ne->kpne_refcount); /* busy until fwd completes */ - atomic_inc (&kpr_queue_depth); - - read_unlock (&kpr_rwlock); - - CDEBUG (D_NET, "forward [%p] "LPX64" from NAL %x: " - "to "LPX64" on NAL %x\n", - fwd, target_nid, src_ne->kpne_interface.kprni_nalid, - fwd->kprfd_gateway_nid, dst_ne->kpne_interface.kprni_nalid); - - dst_ne->kpne_interface.kprni_fwd (dst_ne->kpne_interface.kprni_arg, fwd); - return; - } - - rc = -EHOSTUNREACH; - out: - kpr_fwd_errors++; - - CDEBUG (D_NET, "Failed to forward [%p] "LPX64" from NAL %x: %d\n", - fwd, target_nid, src_ne->kpne_interface.kprni_nalid, rc); - - (fwd->kprfd_callback)(fwd->kprfd_callback_arg, rc); - - read_unlock (&kpr_rwlock); -} - -void -kpr_complete_packet (void *arg, kpr_fwd_desc_t *fwd, int error) -{ - kpr_nal_entry_t *dst_ne = (kpr_nal_entry_t *)arg; - kpr_nal_entry_t *src_ne = (kpr_nal_entry_t *)fwd->kprfd_router_arg; - - CDEBUG (D_NET, "complete(1) [%p] from NAL %x to NAL %x: %d\n", fwd, - src_ne->kpne_interface.kprni_nalid, dst_ne->kpne_interface.kprni_nalid, error); - - atomic_dec (&dst_ne->kpne_refcount); /* CAVEAT EMPTOR dst_ne can disappear now!!! */ - - (fwd->kprfd_callback)(fwd->kprfd_callback_arg, error); - - CDEBUG (D_NET, "complete(2) [%p] from NAL %x: %d\n", fwd, - src_ne->kpne_interface.kprni_nalid, error); - - atomic_dec (&kpr_queue_depth); - atomic_dec (&src_ne->kpne_refcount); /* CAVEAT EMPTOR src_ne can disappear now!!! */ -} - -int -kpr_add_route (int gateway_nalid, ptl_nid_t gateway_nid, - ptl_nid_t lo_nid, ptl_nid_t hi_nid) -{ - unsigned long flags; - struct list_head *e; - kpr_route_entry_t *re; - kpr_gateway_entry_t *ge; - int dup = 0; - - CDEBUG(D_NET, "Add route: %x "LPX64" : "LPX64" - "LPX64"\n", - gateway_nalid, gateway_nid, lo_nid, hi_nid); - - if (gateway_nalid == PTL_NID_ANY || - lo_nid == PTL_NID_ANY || - hi_nid == PTL_NID_ANY || - lo_nid > hi_nid) - return (-EINVAL); - - PORTAL_ALLOC (ge, sizeof (*ge)); - if (ge == NULL) - return (-ENOMEM); - - ge->kpge_nalid = gateway_nalid; - ge->kpge_nid = gateway_nid; - ge->kpge_alive = 1; - ge->kpge_timestamp = 0; - ge->kpge_refcount = 0; - atomic_set (&ge->kpge_weight, 0); - - PORTAL_ALLOC (re, sizeof (*re)); - if (re == NULL) { - PORTAL_FREE (ge, sizeof (*ge)); - return (-ENOMEM); - } - - re->kpre_lo_nid = lo_nid; - re->kpre_hi_nid = hi_nid; - - LASSERT(!in_interrupt()); - write_lock_irqsave (&kpr_rwlock, flags); - - list_for_each (e, &kpr_gateways) { - kpr_gateway_entry_t *ge2 = list_entry(e, kpr_gateway_entry_t, - kpge_list); - - if (ge2->kpge_nalid == gateway_nalid && - ge2->kpge_nid == gateway_nid) { - PORTAL_FREE (ge, sizeof (*ge)); - ge = ge2; - dup = 1; - break; - } - } - - if (!dup) { - /* Adding a new gateway... */ - list_add (&ge->kpge_list, &kpr_gateways); - - /* ...zero all gateway weights so this one doesn't have to - * play catch-up */ - - list_for_each (e, &kpr_gateways) { - kpr_gateway_entry_t *ge2 = list_entry(e, kpr_gateway_entry_t, - kpge_list); - atomic_set (&ge2->kpge_weight, 0); - } - } - - re->kpre_gateway = ge; - ge->kpge_refcount++; - list_add (&re->kpre_list, &kpr_routes); - kpr_routes_generation++; - - write_unlock_irqrestore (&kpr_rwlock, flags); - return (0); -} - -int -kpr_sys_notify (int gateway_nalid, ptl_nid_t gateway_nid, - int alive, time_t when) -{ - return (kpr_do_notify (0, gateway_nalid, gateway_nid, alive, when)); -} - -int -kpr_del_route (int gw_nalid, ptl_nid_t gw_nid, - ptl_nid_t lo, ptl_nid_t hi) -{ - int specific = (lo != PTL_NID_ANY); - unsigned long flags; - int rc = -ENOENT; - struct list_head *e; - struct list_head *n; - - CDEBUG(D_NET, "Del route [%x] "LPX64" : "LPX64" - "LPX64"\n", - gw_nalid, gw_nid, lo, hi); - - LASSERT(!in_interrupt()); - - /* NB Caller may specify either all routes via the given gateway - * (lo/hi == PTL_NID_ANY) or a specific route entry (lo/hi are - * actual NIDs) */ - if (specific ? (hi == PTL_NID_ANY || hi < lo) : (hi != PTL_NID_ANY)) - return (-EINVAL); - - write_lock_irqsave(&kpr_rwlock, flags); - - list_for_each_safe (e, n, &kpr_routes) { - kpr_route_entry_t *re = list_entry(e, kpr_route_entry_t, - kpre_list); - kpr_gateway_entry_t *ge = re->kpre_gateway; - - if (ge->kpge_nalid != gw_nalid || - ge->kpge_nid != gw_nid || - (specific && - (lo != re->kpre_lo_nid || hi != re->kpre_hi_nid))) - continue; - - rc = 0; - - if (--ge->kpge_refcount == 0) { - list_del (&ge->kpge_list); - PORTAL_FREE (ge, sizeof (*ge)); - } - - list_del (&re->kpre_list); - PORTAL_FREE(re, sizeof (*re)); - - if (specific) - break; - } - - kpr_routes_generation++; - write_unlock_irqrestore(&kpr_rwlock, flags); - - return (rc); -} - -int -kpr_get_route (int idx, __u32 *gateway_nalid, ptl_nid_t *gateway_nid, - ptl_nid_t *lo_nid, ptl_nid_t *hi_nid, __u32 *alive) -{ - struct list_head *e; - - LASSERT (!in_interrupt()); - read_lock(&kpr_rwlock); - - for (e = kpr_routes.next; e != &kpr_routes; e = e->next) { - kpr_route_entry_t *re = list_entry(e, kpr_route_entry_t, - kpre_list); - kpr_gateway_entry_t *ge = re->kpre_gateway; - - if (idx-- == 0) { - *gateway_nalid = ge->kpge_nalid; - *gateway_nid = ge->kpge_nid; - *alive = ge->kpge_alive; - *lo_nid = re->kpre_lo_nid; - *hi_nid = re->kpre_hi_nid; - - read_unlock(&kpr_rwlock); - return (0); - } - } - - read_unlock (&kpr_rwlock); - return (-ENOENT); -} - -static int -kpr_nal_cmd(struct portals_cfg *pcfg, void * private) -{ - int err = -EINVAL; - ENTRY; - - switch(pcfg->pcfg_command) { - default: - CDEBUG(D_IOCTL, "Inappropriate cmd: %d\n", pcfg->pcfg_command); - break; - - case NAL_CMD_ADD_ROUTE: - CDEBUG(D_IOCTL, "Adding route: [%x] "LPU64" : "LPU64" - "LPU64"\n", - pcfg->pcfg_nal, pcfg->pcfg_nid, - pcfg->pcfg_nid2, pcfg->pcfg_nid3); - err = kpr_add_route(pcfg->pcfg_gw_nal, pcfg->pcfg_nid, - pcfg->pcfg_nid2, pcfg->pcfg_nid3); - break; - - case NAL_CMD_DEL_ROUTE: - CDEBUG (D_IOCTL, "Removing routes via [%x] "LPU64" : "LPU64" - "LPU64"\n", - pcfg->pcfg_gw_nal, pcfg->pcfg_nid, - pcfg->pcfg_nid2, pcfg->pcfg_nid3); - err = kpr_del_route (pcfg->pcfg_gw_nal, pcfg->pcfg_nid, - pcfg->pcfg_nid2, pcfg->pcfg_nid3); - break; - - case NAL_CMD_NOTIFY_ROUTER: { - CDEBUG (D_IOCTL, "Notifying peer [%x] "LPU64" %s @ %ld\n", - pcfg->pcfg_gw_nal, pcfg->pcfg_nid, - pcfg->pcfg_flags ? "Enabling" : "Disabling", - (time_t)pcfg->pcfg_nid3); - - err = kpr_sys_notify (pcfg->pcfg_gw_nal, pcfg->pcfg_nid, - pcfg->pcfg_flags, (time_t)pcfg->pcfg_nid3); - break; - } - - case NAL_CMD_GET_ROUTE: - CDEBUG (D_IOCTL, "Getting route [%d]\n", pcfg->pcfg_count); - err = kpr_get_route(pcfg->pcfg_count, &pcfg->pcfg_gw_nal, - &pcfg->pcfg_nid, - &pcfg->pcfg_nid2, &pcfg->pcfg_nid3, - &pcfg->pcfg_flags); - break; - } - RETURN(err); -} - - -static void /*__exit*/ -kpr_finalise (void) -{ - LASSERT (list_empty (&kpr_nals)); - - libcfs_nal_cmd_unregister(ROUTER); - - PORTAL_SYMBOL_UNREGISTER(kpr_router_interface); - - kpr_proc_fini(); - - while (!list_empty (&kpr_routes)) { - kpr_route_entry_t *re = list_entry(kpr_routes.next, - kpr_route_entry_t, - kpre_list); - - list_del(&re->kpre_list); - PORTAL_FREE(re, sizeof (*re)); - } - - CDEBUG(D_MALLOC, "kpr_finalise: kmem back to %d\n", - atomic_read(&portal_kmemory)); -} - -static int __init -kpr_initialise (void) -{ - int rc; - - CDEBUG(D_MALLOC, "kpr_initialise: kmem %d\n", - atomic_read(&portal_kmemory)); - - kpr_routes_generation = 0; - kpr_proc_init(); - - rc = libcfs_nal_cmd_register(ROUTER, kpr_nal_cmd, NULL); - if (rc != 0) { - CERROR("Can't register nal cmd handler\n"); - return (rc); - } - - PORTAL_SYMBOL_REGISTER(kpr_router_interface); - return (0); -} - -MODULE_AUTHOR("Eric Barton"); -MODULE_DESCRIPTION("Kernel Portals Router v0.01"); -MODULE_LICENSE("GPL"); - -module_init (kpr_initialise); -module_exit (kpr_finalise); - -EXPORT_SYMBOL (kpr_router_interface); diff --git a/lnet/router/router.h b/lnet/router/router.h deleted file mode 100644 index 27e4983..0000000 --- a/lnet/router/router.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * - * This file is part of Portals - * http://sourceforge.net/projects/sandiaportals/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef _KPTLROUTER_H -#define _KPTLROUTER_H -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_PTLROUTER - -#include -#include -#include -#include - -typedef struct -{ - struct list_head kpne_list; - kpr_nal_interface_t kpne_interface; - atomic_t kpne_refcount; - int kpne_shutdown; -} kpr_nal_entry_t; - -typedef struct -{ - struct list_head kpge_list; - atomic_t kpge_weight; - time_t kpge_timestamp; - int kpge_alive; - int kpge_nalid; - int kpge_refcount; - ptl_nid_t kpge_nid; -} kpr_gateway_entry_t; - -typedef struct -{ - struct list_head kpre_list; - kpr_gateway_entry_t *kpre_gateway; - ptl_nid_t kpre_lo_nid; - ptl_nid_t kpre_hi_nid; -} kpr_route_entry_t; - -typedef struct -{ - work_struct_t kpru_tq; - int kpru_nal_id; - ptl_nid_t kpru_nid; - int kpru_alive; - time_t kpru_when; -} kpr_upcall_t; - -extern int kpr_register_nal (kpr_nal_interface_t *nalif, void **argp); -extern int kpr_lookup_target (void *arg, ptl_nid_t target_nid, int nob, - ptl_nid_t *gateway_nidp); -extern kpr_nal_entry_t *kpr_find_nal_entry_locked (int nal_id); -extern void kpr_forward_packet (void *arg, kpr_fwd_desc_t *fwd); -extern void kpr_complete_packet (void *arg, kpr_fwd_desc_t *fwd, int error); -extern void kpr_nal_notify (void *arg, ptl_nid_t peer, - int alive, time_t when); -extern void kpr_shutdown_nal (void *arg); -extern void kpr_deregister_nal (void *arg); - -extern void kpr_proc_init (void); -extern void kpr_proc_fini (void); - -extern unsigned int kpr_routes_generation; -extern unsigned long long kpr_fwd_bytes; -extern unsigned long kpr_fwd_packets; -extern unsigned long kpr_fwd_errors; -extern atomic_t kpr_queue_depth; - -extern struct list_head kpr_routes; -extern rwlock_t kpr_rwlock; - -#endif /* _KPLROUTER_H */ diff --git a/lnet/tests/.cvsignore b/lnet/tests/.cvsignore deleted file mode 100644 index e034130..0000000 --- a/lnet/tests/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -Makefile -.deps -.*.cmd -autoMakefile.in -autoMakefile -*.ko -*.mod.c -.*.flags -.tmp_versions -.depend diff --git a/lnet/tests/Makefile.in b/lnet/tests/Makefile.in deleted file mode 100644 index c309db0..0000000 --- a/lnet/tests/Makefile.in +++ /dev/null @@ -1,16 +0,0 @@ -MODULES := pingsrv pingcli spingsrv spingcli -pingsrv-objs := ping_srv.o - -ifeq ($(PATCHLEVEL),6) -pingcli-objs := ping_cli.o -spingsrv-objs := sping_srv.o -spingcli-objs := sping_cli.o -else -ping%.c: ping_%.c - ln -sf $< $@ - -sping%.c: sping_%.c - ln -sf $< $@ -endif - -@INCLUDE_RULES@ diff --git a/lnet/tests/Makefile.mk b/lnet/tests/Makefile.mk deleted file mode 100644 index 751c0a0..0000000 --- a/lnet/tests/Makefile.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -include $(src)/../Kernelenv - -obj-y += ping_cli.o -obj-y += ping_srv.o diff --git a/lnet/tests/autoMakefile.am b/lnet/tests/autoMakefile.am deleted file mode 100644 index 5f81b93..0000000 --- a/lnet/tests/autoMakefile.am +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -if MODULES -if !CRAY_PORTALS -if TESTS -noinst_DATA := pingsrv$(KMODEXT) pingcli$(KMODEXT) -noinst_DATA += spingsrv$(KMODEXT) spingcli$(KMODEXT) -endif -endif -endif - -MOSTLYCLEANFILES = *.o *.ko *.mod.c pingsrv.c pingcli.c spingsrv.c spingcli.c -DIST_SOURCES = ping_srv.c ping_cli.c sping_srv.c sping_cli.c ping.h diff --git a/lnet/tests/ping.h b/lnet/tests/ping.h deleted file mode 100644 index f07444b..0000000 --- a/lnet/tests/ping.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _KPING_INCLUDED -#define _KPING_INCLUDED - -#include - - -#define PTL_PING_IN_SIZE 256 // n packets per buffer -#define PTL_PING_IN_BUFFERS 2 // n fallback buffers - -#define PTL_PING_CLIENT 4 -#define PTL_PING_SERVER 5 - -#define PING_HEADER_MAGIC 0xDEADBEEF -#define PING_BULK_MAGIC 0xCAFEBABE - -#define PING_HEAD_BITS 0x00000001 -#define PING_BULK_BITS 0x00000002 -#define PING_IGNORE_BITS 0xFFFFFFFC - -#define PTL_PING_ACK 0x01 -#define PTL_PING_VERBOSE 0x02 -#define PTL_PING_VERIFY 0x04 -#define PTL_PING_PREALLOC 0x08 - - -#define NEXT_PRIMARY_BUFFER(index) \ - (((index + 1) >= PTL_PING_IN_BUFFERS) ? 0 : (index + 1)) - -#define PDEBUG(str, err) \ - CERROR ("%s: error=%s (%d)\n", str, ptl_err_str[err], err) - - -/* Ping data to be passed via the ioctl to kernel space */ - -#if __KERNEL__ - - -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) -#include -#else -#include -#endif -struct pingsrv_data { - - ptl_handle_ni_t ni; - ptl_handle_me_t me; - ptl_handle_eq_t eq; - void *in_buf; - ptl_process_id_t my_id; - ptl_process_id_t id_local; - ptl_md_t mdin; - ptl_md_t mdout; - ptl_handle_md_t mdin_h; - ptl_handle_md_t mdout_h; - ptl_event_t evnt; - struct task_struct *tsk; -}; /* struct pingsrv_data */ - -struct pingcli_data { - - struct portal_ioctl_data *args; - ptl_handle_me_t me; - ptl_handle_eq_t eq; - char *inbuf; - char *outbuf; - ptl_process_id_t myid; - ptl_process_id_t id_local; - ptl_process_id_t id_remote; - ptl_md_t md_in_head; - ptl_md_t md_out_head; - ptl_handle_md_t md_in_head_h; - ptl_handle_md_t md_out_head_h; - ptl_event_t ev; - struct task_struct *tsk; -}; /* struct pingcli_data */ - - -#endif /* __KERNEL__ */ - -#endif /* _KPING_INCLUDED */ diff --git a/lnet/tests/ping_cli.c b/lnet/tests/ping_cli.c deleted file mode 100644 index e9a8481..0000000 --- a/lnet/tests/ping_cli.c +++ /dev/null @@ -1,303 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002, Lawrence Livermore National Labs (LLNL) - * Author: Brian Behlendorf - * Kedar Sovani (kedar@calsoftinc.com) - * Amey Inamdar (amey@calsoftinc.com) - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#define DEBUG_SUBSYSTEM S_PINGER - -#include -#include -#include -#include -#include -#include -#include "ping.h" -/* int portal_debug = D_PING_CLI; */ - - -#define STDSIZE (sizeof(int) + sizeof(int) + sizeof(struct timeval)) - -#define MAX_TIME 100000 - -/* This should be enclosed in a structure */ - -static struct pingcli_data *client = NULL; - -static int count = 0; - -static void -pingcli_shutdown(ptl_handle_ni_t nih, int err) -{ - int rc; - - /* Yes, we are intentionally allowing us to fall through each - * case in to the next. This allows us to pass an error - * code to just clean up the right stuff. - */ - switch (err) { - case 1: - /* Unlink any memory descriptors we may have used */ - if ((rc = PtlMDUnlink (client->md_out_head_h))) - PDEBUG ("PtlMDUnlink", rc); - case 2: - if ((rc = PtlMDUnlink (client->md_in_head_h))) - PDEBUG ("PtlMDUnlink", rc); - - /* Free the event queue */ - if ((rc = PtlEQFree (client->eq))) - PDEBUG ("PtlEQFree", rc); - - if ((rc = PtlMEUnlink (client->me))) - PDEBUG ("PtlMEUnlink", rc); - case 3: - PtlNIFini(nih); - - case 4: - /* Free our buffers */ - - if (client != NULL) - PORTAL_FREE (client, - sizeof(struct pingcli_data)); - } - - - CDEBUG (D_OTHER, "ping client released resources\n"); -} /* pingcli_shutdown() */ - -static void pingcli_callback(ptl_event_t *ev) -{ - int i, magic; - i = *(int *)(ev->md.start + ev->offset + sizeof(unsigned)); - magic = *(int *)(ev->md.start + ev->offset); - - if(magic != 0xcafebabe) { - CERROR("Unexpected response %x\n", magic); - } - - if((i == count) || !count) - wake_up_process (client->tsk); - else - CERROR("Received response after timeout for %d\n",i); -} - - -static struct pingcli_data * -pingcli_start(struct portal_ioctl_data *args) -{ - ptl_handle_ni_t nih = PTL_INVALID_HANDLE; - unsigned ping_head_magic = PING_HEADER_MAGIC; - unsigned ping_bulk_magic = PING_BULK_MAGIC; - int rc; - struct timeval tv1, tv2; - char str[PTL_NALFMT_SIZE]; - - client->tsk = current; - client->args = args; - CDEBUG (D_OTHER, "pingcli_setup args: nid "LPX64" (%s), \ - nal %x, size %u, count: %u, timeout: %u\n", - args->ioc_nid, - portals_nid2str(args->ioc_nal, args->ioc_nid, str), - args->ioc_nal, args->ioc_size, - args->ioc_count, args->ioc_timeout); - - - PORTAL_ALLOC (client->outbuf, STDSIZE + args->ioc_size) ; - if (client->outbuf == NULL) - { - CERROR ("Unable to allocate out_buf ("LPSZ" bytes)\n", STDSIZE); - pingcli_shutdown (nih, 4); - return (NULL); - } - - PORTAL_ALLOC (client->inbuf, - (args->ioc_size + STDSIZE) * args->ioc_count); - if (client->inbuf == NULL) - { - CERROR ("Unable to allocate out_buf ("LPSZ" bytes)\n", STDSIZE); - pingcli_shutdown (nih, 4); - return (NULL); - } - - /* Aquire and initialize the proper nal for portals. */ - rc = PtlNIInit(args->ioc_nal, 0, NULL, NULL, &nih); - if (rc != PTL_OK || rc != PTL_IFACE_DUP) - { - CERROR ("NAL %x not loaded\n", args->ioc_nal); - pingcli_shutdown (nih, 4); - return (NULL); - } - - /* Based on the initialization aquire our unique portal ID. */ - if ((rc = PtlGetId (nih, &client->myid))) - { - CERROR ("PtlGetId error %d\n", rc); - pingcli_shutdown (nih, 2); - return (NULL); - } - - /* Setup the local match entries */ - client->id_local.nid = PTL_NID_ANY; - client->id_local.pid = PTL_PID_ANY; - - /* Setup the remote match entries */ - client->id_remote.nid = args->ioc_nid; - client->id_remote.pid = 0; - - if ((rc = PtlMEAttach (nih, PTL_PING_CLIENT, - client->id_local, 0, ~0, PTL_RETAIN, - PTL_INS_AFTER, &client->me))) - { - CERROR ("PtlMEAttach error %d\n", rc); - pingcli_shutdown (nih, 2); - return (NULL); - } - - /* Allocate the event queue for this network interface */ - if ((rc = PtlEQAlloc (nih, 64, pingcli_callback, &client->eq))) - { - CERROR ("PtlEQAlloc error %d\n", rc); - pingcli_shutdown (nih, 2); - return (NULL); - } - - count = args->ioc_count; - - client->md_in_head.start = client->inbuf; - client->md_in_head.length = (args->ioc_size + STDSIZE) - * count; - client->md_in_head.threshold = PTL_MD_THRESH_INF; - client->md_in_head.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - client->md_in_head.user_ptr = NULL; - client->md_in_head.eq_handle = client->eq; - memset (client->inbuf, 0, (args->ioc_size + STDSIZE) * count); - - /* Attach the incoming buffer */ - if ((rc = PtlMDAttach (client->me, client->md_in_head, - PTL_UNLINK, &client->md_in_head_h))) { - CERROR ("PtlMDAttach error %d\n", rc); - pingcli_shutdown (nih, 1); - return (NULL); - } - /* Setup the outgoing ping header */ - client->md_out_head.start = client->outbuf; - client->md_out_head.length = STDSIZE + args->ioc_size; - client->md_out_head.threshold = args->ioc_count; - client->md_out_head.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - client->md_out_head.user_ptr = NULL; - client->md_out_head.eq_handle = PTL_EQ_NONE; - - memcpy (client->outbuf, &ping_head_magic, sizeof(ping_bulk_magic)); - - count = 0; - - /* Bind the outgoing ping header */ - if ((rc=PtlMDBind (nih, client->md_out_head, - PTL_UNLINK, &client->md_out_head_h))) { - CERROR ("PtlMDBind error %d\n", rc); - pingcli_shutdown (nih, 1); - return NULL; - } - while ((args->ioc_count - count)) { - memcpy (client->outbuf + sizeof(unsigned), - &(count), sizeof(unsigned)); - /* Put the ping packet */ - do_gettimeofday (&tv1); - - memcpy(client->outbuf+sizeof(unsigned)+sizeof(unsigned),&tv1, - sizeof(struct timeval)); - - if((rc = PtlPut (client->md_out_head_h, PTL_NOACK_REQ, - client->id_remote, PTL_PING_SERVER, 0, 0, 0, 0))) { - PDEBUG ("PtlPut (header)", rc); - pingcli_shutdown (nih, 1); - return NULL; - } - CWARN ("Lustre: sent msg no %d", count); - - set_current_state (TASK_INTERRUPTIBLE); - rc = schedule_timeout (20 * args->ioc_timeout); - if (rc == 0) { - CERROR ("timeout .....\n"); - } else { - do_gettimeofday (&tv2); - CWARN("Reply in %u usec\n", - (unsigned)((tv2.tv_sec - tv1.tv_sec) - * 1000000 + (tv2.tv_usec - tv1.tv_usec))); - } - count++; - } - - if (client->outbuf != NULL) - PORTAL_FREE (client->outbuf, STDSIZE + args->ioc_size); - - if (client->inbuf != NULL) - PORTAL_FREE (client->inbuf, - (args->ioc_size + STDSIZE) * args->ioc_count); - - pingcli_shutdown (nih, 2); - - /* Success! */ - return NULL; -} /* pingcli_setup() */ - - - -/* called by the portals_ioctl for ping requests */ -int kping_client(struct portal_ioctl_data *args) -{ - PORTAL_ALLOC (client, sizeof(struct pingcli_data)); - if (client == NULL) - { - CERROR ("Unable to allocate client structure\n"); - return (0); - } - memset (client, 0, sizeof(struct pingcli_data)); - pingcli_start (args); - - return 0; -} /* kping_client() */ - - -static int __init pingcli_init(void) -{ - PORTAL_SYMBOL_REGISTER(kping_client); - return 0; -} /* pingcli_init() */ - - -static void /*__exit*/ pingcli_cleanup(void) -{ - PORTAL_SYMBOL_UNREGISTER (kping_client); -} /* pingcli_cleanup() */ - - -MODULE_AUTHOR("Brian Behlendorf (LLNL)"); -MODULE_DESCRIPTION("A simple kernel space ping client for portals testing"); -MODULE_LICENSE("GPL"); - -module_init(pingcli_init); -module_exit(pingcli_cleanup); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) -EXPORT_SYMBOL (kping_client); -#endif diff --git a/lnet/tests/ping_srv.c b/lnet/tests/ping_srv.c deleted file mode 100644 index 49e82af..0000000 --- a/lnet/tests/ping_srv.c +++ /dev/null @@ -1,308 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002, Lawrence Livermore National Labs (LLNL) - * Author: Brian Behlendorf - * Amey Inamdar - * Kedar Sovani - * - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#define DEBUG_SUBSYSTEM S_PINGER - -#include -#include -#include "ping.h" - -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) -#include -#else -#include -#endif -#include -#include - -#include -#include - -#define STDSIZE (sizeof(int) + sizeof(int) + sizeof(struct timeval)) -#define MAXSIZE (16*1024) - -static unsigned ping_head_magic; -static unsigned ping_bulk_magic; -static int nal = SOCKNAL; // Your NAL, -static unsigned long packets_valid = 0; // Valid packets -static int running = 1; -atomic_t pkt; - -static struct pingsrv_data *server=NULL; // Our ping server - -static void *pingsrv_shutdown(int err) -{ - int rc; - - /* Yes, we are intentionally allowing us to fall through each - * case in to the next. This allows us to pass an error - * code to just clean up the right stuff. - */ - switch (err) { - case 1: - /* Unlink any memory descriptors we may have used */ - if ((rc = PtlMDUnlink (server->mdin_h))) - PDEBUG ("PtlMDUnlink (out head buffer)", rc); - case 2: - /* Free the event queue */ - if ((rc = PtlEQFree (server->eq))) - PDEBUG ("PtlEQFree", rc); - - /* Unlink the client portal from the ME list */ - if ((rc = PtlMEUnlink (server->me))) - PDEBUG ("PtlMEUnlink", rc); - - case 3: - PtlNIFini (server->ni); - - case 4: - - case 5: - if (server->in_buf != NULL) - PORTAL_FREE (server->in_buf, MAXSIZE); - - if (server != NULL) - PORTAL_FREE (server, - sizeof (struct pingsrv_data)); - - } - - CDEBUG (D_OTHER, "ping sever resources released\n"); - return NULL; -} /* pingsrv_shutdown() */ - - -int pingsrv_thread(void *arg) -{ - int rc; - unsigned long magic; - unsigned long ping_bulk_magic = 0xcafebabe; - - kportal_daemonize ("pingsrv"); - server->tsk = current; - - while (running) { - set_current_state (TASK_INTERRUPTIBLE); - if (atomic_read (&pkt) == 0) { - schedule_timeout (MAX_SCHEDULE_TIMEOUT); - continue; - } - - magic = *((int *)(server->evnt.md.start - + server->evnt.offset)); - - - if(magic != 0xdeadbeef) { - CERROR("Unexpected Packet to the server\n"); - - } - memcpy (server->in_buf, &ping_bulk_magic, sizeof(ping_bulk_magic)); - - server->mdout.length = server->evnt.rlength; - server->mdout.start = server->in_buf; - server->mdout.threshold = 1; - server->mdout.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - server->mdout.user_ptr = NULL; - server->mdout.eq_handle = PTL_EQ_NONE; - - /* Bind the outgoing buffer */ - if ((rc = PtlMDBind (server->ni, server->mdout, - PTL_UNLINK, &server->mdout_h))) { - PDEBUG ("PtlMDBind", rc); - pingsrv_shutdown (1); - return 1; - } - - - server->mdin.start = server->in_buf; - server->mdin.length = MAXSIZE; - server->mdin.threshold = 1; - server->mdin.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - server->mdin.user_ptr = NULL; - server->mdin.eq_handle = server->eq; - - if ((rc = PtlMDAttach (server->me, server->mdin, - PTL_UNLINK, &server->mdin_h))) { - PDEBUG ("PtlMDAttach (bulk)", rc); - CDEBUG (D_OTHER, "ping server resources allocated\n"); - } - - if ((rc = PtlPut (server->mdout_h, PTL_NOACK_REQ, - server->evnt.initiator, PTL_PING_CLIENT, 0, 0, 0, 0))) - PDEBUG ("PtlPut", rc); - - atomic_dec (&pkt); - - } - pingsrv_shutdown (1); - running = 1; - return 0; -} - -static void pingsrv_packet(ptl_event_t *ev) -{ - atomic_inc (&pkt); - wake_up_process (server->tsk); -} /* pingsrv_head() */ - -static void pingsrv_callback(ptl_event_t *ev) -{ - - if (ev == NULL) { - CERROR ("null in callback, ev=%p\n", ev); - return; - } - server->evnt = *ev; - - CWARN ("received ping from nid "LPX64" " - "(off=%u rlen=%u mlen=%u head=%x seq=%d size=%d)\n", - ev->initiator.nid, ev->offset, ev->rlength, ev->mlength, - *((int *)(ev->md.start + ev->offset)), - *((int *)(ev->md.start + ev->offset + sizeof(unsigned))), - *((int *)(ev->md.start + ev->offset + 2 * - sizeof(unsigned)))); - - packets_valid++; - - pingsrv_packet(ev); - -} /* pingsrv_callback() */ - - -static struct pingsrv_data *pingsrv_setup(void) -{ - int rc; - - server->ni = PTL_INVALID_HANDLE; - - /* Aquire and initialize the proper nal for portals. */ - rc = PtlNIInit(nal, 0, NULL, NULL, &server->ni); - if (!(rc == PTL_OK || rc == PTL_IFACE_DUP)) { - CDEBUG (D_OTHER, "NAL %x not loaded\n", nal); - return pingsrv_shutdown (4); - } - - - /* Based on the initialization aquire our unique portal ID. */ - if ((rc = PtlGetId (server->ni, &server->my_id))) { - PDEBUG ("PtlGetId", rc); - return pingsrv_shutdown (2); - } - - server->id_local.nid = PTL_NID_ANY; - server->id_local.pid = PTL_PID_ANY; - - /* Attach a match entries for header packets */ - if ((rc = PtlMEAttach (server->ni, PTL_PING_SERVER, - server->id_local,0, ~0, - PTL_RETAIN, PTL_INS_AFTER, &server->me))) { - PDEBUG ("PtlMEAttach", rc); - return pingsrv_shutdown (2); - } - - - if ((rc = PtlEQAlloc (server->ni, 1024, &pingsrv_callback, - &server->eq))) { - PDEBUG ("PtlEQAlloc (callback)", rc); - return pingsrv_shutdown (2); - } - - PORTAL_ALLOC (server->in_buf, MAXSIZE); - if(!server->in_buf){ - CDEBUG (D_OTHER,"Allocation error\n"); - return pingsrv_shutdown(2); - } - - /* Setup the incoming buffer */ - server->mdin.start = server->in_buf; - server->mdin.length = MAXSIZE; - server->mdin.threshold = 1; - server->mdin.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - server->mdin.user_ptr = NULL; - server->mdin.eq_handle = server->eq; - memset (server->in_buf, 0, STDSIZE); - - if ((rc = PtlMDAttach (server->me, server->mdin, - PTL_UNLINK, &server->mdin_h))) { - PDEBUG ("PtlMDAttach (bulk)", rc); - CDEBUG (D_OTHER, "ping server resources allocated\n"); - } - - /* Success! */ - return server; -} /* pingsrv_setup() */ - -static int pingsrv_start(void) -{ - /* Setup our server */ - if (!pingsrv_setup()) { - CDEBUG (D_OTHER, "pingsrv_setup() failed, server stopped\n"); - return -ENOMEM; - } - kernel_thread (pingsrv_thread,NULL,0); - return 0; -} /* pingsrv_start() */ - - - -static int __init pingsrv_init(void) -{ - ping_head_magic = PING_HEADER_MAGIC; - ping_bulk_magic = PING_BULK_MAGIC; - PORTAL_ALLOC (server, sizeof(struct pingsrv_data)); - return pingsrv_start (); -} /* pingsrv_init() */ - - -static void /*__exit*/ pingsrv_cleanup(void) -{ - remove_proc_entry ("net/pingsrv", NULL); - - running = 0; - wake_up_process (server->tsk); - while (running != 1) { - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - } - -} /* pingsrv_cleanup() */ - - -MODULE_PARM(nal, "i"); -MODULE_PARM_DESC(nal, "Use the specified NAL " - "(2-ksocknal, 1-kqswnal)"); - -MODULE_AUTHOR("Brian Behlendorf (LLNL)"); -MODULE_DESCRIPTION("A kernel space ping server for portals testing"); -MODULE_LICENSE("GPL"); - -module_init(pingsrv_init); -module_exit(pingsrv_cleanup); diff --git a/lnet/tests/sping_cli.c b/lnet/tests/sping_cli.c deleted file mode 100644 index d9970e7..0000000 --- a/lnet/tests/sping_cli.c +++ /dev/null @@ -1,279 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002, Lawrence Livermore National Labs (LLNL) - * Author: Brian Behlendorf - * Kedar Sovani (kedar@calsoftinc.com) - * Amey Inamdar (amey@calsoftinc.com) - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* This is a striped down version of pinger. It follows a single - * request-response protocol. Doesn't do Bulk data pinging. Also doesn't - * send multiple packets in a single ioctl. - */ - - -#define DEBUG_SUBSYSTEM S_PINGER - -#include -#include -#include -#include -#include -#include -#include "ping.h" -/* int portal_debug = D_PING_CLI; */ - - -#define STDSIZE (sizeof(int) + sizeof(int) + 4) /* The data is 4 bytes - assumed */ - -/* This should be enclosed in a structure */ - -static struct pingcli_data *client = NULL; - -static int count = 0; - -static void -pingcli_shutdown(ptl_handle_ni_t nih, int err) -{ - int rc; - - /* Yes, we are intentionally allowing us to fall through each - * case in to the next. This allows us to pass an error - * code to just clean up the right stuff. - */ - switch (err) { - case 1: - /* Unlink any memory descriptors we may have used */ - if ((rc = PtlMDUnlink (client->md_out_head_h))) - PDEBUG ("PtlMDUnlink", rc); - case 2: - /* Free the event queue */ - if ((rc = PtlEQFree (client->eq))) - PDEBUG ("PtlEQFree", rc); - - if ((rc = PtlMEUnlink (client->me))) - PDEBUG ("PtlMEUnlink", rc); - case 3: - PtlNIFini (nih); - - case 4: - /* Free our buffers */ - if (client->outbuf != NULL) - PORTAL_FREE (client->outbuf, STDSIZE); - - if (client->inbuf != NULL) - PORTAL_FREE (client->inbuf, STDSIZE); - - - if (client != NULL) - PORTAL_FREE (client, - sizeof(struct pingcli_data)); - } - - - CDEBUG (D_OTHER, "ping client released resources\n"); -} /* pingcli_shutdown() */ - -static void pingcli_callback(ptl_event_t *ev) -{ - wake_up_process (client->tsk); -} - - -static struct pingcli_data * -pingcli_start(struct portal_ioctl_data *args) -{ - ptl_handle_ni_t nih = PTL_INVALID_HANDLE; - unsigned ping_head_magic = PING_HEADER_MAGIC; - char str[PTL_NALFMT_SIZE]; - int rc; - - client->tsk = current; - client->args = args; - - CDEBUG (D_OTHER, "pingcli_setup args: nid "LPX64" (%s), \ - nal %x, size %u, count: %u, timeout: %u\n", - args->ioc_nid, - portals_nid2str(args->ioc_nid, args->ioc_nal, str), - args->ioc_nal, args->ioc_size, - args->ioc_count, args->ioc_timeout); - - - PORTAL_ALLOC (client->outbuf, STDSIZE) ; - if (client->outbuf == NULL) - { - CERROR ("Unable to allocate out_buf ("LPSZ" bytes)\n", STDSIZE); - pingcli_shutdown (nih, 4); - return (NULL); - } - - PORTAL_ALLOC (client->inbuf, STDSIZE); - - if (client->inbuf == NULL) - { - CERROR ("Unable to allocate out_buf ("LPSZ" bytes)\n", STDSIZE); - pingcli_shutdown (nih, 4); - return (NULL); - } - - /* Aquire and initialize the proper nal for portals. */ - rc = PtlNIInit(args->ioc_nal, 0, NULL, NULL, &nih); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) - { - CERROR ("NAL %x not loaded.\n", args->ioc_nal); - pingcli_shutdown (nih, 4); - return (NULL); - } - - /* Based on the initialization aquire our unique portal ID. */ - if ((rc = PtlGetId (nih, &client->myid))) - { - CERROR ("PtlGetId error %d\n", rc); - pingcli_shutdown (nih, 2); - return (NULL); - } - - /* Setup the local match entries */ - client->id_local.nid = PTL_NID_ANY; - client->id_local.pid = PTL_PID_ANY; - - /* Setup the remote match entries */ - client->id_remote.nid = args->ioc_nid; - client->id_remote.pid = 0; - - if ((rc = PtlMEAttach (nih, PTL_PING_CLIENT, - client->id_local, 0, ~0, PTL_RETAIN, - PTL_INS_AFTER, &client->me))) - { - CERROR ("PtlMEAttach error %d\n", rc); - pingcli_shutdown (nih, 2); - return (NULL); - } - - /* Allocate the event queue for this network interface */ - if ((rc = PtlEQAlloc (nih, 64, pingcli_callback, &client->eq))) - { - CERROR ("PtlEQAlloc error %d\n", rc); - pingcli_shutdown (nih, 2); - return (NULL); - } - - - client->md_in_head.start = client->inbuf; - client->md_in_head.length = STDSIZE; - client->md_in_head.threshold = 1; - client->md_in_head.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - client->md_in_head.user_ptr = NULL; - client->md_in_head.eq_handle = client->eq; - memset (client->inbuf, 0, STDSIZE); - - /* Attach the incoming buffer */ - if ((rc = PtlMDAttach (client->me, client->md_in_head, - PTL_UNLINK, &client->md_in_head_h))) { - CERROR ("PtlMDAttach error %d\n", rc); - pingcli_shutdown (nih, 1); - return (NULL); - } - - /* Setup the outgoing ping header */ - client->md_out_head.start = client->outbuf; - client->md_out_head.length = STDSIZE; - client->md_out_head.threshold = 1; - client->md_out_head.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - client->md_out_head.user_ptr = NULL; - client->md_out_head.eq_handle = PTL_EQ_NONE; - - memcpy (client->outbuf, &ping_head_magic, sizeof(ping_head_magic)); - - /* Bind the outgoing ping header */ - if ((rc=PtlMDBind (nih, client->md_out_head, - PTL_UNLINK, &client->md_out_head_h))) { - CERROR ("PtlMDBind error %d\n", rc); - pingcli_shutdown (nih, 1); - return (NULL); - } - /* Put the ping packet */ - if((rc = PtlPut (client->md_out_head_h, PTL_NOACK_REQ, - client->id_remote, PTL_PING_SERVER, 0, 0, 0, 0))) { - PDEBUG ("PtlPut (header)", rc); - pingcli_shutdown (nih, 1); - return NULL; - } - - count = 0; - set_current_state (TASK_INTERRUPTIBLE); - rc = schedule_timeout (20 * args->ioc_timeout); - if (rc == 0) { - CERROR ("Time out on the server\n"); - pingcli_shutdown (nih, 2); - return NULL; - } else { - CWARN("Received respose from the server \n"); - } - - pingcli_shutdown (nih, 2); - - /* Success! */ - return NULL; -} /* pingcli_setup() */ - - - -/* called by the portals_ioctl for ping requests */ -int kping_client(struct portal_ioctl_data *args) -{ - - PORTAL_ALLOC (client, sizeof(struct pingcli_data)); - memset (client, 0, sizeof(struct pingcli_data)); - if (client == NULL) - { - CERROR ("Unable to allocate client structure\n"); - return (0); - } - pingcli_start (args); - - return 0; -} /* kping_client() */ - - -static int __init pingcli_init(void) -{ - PORTAL_SYMBOL_REGISTER(kping_client); - return 0; -} /* pingcli_init() */ - - -static void /*__exit*/ pingcli_cleanup(void) -{ - PORTAL_SYMBOL_UNREGISTER (kping_client); -} /* pingcli_cleanup() */ - - -MODULE_AUTHOR("Brian Behlendorf (LLNL)"); -MODULE_DESCRIPTION("A simple kernel space ping client for portals testing"); -MODULE_LICENSE("GPL"); - -module_init(pingcli_init); -module_exit(pingcli_cleanup); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) -EXPORT_SYMBOL (kping_client); -#endif diff --git a/lnet/tests/sping_srv.c b/lnet/tests/sping_srv.c deleted file mode 100644 index 069423d..0000000 --- a/lnet/tests/sping_srv.c +++ /dev/null @@ -1,294 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002, Lawrence Livermore National Labs (LLNL) - * Author: Brian Behlendorf - * Amey Inamdar - * Kedar Sovani - * - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* This is a striped down version of pinger. It follows a single - * request-response protocol. Doesn't do Bulk data pinging. Also doesn't - * send multiple packets in a single ioctl. - */ - -#define DEBUG_SUBSYSTEM S_PINGER - -#include -#include -#include "ping.h" - -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) -#include -#else -#include -#endif -#include -#include - -#include -#include - -#define STDSIZE (sizeof(int) + sizeof(int) + 4) - -static int nal = PTL_IFACE_DEFAULT; // Your NAL, -static unsigned long packets_valid = 0; // Valid packets -static int running = 1; -atomic_t pkt; - -static struct pingsrv_data *server=NULL; // Our ping server - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) -#endif - -static void *pingsrv_shutdown(int err) -{ - int rc; - - /* Yes, we are intentionally allowing us to fall through each - * case in to the next. This allows us to pass an error - * code to just clean up the right stuff. - */ - switch (err) { - case 1: - /* Unlink any memory descriptors we may have used */ - if ((rc = PtlMDUnlink (server->mdin_h))) - PDEBUG ("PtlMDUnlink (out head buffer)", rc); - case 2: - /* Free the event queue */ - if ((rc = PtlEQFree (server->eq))) - PDEBUG ("PtlEQFree", rc); - - /* Unlink the client portal from the ME list */ - if ((rc = PtlMEUnlink (server->me))) - PDEBUG ("PtlMEUnlink", rc); - - case 3: - PtlNIFini(server->ni); - - case 4: - - if (server->in_buf != NULL) - PORTAL_FREE (server->in_buf, STDSIZE); - - if (server != NULL) - PORTAL_FREE (server, - sizeof (struct pingsrv_data)); - - } - - CDEBUG (D_OTHER, "ping sever resources released\n"); - return NULL; -} /* pingsrv_shutdown() */ - - -int pingsrv_thread(void *arg) -{ - int rc; - - kportal_daemonize ("pingsrv"); - server->tsk = current; - - while (running) { - set_current_state (TASK_INTERRUPTIBLE); - if (atomic_read (&pkt) == 0) { - schedule_timeout (MAX_SCHEDULE_TIMEOUT); - continue; - } - - server->mdout.start = server->in_buf; - server->mdout.length = STDSIZE; - server->mdout.threshold = 1; - server->mdout.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - server->mdout.user_ptr = NULL; - server->mdout.eq_handle = PTL_EQ_NONE; - - /* Bind the outgoing buffer */ - if ((rc = PtlMDBind (server->ni, server->mdout, - PTL_UNLINK, &server->mdout_h))) { - PDEBUG ("PtlMDBind", rc); - pingsrv_shutdown (1); - return 1; - } - - - server->mdin.start = server->in_buf; - server->mdin.length = STDSIZE; - server->mdin.threshold = 1; - server->mdin.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - server->mdin.user_ptr = NULL; - server->mdin.eq_handle = server->eq; - - if ((rc = PtlMDAttach (server->me, server->mdin, - PTL_UNLINK, &server->mdin_h))) { - PDEBUG ("PtlMDAttach (bulk)", rc); - CDEBUG (D_OTHER, "ping server resources allocated\n"); - } - - if ((rc = PtlPut (server->mdout_h, PTL_NOACK_REQ, - server->evnt.initiator, PTL_PING_CLIENT, 0, 0, 0, 0))) - PDEBUG ("PtlPut", rc); - - atomic_dec (&pkt); - - } - pingsrv_shutdown (1); - running = 1; - return 0; -} - -static void pingsrv_packet(ptl_event_t *ev) -{ - atomic_inc (&pkt); - wake_up_process (server->tsk); -} /* pingsrv_head() */ - -static void pingsrv_callback(ptl_event_t *ev) -{ - - if (ev == NULL) { - CERROR ("null in callback, ev=%p\n", ev); - return; - } - server->evnt = *ev; - - CWARN("Lustre: received ping from nid "LPX64" " - "(off=%u rlen=%u mlen=%u head=%x)\n", - ev->initiator.nid, ev->offset, ev->rlength, ev->mlength, - *((int *)(ev->md.start + ev->offset))); - - packets_valid++; - - pingsrv_packet(ev); - -} /* pingsrv_callback() */ - - -static struct pingsrv_data *pingsrv_setup(void) -{ - int rc; - - /* Aquire and initialize the proper nal for portals. */ - server->ni = PTL_INVALID_HANDLE; - - rc = PtlNIInit(nal, 0, NULL, NULL, &server->ni); - if (rc != PTL_OK && rc != PTL_IFACE_DUP) { - CDEBUG (D_OTHER, "Nal %x not loaded.\n", nal); - return pingsrv_shutdown (4); - } - - /* Based on the initialization aquire our unique portal ID. */ - if ((rc = PtlGetId (server->ni, &server->my_id))) { - PDEBUG ("PtlGetId", rc); - return pingsrv_shutdown (2); - } - - server->id_local.nid = PTL_NID_ANY; - server->id_local.pid = PTL_PID_ANY; - - /* Attach a match entries for header packets */ - if ((rc = PtlMEAttach (server->ni, PTL_PING_SERVER, - server->id_local,0, ~0, - PTL_RETAIN, PTL_INS_AFTER, &server->me))) { - PDEBUG ("PtlMEAttach", rc); - return pingsrv_shutdown (2); - } - - - if ((rc = PtlEQAlloc (server->ni, 64, pingsrv_callback, - &server->eq))) { - PDEBUG ("PtlEQAlloc (callback)", rc); - return pingsrv_shutdown (2); - } - - PORTAL_ALLOC (server->in_buf, STDSIZE); - if(!server->in_buf){ - CDEBUG (D_OTHER,"Allocation error\n"); - return pingsrv_shutdown(2); - } - - /* Setup the incoming buffer */ - server->mdin.start = server->in_buf; - server->mdin.length = STDSIZE; - server->mdin.threshold = 1; - server->mdin.options = PTL_MD_EVENT_START_DISABLE | PTL_MD_OP_PUT; - server->mdin.user_ptr = NULL; - server->mdin.eq_handle = server->eq; - memset (server->in_buf, 0, STDSIZE); - - if ((rc = PtlMDAttach (server->me, server->mdin, - PTL_UNLINK, &server->mdin_h))) { - PDEBUG ("PtlMDAttach (bulk)", rc); - CDEBUG (D_OTHER, "ping server resources allocated\n"); - } - - /* Success! */ - return server; -} /* pingsrv_setup() */ - -static int pingsrv_start(void) -{ - /* Setup our server */ - if (!pingsrv_setup()) { - CDEBUG (D_OTHER, "pingsrv_setup() failed, server stopped\n"); - return -ENOMEM; - } - kernel_thread (pingsrv_thread,NULL,0); - return 0; -} /* pingsrv_start() */ - - - -static int __init pingsrv_init(void) -{ - PORTAL_ALLOC (server, sizeof(struct pingsrv_data)); - return pingsrv_start (); -} /* pingsrv_init() */ - - -static void /*__exit*/ pingsrv_cleanup(void) -{ - remove_proc_entry ("net/pingsrv", NULL); - - running = 0; - wake_up_process (server->tsk); - while (running != 1) { - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); - } - -} /* pingsrv_cleanup() */ - - -MODULE_PARM(nal, "i"); -MODULE_PARM_DESC(nal, "Use the specified NAL " - "(2-ksocknal, 1-kqswnal)"); - -MODULE_AUTHOR("Brian Behlendorf (LLNL)"); -MODULE_DESCRIPTION("A kernel space ping server for portals testing"); -MODULE_LICENSE("GPL"); - -module_init(pingsrv_init); -module_exit(pingsrv_cleanup); diff --git a/lnet/tests/startclient.sh b/lnet/tests/startclient.sh deleted file mode 100644 index be60509..0000000 --- a/lnet/tests/startclient.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -SIMPLE=${SIMPLE:-0} - -if [ $SIMPLE -eq 0 ]; then - PING=pingcli.o -else - PING=spingcli.o -fi - -case "$1" in - tcp) - /sbin/insmod ../oslib/portals.o - /sbin/insmod ../socknal/ksocknal.o - /sbin/insmod ./$PING - echo ksocknal > /tmp/nal - ;; - - elan) - /sbin/insmod ../oslib/portals.o - /sbin/insmod ../qswnal/kqswnal.o - /sbin/insmod ./$PING - echo kqswnal > /tmp/nal - ;; - - gm) - /sbin/insmod portals - /sbin/insmod kgmnal - /sbin/insmod ./$PING - echo kgmnal > /tmp/nal - ;; - - *) - echo "Usage : ${0} < tcp | elan | gm>" - exit 1; -esac -exit 0; diff --git a/lnet/tests/startserver.sh b/lnet/tests/startserver.sh deleted file mode 100644 index 9b5ccf6..0000000 --- a/lnet/tests/startserver.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -SIMPLE=${SIMPLE:-0} - -if [ $SIMPLE -eq 0 ]; then - PING=pingsrv.o -else - PING=spingsrv.o -fi - -case "$1" in - tcp) - /sbin/insmod ../oslib/portals.o - /sbin/insmod ../socknal/ksocknal.o - /sbin/insmod ./$PING nal=2 - echo ksocknal > /tmp/nal - ;; - - elan) - /sbin/insmod ../oslib/portals.o - /sbin/insmod ../qswnal/kqswnal.o - /sbin/insmod ./$PING nal=4 - echo kqswnal > /tmp/nal - ;; - - gm) - /sbin/insmod portals - /sbin/insmod kgmnal - /sbin/insmod ./$PING nal=3 - echo kgmnal > /tmp/nal - ;; - - *) - echo "Usage : ${0} < tcp | elan | gm>" - exit 1; -esac -../utils/acceptor 9999& -exit 0; diff --git a/lnet/tests/stopclient.sh b/lnet/tests/stopclient.sh deleted file mode 100644 index f7e3aa1..0000000 --- a/lnet/tests/stopclient.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -SIMPLE=${SIMPLE:-1} - -if [ $SIMPLE -eq 0 ]; then - PING=spingcli -else - PING=pingcli -fi - -rmmod $PING -NAL=`cat /tmp/nal`; -rmmod $NAL -rmmod portals diff --git a/lnet/tests/stopserver.sh b/lnet/tests/stopserver.sh deleted file mode 100644 index 3e81831..0000000 --- a/lnet/tests/stopserver.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -SIMPLE=${SIMPLE:-1} - -if [ $SIMPLE -eq 0 ]; then - PING=spingsrv -else - PING=pingsrv -fi - -rmmod $PING -NAL=`cat /tmp/nal`; -rmmod $NAL -killall -9 acceptor -rm -f /var/run/acceptor-9999.pid -rmmod portals diff --git a/lnet/ulnds/.cvsignore b/lnet/ulnds/.cvsignore deleted file mode 100644 index e995588..0000000 --- a/lnet/ulnds/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -.deps -Makefile -Makefile.in diff --git a/lnet/ulnds/Makefile.am b/lnet/ulnds/Makefile.am deleted file mode 100644 index 3437d39..0000000 --- a/lnet/ulnds/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -if LIBLUSTRE -if !CRAY_PORTALS -noinst_LIBRARIES = libtcpnal.a -endif -endif - -noinst_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h -libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h -libtcpnal_a_CPPFLAGS = $(LLCPPFLAGS) -libtcpnal_a_CFLAGS = $(LLCFLAGS) diff --git a/lnet/ulnds/README b/lnet/ulnds/README deleted file mode 100644 index 6cb93d9..0000000 --- a/lnet/ulnds/README +++ /dev/null @@ -1,53 +0,0 @@ -This library implements two NAL interfaces, both running over IP. -The first, tcpnal, creates TCP connections between participating -processes in order to transport the portals requests. The second, -ernal, provides a simple transport protocol which runs over -UDP datagrams. - -The interface functions return both of these values in host order for -convenience and readability. However this means that addresses -exchanged in messages between hosts of different orderings will not -function properly. - -Both NALs use the same support functions in order to schedule events -and communicate with the generic portals implementation. - - ------------------------- - | api | - |_______________________| - | lib | - |_______________________| - | ernal | |tcpnal | - |--------| |----------| - | udpsock| |connection| - |-----------------------| - | timer/select | - ------------------------- - - - These NALs uses the framework from fdnal of a pipe between the api -and library sides. This is wrapped up in the select on the library -side, and blocks on the api side. Performance could be severely -enhanced by collapsing this aritificial barrier, by using shared -memory queues, or by wiring the api layer directly to the library. - - -nid is defined as the low order 24-bits of the IP address of the -physical node left shifted by 8 plus a virtual node number of 0 -through 255 (really only 239). The virtual node number of a tcpnal -application should be specified using the environment variable -PTL_VIRTNODE. pid is now a completely arbitrary number in the -range of 0 to 255. The IP interface used can be overridden by -specifying the appropriate hostid by setting the PTL_HOSTID -environment variable. The value can be either dotted decimal -(n.n.n.n) or hex starting with "0x". -TCPNAL: - As the NAL needs to try to send to a particular nid/pid pair, it - will open up connections on demand. Because the port associated with - the connecting socket is different from the bound port, two - connections will normally be established between a pair of peers, with - data flowing from the anonymous connect (active) port to the advertised - or well-known bound (passive) port of each peer. - - Should the connection fail to open, an error is reported to the - library component, which causes the api request to fail. diff --git a/lnet/ulnds/address.c b/lnet/ulnds/address.c deleted file mode 100644 index f329e2a..0000000 --- a/lnet/ulnds/address.c +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * 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. - */ - -/* address.c: - * this file provides functions to aquire the IP address of the node - * and translate them into a NID/PID pair which supports a static - * mapping of virtual nodes into the port range of an IP socket. -*/ - -#include -#include -#include -#include -#include -#include -#include - - -/* Function: get_node_id - * Returns: a 32 bit id for this node, actually a big-endian IP address - * - * get_node_id() determines the host name and uses the resolver to - * find out its ip address. This is fairly fragile and inflexible, but - * explicitly asking about interfaces and their addresses is very - * complicated and nonportable. - */ -static unsigned int get_node_id(void) -{ - char buffer[255]; - unsigned int x; - struct hostent *he; - char * host_envp; - - if (!(host_envp = getenv("PTL_HOSTID"))) - { - gethostname(buffer,sizeof(buffer)); - he=gethostbyname(buffer); - if (he) - x=*(unsigned int *)he->h_addr_list[0]; - else - x = 0; - return(ntohl(x)); - } - else - { - if (host_envp[1] != 'x') - { - int a, b, c, d; - sscanf(host_envp, "%d.%d.%d.%d", &a, &b, &c, &d); - return ((a<<24) | (b<<16) | (c<<8) | d); - } - else - { - long long hostid = strtoll(host_envp, 0, 0); - return((unsigned int) hostid); - } - } -} - - -/* Function: set_address - * Arugments: t: a procnal structure to populate with the request - * - * set_address performs the bit manipulations to set the nid, pid, and - * iptop8 fields of the procnal structures. - * - * TODO: fix pidrequest to try to do dynamic binding if PTL_ID_ANY - */ - -#ifdef DIRECT_IP_MODE -void set_address(bridge t,ptl_pid_t pidrequest) -{ - int port; - if (pidrequest==(unsigned short)PTL_PID_ANY) port = 0; - else port=pidrequest; - t->lib_nal->libnal_ni.ni_pid.nid=get_node_id(); - t->lib_nal->libnal_ni.ni_pid.pid=port; -} -#else - -void set_address(bridge t,ptl_pid_t pidrequest) -{ - int virtnode, in_addr, port; - ptl_pid_t pid; - - /* get and remember my node id*/ - if (!getenv("PTL_VIRTNODE")) - virtnode = 0; - else - { - int maxvnode = PNAL_VNODE_MASK - (PNAL_BASE_PORT - >> PNAL_VNODE_SHIFT); - virtnode = atoi(getenv("PTL_VIRTNODE")); - if (virtnode > maxvnode) - { - fprintf(stderr, "PTL_VIRTNODE of %d is too large - max %d\n", - virtnode, maxvnode); - return; - } - } - - in_addr = get_node_id(); - - t->iptop8 = in_addr >> PNAL_HOSTID_SHIFT;/* for making new connections */ - t->lib_nal->libnal_ni.ni_pid.nid = ((in_addr & PNAL_HOSTID_MASK) - << PNAL_VNODE_SHIFT) - + virtnode; - pid=pidrequest; - /* TODO: Support of pid PTL_ID_ANY with virtual nodes needs more work. */ -#ifdef notyet - if (pid==(unsigned short)PTL_PID_ANY) port = 0; -#endif - if (pid==(unsigned short)PTL_PID_ANY) - { - fprintf(stderr, "portal pid PTL_ID_ANY is not currently supported\n"); - return; - } - else if (pid > PNAL_PID_MASK) - { - fprintf(stderr, "portal pid of %d is too large - max %d\n", - pid, PNAL_PID_MASK); - return; - } - else port = ((virtnode << PNAL_VNODE_SHIFT) + pid) + PNAL_BASE_PORT; - t->lib_nal->libnal_ni.ni_pid.pid=pid; -} -#endif diff --git a/lnet/ulnds/bridge.h b/lnet/ulnds/bridge.h deleted file mode 100644 index d2f0f2c..0000000 --- a/lnet/ulnds/bridge.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#ifndef TCPNAL_PROCBRIDGE_H -#define TCPNAL_PROCBRIDGE_H - -#include -#include - -#define PTL_IFACE_TCP 1 -#define PTL_IFACE_ER 2 -#define PTL_IFACE_SS 3 -#define PTL_IFACE_MAX 4 - -typedef struct bridge { - int alive; - lib_nal_t *lib_nal; - void *lower; - void *local; - void (*shutdown)(struct bridge *); - /* this doesn't really belong here */ - unsigned char iptop8; -} *bridge; - - -typedef int (*nal_initialize)(bridge); -extern nal_initialize nal_table[PTL_IFACE_MAX]; - -#endif diff --git a/lnet/ulnds/connection.c b/lnet/ulnds/connection.c deleted file mode 100644 index b399fcf..0000000 --- a/lnet/ulnds/connection.c +++ /dev/null @@ -1,508 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * 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. - */ - -/* connection.c: - This file provides a simple stateful connection manager which - builds tcp connections on demand and leaves them open for - future use. It also provides the machinery to allow peers - to connect to it -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif - -/* global variable: acceptor port */ -unsigned short tcpnal_acceptor_port = 988; - - -/* Function: compare_connection - * Arguments: connection c: a connection in the hash table - * ptl_process_id_t: an id to verify agains - * Returns: 1 if the connection is the one requested, 0 otherwise - * - * compare_connection() tests for collisions in the hash table - */ -static int compare_connection(void *arg1, void *arg2) -{ - connection c = arg1; - unsigned int * id = arg2; -#if 0 - return((c->ip==id[0]) && (c->port==id[1])); -#else - /* CFS specific hacking */ - return (c->ip == id[0]); -#endif -} - - -/* Function: connection_key - * Arguments: ptl_process_id_t id: an id to hash - * Returns: a not-particularily-well-distributed hash - * of the id - */ -static unsigned int connection_key(unsigned int *id) -{ -#if 0 - return(id[0]^id[1]); -#else - /* CFS specific hacking */ - return (unsigned int) id[0]; -#endif -} - - -/* Function: remove_connection - * Arguments: c: the connection to remove - */ -void remove_connection(void *arg) -{ - connection c = arg; - unsigned int id[2]; - - id[0]=c->ip; - id[1]=c->port; - hash_table_remove(c->m->connections,id); - close(c->fd); - free(c); -} - - -/* Function: read_connection: - * Arguments: c: the connection to read from - * dest: the buffer to read into - * len: the number of bytes to read - * Returns: success as 1, or failure as 0 - * - * read_connection() reads data from the connection, continuing - * to read partial results until the request is satisfied or - * it errors. TODO: this read should be covered by signal protection. - */ -int read_connection(connection c, - unsigned char *dest, - int len) -{ - int offset = 0,rc; - - if (len) { - do { -#ifndef __CYGWIN__ - rc = syscall(SYS_read, c->fd, dest+offset, len-offset); -#else - rc = recv(c->fd, dest+offset, len-offset, 0); -#endif - if (rc <= 0) { - if (errno == EINTR) { - rc = 0; - } else { - remove_connection(c); - return (0); - } - } - offset += rc; - } while (offset < len); - } - return (1); -} - -static int connection_input(void *d) -{ - connection c = d; - return((*c->m->handler)(c->m->handler_arg,c)); -} - - -/* Function: allocate_connection - * Arguments: t: tcpnal the allocation is occuring in the context of - * dest: portal endpoint address for this connection - * fd: open file descriptor for the socket - * Returns: an allocated connection structure - * - * just encompasses the action common to active and passive - * connections of allocation and placement in the global table - */ -static connection allocate_connection(manager m, - unsigned int ip, - unsigned short port, - int fd) -{ - connection c=malloc(sizeof(struct connection)); - unsigned int id[2]; - c->m=m; - c->fd=fd; - c->ip=ip; - c->port=port; - id[0]=ip; - id[1]=port; - register_io_handler(fd,READ_HANDLER,connection_input,c); - hash_table_insert(m->connections,c,id); - return(c); -} - - -/* Function: new_connection - * Arguments: t: opaque argument holding the tcpname - * Returns: 1 in order to reregister for new connection requests - * - * called when the bound service socket recieves - * a new connection request, it always accepts and - * installs a new connection - */ -static int new_connection(void *z) -{ - manager m=z; - struct sockaddr_in s; - int len=sizeof(struct sockaddr_in); - int fd=accept(m->bound,(struct sockaddr *)&s,&len); - unsigned int nid=*((unsigned int *)&s.sin_addr); - /* cfs specific hack */ - //unsigned short pid=s.sin_port; - pthread_mutex_lock(&m->conn_lock); - allocate_connection(m,htonl(nid),0/*pid*/,fd); - pthread_mutex_unlock(&m->conn_lock); - return(1); -} - -extern ptl_nid_t tcpnal_mynid; - -int -tcpnal_hello (int sockfd, ptl_nid_t *nid, int type, __u64 incarnation) -{ - int rc; - int nob; - ptl_hdr_t hdr; - ptl_magicversion_t *hmv = (ptl_magicversion_t *)&hdr.dest_nid; - - LASSERT (sizeof (*hmv) == sizeof (hdr.dest_nid)); - - memset (&hdr, 0, sizeof (hdr)); - hmv->magic = cpu_to_le32(PORTALS_PROTO_MAGIC); - hmv->version_major = cpu_to_le32(PORTALS_PROTO_VERSION_MAJOR); - hmv->version_minor = cpu_to_le32(PORTALS_PROTO_VERSION_MINOR); - - hdr.src_nid = cpu_to_le64(tcpnal_mynid); - hdr.type = cpu_to_le32(PTL_MSG_HELLO); - - hdr.msg.hello.type = cpu_to_le32(type); - hdr.msg.hello.incarnation = cpu_to_le64(incarnation); - - /* I don't send any interface info */ - - /* Assume sufficient socket buffering for this message */ - rc = syscall(SYS_write, sockfd, &hdr, sizeof(hdr)); - if (rc <= 0) { - CERROR ("Error %d sending HELLO to "LPX64"\n", rc, *nid); - return (rc); - } - - rc = syscall(SYS_read, sockfd, hmv, sizeof(*hmv)); - if (rc <= 0) { - CERROR ("Error %d reading HELLO from "LPX64"\n", rc, *nid); - return (rc); - } - - if (hmv->magic != le32_to_cpu(PORTALS_PROTO_MAGIC)) { - CERROR ("Bad magic %#08x (%#08x expected) from "LPX64"\n", - cpu_to_le32(hmv->magic), PORTALS_PROTO_MAGIC, *nid); - return (-EPROTO); - } - - if (hmv->version_major != cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR) || - hmv->version_minor != cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR)) { - CERROR ("Incompatible protocol version %d.%d (%d.%d expected)" - " from "LPX64"\n", - le16_to_cpu (hmv->version_major), - le16_to_cpu (hmv->version_minor), - PORTALS_PROTO_VERSION_MAJOR, - PORTALS_PROTO_VERSION_MINOR, - *nid); - return (-EPROTO); - } - -#if (PORTALS_PROTO_VERSION_MAJOR != 1) -# error "This code only understands protocol version 1.x" -#endif - /* version 1 sends magic/version as the dest_nid of a 'hello' header, - * so read the rest of it in now... */ - - rc = syscall(SYS_read, sockfd, hmv + 1, sizeof(hdr) - sizeof(*hmv)); - if (rc <= 0) { - CERROR ("Error %d reading rest of HELLO hdr from "LPX64"\n", - rc, *nid); - return (rc); - } - - /* ...and check we got what we expected */ - if (hdr.type != cpu_to_le32 (PTL_MSG_HELLO)) { - CERROR ("Expecting a HELLO hdr " - " but got type %d with %d payload from "LPX64"\n", - le32_to_cpu (hdr.type), - le32_to_cpu (hdr.payload_length), *nid); - return (-EPROTO); - } - - if (le64_to_cpu(hdr.src_nid) == PTL_NID_ANY) { - CERROR("Expecting a HELLO hdr with a NID, but got PTL_NID_ANY\n"); - return (-EPROTO); - } - - if (*nid == PTL_NID_ANY) { /* don't know peer's nid yet */ - *nid = le64_to_cpu(hdr.src_nid); - } else if (*nid != le64_to_cpu (hdr.src_nid)) { - CERROR ("Connected to nid "LPX64", but expecting "LPX64"\n", - le64_to_cpu (hdr.src_nid), *nid); - return (-EPROTO); - } - - /* Ignore any interface info in the payload */ - nob = le32_to_cpu(hdr.payload_length); - if (nob > getpagesize()) { - CERROR("Unexpected HELLO payload %d from "LPX64"\n", - nob, *nid); - return (-EPROTO); - } - if (nob > 0) { - char *space = (char *)malloc(nob); - - if (space == NULL) { - CERROR("Can't allocate scratch buffer %d\n", nob); - return (-ENOMEM); - } - - rc = syscall(SYS_read, sockfd, space, nob); - if (rc <= 0) { - CERROR("Error %d skipping HELLO payload from " - LPX64"\n", rc, *nid); - return (rc); - } - } - - return (0); -} - -/* Function: force_tcp_connection - * Arguments: t: tcpnal - * dest: portals endpoint for the connection - * Returns: an allocated connection structure, either - * a pre-existing one, or a new connection - */ -connection force_tcp_connection(manager m, - unsigned int ip, - unsigned short port, - procbridge pb) -{ - connection conn; - struct sockaddr_in addr; - struct sockaddr_in locaddr; - unsigned int id[2]; - struct timeval tv; - __u64 incarnation; - - int fd; - int option; - int rc; - int rport; - ptl_nid_t peernid = PTL_NID_ANY; - - port = tcpnal_acceptor_port; - - id[0] = ip; - id[1] = port; - - pthread_mutex_lock(&m->conn_lock); - - conn = hash_table_find(m->connections, id); - if (conn) - goto out; - - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = htonl(ip); - addr.sin_port = htons(port); - - memset(&locaddr, 0, sizeof(locaddr)); - locaddr.sin_family = AF_INET; - locaddr.sin_addr.s_addr = INADDR_ANY; - - for (rport = IPPORT_RESERVED - 1; rport > IPPORT_RESERVED / 2; --rport) { - fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) { - perror("tcpnal socket failed"); - goto out; - } - - option = 1; - rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - &option, sizeof(option)); - if (rc != 0) { - perror ("Can't set SO_REUSEADDR for socket"); - close(fd); - goto out; - } - - locaddr.sin_port = htons(rport); - rc = bind(fd, (struct sockaddr *)&locaddr, sizeof(locaddr)); - if (rc == 0 || errno == EACCES) { - rc = connect(fd, (struct sockaddr *)&addr, - sizeof(struct sockaddr_in)); - if (rc == 0) { - break; - } else if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) { - perror("Error connecting to remote host"); - close(fd); - goto out; - } - } else if (errno != EADDRINUSE) { - perror("Error binding to privileged port"); - close(fd); - goto out; - } - close(fd); - } - - if (rport == IPPORT_RESERVED / 2) { - fprintf(stderr, "Out of ports trying to bind to a reserved port\n"); - goto out; - } - -#if 1 - option = 1; - setsockopt(fd, SOL_TCP, TCP_NODELAY, &option, sizeof(option)); - option = 1<<20; - setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &option, sizeof(option)); - option = 1<<20; - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option)); -#endif - - gettimeofday(&tv, NULL); - incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; - - /* say hello */ - if (tcpnal_hello(fd, &peernid, SOCKNAL_CONN_ANY, incarnation)) - exit(-1); - - conn = allocate_connection(m, ip, port, fd); - - /* let nal thread know this event right away */ - if (conn) - procbridge_wakeup_nal(pb); - -out: - pthread_mutex_unlock(&m->conn_lock); - return (conn); -} - - -/* Function: bind_socket - * Arguments: t: the nal state for this interface - * port: the port to attempt to bind to - * Returns: 1 on success, or 0 on error - * - * bind_socket() attempts to allocate and bind a socket to the requested - * port, or dynamically assign one from the kernel should the port be - * zero. Sets the bound and bound_handler elements of m. - * - * TODO: The port should be an explicitly sized type. - */ -static int bind_socket(manager m,unsigned short port) -{ - struct sockaddr_in addr; - int alen=sizeof(struct sockaddr_in); - - if ((m->bound = socket(AF_INET, SOCK_STREAM, 0)) < 0) - return(0); - - bzero((char *) &addr, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = 0; - addr.sin_port = htons(port); - - if (bind(m->bound,(struct sockaddr *)&addr,alen)<0){ - perror ("tcpnal bind"); - return(0); - } - - getsockname(m->bound,(struct sockaddr *)&addr, &alen); - - m->bound_handler=register_io_handler(m->bound,READ_HANDLER, - new_connection,m); - listen(m->bound,5); - m->port=addr.sin_port; - return(1); -} - - -/* Function: shutdown_connections - * Arguments: m: the manager structure - * - * close all connections and reclaim resources - */ -void shutdown_connections(manager m) -{ - close(m->bound); - remove_io_handler(m->bound_handler); - hash_destroy_table(m->connections,remove_connection); - free(m); -} - - -/* Function: init_connections - * Arguments: t: the nal state for this interface - * port: the port to attempt to bind to - * Returns: a newly allocated manager structure, or - * zero if the fixed port could not be bound - */ -manager init_connections(unsigned short pid, - int (*input)(void *, void *), - void *a) -{ - manager m = (manager)malloc(sizeof(struct manager)); - m->connections = hash_create_table(compare_connection,connection_key); - m->handler = input; - m->handler_arg = a; - pthread_mutex_init(&m->conn_lock, 0); - - if (bind_socket(m,pid)) - return(m); - - free(m); - return(0); -} diff --git a/lnet/ulnds/connection.h b/lnet/ulnds/connection.h deleted file mode 100644 index 343ffa6..0000000 --- a/lnet/ulnds/connection.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#include -#include - -typedef struct manager { - table connections; - pthread_mutex_t conn_lock; /* protect connections table */ - int bound; - io_handler bound_handler; - int (*handler)(void *, void *); - void *handler_arg; - unsigned short port; -} *manager; - - -typedef struct connection { - unsigned int ip; - unsigned short port; - int fd; - manager m; -} *connection; - -connection force_tcp_connection(manager m, unsigned int ip, unsigned int short, - procbridge pb); -manager init_connections(unsigned short, int (*f)(void *, void *), void *); -void remove_connection(void *arg); -void shutdown_connections(manager m); -int read_connection(connection c, unsigned char *dest, int len); diff --git a/lnet/ulnds/debug.c b/lnet/ulnds/debug.c deleted file mode 100644 index b82bb2f..0000000 --- a/lnet/ulnds/debug.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * Author: Phil Schwan - * - * 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. - */ - -#include -#include -#include -#include -#include - -int smp_processor_id = 1; -char debug_file_path[1024] = "/tmp/lustre-log"; -char debug_file_name[1024]; -FILE *debug_file_fd; - -int portals_do_debug_dumplog(void *arg) -{ - printf("Look in %s\n", debug_file_name); - return 0; -} - - -void portals_debug_print(void) -{ - return; -} - - -void portals_debug_dumplog(void) -{ - printf("Look in %s\n", debug_file_name); - return; -} - - -int portals_debug_init(unsigned long bufsize) -{ - debug_file_fd = stdout; - return 0; -} - -int portals_debug_cleanup(void) -{ - return 0; //close(portals_debug_fd); -} - -int portals_debug_clear_buffer(void) -{ - return 0; -} - -int portals_debug_mark_buffer(char *text) -{ - - fprintf(debug_file_fd, "*******************************************************************************\n"); - fprintf(debug_file_fd, "DEBUG MARKER: %s\n", text); - fprintf(debug_file_fd, "*******************************************************************************\n"); - - return 0; -} - -int portals_debug_copy_to_user(char *buf, unsigned long len) -{ - return 0; -} - -/* FIXME: I'm not very smart; someone smarter should make this better. */ -void -portals_debug_msg (int subsys, int mask, char *file, const char *fn, - const int line, const char *format, ...) -{ - va_list ap; - unsigned long flags; - struct timeval tv; - int nob; - - - /* NB since we pass a non-zero sized buffer (at least) on the first - * print, we can be assured that by the end of all the snprinting, - * we _do_ have a terminated buffer, even if our message got truncated. - */ - - gettimeofday(&tv, NULL); - - nob += fprintf(debug_file_fd, - "%02x:%06x:%d:%lu.%06lu ", - subsys >> 24, mask, smp_processor_id, - tv.tv_sec, tv.tv_usec); - - nob += fprintf(debug_file_fd, - "(%s:%d:%s() %d+%ld): ", - file, line, fn, 0, - 8192 - ((unsigned long)&flags & 8191UL)); - - va_start (ap, format); - nob += fprintf(debug_file_fd, format, ap); - va_end (ap); - - -} - diff --git a/lnet/ulnds/dispatch.h b/lnet/ulnds/dispatch.h deleted file mode 100644 index a8f916d9..0000000 --- a/lnet/ulnds/dispatch.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -/* this file is only called dispatch.h to prevent it - from colliding with /usr/include/sys/select.h */ - -typedef struct io_handler *io_handler; - -struct io_handler{ - io_handler *last; - io_handler next; - int fd; - int type; - int (*function)(void *); - void *argument; - int disabled; -}; - - -#define READ_HANDLER 1 -#define WRITE_HANDLER 2 -#define EXCEPTION_HANDLER 4 -#define ALL_HANDLER (READ_HANDLER | WRITE_HANDLER | EXCEPTION_HANDLER) - -io_handler register_io_handler(int fd, - int type, - int (*function)(void *), - void *arg); - -void remove_io_handler (io_handler i); -void init_unix_timer(void); -void select_timer_block(when until); -when now(void); - -/* - * hacking for CFS internal MPI testing - */ -#if !CRAY_PORTALS -#define ENABLE_SELECT_DISPATCH -#endif diff --git a/lnet/ulnds/ipmap.h b/lnet/ulnds/ipmap.h deleted file mode 100644 index 85b1e18..0000000 --- a/lnet/ulnds/ipmap.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#define DIRECT_IP_MODE -#ifdef DIRECT_IP_MODE -#define PNAL_NID(in_addr, port) (in_addr) -#define PNAL_PID(pid) (pid) -#define PNAL_IP(in_addr, port) (in_addr) -#define PNAL_PORT(nid, pid) (pid) -#else - -#define PNAL_BASE_PORT 4096 -#define PNAL_HOSTID_SHIFT 24 -#define PNAL_HOSTID_MASK ((1 << PNAL_HOSTID_SHIFT) - 1) -#define PNAL_VNODE_SHIFT 8 -#define PNAL_VNODE_MASK ((1 << PNAL_VNODE_SHIFT) - 1) -#define PNAL_PID_SHIFT 8 -#define PNAL_PID_MASK ((1 << PNAL_PID_SHIFT) - 1) - -#define PNAL_NID(in_addr, port) (((ntohl(in_addr) & PNAL_HOSTID_MASK) \ - << PNAL_VNODE_SHIFT) \ - | (((ntohs(port)-PNAL_BASE_PORT) >>\ - PNAL_PID_SHIFT))) -#define PNAL_PID(port) ((ntohs(port) - PNAL_BASE_PORT) & PNAL_PID_MASK) - -#define PNAL_IP(nid,t) (htonl((((unsigned)(nid))\ - >> PNAL_VNODE_SHIFT)\ - | (t->iptop8 << PNAL_HOSTID_SHIFT))) -#define PNAL_PORT(nid, pid) (htons(((((nid) & PNAL_VNODE_MASK) \ - << PNAL_VNODE_SHIFT) \ - | ((pid) & PNAL_PID_MASK)) \ - + PNAL_BASE_PORT)) -#endif diff --git a/lnet/ulnds/pqtimer.c b/lnet/ulnds/pqtimer.c deleted file mode 100644 index 98c48eb..0000000 --- a/lnet/ulnds/pqtimer.c +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * 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. - */ - -/* timer.c: - * this file implements a simple priority-queue based timer system. when - * combined with a file which implements now() and block(), it can - * be used to provide course-grained time-based callbacks. - */ - -#include -#include -#include - -struct timer { - void (*function)(void *); - void *arg; - when w; - int interval; - int disable; -}; - -typedef struct thunk *thunk; -struct thunk { - void (*f)(void *); - void *a; - thunk next; -}; - -extern when now(void); - -static thunk thunks; -static int internal; -static void (*block_function)(when); -static int number_of_timers; -static int size_of_pqueue; -static timer *timers; - - -static void heal(int where) -{ - int left=(where<<1); - int right=(where<<1)+1; - int min=where; - timer temp; - - if (left <= number_of_timers) - if (timers[left]->w < timers[min]->w) min=left; - if (right <= number_of_timers) - if (timers[right]->w < timers[min]->w) min=right; - if (min != where){ - temp=timers[where]; - timers[where]=timers[min]; - timers[min]=temp; - heal(min); - } -} - -static void add_pqueue(int i) -{ - timer temp; - int parent=(i>>1); - if ((i>1) && (timers[i]->w< timers[parent]->w)){ - temp=timers[i]; - timers[i]=timers[parent]; - timers[parent]=temp; - add_pqueue(parent); - } -} - -static void add_timer(timer t) -{ - if (size_of_pqueue<(number_of_timers+2)){ - int oldsize=size_of_pqueue; - timer *new=(void *)malloc(sizeof(struct timer)*(size_of_pqueue+=10)); - memcpy(new,timers,sizeof(timer)*oldsize); - timers=new; - } - timers[++number_of_timers]=t; - add_pqueue(number_of_timers); -} - -/* Function: register_timer - * Arguments: interval: the time interval from the current time when - * the timer function should be called - * function: the function to call when the time has expired - * argument: the argument to call it with. - * Returns: a pointer to a timer structure - */ -timer register_timer(when interval, - void (*function)(void *), - void *argument) -{ - timer t=(timer)malloc(sizeof(struct timer)); - - t->arg=argument; - t->function=function; - t->interval=interval; - t->disable=0; - t->w=now()+interval; - add_timer(t); - if (!internal && (number_of_timers==1)) - block_function(t->w); - return(t); -} - -/* Function: remove_timer - * Arguments: t: - * Returns: nothing - * - * remove_timer removes a timer from the system, insuring - * that it will never be called. It does not actually - * free the timer due to reentrancy issues. - */ - -void remove_timer(timer t) -{ - t->disable=1; -} - - - -void timer_fire() -{ - timer current; - - current=timers[1]; - timers[1]=timers[number_of_timers--]; - heal(1); - if (!current->disable) { - (*current->function)(current->arg); - } - free(current); -} - -when next_timer(void) -{ - when here=now(); - - while (number_of_timers && (timers[1]->w <= here)) timer_fire(); - if (number_of_timers) return(timers[1]->w); - return(0); -} - -/* Function: timer_loop - * Arguments: none - * Returns: never - * - * timer_loop() is the blocking dispatch function for the timer. - * Is calls the block() function registered with init_timer, - * and handles associated with timers that have been registered. - */ -void timer_loop() -{ - when here; - - while (1){ - thunk z; - here=now(); - - for (z=thunks;z;z=z->next) (*z->f)(z->a); - - if (number_of_timers){ - if (timers[1]->w > here){ - (*block_function)(timers[1]->w); - } else { - timer_fire(); - } - } else { - thunk z; - for (z=thunks;z;z=z->next) (*z->f)(z->a); - (*block_function)(0); - } - } -} - - -/* Function: register_thunk - * Arguments: f: the function to call - * a: the single argument to call it with - * - * Thunk functions get called at irregular intervals, they - * should not assume when, or take a particularily long - * amount of time. Thunks are for background cleanup tasks. - */ -void register_thunk(void (*f)(void *),void *a) -{ - thunk t=(void *)malloc(sizeof(struct thunk)); - t->f=f; - t->a=a; - t->next=thunks; - thunks=t; -} - -/* Function: initialize_timer - * Arguments: block: the function to call to block for the specified interval - * - * initialize_timer() must be called before any other timer function, - * including timer_loop. - */ -void initialize_timer(void (*block)(when)) -{ - block_function=block; - number_of_timers=0; - size_of_pqueue=10; - timers=(timer *)malloc(sizeof(timer)*size_of_pqueue); - thunks=0; -} diff --git a/lnet/ulnds/pqtimer.h b/lnet/ulnds/pqtimer.h deleted file mode 100644 index 11efb0e..0000000 --- a/lnet/ulnds/pqtimer.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -typedef unsigned long long when; -when now(void); -typedef struct timer *timer; -timer register_timer(when interval, - void (*function)(void *), - void *argument); -timer register_timer_wait(void); -void remove_timer(timer); -void timer_loop(void); -void initialize_timer(void (*block)(when)); -void timer_fire(void); - - -#define HZ 0x100000000ull - - diff --git a/lnet/ulnds/procapi.c b/lnet/ulnds/procapi.c deleted file mode 100644 index 6b471c0..0000000 --- a/lnet/ulnds/procapi.c +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * 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. - */ - -/* api.c: - * This file provides the 'api' side for the process-based nals. - * it is responsible for creating the 'library' side thread, - * and passing wrapped portals transactions to it. - * - * Along with initialization, shutdown, and transport to the library - * side, this file contains some stubs to satisfy the nal definition. - */ -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif -#include -#include -#include -#include -#include - - -/* XXX CFS workaround, to give a chance to let nal thread wake up - * from waiting in select - */ -static int procbridge_notifier_handler(void *arg) -{ - static char buf[8]; - procbridge p = (procbridge) arg; - - syscall(SYS_read, p->notifier[1], buf, sizeof(buf)); - return 1; -} - -void procbridge_wakeup_nal(procbridge p) -{ - static char buf[8]; - syscall(SYS_write, p->notifier[0], buf, sizeof(buf)); -} - -/* Function: shutdown - * Arguments: nal: a pointer to my top side nal structure - * ni: my network interface index - * - * cleanup nal state, reclaim the lower side thread and - * its state using PTL_FINI codepoint - */ -static void procbridge_shutdown(nal_t *n) -{ - lib_nal_t *nal = n->nal_data; - bridge b=(bridge)nal->libnal_data; - procbridge p=(procbridge)b->local; - - p->nal_flags |= NAL_FLAG_STOPPING; - procbridge_wakeup_nal(p); - - do { - pthread_mutex_lock(&p->mutex); - if (p->nal_flags & NAL_FLAG_STOPPED) { - pthread_mutex_unlock(&p->mutex); - break; - } - pthread_cond_wait(&p->cond, &p->mutex); - pthread_mutex_unlock(&p->mutex); - } while (1); - - free(p); -} - - -/* forward decl */ -extern int procbridge_startup (nal_t *, ptl_pid_t, - ptl_ni_limits_t *, ptl_ni_limits_t *); - -/* api_nal - * the interface vector to allow the generic code to access - * this nal. this is seperate from the library side lib_nal. - * TODO: should be dyanmically allocated - */ -nal_t procapi_nal = { - nal_data: NULL, - nal_ni_init: procbridge_startup, - nal_ni_fini: procbridge_shutdown, -}; - -ptl_nid_t tcpnal_mynid; - -#ifdef ENABLE_SELECT_DISPATCH -procbridge __global_procbridge = NULL; -#endif - -/* Function: procbridge_startup - * - * Arguments: pid: requested process id (port offset) - * PTL_ID_ANY not supported. - * desired: limits passed from the application - * and effectively ignored - * actual: limits actually allocated and returned - * - * Returns: portals rc - * - * initializes the tcp nal. we define unix_failure as an - * error wrapper to cut down clutter. - */ -int procbridge_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - nal_init_args_t args; - - procbridge p; - bridge b; - /* XXX nal_type is purely private to tcpnal here */ - int nal_type = PTL_IFACE_TCP;/* PTL_IFACE_DEFAULT FIXME hack */ - - LASSERT(nal == &procapi_nal); - - init_unix_timer(); - - b=(bridge)malloc(sizeof(struct bridge)); - p=(procbridge)malloc(sizeof(struct procbridge)); - b->local=p; - - args.nia_requested_pid = requested_pid; - args.nia_requested_limits = requested_limits; - args.nia_actual_limits = actual_limits; - args.nia_nal_type = nal_type; - args.nia_bridge = b; - args.nia_apinal = nal; - - /* init procbridge */ - pthread_mutex_init(&p->mutex,0); - pthread_cond_init(&p->cond, 0); - p->nal_flags = 0; - - /* initialize notifier */ - if (socketpair(AF_UNIX, SOCK_STREAM, 0, p->notifier)) { - perror("socketpair failed"); - return PTL_FAIL; - } - - if (!register_io_handler(p->notifier[1], READ_HANDLER, - procbridge_notifier_handler, p)) { - perror("fail to register notifier handler"); - return PTL_FAIL; - } - -#ifdef ENABLE_SELECT_DISPATCH - __global_procbridge = p; -#endif - - /* create nal thread */ - if (pthread_create(&p->t, NULL, nal_thread, &args)) { - perror("nal_init: pthread_create"); - return PTL_FAIL; - } - - do { - pthread_mutex_lock(&p->mutex); - if (p->nal_flags & (NAL_FLAG_RUNNING | NAL_FLAG_STOPPED)) { - pthread_mutex_unlock(&p->mutex); - break; - } - pthread_cond_wait(&p->cond, &p->mutex); - pthread_mutex_unlock(&p->mutex); - } while (1); - - if (p->nal_flags & NAL_FLAG_STOPPED) - return PTL_FAIL; - - b->lib_nal->libnal_ni.ni_pid.nid = tcpnal_mynid; - - return PTL_OK; -} diff --git a/lnet/ulnds/procbridge.h b/lnet/ulnds/procbridge.h deleted file mode 100644 index 1f91ced..0000000 --- a/lnet/ulnds/procbridge.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#ifndef _PROCBRIDGE_H_ -#define _PROCBRIDGE_H_ - -#include -#include -#include - - -#define NAL_FLAG_RUNNING 1 -#define NAL_FLAG_STOPPING 2 -#define NAL_FLAG_STOPPED 4 - -typedef struct procbridge { - /* sync between user threads and nal thread */ - pthread_t t; - pthread_cond_t cond; - pthread_mutex_t mutex; - - /* socket pair used to notify nal thread */ - int notifier[2]; - - int nal_flags; - -} *procbridge; - -typedef struct nal_init_args { - ptl_pid_t nia_requested_pid; - ptl_ni_limits_t *nia_requested_limits; - ptl_ni_limits_t *nia_actual_limits; - int nia_nal_type; - bridge nia_bridge; - nal_t *nia_apinal; -} nal_init_args_t; - -extern void *nal_thread(void *); - - -#define PTL_INIT (LIB_MAX_DISPATCH+1) -#define PTL_FINI (LIB_MAX_DISPATCH+2) - -#define MAX_ACLS 1 -#define MAX_PTLS 128 - -extern void set_address(bridge t,ptl_pid_t pidrequest); -extern void procbridge_wakeup_nal(procbridge p); - -#endif diff --git a/lnet/ulnds/proclib.c b/lnet/ulnds/proclib.c deleted file mode 100644 index 7ee7c71..0000000 --- a/lnet/ulnds/proclib.c +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * 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. - */ - -/* lib.c: - * This file provides the 'library' side for the process-based nals. - * it is responsible for communication with the 'api' side and - * providing service to the generic portals 'library' - * implementation. 'library' might be better termed 'communication' - * or 'kernel'. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* the following functions are stubs to satisfy the nal definition - without doing anything particularily useful*/ - -static int nal_dist(lib_nal_t *nal, - ptl_nid_t nid, - unsigned long *dist) -{ - return 0; -} - -static void check_stopping(void *z) -{ - bridge b = z; - procbridge p = b->local; - - if ((p->nal_flags & NAL_FLAG_STOPPING) == 0) - return; - - pthread_mutex_lock(&p->mutex); - p->nal_flags |= NAL_FLAG_STOPPED; - pthread_cond_broadcast(&p->cond); - pthread_mutex_unlock(&p->mutex); - - pthread_exit(0); -} - - -/* Function: nal_thread - * Arguments: z: an opaque reference to a nal control structure - * allocated and partially populated by the api level code - * Returns: nothing, and only on error or explicit shutdown - * - * This function is the entry point of the pthread initiated on - * the api side of the interface. This thread is used to handle - * asynchronous delivery to the application. - * - * We define a limit macro to place a ceiling on limits - * for syntactic convenience - */ -extern int tcpnal_init(bridge); - -nal_initialize nal_table[PTL_IFACE_MAX]={0,tcpnal_init,0}; - -void *nal_thread(void *z) -{ - nal_init_args_t *args = (nal_init_args_t *) z; - bridge b = args->nia_bridge; - procbridge p=b->local; - int rc; - ptl_process_id_t process_id; - int nal_type; - - b->lib_nal=(lib_nal_t *)malloc(sizeof(lib_nal_t)); - b->lib_nal->libnal_data=b; - b->lib_nal->libnal_map=NULL; - b->lib_nal->libnal_unmap=NULL; - b->lib_nal->libnal_dist=nal_dist; - - nal_type = args->nia_nal_type; - - /* Wierd, but this sets b->lib_nal->libnal_ni.ni_pid.{nid,pid}, which - * lib_init() is about to do from the process_id passed to it...*/ - set_address(b,args->nia_requested_pid); - - process_id = b->lib_nal->libnal_ni.ni_pid; - - if (nal_table[nal_type]) rc=(*nal_table[nal_type])(b); - /* initialize the generic 'library' level code */ - - rc = lib_init(b->lib_nal, args->nia_apinal, - process_id, - args->nia_requested_limits, - args->nia_actual_limits); - - /* - * Whatever the initialization returned is passed back to the - * user level code for further interpretation. We just exit if - * it is non-zero since something went wrong. - */ - /* this should perform error checking */ - pthread_mutex_lock(&p->mutex); - p->nal_flags |= (rc != PTL_OK) ? NAL_FLAG_STOPPED : NAL_FLAG_RUNNING; - pthread_cond_broadcast(&p->cond); - pthread_mutex_unlock(&p->mutex); - - if (rc == PTL_OK) { - /* the thunk function is called each time the timer loop - performs an operation and returns to blocking mode. we - overload this function to inform the api side that - it may be interested in looking at the event queue */ - register_thunk(check_stopping,b); - timer_loop(); - } - return(0); -} diff --git a/lnet/ulnds/select.c b/lnet/ulnds/select.c deleted file mode 100644 index 09e1542..0000000 --- a/lnet/ulnds/select.c +++ /dev/null @@ -1,419 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * 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. - */ - -/* select.c: - * Provides a general mechanism for registering and dispatching - * io events through the select system call. - */ - -#ifdef sun -#include -#else -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -static struct timeval beginning_of_epoch; -static io_handler io_handlers; - -/* Function: now - * - * Return: the current time in canonical units: a 64 bit number - * where the most significant 32 bits contains the number - * of seconds, and the least signficant a count of (1/(2^32))ths - * of a second. - */ -when now() -{ - struct timeval result; - - gettimeofday(&result,0); - return((((unsigned long long)result.tv_sec)<<32)| - (((unsigned long long)result.tv_usec)<<32)/1000000); -} - - -/* Function: register_io_handler - * Arguments: fd: the file descriptor of interest - * type: a mask of READ_HANDLER, WRITE_HANDLER, EXCEPTION_HANDLER - * function: a function to call when io is available on fd - * arg: an opaque correlator to return to the handler - * Returns: a pointer to the io_handler structure - */ -io_handler register_io_handler(int fd, - int type, - int (*function)(void *), - void *arg) -{ - io_handler i=(io_handler)malloc(sizeof(struct io_handler)); - if ((i->fd=fd)>=0){ - i->type=type; - i->function=function; - i->argument=arg; - i->disabled=0; - i->last=&io_handlers; - if ((i->next=io_handlers)) i->next->last=&i->next; - io_handlers=i; - } - return(i); -} - -/* Function: remove_io_handler - * Arguments: i: a pointer to the handler to stop servicing - * - * remove_io_handler() doesn't actually free the handler, due - * to reentrancy problems. it just marks the handler for - * later cleanup by the blocking function. - */ -void remove_io_handler (io_handler i) -{ - i->disabled=1; -} - -static void set_flag(io_handler n,fd_set *r, fd_set *w, fd_set *e) -{ - if (n->type & READ_HANDLER) FD_SET(n->fd, r); - if (n->type & WRITE_HANDLER) FD_SET(n->fd, w); - if (n->type & EXCEPTION_HANDLER) FD_SET(n->fd, e); -} - -static int prepare_fd_sets(fd_set *r, fd_set *w, fd_set *e) -{ - io_handler j; - io_handler *k; - int max = 0; - - FD_ZERO(r); - FD_ZERO(w); - FD_ZERO(e); - for (k=&io_handlers;*k;){ - if ((*k)->disabled){ - j=*k; - *k=(*k)->next; - free(j); - } - if (*k) { - set_flag(*k,r,w,e); - if ((*k)->fd > max) - max = (*k)->fd; - k=&(*k)->next; - } - } - return max + 1; -} - -static int execute_callbacks(fd_set *r, fd_set *w, fd_set *e) -{ - io_handler j; - int n = 0, t; - - for (j = io_handlers; j; j = j->next) { - if (j->disabled) - continue; - - t = 0; - if (FD_ISSET(j->fd, r) && (j->type & READ_HANDLER)) { - FD_CLR(j->fd, r); - t++; - } - if (FD_ISSET(j->fd, w) && (j->type & WRITE_HANDLER)) { - FD_CLR(j->fd, w); - t++; - } - if (FD_ISSET(j->fd, e) && (j->type & EXCEPTION_HANDLER)) { - FD_CLR(j->fd, e); - t++; - } - if (t == 0) - continue; - - if (!(*j->function)(j->argument)) - j->disabled = 1; - - n += t; - } - - return n; -} - -#ifdef ENABLE_SELECT_DISPATCH - -static struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - int submitted; - int nready; - int maxfd; - fd_set *rset; - fd_set *wset; - fd_set *eset; - struct timeval *timeout; - struct timeval submit_time; -} fd_extra = { - PTHREAD_MUTEX_INITIALIZER, - PTHREAD_COND_INITIALIZER, - 0, 0, 0, - NULL, NULL, NULL, NULL, -}; - -extern int liblustre_wait_event(int timeout); -extern procbridge __global_procbridge; - -/* - * this will intercept syscall select() of user apps - * such as MPI libs. - */ -int select(int n, fd_set *rset, fd_set *wset, fd_set *eset, - struct timeval *timeout) -{ - LASSERT(fd_extra.submitted == 0); - - fd_extra.nready = 0; - fd_extra.maxfd = n; - fd_extra.rset = rset; - fd_extra.wset = wset; - fd_extra.eset = eset; - fd_extra.timeout = timeout; - - liblustre_wait_event(0); - pthread_mutex_lock(&fd_extra.mutex); - gettimeofday(&fd_extra.submit_time, NULL); - fd_extra.submitted = 1; - LASSERT(__global_procbridge); - procbridge_wakeup_nal(__global_procbridge); - -again: - if (fd_extra.submitted) - pthread_cond_wait(&fd_extra.cond, &fd_extra.mutex); - pthread_mutex_unlock(&fd_extra.mutex); - - liblustre_wait_event(0); - - pthread_mutex_lock(&fd_extra.mutex); - if (fd_extra.submitted) - goto again; - pthread_mutex_unlock(&fd_extra.mutex); - - LASSERT(fd_extra.nready >= 0); - LASSERT(fd_extra.submitted == 0); - return fd_extra.nready; -} - -static int merge_fds(int max, fd_set *rset, fd_set *wset, fd_set *eset) -{ - int i; - - LASSERT(rset); - LASSERT(wset); - LASSERT(eset); - - for (i = 0; i < __FD_SETSIZE/__NFDBITS; i++) { - LASSERT(!fd_extra.rset || - !(__FDS_BITS(rset)[i] & __FDS_BITS(fd_extra.rset)[i])); - LASSERT(!fd_extra.wset || - !(__FDS_BITS(wset)[i] & __FDS_BITS(fd_extra.wset)[i])); - LASSERT(!fd_extra.eset || - !(__FDS_BITS(eset)[i] & __FDS_BITS(fd_extra.eset)[i])); - - if (fd_extra.rset && __FDS_BITS(fd_extra.rset)[i]) - __FDS_BITS(rset)[i] |= __FDS_BITS(fd_extra.rset)[i]; - if (fd_extra.wset && __FDS_BITS(fd_extra.wset)[i]) - __FDS_BITS(wset)[i] |= __FDS_BITS(fd_extra.wset)[i]; - if (fd_extra.eset && __FDS_BITS(fd_extra.eset)[i]) - __FDS_BITS(eset)[i] |= __FDS_BITS(fd_extra.eset)[i]; - } - - return (fd_extra.maxfd > max ? fd_extra.maxfd : max); -} - -static inline -int timeval_ge(struct timeval *tv1, struct timeval *tv2) -{ - LASSERT(tv1 && tv2); - return ((tv1->tv_sec - tv2->tv_sec) * 1000000 + - (tv1->tv_usec - tv2->tv_usec) >= 0); -} - -/* - * choose the most recent timeout value - */ -static struct timeval *choose_timeout(struct timeval *tv1, - struct timeval *tv2) -{ - if (!tv1) - return tv2; - else if (!tv2) - return tv1; - - if (timeval_ge(tv1, tv2)) - return tv2; - else - return tv1; -} - -/* Function: select_timer_block - * Arguments: until: an absolute time when the select should return - * - * This function dispatches the various file descriptors' handler - * functions, if the kernel indicates there is io available. - */ -void select_timer_block(when until) -{ - fd_set fds[3]; - struct timeval timeout; - struct timeval *timeout_pointer, *select_timeout; - int max, nready, nexec; - int fd_handling; - -again: - if (until) { - when interval; - - interval = until - now(); - timeout.tv_sec = (interval >> 32); - timeout.tv_usec = ((interval << 32) / 1000000) >> 32; - timeout_pointer = &timeout; - } else - timeout_pointer = NULL; - - fd_handling = 0; - max = prepare_fd_sets(&fds[0], &fds[1], &fds[2]); - select_timeout = timeout_pointer; - - pthread_mutex_lock(&fd_extra.mutex); - fd_handling = fd_extra.submitted; - pthread_mutex_unlock(&fd_extra.mutex); - if (fd_handling) { - max = merge_fds(max, &fds[0], &fds[1], &fds[2]); - select_timeout = choose_timeout(timeout_pointer, fd_extra.timeout); - } - - /* XXX only compile for linux */ -#if __WORDSIZE == 64 - nready = syscall(SYS_select, max, &fds[0], &fds[1], &fds[2], - select_timeout); -#else - nready = syscall(SYS__newselect, max, &fds[0], &fds[1], &fds[2], - select_timeout); -#endif - if (nready < 0) { - CERROR("select return err %d, errno %d\n", nready, errno); - return; - } - - if (nready) { - nexec = execute_callbacks(&fds[0], &fds[1], &fds[2]); - nready -= nexec; - } else - nexec = 0; - - /* even both nready & nexec are 0, we still need try to wakeup - * upper thread since it may have timed out - */ - if (fd_handling) { - LASSERT(nready >= 0); - - pthread_mutex_lock(&fd_extra.mutex); - if (nready) { - if (fd_extra.rset) - *fd_extra.rset = fds[0]; - if (fd_extra.wset) - *fd_extra.wset = fds[1]; - if (fd_extra.eset) - *fd_extra.eset = fds[2]; - fd_extra.nready = nready; - fd_extra.submitted = 0; - } else { - struct timeval t; - - fd_extra.nready = 0; - if (fd_extra.timeout) { - gettimeofday(&t, NULL); - if (timeval_ge(&t, &fd_extra.submit_time)) - fd_extra.submitted = 0; - } - } - - pthread_cond_signal(&fd_extra.cond); - pthread_mutex_unlock(&fd_extra.mutex); - } - - /* haven't found portals event, go back to loop if time - * is not expired */ - if (!nexec) { - if (timeout_pointer == NULL || now() >= until) - goto again; - } -} - -#else /* !ENABLE_SELECT_DISPATCH */ - -/* Function: select_timer_block - * Arguments: until: an absolute time when the select should return - * - * This function dispatches the various file descriptors' handler - * functions, if the kernel indicates there is io available. - */ -void select_timer_block(when until) -{ - fd_set fds[3]; - struct timeval timeout; - struct timeval *timeout_pointer; - int max, nready; - -again: - if (until) { - when interval; - interval = until - now(); - timeout.tv_sec = (interval >> 32); - timeout.tv_usec = ((interval << 32) / 1000000) >> 32; - timeout_pointer = &timeout; - } else - timeout_pointer = NULL; - - max = prepare_fd_sets(&fds[0], &fds[1], &fds[2]); - - nready = select(max, &fds[0], &fds[1], &fds[2], timeout_pointer); - if (nready > 0) - execute_callbacks(&fds[0], &fds[1], &fds[2]); -} -#endif /* ENABLE_SELECT_DISPATCH */ - -/* Function: init_unix_timer() - * is called to initialize the library - */ -void init_unix_timer() -{ - io_handlers=0; - gettimeofday(&beginning_of_epoch, 0); - initialize_timer(select_timer_block); -} diff --git a/lnet/ulnds/socklnd/Makefile.am b/lnet/ulnds/socklnd/Makefile.am deleted file mode 100644 index 3437d39..0000000 --- a/lnet/ulnds/socklnd/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -if LIBLUSTRE -if !CRAY_PORTALS -noinst_LIBRARIES = libtcpnal.a -endif -endif - -noinst_HEADERS = pqtimer.h dispatch.h table.h timer.h connection.h ipmap.h bridge.h procbridge.h -libtcpnal_a_SOURCES = debug.c pqtimer.c select.c table.c pqtimer.h dispatch.h table.h timer.h address.c procapi.c proclib.c connection.c tcpnal.c connection.h -libtcpnal_a_CPPFLAGS = $(LLCPPFLAGS) -libtcpnal_a_CFLAGS = $(LLCFLAGS) diff --git a/lnet/ulnds/socklnd/README b/lnet/ulnds/socklnd/README deleted file mode 100644 index 6cb93d9..0000000 --- a/lnet/ulnds/socklnd/README +++ /dev/null @@ -1,53 +0,0 @@ -This library implements two NAL interfaces, both running over IP. -The first, tcpnal, creates TCP connections between participating -processes in order to transport the portals requests. The second, -ernal, provides a simple transport protocol which runs over -UDP datagrams. - -The interface functions return both of these values in host order for -convenience and readability. However this means that addresses -exchanged in messages between hosts of different orderings will not -function properly. - -Both NALs use the same support functions in order to schedule events -and communicate with the generic portals implementation. - - ------------------------- - | api | - |_______________________| - | lib | - |_______________________| - | ernal | |tcpnal | - |--------| |----------| - | udpsock| |connection| - |-----------------------| - | timer/select | - ------------------------- - - - These NALs uses the framework from fdnal of a pipe between the api -and library sides. This is wrapped up in the select on the library -side, and blocks on the api side. Performance could be severely -enhanced by collapsing this aritificial barrier, by using shared -memory queues, or by wiring the api layer directly to the library. - - -nid is defined as the low order 24-bits of the IP address of the -physical node left shifted by 8 plus a virtual node number of 0 -through 255 (really only 239). The virtual node number of a tcpnal -application should be specified using the environment variable -PTL_VIRTNODE. pid is now a completely arbitrary number in the -range of 0 to 255. The IP interface used can be overridden by -specifying the appropriate hostid by setting the PTL_HOSTID -environment variable. The value can be either dotted decimal -(n.n.n.n) or hex starting with "0x". -TCPNAL: - As the NAL needs to try to send to a particular nid/pid pair, it - will open up connections on demand. Because the port associated with - the connecting socket is different from the bound port, two - connections will normally be established between a pair of peers, with - data flowing from the anonymous connect (active) port to the advertised - or well-known bound (passive) port of each peer. - - Should the connection fail to open, an error is reported to the - library component, which causes the api request to fail. diff --git a/lnet/ulnds/socklnd/address.c b/lnet/ulnds/socklnd/address.c deleted file mode 100644 index f329e2a..0000000 --- a/lnet/ulnds/socklnd/address.c +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * 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. - */ - -/* address.c: - * this file provides functions to aquire the IP address of the node - * and translate them into a NID/PID pair which supports a static - * mapping of virtual nodes into the port range of an IP socket. -*/ - -#include -#include -#include -#include -#include -#include -#include - - -/* Function: get_node_id - * Returns: a 32 bit id for this node, actually a big-endian IP address - * - * get_node_id() determines the host name and uses the resolver to - * find out its ip address. This is fairly fragile and inflexible, but - * explicitly asking about interfaces and their addresses is very - * complicated and nonportable. - */ -static unsigned int get_node_id(void) -{ - char buffer[255]; - unsigned int x; - struct hostent *he; - char * host_envp; - - if (!(host_envp = getenv("PTL_HOSTID"))) - { - gethostname(buffer,sizeof(buffer)); - he=gethostbyname(buffer); - if (he) - x=*(unsigned int *)he->h_addr_list[0]; - else - x = 0; - return(ntohl(x)); - } - else - { - if (host_envp[1] != 'x') - { - int a, b, c, d; - sscanf(host_envp, "%d.%d.%d.%d", &a, &b, &c, &d); - return ((a<<24) | (b<<16) | (c<<8) | d); - } - else - { - long long hostid = strtoll(host_envp, 0, 0); - return((unsigned int) hostid); - } - } -} - - -/* Function: set_address - * Arugments: t: a procnal structure to populate with the request - * - * set_address performs the bit manipulations to set the nid, pid, and - * iptop8 fields of the procnal structures. - * - * TODO: fix pidrequest to try to do dynamic binding if PTL_ID_ANY - */ - -#ifdef DIRECT_IP_MODE -void set_address(bridge t,ptl_pid_t pidrequest) -{ - int port; - if (pidrequest==(unsigned short)PTL_PID_ANY) port = 0; - else port=pidrequest; - t->lib_nal->libnal_ni.ni_pid.nid=get_node_id(); - t->lib_nal->libnal_ni.ni_pid.pid=port; -} -#else - -void set_address(bridge t,ptl_pid_t pidrequest) -{ - int virtnode, in_addr, port; - ptl_pid_t pid; - - /* get and remember my node id*/ - if (!getenv("PTL_VIRTNODE")) - virtnode = 0; - else - { - int maxvnode = PNAL_VNODE_MASK - (PNAL_BASE_PORT - >> PNAL_VNODE_SHIFT); - virtnode = atoi(getenv("PTL_VIRTNODE")); - if (virtnode > maxvnode) - { - fprintf(stderr, "PTL_VIRTNODE of %d is too large - max %d\n", - virtnode, maxvnode); - return; - } - } - - in_addr = get_node_id(); - - t->iptop8 = in_addr >> PNAL_HOSTID_SHIFT;/* for making new connections */ - t->lib_nal->libnal_ni.ni_pid.nid = ((in_addr & PNAL_HOSTID_MASK) - << PNAL_VNODE_SHIFT) - + virtnode; - pid=pidrequest; - /* TODO: Support of pid PTL_ID_ANY with virtual nodes needs more work. */ -#ifdef notyet - if (pid==(unsigned short)PTL_PID_ANY) port = 0; -#endif - if (pid==(unsigned short)PTL_PID_ANY) - { - fprintf(stderr, "portal pid PTL_ID_ANY is not currently supported\n"); - return; - } - else if (pid > PNAL_PID_MASK) - { - fprintf(stderr, "portal pid of %d is too large - max %d\n", - pid, PNAL_PID_MASK); - return; - } - else port = ((virtnode << PNAL_VNODE_SHIFT) + pid) + PNAL_BASE_PORT; - t->lib_nal->libnal_ni.ni_pid.pid=pid; -} -#endif diff --git a/lnet/ulnds/socklnd/bridge.h b/lnet/ulnds/socklnd/bridge.h deleted file mode 100644 index d2f0f2c..0000000 --- a/lnet/ulnds/socklnd/bridge.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#ifndef TCPNAL_PROCBRIDGE_H -#define TCPNAL_PROCBRIDGE_H - -#include -#include - -#define PTL_IFACE_TCP 1 -#define PTL_IFACE_ER 2 -#define PTL_IFACE_SS 3 -#define PTL_IFACE_MAX 4 - -typedef struct bridge { - int alive; - lib_nal_t *lib_nal; - void *lower; - void *local; - void (*shutdown)(struct bridge *); - /* this doesn't really belong here */ - unsigned char iptop8; -} *bridge; - - -typedef int (*nal_initialize)(bridge); -extern nal_initialize nal_table[PTL_IFACE_MAX]; - -#endif diff --git a/lnet/ulnds/socklnd/connection.c b/lnet/ulnds/socklnd/connection.c deleted file mode 100644 index b399fcf..0000000 --- a/lnet/ulnds/socklnd/connection.c +++ /dev/null @@ -1,508 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * 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. - */ - -/* connection.c: - This file provides a simple stateful connection manager which - builds tcp connections on demand and leaves them open for - future use. It also provides the machinery to allow peers - to connect to it -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif - -/* global variable: acceptor port */ -unsigned short tcpnal_acceptor_port = 988; - - -/* Function: compare_connection - * Arguments: connection c: a connection in the hash table - * ptl_process_id_t: an id to verify agains - * Returns: 1 if the connection is the one requested, 0 otherwise - * - * compare_connection() tests for collisions in the hash table - */ -static int compare_connection(void *arg1, void *arg2) -{ - connection c = arg1; - unsigned int * id = arg2; -#if 0 - return((c->ip==id[0]) && (c->port==id[1])); -#else - /* CFS specific hacking */ - return (c->ip == id[0]); -#endif -} - - -/* Function: connection_key - * Arguments: ptl_process_id_t id: an id to hash - * Returns: a not-particularily-well-distributed hash - * of the id - */ -static unsigned int connection_key(unsigned int *id) -{ -#if 0 - return(id[0]^id[1]); -#else - /* CFS specific hacking */ - return (unsigned int) id[0]; -#endif -} - - -/* Function: remove_connection - * Arguments: c: the connection to remove - */ -void remove_connection(void *arg) -{ - connection c = arg; - unsigned int id[2]; - - id[0]=c->ip; - id[1]=c->port; - hash_table_remove(c->m->connections,id); - close(c->fd); - free(c); -} - - -/* Function: read_connection: - * Arguments: c: the connection to read from - * dest: the buffer to read into - * len: the number of bytes to read - * Returns: success as 1, or failure as 0 - * - * read_connection() reads data from the connection, continuing - * to read partial results until the request is satisfied or - * it errors. TODO: this read should be covered by signal protection. - */ -int read_connection(connection c, - unsigned char *dest, - int len) -{ - int offset = 0,rc; - - if (len) { - do { -#ifndef __CYGWIN__ - rc = syscall(SYS_read, c->fd, dest+offset, len-offset); -#else - rc = recv(c->fd, dest+offset, len-offset, 0); -#endif - if (rc <= 0) { - if (errno == EINTR) { - rc = 0; - } else { - remove_connection(c); - return (0); - } - } - offset += rc; - } while (offset < len); - } - return (1); -} - -static int connection_input(void *d) -{ - connection c = d; - return((*c->m->handler)(c->m->handler_arg,c)); -} - - -/* Function: allocate_connection - * Arguments: t: tcpnal the allocation is occuring in the context of - * dest: portal endpoint address for this connection - * fd: open file descriptor for the socket - * Returns: an allocated connection structure - * - * just encompasses the action common to active and passive - * connections of allocation and placement in the global table - */ -static connection allocate_connection(manager m, - unsigned int ip, - unsigned short port, - int fd) -{ - connection c=malloc(sizeof(struct connection)); - unsigned int id[2]; - c->m=m; - c->fd=fd; - c->ip=ip; - c->port=port; - id[0]=ip; - id[1]=port; - register_io_handler(fd,READ_HANDLER,connection_input,c); - hash_table_insert(m->connections,c,id); - return(c); -} - - -/* Function: new_connection - * Arguments: t: opaque argument holding the tcpname - * Returns: 1 in order to reregister for new connection requests - * - * called when the bound service socket recieves - * a new connection request, it always accepts and - * installs a new connection - */ -static int new_connection(void *z) -{ - manager m=z; - struct sockaddr_in s; - int len=sizeof(struct sockaddr_in); - int fd=accept(m->bound,(struct sockaddr *)&s,&len); - unsigned int nid=*((unsigned int *)&s.sin_addr); - /* cfs specific hack */ - //unsigned short pid=s.sin_port; - pthread_mutex_lock(&m->conn_lock); - allocate_connection(m,htonl(nid),0/*pid*/,fd); - pthread_mutex_unlock(&m->conn_lock); - return(1); -} - -extern ptl_nid_t tcpnal_mynid; - -int -tcpnal_hello (int sockfd, ptl_nid_t *nid, int type, __u64 incarnation) -{ - int rc; - int nob; - ptl_hdr_t hdr; - ptl_magicversion_t *hmv = (ptl_magicversion_t *)&hdr.dest_nid; - - LASSERT (sizeof (*hmv) == sizeof (hdr.dest_nid)); - - memset (&hdr, 0, sizeof (hdr)); - hmv->magic = cpu_to_le32(PORTALS_PROTO_MAGIC); - hmv->version_major = cpu_to_le32(PORTALS_PROTO_VERSION_MAJOR); - hmv->version_minor = cpu_to_le32(PORTALS_PROTO_VERSION_MINOR); - - hdr.src_nid = cpu_to_le64(tcpnal_mynid); - hdr.type = cpu_to_le32(PTL_MSG_HELLO); - - hdr.msg.hello.type = cpu_to_le32(type); - hdr.msg.hello.incarnation = cpu_to_le64(incarnation); - - /* I don't send any interface info */ - - /* Assume sufficient socket buffering for this message */ - rc = syscall(SYS_write, sockfd, &hdr, sizeof(hdr)); - if (rc <= 0) { - CERROR ("Error %d sending HELLO to "LPX64"\n", rc, *nid); - return (rc); - } - - rc = syscall(SYS_read, sockfd, hmv, sizeof(*hmv)); - if (rc <= 0) { - CERROR ("Error %d reading HELLO from "LPX64"\n", rc, *nid); - return (rc); - } - - if (hmv->magic != le32_to_cpu(PORTALS_PROTO_MAGIC)) { - CERROR ("Bad magic %#08x (%#08x expected) from "LPX64"\n", - cpu_to_le32(hmv->magic), PORTALS_PROTO_MAGIC, *nid); - return (-EPROTO); - } - - if (hmv->version_major != cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR) || - hmv->version_minor != cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR)) { - CERROR ("Incompatible protocol version %d.%d (%d.%d expected)" - " from "LPX64"\n", - le16_to_cpu (hmv->version_major), - le16_to_cpu (hmv->version_minor), - PORTALS_PROTO_VERSION_MAJOR, - PORTALS_PROTO_VERSION_MINOR, - *nid); - return (-EPROTO); - } - -#if (PORTALS_PROTO_VERSION_MAJOR != 1) -# error "This code only understands protocol version 1.x" -#endif - /* version 1 sends magic/version as the dest_nid of a 'hello' header, - * so read the rest of it in now... */ - - rc = syscall(SYS_read, sockfd, hmv + 1, sizeof(hdr) - sizeof(*hmv)); - if (rc <= 0) { - CERROR ("Error %d reading rest of HELLO hdr from "LPX64"\n", - rc, *nid); - return (rc); - } - - /* ...and check we got what we expected */ - if (hdr.type != cpu_to_le32 (PTL_MSG_HELLO)) { - CERROR ("Expecting a HELLO hdr " - " but got type %d with %d payload from "LPX64"\n", - le32_to_cpu (hdr.type), - le32_to_cpu (hdr.payload_length), *nid); - return (-EPROTO); - } - - if (le64_to_cpu(hdr.src_nid) == PTL_NID_ANY) { - CERROR("Expecting a HELLO hdr with a NID, but got PTL_NID_ANY\n"); - return (-EPROTO); - } - - if (*nid == PTL_NID_ANY) { /* don't know peer's nid yet */ - *nid = le64_to_cpu(hdr.src_nid); - } else if (*nid != le64_to_cpu (hdr.src_nid)) { - CERROR ("Connected to nid "LPX64", but expecting "LPX64"\n", - le64_to_cpu (hdr.src_nid), *nid); - return (-EPROTO); - } - - /* Ignore any interface info in the payload */ - nob = le32_to_cpu(hdr.payload_length); - if (nob > getpagesize()) { - CERROR("Unexpected HELLO payload %d from "LPX64"\n", - nob, *nid); - return (-EPROTO); - } - if (nob > 0) { - char *space = (char *)malloc(nob); - - if (space == NULL) { - CERROR("Can't allocate scratch buffer %d\n", nob); - return (-ENOMEM); - } - - rc = syscall(SYS_read, sockfd, space, nob); - if (rc <= 0) { - CERROR("Error %d skipping HELLO payload from " - LPX64"\n", rc, *nid); - return (rc); - } - } - - return (0); -} - -/* Function: force_tcp_connection - * Arguments: t: tcpnal - * dest: portals endpoint for the connection - * Returns: an allocated connection structure, either - * a pre-existing one, or a new connection - */ -connection force_tcp_connection(manager m, - unsigned int ip, - unsigned short port, - procbridge pb) -{ - connection conn; - struct sockaddr_in addr; - struct sockaddr_in locaddr; - unsigned int id[2]; - struct timeval tv; - __u64 incarnation; - - int fd; - int option; - int rc; - int rport; - ptl_nid_t peernid = PTL_NID_ANY; - - port = tcpnal_acceptor_port; - - id[0] = ip; - id[1] = port; - - pthread_mutex_lock(&m->conn_lock); - - conn = hash_table_find(m->connections, id); - if (conn) - goto out; - - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = htonl(ip); - addr.sin_port = htons(port); - - memset(&locaddr, 0, sizeof(locaddr)); - locaddr.sin_family = AF_INET; - locaddr.sin_addr.s_addr = INADDR_ANY; - - for (rport = IPPORT_RESERVED - 1; rport > IPPORT_RESERVED / 2; --rport) { - fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) { - perror("tcpnal socket failed"); - goto out; - } - - option = 1; - rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - &option, sizeof(option)); - if (rc != 0) { - perror ("Can't set SO_REUSEADDR for socket"); - close(fd); - goto out; - } - - locaddr.sin_port = htons(rport); - rc = bind(fd, (struct sockaddr *)&locaddr, sizeof(locaddr)); - if (rc == 0 || errno == EACCES) { - rc = connect(fd, (struct sockaddr *)&addr, - sizeof(struct sockaddr_in)); - if (rc == 0) { - break; - } else if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) { - perror("Error connecting to remote host"); - close(fd); - goto out; - } - } else if (errno != EADDRINUSE) { - perror("Error binding to privileged port"); - close(fd); - goto out; - } - close(fd); - } - - if (rport == IPPORT_RESERVED / 2) { - fprintf(stderr, "Out of ports trying to bind to a reserved port\n"); - goto out; - } - -#if 1 - option = 1; - setsockopt(fd, SOL_TCP, TCP_NODELAY, &option, sizeof(option)); - option = 1<<20; - setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &option, sizeof(option)); - option = 1<<20; - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option)); -#endif - - gettimeofday(&tv, NULL); - incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; - - /* say hello */ - if (tcpnal_hello(fd, &peernid, SOCKNAL_CONN_ANY, incarnation)) - exit(-1); - - conn = allocate_connection(m, ip, port, fd); - - /* let nal thread know this event right away */ - if (conn) - procbridge_wakeup_nal(pb); - -out: - pthread_mutex_unlock(&m->conn_lock); - return (conn); -} - - -/* Function: bind_socket - * Arguments: t: the nal state for this interface - * port: the port to attempt to bind to - * Returns: 1 on success, or 0 on error - * - * bind_socket() attempts to allocate and bind a socket to the requested - * port, or dynamically assign one from the kernel should the port be - * zero. Sets the bound and bound_handler elements of m. - * - * TODO: The port should be an explicitly sized type. - */ -static int bind_socket(manager m,unsigned short port) -{ - struct sockaddr_in addr; - int alen=sizeof(struct sockaddr_in); - - if ((m->bound = socket(AF_INET, SOCK_STREAM, 0)) < 0) - return(0); - - bzero((char *) &addr, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = 0; - addr.sin_port = htons(port); - - if (bind(m->bound,(struct sockaddr *)&addr,alen)<0){ - perror ("tcpnal bind"); - return(0); - } - - getsockname(m->bound,(struct sockaddr *)&addr, &alen); - - m->bound_handler=register_io_handler(m->bound,READ_HANDLER, - new_connection,m); - listen(m->bound,5); - m->port=addr.sin_port; - return(1); -} - - -/* Function: shutdown_connections - * Arguments: m: the manager structure - * - * close all connections and reclaim resources - */ -void shutdown_connections(manager m) -{ - close(m->bound); - remove_io_handler(m->bound_handler); - hash_destroy_table(m->connections,remove_connection); - free(m); -} - - -/* Function: init_connections - * Arguments: t: the nal state for this interface - * port: the port to attempt to bind to - * Returns: a newly allocated manager structure, or - * zero if the fixed port could not be bound - */ -manager init_connections(unsigned short pid, - int (*input)(void *, void *), - void *a) -{ - manager m = (manager)malloc(sizeof(struct manager)); - m->connections = hash_create_table(compare_connection,connection_key); - m->handler = input; - m->handler_arg = a; - pthread_mutex_init(&m->conn_lock, 0); - - if (bind_socket(m,pid)) - return(m); - - free(m); - return(0); -} diff --git a/lnet/ulnds/socklnd/connection.h b/lnet/ulnds/socklnd/connection.h deleted file mode 100644 index 343ffa6..0000000 --- a/lnet/ulnds/socklnd/connection.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#include -#include - -typedef struct manager { - table connections; - pthread_mutex_t conn_lock; /* protect connections table */ - int bound; - io_handler bound_handler; - int (*handler)(void *, void *); - void *handler_arg; - unsigned short port; -} *manager; - - -typedef struct connection { - unsigned int ip; - unsigned short port; - int fd; - manager m; -} *connection; - -connection force_tcp_connection(manager m, unsigned int ip, unsigned int short, - procbridge pb); -manager init_connections(unsigned short, int (*f)(void *, void *), void *); -void remove_connection(void *arg); -void shutdown_connections(manager m); -int read_connection(connection c, unsigned char *dest, int len); diff --git a/lnet/ulnds/socklnd/debug.c b/lnet/ulnds/socklnd/debug.c deleted file mode 100644 index b82bb2f..0000000 --- a/lnet/ulnds/socklnd/debug.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * Author: Phil Schwan - * - * 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. - */ - -#include -#include -#include -#include -#include - -int smp_processor_id = 1; -char debug_file_path[1024] = "/tmp/lustre-log"; -char debug_file_name[1024]; -FILE *debug_file_fd; - -int portals_do_debug_dumplog(void *arg) -{ - printf("Look in %s\n", debug_file_name); - return 0; -} - - -void portals_debug_print(void) -{ - return; -} - - -void portals_debug_dumplog(void) -{ - printf("Look in %s\n", debug_file_name); - return; -} - - -int portals_debug_init(unsigned long bufsize) -{ - debug_file_fd = stdout; - return 0; -} - -int portals_debug_cleanup(void) -{ - return 0; //close(portals_debug_fd); -} - -int portals_debug_clear_buffer(void) -{ - return 0; -} - -int portals_debug_mark_buffer(char *text) -{ - - fprintf(debug_file_fd, "*******************************************************************************\n"); - fprintf(debug_file_fd, "DEBUG MARKER: %s\n", text); - fprintf(debug_file_fd, "*******************************************************************************\n"); - - return 0; -} - -int portals_debug_copy_to_user(char *buf, unsigned long len) -{ - return 0; -} - -/* FIXME: I'm not very smart; someone smarter should make this better. */ -void -portals_debug_msg (int subsys, int mask, char *file, const char *fn, - const int line, const char *format, ...) -{ - va_list ap; - unsigned long flags; - struct timeval tv; - int nob; - - - /* NB since we pass a non-zero sized buffer (at least) on the first - * print, we can be assured that by the end of all the snprinting, - * we _do_ have a terminated buffer, even if our message got truncated. - */ - - gettimeofday(&tv, NULL); - - nob += fprintf(debug_file_fd, - "%02x:%06x:%d:%lu.%06lu ", - subsys >> 24, mask, smp_processor_id, - tv.tv_sec, tv.tv_usec); - - nob += fprintf(debug_file_fd, - "(%s:%d:%s() %d+%ld): ", - file, line, fn, 0, - 8192 - ((unsigned long)&flags & 8191UL)); - - va_start (ap, format); - nob += fprintf(debug_file_fd, format, ap); - va_end (ap); - - -} - diff --git a/lnet/ulnds/socklnd/dispatch.h b/lnet/ulnds/socklnd/dispatch.h deleted file mode 100644 index a8f916d9..0000000 --- a/lnet/ulnds/socklnd/dispatch.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -/* this file is only called dispatch.h to prevent it - from colliding with /usr/include/sys/select.h */ - -typedef struct io_handler *io_handler; - -struct io_handler{ - io_handler *last; - io_handler next; - int fd; - int type; - int (*function)(void *); - void *argument; - int disabled; -}; - - -#define READ_HANDLER 1 -#define WRITE_HANDLER 2 -#define EXCEPTION_HANDLER 4 -#define ALL_HANDLER (READ_HANDLER | WRITE_HANDLER | EXCEPTION_HANDLER) - -io_handler register_io_handler(int fd, - int type, - int (*function)(void *), - void *arg); - -void remove_io_handler (io_handler i); -void init_unix_timer(void); -void select_timer_block(when until); -when now(void); - -/* - * hacking for CFS internal MPI testing - */ -#if !CRAY_PORTALS -#define ENABLE_SELECT_DISPATCH -#endif diff --git a/lnet/ulnds/socklnd/ipmap.h b/lnet/ulnds/socklnd/ipmap.h deleted file mode 100644 index 85b1e18..0000000 --- a/lnet/ulnds/socklnd/ipmap.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#define DIRECT_IP_MODE -#ifdef DIRECT_IP_MODE -#define PNAL_NID(in_addr, port) (in_addr) -#define PNAL_PID(pid) (pid) -#define PNAL_IP(in_addr, port) (in_addr) -#define PNAL_PORT(nid, pid) (pid) -#else - -#define PNAL_BASE_PORT 4096 -#define PNAL_HOSTID_SHIFT 24 -#define PNAL_HOSTID_MASK ((1 << PNAL_HOSTID_SHIFT) - 1) -#define PNAL_VNODE_SHIFT 8 -#define PNAL_VNODE_MASK ((1 << PNAL_VNODE_SHIFT) - 1) -#define PNAL_PID_SHIFT 8 -#define PNAL_PID_MASK ((1 << PNAL_PID_SHIFT) - 1) - -#define PNAL_NID(in_addr, port) (((ntohl(in_addr) & PNAL_HOSTID_MASK) \ - << PNAL_VNODE_SHIFT) \ - | (((ntohs(port)-PNAL_BASE_PORT) >>\ - PNAL_PID_SHIFT))) -#define PNAL_PID(port) ((ntohs(port) - PNAL_BASE_PORT) & PNAL_PID_MASK) - -#define PNAL_IP(nid,t) (htonl((((unsigned)(nid))\ - >> PNAL_VNODE_SHIFT)\ - | (t->iptop8 << PNAL_HOSTID_SHIFT))) -#define PNAL_PORT(nid, pid) (htons(((((nid) & PNAL_VNODE_MASK) \ - << PNAL_VNODE_SHIFT) \ - | ((pid) & PNAL_PID_MASK)) \ - + PNAL_BASE_PORT)) -#endif diff --git a/lnet/ulnds/socklnd/pqtimer.c b/lnet/ulnds/socklnd/pqtimer.c deleted file mode 100644 index 98c48eb..0000000 --- a/lnet/ulnds/socklnd/pqtimer.c +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * 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. - */ - -/* timer.c: - * this file implements a simple priority-queue based timer system. when - * combined with a file which implements now() and block(), it can - * be used to provide course-grained time-based callbacks. - */ - -#include -#include -#include - -struct timer { - void (*function)(void *); - void *arg; - when w; - int interval; - int disable; -}; - -typedef struct thunk *thunk; -struct thunk { - void (*f)(void *); - void *a; - thunk next; -}; - -extern when now(void); - -static thunk thunks; -static int internal; -static void (*block_function)(when); -static int number_of_timers; -static int size_of_pqueue; -static timer *timers; - - -static void heal(int where) -{ - int left=(where<<1); - int right=(where<<1)+1; - int min=where; - timer temp; - - if (left <= number_of_timers) - if (timers[left]->w < timers[min]->w) min=left; - if (right <= number_of_timers) - if (timers[right]->w < timers[min]->w) min=right; - if (min != where){ - temp=timers[where]; - timers[where]=timers[min]; - timers[min]=temp; - heal(min); - } -} - -static void add_pqueue(int i) -{ - timer temp; - int parent=(i>>1); - if ((i>1) && (timers[i]->w< timers[parent]->w)){ - temp=timers[i]; - timers[i]=timers[parent]; - timers[parent]=temp; - add_pqueue(parent); - } -} - -static void add_timer(timer t) -{ - if (size_of_pqueue<(number_of_timers+2)){ - int oldsize=size_of_pqueue; - timer *new=(void *)malloc(sizeof(struct timer)*(size_of_pqueue+=10)); - memcpy(new,timers,sizeof(timer)*oldsize); - timers=new; - } - timers[++number_of_timers]=t; - add_pqueue(number_of_timers); -} - -/* Function: register_timer - * Arguments: interval: the time interval from the current time when - * the timer function should be called - * function: the function to call when the time has expired - * argument: the argument to call it with. - * Returns: a pointer to a timer structure - */ -timer register_timer(when interval, - void (*function)(void *), - void *argument) -{ - timer t=(timer)malloc(sizeof(struct timer)); - - t->arg=argument; - t->function=function; - t->interval=interval; - t->disable=0; - t->w=now()+interval; - add_timer(t); - if (!internal && (number_of_timers==1)) - block_function(t->w); - return(t); -} - -/* Function: remove_timer - * Arguments: t: - * Returns: nothing - * - * remove_timer removes a timer from the system, insuring - * that it will never be called. It does not actually - * free the timer due to reentrancy issues. - */ - -void remove_timer(timer t) -{ - t->disable=1; -} - - - -void timer_fire() -{ - timer current; - - current=timers[1]; - timers[1]=timers[number_of_timers--]; - heal(1); - if (!current->disable) { - (*current->function)(current->arg); - } - free(current); -} - -when next_timer(void) -{ - when here=now(); - - while (number_of_timers && (timers[1]->w <= here)) timer_fire(); - if (number_of_timers) return(timers[1]->w); - return(0); -} - -/* Function: timer_loop - * Arguments: none - * Returns: never - * - * timer_loop() is the blocking dispatch function for the timer. - * Is calls the block() function registered with init_timer, - * and handles associated with timers that have been registered. - */ -void timer_loop() -{ - when here; - - while (1){ - thunk z; - here=now(); - - for (z=thunks;z;z=z->next) (*z->f)(z->a); - - if (number_of_timers){ - if (timers[1]->w > here){ - (*block_function)(timers[1]->w); - } else { - timer_fire(); - } - } else { - thunk z; - for (z=thunks;z;z=z->next) (*z->f)(z->a); - (*block_function)(0); - } - } -} - - -/* Function: register_thunk - * Arguments: f: the function to call - * a: the single argument to call it with - * - * Thunk functions get called at irregular intervals, they - * should not assume when, or take a particularily long - * amount of time. Thunks are for background cleanup tasks. - */ -void register_thunk(void (*f)(void *),void *a) -{ - thunk t=(void *)malloc(sizeof(struct thunk)); - t->f=f; - t->a=a; - t->next=thunks; - thunks=t; -} - -/* Function: initialize_timer - * Arguments: block: the function to call to block for the specified interval - * - * initialize_timer() must be called before any other timer function, - * including timer_loop. - */ -void initialize_timer(void (*block)(when)) -{ - block_function=block; - number_of_timers=0; - size_of_pqueue=10; - timers=(timer *)malloc(sizeof(timer)*size_of_pqueue); - thunks=0; -} diff --git a/lnet/ulnds/socklnd/pqtimer.h b/lnet/ulnds/socklnd/pqtimer.h deleted file mode 100644 index 11efb0e..0000000 --- a/lnet/ulnds/socklnd/pqtimer.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -typedef unsigned long long when; -when now(void); -typedef struct timer *timer; -timer register_timer(when interval, - void (*function)(void *), - void *argument); -timer register_timer_wait(void); -void remove_timer(timer); -void timer_loop(void); -void initialize_timer(void (*block)(when)); -void timer_fire(void); - - -#define HZ 0x100000000ull - - diff --git a/lnet/ulnds/socklnd/procapi.c b/lnet/ulnds/socklnd/procapi.c deleted file mode 100644 index 6b471c0..0000000 --- a/lnet/ulnds/socklnd/procapi.c +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * 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. - */ - -/* api.c: - * This file provides the 'api' side for the process-based nals. - * it is responsible for creating the 'library' side thread, - * and passing wrapped portals transactions to it. - * - * Along with initialization, shutdown, and transport to the library - * side, this file contains some stubs to satisfy the nal definition. - */ -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif -#include -#include -#include -#include -#include - - -/* XXX CFS workaround, to give a chance to let nal thread wake up - * from waiting in select - */ -static int procbridge_notifier_handler(void *arg) -{ - static char buf[8]; - procbridge p = (procbridge) arg; - - syscall(SYS_read, p->notifier[1], buf, sizeof(buf)); - return 1; -} - -void procbridge_wakeup_nal(procbridge p) -{ - static char buf[8]; - syscall(SYS_write, p->notifier[0], buf, sizeof(buf)); -} - -/* Function: shutdown - * Arguments: nal: a pointer to my top side nal structure - * ni: my network interface index - * - * cleanup nal state, reclaim the lower side thread and - * its state using PTL_FINI codepoint - */ -static void procbridge_shutdown(nal_t *n) -{ - lib_nal_t *nal = n->nal_data; - bridge b=(bridge)nal->libnal_data; - procbridge p=(procbridge)b->local; - - p->nal_flags |= NAL_FLAG_STOPPING; - procbridge_wakeup_nal(p); - - do { - pthread_mutex_lock(&p->mutex); - if (p->nal_flags & NAL_FLAG_STOPPED) { - pthread_mutex_unlock(&p->mutex); - break; - } - pthread_cond_wait(&p->cond, &p->mutex); - pthread_mutex_unlock(&p->mutex); - } while (1); - - free(p); -} - - -/* forward decl */ -extern int procbridge_startup (nal_t *, ptl_pid_t, - ptl_ni_limits_t *, ptl_ni_limits_t *); - -/* api_nal - * the interface vector to allow the generic code to access - * this nal. this is seperate from the library side lib_nal. - * TODO: should be dyanmically allocated - */ -nal_t procapi_nal = { - nal_data: NULL, - nal_ni_init: procbridge_startup, - nal_ni_fini: procbridge_shutdown, -}; - -ptl_nid_t tcpnal_mynid; - -#ifdef ENABLE_SELECT_DISPATCH -procbridge __global_procbridge = NULL; -#endif - -/* Function: procbridge_startup - * - * Arguments: pid: requested process id (port offset) - * PTL_ID_ANY not supported. - * desired: limits passed from the application - * and effectively ignored - * actual: limits actually allocated and returned - * - * Returns: portals rc - * - * initializes the tcp nal. we define unix_failure as an - * error wrapper to cut down clutter. - */ -int procbridge_startup (nal_t *nal, ptl_pid_t requested_pid, - ptl_ni_limits_t *requested_limits, - ptl_ni_limits_t *actual_limits) -{ - nal_init_args_t args; - - procbridge p; - bridge b; - /* XXX nal_type is purely private to tcpnal here */ - int nal_type = PTL_IFACE_TCP;/* PTL_IFACE_DEFAULT FIXME hack */ - - LASSERT(nal == &procapi_nal); - - init_unix_timer(); - - b=(bridge)malloc(sizeof(struct bridge)); - p=(procbridge)malloc(sizeof(struct procbridge)); - b->local=p; - - args.nia_requested_pid = requested_pid; - args.nia_requested_limits = requested_limits; - args.nia_actual_limits = actual_limits; - args.nia_nal_type = nal_type; - args.nia_bridge = b; - args.nia_apinal = nal; - - /* init procbridge */ - pthread_mutex_init(&p->mutex,0); - pthread_cond_init(&p->cond, 0); - p->nal_flags = 0; - - /* initialize notifier */ - if (socketpair(AF_UNIX, SOCK_STREAM, 0, p->notifier)) { - perror("socketpair failed"); - return PTL_FAIL; - } - - if (!register_io_handler(p->notifier[1], READ_HANDLER, - procbridge_notifier_handler, p)) { - perror("fail to register notifier handler"); - return PTL_FAIL; - } - -#ifdef ENABLE_SELECT_DISPATCH - __global_procbridge = p; -#endif - - /* create nal thread */ - if (pthread_create(&p->t, NULL, nal_thread, &args)) { - perror("nal_init: pthread_create"); - return PTL_FAIL; - } - - do { - pthread_mutex_lock(&p->mutex); - if (p->nal_flags & (NAL_FLAG_RUNNING | NAL_FLAG_STOPPED)) { - pthread_mutex_unlock(&p->mutex); - break; - } - pthread_cond_wait(&p->cond, &p->mutex); - pthread_mutex_unlock(&p->mutex); - } while (1); - - if (p->nal_flags & NAL_FLAG_STOPPED) - return PTL_FAIL; - - b->lib_nal->libnal_ni.ni_pid.nid = tcpnal_mynid; - - return PTL_OK; -} diff --git a/lnet/ulnds/socklnd/procbridge.h b/lnet/ulnds/socklnd/procbridge.h deleted file mode 100644 index 1f91ced..0000000 --- a/lnet/ulnds/socklnd/procbridge.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#ifndef _PROCBRIDGE_H_ -#define _PROCBRIDGE_H_ - -#include -#include -#include - - -#define NAL_FLAG_RUNNING 1 -#define NAL_FLAG_STOPPING 2 -#define NAL_FLAG_STOPPED 4 - -typedef struct procbridge { - /* sync between user threads and nal thread */ - pthread_t t; - pthread_cond_t cond; - pthread_mutex_t mutex; - - /* socket pair used to notify nal thread */ - int notifier[2]; - - int nal_flags; - -} *procbridge; - -typedef struct nal_init_args { - ptl_pid_t nia_requested_pid; - ptl_ni_limits_t *nia_requested_limits; - ptl_ni_limits_t *nia_actual_limits; - int nia_nal_type; - bridge nia_bridge; - nal_t *nia_apinal; -} nal_init_args_t; - -extern void *nal_thread(void *); - - -#define PTL_INIT (LIB_MAX_DISPATCH+1) -#define PTL_FINI (LIB_MAX_DISPATCH+2) - -#define MAX_ACLS 1 -#define MAX_PTLS 128 - -extern void set_address(bridge t,ptl_pid_t pidrequest); -extern void procbridge_wakeup_nal(procbridge p); - -#endif diff --git a/lnet/ulnds/socklnd/proclib.c b/lnet/ulnds/socklnd/proclib.c deleted file mode 100644 index 7ee7c71..0000000 --- a/lnet/ulnds/socklnd/proclib.c +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * 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. - */ - -/* lib.c: - * This file provides the 'library' side for the process-based nals. - * it is responsible for communication with the 'api' side and - * providing service to the generic portals 'library' - * implementation. 'library' might be better termed 'communication' - * or 'kernel'. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* the following functions are stubs to satisfy the nal definition - without doing anything particularily useful*/ - -static int nal_dist(lib_nal_t *nal, - ptl_nid_t nid, - unsigned long *dist) -{ - return 0; -} - -static void check_stopping(void *z) -{ - bridge b = z; - procbridge p = b->local; - - if ((p->nal_flags & NAL_FLAG_STOPPING) == 0) - return; - - pthread_mutex_lock(&p->mutex); - p->nal_flags |= NAL_FLAG_STOPPED; - pthread_cond_broadcast(&p->cond); - pthread_mutex_unlock(&p->mutex); - - pthread_exit(0); -} - - -/* Function: nal_thread - * Arguments: z: an opaque reference to a nal control structure - * allocated and partially populated by the api level code - * Returns: nothing, and only on error or explicit shutdown - * - * This function is the entry point of the pthread initiated on - * the api side of the interface. This thread is used to handle - * asynchronous delivery to the application. - * - * We define a limit macro to place a ceiling on limits - * for syntactic convenience - */ -extern int tcpnal_init(bridge); - -nal_initialize nal_table[PTL_IFACE_MAX]={0,tcpnal_init,0}; - -void *nal_thread(void *z) -{ - nal_init_args_t *args = (nal_init_args_t *) z; - bridge b = args->nia_bridge; - procbridge p=b->local; - int rc; - ptl_process_id_t process_id; - int nal_type; - - b->lib_nal=(lib_nal_t *)malloc(sizeof(lib_nal_t)); - b->lib_nal->libnal_data=b; - b->lib_nal->libnal_map=NULL; - b->lib_nal->libnal_unmap=NULL; - b->lib_nal->libnal_dist=nal_dist; - - nal_type = args->nia_nal_type; - - /* Wierd, but this sets b->lib_nal->libnal_ni.ni_pid.{nid,pid}, which - * lib_init() is about to do from the process_id passed to it...*/ - set_address(b,args->nia_requested_pid); - - process_id = b->lib_nal->libnal_ni.ni_pid; - - if (nal_table[nal_type]) rc=(*nal_table[nal_type])(b); - /* initialize the generic 'library' level code */ - - rc = lib_init(b->lib_nal, args->nia_apinal, - process_id, - args->nia_requested_limits, - args->nia_actual_limits); - - /* - * Whatever the initialization returned is passed back to the - * user level code for further interpretation. We just exit if - * it is non-zero since something went wrong. - */ - /* this should perform error checking */ - pthread_mutex_lock(&p->mutex); - p->nal_flags |= (rc != PTL_OK) ? NAL_FLAG_STOPPED : NAL_FLAG_RUNNING; - pthread_cond_broadcast(&p->cond); - pthread_mutex_unlock(&p->mutex); - - if (rc == PTL_OK) { - /* the thunk function is called each time the timer loop - performs an operation and returns to blocking mode. we - overload this function to inform the api side that - it may be interested in looking at the event queue */ - register_thunk(check_stopping,b); - timer_loop(); - } - return(0); -} diff --git a/lnet/ulnds/socklnd/select.c b/lnet/ulnds/socklnd/select.c deleted file mode 100644 index 09e1542..0000000 --- a/lnet/ulnds/socklnd/select.c +++ /dev/null @@ -1,419 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * 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. - */ - -/* select.c: - * Provides a general mechanism for registering and dispatching - * io events through the select system call. - */ - -#ifdef sun -#include -#else -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -static struct timeval beginning_of_epoch; -static io_handler io_handlers; - -/* Function: now - * - * Return: the current time in canonical units: a 64 bit number - * where the most significant 32 bits contains the number - * of seconds, and the least signficant a count of (1/(2^32))ths - * of a second. - */ -when now() -{ - struct timeval result; - - gettimeofday(&result,0); - return((((unsigned long long)result.tv_sec)<<32)| - (((unsigned long long)result.tv_usec)<<32)/1000000); -} - - -/* Function: register_io_handler - * Arguments: fd: the file descriptor of interest - * type: a mask of READ_HANDLER, WRITE_HANDLER, EXCEPTION_HANDLER - * function: a function to call when io is available on fd - * arg: an opaque correlator to return to the handler - * Returns: a pointer to the io_handler structure - */ -io_handler register_io_handler(int fd, - int type, - int (*function)(void *), - void *arg) -{ - io_handler i=(io_handler)malloc(sizeof(struct io_handler)); - if ((i->fd=fd)>=0){ - i->type=type; - i->function=function; - i->argument=arg; - i->disabled=0; - i->last=&io_handlers; - if ((i->next=io_handlers)) i->next->last=&i->next; - io_handlers=i; - } - return(i); -} - -/* Function: remove_io_handler - * Arguments: i: a pointer to the handler to stop servicing - * - * remove_io_handler() doesn't actually free the handler, due - * to reentrancy problems. it just marks the handler for - * later cleanup by the blocking function. - */ -void remove_io_handler (io_handler i) -{ - i->disabled=1; -} - -static void set_flag(io_handler n,fd_set *r, fd_set *w, fd_set *e) -{ - if (n->type & READ_HANDLER) FD_SET(n->fd, r); - if (n->type & WRITE_HANDLER) FD_SET(n->fd, w); - if (n->type & EXCEPTION_HANDLER) FD_SET(n->fd, e); -} - -static int prepare_fd_sets(fd_set *r, fd_set *w, fd_set *e) -{ - io_handler j; - io_handler *k; - int max = 0; - - FD_ZERO(r); - FD_ZERO(w); - FD_ZERO(e); - for (k=&io_handlers;*k;){ - if ((*k)->disabled){ - j=*k; - *k=(*k)->next; - free(j); - } - if (*k) { - set_flag(*k,r,w,e); - if ((*k)->fd > max) - max = (*k)->fd; - k=&(*k)->next; - } - } - return max + 1; -} - -static int execute_callbacks(fd_set *r, fd_set *w, fd_set *e) -{ - io_handler j; - int n = 0, t; - - for (j = io_handlers; j; j = j->next) { - if (j->disabled) - continue; - - t = 0; - if (FD_ISSET(j->fd, r) && (j->type & READ_HANDLER)) { - FD_CLR(j->fd, r); - t++; - } - if (FD_ISSET(j->fd, w) && (j->type & WRITE_HANDLER)) { - FD_CLR(j->fd, w); - t++; - } - if (FD_ISSET(j->fd, e) && (j->type & EXCEPTION_HANDLER)) { - FD_CLR(j->fd, e); - t++; - } - if (t == 0) - continue; - - if (!(*j->function)(j->argument)) - j->disabled = 1; - - n += t; - } - - return n; -} - -#ifdef ENABLE_SELECT_DISPATCH - -static struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - int submitted; - int nready; - int maxfd; - fd_set *rset; - fd_set *wset; - fd_set *eset; - struct timeval *timeout; - struct timeval submit_time; -} fd_extra = { - PTHREAD_MUTEX_INITIALIZER, - PTHREAD_COND_INITIALIZER, - 0, 0, 0, - NULL, NULL, NULL, NULL, -}; - -extern int liblustre_wait_event(int timeout); -extern procbridge __global_procbridge; - -/* - * this will intercept syscall select() of user apps - * such as MPI libs. - */ -int select(int n, fd_set *rset, fd_set *wset, fd_set *eset, - struct timeval *timeout) -{ - LASSERT(fd_extra.submitted == 0); - - fd_extra.nready = 0; - fd_extra.maxfd = n; - fd_extra.rset = rset; - fd_extra.wset = wset; - fd_extra.eset = eset; - fd_extra.timeout = timeout; - - liblustre_wait_event(0); - pthread_mutex_lock(&fd_extra.mutex); - gettimeofday(&fd_extra.submit_time, NULL); - fd_extra.submitted = 1; - LASSERT(__global_procbridge); - procbridge_wakeup_nal(__global_procbridge); - -again: - if (fd_extra.submitted) - pthread_cond_wait(&fd_extra.cond, &fd_extra.mutex); - pthread_mutex_unlock(&fd_extra.mutex); - - liblustre_wait_event(0); - - pthread_mutex_lock(&fd_extra.mutex); - if (fd_extra.submitted) - goto again; - pthread_mutex_unlock(&fd_extra.mutex); - - LASSERT(fd_extra.nready >= 0); - LASSERT(fd_extra.submitted == 0); - return fd_extra.nready; -} - -static int merge_fds(int max, fd_set *rset, fd_set *wset, fd_set *eset) -{ - int i; - - LASSERT(rset); - LASSERT(wset); - LASSERT(eset); - - for (i = 0; i < __FD_SETSIZE/__NFDBITS; i++) { - LASSERT(!fd_extra.rset || - !(__FDS_BITS(rset)[i] & __FDS_BITS(fd_extra.rset)[i])); - LASSERT(!fd_extra.wset || - !(__FDS_BITS(wset)[i] & __FDS_BITS(fd_extra.wset)[i])); - LASSERT(!fd_extra.eset || - !(__FDS_BITS(eset)[i] & __FDS_BITS(fd_extra.eset)[i])); - - if (fd_extra.rset && __FDS_BITS(fd_extra.rset)[i]) - __FDS_BITS(rset)[i] |= __FDS_BITS(fd_extra.rset)[i]; - if (fd_extra.wset && __FDS_BITS(fd_extra.wset)[i]) - __FDS_BITS(wset)[i] |= __FDS_BITS(fd_extra.wset)[i]; - if (fd_extra.eset && __FDS_BITS(fd_extra.eset)[i]) - __FDS_BITS(eset)[i] |= __FDS_BITS(fd_extra.eset)[i]; - } - - return (fd_extra.maxfd > max ? fd_extra.maxfd : max); -} - -static inline -int timeval_ge(struct timeval *tv1, struct timeval *tv2) -{ - LASSERT(tv1 && tv2); - return ((tv1->tv_sec - tv2->tv_sec) * 1000000 + - (tv1->tv_usec - tv2->tv_usec) >= 0); -} - -/* - * choose the most recent timeout value - */ -static struct timeval *choose_timeout(struct timeval *tv1, - struct timeval *tv2) -{ - if (!tv1) - return tv2; - else if (!tv2) - return tv1; - - if (timeval_ge(tv1, tv2)) - return tv2; - else - return tv1; -} - -/* Function: select_timer_block - * Arguments: until: an absolute time when the select should return - * - * This function dispatches the various file descriptors' handler - * functions, if the kernel indicates there is io available. - */ -void select_timer_block(when until) -{ - fd_set fds[3]; - struct timeval timeout; - struct timeval *timeout_pointer, *select_timeout; - int max, nready, nexec; - int fd_handling; - -again: - if (until) { - when interval; - - interval = until - now(); - timeout.tv_sec = (interval >> 32); - timeout.tv_usec = ((interval << 32) / 1000000) >> 32; - timeout_pointer = &timeout; - } else - timeout_pointer = NULL; - - fd_handling = 0; - max = prepare_fd_sets(&fds[0], &fds[1], &fds[2]); - select_timeout = timeout_pointer; - - pthread_mutex_lock(&fd_extra.mutex); - fd_handling = fd_extra.submitted; - pthread_mutex_unlock(&fd_extra.mutex); - if (fd_handling) { - max = merge_fds(max, &fds[0], &fds[1], &fds[2]); - select_timeout = choose_timeout(timeout_pointer, fd_extra.timeout); - } - - /* XXX only compile for linux */ -#if __WORDSIZE == 64 - nready = syscall(SYS_select, max, &fds[0], &fds[1], &fds[2], - select_timeout); -#else - nready = syscall(SYS__newselect, max, &fds[0], &fds[1], &fds[2], - select_timeout); -#endif - if (nready < 0) { - CERROR("select return err %d, errno %d\n", nready, errno); - return; - } - - if (nready) { - nexec = execute_callbacks(&fds[0], &fds[1], &fds[2]); - nready -= nexec; - } else - nexec = 0; - - /* even both nready & nexec are 0, we still need try to wakeup - * upper thread since it may have timed out - */ - if (fd_handling) { - LASSERT(nready >= 0); - - pthread_mutex_lock(&fd_extra.mutex); - if (nready) { - if (fd_extra.rset) - *fd_extra.rset = fds[0]; - if (fd_extra.wset) - *fd_extra.wset = fds[1]; - if (fd_extra.eset) - *fd_extra.eset = fds[2]; - fd_extra.nready = nready; - fd_extra.submitted = 0; - } else { - struct timeval t; - - fd_extra.nready = 0; - if (fd_extra.timeout) { - gettimeofday(&t, NULL); - if (timeval_ge(&t, &fd_extra.submit_time)) - fd_extra.submitted = 0; - } - } - - pthread_cond_signal(&fd_extra.cond); - pthread_mutex_unlock(&fd_extra.mutex); - } - - /* haven't found portals event, go back to loop if time - * is not expired */ - if (!nexec) { - if (timeout_pointer == NULL || now() >= until) - goto again; - } -} - -#else /* !ENABLE_SELECT_DISPATCH */ - -/* Function: select_timer_block - * Arguments: until: an absolute time when the select should return - * - * This function dispatches the various file descriptors' handler - * functions, if the kernel indicates there is io available. - */ -void select_timer_block(when until) -{ - fd_set fds[3]; - struct timeval timeout; - struct timeval *timeout_pointer; - int max, nready; - -again: - if (until) { - when interval; - interval = until - now(); - timeout.tv_sec = (interval >> 32); - timeout.tv_usec = ((interval << 32) / 1000000) >> 32; - timeout_pointer = &timeout; - } else - timeout_pointer = NULL; - - max = prepare_fd_sets(&fds[0], &fds[1], &fds[2]); - - nready = select(max, &fds[0], &fds[1], &fds[2], timeout_pointer); - if (nready > 0) - execute_callbacks(&fds[0], &fds[1], &fds[2]); -} -#endif /* ENABLE_SELECT_DISPATCH */ - -/* Function: init_unix_timer() - * is called to initialize the library - */ -void init_unix_timer() -{ - io_handlers=0; - gettimeofday(&beginning_of_epoch, 0); - initialize_timer(select_timer_block); -} diff --git a/lnet/ulnds/socklnd/table.c b/lnet/ulnds/socklnd/table.c deleted file mode 100644 index 662775a..0000000 --- a/lnet/ulnds/socklnd/table.c +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * 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. - */ - -#include -#include -#include - - -/* table.c: - * a very simple hash table implementation with paramerterizable - * comparison and key generation functions. it does resize - * in order to accomidate more entries, but never collapses - * the table - */ - -static table_entry *table_lookup (table t,void *comparator, - unsigned int k, - int (*compare_function)(void *, void *), - int *success) -{ - unsigned int key=k%t->size; - table_entry *i; - - for (i=&(t->entries[key]);*i;i=&((*i)->next)){ - if (compare_function && ((*i)->key==k)) - if ((*t->compare_function)((*i)->value,comparator)){ - *success=1; - return(i); - } - } - *success=0; - return(&(t->entries[key])); -} - - -static void resize_table(table t, int size) -{ - int old_size=t->size; - table_entry *old_entries=t->entries; - int i; - table_entry j,n; - table_entry *position; - int success; - - t->size=size; - t->entries=(table_entry *)malloc(sizeof(table_entry)*t->size); - memset(t->entries,0,sizeof(table_entry)*t->size); - - for (i=0;inext; - position=table_lookup(t,0,j->key,0,&success); - j->next= *position; - *position=j; - } - free(old_entries); -} - - -/* Function: key_from_int - * Arguments: int i: value to compute the key of - * Returns: the key - */ -unsigned int key_from_int(int i) -{ - return(i); -} - - -/* Function: key_from_string - * Arguments: char *s: the null terminated string - * to compute the key of - * Returns: the key - */ -unsigned int key_from_string(char *s) -{ - unsigned int result=0; - unsigned char *n; - int i; - if (!s) return(1); - for (n=s,i=0;*n;n++,i++) result^=(*n*57)^*n*i; - return(result); -} - - -/* Function: hash_create_table - * Arguments: compare_function: a function to compare - * a table instance with a correlator - * key_function: a function to generate a 32 bit - * hash key from a correlator - * Returns: a pointer to the new table - */ -table hash_create_table (int (*compare_function)(void *, void *), - unsigned int (*key_function)(unsigned int *)) -{ - table new=(table)malloc(sizeof(struct table)); - memset(new, 0, sizeof(struct table)); - - new->compare_function=compare_function; - new->key_function=key_function; - new->number_of_entries=0; - new->size=4; - new->entries=(table_entry *)malloc(sizeof(table_entry)*new->size); - memset(new->entries,0,sizeof(table_entry)*new->size); - return(new); -} - - -/* Function: hash_table_find - * Arguments: t: a table to look in - * comparator: a value to access the table entry - * Returns: the element references to by comparator, or null - */ -void *hash_table_find (table t, void *comparator) -{ - int success; - table_entry* entry=table_lookup(t,comparator, - (*t->key_function)(comparator), - t->compare_function, - &success); - if (success) return((*entry)->value); - return(0); -} - - -/* Function: hash_table_insert - * Arguments: t: a table to insert the object - * value: the object to put in the table - * comparator: the value by which the object - * will be addressed - * Returns: nothing - */ -void hash_table_insert (table t, void *value, void *comparator) -{ - int success; - unsigned int k=(*t->key_function)(comparator); - table_entry *position=table_lookup(t,comparator,k, - t->compare_function,&success); - table_entry entry; - - if (success) { - entry = *position; - } else { - entry = (table_entry)malloc(sizeof(struct table_entry)); - memset(entry, 0, sizeof(struct table_entry)); - entry->next= *position; - *position=entry; - t->number_of_entries++; - } - entry->value=value; - entry->key=k; - if (t->number_of_entries > t->size) resize_table(t,t->size*2); -} - -/* Function: hash_table_remove - * Arguments: t: the table to remove the object from - * comparator: the index value of the object to remove - * Returns: - */ -void hash_table_remove (table t, void *comparator) -{ - int success; - table_entry temp; - table_entry *position=table_lookup(t,comparator, - (*t->key_function)(comparator), - t->compare_function,&success); - if(success) { - temp=*position; - *position=(*position)->next; - free(temp); /* the value? */ - t->number_of_entries--; - } -} - -/* Function: hash_iterate_table_entries - * Arguments: t: the table to iterate over - * handler: a function to call with each element - * of the table, along with arg - * arg: the opaque object to pass to handler - * Returns: nothing - */ -void hash_iterate_table_entries(table t, - void (*handler)(void *,void *), - void *arg) -{ - int i; - table_entry *j,*next; - - for (i=0;isize;i++) - for (j=t->entries+i;*j;j=next){ - next=&((*j)->next); - (*handler)(arg,(*j)->value); - } -} - -/* Function: hash_filter_table_entries - * Arguments: t: the table to iterate over - * handler: a function to call with each element - * of the table, along with arg - * arg: the opaque object to pass to handler - * Returns: nothing - * Notes: operations on the table inside handler are not safe - * - * filter_table_entires() calls the handler function for each - * item in the table, passing it and arg. The handler function - * returns 1 if it is to be retained in the table, and 0 - * if it is to be removed. - */ -void hash_filter_table_entries(table t, int (*handler)(void *, void *), void *arg) -{ - int i; - table_entry *j,*next,v; - - for (i=0;isize;i++) - for (j=t->entries+i;*j;j=next){ - next=&((*j)->next); - if (!(*handler)(arg,(*j)->value)){ - next=j; - v=*j; - *j=(*j)->next; - free(v); - t->number_of_entries--; - } - } -} - -/* Function: destroy_table - * Arguments: t: the table to free - * thunk: a function to call with each element, - * most likely free() - * Returns: nothing - */ -void hash_destroy_table(table t,void (*thunk)(void *)) -{ - table_entry j,next; - int i; - for (i=0;isize;i++) - for (j=t->entries[i];j;j=next){ - next=j->next; - if (thunk) (*thunk)(j->value); - free(j); - } - free(t->entries); - free(t); -} diff --git a/lnet/ulnds/socklnd/table.h b/lnet/ulnds/socklnd/table.h deleted file mode 100644 index 7fab586..0000000 --- a/lnet/ulnds/socklnd/table.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#ifndef E_TABLE -#define E_TABLE - -typedef struct table_entry { - unsigned int key; - void *value; - struct table_entry *next; -} *table_entry; - - -typedef struct table { - unsigned int size; - int number_of_entries; - table_entry *entries; - int (*compare_function)(void *, void *); - unsigned int (*key_function)(unsigned int *); -} *table; - -/* table.c */ -unsigned int key_from_int(int i); -unsigned int key_from_string(char *s); -table hash_create_table(int (*compare_function)(void *, void *), unsigned int (*key_function)(unsigned int *)); -void *hash_table_find(table t, void *comparator); -void hash_table_insert(table t, void *value, void *comparator); -void hash_table_remove(table t, void *comparator); -void hash_iterate_table_entries(table t, void (*handler)(void *, void *), void *arg); -void hash_filter_table_entries(table t, int (*handler)(void *, void *), void *arg); -void hash_destroy_table(table t, void (*thunk)(void *)); - -#endif diff --git a/lnet/ulnds/socklnd/tcplnd.c b/lnet/ulnds/socklnd/tcplnd.c deleted file mode 100644 index abb6d01..0000000 --- a/lnet/ulnds/socklnd/tcplnd.c +++ /dev/null @@ -1,256 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * 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. - */ - -/* tcpnal.c: - This file implements the TCP-based nal by providing glue - between the connection service and the generic NAL implementation */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif - -/* Function: tcpnal_send - * Arguments: nal: pointer to my nal control block - * private: unused - * cookie: passed back to the portals library - * hdr: pointer to the portals header - * nid: destination node - * pid: destination process - * data: body of the message - * len: length of the body - * Returns: zero on success - * - * sends a packet to the peer, after insuring that a connection exists - */ -ptl_err_t tcpnal_send(lib_nal_t *n, - void *private, - lib_msg_t *cookie, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int niov, - struct iovec *iov, - size_t offset, - size_t len) -{ - connection c; - bridge b=(bridge)n->libnal_data; - struct iovec tiov[257]; - static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; - ptl_err_t rc = PTL_OK; - int sysrc; - int total; - int ntiov; - int i; - - if (!(c=force_tcp_connection((manager)b->lower, - PNAL_IP(nid,b), - PNAL_PORT(nid,pid), - b->local))) - return(PTL_FAIL); - - /* TODO: these results should be checked. furthermore, provision - must be made for the SIGPIPE which is delivered when - writing on a tcp socket which has closed underneath - the application. there is a linux flag in the sendmsg - call which turns off the signally behaviour, but its - nonstandard */ - - LASSERT (niov <= 256); - - tiov[0].iov_base = hdr; - tiov[0].iov_len = sizeof(ptl_hdr_t); - ntiov = 1 + lib_extract_iov(256, &tiov[1], niov, iov, offset, len); - - pthread_mutex_lock(&send_lock); -#if 1 - for (i = total = 0; i < ntiov; i++) - total += tiov[i].iov_len; - - sysrc = syscall(SYS_writev, c->fd, tiov, ntiov); - if (sysrc != total) { - fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", - rc, total, errno); - rc = PTL_FAIL; - } -#else - for (i = total = 0; i <= ntiov; i++) { - rc = send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); - - if (rc != tiov[i].iov_len) { - fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", - rc, tiov[i].iov_len, errno); - rc = PTL_FAIL; - break; - } - total += rc; - } -#endif -#if 0 - fprintf (stderr, "sent %s total %d in %d frags\n", - hdr->type == PTL_MSG_ACK ? "ACK" : - hdr->type == PTL_MSG_PUT ? "PUT" : - hdr->type == PTL_MSG_GET ? "GET" : - hdr->type == PTL_MSG_REPLY ? "REPLY" : - hdr->type == PTL_MSG_HELLO ? "HELLO" : "UNKNOWN", - total, niov + 1); -#endif - pthread_mutex_unlock(&send_lock); - - if (rc == PTL_OK) { - /* NB the NAL only calls lib_finalize() if it returns PTL_OK - * from cb_send() */ - lib_finalize(n, private, cookie, PTL_OK); - } - - return(rc); -} - - -/* Function: tcpnal_recv - * Arguments: lib_nal_t *nal: pointer to my nal control block - * void *private: connection pointer passed through - * lib_parse() - * lib_msg_t *cookie: passed back to portals library - * user_ptr data: pointer to the destination buffer - * size_t mlen: length of the body - * size_t rlen: length of data in the network - * Returns: zero on success - * - * blocking read of the requested data. must drain out the - * difference of mainpulated and requested lengths from the network - */ -ptl_err_t tcpnal_recv(lib_nal_t *n, - void *private, - lib_msg_t *cookie, - unsigned int niov, - struct iovec *iov, - size_t offset, - size_t mlen, - size_t rlen) - -{ - struct iovec tiov[256]; - int ntiov; - int i; - - if (!niov) - goto finalize; - - LASSERT(mlen); - LASSERT(rlen); - LASSERT(rlen >= mlen); - - ntiov = lib_extract_iov(256, tiov, niov, iov, offset, mlen); - - /* FIXME - * 1. Is this effecient enough? change to use readv() directly? - * 2. need check return from read_connection() - * - MeiJia - */ - for (i = 0; i < ntiov; i++) - read_connection(private, tiov[i].iov_base, tiov[i].iov_len); - -finalize: - /* FIXME; we always assume success here... */ - lib_finalize(n, private, cookie, PTL_OK); - - if (mlen!=rlen){ - char *trash=malloc(rlen-mlen); - - /*TODO: check error status*/ - read_connection(private,trash,rlen-mlen); - free(trash); - } - - return(PTL_OK); -} - - -/* Function: from_connection: - * Arguments: c: the connection to read from - * Returns: whether or not to continue reading from this connection, - * expressed as a 1 to continue, and a 0 to not - * - * from_connection() is called from the select loop when i/o is - * available. It attempts to read the portals header and - * pass it to the generic library for processing. - */ -static int from_connection(void *a, void *d) -{ - connection c = d; - bridge b = a; - ptl_hdr_t hdr; - - if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ - lib_parse(b->lib_nal, &hdr, c); - /*TODO: check error status*/ - return(1); - } - return(0); -} - - -static void tcpnal_shutdown(bridge b) -{ - shutdown_connections(b->lower); -} - -/* Function: PTL_IFACE_TCP - * Arguments: pid_request: desired port number to bind to - * desired: passed NAL limits structure - * actual: returned NAL limits structure - * Returns: a nal structure on success, or null on failure - */ -int tcpnal_init(bridge b) -{ - manager m; - - b->lib_nal->libnal_send=tcpnal_send; - b->lib_nal->libnal_recv=tcpnal_recv; - b->shutdown=tcpnal_shutdown; - - if (!(m=init_connections(PNAL_PORT(b->lib_nal->libnal_ni.ni_pid.nid, - b->lib_nal->libnal_ni.ni_pid.pid), - from_connection,b))){ - /* TODO: this needs to shut down the - newly created junk */ - return(PTL_NAL_FAILED); - } - b->lower=m; - return(PTL_OK); -} diff --git a/lnet/ulnds/socklnd/timer.h b/lnet/ulnds/socklnd/timer.h deleted file mode 100644 index aaf39d2..0000000 --- a/lnet/ulnds/socklnd/timer.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -/* TODO: make this an explicit type when they become available */ -typedef unsigned long long when; - -typedef struct timer { - void (*function)(void *); - void *arg; - when w; - int interval; - int disable; -} *timer; - -timer register_timer(when, void (*f)(void *), void *a); -void remove_timer(timer t); -void timer_loop(void); -void initialize_timer(void); -void register_thunk(void (*f)(void *),void *a); - - -#define HZ 0x100000000ull - - diff --git a/lnet/ulnds/socklnd/utypes.h b/lnet/ulnds/socklnd/utypes.h deleted file mode 100644 index 7eca959..0000000 --- a/lnet/ulnds/socklnd/utypes.h +++ /dev/null @@ -1,12 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef unsigned long long uint64; -typedef unsigned char uint8; diff --git a/lnet/ulnds/table.c b/lnet/ulnds/table.c deleted file mode 100644 index 662775a..0000000 --- a/lnet/ulnds/table.c +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * 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. - */ - -#include -#include -#include - - -/* table.c: - * a very simple hash table implementation with paramerterizable - * comparison and key generation functions. it does resize - * in order to accomidate more entries, but never collapses - * the table - */ - -static table_entry *table_lookup (table t,void *comparator, - unsigned int k, - int (*compare_function)(void *, void *), - int *success) -{ - unsigned int key=k%t->size; - table_entry *i; - - for (i=&(t->entries[key]);*i;i=&((*i)->next)){ - if (compare_function && ((*i)->key==k)) - if ((*t->compare_function)((*i)->value,comparator)){ - *success=1; - return(i); - } - } - *success=0; - return(&(t->entries[key])); -} - - -static void resize_table(table t, int size) -{ - int old_size=t->size; - table_entry *old_entries=t->entries; - int i; - table_entry j,n; - table_entry *position; - int success; - - t->size=size; - t->entries=(table_entry *)malloc(sizeof(table_entry)*t->size); - memset(t->entries,0,sizeof(table_entry)*t->size); - - for (i=0;inext; - position=table_lookup(t,0,j->key,0,&success); - j->next= *position; - *position=j; - } - free(old_entries); -} - - -/* Function: key_from_int - * Arguments: int i: value to compute the key of - * Returns: the key - */ -unsigned int key_from_int(int i) -{ - return(i); -} - - -/* Function: key_from_string - * Arguments: char *s: the null terminated string - * to compute the key of - * Returns: the key - */ -unsigned int key_from_string(char *s) -{ - unsigned int result=0; - unsigned char *n; - int i; - if (!s) return(1); - for (n=s,i=0;*n;n++,i++) result^=(*n*57)^*n*i; - return(result); -} - - -/* Function: hash_create_table - * Arguments: compare_function: a function to compare - * a table instance with a correlator - * key_function: a function to generate a 32 bit - * hash key from a correlator - * Returns: a pointer to the new table - */ -table hash_create_table (int (*compare_function)(void *, void *), - unsigned int (*key_function)(unsigned int *)) -{ - table new=(table)malloc(sizeof(struct table)); - memset(new, 0, sizeof(struct table)); - - new->compare_function=compare_function; - new->key_function=key_function; - new->number_of_entries=0; - new->size=4; - new->entries=(table_entry *)malloc(sizeof(table_entry)*new->size); - memset(new->entries,0,sizeof(table_entry)*new->size); - return(new); -} - - -/* Function: hash_table_find - * Arguments: t: a table to look in - * comparator: a value to access the table entry - * Returns: the element references to by comparator, or null - */ -void *hash_table_find (table t, void *comparator) -{ - int success; - table_entry* entry=table_lookup(t,comparator, - (*t->key_function)(comparator), - t->compare_function, - &success); - if (success) return((*entry)->value); - return(0); -} - - -/* Function: hash_table_insert - * Arguments: t: a table to insert the object - * value: the object to put in the table - * comparator: the value by which the object - * will be addressed - * Returns: nothing - */ -void hash_table_insert (table t, void *value, void *comparator) -{ - int success; - unsigned int k=(*t->key_function)(comparator); - table_entry *position=table_lookup(t,comparator,k, - t->compare_function,&success); - table_entry entry; - - if (success) { - entry = *position; - } else { - entry = (table_entry)malloc(sizeof(struct table_entry)); - memset(entry, 0, sizeof(struct table_entry)); - entry->next= *position; - *position=entry; - t->number_of_entries++; - } - entry->value=value; - entry->key=k; - if (t->number_of_entries > t->size) resize_table(t,t->size*2); -} - -/* Function: hash_table_remove - * Arguments: t: the table to remove the object from - * comparator: the index value of the object to remove - * Returns: - */ -void hash_table_remove (table t, void *comparator) -{ - int success; - table_entry temp; - table_entry *position=table_lookup(t,comparator, - (*t->key_function)(comparator), - t->compare_function,&success); - if(success) { - temp=*position; - *position=(*position)->next; - free(temp); /* the value? */ - t->number_of_entries--; - } -} - -/* Function: hash_iterate_table_entries - * Arguments: t: the table to iterate over - * handler: a function to call with each element - * of the table, along with arg - * arg: the opaque object to pass to handler - * Returns: nothing - */ -void hash_iterate_table_entries(table t, - void (*handler)(void *,void *), - void *arg) -{ - int i; - table_entry *j,*next; - - for (i=0;isize;i++) - for (j=t->entries+i;*j;j=next){ - next=&((*j)->next); - (*handler)(arg,(*j)->value); - } -} - -/* Function: hash_filter_table_entries - * Arguments: t: the table to iterate over - * handler: a function to call with each element - * of the table, along with arg - * arg: the opaque object to pass to handler - * Returns: nothing - * Notes: operations on the table inside handler are not safe - * - * filter_table_entires() calls the handler function for each - * item in the table, passing it and arg. The handler function - * returns 1 if it is to be retained in the table, and 0 - * if it is to be removed. - */ -void hash_filter_table_entries(table t, int (*handler)(void *, void *), void *arg) -{ - int i; - table_entry *j,*next,v; - - for (i=0;isize;i++) - for (j=t->entries+i;*j;j=next){ - next=&((*j)->next); - if (!(*handler)(arg,(*j)->value)){ - next=j; - v=*j; - *j=(*j)->next; - free(v); - t->number_of_entries--; - } - } -} - -/* Function: destroy_table - * Arguments: t: the table to free - * thunk: a function to call with each element, - * most likely free() - * Returns: nothing - */ -void hash_destroy_table(table t,void (*thunk)(void *)) -{ - table_entry j,next; - int i; - for (i=0;isize;i++) - for (j=t->entries[i];j;j=next){ - next=j->next; - if (thunk) (*thunk)(j->value); - free(j); - } - free(t->entries); - free(t); -} diff --git a/lnet/ulnds/table.h b/lnet/ulnds/table.h deleted file mode 100644 index 7fab586..0000000 --- a/lnet/ulnds/table.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -#ifndef E_TABLE -#define E_TABLE - -typedef struct table_entry { - unsigned int key; - void *value; - struct table_entry *next; -} *table_entry; - - -typedef struct table { - unsigned int size; - int number_of_entries; - table_entry *entries; - int (*compare_function)(void *, void *); - unsigned int (*key_function)(unsigned int *); -} *table; - -/* table.c */ -unsigned int key_from_int(int i); -unsigned int key_from_string(char *s); -table hash_create_table(int (*compare_function)(void *, void *), unsigned int (*key_function)(unsigned int *)); -void *hash_table_find(table t, void *comparator); -void hash_table_insert(table t, void *value, void *comparator); -void hash_table_remove(table t, void *comparator); -void hash_iterate_table_entries(table t, void (*handler)(void *, void *), void *arg); -void hash_filter_table_entries(table t, int (*handler)(void *, void *), void *arg); -void hash_destroy_table(table t, void (*thunk)(void *)); - -#endif diff --git a/lnet/ulnds/tcplnd.c b/lnet/ulnds/tcplnd.c deleted file mode 100644 index abb6d01..0000000 --- a/lnet/ulnds/tcplnd.c +++ /dev/null @@ -1,256 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2003 Cluster File Systems, Inc. - * - * 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. - */ - -/* tcpnal.c: - This file implements the TCP-based nal by providing glue - between the connection service and the generic NAL implementation */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __CYGWIN__ -#include -#endif - -/* Function: tcpnal_send - * Arguments: nal: pointer to my nal control block - * private: unused - * cookie: passed back to the portals library - * hdr: pointer to the portals header - * nid: destination node - * pid: destination process - * data: body of the message - * len: length of the body - * Returns: zero on success - * - * sends a packet to the peer, after insuring that a connection exists - */ -ptl_err_t tcpnal_send(lib_nal_t *n, - void *private, - lib_msg_t *cookie, - ptl_hdr_t *hdr, - int type, - ptl_nid_t nid, - ptl_pid_t pid, - unsigned int niov, - struct iovec *iov, - size_t offset, - size_t len) -{ - connection c; - bridge b=(bridge)n->libnal_data; - struct iovec tiov[257]; - static pthread_mutex_t send_lock = PTHREAD_MUTEX_INITIALIZER; - ptl_err_t rc = PTL_OK; - int sysrc; - int total; - int ntiov; - int i; - - if (!(c=force_tcp_connection((manager)b->lower, - PNAL_IP(nid,b), - PNAL_PORT(nid,pid), - b->local))) - return(PTL_FAIL); - - /* TODO: these results should be checked. furthermore, provision - must be made for the SIGPIPE which is delivered when - writing on a tcp socket which has closed underneath - the application. there is a linux flag in the sendmsg - call which turns off the signally behaviour, but its - nonstandard */ - - LASSERT (niov <= 256); - - tiov[0].iov_base = hdr; - tiov[0].iov_len = sizeof(ptl_hdr_t); - ntiov = 1 + lib_extract_iov(256, &tiov[1], niov, iov, offset, len); - - pthread_mutex_lock(&send_lock); -#if 1 - for (i = total = 0; i < ntiov; i++) - total += tiov[i].iov_len; - - sysrc = syscall(SYS_writev, c->fd, tiov, ntiov); - if (sysrc != total) { - fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", - rc, total, errno); - rc = PTL_FAIL; - } -#else - for (i = total = 0; i <= ntiov; i++) { - rc = send(c->fd, tiov[i].iov_base, tiov[i].iov_len, 0); - - if (rc != tiov[i].iov_len) { - fprintf (stderr, "BAD SEND rc %d != %d, errno %d\n", - rc, tiov[i].iov_len, errno); - rc = PTL_FAIL; - break; - } - total += rc; - } -#endif -#if 0 - fprintf (stderr, "sent %s total %d in %d frags\n", - hdr->type == PTL_MSG_ACK ? "ACK" : - hdr->type == PTL_MSG_PUT ? "PUT" : - hdr->type == PTL_MSG_GET ? "GET" : - hdr->type == PTL_MSG_REPLY ? "REPLY" : - hdr->type == PTL_MSG_HELLO ? "HELLO" : "UNKNOWN", - total, niov + 1); -#endif - pthread_mutex_unlock(&send_lock); - - if (rc == PTL_OK) { - /* NB the NAL only calls lib_finalize() if it returns PTL_OK - * from cb_send() */ - lib_finalize(n, private, cookie, PTL_OK); - } - - return(rc); -} - - -/* Function: tcpnal_recv - * Arguments: lib_nal_t *nal: pointer to my nal control block - * void *private: connection pointer passed through - * lib_parse() - * lib_msg_t *cookie: passed back to portals library - * user_ptr data: pointer to the destination buffer - * size_t mlen: length of the body - * size_t rlen: length of data in the network - * Returns: zero on success - * - * blocking read of the requested data. must drain out the - * difference of mainpulated and requested lengths from the network - */ -ptl_err_t tcpnal_recv(lib_nal_t *n, - void *private, - lib_msg_t *cookie, - unsigned int niov, - struct iovec *iov, - size_t offset, - size_t mlen, - size_t rlen) - -{ - struct iovec tiov[256]; - int ntiov; - int i; - - if (!niov) - goto finalize; - - LASSERT(mlen); - LASSERT(rlen); - LASSERT(rlen >= mlen); - - ntiov = lib_extract_iov(256, tiov, niov, iov, offset, mlen); - - /* FIXME - * 1. Is this effecient enough? change to use readv() directly? - * 2. need check return from read_connection() - * - MeiJia - */ - for (i = 0; i < ntiov; i++) - read_connection(private, tiov[i].iov_base, tiov[i].iov_len); - -finalize: - /* FIXME; we always assume success here... */ - lib_finalize(n, private, cookie, PTL_OK); - - if (mlen!=rlen){ - char *trash=malloc(rlen-mlen); - - /*TODO: check error status*/ - read_connection(private,trash,rlen-mlen); - free(trash); - } - - return(PTL_OK); -} - - -/* Function: from_connection: - * Arguments: c: the connection to read from - * Returns: whether or not to continue reading from this connection, - * expressed as a 1 to continue, and a 0 to not - * - * from_connection() is called from the select loop when i/o is - * available. It attempts to read the portals header and - * pass it to the generic library for processing. - */ -static int from_connection(void *a, void *d) -{ - connection c = d; - bridge b = a; - ptl_hdr_t hdr; - - if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){ - lib_parse(b->lib_nal, &hdr, c); - /*TODO: check error status*/ - return(1); - } - return(0); -} - - -static void tcpnal_shutdown(bridge b) -{ - shutdown_connections(b->lower); -} - -/* Function: PTL_IFACE_TCP - * Arguments: pid_request: desired port number to bind to - * desired: passed NAL limits structure - * actual: returned NAL limits structure - * Returns: a nal structure on success, or null on failure - */ -int tcpnal_init(bridge b) -{ - manager m; - - b->lib_nal->libnal_send=tcpnal_send; - b->lib_nal->libnal_recv=tcpnal_recv; - b->shutdown=tcpnal_shutdown; - - if (!(m=init_connections(PNAL_PORT(b->lib_nal->libnal_ni.ni_pid.nid, - b->lib_nal->libnal_ni.ni_pid.pid), - from_connection,b))){ - /* TODO: this needs to shut down the - newly created junk */ - return(PTL_NAL_FAILED); - } - b->lower=m; - return(PTL_OK); -} diff --git a/lnet/ulnds/timer.h b/lnet/ulnds/timer.h deleted file mode 100644 index aaf39d2..0000000 --- a/lnet/ulnds/timer.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * Copyright (c) 2002 Eric Hoffman - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -/* TODO: make this an explicit type when they become available */ -typedef unsigned long long when; - -typedef struct timer { - void (*function)(void *); - void *arg; - when w; - int interval; - int disable; -} *timer; - -timer register_timer(when, void (*f)(void *), void *a); -void remove_timer(timer t); -void timer_loop(void); -void initialize_timer(void); -void register_thunk(void (*f)(void *),void *a); - - -#define HZ 0x100000000ull - - diff --git a/lnet/ulnds/utypes.h b/lnet/ulnds/utypes.h deleted file mode 100644 index 7eca959..0000000 --- a/lnet/ulnds/utypes.h +++ /dev/null @@ -1,12 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 Cray Inc. - * - * This file is part of Portals, http://www.sf.net/projects/sandiaportals/ - */ - -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef unsigned long long uint64; -typedef unsigned char uint8; diff --git a/lnet/utils/.cvsignore b/lnet/utils/.cvsignore deleted file mode 100644 index e2a0d44..0000000 --- a/lnet/utils/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -Makefile -Makefile.in -acceptor -debugctl -ptlctl -.deps -routerstat -wirecheck -gmnalnid -.*.cmd diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am deleted file mode 100644 index 1d9f905..0000000 --- a/lnet/utils/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -## $(srcdir)/../ for , ../../ for generated -#COMPILE = $(CC) -Wall -g -I$(srcdir)/../include -I../../include -#LINK = $(CC) -o $@ - -if LIBLUSTRE -noinst_LIBRARIES = libuptlctl.a -endif - -libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c -libuptlctl_a_CPPFLAGS = $(LLCPPFLAGS) -libuptlctl_a_CFLAGS = $(LLCFLAGS) - -sbin_PROGRAMS = debugctl - -lib_LIBRARIES = libptlctl.a - -libptlctl_a_SOURCES = portals.c debug.c l_ioctl.c parser.c parser.h - -if UTILS -if !CRAY_PORTALS -sbin_PROGRAMS += acceptor ptlctl routerstat wirecheck gmnalnid -endif -endif - -acceptor_SOURCES = acceptor.c -acceptor_LDADD = $(LIBWRAP) - -wirecheck_SOURCES = wirecheck.c - -gmnalnid_SOURCES = gmnalnid.c - -ptlctl_SOURCES = ptlctl.c -ptlctl_LDADD = -L. -lptlctl $(LIBREADLINE) $(LIBEFENCE) -ptlctl_DEPENDENCIES = libptlctl.a - -routerstat_SOURCES = routerstat.c - -debugctl_SOURCES = debugctl.c -debugctl_LDADD = -L. -lptlctl $(LIBREADLINE) $(LIBEFENCE) -debugctl_DEPENDENCIES = libptlctl.a - diff --git a/lnet/utils/Makefile.mk b/lnet/utils/Makefile.mk deleted file mode 100644 index cbbe6d5..0000000 --- a/lnet/utils/Makefile.mk +++ /dev/null @@ -1,6 +0,0 @@ -include $(src)/../Kernelenv - -host-progs := acceptor ptlctl -always := $(host-progs) - -ptlctl-objs := ptlctl.o $(PTLCTLOBJS) diff --git a/lnet/utils/acceptor.c b/lnet/utils/acceptor.c deleted file mode 100644 index 524d128..0000000 --- a/lnet/utils/acceptor.c +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_LIBWRAP -#include -#include -#include -#endif - -#include -#include -#include -#include - -/* should get this from autoconf somehow */ -#ifndef PIDFILE_DIR -#define PIDFILE_DIR "/var/run" -#endif - -#define PROGNAME "acceptor" - -#ifdef HAVE_LIBWRAP -/* needed because libwrap declares these as externs */ -int allow_severity = LOG_INFO; -int deny_severity = LOG_WARNING; -#endif - -void create_pidfile(char *name, int port) -{ - char pidfile[1024]; - FILE *fp; - - snprintf(pidfile, sizeof(pidfile), "%s/%s-%d.pid", - PIDFILE_DIR, name, port); - - if ((fp = fopen(pidfile, "w"))) { - fprintf(fp, "%d\n", getpid()); - fclose(fp); - } else { - syslog(LOG_ERR, "%s: %s\n", pidfile, - strerror(errno)); - } -} - -int pidfile_exists(char *name, int port) -{ - char pidfile[1024]; - - snprintf(pidfile, sizeof(pidfile), "%s/%s-%d.pid", - PIDFILE_DIR, name, port); - - if (!access(pidfile, F_OK)) { - fprintf(stderr, "%s: exists, acceptor already running.\n", - pidfile); - return (1); - } - return (0); -} - -void -show_connection (int fd, __u32 net_ip) -{ - struct hostent *h = gethostbyaddr ((char *)&net_ip, sizeof net_ip, AF_INET); - __u32 host_ip = ntohl (net_ip); - int len; - char host[1024]; - - if (h == NULL) - snprintf (host, sizeof(host), "%d.%d.%d.%d", (host_ip >> 24) & 0xff, - (host_ip >> 16) & 0xff, (host_ip >> 8) & 0xff, host_ip & 0xff); - else - snprintf (host, sizeof(host), "%s", h->h_name); - - syslog (LOG_INFO, "Accepted host: %s\n", host); -} - -void -usage (char *myname) -{ - fprintf (stderr, - "Usage: %s [-N nal_id] [-p] [-l] port\n\n" - " -l\tKeep stdin/stdout open\n" - " -p\tAllow connections from non-privileged ports\n", - myname); - exit (1); -} - -int main(int argc, char **argv) -{ - int o, fd, rc, port, pfd; - struct sockaddr_in srvaddr; - int c; - int noclose = 0; - int nal = SOCKNAL; - int rport; - int require_privports = 1; - - while ((c = getopt (argc, argv, "N:lp")) != -1) { - switch (c) { - case 'N': - if (sscanf(optarg, "%d", &nal) != 1 || - nal < 0 || nal > NAL_MAX_NR) - usage(argv[0]); - break; - case 'l': - noclose = 1; - break; - case 'p': - require_privports = 0; - break; - default: - usage (argv[0]); - break; - } - } - - if (optind >= argc) - usage (argv[0]); - - port = atol(argv[optind++]); - - if (pidfile_exists(PROGNAME, port)) - exit(1); - - memset(&srvaddr, 0, sizeof(srvaddr)); - srvaddr.sin_family = AF_INET; - srvaddr.sin_port = htons(port); - srvaddr.sin_addr.s_addr = INADDR_ANY; - - fd = socket(PF_INET, SOCK_STREAM, 0); - if (fd < 0) { - perror("opening socket"); - exit(1); - } - - o = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &o, sizeof(o))) { - perror("Cannot set REUSEADDR socket opt"); - exit(1); - } - - rc = bind(fd, (struct sockaddr *)&srvaddr, sizeof(srvaddr)); - if ( rc == -1 ) { - perror("bind: "); - exit(1); - } - - if (listen(fd, 127)) { - perror("listen: "); - exit(1); - } - fprintf(stderr, "listening on port %d\n", port); - - pfd = open("/dev/portals", O_RDWR); - if ( pfd < 0 ) { - perror("opening portals device"); - exit(1); - } - - rc = daemon(0, noclose); - if (rc < 0) { - perror("daemon(): "); - exit(1); - } - - openlog(PROGNAME, LOG_PID, LOG_DAEMON); - syslog(LOG_INFO, "started, listening on port %d\n", port); - create_pidfile(PROGNAME, port); - - while (1) { - struct sockaddr_in clntaddr; - int len = sizeof(clntaddr); - int cfd; - struct portal_ioctl_data data; - struct portals_cfg pcfg; -#ifdef HAVE_LIBWRAP - struct request_info request; -#endif - char addrstr[INET_ADDRSTRLEN]; - - cfd = accept(fd, (struct sockaddr *)&clntaddr, &len); - if ( cfd < 0 ) { - perror("accept"); - exit(0); - continue; - } - -#ifdef HAVE_LIBWRAP - /* libwrap access control */ - request_init(&request, RQ_DAEMON, "lustre", RQ_FILE, cfd, 0); - sock_host(&request); - if (!hosts_access(&request)) { - inet_ntop(AF_INET, &clntaddr.sin_addr, - addrstr, INET_ADDRSTRLEN); - syslog(LOG_WARNING, "Unauthorized access from %s:%hd\n", - addrstr, ntohs(clntaddr.sin_port)); - close (cfd); - continue; - } -#endif - - if (require_privports && ntohs(clntaddr.sin_port) >= IPPORT_RESERVED) { - inet_ntop(AF_INET, &clntaddr.sin_addr, - addrstr, INET_ADDRSTRLEN); - syslog(LOG_ERR, "Closing non-privileged connection from %s:%d\n", - addrstr, ntohs(clntaddr.sin_port)); - rc = close(cfd); - if (rc) - perror ("close un-privileged client failed"); - continue; - } - - show_connection (cfd, clntaddr.sin_addr.s_addr); - - PCFG_INIT(pcfg, NAL_CMD_REGISTER_PEER_FD); - pcfg.pcfg_nal = nal; - pcfg.pcfg_fd = cfd; - pcfg.pcfg_misc = SOCKNAL_CONN_NONE; /* == incoming connection */ - - PORTAL_IOC_INIT(data); - data.ioc_pbuf1 = (char*)&pcfg; - data.ioc_plen1 = sizeof(pcfg); - - if (ioctl(pfd, IOC_PORTAL_NAL_CMD, &data) < 0) { - perror("ioctl failed"); - } else { - printf("client registered\n"); - } - rc = close(cfd); - if (rc) - perror ("close failed"); - } - - closelog(); - exit(0); - -} diff --git a/lnet/utils/debug.c b/lnet/utils/debug.c deleted file mode 100644 index 9886a5c..0000000 --- a/lnet/utils/debug.c +++ /dev/null @@ -1,833 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Some day I'll split all of this functionality into a cfs_debug module - * of its own. That day is not today. - * - */ - -#define __USE_FILE_OFFSET64 -#define _GNU_SOURCE - -#include - -#include -#ifdef HAVE_NETDB_H -#include -#endif -#include -#include -#include "ioctl.h" -#include -#include -#include -#ifndef __CYGWIN__ -# include -#endif - -#include -#include -#include -#include -#include - -#ifdef HAVE_LINUX_VERSION_H -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define BUG() /* workaround for module.h includes */ -#include -#endif -#endif /* !HAVE_LINUX_VERSION_H */ - -#include - -#include -#include -#include "parser.h" - -#include - -static char rawbuf[8192]; -static char *buf = rawbuf; -static int max = 8192; -/*static int g_pfd = -1;*/ -static int subsystem_mask = ~0; -static int debug_mask = ~0; - -#define MAX_MARK_SIZE 100 - -static const char *portal_debug_subsystems[] = - {"undefined", "mdc", "mds", "osc", - "ost", "class", "log", "llite", - "rpc", "mgmt", "portals", "nal", - "pinger", "filter", "ptlbd", "echo", - "ldlm", "lov", "router", "cobd", - "sm", "asobd", "confobd", "lmv", - "cmobd", NULL}; -static const char *portal_debug_masks[] = - {"trace", "inode", "super", "ext2", - "malloc", "cache", "info", "ioctl", - "blocks", "net", "warning", "buffs", - "other", "dentry", "portals", "page", - "dlmtrace", "error", "emerg", "ha", - "rpctrace", "vfstrace", "reada", "mmap", - "config", NULL}; - -struct debug_daemon_cmd { - char *cmd; - unsigned int cmdv; -}; - -static const struct debug_daemon_cmd portal_debug_daemon_cmd[] = { - {"start", DEBUG_DAEMON_START}, - {"stop", DEBUG_DAEMON_STOP}, - {0, 0} -}; - -static int do_debug_mask(char *name, int enable) -{ - int found = 0, i; - - for (i = 0; portal_debug_subsystems[i] != NULL; i++) { - if (strcasecmp(name, portal_debug_subsystems[i]) == 0 || - strcasecmp(name, "all_subs") == 0) { - printf("%s output from subsystem \"%s\"\n", - enable ? "Enabling" : "Disabling", - portal_debug_subsystems[i]); - if (enable) - subsystem_mask |= (1 << i); - else - subsystem_mask &= ~(1 << i); - found = 1; - } - } - for (i = 0; portal_debug_masks[i] != NULL; i++) { - if (strcasecmp(name, portal_debug_masks[i]) == 0 || - strcasecmp(name, "all_types") == 0) { - printf("%s output of type \"%s\"\n", - enable ? "Enabling" : "Disabling", - portal_debug_masks[i]); - if (enable) - debug_mask |= (1 << i); - else - debug_mask &= ~(1 << i); - found = 1; - } - } - - return found; -} - -int dbg_initialize(int argc, char **argv) -{ - return 0; -} - -int jt_dbg_filter(int argc, char **argv) -{ - int i; - - if (argc < 2) { - fprintf(stderr, "usage: %s \n", - argv[0]); - return 0; - } - - for (i = 1; i < argc; i++) - if (!do_debug_mask(argv[i], 0)) - fprintf(stderr, "Unknown subsystem or debug type: %s\n", - argv[i]); - return 0; -} - -int jt_dbg_show(int argc, char **argv) -{ - int i; - - if (argc < 2) { - fprintf(stderr, "usage: %s \n", - argv[0]); - return 0; - } - - for (i = 1; i < argc; i++) - if (!do_debug_mask(argv[i], 1)) - fprintf(stderr, "Unknown subsystem or debug type: %s\n", - argv[i]); - - return 0; -} - -static int applymask(char* procpath, int value) -{ - int rc; - char buf[64]; - int len = snprintf(buf, 64, "%d", value); - - int fd = open(procpath, O_WRONLY); - if (fd == -1) { - fprintf(stderr, "Unable to open %s: %s\n", - procpath, strerror(errno)); - return fd; - } - rc = write(fd, buf, len+1); - if (rc<0) { - fprintf(stderr, "Write to %s failed: %s\n", - procpath, strerror(errno)); - return rc; - } - close(fd); - return 0; -} - -static void applymask_all(unsigned int subs_mask, unsigned int debug_mask) -{ - if (!dump_filename) { - applymask("/proc/sys/portals/subsystem_debug", subs_mask); - applymask("/proc/sys/portals/debug", debug_mask); - } else { - struct portals_debug_ioctl_data data; - - data.hdr.ioc_len = sizeof(data); - data.hdr.ioc_version = 0; - data.subs = subs_mask; - data.debug = debug_mask; - - dump(OBD_DEV_ID, PTL_IOC_DEBUG_MASK, &data); - } - printf("Applied subsystem_debug=%d, debug=%d to /proc/sys/portals\n", - subs_mask, debug_mask); -} - -int jt_dbg_list(int argc, char **argv) -{ - int i; - - if (argc != 2) { - fprintf(stderr, "usage: %s \n", argv[0]); - return 0; - } - - if (strcasecmp(argv[1], "subs") == 0) { - printf("Subsystems: all_subs"); - for (i = 0; portal_debug_subsystems[i] != NULL; i++) - printf(", %s", portal_debug_subsystems[i]); - printf("\n"); - } else if (strcasecmp(argv[1], "types") == 0) { - printf("Types: all_types"); - for (i = 0; portal_debug_masks[i] != NULL; i++) - printf(", %s", portal_debug_masks[i]); - printf("\n"); - } else if (strcasecmp(argv[1], "applymasks") == 0) { - applymask_all(subsystem_mask, debug_mask); - } - return 0; -} - -/* all strings nul-terminated; only the struct and hdr need to be freed */ -struct dbg_line { - struct ptldebug_header *hdr; - char *file; - char *fn; - char *text; - struct list_head chain; -}; - -/* nurr. */ -static void list_add_ordered(struct dbg_line *new, struct list_head *head) -{ - struct list_head *pos; - struct dbg_line *curr; - - list_for_each(pos, head) { - curr = list_entry(pos, struct dbg_line, chain); - - if (curr->hdr->ph_sec < new->hdr->ph_sec) - continue; - if (curr->hdr->ph_sec == new->hdr->ph_sec && - curr->hdr->ph_usec < new->hdr->ph_usec) - continue; - - list_add(&new->chain, pos->prev); - return; - } - list_add_tail(&new->chain, head); -} - -static void print_saved_records(struct list_head *list, FILE *out) -{ - struct list_head *pos, *tmp; - - list_for_each_safe(pos, tmp, list) { - struct dbg_line *line; - struct ptldebug_header *hdr; - - line = list_entry(pos, struct dbg_line, chain); - list_del(&line->chain); - - hdr = line->hdr; - fprintf(out, "%06x:%06x:%u:%u.%06Lu:%u:%u:%u:(%s:%u:%s()) %s", - hdr->ph_subsys, hdr->ph_mask, hdr->ph_cpu_id, - hdr->ph_sec, (unsigned long long)hdr->ph_usec, - hdr->ph_stack, hdr->ph_pid, hdr->ph_extern_pid, - line->file, hdr->ph_line_num, line->fn, line->text); - free(line->hdr); - free(line); - } -} - -static int parse_buffer(FILE *in, FILE *out) -{ - struct dbg_line *line; - struct ptldebug_header *hdr; - char buf[4097], *p; - int rc; - unsigned long dropped = 0, kept = 0; - struct list_head chunk_list; - - INIT_LIST_HEAD(&chunk_list); - - while (1) { - rc = fread(buf, sizeof(hdr->ph_len), 1, in); - if (rc <= 0) - break; - - hdr = (void *)buf; - if (hdr->ph_len == 0) - break; - if (hdr->ph_len > 4094) { - fprintf(stderr, "unexpected large record: %d bytes. " - "aborting.\n", - hdr->ph_len); - break; - } - - if (hdr->ph_flags & PH_FLAG_FIRST_RECORD) { - print_saved_records(&chunk_list, out); - assert(list_empty(&chunk_list)); - } - - rc = fread(buf + sizeof(hdr->ph_len), 1, - hdr->ph_len - sizeof(hdr->ph_len), in); - if (rc <= 0) - break; - - if (hdr->ph_mask && - (!(subsystem_mask & hdr->ph_subsys) || - (!(debug_mask & hdr->ph_mask)))) { - dropped++; - continue; - } - - line = malloc(sizeof(*line)); - if (line == NULL) { - fprintf(stderr, "malloc failed; printing accumulated " - "records and exiting.\n"); - break; - } - - line->hdr = malloc(hdr->ph_len + 1); - if (line->hdr == NULL) { - fprintf(stderr, "malloc failed; printing accumulated " - "records and exiting.\n"); - break; - } - - p = (void *)line->hdr; - memcpy(line->hdr, buf, hdr->ph_len); - p[hdr->ph_len] = '\0'; - - p += sizeof(*hdr); - line->file = p; - p += strlen(line->file) + 1; - line->fn = p; - p += strlen(line->fn) + 1; - line->text = p; - - list_add_ordered(line, &chunk_list); - kept++; - } - - print_saved_records(&chunk_list, out); - - printf("Debug log: %lu lines, %lu kept, %lu dropped.\n", - dropped + kept, kept, dropped); - return 0; -} - -int jt_dbg_debug_kernel(int argc, char **argv) -{ - char filename[4096]; - struct stat st; - int rc, raw = 0, fd; - FILE *in, *out = stdout; - - if (argc > 3) { - fprintf(stderr, "usage: %s [file] [raw]\n", argv[0]); - return 0; - } - - if (argc > 2) { - raw = atoi(argv[2]); - } else if (argc > 1 && (argv[1][0] == '0' || argv[1][0] == '1')) { - raw = atoi(argv[1]); - argc--; - } - - /* If we are dumping raw (which means no conversion step to ASCII) - * then dump directly to any supplied filename, otherwise this is - * just a temp file and we dump to the real file at convert time. */ - if (argc > 1 && raw) - strcpy(filename, argv[1]); - else - sprintf(filename, "/tmp/lustre-log.%lu.%u",time(NULL),getpid()); - - if (stat(filename, &st) == 0 && S_ISREG(st.st_mode)) - unlink(filename); - - fd = open("/proc/sys/portals/dump_kernel", O_WRONLY); - if (fd < 0) { - fprintf(stderr, "open(dump_kernel) failed: %s\n", - strerror(errno)); - return 1; - } - - rc = write(fd, filename, strlen(filename)); - if (rc != strlen(filename)) { - fprintf(stderr, "write(%s) failed: %s\n", filename, - strerror(errno)); - close(fd); - return 1; - } - close(fd); - - if (raw) - return 0; - - in = fopen(filename, "r"); - if (in == NULL) { - if (errno == ENOENT) /* no dump file created */ - return 0; - - fprintf(stderr, "fopen(%s) failed: %s\n", filename, - strerror(errno)); - return 1; - } - if (argc > 1) { - out = fopen(argv[1], "w"); - if (out == NULL) { - fprintf(stderr, "fopen(%s) failed: %s\n", argv[1], - strerror(errno)); - fclose(in); - return 1; - } - } - - rc = parse_buffer(in, out); - fclose(in); - if (argc > 1) - fclose(out); - if (rc) { - fprintf(stderr, "parse_buffer failed; leaving tmp file %s " - "behind.\n", filename); - } else { - rc = unlink(filename); - if (rc) - fprintf(stderr, "dumped successfully, but couldn't " - "unlink tmp file %s: %s\n", filename, - strerror(errno)); - } - return rc; -} - -int jt_dbg_debug_file(int argc, char **argv) -{ - int fdin,fdout; - FILE *in, *out = stdout; - if (argc > 3 || argc < 2) { - fprintf(stderr, "usage: %s [output]\n", argv[0]); - return 0; - } - - fdin = open(argv[1], O_RDONLY | O_LARGEFILE); - if (fdin == -1) { - fprintf(stderr, "open(%s) failed: %s\n", argv[1], - strerror(errno)); - return 1; - } - in = fdopen(fdin, "r"); - if (in == NULL) { - fprintf(stderr, "fopen(%s) failed: %s\n", argv[1], - strerror(errno)); - close(fdin); - return 1; - } - if (argc > 2) { - fdout = open(argv[2], O_CREAT | O_WRONLY | O_LARGEFILE); - if (fdout == -1) { - fprintf(stderr, "open(%s) failed: %s\n", argv[2], - strerror(errno)); - fclose(in); - return 1; - } - out = fdopen(fdout, "w"); - if (out == NULL) { - fprintf(stderr, "fopen(%s) failed: %s\n", argv[2], - strerror(errno)); - fclose(in); - close(fdout); - return 1; - } - } - - return parse_buffer(in, out); -} - -static int -dbg_write_cmd(int fd, char *str) -{ - int len = strlen(str); - int rc = write(fd, str, len); - - return (rc == len ? 0 : 1); -} - -const char debug_daemon_usage[] = "usage: %s {start file [MB]|stop}\n"; -#define DAEMON_FILE "/proc/sys/portals/daemon_file" -int jt_dbg_debug_daemon(int argc, char **argv) -{ - int rc; - int fd; - - if (argc <= 1) { - fprintf(stderr, debug_daemon_usage, argv[0]); - return 1; - } - - fd = open(DAEMON_FILE, O_WRONLY); - if (fd < 0) { - fprintf(stderr, "open %s failed: %s\n", DAEMON_FILE, - strerror(errno)); - return -1; - } - - rc = -1; - if (strcasecmp(argv[1], "start") == 0) { - if (argc < 3 || argc > 4 || - (argc == 4 && strlen(argv[3]) > 5)) { - fprintf(stderr, debug_daemon_usage, argv[0]); - goto out; - } - - if (argc == 4) { - char buf[12]; - const long min_size = 10; - const long max_size = 20480; - long size; - char *end; - - size = strtoul(argv[3], &end, 0); - if (size < min_size || - size > max_size || - *end != 0) { - fprintf(stderr, "size %s invalid, must be in " - "the range %ld-%ld MB\n", argv[3], - min_size, max_size); - goto out; - } - - snprintf(buf, sizeof(buf), "size=%ld", size); - rc = dbg_write_cmd(fd, buf); - if (rc != 0) { - fprintf(stderr, "set %s failed: %s\n", - buf, strerror(errno)); - goto out; - } - } - - rc = dbg_write_cmd(fd, "start"); - if (rc != 0) { - fprintf(stderr, "start debug_daemon on %s failed: %s\n", - argv[2], strerror(errno)); - goto out; - } - - rc = 0; - goto out; - } - - if (strcasecmp(argv[1], "stop") == 0) { - rc = dbg_write_cmd(fd, "stop"); - if (rc != 0) { - fprintf(stderr, "stopping debug_daemon failed: %s\n", - strerror(errno)); - goto out; - } - - rc = 0; - goto out; - } - - fprintf(stderr, debug_daemon_usage, argv[0]); - rc = -1; -out: - close(fd); - return rc; -} - -int jt_dbg_clear_debug_buf(int argc, char **argv) -{ - int rc; - struct portal_ioctl_data data; - - if (argc != 1) { - fprintf(stderr, "usage: %s\n", argv[0]); - return 0; - } - - memset(&data, 0, sizeof(data)); - if (portal_ioctl_pack(&data, &buf, max) != 0) { - fprintf(stderr, "portal_ioctl_pack failed.\n"); - return -1; - } - - rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_CLEAR_DEBUG, buf); - if (rc) { - fprintf(stderr, "IOC_PORTAL_CLEAR_DEBUG failed: %s\n", - strerror(errno)); - return -1; - } - return 0; -} - -int jt_dbg_mark_debug_buf(int argc, char **argv) -{ - int rc, max_size = MAX_MARK_SIZE-1; - struct portal_ioctl_data data; - char *text; - time_t now = time(NULL); - - if (argc > 1) { - int counter; - text = malloc(MAX_MARK_SIZE); - strncpy(text, argv[1], max_size); - max_size-=strlen(argv[1]); - for(counter = 2; (counter < argc) && (max_size > 0) ; counter++){ - strncat(text, " ", 1); - max_size-=1; - strncat(text, argv[counter], max_size); - max_size-=strlen(argv[counter]); - } - } else { - text = ctime(&now); - text[strlen(text) - 1] = '\0'; /* stupid \n */ - } - if (!max_size) { - text[MAX_MARK_SIZE - 1] = '\0'; - } - - memset(&data, 0, sizeof(data)); - data.ioc_inllen1 = strlen(text) + 1; - data.ioc_inlbuf1 = text; - if (portal_ioctl_pack(&data, &buf, max) != 0) { - fprintf(stderr, "portal_ioctl_pack failed.\n"); - return -1; - } - - rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_MARK_DEBUG, buf); - if (rc) { - fprintf(stderr, "IOC_PORTAL_MARK_DEBUG failed: %s\n", - strerror(errno)); - return -1; - } - return 0; -} - -static struct mod_paths { - char *name, *path; -} mod_paths[] = { - {"libcfs", "lustre/portals/libcfs"}, - {"portals", "lustre/portals/portals"}, - {"ksocknal", "lustre/portals/knals/socknal"}, - {"kptlrouter", "lustre/portals/router"}, - {"lvfs", "lustre/lvfs"}, - {"obdclass", "lustre/obdclass"}, - {"llog_test", "lustre/obdclass"}, - {"ptlrpc", "lustre/ptlrpc"}, - {"obdext2", "lustre/obdext2"}, - {"ost", "lustre/ost"}, - {"osc", "lustre/osc"}, - {"mds", "lustre/mds"}, - {"mdc", "lustre/mdc"}, - {"llite", "lustre/llite"}, - {"ldiskfs", "lustre/ldiskfs"}, - {"smfs", "lustre/smfs"}, - {"obdecho", "lustre/obdecho"}, - {"ldlm", "lustre/ldlm"}, - {"obdfilter", "lustre/obdfilter"}, - {"extN", "lustre/extN"}, - {"lov", "lustre/lov"}, - {"lmv", "lustre/lmv"}, - {"fsfilt_ext3", "lustre/lvfs"}, - {"fsfilt_extN", "lustre/lvfs"}, - {"fsfilt_reiserfs", "lustre/lvfs"}, - {"fsfilt_smfs", "lustre/lvfs"}, - {"fsfilt_ldiskfs", "lustre/lvfs"}, - {"mds_ext2", "lustre/mds"}, - {"mds_ext3", "lustre/mds"}, - {"mds_extN", "lustre/mds"}, - {"ptlbd", "lustre/ptlbd"}, - {"mgmt_svc", "lustre/mgmt"}, - {"mgmt_cli", "lustre/mgmt"}, - {"cobd", "lustre/cobd"}, - {"cmobd", "lustre/cmobd"}, - {"conf_obd", "lustre/obdclass"}, - {NULL, NULL} -}; - -static int jt_dbg_modules_2_4(int argc, char **argv) -{ -#ifdef HAVE_LINUX_VERSION_H -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - struct mod_paths *mp; - char *path = ".."; - char *kernel = "linux"; - - if (argc >= 2) - path = argv[1]; - if (argc == 3) - kernel = argv[2]; - if (argc > 3) { - printf("%s [path] [kernel]\n", argv[0]); - return 0; - } - - for (mp = mod_paths; mp->name != NULL; mp++) { - struct module_info info; - int rc; - size_t crap; - int query_module(const char *name, int which, void *buf, - size_t bufsize, size_t *ret); - - rc = query_module(mp->name, QM_INFO, &info, sizeof(info), - &crap); - if (rc < 0) { - if (errno != ENOENT) - printf("query_module(%s) failed: %s\n", - mp->name, strerror(errno)); - } else { - printf("add-symbol-file %s/%s/%s.o 0x%0lx\n", path, - mp->path, mp->name, - info.addr + sizeof(struct module)); - } - } - - return 0; -#endif /* Headers are 2.6-only */ -#endif /* !HAVE_LINUX_VERSION_H */ - return -EINVAL; -} - -static int jt_dbg_modules_2_5(int argc, char **argv) -{ - struct mod_paths *mp; - char *path = ".."; - char *kernel = "linux"; - const char *proc = "/proc/modules"; - char modname[128], others[128]; - long modaddr; - int rc; - FILE *file; - - if (argc >= 2) - path = argv[1]; - if (argc == 3) - kernel = argv[2]; - if (argc > 3) { - printf("%s [path] [kernel]\n", argv[0]); - return 0; - } - - file = fopen(proc, "r"); - if (!file) { - printf("failed open %s: %s\n", proc, strerror(errno)); - return 0; - } - - while ((rc = fscanf(file, "%s %s %s %s %s %lx\n", - modname, others, others, others, others, &modaddr)) == 6) { - for (mp = mod_paths; mp->name != NULL; mp++) { - if (!strcmp(mp->name, modname)) - break; - } - if (mp->name) { - printf("add-symbol-file %s/%s/%s.o 0x%0lx\n", path, - mp->path, mp->name, modaddr); - } - } - - return 0; -} - -int jt_dbg_modules(int argc, char **argv) -{ - int rc = 0; - struct utsname sysinfo; - - rc = uname(&sysinfo); - if (rc) { - printf("uname() failed: %s\n", strerror(errno)); - return 0; - } - - if (sysinfo.release[2] > '4') { - return jt_dbg_modules_2_5(argc, argv); - } else { - return jt_dbg_modules_2_4(argc, argv); - } - - return 0; -} - -int jt_dbg_panic(int argc, char **argv) -{ - int rc; - struct portal_ioctl_data data; - - if (argc != 1) { - fprintf(stderr, "usage: %s\n", argv[0]); - return 0; - } - - memset(&data, 0, sizeof(data)); - if (portal_ioctl_pack(&data, &buf, max) != 0) { - fprintf(stderr, "portal_ioctl_pack failed.\n"); - return -1; - } - - rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_PANIC, buf); - if (rc) { - fprintf(stderr, "IOC_PORTAL_PANIC failed: %s\n", - strerror(errno)); - return -1; - } - return 0; -} diff --git a/lnet/utils/debugctl.c b/lnet/utils/debugctl.c deleted file mode 100644 index 1b6cd96..0000000 --- a/lnet/utils/debugctl.c +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Some day I'll split all of this functionality into a cfs_debug module - * of its own. That day is not today. - * - */ - -#include -#include -#include -#include -#include "parser.h" - - -command_t list[] = { - {"debug_kernel", jt_dbg_debug_kernel, 0, "usage: debug_kernel [file] [raw], get debug buffer and print it [to a file]"}, - {"debug_daemon", jt_dbg_debug_daemon, 0, "usage: debug_daemon [start file|stop], control debug daemon to dump debug buffer to a file"}, - {"debug_file", jt_dbg_debug_file, 0, "usage: debug_file [output] [raw], read debug buffer from input and print it [to output]"}, - {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer"}, - {"mark", jt_dbg_mark_debug_buf, 0, "insert a marker into the kernel debug buffer (args: [marker text])"}, - {"filter", jt_dbg_filter, 0, "filter certain messages (args: subsystem/debug ID)\n"}, - {"show", jt_dbg_show, 0, "enable certain messages (args: subsystem/debug ID)\n"}, - {"list", jt_dbg_list, 0, "list subsystem and debug types (args: subs or types)\n"}, - {"modules", jt_dbg_modules, 0, "provide gdb-friendly module info (arg: )"}, - {"panic", jt_dbg_panic, 0, "cause the kernel to panic"}, - {"dump", jt_ioc_dump, 0, "usage: dump file, save ioctl buffer to file"}, - {"help", Parser_help, 0, "help"}, - {"exit", Parser_quit, 0, "quit"}, - {"quit", Parser_quit, 0, "quit"}, - { 0, 0, 0, NULL } -}; - -int main(int argc, char **argv) -{ - if (dbg_initialize(argc, argv) < 0) - exit(2); - - register_ioc_dev(PORTALS_DEV_ID, PORTALS_DEV_PATH); - - Parser_init("debugctl > ", list); - if (argc > 1) - return Parser_execarg(argc - 1, &argv[1], list); - - Parser_commands(); - - unregister_ioc_dev(PORTALS_DEV_ID); - return 0; -} diff --git a/lnet/utils/gmlndnid.c b/lnet/utils/gmlndnid.c deleted file mode 100644 index e45fae4..0000000 --- a/lnet/utils/gmlndnid.c +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2003 Los Alamos National Laboratory (LANL) - * - * This file is part of Lustre, http://www.lustre.org/ - * - * This file is free software; you can redistribute it and/or - * modify it under the terms of version 2.1 of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define GMNAL_IOC_GET_GNID 1 - -int -roundup(int len) -{ - return((len+7) & (~0x7)); -} - -int main(int argc, char **argv) -{ - int rc, pfd; - struct portal_ioctl_data data; - struct portals_cfg pcfg; - unsigned int nid = 0, len; - char *name = NULL; - int c; - - - - while ((c = getopt(argc, argv, "n:l")) != -1) { - switch(c) { - case('n'): - name = optarg; - break; - case('l'): - printf("Get local id not implemented yet!\n"); - exit(-1); - default: - printf("usage %s -n nodename [-p]\n", argv[0]); - } - } - - if (!name) { - printf("usage %s -n nodename [-p]\n", argv[0]); - exit(-1); - } - - - - - PCFG_INIT(pcfg, GMNAL_IOC_GET_GNID); - pcfg.pcfg_nal = GMNAL; - - /* - * set up the inputs - */ - len = strlen(name) + 1; - pcfg.pcfg_pbuf1 = malloc(len); - strcpy(pcfg.pcfg_pbuf1, name); - pcfg.pcfg_plen1 = len; - - /* - * set up the outputs - */ - pcfg.pcfg_pbuf2 = (void*)&nid; - pcfg.pcfg_plen2 = sizeof(unsigned int*); - - pfd = open("/dev/portals", O_RDWR); - if ( pfd < 0 ) { - perror("opening portals device"); - free(pcfg.pcfg_pbuf1); - exit(-1); - } - - PORTAL_IOC_INIT(data); - data.ioc_pbuf1 = (char*)&pcfg; - data.ioc_plen1 = sizeof(pcfg); - - rc = ioctl (pfd, IOC_PORTAL_NAL_CMD, &data); - if (rc < 0) - { - perror ("Can't get my NID"); - } - - free(pcfg.pcfg_pbuf1); - close(pfd); - printf("%u\n", nid); - exit(0); -} diff --git a/lnet/utils/l_ioctl.c b/lnet/utils/l_ioctl.c deleted file mode 100644 index 0671c24..0000000 --- a/lnet/utils/l_ioctl.c +++ /dev/null @@ -1,339 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#define __USE_FILE_OFFSET64 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifndef __CYGWIN__ - #include -#else - #include - #include -#endif - -static ioc_handler_t do_ioctl; /* forward ref */ -static ioc_handler_t *current_ioc_handler = &do_ioctl; - -struct ioc_dev { - const char * dev_name; - int dev_fd; -}; - -static struct ioc_dev ioc_dev_list[10]; - -struct dump_hdr { - int magic; - int dev_id; - unsigned int opc; -}; - -char *dump_filename; - -void -set_ioc_handler (ioc_handler_t *handler) -{ - if (handler == NULL) - current_ioc_handler = do_ioctl; - else - current_ioc_handler = handler; -} - -static int -open_ioc_dev(int dev_id) -{ - const char * dev_name; - - if (dev_id < 0 || dev_id >= sizeof(ioc_dev_list)) - return -EINVAL; - - dev_name = ioc_dev_list[dev_id].dev_name; - if (dev_name == NULL) { - fprintf(stderr, "unknown device id: %d\n", dev_id); - return -EINVAL; - } - - if (ioc_dev_list[dev_id].dev_fd < 0) { - int fd = open(dev_name, O_RDWR); - - if (fd < 0) { - fprintf(stderr, "opening %s failed: %s\n" - "hint: the kernel modules may not be loaded\n", - dev_name, strerror(errno)); - return fd; - } - ioc_dev_list[dev_id].dev_fd = fd; - } - - return ioc_dev_list[dev_id].dev_fd; -} - - -static int -do_ioctl(int dev_id, unsigned int opc, void *buf) -{ - int fd, rc; - - fd = open_ioc_dev(dev_id); - if (fd < 0) - return fd; - - rc = ioctl(fd, opc, buf); - return rc; - -} - -static FILE * -get_dump_file() -{ - FILE *fp = NULL; - - if (!dump_filename) { - fprintf(stderr, "no dump filename\n"); - } else - fp = fopen(dump_filename, "a"); - return fp; -} - -/* - * The dump file should start with a description of which devices are - * used, but for now it will assumed whatever app reads the file will - * know what to do. */ -int -dump(int dev_id, unsigned int opc, void *buf) -{ - FILE *fp; - struct dump_hdr dump_hdr; - struct portal_ioctl_hdr * ioc_hdr = (struct portal_ioctl_hdr *) buf; - int rc; - - printf("dumping opc %x to %s\n", opc, dump_filename); - - - dump_hdr.magic = 0xdeadbeef; - dump_hdr.dev_id = dev_id; - dump_hdr.opc = opc; - - fp = get_dump_file(); - if (fp == NULL) { - fprintf(stderr, "%s: %s\n", dump_filename, - strerror(errno)); - return -EINVAL; - } - - rc = fwrite(&dump_hdr, sizeof(dump_hdr), 1, fp); - if (rc == 1) - rc = fwrite(buf, ioc_hdr->ioc_len, 1, fp); - fclose(fp); - if (rc != 1) { - fprintf(stderr, "%s: %s\n", dump_filename, - strerror(errno)); - return -EINVAL; - } - - return 0; -} - -/* register a device to send ioctls to. */ -int -register_ioc_dev(int dev_id, const char * dev_name) -{ - - if (dev_id < 0 || dev_id >= sizeof(ioc_dev_list)) - return -EINVAL; - - unregister_ioc_dev(dev_id); - - ioc_dev_list[dev_id].dev_name = dev_name; - ioc_dev_list[dev_id].dev_fd = -1; - - return dev_id; -} - -void -unregister_ioc_dev(int dev_id) -{ - - if (dev_id < 0 || dev_id >= sizeof(ioc_dev_list)) - return; - if (ioc_dev_list[dev_id].dev_name != NULL && - ioc_dev_list[dev_id].dev_fd >= 0) - close(ioc_dev_list[dev_id].dev_fd); - - ioc_dev_list[dev_id].dev_name = NULL; - ioc_dev_list[dev_id].dev_fd = -1; -} - -/* If this file is set, then all ioctl buffers will be - appended to the file. */ -int -set_ioctl_dump(char * file) -{ - if (dump_filename) - free(dump_filename); - - dump_filename = strdup(file); - if (dump_filename == NULL) - abort(); - - set_ioc_handler(&dump); - return 0; -} - -int -l_ioctl(int dev_id, unsigned int opc, void *buf) -{ - return current_ioc_handler(dev_id, opc, buf); -} - -/* Read an ioctl dump file, and call the ioc_func for each ioctl buffer - * in the file. For example: - * - * parse_dump("lctl.dump", l_ioctl); - * - * Note: if using l_ioctl, then you also need to register_ioc_dev() for - * each device used in the dump. - */ -int -parse_dump(char * dump_file, ioc_handler_t ioc_func) -{ - int line =0; - struct stat st; - char *start, *buf, *end; -#ifndef __CYGWIN__ - int fd; -#else - HANDLE fd, hmap; - DWORD size; -#endif - -#ifndef __CYGWIN__ - fd = syscall(SYS_open, dump_file, O_RDONLY); - if (fd < 0) { - fprintf(stderr, "couldn't open %s: %s\n", dump_file, - strerror(errno)); - exit(1); - } - - if (fstat(fd, &st)) { - perror("stat fails"); - exit(1); - } - - if (st.st_size < 1) { - fprintf(stderr, "KML is empty\n"); - exit(1); - } - - start = buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE , fd, 0); - end = start + st.st_size; - close(fd); - if (start == MAP_FAILED) { - fprintf(stderr, "can't create file mapping\n"); - exit(1); - } -#else - fd = CreateFile(dump_file, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - size = GetFileSize(fd, NULL); - if (size < 1) { - fprintf(stderr, "KML is empty\n"); - exit(1); - } - - hmap = CreateFileMapping(fd, NULL, PAGE_READONLY, 0,0, NULL); - start = buf = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0); - end = buf + size; - CloseHandle(fd); - if (start == NULL) { - fprintf(stderr, "can't create file mapping\n"); - exit(1); - } -#endif /* __CYGWIN__ */ - - while (buf < end) { - struct dump_hdr *dump_hdr = (struct dump_hdr *) buf; - struct portal_ioctl_hdr * data; - char tmp[8096]; - int rc; - - line++; - - data = (struct portal_ioctl_hdr *) (buf + sizeof(*dump_hdr)); - if (buf + data->ioc_len > end ) { - fprintf(stderr, "dump file overflow, %p + %d > %p\n", buf, - data->ioc_len, end); - return -1; - } -#if 0 - printf ("dump_hdr: %lx data: %lx\n", - (unsigned long)dump_hdr - (unsigned long)buf, (unsigned long)data - (unsigned long)buf); - - printf("%d: opcode %x len: %d ver: %x ", line, dump_hdr->opc, - data->ioc_len, data->ioc_version); -#endif - - memcpy(tmp, data, data->ioc_len); - - rc = ioc_func(dump_hdr->dev_id, dump_hdr->opc, tmp); - if (rc) { - printf("failed: %d\n", rc); - exit(1); - } - - buf += data->ioc_len + sizeof(*dump_hdr); - } - -#ifndef __CYGWIN__ - munmap(start, end - start); -#else - UnmapViewOfFile(start); - CloseHandle(hmap); -#endif - - return 0; -} - -int -jt_ioc_dump(int argc, char **argv) -{ - if (argc > 2) { - fprintf(stderr, "usage: %s [hostname]\n", argv[0]); - return 0; - } - printf("setting dumpfile to: %s\n", argv[1]); - - set_ioctl_dump(argv[1]); - return 0; -} diff --git a/lnet/utils/parser.c b/lnet/utils/parser.c deleted file mode 100644 index b91295b..0000000 --- a/lnet/utils/parser.c +++ /dev/null @@ -1,651 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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. - * - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_LIBREADLINE -#define READLINE_LIBRARY -#include - -/* completion_matches() is #if 0-ed out in modern glibc */ -#ifndef completion_matches -# define completion_matches rl_completion_matches -#endif -#endif - -extern void using_history(void); -extern void stifle_history(int); -extern void add_history(char *); - -#include "parser.h" - -static command_t * top_level; /* Top level of commands, initialized by - * InitParser */ -static char * parser_prompt = NULL;/* Parser prompt, set by InitParser */ -static int done; /* Set to 1 if user types exit or quit */ - - -/* static functions */ -static char *skipwhitespace(char *s); -static char *skiptowhitespace(char *s); -static command_t *find_cmd(char *name, command_t cmds[], char **next); -static int process(char *s, char **next, command_t *lookup, command_t **result, - char **prev); -static void print_commands(char *str, command_t *table); - -static char * skipwhitespace(char * s) -{ - char * t; - int len; - - len = (int)strlen(s); - for (t = s; t <= s + len && isspace(*t); t++); - return(t); -} - - -static char * skiptowhitespace(char * s) -{ - char * t; - - for (t = s; *t && !isspace(*t); t++); - return(t); -} - -static int line2args(char *line, char **argv, int maxargs) -{ - char *arg; - int i = 0; - - arg = strtok(line, " \t"); - if ( arg ) { - argv[i] = arg; - i++; - } else - return 0; - - while( (arg = strtok(NULL, " \t")) && (i <= maxargs)) { - argv[i] = arg; - i++; - } - return i; -} - -/* find a command -- return it if unique otherwise print alternatives */ -static command_t *Parser_findargcmd(char *name, command_t cmds[]) -{ - command_t *cmd; - - for (cmd = cmds; cmd->pc_name; cmd++) { - if (strcmp(name, cmd->pc_name) == 0) - return cmd; - } - return NULL; -} - -int Parser_execarg(int argc, char **argv, command_t cmds[]) -{ - command_t *cmd; - - cmd = Parser_findargcmd(argv[0], cmds); - if ( cmd ) { - int rc = (cmd->pc_func)(argc, argv); - if (rc == CMD_HELP) - fprintf(stderr, "%s\n", cmd->pc_help); - return rc; - } else { - printf("Try interactive use without arguments or use one of:\n"); - for (cmd = cmds; cmd->pc_name; cmd++) - printf("\"%s\" ", cmd->pc_name); - printf("\nas argument.\n"); - } - return -1; -} - -/* returns the command_t * (NULL if not found) corresponding to a - _partial_ match with the first token in name. It sets *next to - point to the following token. Does not modify *name. */ -static command_t * find_cmd(char * name, command_t cmds[], char ** next) -{ - int i, len; - - if (!cmds || !name ) - return NULL; - - /* This sets name to point to the first non-white space character, - and next to the first whitespace after name, len to the length: do - this with strtok*/ - name = skipwhitespace(name); - *next = skiptowhitespace(name); - len = *next - name; - if (len == 0) - return NULL; - - for (i = 0; cmds[i].pc_name; i++) { - if (strncasecmp(name, cmds[i].pc_name, len) == 0) { - *next = skipwhitespace(*next); - return(&cmds[i]); - } - } - return NULL; -} - -/* Recursively process a command line string s and find the command - corresponding to it. This can be ambiguous, full, incomplete, - non-existent. */ -static int process(char *s, char ** next, command_t *lookup, - command_t **result, char **prev) -{ - *result = find_cmd(s, lookup, next); - *prev = s; - - /* non existent */ - if ( ! *result ) - return CMD_NONE; - - /* found entry: is it ambigous, i.e. not exact command name and - more than one command in the list matches. Note that find_cmd - points to the first ambiguous entry */ - if ( strncasecmp(s, (*result)->pc_name, strlen((*result)->pc_name)) && - find_cmd(s, (*result) + 1, next)) - return CMD_AMBIG; - - /* found a unique command: component or full? */ - if ( (*result)->pc_func ) { - return CMD_COMPLETE; - } else { - if ( *next == '\0' ) { - return CMD_INCOMPLETE; - } else { - return process(*next, next, (*result)->pc_sub_cmd, result, prev); - } - } -} - -#ifdef HAVE_LIBREADLINE -static command_t * match_tbl; /* Command completion against this table */ -static char * command_generator(const char * text, int state) -{ - static int index, - len; - char *name; - - /* Do we have a match table? */ - if (!match_tbl) - return NULL; - - /* If this is the first time called on this word, state is 0 */ - if (!state) { - index = 0; - len = (int)strlen(text); - } - - /* Return next name in the command list that paritally matches test */ - while ( (name = (match_tbl + index)->pc_name) ) { - index++; - - if (strncasecmp(name, text, len) == 0) { - return(strdup(name)); - } - } - - /* No more matches */ - return NULL; -} - -/* probably called by readline */ -static char **command_completion(char * text, int start, int end) -{ - command_t * table; - char * pos; - - match_tbl = top_level; - - for (table = find_cmd(rl_line_buffer, match_tbl, &pos); - table; table = find_cmd(pos, match_tbl, &pos)) - { - - if (*(pos - 1) == ' ') match_tbl = table->pc_sub_cmd; - } - - return completion_matches(text, command_generator); -} -#endif - -/* take a string and execute the function or print help */ -int execute_line(char * line) -{ - command_t *cmd, *ambig; - char *prev; - char *next, *tmp; - char *argv[MAXARGS]; - int i; - int rc = 0; - - switch( process(line, &next, top_level, &cmd, &prev) ) { - case CMD_AMBIG: - fprintf(stderr, "Ambiguous command \'%s\'\nOptions: ", line); - while( (ambig = find_cmd(prev, cmd, &tmp)) ) { - fprintf(stderr, "%s ", ambig->pc_name); - cmd = ambig + 1; - } - fprintf(stderr, "\n"); - break; - case CMD_NONE: - fprintf(stderr, "No such command, type help\n"); - break; - case CMD_INCOMPLETE: - fprintf(stderr, - "'%s' incomplete command. Use '%s x' where x is one of:\n", - line, line); - fprintf(stderr, "\t"); - for (i = 0; cmd->pc_sub_cmd[i].pc_name; i++) { - fprintf(stderr, "%s ", cmd->pc_sub_cmd[i].pc_name); - } - fprintf(stderr, "\n"); - break; - case CMD_COMPLETE: - i = line2args(line, argv, MAXARGS); - rc = (cmd->pc_func)(i, argv); - - if (rc == CMD_HELP) - fprintf(stderr, "%s\n", cmd->pc_help); - - break; - } - - return rc; -} - -int -noop_fn () -{ - return (0); -} - -/* just in case you're ever in an airplane and discover you - forgot to install readline-dev. :) */ -int init_input() -{ - int interactive = isatty (fileno (stdin)); - -#ifdef HAVE_LIBREADLINE - using_history(); - stifle_history(HISTORY); - - if (!interactive) - { - rl_prep_term_function = (rl_vintfunc_t *)noop_fn; - rl_deprep_term_function = (rl_voidfunc_t *)noop_fn; - } - - rl_attempted_completion_function = (CPPFunction *)command_completion; - rl_completion_entry_function = (void *)command_generator; -#endif - return interactive; -} - -#ifndef HAVE_LIBREADLINE -#define add_history(s) -char * readline(char * prompt) -{ - char line[2048]; - int n = 0; - if (prompt) - printf ("%s", prompt); - if (fgets(line, sizeof(line), stdin) == NULL) - return (NULL); - n = strlen(line); - if (n && line[n-1] == '\n') - line[n-1] = '\0'; - return strdup(line); -} -#endif - -/* this is the command execution machine */ -int Parser_commands(void) -{ - char *line, *s; - int rc = 0; - int interactive; - - interactive = init_input(); - - while(!done) { - line = readline(interactive ? parser_prompt : NULL); - - if (!line) break; - - s = skipwhitespace(line); - - if (*s) { - add_history(s); - rc = execute_line(s); - } - - free(line); - } - return rc; -} - - -/* sets the parser prompt */ -void Parser_init(char * prompt, command_t * cmds) -{ - done = 0; - top_level = cmds; - if (parser_prompt) free(parser_prompt); - parser_prompt = strdup(prompt); -} - -/* frees the parser prompt */ -void Parser_exit(int argc, char *argv[]) -{ - done = 1; - free(parser_prompt); - parser_prompt = NULL; -} - -/* convert a string to an integer */ -int Parser_int(char *s, int *val) -{ - int ret; - - if (*s != '0') - ret = sscanf(s, "%d", val); - else if (*(s+1) != 'x') - ret = sscanf(s, "%o", val); - else { - s++; - ret = sscanf(++s, "%x", val); - } - - return(ret); -} - - -void Parser_qhelp(int argc, char *argv[]) { - - printf("Available commands are:\n"); - - print_commands(NULL, top_level); - printf("For more help type: help command-name\n"); -} - -int Parser_help(int argc, char **argv) -{ - char line[1024]; - char *next, *prev, *tmp; - command_t *result, *ambig; - int i; - - if ( argc == 1 ) { - Parser_qhelp(argc, argv); - return 0; - } - - line[0]='\0'; - for ( i = 1 ; i < argc ; i++ ) { - strcat(line, argv[i]); - } - - switch ( process(line, &next, top_level, &result, &prev) ) { - case CMD_COMPLETE: - fprintf(stderr, "%s: %s\n",line, result->pc_help); - break; - case CMD_NONE: - fprintf(stderr, "%s: Unknown command.\n", line); - break; - case CMD_INCOMPLETE: - fprintf(stderr, - "'%s' incomplete command. Use '%s x' where x is one of:\n", - line, line); - fprintf(stderr, "\t"); - for (i = 0; result->pc_sub_cmd[i].pc_name; i++) { - fprintf(stderr, "%s ", result->pc_sub_cmd[i].pc_name); - } - fprintf(stderr, "\n"); - break; - case CMD_AMBIG: - fprintf(stderr, "Ambiguous command \'%s\'\nOptions: ", line); - while( (ambig = find_cmd(prev, result, &tmp)) ) { - fprintf(stderr, "%s ", ambig->pc_name); - result = ambig + 1; - } - fprintf(stderr, "\n"); - break; - } - return 0; -} - - -void Parser_printhelp(char *cmd) -{ - char *argv[] = { "help", cmd }; - Parser_help(2, argv); -} - -/************************************************************************* - * COMMANDS * - *************************************************************************/ - - -static void print_commands(char * str, command_t * table) { - command_t * cmds; - char buf[80]; - - for (cmds = table; cmds->pc_name; cmds++) { - if (cmds->pc_func) { - if (str) printf("\t%s %s\n", str, cmds->pc_name); - else printf("\t%s\n", cmds->pc_name); - } - if (cmds->pc_sub_cmd) { - if (str) { - sprintf(buf, "%s %s", str, cmds->pc_name); - print_commands(buf, cmds->pc_sub_cmd); - } else { - print_commands(cmds->pc_name, cmds->pc_sub_cmd); - } - } - } -} - -char *Parser_getstr(const char *prompt, const char *deft, char *res, - size_t len) -{ - char *line = NULL; - int size = strlen(prompt) + strlen(deft) + 8; - char *theprompt; - theprompt = malloc(size); - assert(theprompt); - - sprintf(theprompt, "%s [%s]: ", prompt, deft); - - line = readline(theprompt); - free(theprompt); - - if ( line == NULL || *line == '\0' ) { - strncpy(res, deft, len); - } else { - strncpy(res, line, len); - } - - if ( line ) { - free(line); - return res; - } else { - return NULL; - } -} - -/* get integer from prompt, loop forever to get it */ -int Parser_getint(const char *prompt, long min, long max, long deft, int base) -{ - int rc; - long result; - char *line; - int size = strlen(prompt) + 40; - char *theprompt = malloc(size); - assert(theprompt); - sprintf(theprompt,"%s [%ld, (0x%lx)]: ", prompt, deft, deft); - - fflush(stdout); - - do { - line = NULL; - line = readline(theprompt); - if ( !line ) { - fprintf(stdout, "Please enter an integer.\n"); - fflush(stdout); - continue; - } - if ( *line == '\0' ) { - free(line); - result = deft; - break; - } - rc = Parser_arg2int(line, &result, base); - free(line); - if ( rc != 0 ) { - fprintf(stdout, "Invalid string.\n"); - fflush(stdout); - } else if ( result > max || result < min ) { - fprintf(stdout, "Error: response must lie between %ld and %ld.\n", - min, max); - fflush(stdout); - } else { - break; - } - } while ( 1 ) ; - - if (theprompt) - free(theprompt); - return result; - -} - -/* get boolean (starting with YyNn; loop forever */ -int Parser_getbool(const char *prompt, int deft) -{ - int result = 0; - char *line; - int size = strlen(prompt) + 8; - char *theprompt = malloc(size); - assert(theprompt); - - fflush(stdout); - - if ( deft != 0 && deft != 1 ) { - fprintf(stderr, "Error: Parser_getbool given bad default (%d).\n", - deft); - assert ( 0 ); - } - sprintf(theprompt, "%s [%s]: ", prompt, (deft==0)? "N" : "Y"); - - do { - line = NULL; - line = readline(theprompt); - if ( line == NULL ) { - result = deft; - break; - } - if ( *line == '\0' ) { - result = deft; - break; - } - if ( *line == 'y' || *line == 'Y' ) { - result = 1; - break; - } - if ( *line == 'n' || *line == 'N' ) { - result = 0; - break; - } - if ( line ) - free(line); - fprintf(stdout, "Invalid string. Must start with yY or nN\n"); - fflush(stdout); - } while ( 1 ); - - if ( line ) - free(line); - if ( theprompt ) - free(theprompt); - return result; -} - -/* parse int out of a string or prompt for it */ -long Parser_intarg(const char *inp, const char *prompt, int deft, - int min, int max, int base) -{ - long result; - int rc; - - rc = Parser_arg2int(inp, &result, base); - - if ( rc == 0 ) { - return result; - } else { - return Parser_getint(prompt, deft, min, max, base); - } -} - -/* parse int out of a string or prompt for it */ -char *Parser_strarg(char *inp, const char *prompt, const char *deft, - char *answer, int len) -{ - if ( inp == NULL || *inp == '\0' ) { - return Parser_getstr(prompt, deft, answer, len); - } else - return inp; -} - -/* change a string into a number: return 0 on success. No invalid characters - allowed. The processing of base and validity follows strtol(3)*/ -int Parser_arg2int(const char *inp, long *result, int base) -{ - char *endptr; - - if ( (base !=0) && (base < 2 || base > 36) ) - return 1; - - *result = strtol(inp, &endptr, base); - - if ( *inp != '\0' && *endptr == '\0' ) - return 0; - else - return 1; -} - -int Parser_quit(int argc, char **argv) -{ - argc = argc; - argv = argv; - done = 1; - return 0; -} diff --git a/lnet/utils/parser.h b/lnet/utils/parser.h deleted file mode 100644 index 9e7e95a..0000000 --- a/lnet/utils/parser.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _PARSER_H_ -#define _PARSER_H_ - -#define HISTORY 100 /* Don't let history grow unbounded */ -#define MAXARGS 512 - -#define CMD_COMPLETE 0 -#define CMD_INCOMPLETE 1 -#define CMD_NONE 2 -#define CMD_AMBIG 3 -#define CMD_HELP 4 - -typedef struct parser_cmd { - char *pc_name; - int (* pc_func)(int, char **); - struct parser_cmd * pc_sub_cmd; - char *pc_help; -} command_t; - -typedef struct argcmd { - char *ac_name; - int (*ac_func)(int, char **); - char *ac_help; -} argcmd_t; - -typedef struct network { - char *type; - char *server; - int port; -} network_t; - -int Parser_quit(int argc, char **argv); -void Parser_init(char *, command_t *); /* Set prompt and load command list */ -int Parser_commands(void); /* Start the command parser */ -void Parser_qhelp(int, char **); /* Quick help routine */ -int Parser_help(int, char **); /* Detailed help routine */ -void Parser_printhelp(char *); /* Detailed help routine */ -void Parser_exit(int, char **); /* Shuts down command parser */ -int Parser_execarg(int argc, char **argv, command_t cmds[]); -int execute_line(char * line); - -/* Converts a string to an integer */ -int Parser_int(char *, int *); - -/* Prompts for a string, with default values and a maximum length */ -char *Parser_getstr(const char *prompt, const char *deft, char *res, - size_t len); - -/* Prompts for an integer, with minimum, maximum and default values and base */ -int Parser_getint(const char *prompt, long min, long max, long deft, - int base); - -/* Prompts for a yes/no, with default */ -int Parser_getbool(const char *prompt, int deft); - -/* Extracts an integer from a string, or prompts if it cannot get one */ -long Parser_intarg(const char *inp, const char *prompt, int deft, - int min, int max, int base); - -/* Extracts a word from the input, or propmts if it cannot get one */ -char *Parser_strarg(char *inp, const char *prompt, const char *deft, - char *answer, int len); - -/* Extracts an integer from a string with a base */ -int Parser_arg2int(const char *inp, long *result, int base); - -#endif diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c deleted file mode 100644 index 9c1537b..0000000 --- a/lnet/utils/portals.c +++ /dev/null @@ -1,1935 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001, 2002 Cluster File Systems, Inc. - * - * This file is part of Portals, http://www.sf.net/projects/lustre/ - * - * Portals 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. - * - * Portals 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 Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include -#include -#ifdef HAVE_NETDB_H -#include -#endif -#include -#ifdef HAVE_NETINET_TCP_H -#include -#endif -#include -#include -#include -#include "ioctl.h" -#include -#include -#include -#include -#include -#include -#if CRAY_PORTALS -#ifdef REDSTORM -#define __QK__ -#endif -#include -#endif - -#ifdef __CYGWIN__ - -#include - -#endif /* __CYGWIN__ */ - -#include -#include -#include -#include -#include -#include "parser.h" - -unsigned int portal_debug; -unsigned int portal_printk; - -static unsigned int g_nal = 0; - -typedef struct -{ - char *name; - int num; -} name2num_t; - -static name2num_t nalnames[] = { - {"any", 0}, -#if !CRAY_PORTALS - {"tcp", SOCKNAL}, - {"elan", QSWNAL}, - {"gm", GMNAL}, - {"openib", OPENIBNAL}, - {"iib", IIBNAL}, - {"lo", LONAL}, - {"ra", RANAL}, -#else - {"cray_kern_nal", CRAY_KERN_NAL}, - {"cray_user_nal", CRAY_USER_NAL}, - {"cray_qk_nal", CRAY_QK_NAL}, -#endif - {NULL, -1} -}; - -static cfg_record_cb_t g_record_cb; - -/* Convert a string boolean to an int; "enable" -> 1 */ -int ptl_parse_bool (int *b, char *str) { - if (!strcasecmp (str, "no") || - !strcasecmp (str, "n") || - !strcasecmp (str, "off") || - !strcasecmp (str, "down") || - !strcasecmp (str, "disable")) - { - *b = 0; - return (0); - } - - if (!strcasecmp (str, "yes") || - !strcasecmp (str, "y") || - !strcasecmp (str, "on") || - !strcasecmp (str, "up") || - !strcasecmp (str, "enable")) - { - *b = 1; - return (0); - } - - return (-1); -} - -/* Convert human readable size string to and int; "1k" -> 1000 */ -int ptl_parse_size (int *sizep, char *str) { - int size; - char mod[32]; - - switch (sscanf (str, "%d%1[gGmMkK]", &size, mod)) { - default: - return (-1); - - case 1: - *sizep = size; - return (0); - - case 2: - switch (*mod) { - case 'g': - case 'G': - *sizep = size << 30; - return (0); - - case 'm': - case 'M': - *sizep = size << 20; - return (0); - - case 'k': - case 'K': - *sizep = size << 10; - return (0); - - default: - *sizep = size; - return (0); - } - } -} - -int -ptl_set_cfg_record_cb(cfg_record_cb_t cb) -{ - g_record_cb = cb; - return 0; -} - -int -pcfg_ioctl(struct portals_cfg *pcfg) -{ - int rc; - - if (pcfg->pcfg_nal ==0) - pcfg->pcfg_nal = g_nal; - - if (g_record_cb) { - rc = g_record_cb(PORTALS_CFG_TYPE, sizeof(*pcfg), pcfg); - } else { - struct portal_ioctl_data data; - PORTAL_IOC_INIT (data); - data.ioc_pbuf1 = (char*)pcfg; - data.ioc_plen1 = sizeof(*pcfg); - /* XXX liblustre hack XXX */ - data.ioc_nal_cmd = pcfg->pcfg_command; - data.ioc_nid = pcfg->pcfg_nid; - - rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data); - } - - return (rc); -} - - - -static name2num_t * -name2num_lookup_name (name2num_t *table, char *str) -{ - while (table->name != NULL) - if (!strcmp (str, table->name)) - return (table); - else - table++; - return (NULL); -} - -static name2num_t * -name2num_lookup_num (name2num_t *table, int num) -{ - while (table->name != NULL) - if (num == table->num) - return (table); - else - table++; - return (NULL); -} - -int -ptl_name2nal (char *str) -{ - name2num_t *e = name2num_lookup_name (nalnames, str); - - return ((e == NULL) ? -1 : e->num); -} - -static char * -nal2name (int nal) -{ - name2num_t *e = name2num_lookup_num (nalnames, nal); - - return ((e == NULL) ? "???" : e->name); -} - -#ifdef HAVE_GETHOSTBYNAME -static struct hostent * -ptl_gethostbyname(char * hname) { - struct hostent *he; - he = gethostbyname(hname); - if (!he) { - switch(h_errno) { - case HOST_NOT_FOUND: - case NO_ADDRESS: - fprintf(stderr, "Unable to resolve hostname: %s\n", - hname); - break; - default: - fprintf(stderr, "gethostbyname error: %s\n", - strerror(errno)); - break; - } - return NULL; - } - return he; -} -#endif - -int -ptl_parse_port (int *port, char *str) -{ - char *end; - - *port = strtol (str, &end, 0); - - if (*end == 0 && /* parsed whole string */ - *port > 0 && *port < 65536) /* minimal sanity check */ - return (0); - - return (-1); -} - -int -ptl_parse_time (time_t *t, char *str) -{ - char *end; - int n; - struct tm tm; - - *t = strtol (str, &end, 0); - if (*end == 0) /* parsed whole string */ - return (0); - - memset (&tm, 0, sizeof (tm)); - n = sscanf (str, "%d-%d-%d-%d:%d:%d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, - &tm.tm_hour, &tm.tm_min, &tm.tm_sec); - if (n != 6) - return (-1); - - tm.tm_mon--; /* convert to 0 == Jan */ - tm.tm_year -= 1900; /* y2k quirk */ - tm.tm_isdst = -1; /* dunno if it's daylight savings... */ - - *t = mktime (&tm); - if (*t == (time_t)-1) - return (-1); - - return (0); -} - -int -ptl_parse_ipquad (__u32 *ipaddrp, char *str) -{ - int a; - int b; - int c; - int d; - - if (sscanf (str, "%d.%d.%d.%d", &a, &b, &c, &d) == 4 && - (a & ~0xff) == 0 && (b & ~0xff) == 0 && - (c & ~0xff) == 0 && (d & ~0xff) == 0) - { - *ipaddrp = (a<<24)|(b<<16)|(c<<8)|d; - return (0); - } - - return (-1); -} - -int -ptl_parse_ipaddr (__u32 *ipaddrp, char *str) -{ -#ifdef HAVE_GETHOSTBYNAME - struct hostent *he; -#endif - - if (!strcmp (str, "_all_")) - { - *ipaddrp = 0; - return (0); - } - - if (ptl_parse_ipquad(ipaddrp, str) == 0) - return (0); - -#if HAVE_GETHOSTBYNAME - if ((('a' <= str[0] && str[0] <= 'z') || - ('A' <= str[0] && str[0] <= 'Z')) && - (he = ptl_gethostbyname (str)) != NULL) - { - __u32 addr = *(__u32 *)he->h_addr; - - *ipaddrp = ntohl(addr); /* HOST byte order */ - return (0); - } -#endif - - return (-1); -} - -char * -ptl_ipaddr_2_str (__u32 ipaddr, char *str, int lookup) -{ -#ifdef HAVE_GETHOSTBYNAME - __u32 net_ip; - struct hostent *he; - - if (lookup) { - net_ip = htonl (ipaddr); - he = gethostbyaddr (&net_ip, sizeof (net_ip), AF_INET); - if (he != NULL) { - strcpy(str, he->h_name); - return (str); - } - } -#endif - - sprintf (str, "%d.%d.%d.%d", - (ipaddr >> 24) & 0xff, (ipaddr >> 16) & 0xff, - (ipaddr >> 8) & 0xff, ipaddr & 0xff); - return (str); -} - -int -ptl_parse_nid (ptl_nid_t *nidp, char *str) -{ - __u32 ipaddr; - char *end; - unsigned long long ullval; - - if (!strcmp (str, "_all_")) { - *nidp = PTL_NID_ANY; - return (0); - } - - if (ptl_parse_ipaddr (&ipaddr, str) == 0) { -#if !CRAY_PORTALS - *nidp = (ptl_nid_t)ipaddr; -#else - *nidp = (((ptl_nid_t)ipaddr & PNAL_HOSTID_MASK) << PNAL_VNODE_SHIFT); -#endif - return (0); - } - - ullval = strtoull(str, &end, 0); - if (*end == 0) { - /* parsed whole string */ - *nidp = (ptl_nid_t)ullval; - return (0); - } - - return (-1); -} - -__u64 ptl_nid2u64(ptl_nid_t nid) -{ - switch (sizeof (nid)) { - case 8: - return (nid); - case 4: - return ((__u32)nid); - default: - fprintf(stderr, "Unexpected sizeof(ptl_nid_t) == %u\n", sizeof(nid)); - abort(); - /* notreached */ - return (-1); - } -} - -char * -ptl_nid2str (char *buffer, ptl_nid_t nid) -{ - __u64 nid64 = ptl_nid2u64(nid); -#ifdef HAVE_GETHOSTBYNAME - struct hostent *he = 0; - - /* Don't try to resolve NIDs that are e.g. Elan host IDs. Assume - * TCP addresses in the 0.x.x.x subnet are not in use. This can - * happen on routers and slows things down a _lot_. Bug 3442. */ - if (nid & 0xff000000) { - __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */ - - he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET); - } - - if (he != NULL) - sprintf(buffer, "%#x:%s", (int)(nid64 >> 32), he->h_name); - else -#endif /* HAVE_GETHOSTBYNAME */ - sprintf(buffer, LPX64, nid64); - - return (buffer); -} - -int g_nal_is_set () -{ - if (g_nal == 0) { - fprintf (stderr, "Error: you must run the 'network' command first.\n"); - return (0); - } - - return (1); -} - -int g_nal_is_compatible (char *cmd, ...) -{ - va_list ap; - int nal; - - if (!g_nal_is_set ()) - return (0); - - va_start (ap, cmd); - - do { - nal = va_arg (ap, int); - } while (nal != 0 && nal != g_nal); - - va_end (ap); - - if (g_nal == nal) - return (1); - - if (cmd != NULL) { - /* Don't complain verbosely if we've not been passed a command - * name to complain about! */ - fprintf (stderr, "Command %s not compatible with nal %s\n", - cmd, nal2name (g_nal)); - } - return (0); -} - -int -sock_write (int cfd, void *buffer, int nob) -{ - while (nob > 0) - { - int rc = write (cfd, buffer, nob); - - if (rc < 0) - { - if (errno == EINTR) - continue; - - return (rc); - } - - if (rc == 0) - { - fprintf (stderr, "Unexpected zero sock_write\n"); - abort(); - } - - nob -= rc; - buffer = (char *)buffer + nob; - } - - return (0); -} - -int -sock_read (int cfd, void *buffer, int nob) -{ - while (nob > 0) - { - int rc = read (cfd, buffer, nob); - - if (rc < 0) - { - if (errno == EINTR) - continue; - - return (rc); - } - - if (rc == 0) /* EOF */ - { - errno = ECONNABORTED; - return (-1); - } - - nob -= rc; - buffer = (char *)buffer + nob; - } - - return (0); -} - -int ptl_initialize(int argc, char **argv) -{ - register_ioc_dev(PORTALS_DEV_ID, PORTALS_DEV_PATH); - return 0; -} - - -int jt_ptl_network(int argc, char **argv) -{ - name2num_t *entry; - int nal; - - if (argc == 2 && - (nal = ptl_name2nal (argv[1])) >= 0) { - g_nal = nal; - return (0); - } - - fprintf(stderr, "usage: %s \n", argv[0]); - for (entry = nalnames; entry->name != NULL; entry++) - fprintf (stderr, "%s%s", entry == nalnames ? "<" : "|", entry->name); - fprintf(stderr, ">\n"); - return (-1); -} - -int -jt_ptl_print_interfaces (int argc, char **argv) -{ - struct portals_cfg pcfg; - char buffer[3][64]; - int index; - int rc; - - if (!g_nal_is_compatible (argv[0], SOCKNAL, 0)) - return -1; - - for (index = 0;;index++) { - PCFG_INIT (pcfg, NAL_CMD_GET_INTERFACE); - pcfg.pcfg_count = index; - - rc = pcfg_ioctl (&pcfg); - if (rc != 0) - break; - - printf ("%s: (%s/%s) npeer %d nroute %d\n", - ptl_ipaddr_2_str(pcfg.pcfg_id, buffer[2], 1), - ptl_ipaddr_2_str(pcfg.pcfg_id, buffer[0], 0), - ptl_ipaddr_2_str(pcfg.pcfg_misc, buffer[1], 0), - pcfg.pcfg_fd, pcfg.pcfg_count); - } - - if (index == 0) - printf ("\n"); - return 0; -} - -int -jt_ptl_add_interface (int argc, char **argv) -{ - struct portals_cfg pcfg; - __u32 ipaddr; - int rc; - __u32 netmask = 0xffffff00; - int i; - int count; - char *end; - - if (argc < 2 || argc > 3) { - fprintf (stderr, "usage: %s ipaddr [netmask]\n", argv[0]); - return 0; - } - - if (!g_nal_is_compatible(argv[0], SOCKNAL, 0)) - return -1; - - if (ptl_parse_ipaddr(&ipaddr, argv[1]) != 0) { - fprintf (stderr, "Can't parse ip: %s\n", argv[1]); - return -1; - } - - if (argc > 2 ) { - count = strtol(argv[2], &end, 0); - if (count > 0 && count < 32 && *end == 0) { - netmask = 0; - for (i = count; i > 0; i--) - netmask = netmask|(1<<(32-i)); - } else if (ptl_parse_ipquad(&netmask, argv[2]) != 0) { - fprintf (stderr, "Can't parse netmask: %s\n", argv[2]); - return -1; - } - } - - PCFG_INIT(pcfg, NAL_CMD_ADD_INTERFACE); - pcfg.pcfg_id = ipaddr; - pcfg.pcfg_misc = netmask; - - rc = pcfg_ioctl (&pcfg); - if (rc != 0) { - fprintf (stderr, "failed to add interface: %s\n", - strerror (errno)); - return -1; - } - - return 0; -} - -int -jt_ptl_del_interface (int argc, char **argv) -{ - struct portals_cfg pcfg; - int rc; - __u32 ipaddr = 0; - - if (argc > 2) { - fprintf (stderr, "usage: %s [ipaddr]\n", argv[0]); - return 0; - } - - if (!g_nal_is_compatible(argv[0], SOCKNAL, 0)) - return -1; - - if (argc == 2 && - ptl_parse_ipaddr(&ipaddr, argv[1]) != 0) { - fprintf (stderr, "Can't parse ip: %s\n", argv[1]); - return -1; - } - - PCFG_INIT(pcfg, NAL_CMD_DEL_INTERFACE); - pcfg.pcfg_id = ipaddr; - - rc = pcfg_ioctl (&pcfg); - if (rc != 0) { - fprintf (stderr, "failed to delete interface: %s\n", - strerror (errno)); - return -1; - } - - return 0; -} - -int -jt_ptl_print_peers (int argc, char **argv) -{ - struct portals_cfg pcfg; - char buffer[2][64]; - int index; - int rc; - - if (!g_nal_is_compatible (argv[0], SOCKNAL, OPENIBNAL, IIBNAL, RANAL, 0)) - return -1; - - for (index = 0;;index++) { - PCFG_INIT (pcfg, NAL_CMD_GET_PEER); - pcfg.pcfg_count = index; - - rc = pcfg_ioctl (&pcfg); - if (rc != 0) - break; - - if (g_nal_is_compatible(NULL, SOCKNAL, 0)) - printf (LPX64"[%d]%s@%s:%d #%d\n", - pcfg.pcfg_nid, pcfg.pcfg_wait, - ptl_ipaddr_2_str (pcfg.pcfg_size, buffer[0], 1), - ptl_ipaddr_2_str (pcfg.pcfg_id, buffer[1], 1), - pcfg.pcfg_misc, pcfg.pcfg_count); - else - printf (LPX64"[%d]\n", - pcfg.pcfg_nid, pcfg.pcfg_wait); - } - - if (index == 0) - printf ("\n"); - return 0; -} - -int -jt_ptl_add_peer (int argc, char **argv) -{ - struct portals_cfg pcfg; - ptl_nid_t nid; - __u32 ip = 0; - int port = 0; - int rc; - - if (!g_nal_is_compatible (argv[0], SOCKNAL, OPENIBNAL, IIBNAL, RANAL, 0)) - return -1; - - if (g_nal_is_compatible(NULL, SOCKNAL, RANAL, 0)) { - if (argc != 4) { - fprintf (stderr, "usage(tcp): %s nid ipaddr port\n", - argv[0]); - return 0; - } - } else if (argc != 2) { - fprintf (stderr, "usage(openib,iib): %s nid\n", argv[0]); - return 0; - } - - if (ptl_parse_nid (&nid, argv[1]) != 0 || - nid == PTL_NID_ANY) { - fprintf (stderr, "Can't parse NID: %s\n", argv[1]); - return -1; - } - - if (g_nal_is_compatible (NULL, SOCKNAL, RANAL, 0)) { - if (ptl_parse_ipaddr (&ip, argv[2]) != 0) { - fprintf (stderr, "Can't parse ip addr: %s\n", argv[2]); - return -1; - } - - if (ptl_parse_port (&port, argv[3]) != 0) { - fprintf (stderr, "Can't parse port: %s\n", argv[3]); - return -1; - } - } - - PCFG_INIT(pcfg, NAL_CMD_ADD_PEER); - pcfg.pcfg_nid = nid; - pcfg.pcfg_id = ip; - pcfg.pcfg_misc = port; - - rc = pcfg_ioctl (&pcfg); - if (rc != 0) { - fprintf (stderr, "failed to add peer: %s\n", - strerror (errno)); - return -1; - } - - return 0; -} - -int -jt_ptl_del_peer (int argc, char **argv) -{ - struct portals_cfg pcfg; - ptl_nid_t nid = PTL_NID_ANY; - __u32 ip = 0; - int single_share = 0; - int argidx; - int rc; - - if (!g_nal_is_compatible (argv[0], SOCKNAL, OPENIBNAL, IIBNAL, RANAL, 0)) - return -1; - - if (g_nal_is_compatible(NULL, SOCKNAL, 0)) { - if (argc > 4) { - fprintf (stderr, "usage: %s [nid] [ipaddr] [single_share]\n", - argv[0]); - return 0; - } - } else if (argc > 3) { - fprintf (stderr, "usage: %s [nid] [single_share]\n", argv[0]); - return 0; - } - - if (argc > 1 && - ptl_parse_nid (&nid, argv[1]) != 0) { - fprintf (stderr, "Can't parse nid: %s\n", argv[1]); - return -1; - } - - argidx = 2; - if (g_nal_is_compatible(NULL, SOCKNAL, 0)) { - if (argc > argidx && - ptl_parse_ipaddr (&ip, argv[argidx]) != 0) { - fprintf (stderr, "Can't parse ip addr: %s\n", - argv[argidx]); - return -1; - } - argidx++; - } - - if (argc > argidx) { - if (!strcmp (argv[argidx], "single_share")) { - single_share = 1; - } else { - fprintf (stderr, "Unrecognised arg %s'\n", argv[3]); - return -1; - } - } - - PCFG_INIT(pcfg, NAL_CMD_DEL_PEER); - pcfg.pcfg_nid = nid; - pcfg.pcfg_id = ip; - pcfg.pcfg_flags = single_share; - - rc = pcfg_ioctl (&pcfg); - if (rc != 0) { - fprintf (stderr, "failed to remove peer: %s\n", - strerror (errno)); - return -1; - } - - return 0; -} - -int -jt_ptl_print_connections (int argc, char **argv) -{ - struct portals_cfg pcfg; - char buffer[2][64]; - int index; - int rc; - - if (!g_nal_is_compatible (argv[0], SOCKNAL, OPENIBNAL, IIBNAL, RANAL, 0)) - return -1; - - for (index = 0;;index++) { - PCFG_INIT (pcfg, NAL_CMD_GET_CONN); - pcfg.pcfg_count = index; - - rc = pcfg_ioctl (&pcfg); - if (rc != 0) - break; - - if (g_nal_is_compatible (NULL, SOCKNAL, 0)) - printf ("[%d]%s:"LPX64"@%s:%d:%s %d/%d %s\n", - pcfg.pcfg_gw_nal, /* scheduler */ - ptl_ipaddr_2_str (pcfg.pcfg_fd, buffer[0], 1), /* local IP addr */ - pcfg.pcfg_nid, - ptl_ipaddr_2_str (pcfg.pcfg_id, buffer[1], 1), /* remote IP addr */ - pcfg.pcfg_misc, /* remote port */ - (pcfg.pcfg_flags == SOCKNAL_CONN_ANY) ? "A" : - (pcfg.pcfg_flags == SOCKNAL_CONN_CONTROL) ? "C" : - (pcfg.pcfg_flags == SOCKNAL_CONN_BULK_IN) ? "I" : - (pcfg.pcfg_flags == SOCKNAL_CONN_BULK_OUT) ? "O" : "?", - pcfg.pcfg_count, /* tx buffer size */ - pcfg.pcfg_size, /* rx buffer size */ - pcfg.pcfg_wait ? "nagle" : "nonagle"); - else - printf (LPX64"\n", - pcfg.pcfg_nid); - } - - if (index == 0) - printf ("\n"); - return 0; -} - -int jt_ptl_connect(int argc, char **argv) -{ -#ifndef HAVE_CONNECT - /* no connect() support */ - return -1; -#else /* HAVE_CONNECT */ - struct portals_cfg pcfg; - struct sockaddr_in srvaddr; - struct sockaddr_in locaddr; - __u32 ipaddr; - char *flag; - int fd, rc; - int type = SOCKNAL_CONN_ANY; - int port, rport; - int o; - - if (argc < 3) { - fprintf(stderr, "usage: %s ip port [type]\n", argv[0]); - return 0; - } - - if (!g_nal_is_compatible (argv[0], SOCKNAL, 0)) - return -1; - - rc = ptl_parse_ipaddr (&ipaddr, argv[1]); - if (rc != 0) { - fprintf(stderr, "Can't parse hostname: %s\n", argv[1]); - return -1; - } - - if (ptl_parse_port (&port, argv[2]) != 0) { - fprintf (stderr, "Can't parse port: %s\n", argv[2]); - return -1; - } - - if (argc > 3) - for (flag = argv[3]; *flag != 0; flag++) - switch (*flag) - { - case 'I': - if (type != SOCKNAL_CONN_ANY) { - fprintf(stderr, "Can't flag type twice\n"); - return -1; - } - type = SOCKNAL_CONN_BULK_IN; - break; - - case 'O': - if (type != SOCKNAL_CONN_ANY) { - fprintf(stderr, "Can't flag type twice\n"); - return -1; - } - type = SOCKNAL_CONN_BULK_OUT; - break; - - case 'C': - if (type != SOCKNAL_CONN_ANY) { - fprintf(stderr, "Can't flag type twice\n"); - return -1; - } - type = SOCKNAL_CONN_CONTROL; - break; - - default: - fprintf (stderr, "unrecognised flag '%c'\n", - *flag); - return (-1); - } - - memset(&locaddr, 0, sizeof(locaddr)); - locaddr.sin_family = AF_INET; - locaddr.sin_addr.s_addr = INADDR_ANY; - - memset(&srvaddr, 0, sizeof(srvaddr)); - srvaddr.sin_family = AF_INET; - srvaddr.sin_port = htons(port); - srvaddr.sin_addr.s_addr = htonl(ipaddr); - - - for (rport = IPPORT_RESERVED - 1; rport > IPPORT_RESERVED / 2; --rport) { - fd = socket(PF_INET, SOCK_STREAM, 0); - if ( fd < 0 ) { - fprintf(stderr, "socket() failed: %s\n", strerror(errno)); - return -1; - } - - o = 1; - rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - &o, sizeof(o)); - - locaddr.sin_port = htons(rport); - rc = bind(fd, (struct sockaddr *)&locaddr, sizeof(locaddr)); - if (rc == 0 || errno == EACCES) { - rc = connect(fd, (struct sockaddr *)&srvaddr, sizeof(srvaddr)); - if (rc == 0) { - break; - } else if (errno != EADDRINUSE) { - fprintf(stderr, "Error connecting to host: %s\n", strerror(errno)); - close(fd); - return -1; - } - } else if (errno != EADDRINUSE) { - fprintf(stderr, "Error binding to port %d: %d: %s\n", port, errno, strerror(errno)); - close(fd); - return -1; - } - } - - if (rport == IPPORT_RESERVED / 2) { - fprintf(stderr, - "Warning: all privileged ports are in use.\n"); - return -1; - } - - printf("Connected host: %s type: %s\n", - argv[1], - (type == SOCKNAL_CONN_ANY) ? "A" : - (type == SOCKNAL_CONN_CONTROL) ? "C" : - (type == SOCKNAL_CONN_BULK_IN) ? "I" : - (type == SOCKNAL_CONN_BULK_OUT) ? "O" : "?"); - - PCFG_INIT(pcfg, NAL_CMD_REGISTER_PEER_FD); - pcfg.pcfg_nal = g_nal; - pcfg.pcfg_fd = fd; - pcfg.pcfg_misc = type; - - rc = pcfg_ioctl(&pcfg); - if (rc) { - fprintf(stderr, "failed to register fd with portals: %s\n", - strerror(errno)); - close (fd); - return -1; - } - - printf("Connection to %s registered with socknal\n", argv[1]); - - rc = close(fd); - if (rc) - fprintf(stderr, "close failed: %d\n", rc); - - return 0; -#endif /* HAVE_CONNECT */ -} - -int jt_ptl_disconnect(int argc, char **argv) -{ - struct portals_cfg pcfg; - ptl_nid_t nid = PTL_NID_ANY; - __u32 ipaddr = 0; - int rc; - - if (argc > 3) { - fprintf(stderr, "usage: %s [nid] [ipaddr]\n", argv[0]); - return 0; - } - - if (!g_nal_is_compatible (NULL, SOCKNAL, OPENIBNAL, IIBNAL, RANAL, 0)) - return 0; - - if (argc >= 2 && - ptl_parse_nid (&nid, argv[1]) != 0) { - fprintf (stderr, "Can't parse nid %s\n", argv[1]); - return -1; - } - - if (g_nal_is_compatible (NULL, SOCKNAL, 0) && - argc >= 3 && - ptl_parse_ipaddr (&ipaddr, argv[2]) != 0) { - fprintf (stderr, "Can't parse ip addr %s\n", argv[2]); - return -1; - } - - PCFG_INIT(pcfg, NAL_CMD_CLOSE_CONNECTION); - pcfg.pcfg_nid = nid; - pcfg.pcfg_id = ipaddr; - - rc = pcfg_ioctl(&pcfg); - if (rc) { - fprintf(stderr, "failed to remove connection: %s\n", - strerror(errno)); - return -1; - } - - return 0; -} - -int jt_ptl_push_connection (int argc, char **argv) -{ - struct portals_cfg pcfg; - int rc; - ptl_nid_t nid = PTL_NID_ANY; - __u32 ipaddr = 0; - - if (argc > 3) { - fprintf(stderr, "usage: %s [nid] [ip]\n", argv[0]); - return 0; - } - - if (!g_nal_is_compatible (argv[0], SOCKNAL, 0)) - return -1; - - if (argc > 1 && - ptl_parse_nid (&nid, argv[1]) != 0) { - fprintf(stderr, "Can't parse nid: %s\n", argv[1]); - return -1; - } - - if (argc > 2 && - ptl_parse_ipaddr (&ipaddr, argv[2]) != 0) { - fprintf(stderr, "Can't parse ipaddr: %s\n", argv[2]); - } - - PCFG_INIT(pcfg, NAL_CMD_PUSH_CONNECTION); - pcfg.pcfg_nid = nid; - pcfg.pcfg_id = ipaddr; - - rc = pcfg_ioctl(&pcfg); - if (rc) { - fprintf(stderr, "failed to push connection: %s\n", - strerror(errno)); - return -1; - } - - return 0; -} - -int -jt_ptl_print_active_txs (int argc, char **argv) -{ - struct portals_cfg pcfg; - int index; - int rc; - - if (!g_nal_is_compatible (argv[0], QSWNAL, 0)) - return -1; - - for (index = 0;;index++) { - PCFG_INIT(pcfg, NAL_CMD_GET_TXDESC); - pcfg.pcfg_count = index; - - rc = pcfg_ioctl(&pcfg); - if (rc != 0) - break; - - printf ("%p: %5s payload %6d bytes to "LPX64" via "LPX64" by pid %6d: %s, %s, state %d\n", - pcfg.pcfg_pbuf1, - pcfg.pcfg_count == PTL_MSG_ACK ? "ACK" : - pcfg.pcfg_count == PTL_MSG_PUT ? "PUT" : - pcfg.pcfg_count == PTL_MSG_GET ? "GET" : - pcfg.pcfg_count == PTL_MSG_REPLY ? "REPLY" : "", - pcfg.pcfg_size, - pcfg.pcfg_nid, - pcfg.pcfg_nid2, - pcfg.pcfg_misc, - (pcfg.pcfg_flags & 1) ? "delayed" : "immediate", - (pcfg.pcfg_flags & 2) ? "nblk" : "normal", - pcfg.pcfg_flags >> 2); - } - - if (index == 0) - printf ("\n"); - return 0; -} - -int jt_ptl_ping(int argc, char **argv) -{ - int rc; - ptl_nid_t nid; - long count = 1; - long size = 4; - long timeout = 1; - struct portal_ioctl_data data; - - if (argc < 2) { - fprintf(stderr, "usage: %s nid [count] [size] [timeout (secs)]\n", argv[0]); - return 0; - } - - if (!g_nal_is_set()) - return -1; - - if (ptl_parse_nid (&nid, argv[1]) != 0) - { - fprintf (stderr, "Can't parse nid \"%s\"\n", argv[1]); - return (-1); - } - - if (argc > 2) - { - count = atol(argv[2]); - - if (count < 0 || count > 20000) - { - fprintf(stderr, "are you insane? %ld is a crazy count.\n", count); - return -1; - } - } - - if (argc > 3) - size= atol(argv[3]); - - if (argc > 4) - timeout = atol (argv[4]); - - PORTAL_IOC_INIT (data); - data.ioc_count = count; - data.ioc_size = size; - data.ioc_nid = nid; - data.ioc_nal = g_nal; - data.ioc_timeout = timeout; - - rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_PING, &data); - if (rc) { - fprintf(stderr, "failed to start pinger: %s\n", - strerror(errno)); - return -1; - } - return 0; -} - -int jt_ptl_shownid(int argc, char **argv) -{ - struct portal_ioctl_data data; - int rc; - - if (argc > 1) { - fprintf(stderr, "usage: %s\n", argv[0]); - return 0; - } - - if (!g_nal_is_set()) - return -1; - - PORTAL_IOC_INIT (data); - data.ioc_nal = g_nal; - rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_NID, &data); - if (rc < 0) - fprintf(stderr, "getting my NID failed: %s\n", - strerror (errno)); - else - printf(LPX64"\n", data.ioc_nid); - return 0; -} - -int jt_ptl_mynid(int argc, char **argv) -{ - int rc; - char hostname[1024]; - char *nidstr; - struct portals_cfg pcfg; - ptl_nid_t mynid; - - if (argc > 2) { - fprintf(stderr, "usage: %s [NID]\n", argv[0]); - fprintf(stderr, "NID defaults to the primary IP address of the machine.\n"); - return 0; - } - - if (!g_nal_is_set()) - return -1; - - if (argc >= 2) - nidstr = argv[1]; - else if (gethostname(hostname, sizeof(hostname)) != 0) { - fprintf(stderr, "gethostname failed: %s\n", - strerror(errno)); - return -1; - } - else - nidstr = hostname; - - rc = ptl_parse_nid (&mynid, nidstr); - if (rc != 0) { - fprintf (stderr, "Can't convert '%s' into a NID\n", nidstr); - return -1; - } - - PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID); - pcfg.pcfg_nid = mynid; - - rc = pcfg_ioctl(&pcfg); - if (rc < 0) - fprintf(stderr, "setting my NID failed: %s\n", - strerror(errno)); - else - printf("registered my nid "LPX64" (%s)\n", - ptl_nid2u64(mynid), hostname); - return 0; -} - -int -jt_ptl_fail_nid (int argc, char **argv) -{ - int rc; - ptl_nid_t nid; - unsigned int threshold; - struct portal_ioctl_data data; - - if (argc < 2 || argc > 3) - { - fprintf (stderr, "usage: %s nid|\"_all_\" [count (0 == mend)]\n", argv[0]); - return (0); - } - - if (!g_nal_is_set()) - return (-1); - - if (!strcmp (argv[1], "_all_")) - nid = PTL_NID_ANY; - else if (ptl_parse_nid (&nid, argv[1]) != 0) - { - fprintf (stderr, "Can't parse nid \"%s\"\n", argv[1]); - return (-1); - } - - if (argc < 3) - threshold = PTL_MD_THRESH_INF; - else if (sscanf (argv[2], "%i", &threshold) != 1) { - fprintf (stderr, "Can't parse count \"%s\"\n", argv[2]); - return (-1); - } - - PORTAL_IOC_INIT (data); - data.ioc_nal = g_nal; - data.ioc_nid = nid; - data.ioc_count = threshold; - - rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_FAIL_NID, &data); - if (rc < 0) - fprintf (stderr, "IOC_PORTAL_FAIL_NID failed: %s\n", - strerror (errno)); - else - printf ("%s %s\n", threshold == 0 ? "Unfailing" : "Failing", argv[1]); - - return (0); -} - -int -jt_ptl_add_route (int argc, char **argv) -{ - struct portals_cfg pcfg; - ptl_nid_t nid1; - ptl_nid_t nid2; - ptl_nid_t gateway_nid; - int rc; - - if (argc < 3) - { - fprintf (stderr, "usage: %s gateway target [target]\n", argv[0]); - return (0); - } - - if (!g_nal_is_set()) - return (-1); - - if (ptl_parse_nid (&gateway_nid, argv[1]) != 0) - { - fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]); - return (-1); - } - - if (ptl_parse_nid (&nid1, argv[2]) != 0) - { - fprintf (stderr, "Can't parse first target NID \"%s\"\n", argv[2]); - return (-1); - } - - if (argc < 4) - nid2 = nid1; - else if (ptl_parse_nid (&nid2, argv[3]) != 0) - { - fprintf (stderr, "Can't parse second target NID \"%s\"\n", argv[4]); - return (-1); - } - - PCFG_INIT(pcfg, NAL_CMD_ADD_ROUTE); - pcfg.pcfg_nid = gateway_nid; - pcfg.pcfg_nal = ROUTER; - pcfg.pcfg_gw_nal = g_nal; - pcfg.pcfg_nid2 = MIN (nid1, nid2); - pcfg.pcfg_nid3 = MAX (nid1, nid2); - - rc = pcfg_ioctl(&pcfg); - if (rc != 0) - { - fprintf (stderr, "NAL_CMD_ADD_ROUTE failed: %s\n", strerror (errno)); - return (-1); - } - - return (0); -} - -int -jt_ptl_del_route (int argc, char **argv) -{ - struct portals_cfg pcfg; - ptl_nid_t nid; - ptl_nid_t nid1 = PTL_NID_ANY; - ptl_nid_t nid2 = PTL_NID_ANY; - int rc; - - if (argc < 2) - { - fprintf (stderr, "usage: %s targetNID\n", argv[0]); - return (0); - } - - if (!g_nal_is_set()) - return (-1); - - if (ptl_parse_nid (&nid, argv[1]) != 0) - { - fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]); - return (-1); - } - - if (argc >= 3 && - ptl_parse_nid (&nid1, argv[2]) != 0) - { - fprintf (stderr, "Can't parse target NID \"%s\"\n", argv[2]); - return (-1); - } - - if (argc < 4) { - nid2 = nid1; - } else { - if (ptl_parse_nid (&nid2, argv[3]) != 0) { - fprintf (stderr, "Can't parse target NID \"%s\"\n", argv[3]); - return (-1); - } - - if (nid1 > nid2) { - ptl_nid_t tmp = nid1; - - nid1 = nid2; - nid2 = tmp; - } - } - - PCFG_INIT(pcfg, NAL_CMD_DEL_ROUTE); - pcfg.pcfg_nal = ROUTER; - pcfg.pcfg_gw_nal = g_nal; - pcfg.pcfg_nid = nid; - pcfg.pcfg_nid2 = nid1; - pcfg.pcfg_nid3 = nid2; - - rc = pcfg_ioctl(&pcfg); - if (rc != 0) - { - fprintf (stderr, "NAL_CMD_DEL_ROUTE ("LPX64") failed: %s\n", - ptl_nid2u64(nid), strerror (errno)); - return (-1); - } - - return (0); -} - -int -jt_ptl_notify_router (int argc, char **argv) -{ - struct portals_cfg pcfg; - int enable; - ptl_nid_t nid; - int rc; - struct timeval now; - time_t when; - - if (argc < 3) - { - fprintf (stderr, "usage: %s targetNID [