From c10d6fb4529de1566981443331d44f71def2de8f Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Wed, 12 Jun 2002 19:20:02 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'unlabeled-1.36.4'. --- lustre/.cvsignore | 11 - lustre/BUGS | 15 - lustre/BUILDING | 25 - lustre/COPYING | 352 ----- lustre/ChangeLog | 597 --------- lustre/FDL | 355 ----- lustre/Makefile.am | 17 - lustre/README | 1 - lustre/Rules | 24 - lustre/archdep.m4 | 75 -- lustre/autogen.sh | 6 - lustre/configure.in | 84 -- lustre/demos/.cvsignore | 8 - lustre/demos/Makefile.am | 13 - lustre/demos/baseclean.sh | 39 - lustre/demos/basesetup.sh | 68 - lustre/demos/config.sh | 65 - lustre/demos/obdfsclean.sh | 31 - lustre/demos/obdfssetup.sh | 34 - lustre/demos/obdtest.sh | 21 - lustre/demos/snap3clean.sh | 22 - lustre/demos/snap3set.sh | 36 - lustre/demos/snapclean.sh | 29 - lustre/demos/snapdel.sh | 38 - lustre/demos/snaprest.sh | 46 - lustre/demos/snaprestclean.sh | 36 - lustre/demos/snapsetup.sh | 73 - lustre/demos/snaptest.sh | 18 - lustre/doc/.cvsignore | 14 - lustre/doc/Makefile.am | 35 - lustre/doc/VERSIONING | 67 - lustre/extN/.cvsignore | 18 - lustre/extN/Makefile.am | 74 - lustre/extN/ext3-2.4.18-ino_sb_macro.diff | 1657 ----------------------- lustre/extN/extN-2.4.18-exports.diff | 11 - lustre/extN/extN-2.4.18-ino_sb_fixup.diff | 33 - lustre/extN/extN-misc-fixup.diff | 15 - lustre/extN/htree-ext3-2.4.18.diff | 1216 ----------------- lustre/extN/linux-2.4.18ea-0.8.26.diff | 1787 ------------------------- lustre/include/.cvsignore | 8 - lustre/include/linux/.cvsignore | 14 - lustre/include/linux/Makefile | 7 - lustre/include/linux/inofs.h | 77 -- lustre/include/linux/lustre_debug.h | 51 - lustre/include/linux/lustre_dlm.h | 266 ---- lustre/include/linux/lustre_ha.h | 37 - lustre/include/linux/lustre_idl.h | 577 -------- lustre/include/linux/lustre_lib.h | 70 - lustre/include/linux/lustre_lite.h | 134 -- lustre/include/linux/lustre_mds.h | 256 ---- lustre/include/linux/lustre_net.h | 317 ----- lustre/include/linux/lustre_req.h | 32 - lustre/include/linux/obd.h | 262 ---- lustre/include/linux/obd_class.h | 710 ---------- lustre/include/linux/obd_echo.h | 18 - lustre/include/linux/obd_ext2.h | 49 - lustre/include/linux/obd_filter.h | 18 - lustre/include/linux/obd_ost.h | 42 - lustre/include/linux/obd_raid1.h | 26 - lustre/include/linux/obd_rpc.h | 94 -- lustre/include/linux/obd_snap.h | 29 - lustre/include/linux/obd_snap_support.h | 85 -- lustre/include/linux/obd_support.h | 148 -- lustre/include/linux/obd_trace.h | 20 - lustre/include/linux/obdfs.h | 165 --- lustre/include/linux/obdo.h | 104 -- lustre/install-sh | 251 ---- lustre/ldlm/.cvsignore | 3 - lustre/ldlm/Makefile.am | 15 - lustre/ldlm/ldlm_extent.c | 85 -- lustre/ldlm/ldlm_lock.c | 527 -------- lustre/ldlm/ldlm_lockd.c | 441 ------ lustre/ldlm/ldlm_request.c | 252 ---- lustre/ldlm/ldlm_resource.c | 342 ----- lustre/ldlm/ldlm_test.c | 165 --- lustre/lib/.cvsignore | 8 - lustre/lib/Makefile.am | 3 - lustre/lib/debug.c | 89 -- lustre/lib/mds_updates.c | 319 ----- lustre/lib/obd_pack.c | 80 -- lustre/lib/page.c | 217 --- lustre/lib/simple.c | 103 -- lustre/llite/.cvsignore | 8 - lustre/llite/Makefile.am | 22 - lustre/llite/commit_callback.c | 128 -- lustre/llite/dcache.c | 32 - lustre/llite/dir.c | 703 ---------- lustre/llite/file.c | 334 ----- lustre/llite/namei.c | 550 -------- lustre/llite/recover.c | 141 -- lustre/llite/super.c | 455 ------- lustre/llite/symlink.c | 62 - lustre/llite/sysctl.c | 65 - lustre/lov/Makefile.am | 14 - lustre/lov/lov_obd.c | 353 ----- lustre/mdc/.cvsignore | 8 - lustre/mdc/Makefile.am | 22 - lustre/mdc/mdc_reint.c | 219 --- lustre/mdc/mdc_request.c | 398 ------ lustre/mds/.cvsignore | 8 - lustre/mds/Makefile.am | 25 - lustre/mds/handler.c | 719 ---------- lustre/mds/mds_ext2.c | 138 -- lustre/mds/mds_ext3.c | 307 ----- lustre/mds/mds_extN.c | 338 ----- lustre/mds/mds_fs.c | 463 ------- lustre/mds/mds_reint.c | 559 -------- lustre/missing | 190 --- lustre/mkinstalldirs | 40 - lustre/nodist | 21 - lustre/obdclass/.cvsignore | 8 - lustre/obdclass/Makefile.am | 7 - lustre/obdclass/class_obd.c | 684 ---------- lustre/obdclass/genops.c | 270 ---- lustre/obdclass/proc_lustre.c | 240 ---- lustre/obdclass/sysctl.c | 128 -- lustre/obdecho/.cvsignore | 8 - lustre/obdecho/Makefile.am | 14 - lustre/obdecho/echo.c | 216 --- lustre/obdfilter/.cvsignore | 8 - lustre/obdfilter/Makefile.am | 22 - lustre/obdfilter/filter.c | 1411 ------------------- lustre/obdfs/.cvsignore | 8 - lustre/obdfs/Makefile.am | 13 - lustre/obdfs/README | 22 - lustre/obdfs/dir.c | 627 --------- lustre/obdfs/file.c | 106 -- lustre/obdfs/flushd.c | 479 ------- lustre/obdfs/namei.c | 466 ------- lustre/obdfs/rw.c | 728 ---------- lustre/obdfs/super.c | 522 -------- lustre/obdfs/symlink.c | 95 -- lustre/obdfs/sysctl.c | 66 - lustre/osc/.cvsignore | 8 - lustre/osc/Makefile.am | 21 - lustre/osc/osc_request.c | 720 ---------- lustre/ost/.cvsignore | 8 - lustre/ost/Makefile.am | 23 - lustre/ost/ost_handler.c | 685 ---------- lustre/patches/.cvsignore | 8 - lustre/patches/intent-lock.patch | 739 ---------- lustre/patches/patch-2.2.10 | 51 - lustre/patches/patch-2.3.15 | 43 - lustre/patches/patch-2.3.21 | 60 - lustre/patches/patch-2.4.16 | 161 --- lustre/patches/patch-2.4.17 | 47 - lustre/patches/patch-2.4.18 | 1354 ------------------- lustre/patches/patch-2.4.18-chaos1 | 1114 --------------- lustre/patches/patch-2.4.3-empty-super | 31 - lustre/patches/patch-2.4.9-ac10 | 22 - lustre/patches/patch-2.4.9-chaos14 | 331 ----- lustre/patches/patch-2.4.9-rh-ac13-xfs-1 | 110 -- lustre/patches/ubd-io-fail-2.4.18 | 34 - lustre/ptlrpc/.cvsignore | 9 - lustre/ptlrpc/Makefile.am | 14 - lustre/ptlrpc/client.c | 576 -------- lustre/ptlrpc/connection.c | 130 -- lustre/ptlrpc/connmgr.c | 155 --- lustre/ptlrpc/events.c | 232 ---- lustre/ptlrpc/niobuf.c | 400 ------ lustre/ptlrpc/pack_generic.c | 128 -- lustre/ptlrpc/recovd.c | 229 ---- lustre/ptlrpc/rpc.c | 210 --- lustre/ptlrpc/service.c | 345 ----- lustre/scripts/.cvsignore | 9 - lustre/scripts/Makefile.am | 8 - lustre/scripts/license-status | 26 - lustre/scripts/lustre.spec.in | 87 -- lustre/scripts/maketags.sh | 8 - lustre/scripts/mkobddevs | 14 - lustre/scripts/obdtrace_demo.scr | 60 - lustre/tests/.cvsignore | 15 - lustre/tests/Makefile.am | 18 - lustre/tests/README | 100 -- lustre/tests/client-echo.cfg | 3 - lustre/tests/client-mount.cfg | 5 - lustre/tests/common.sh | 545 -------- lustre/tests/directio.c | 62 - lustre/tests/elan-client.cfg | 5 - lustre/tests/elan-server.cfg | 5 - lustre/tests/ext2_10000.gz | Bin 10228 -> 0 bytes lustre/tests/ext2_25000.gz | Bin 25136 -> 0 bytes lustre/tests/ext3_10000.gz | Bin 12172 -> 0 bytes lustre/tests/fs.sh | 27 - lustre/tests/fsx.c | 1121 ---------------- lustre/tests/ldaptest.c | 27 - lustre/tests/ldlm.cfg | 3 - lustre/tests/llcleanup.sh | 18 - lustre/tests/lldlm.sh | 13 - lustre/tests/llecho.sh | 13 - lustre/tests/llext3.sh | 10 - lustre/tests/llmount-client.sh | 9 - lustre/tests/llmount-server.sh | 9 - lustre/tests/llmount.sh | 10 - lustre/tests/llmountcleanup.sh | 71 - lustre/tests/llrext3.sh | 10 - lustre/tests/llrmount.sh | 10 - lustre/tests/llrsetup.sh | 13 - lustre/tests/llsetup.sh | 13 - lustre/tests/mdcreq.sh | 36 - lustre/tests/mdcreqcleanup.sh | 34 - lustre/tests/mds.cfg | 6 - lustre/tests/net-client.cfg | 6 - lustre/tests/net-local.cfg | 6 - lustre/tests/net-server.cfg | 6 - lustre/tests/obddisk.cfg | 6 - lustre/tests/obdecho.cfg | 4 - lustre/tests/obdext2.cfg | 7 - lustre/tests/obdfilter.cfg | 7 - lustre/tests/openme.c | 23 - lustre/tests/openunlink.c | 122 -- lustre/tests/ostreq.sh | 36 - lustre/tests/rundbench | 6 - lustre/tests/runfailure-client-mds-recover.sh | 102 -- lustre/tests/runfailure-mds | 97 -- lustre/tests/runfailure-net | 55 - lustre/tests/runiozone | 11 - lustre/tests/runregression-net.sh | 59 - lustre/tests/runtests | 56 - lustre/tests/runvmstat | 2 - lustre/tests/snaprun.sh | 36 - lustre/tests/test.c | 101 -- lustre/tests/test2.c | 60 - lustre/tests/testreq.c | 137 -- lustre/tests/truncate.c | 24 - lustre/tests/writeme.c | 32 - lustre/utils/.cvsignore | 10 - lustre/utils/Makefile.am | 12 - lustre/utils/ha_assist.sh | 5 - lustre/utils/ha_assist2.sh | 33 - lustre/utils/obdctl.c | 1011 -------------- lustre/utils/parser.c | 590 -------- lustre/utils/parser.h | 55 - 233 files changed, 39190 deletions(-) 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.am delete mode 100644 lustre/README delete mode 100644 lustre/Rules delete mode 100644 lustre/archdep.m4 delete mode 100644 lustre/autogen.sh delete mode 100644 lustre/configure.in delete mode 100644 lustre/demos/.cvsignore delete mode 100644 lustre/demos/Makefile.am delete mode 100755 lustre/demos/baseclean.sh delete mode 100755 lustre/demos/basesetup.sh delete mode 100644 lustre/demos/config.sh delete mode 100755 lustre/demos/obdfsclean.sh delete mode 100755 lustre/demos/obdfssetup.sh delete mode 100755 lustre/demos/obdtest.sh delete mode 100755 lustre/demos/snap3clean.sh delete mode 100755 lustre/demos/snap3set.sh delete mode 100755 lustre/demos/snapclean.sh delete mode 100755 lustre/demos/snapdel.sh delete mode 100755 lustre/demos/snaprest.sh delete mode 100755 lustre/demos/snaprestclean.sh delete mode 100755 lustre/demos/snapsetup.sh delete mode 100755 lustre/demos/snaptest.sh delete mode 100644 lustre/doc/.cvsignore delete mode 100644 lustre/doc/Makefile.am delete mode 100644 lustre/doc/VERSIONING delete mode 100644 lustre/extN/.cvsignore delete mode 100644 lustre/extN/Makefile.am delete mode 100644 lustre/extN/ext3-2.4.18-ino_sb_macro.diff delete mode 100644 lustre/extN/extN-2.4.18-exports.diff delete mode 100644 lustre/extN/extN-2.4.18-ino_sb_fixup.diff delete mode 100644 lustre/extN/extN-misc-fixup.diff delete mode 100644 lustre/extN/htree-ext3-2.4.18.diff delete mode 100644 lustre/extN/linux-2.4.18ea-0.8.26.diff delete mode 100644 lustre/include/.cvsignore delete mode 100644 lustre/include/linux/.cvsignore delete mode 100644 lustre/include/linux/Makefile delete mode 100644 lustre/include/linux/inofs.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_ha.h delete mode 100644 lustre/include/linux/lustre_idl.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_mds.h delete mode 100644 lustre/include/linux/lustre_net.h delete mode 100644 lustre/include/linux/lustre_req.h delete mode 100644 lustre/include/linux/obd.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_ext2.h delete mode 100644 lustre/include/linux/obd_filter.h delete mode 100644 lustre/include/linux/obd_ost.h delete mode 100644 lustre/include/linux/obd_raid1.h delete mode 100644 lustre/include/linux/obd_rpc.h delete mode 100644 lustre/include/linux/obd_snap.h delete mode 100644 lustre/include/linux/obd_snap_support.h delete mode 100644 lustre/include/linux/obd_support.h delete mode 100644 lustre/include/linux/obd_trace.h delete mode 100644 lustre/include/linux/obdfs.h delete mode 100644 lustre/include/linux/obdo.h delete mode 100755 lustre/install-sh delete mode 100644 lustre/ldlm/.cvsignore delete mode 100644 lustre/ldlm/Makefile.am delete mode 100644 lustre/ldlm/ldlm_extent.c delete mode 100644 lustre/ldlm/ldlm_lock.c delete mode 100644 lustre/ldlm/ldlm_lockd.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/lib/.cvsignore delete mode 100644 lustre/lib/Makefile.am delete mode 100644 lustre/lib/debug.c delete mode 100644 lustre/lib/mds_updates.c delete mode 100644 lustre/lib/obd_pack.c delete mode 100644 lustre/lib/page.c delete mode 100644 lustre/lib/simple.c delete mode 100644 lustre/llite/.cvsignore delete mode 100644 lustre/llite/Makefile.am delete mode 100644 lustre/llite/commit_callback.c 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/namei.c delete mode 100644 lustre/llite/recover.c delete mode 100644 lustre/llite/super.c delete mode 100644 lustre/llite/symlink.c delete mode 100644 lustre/llite/sysctl.c delete mode 100644 lustre/lov/Makefile.am delete mode 100644 lustre/lov/lov_obd.c delete mode 100644 lustre/mdc/.cvsignore delete mode 100644 lustre/mdc/Makefile.am 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.am delete mode 100644 lustre/mds/handler.c delete mode 100644 lustre/mds/mds_ext2.c delete mode 100644 lustre/mds/mds_ext3.c delete mode 100644 lustre/mds/mds_extN.c delete mode 100644 lustre/mds/mds_fs.c delete mode 100644 lustre/mds/mds_reint.c delete mode 100755 lustre/missing delete mode 100755 lustre/mkinstalldirs delete mode 100644 lustre/nodist delete mode 100644 lustre/obdclass/.cvsignore delete mode 100644 lustre/obdclass/Makefile.am delete mode 100644 lustre/obdclass/class_obd.c delete mode 100644 lustre/obdclass/genops.c delete mode 100644 lustre/obdclass/proc_lustre.c delete mode 100644 lustre/obdclass/sysctl.c delete mode 100644 lustre/obdecho/.cvsignore delete mode 100644 lustre/obdecho/Makefile.am delete mode 100644 lustre/obdecho/echo.c delete mode 100644 lustre/obdfilter/.cvsignore delete mode 100644 lustre/obdfilter/Makefile.am delete mode 100644 lustre/obdfilter/filter.c delete mode 100644 lustre/obdfs/.cvsignore delete mode 100644 lustre/obdfs/Makefile.am delete mode 100644 lustre/obdfs/README delete mode 100644 lustre/obdfs/dir.c delete mode 100644 lustre/obdfs/file.c delete mode 100644 lustre/obdfs/flushd.c delete mode 100644 lustre/obdfs/namei.c delete mode 100644 lustre/obdfs/rw.c delete mode 100644 lustre/obdfs/super.c delete mode 100644 lustre/obdfs/symlink.c delete mode 100644 lustre/obdfs/sysctl.c delete mode 100644 lustre/osc/.cvsignore delete mode 100644 lustre/osc/Makefile.am delete mode 100644 lustre/osc/osc_request.c delete mode 100644 lustre/ost/.cvsignore delete mode 100644 lustre/ost/Makefile.am delete mode 100644 lustre/ost/ost_handler.c delete mode 100644 lustre/patches/.cvsignore delete mode 100644 lustre/patches/intent-lock.patch delete mode 100644 lustre/patches/patch-2.2.10 delete mode 100644 lustre/patches/patch-2.3.15 delete mode 100644 lustre/patches/patch-2.3.21 delete mode 100644 lustre/patches/patch-2.4.16 delete mode 100644 lustre/patches/patch-2.4.17 delete mode 100644 lustre/patches/patch-2.4.18 delete mode 100644 lustre/patches/patch-2.4.18-chaos1 delete mode 100644 lustre/patches/patch-2.4.3-empty-super delete mode 100644 lustre/patches/patch-2.4.9-ac10 delete mode 100644 lustre/patches/patch-2.4.9-chaos14 delete mode 100644 lustre/patches/patch-2.4.9-rh-ac13-xfs-1 delete mode 100644 lustre/patches/ubd-io-fail-2.4.18 delete mode 100644 lustre/ptlrpc/.cvsignore delete mode 100644 lustre/ptlrpc/Makefile.am delete mode 100644 lustre/ptlrpc/client.c delete mode 100644 lustre/ptlrpc/connection.c delete mode 100644 lustre/ptlrpc/connmgr.c delete mode 100644 lustre/ptlrpc/events.c delete mode 100644 lustre/ptlrpc/niobuf.c delete mode 100644 lustre/ptlrpc/pack_generic.c delete mode 100644 lustre/ptlrpc/recovd.c delete mode 100644 lustre/ptlrpc/rpc.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/license-status delete mode 100644 lustre/scripts/lustre.spec.in delete mode 100755 lustre/scripts/maketags.sh delete mode 100755 lustre/scripts/mkobddevs delete mode 100644 lustre/scripts/obdtrace_demo.scr delete mode 100644 lustre/tests/.cvsignore delete mode 100644 lustre/tests/Makefile.am delete mode 100644 lustre/tests/README delete mode 100644 lustre/tests/client-echo.cfg delete mode 100644 lustre/tests/client-mount.cfg delete mode 100644 lustre/tests/common.sh delete mode 100644 lustre/tests/directio.c delete mode 100644 lustre/tests/elan-client.cfg delete mode 100644 lustre/tests/elan-server.cfg delete mode 100644 lustre/tests/ext2_10000.gz delete mode 100644 lustre/tests/ext2_25000.gz delete mode 100644 lustre/tests/ext3_10000.gz delete mode 100644 lustre/tests/fs.sh delete mode 100644 lustre/tests/fsx.c delete mode 100644 lustre/tests/ldaptest.c delete mode 100644 lustre/tests/ldlm.cfg delete mode 100755 lustre/tests/llcleanup.sh delete mode 100755 lustre/tests/lldlm.sh delete mode 100644 lustre/tests/llecho.sh delete mode 100755 lustre/tests/llext3.sh delete mode 100644 lustre/tests/llmount-client.sh delete mode 100644 lustre/tests/llmount-server.sh delete mode 100755 lustre/tests/llmount.sh delete mode 100755 lustre/tests/llmountcleanup.sh delete mode 100755 lustre/tests/llrext3.sh delete mode 100755 lustre/tests/llrmount.sh delete mode 100644 lustre/tests/llrsetup.sh delete mode 100644 lustre/tests/llsetup.sh delete mode 100644 lustre/tests/mdcreq.sh delete mode 100755 lustre/tests/mdcreqcleanup.sh delete mode 100644 lustre/tests/mds.cfg delete mode 100644 lustre/tests/net-client.cfg delete mode 100644 lustre/tests/net-local.cfg delete mode 100644 lustre/tests/net-server.cfg delete mode 100644 lustre/tests/obddisk.cfg delete mode 100644 lustre/tests/obdecho.cfg delete mode 100644 lustre/tests/obdext2.cfg delete mode 100644 lustre/tests/obdfilter.cfg delete mode 100644 lustre/tests/openme.c delete mode 100644 lustre/tests/openunlink.c delete mode 100644 lustre/tests/ostreq.sh delete mode 100755 lustre/tests/rundbench delete mode 100755 lustre/tests/runfailure-client-mds-recover.sh delete mode 100755 lustre/tests/runfailure-mds delete mode 100755 lustre/tests/runfailure-net delete mode 100755 lustre/tests/runiozone delete mode 100644 lustre/tests/runregression-net.sh delete mode 100755 lustre/tests/runtests delete mode 100755 lustre/tests/runvmstat delete mode 100755 lustre/tests/snaprun.sh delete mode 100755 lustre/tests/test.c delete mode 100755 lustre/tests/test2.c delete mode 100644 lustre/tests/testreq.c delete mode 100644 lustre/tests/truncate.c delete mode 100644 lustre/tests/writeme.c delete mode 100644 lustre/utils/.cvsignore delete mode 100644 lustre/utils/Makefile.am delete mode 100755 lustre/utils/ha_assist.sh delete mode 100755 lustre/utils/ha_assist2.sh delete mode 100644 lustre/utils/obdctl.c delete mode 100644 lustre/utils/parser.c delete mode 100644 lustre/utils/parser.h diff --git a/lustre/.cvsignore b/lustre/.cvsignore deleted file mode 100644 index 2172c53..0000000 --- a/lustre/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -.Xrefs -aclocal.m4 -config.log -config.status -config.cache -configure -Makefile -Makefile.in -.deps -tags -TAGS diff --git a/lustre/BUGS b/lustre/BUGS deleted file mode 100644 index 9cf6fa2..0000000 --- a/lustre/BUGS +++ /dev/null @@ -1,15 +0,0 @@ -include /dev/obd in the documentation - - -attach: attaching ext2obd allows ext2 module to be unloaded. Unload, -then do cleanup, get Oops... - -syncing: invalid IOCTL - -create: more than one object - -preallocate: IOCTL - -statfs: - -restoresnap: decrements directory count for ext2 diff --git a/lustre/BUILDING b/lustre/BUILDING deleted file mode 100644 index deaa5e8..0000000 --- a/lustre/BUILDING +++ /dev/null @@ -1,25 +0,0 @@ -BUILDING LUSTRE ---------------- - -To build the lustre obd module, you must first build portals. - -Portals is available from the same CVS repository of the lustre -project module portals, see http://www.lustre.org - -To build: - sh autogen.sh - ./configure --enable-linuxdir=/usr/src/linux --enable-portalsdir=/usr/src/portals - make - -To play with Lustre Lite: - cd obd/tests - sh llmount.sh - -To clean up: - sh llmountcleanup.sh - -Feedback: - lustre-devel@lists.sf.net - lustre-discuss@lists.sf.net - -- Peter - \ No newline at end of file diff --git a/lustre/COPYING b/lustre/COPYING deleted file mode 100644 index c69cfd8..0000000 --- a/lustre/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/lustre/ChangeLog b/lustre/ChangeLog deleted file mode 100644 index 51558f5..0000000 --- a/lustre/ChangeLog +++ /dev/null @@ -1,597 +0,0 @@ -2001-06-29 18:15 PDT rzahir - - * obdfs/flushd.c: conditionalized number of C_DEBUG messages. - * include/linux/obd_class.h: added obd_devicename member to - struct obd_device (name is either ptr to dentry or uuid). - * ext2obd/ext2_obd.c: setup() converts dentry into rdev number. - class/class_obd.c: setup() converts name into obd_device dentry - class/obdcontrol: setup() passes /dev/obd name into ioctl - (used to be rdev number and if invalid rdev number was passed - old ext2_obd.c would crash kernel when trying to read superblock). - * class/obdcontrol: added "status, procsys, script, insmod, rmmod, - lsmod, shell and close" commands for obdcontrol. This allows - easier scripting from within obdcontrol. Introduced ability to - maintain multiple open obd devices from a single obdcontrol - session. Device command toggles device context. Obdcontrol - maintains multiple open file handles. "script " command is - useful for "sourcing" scripts without leaving obdcontrol. - shell allows any shell command to be executed from - within obdcontrol. - * class/proc_lustre.c: added support for /proc/lustre/obd//status. - These are read-only /proc entries that track /dev/obd - internal state. - * obdtrace/* & include/linux/obd_class.h: obd_trace a logical obd - module useful for tracing and performance debug of the Lustre - obd protocol stack. obdtrace module creates - /proc/lustre/obd//stats file. Reading this /proc file shows - per OBD performance statistics. Any write to this /proc file - resets the counters for this OBD. - * scripts/obdtrace_demo.scr: Example of obdtrace that - takes advantage of new obdcontrol functionality. - * doc/obdtrace_demo.txt: shows obdtrace capabilities. - - -2000-03-06 12:33 adilger - - * obdfs/ext2_obd: added punch/truncate methods - -2000-01-26 01:40 adilger - - * obdfs/flushd.c: removed iput() from dequeue routine, since we no - longer remove the inodes from the list in this routine, rather - waiting to do it in flush_reqs, which also does a iput() - -2000-01-25 12:55 adilger - - * obdfs/super.c: add call to flush pages when unmounting filesystem - * obdfs/flushd.c: pass "check_time" parameter to flush routines - * obdfs/namei.c: fixed rename call to getpage to use offset, not index - * snap/*: tested snapshots with new vector I/O, async writes - OK - * tests/snaprun.sh: small script to step through testing of some - snapshot features - -2000-01-24 18:55 braam - - * obdfs/rw.c: fixed obdfs_getpage() to use page index, not offset - * obdfs/rw.c, flushd.c: added superblock lock for inode/page lists, - added new iget()/iput() on all inodes in page cache to prevent - them from being flushed from memory while waiting for write. - -2000-01-22 02:55 adilger - - * flush daemon testing/debugging - inode list still needs a lock - * snapshot compiles with vector I/O now - untested - -2000-01-20 18:05 adilger - - * add dirty inode list to superblock - -2000-01-20 11:50 adilger - - * ext2obd/ext2obd.c: fixed brw I/O to have array of iobufs, not pointer - * obdfs/super.c: add superblock to list of superblocks - * obdfs/flushd.c: use pupdated() to do page writes - -2000-01-19 18:05 adilger - - * ext2obd/ext2obd.c: changed _brw to use vector I/O with brw_kiovec() - * obdfs/rw.c, obdfs/flushd.c: updated for async page cache - -2000-01-18 20:20 adilger - - * class/obdcontrol: fixed read, write, create to work with obdos - (write is still not fully functional) - * ext2obd/ext2obd.c: ext2obd_write() - copy inode data back into obdo - add a few missing iput()s for error conditions - -2000-01-18 13:30 adilger - - * modified _brw method to allow array of obdos to be submitted for - multiple I/Os with one call - -2000-01-18 11:30 adilger - - * include/obd_support.h: removed printk() of long long values - (sometimes does not print properly) - * obdfs/rw.c: added obdo_from_inode() call in obdfs_brw(), as inode - was not properly being copied into obdo, causing occasional confusion - * snap/snap.c: always copy back obdo data to primary from disk obdo - * obdsync/*: removed from CVS - -2000-01-14 08:05 adilger - - * snap/*: obdo snapshots should be working now. - -2000-01-13 13:50 adilger - - * snap/*: working on storing obdmd outside of inode - -2000-01-11 14:25 adilger - - * snap/*: updated to work with new obdo methods, untested - -2000-01-10 10:37 adilger - - * obdfs/*, ext2obd/*: updated to work with new obdo methods, tested - -1999-12-29 13:57 adilger - - * obdsync/*: added to CVS - * obdfs/super.c,rw.c: added start of page cache - -1999-12-29 10:20 adilger - - * ext2obd/ext2_obd.c, snap/snap.c: change parameters for create - * class/obdcontrol: update copy, migrate dst & src parameter order - -1999-12-23 14:21 adilger - - * demos/snaprest.sh: ensure client is disconnected after snaprestore - * class/class_obd.c: debugging for connection counts, made error - returns more consistent, check connections when doing cleanup - -1999-12-23 03:10 adilger - - * ext2obd/ext2_obd.c: added iput() after reading a bad inode, - remove EXT2_UNDEL_DIR_INO from list of iterated inodes. - * class/obdcontrol: after snaprestore remove snapshot from - table by key not index - -1999-12-22 13:44 adilger - - * demos/snaprest.sh: mount /dev/obd2 on /mnt/obd at end of restore - -1999-12-22 13:11 adilger - - * snap/snap.c: always try to collapse an object in snap_restoreobj() - * demos/snaprest.sh: need to rework snaprestore process - * demos/basesetup.sh: check if /dev/obd* exist - * demos/baseclean.sh: don't remove temp file - -1999-12-22 08:43 adilger - - * demos/obdtest.sh: added new script - -1999-12-21 18:03 adilger - - * class/obdcontrol: added "basedev" parameter to the attach command - for ext2_obd. This was required after the removal of Filesystem() - * demos/*: moved test scripts here, renamed by function - -1999-12-21 17:03 adilger - - * class/obdcontrol: merge snapattach into attach, fix scsi_obd packing - * snap/cleanup.sh: use ../class/cleanup.sh like snap/setup.sh does - -1999-12-21 00:41 braam - - * doc/obd-howto.sgml: numerous edits - * class/obdcontrol: make things clearer (no implicit filesystem) - * change to our official MAJOR (186). - -1999-12-20 17:03 adilger - - * doc/obd-howto.sgml: added issues/bugs section - * snap/test*.sh: added brief comments to each script - -1999-12-20 16:08 adilger - - * doc/obd-howto.sgml: updated for initial public release - * obdfs/many: changed to have separate dir/file operations, - * ext2obd/ext2_obd: cosmetic changes to match ext2 code more closely - * include/linux/obd_class.h: change obdo_{cpy,cmp}_md() to allow - include or exclude flags for copy/compare of metadata - * snap/snaptable.c: comment iterator functions clearly - -1999-12-17 10:20 adilger - - * include/linux/obd_sim.h: renamed to obd_ext2.h - * Configure: revert PCI, APIC checks (otherwise won't compile after - config) - -1999-12-17 08:45 adilger - - * doc/obd-howto.sgml: completed OBD tutorial section - * snap/snap.c: in eliminate_obj() turn off S_IFDIR flag on object - before passing to underlying obdext2 driver, so it doesn't - decrement the dir count for the group - * Configure: removed questions for PCMCIA specific features - * class/obdcontrol: disconnect session when changing devices - -1999-12-14 20:32 adilger - - * include/linux/obdfs.h: add symlink_inode_operations, prototypes - * obdfs/symlink.c, obdfs/namei.c: handle obdfs symlinks properly - -1999-12-13 17:55 adilger - - * snap/snap.c, class/obdcontrol: added support for snapshot restores - on unmounted OBD filesystems - * snap/setup3.sh, snap/cleanup3.sh: scripts to test 3 snapshots - * include/linux/obd_snap_support.h: iterator struct/function prototypes - -1999-12-13 09:30 adilger - - * all: significant overhaul by Peter to avoid problems with OBD - metadata conflicting with ext2 block data in the inode. - * class/obdcontrol: added proper commands for snapdelete/snaprestore - * class/obdcontrol: device command now disconnects old session if any - * ext2obd/*: updated for kernel 2.3.30 - * include/linux/obd_class.h: helper functions inode metadata cpy/cmp - * include/linux/obd_snap.h: new magic less likely for block conflict - now that the redirector can have "i_blocks" set - * obd/obdfs: updated for kernel 2.3.30 - * snap/snap.c: use new obd metadata copy helper routines - * snap/snap.c: updated delete/restore snapshot iterator functions - -1999-12-08 21:42 adilger - - * snap/snap.c: snap_do_cow() fixed case with existing indirect object - * snap/snap.c: snap_delsnap() removes (partly) a snapshot - * ext2obd/ext2_obd.c: fixed iterator to handle reserved inodes - * ext2obd/ext2_obd.c: fixed direct_brw() to handle > 1 block offset - * class/obdcontrol: added testsnapiterator command/ioctl - * class/setup.sh: added creation of /tmp/fs, 4k block size - * obdfs/namei.c: fixed new directory size after write - -1999-12-07 11:45 adilger - - * snap/snap.c: fixed check for snap_create() to test for correct - read-only copy - -1999-12-06 16:53 adilger - - * snap/snap.c, snap/snaptable.c: Fixed up snapshot to work again with - snaptables, added snap_iterate() calldown, snap_cleanup() to free - a snapshot table entry - * ext2obd/ext2_obd.c: added iterator ext2obd_iterate() for all inodes - * class/class_obd.c: blocked TCGETS IOCTL, added connection ID to calls - * class/obdcontrol: added IOCTL for testing iterator, connection ID - -1999-12-06 08:00 braam - - * Added a file handling snapshot tables - * Added an ioctl system that allows ioctls to be made without - specific devices being attached (pass method down). - * Numerous small routines for snapshot handling. - -1999-12-03 16:53 adilger - - * Makefile: made "all" the default target - * class/class_obd.c, class/genops.c, snap/snap.c: re-ordered - migrate, copy argument order to be consistent (dst, src) - * snap/snap.c: fixed unlink to work in all cases of (direct, - indirect) - * snap/setup.sh: check for mounted obdfs before starting - * snap/cleanup.sh: remove loop device - * ext2obd/ext2_obd.c: start of iterator - -1999-12-03 11:08 adilger - - * snap/snap.c: implemented unlink functionality for snapshots. - * doc/obd-howto.sgml: started on OBD howto documentation - -1999-12-02 13:40 braam - - * class/genops.c: Undo accidental commit - -1999-12-02 13:36 braam - - * .cvsignore, class/.cvsignore, class/genops.c, ext2obd/.cvsignore, - inofs/.cvsignore, obdfs/.cvsignore, oraid1/.cvsignore, - rpcclient/.cvsignore, rpctarget/.cvsignore, snap/.cvsignore: Added - .cvsignore files to the repository - -1999-12-02 12:33 adilger - - * snap/setup.sh: Updated to use the new "now" and "current" flags - when creating snapshots. - -1999-12-01 17:11 braam - - * class/obdcontrol, doc/OLVM.txt, include/linux/obd_snap.h, - obdfs/super.c, snap/snap.c: Updated snapshot indexes in superblock - to not depend on index "0" as being the current snapshot. We still - need to push the inode attributes to the snap copy so that - size/times are correct. - -1999-12-01 11:45 adilger - - * class/genops.c, ext2obd/Makefile, ext2obd/dir.c, ext2obd/file.c, - ext2obd/inode.c, ext2obd/truncate.c, include/linux/obdfs.h, - obdfs/rw.c, snap/cleanup.sh, snap/setup.sh, tests/fs.sh: Updated - parameters for obdfs_writepage() to use struct *dentry instead of - struct *file, and call in odbfs_write_one_page() to use new - parameters. Updated gen_copy_data() to round up the number of - pages copied in while loop. - -1999-12-01 01:02 braam - - * snap/snap.c: small test - -1999-11-30 12:06 braam - - * class/genops.c, class/setup.sh, ext2obd/Makefile, - ext2obd/ext2_obd.c, include/linux/obd_support.h, obdfs/namei.c, - snap/snap.c: fixes for 2.3.25 and higher - -1999-11-24 14:15 braam - - * BUGS, Makefile, doc/OLVM.txt, ext2obd/ext2_obd.c, - include/linux/obd_class.h, include/linux/obd_snap.h, - include/linux/obd_support.h, include/linux/obdfs.h, obdfs/dir.c, - obdfs/rw.c, obdfs/super.c: Changes to accomodate the snapshot - features! - -1999-11-24 12:46 braam - - * class/: class_obd.c, cleanup.sh, genops.c, obdcontrol, setup.sh: - Changes to accomodate the snapshot driver. - - For working snapshot code, see the snap directory and the - snap/setup.sh script. The code is not complete, unlink hasn't been - done yet. - -1999-11-24 12:42 braam - - * snap/snap.c: first working snapshot OBD driver; see setup.sh for - usage. - -1999-11-03 - - * class/obdcontrol: add Device directive to change OBD device - while running - * class/obdcontrol: add Filesystem directive to change disk - partition while running - * rename sim_obd to ext2_obd; prevent doubling up on ext2_unlink - etc. - * obdfs/super.c fixes to pass device to kernel and to allow - mouting multiple devices. - * clean up the calling of operations and finding of connection - numbers from obdfs - -1999-11-02 12:19 braam - - * Makefile: Minimal changes to the makefiles. - -1999-11-02 12:12 braam - - * Configure, Makefile, make.rules, class/Makefile, doc/notes.txt, - ext2obd/Makefile, ext2obd/sim_obd.c, ext2obd/test.c, - ext2obd/test2.c, include/linux/inofs.h, include/linux/obd_rpc.h, - include/linux/obd_support.h, include/linux/obdfs.h, inofs/Makefile, - inofs/file.c, inofs/inofs.h, inofs/namei.c, inofs/rw.c, - inofs/super.c, obdfs/Makefile, obdfs/dir.c, obdfs/file.c, - obdfs/namei.c, obdfs/notes.txt, obdfs/rw.c, obdfs/super.c, - oraid1/Makefile, rpcclient/Makefile, rpcclient/obdxdr.c, - rpcclient/proc.c, rpcclient/rpc_obd.c, snap/Makefile, snap/snap.c, - tests/test.c, tests/test2.c: New direcotory layout: subdirs for - different clients and file systems documentation, tests and lib - subdirectories. - -1999-11-01 - - * OBDFS fixes: - - code ported to 2.3.24 (no patches needed anymore) - - the obdfs_find_entry function which had a nasty bug - - rename now works - - all pages are currently in a locked state when touched by obdfs - - Configure/Makefile fixed to work without MODVERSIONS - - read_inode/write_inode copy out the data area - -1999-11-01 10:44 braam - - * .cvsignore, ChangeLog, Configure, class/cleanup.sh, - class/genops.c, class/obdcontrol, class/setup.sh, class/sysctl.c, - doc/API.txt, ext2obd/Makefile, ext2obd/inode.c, ext2obd/sim_obd.c, - include/linux/obd_class.h, include/linux/obd_rpc.h, - include/linux/obd_snap.h, include/linux/obd_support.h, - include/linux/obdfs.h, inofs/Makefile, inofs/file.c, inofs/inofs.h, - inofs/namei.c, inofs/rw.c, inofs/super.c, inofs/sysctl.c, - obdfs/Makefile, obdfs/dir.c, obdfs/file.c, obdfs/namei.c, - obdfs/rw.c, obdfs/super.c, obdfs/symlink.c, obdfs/sysctl.c, - rpcclient/obdxdr.c, rpcclient/rpc_obd.c: Over of the changes: - Many bugfixes INOFS added SNAP added - - See ChangeLog for details - -1999-10-28 - - * INOFS: a new "inode" file system was written. It tests components - of obdfs and could be useful for Coda/AFS servers and object - databases. - - * This file system will not have directories, but access pure - objects. Readdir will be an iterator and to create objects with - known names (integers of course) the preallocation function will - need to be completed. - - * This will still need to exploit preallocation and and a readdir - function should be added - -1999-10-22 - - * Beginning of a "rpc_client" layout for OBD - - -1999-10-21 - - * Much of the snap shot client driver is there (see API.txt). - This driver introduced the need for substantial changes in the - calling interface of the OBD layers. More to come. - - * Part of the RAID1 driver added. Also here many changes to the - calling interface were needed. - -1999-10-21 12:39 braam - - * BUGS, ChangeLog, Configure, class/class_obd.c, class/genops.c, - class/obdcontrol, class/setup.sh, doc/OLVM.txt, ext2obd/Makefile, - ext2obd/sim_obd.c, oraid1/raid1_obd.c, snap/snap.c, - include/linux/obd.h, include/linux/obd_class.h, - include/linux/obd_raid1.h, include/linux/obd_sim.h, - include/linux/obd_snap.h, include/linux/obd_support.h, - include/linux/obdfs.h, obdfs/dir.c, obdfs/file.c, obdfs/namei.c, - obdfs/rw.c, obdfs/super.c, patches/patch-2.3.21: New files: for - raid1 for snap shots OLVM a technical description of the - logical volume management genops generic operations useful to - many obd clients - - Fixes: numerous fixes to the file system several fixes to - OBD and obdcontrol - - Current state: does not compile - -1999-10-21 00:47 braam - - * ChangeLog, Makefile, class/class_obd.c, class/cleanup.sh, - class/genops.c, class/obdcontrol, class/setup.sh, doc/OLVM.txt, - ext2obd/Makefile, ext2obd/ext2_obd.c, ext2obd/sim_obd.c, - ext2obd/super.c, include/linux/obd_class.h, - include/linux/obd_sim.h, include/linux/obd_snap.h, - include/linux/obd_support.h, include/linux/obdfs.h, obdfs/namei.c, - obdfs/rw.c, obdfs/super.c, oraid1/raid1_obd.c, rpcclient/rpc_obd.c, - scripts/maketags.sh, snap/snap.c: Cleanup : no more "sim" now - "ext2" can mount multiple devices obdcontrol - improved more work on snap (doesn't compile yet) - - check in just before we are again overhauling the - interface. - -1999-10-12 21:29 braam - - * Configure, class/class_obd.c, class/obdcontrol, - ext2obd/sim_obd.c, include/linux/obd_class.h, - include/linux/obd_support.h, include/linux/obdfs.h, obdfs/dir.c, - obdfs/namei.c, obdfs/rw.c, obdfs/super.c: Numerous fixes, including - the attach code, better page locking etc. - -1999-09-25 21:20 braam - - * class/class_obd.c, class/obdcontrol, doc/API.txt, - ext2obd/sim_obd.c, ext2obd/super.c, include/linux/obd_class.h, - include/linux/obd_sim.h, include/linux/obd_support.h, - include/linux/obdfs.h, obdfs/Makefile, obdfs/dir.c, obdfs/file.c, - obdfs/namei.c, obdfs/rw.c, obdfs/super.c, obdfs/sysctl.c: Added - code for obdfs to do writes to files and reads of directories and - files. - -1999-09-11 00:25 braam - - * class/class_obd.c, class/obdcontrol, class/sysctl.c, - ext2obd/Makefile, ext2obd/balloc.c, ext2obd/bitmap.c, - ext2obd/dir.c, ext2obd/file.c, ext2obd/fsync.c, ext2obd/ialloc.c, - ext2obd/inode.c, ext2obd/interface.c, ext2obd/ioctl.c, - ext2obd/psdev.c, ext2obd/sim_obd.c, ext2obd/super.c, - ext2obd/truncate.c, include/linux/obd_class.h, - include/linux/obd_psdev.h, include/linux/obd_sim.h, - include/linux/presto.h, include/linux/presto_upcall.h, - include/linux/sim_obd.h: Much cleaner separation of the class and - simulated obd code. - -1999-09-11 00:25 braam - - * include/linux/obd_support.h: Whoops, forgotten! - -1999-09-03 15:01 braam - - * Configure, class/obdcontrol, ext2obd/interface.c, - ext2obd/ioctl.c, ext2obd/psdev.c: fixes for deliverables. - -1999-09-03 15:01 braam - - * COPYING: forgot the good old gpl - -1999-08-31 17:05 braam - - * class/obdcontrol, ext2obd/Makefile, ext2obd/README, - ext2obd/acl.c, ext2obd/balloc.c, ext2obd/dir.c, ext2obd/file.c, - ext2obd/fsync.c, ext2obd/ialloc.c, ext2obd/inode.c, - ext2obd/interface.c, ext2obd/ioctl.c, ext2obd/super.c, - ext2obd/symlink.c, ext2obd/test.c, ext2obd/truncate.c: Fixes for - Linux 2.3 as well as bug fixes after Ayman's testing. - -1999-08-31 17:05 braam - - * patches/: patch-2.2.10, patch-2.3.15: patches for the kernel - code. - -1999-08-31 17:05 braam - - * obdfs/super.c: Minor change for Linux 2.3 - -1999-08-16 16:41 braam - - * obdfs/super.c: fix the module unloading bug. - -1999-08-10 10:18 braam - - * Configure, class/obdcontrol, doc/API.txt, ext2obd/Makefile, - ext2obd/README, ext2obd/file.c, ext2obd/ialloc.c, ext2obd/inode.c, - ext2obd/interface.c, ext2obd/ioctl.c, ext2obd/psdev.c, - ext2obd/super.c, include/linux/obdfs.h, include/linux/sim_obd.h, - obdfs/README, obdfs/notes.txt: Numerous patches and fixes to Phil's - initial attack. - - In particular we now have clean tracking of inode counts, so that - things attach detach cleanly. Enough there for deliverable 1 & 2. - -1999-07-28 22:10 pschwan - - * doc/API.txt, ext2obd/README, ext2obd/interface.c: [no log - message] - -1999-07-28 10:11 braam - - * Configure, Makefile, class/sysctl.c, ext2obd/balloc.c, - ext2obd/bitmap.c, ext2obd/dir.c, ext2obd/file.c, ext2obd/fsync.c, - ext2obd/ialloc.c, ext2obd/inode.c, ext2obd/interface.c, - ext2obd/ioctl.c, ext2obd/psdev.c, ext2obd/super.c, - ext2obd/truncate.c, include/linux/obdfs.h, include/linux/sim_obd.h, - include/linux/sym_obd.h, obdfs/super.c, obdfs/sysctl.c: Fixed a - spelling mistake: "symulated" --> "simulated" (sym_obd etc). - - Improved configuration scripts - - Removed compiler warnings from re-defining ext2_error - -1999-06-24 16:16 pschwan - - * Configure, Makefile, class/obdcontrol, ext2obd/file.c, - ext2obd/ialloc.c, ext2obd/inode.c, ext2obd/interface.c, - ext2obd/ioctl.c, ext2obd/psdev.c, ext2obd/super.c, - include/linux/sym_obd.h, include/linux/obdfs.h, obdfs/Makefile, - obdfs/super.c, obdfs/sysctl.c: the last two weeks' work - -1999-06-09 18:17 pschwan - - * class/obdcontrol, ext2obd/balloc.c, ext2obd/bitmap.c, - ext2obd/dir.c, ext2obd/file.c, ext2obd/fsync.c, ext2obd/ialloc.c, - ext2obd/inode.c, ext2obd/interface.c, ext2obd/ioctl.c, - ext2obd/super.c, ext2obd/truncate.c, include/linux/sym_obd.h: - mostly read, 2.2.1 -> 2.2.9 updates - -1999-06-05 13:02 pschwan - - * class/obdcontrol, class/sysctl.c, ext2obd/Makefile, - ext2obd/balloc.c, ext2obd/bitmap.c, ext2obd/file.c, - ext2obd/ialloc.c, ext2obd/inode.c, ext2obd/interface.c, - ext2obd/ioctl.c, ext2obd/psdev.c, ext2obd/super.c, ext2obd/test.c, - ext2obd/test2.c, ext2obd/truncate.c, include/linux/presto.h, - include/linux/sym_obd.h: A couple days of changes--much - improvement. - -1999-06-02 19:34 pschwan - - * ext2obd/Makefile, ext2obd/balloc.c, ext2obd/bitmap.c, - ext2obd/dir.c, ext2obd/file.c, ext2obd/fsync.c, ext2obd/ialloc.c, - ext2obd/inode.c, ext2obd/interface.c, ext2obd/ioctl.c, - ext2obd/psdev.c, ext2obd/super.c, ext2obd/test.c, ext2obd/test2.c, - ext2obd/truncate.c, include/linux/obd_psdev.h, - include/linux/presto.h, include/linux/presto_upcall.h, - include/linux/sym_obd.h: foo - -1999-06-02 19:28 pschwan - - * Configure, Makefile, config.in: foo - diff --git a/lustre/FDL b/lustre/FDL deleted file mode 100644 index b42936b..0000000 --- a/lustre/FDL +++ /dev/null @@ -1,355 +0,0 @@ - GNU Free Documentation License - Version 1.1, March 2000 - - Copyright (C) 2000 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. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -written document "free" in the sense of freedom: to assure everyone -the effective freedom to copy and redistribute it, with or without -modifying it, either commercially or noncommercially. Secondarily, -this License preserves for the author and publisher a way to get -credit for their work, while not being considered responsible for -modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work that contains a -notice placed by the copyright holder saying it can be distributed -under the terms of this License. The "Document", below, refers to any -such manual or work. Any member of the public is a licensee, and is -addressed as "you". - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (For example, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, whose contents can be viewed and edited directly and -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup has been designed to thwart or discourage -subsequent modification by readers is not Transparent. A copy that is -not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML designed for human modification. Opaque formats include -PostScript, PDF, proprietary formats that can be read and edited only -by proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML produced by some word processors for output -purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies of the Document numbering more than 100, -and the Document's license notice requires Cover Texts, you must enclose -the copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a publicly-accessible computer-network location containing a complete -Transparent copy of the Document, free of added material, which the -general network-using public has access to download anonymously at no -charge using public-standard network protocols. If you use the latter -option, you must take reasonably prudent steps, when you begin -distribution of Opaque copies in quantity, to ensure that this -Transparent copy will remain thus accessible at the stated location -until at least one year after the last time you distribute an Opaque -copy (directly or through your agents or retailers) of that edition to -the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has less than five). -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section entitled "History", and its title, and add to - it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. In any section entitled "Acknowledgements" or "Dedications", - preserve the section's title, and preserve in the section all the - substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section as "Endorsements" - or to conflict in title with any Invariant Section. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections entitled "History" -in the various original documents, forming one section entitled -"History"; likewise combine any sections entitled "Acknowledgements", -and any sections entitled "Dedications". You must delete all sections -entitled "Endorsements." - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, does not as a whole count as a Modified Version -of the Document, provided no compilation copyright is claimed for the -compilation. Such a compilation is called an "aggregate", and this -License does not apply to the other self-contained works thus compiled -with the Document, on account of their being thus compiled, if they -are not themselves derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one quarter -of the entire aggregate, the Document's Cover Texts may be placed on -covers that surround only the Document within the aggregate. -Otherwise they must appear on covers around the whole aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License provided that you also include the -original English version of this License. In case of a disagreement -between the translation and the original English version of this -License, the original English version will prevail. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document 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. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation 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. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.1 - or any later version published by the Free Software Foundation; - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have no Invariant Sections, write "with no Invariant Sections" -instead of saying which ones are invariant. If you have no -Front-Cover Texts, write "no Front-Cover Texts" instead of -"Front-Cover Texts being LIST"; likewise for Back-Cover Texts. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. diff --git a/lustre/Makefile.am b/lustre/Makefile.am deleted file mode 100644 index 9072670..0000000 --- a/lustre/Makefile.am +++ /dev/null @@ -1,17 +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 - -AUTOMAKE_OPTIONS = foreign -SUBDIRS = ptlrpc llite lib ldlm obdecho mdc osc extN mds ost utils tests obdfilter -SUBDIRS+= obdclass obdext2 obdfs demos doc scripts -EXTRA_DIST = BUGS FDL Rules include patches - -# We get the version from the spec file. -configure: scripts/lustre.spec.in - -dist-hook: - find $(distdir) -name .deps | xargs rm -rf - -include $(top_srcdir)/Rules diff --git a/lustre/README b/lustre/README deleted file mode 100644 index 42592cb..0000000 --- a/lustre/README +++ /dev/null @@ -1 +0,0 @@ -Build instructions can be found in the lustre-HOWTO in the doc directory. diff --git a/lustre/Rules b/lustre/Rules deleted file mode 100644 index 828a8c9..0000000 --- a/lustre/Rules +++ /dev/null @@ -1,24 +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 - -# Build a kernel module, name.o, and install it in $(moduledir) by: -# MODULE = name -# module_DATA = name.o -# EXTRA_PROGRAMS = name -# name_SOURCES = my.c files.c -# include $(top_srcdir)/Rules - -$(MODULE).o: $($(MODULE)_OBJECTS) - $(LD) -m "`$(LD) --help | awk '/supported emulations/ {print $$4}'`" -r -o $(MODULE).o $($(MODULE)_OBJECTS) - -tags: - rm -f $(top_srcdir)/TAGS - rm -f $(top_srcdir)/tags - find $(top_srcdir)/../portals -name '*.[hc]' | xargs etags -a - find $(top_srcdir) -name '*.[hc]' | xargs etags -a - find $(top_srcdir)/../portals -name '*.[hc]' | xargs ctags -a - find $(top_srcdir) -name '*.[hc]' | xargs ctags -a - -EXTRA_DIST += CVS \ No newline at end of file diff --git a/lustre/archdep.m4 b/lustre/archdep.m4 deleted file mode 100644 index 7c7a1c8..0000000 --- a/lustre/archdep.m4 +++ /dev/null @@ -1,75 +0,0 @@ -AC_MSG_CHECKING(if you are running user mode linux for $host_alias..) -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 - host_cpu="um"; - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -else - AC_MSG_RESULT(no) -fi - -AC_MSG_CHECKING(setting make flags system architecture: ) -case ${host_cpu} in - um ) - AC_MSG_RESULT($host_cpu) - KCFLAGS='-g -Wall -pipe -Wno-trigraphs -Wstrict-prototypes -fno-strict-aliasing -fno-common ' - KCPPFLAGS='-D__KERNEL__ -U__i386__ -Ui386 -DUM_FASTCALL -D__arch_um__ -DSUBARCH="i386" -DNESTING=0 -D_LARGEFILE64_SOURCE -Derrno=kernel_errno -DPATCHLEVEL=4 -DMODULE -I$(LINUX)/arch/um/include ' - MOD_LINK=elf_i386 -;; - i*86 ) - AC_MSG_RESULT($host_cpu) - KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -pipe' - KCPPFLAGS='-D__KERNEL__ -DMODULE ' - MOD_LINK=elf_i386 -;; - - alpha ) - AC_MSG_RESULT($host_cpu) - KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -pipe' - KCPPFLAGS='-D__KERNEL__ -DMODULE ' - MOD_LINK=elf64_alpha -;; - - ia64 ) - AC_MSG_RESULT($host_cpu) - KCFLAGS='-Wall -Wstrict-prototypes -Wno-trigraphs -g -O2 -fno-strict-aliasing -fno-common -pipe -ffixed-r13 -mfixed-range=f10-f15,f32-f127 -falign-functions=32 -mb-step' - KCPPFLAGS='-D__KERNEL__ -DMODULE' - MOD_LINK=elf64_ia64 -;; - - sparc64 ) - AC_MSG_RESULT($host_cpu) - KCFLAGS='-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -Wno-unused -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare -Wa,--undeclared-regs' - KCPPFLAGS='-D__KERNEL__' - MOD_LINK=elf64_sparc - -;; - - default ) - AC_ERROR("Unknown Linux Platform") -esac - -AC_MSG_CHECKING(for MODVERSIONS) -if egrep -e 'MODVERSIONS.*1' $LINUX/include/linux/autoconf.h >/dev/null 2>&1; -then - MFLAGS="-DMODULE -DMODVERSIONS -include $LINUX/include/linux/modversions.h -DEXPORT_SYMTAB" - AC_MSG_RESULT(yes) -else - MFLAGS= - AC_MSG_RESULT(no) -fi - -AC_MSG_CHECKING(for SMP) -if egrep -e SMP=y $LINUX/.config >/dev/null 2>&1; then - SMPFLAG= - AC_MSG_RESULT(yes) -else - SMPFLAG= - AC_MSG_RESULT(no) -fi - -CFLAGS="$KCFLAGS $MFLAGS" -ARCHCPPFLAGS="$KCPPFLAGS" diff --git a/lustre/autogen.sh b/lustre/autogen.sh deleted file mode 100644 index 2468998..0000000 --- a/lustre/autogen.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -find . -type d -name .deps | xargs rm -rf -automake --add-missing && -aclocal && -autoconf diff --git a/lustre/configure.in b/lustre/configure.in deleted file mode 100644 index 1a6a722..0000000 --- a/lustre/configure.in +++ /dev/null @@ -1,84 +0,0 @@ -AC_INIT -AC_CANONICAL_SYSTEM - -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -# Automake variables. Steal the version number from lustre.spec.in. -AM_INIT_AUTOMAKE(obd, builtin([esyscmd], [sed -ne '/^%define version /{ s/.*version //; p; q; }' scripts/lustre.spec.in])) -#AM_MAINTAINER_MODE -AC_PROG_CC -AC_PROG_RANLIB - -# Kernel build environment. -ac_default_prefix= -bindir='${exec_prefix}/usr/bin' -sbindir='${exec_prefix}/usr/sbin' - -linuxdir_def=/usr/src/linux -AC_ARG_ENABLE(linuxdir, [ --enable-linuxdir=[path] set path to Linux source (default=/usr/src/linux)],, enable_linuxdir=$linuxdir_def) - -LINUX=$enable_linuxdir -AC_SUBST(LINUX) - -sinclude(archdep.m4) - -KINCFLAGS='-I. -I$(top_srcdir)/include -I$(PORTALS)/include -I$(LINUX)/include' -CPPFLAGS="$KINCFLAGS $ARCHCPPFLAGS" - -portalsdir_def='$(top_srcdir)/../portals' -AC_ARG_ENABLE(portalsdir, [ --enable-portalsdir=[path] set path to Portals source (default=../portals)],, enable_portalsdir=$portalsdir_def) -PORTALS=$enable_portalsdir -AC_SUBST(PORTALS) - -AC_MSG_CHECKING(if make dep has been run in kernel source) -if test -f $LINUX/include/linux/config.h ; then - AC_MSG_RESULT(yes) -else - AC_MSG_ERROR(** cannot find $LINUX/include/linux/config.h. Run make dep in $LINUX.) -fi - -AC_MSG_CHECKING(if autoconf.h is in kernel source) -if test -f $LINUX/include/linux/autoconf.h ; then - AC_MSG_RESULT(yes) -else - AC_MSG_ERROR(** cannot find $LINUX/include/linux/autoconf.h. Run make config in $LINUX.) -fi - - -AC_MSG_CHECKING(for Linux release) - -dnl We need to rid ourselves of the nasty [ ] quotes. -changequote(, ) -LVERSION="`sed -ne 's/^VERSION[ ]*=[ ]*//gp' $LINUX/Makefile`" -PATCHLEVEL="`sed -ne 's/^PATCHLEVEL[ ]*=[ ]*//gp' $LINUX/Makefile`" -SUBLEVEL="`sed -ne 's/^SUBLEVEL[ ]*=[ ]*//gp' $LINUX/Makefile`" -EXTRAVERSION="`sed -ne 's/^EXTRAVERSION[ ]*=[ ]*//gp' $LINUX/Makefile`" -changequote([, ]) - -RELEASE="$LVERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" -moduledir='$(libdir)/modules/'$RELEASE -AC_SUBST(moduledir) -AC_SUBST(EXTRAVERSION) - -modulefsdir='$(moduledir)/fs' -AC_SUBST(modulefsdir) - -AC_MSG_RESULT($RELEASE) -AC_SUBST(RELEASE) - -# Directories for documentation and demos. -docdir='${prefix}/usr/share/doc/$(PACKAGE)' -AC_SUBST(docdir) - -demodir='$(docdir)/demo' -AC_SUBST(demodir) - -AC_OUTPUT(Makefile lib/Makefile ldlm/Makefile obdecho/Makefile ptlrpc/Makefile \ - osc/Makefile mdc/Makefile mds/Makefile ost/Makefile utils/Makefile \ - tests/Makefile obdfilter/Makefile obdclass/Makefile obdext2/Makefile \ - llite/Makefile obdfs/Makefile demos/Makefile \ - doc/Makefile scripts/Makefile scripts/lustre.spec \ - extN/Makefile) diff --git a/lustre/demos/.cvsignore b/lustre/demos/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/demos/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/demos/Makefile.am b/lustre/demos/Makefile.am deleted file mode 100644 index 49d579d..0000000 --- a/lustre/demos/Makefile.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 - -demo_SCRIPTS = baseclean.sh basesetup.sh obdfsclean.sh obdfssetup.sh \ - obdtest.sh snap3clean.sh snap3set.sh snapclean.sh snapdel.sh \ - snaprest.sh snaprestclean.sh snapsetup.sh snaptest.sh -demo_DATA = config.sh -EXTRA_DIST = $(demo_SCRIPTS) $(demo_DATA) - -include $(top_srcdir)/Rules - diff --git a/lustre/demos/baseclean.sh b/lustre/demos/baseclean.sh deleted file mode 100755 index 93730ee..0000000 --- a/lustre/demos/baseclean.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Script to remove the loopback device and temp file created in newtest.sh -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - - -mount | grep "$MNTOBD " > /dev/null 2>&1 -if [ x$? = x0 ]; then - echo "Stuff still mounted on $MNTOBD" - exit 1 -fi - -mount | grep "$MNTSNAP " > /dev/null 2>&1 -if [ x$? = x0 ]; then - echo "Stuff still mounted on $MNTSNAP" - exit 2 -fi - -mount | grep "$MNTSNAP2 " > /dev/null 2>&1 -if [ x$? = x0 ]; then - echo "Stuff still mounted on $MNTSNAP2" - exit 3 -fi - - -if [ "$LOOPDEV" ]; then - losetup -d $LOOPDEV - rmmod loop > /dev/null 2>&1 -fi - -if [ "$LOOPDEV" -a "$TMPFILE" -a -f "$TMPFILE" ]; then - rm -i $TMPFILE -fi - diff --git a/lustre/demos/basesetup.sh b/lustre/demos/basesetup.sh deleted file mode 100755 index 3b0bad8..0000000 --- a/lustre/demos/basesetup.sh +++ /dev/null @@ -1,68 +0,0 @@ -#! /bin/sh -# Get the locations for the files from a single place to avoid confusion -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution -OBDDIR="`dirname $0`/.." - -# source config info -. $OBDDIR/demos/config.sh - -insmod obdclass -insmod obdext2 -insmod obdfs - -# module configuration -if [ "$MODCONF" -a -f $MODCONF ]; then - if [ -z "`grep -i "alias *char-major-$OBDMAJ *obdclass" $MODCONF`" ]; then - if [ -d /etc/modutils ]; then - # Debian-style modules configuration. - echo "alias char-major-${OBDMAJ} obdclass" > /etc/modutils/obd - update-modules - else - echo "alias char-major-${OBDMAJ} obdclass" >>$MODCONF - fi - fi -fi - - -# temp file -if [ "$LOOPDEV" -a "$TMPFILE" -a -f $TMPFILE ]; then - echo "$TMPFILE exists; I'm unwilling to overwrite it. Remove [N/y]?" 1>&2 - rm -i $TMPFILE - [ -f $TMPFILE ] && exit 1 -fi -[ "$TMPFILE" ] && dd if=/dev/zero of=$TMPFILE bs=1k count=$TMPSIZE - - -# loop device -if [ "$LOOPDEV" ]; then - insmod loop > /dev/null 2>&1 - if [ -a "`losetup $LOOPDEV 2> /dev/null`" ]; then - echo "It appears that $LOOPDEV is in use. Unable to continue" 1>&2 - echo "You need to clean up $LOOPDEV (via cleanup.sh)," - echo "or you can change which device is used in demos/config.sh" 1>&2 - # undo previous - [ "$TMPFILE" ] && rm $TMPFILE - exit 2 - fi - losetup $LOOPDEV $TMPFILE -fi - -# Ensure that we have the correct devices for OBD to work -[ ! -c /dev/obd0 ] && mknod /dev/obd0 c $OBDMAJ 0 -[ ! -c /dev/obd1 ] && mknod /dev/obd1 c $OBDMAJ 1 -[ ! -c /dev/obd2 ] && mknod /dev/obd2 c $OBDMAJ 2 - - -if [ "$BASEDEV" ]; then - # echo "No mke2fs!!" - mke2fs -r 0 -b 4096 $BASEDEV -else - echo "\$BASEDEV not defined in demos/config.sh. Please fix!" - [ "$LOOPDEV" ] && losetup -d $LOOPDEV - [ "$TMPFILE" ] && rm $TMPFILE - exit 3 -fi diff --git a/lustre/demos/config.sh b/lustre/demos/config.sh deleted file mode 100644 index 4d19a29..0000000 --- a/lustre/demos/config.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# File which holds configuation parameters in a single place to avoid any -# mismatch between scripts (especially the cleanup scripts, which are -# destructive). -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution -#set -vx - -# Major number for OBD devices -OBDMAJ=186 - -# Module configuration file -[ -f /etc/conf.modules ] && MODCONF=/etc/conf.modules -[ -z "$MODCONF" -a -f /etc/modules.conf ] && MODCONF=/etc/modules.conf - -# If LOOPDEV is empty (""), then no loopback device will be configured. -# If TMPFILE is empty (""), then no temporary file will be created for loop. -[ "$TMPFILE" ] || TMPFILE="/tmp/obdfs.tmpfile" -[ "$TMPSIZE" ] || TMPSIZE=10240 -[ -b /dev/loop/0 ] && LOOPDEV=/dev/loop/0 -[ -z "$LOOPDEV" -a -b /dev/loop0 ] && LOOPDEV="/dev/loop0" - -# If LOOPDEV is empty, then it is assumed that BASEDEV is a real block device -# that doesn't mind being overwritten - don't use a partition with data on it!! -LOOPDEV="/dev/loop0" -BASEDEV="/dev/loop0" - -# The following are mount points for the filesystems during the test. -MNTOBD="/mnt/obd" -MNTSNAP="/mnt/snap" -MNTSNAP2="/mnt/snap2" - -# This is where the snapshot table will be stored: -SNAPTABLE="/tmp/obdfs.snaptable" - -# A simple routine called by most of the scripts to help debugging. The -# kernel code has a lot of debugging statements, so this helps us keep -# track of what is going on in user-land to generate the kernel messages. -plog () { - if [ "$1" = "log" ]; then - shift - logger -p kern.info "******** $* **********" - echo "$*" - else - logger -p kern.info "****start**** $* *****" - echo "$*" - $* - logger -p kern.info "*****end***** $* *****" - fi -} - -# A routine to display a command, and prompt user if it should be run -qrun () { - echo - echo -n "Run '$*' [Y/n]?'"; - read JUNK - - case $JUNK in - n*|N*) echo "'$*' not run" ;; - *) plog $* ;; - esac -} diff --git a/lustre/demos/obdfsclean.sh b/lustre/demos/obdfsclean.sh deleted file mode 100755 index c0fa384..0000000 --- a/lustre/demos/obdfsclean.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Utility script for cleaning up a simple OBDFS mounted filesystem -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -plog umount $MNTOBD -#killall pupdated # stop the OBDFS flush daemon -plog rmmod obdfs - -plog log "CLEANUP/DETACH" -$OBDDIR/utils/obdctl << EOF -device 0 -cleanup -detach -quit -EOF - -plog rmmod xfs -plog rmmod xfs_support -plog rmmod pagebuf -plog rmmod obdfilter -plog rmmod obdext2 -plog rmmod obdclass - -$OBDDIR/demos/baseclean.sh diff --git a/lustre/demos/obdfssetup.sh b/lustre/demos/obdfssetup.sh deleted file mode 100755 index 80acc66..0000000 --- a/lustre/demos/obdfssetup.sh +++ /dev/null @@ -1,34 +0,0 @@ -#! /bin/bash -# Utility script for configuring a simple OBDFS mount -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -$OBDDIR/demos/basesetup.sh - -if [ x$? != x0 ]; then - echo "Error running basesetup.sh" - exit 4; -fi - -#insmod $OBDDIR/class/obdclass.o -#insmod $OBDDIR/ext2obd/obdext2.o -#insmod $OBDDIR/obdfs/obdfs.o - -plog log "ATTACHING device 0 SETUP $BASEDEV" -$OBDDIR/utils/obdctl << EOF -device 0 -# attach obdfilter -# setup $BASEDEV reiserfs -attach obdext2 -setup $BASEDEV -quit -EOF - -[ ! -d "$MNTOBD" ] && mkdir $MNTOBD -plog mount -t obdfs -odevice=/dev/obd0 none $MNTOBD diff --git a/lustre/demos/obdtest.sh b/lustre/demos/obdtest.sh deleted file mode 100755 index e1235f2..0000000 --- a/lustre/demos/obdtest.sh +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/bash -# Utility script to create an OBD snapshot. If an existing filesystem is -# not already mounted on /mnt/obd, we call the basic OBD setup script to -# create and mount a filesystem for us. -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -[ ! -d $MNTOBD/lost+found ] && $OBDDIR/demos/obdfssetup.sh - -echo "echo yesterday >> $MNTOBD/hello" # create a file -echo "yesterday" > $MNTOBD/hello -echo "echo testing > $MNTOBD/goodbye" # create a file -echo "testing" > $MNTOBD/goodbye -plog ln -s hello $MNTOBD/link # create a symbolic link -cd $MNTOBD ; plog touch a b c ; cd - # create a file diff --git a/lustre/demos/snap3clean.sh b/lustre/demos/snap3clean.sh deleted file mode 100755 index a660ad2..0000000 --- a/lustre/demos/snap3clean.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# Utility script for cleaning up a third snapshot created by setup3.sh -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -plog umount $MNTSNAP2 - -plog log "CLEANUP /dev/obd3" -$OBDDIR/utils/obdcontrol -f << EOF -device /dev/obd3 -cleanup -detach -quit -EOF - -$OBDDIR/demos/snapclean.sh diff --git a/lustre/demos/snap3set.sh b/lustre/demos/snap3set.sh deleted file mode 100755 index d32baba..0000000 --- a/lustre/demos/snap3set.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Utility script for creating a third snapshot. -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -[ ! -d $MNTSNAP/lost+found ] && $OBDDIR/demos/snapsetup.sh - -$OBDDIR/demos/snaptest.sh - -sync -sleep 5 # let syslog logs get written - -plog log "CREATING /dev/obd3 snapshot" -$OBDDIR/utils/obdcontrol -f << EOF -snaptable -$SNAPTABLE -a -3 -now -q -y -snapset 0 $SNAPTABLE -device /dev/obd3 -attach obdsnap 0 3 0 -setup -quit -EOF - -[ ! -d "$MNTSNAP2" ] && mkdir $MNTSNAP2 -plog mount -t obdfs -oro,device=/dev/obd3 none $MNTSNAP2 diff --git a/lustre/demos/snapclean.sh b/lustre/demos/snapclean.sh deleted file mode 100755 index ecc94ee..0000000 --- a/lustre/demos/snapclean.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/bash -# Utility script for cleaning up snapshots and removing modules. -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -plog umount $MNTOBD -plog umount $MNTSNAP - -plog log "CLEANUP /dev/obd2 /dev/obd1" -$OBDDIR/utils/obdcontrol -f << EOF -device /dev/obd2 -cleanup -detach -device /dev/obd1 -cleanup -detach -quit -EOF - -rmmod obdsnap - -rm $SNAPTABLE -$OBDDIR/demos/obdfsclean.sh diff --git a/lustre/demos/snapdel.sh b/lustre/demos/snapdel.sh deleted file mode 100755 index 06e33a4..0000000 --- a/lustre/demos/snapdel.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Utility script to test deleting a snapshot that has been previously -# created as the setup.sh script does. -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -[ ! -d $MNTSNAP/lost+found ] && echo "need to run obdsetup.sh first" && exit 1 -[ ! -f $MNTOBD/hosts ] && $OBDDIR/demos/snaptest.sh - -plog umount $MNTSNAP -plog umount $MNTOBD - -sync -sleep 1 -plog log "STARTING snapdelete" -$OBDDIR/utils/obdcontrol -f << EOF -device /dev/obd2 -connect -snapdelete -disconnect -cleanup -detach -snaptable -$SNAPTABLE -d -2 -q -y -snapset 0 $SNAPTABLE -EOF -plog log "COMPLETE snapdelete" -plog mount -t obdfs -odevice=/dev/obd1 none $MNTOBD diff --git a/lustre/demos/snaprest.sh b/lustre/demos/snaprest.sh deleted file mode 100755 index b139e39..0000000 --- a/lustre/demos/snaprest.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# Utility script to test restoring a previous snapshot. This will destroy -# the "current" snapshot and restore the old one in its place. -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -[ ! -d $MNTSNAP/lost+found ] && echo "need to run snapsetup.sh first" && exit 1 - -plog umount $MNTSNAP -plog umount $MNTOBD - -mount | grep "$MNTOBD " > /dev/null 2>&1 -if [ x$? = x0 ]; then - echo "Stuff still mounted on $MNTOBD; clean up first." - exit -fi - -mount | grep "$MNTSNAP " > /dev/null 2>&1 -if [ x$? = x0 ]; then - echo "Stuff still mounted on $MNTSNAP; clean up first." - exit -fi - -sync -plog log "STARTING snaprestore" - - -$OBDDIR/utils/obdcontrol -f << EOF -device /dev/obd1 -cleanup -detach -device /dev/obd2 -connect -snaprestore 2 $SNAPTABLE 0 -quit -EOF - -plog log "COMPLETE snaprestore" - -plog mount -t obdfs -odevice=/dev/obd2 none $MNTOBD diff --git a/lustre/demos/snaprestclean.sh b/lustre/demos/snaprestclean.sh deleted file mode 100755 index 4b3b57d..0000000 --- a/lustre/demos/snaprestclean.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/bash -# Utility script for cleaning up a simple OBDFS mounted filesystem -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -umount $MNTOBD -mount | grep "$MNTOBD " > /dev/null 2>&1 -if [ x$? = x0 ]; then - echo "Stuff still mounted on $MNTOBD; clean up first." - exit -fi - -rmmod obdfs - -$OBDDIR/utils/obdcontrol -f << EOF -device /dev/obd2 -cleanup -detach -device /dev/obd0 -cleanup -detach -quit -EOF - -rmmod obdsnap -rmmod obdext2 -rmmod obdclass - -rm $SNAPTABLE -$OBDDIR/demos/baseclean.sh diff --git a/lustre/demos/snapsetup.sh b/lustre/demos/snapsetup.sh deleted file mode 100755 index 7db6ab1..0000000 --- a/lustre/demos/snapsetup.sh +++ /dev/null @@ -1,73 +0,0 @@ -#! /bin/bash -# Utility script to create an OBD snapshot. If an existing filesystem is -# not already mounted on /mnt/obd, we call the basic OBD setup script to -# create and mount a filesystem for us. -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - - -# prepare the snapshot drive with a file to be COW'd -if [ ! -d /mnt/obd/lost+found ]; then - $OBDDIR/demos/obdfssetup.sh - if [ x$? != x0 ]; then - echo "Error running obdfssetup.sh" - exit 4 - fi -fi - -if [ ! -f $MNTOBD/hello ]; then - $OBDDIR/demos/obdtest.sh - if [ x$? != x0 ]; then - echo "Error in obdfssetup.sh" - exit 4 - fi -fi - -plog umount $MNTOBD - -#plog insmod $OBDDIR/snap/obdsnap.o - -rm -f $SNAPTABLE - -plog log "NEW SNAP SETUP" -# Create two snapshots using the OBD snapshot driver. One will be the -# "current" snapshot (in obd device 1), where changes will take place. -# The current snapshot is required in order to use the filesystem. The -# second will be a snapshot of the filesystem taken "now" (in obd device 2) -# that will remain static (historical read-only) filesystem as changes -# are made to the current snapshot. -$OBDDIR/utils/obdcontrol -f << EOF -snaptable -$SNAPTABLE -a -1 -current -a -2 -now -q -y -snapset 0 $SNAPTABLE -device /dev/obd1 -attach obdsnap 0 1 0 -setup -device /dev/obd2 -attach obdsnap 0 2 0 -setup -quit -EOF - -# Mount the two filesystems. The filesystem under $MNTOBD will be the -# one where changes are made, while $MNTSNAP will contain the original -# files at the point when the snapshot was taken. - -[ ! -d "$MNTOBD" ] && mkdir $MNTOBD -[ ! -d "$MNTSNAP" ] && mkdir $MNTSNAP -plog mount -t obdfs -odevice=/dev/obd1 none $MNTOBD -plog mount -t obdfs -oro,device=/dev/obd2 none $MNTSNAP diff --git a/lustre/demos/snaptest.sh b/lustre/demos/snaptest.sh deleted file mode 100755 index 675a529..0000000 --- a/lustre/demos/snaptest.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Utility script to perform minor modifications to the read-write mounted -# snapshot in order to demonstrate the changes w.r.t. the read-only snapshot -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -plog chmod 777 $MNTOBD # change attributes on an existing file -plog rm $MNTOBD/a # delete an existing file -echo "echo today >> $MNTOBD/hello" # modify an existing file -echo today >> $MNTOBD/hello -plog cp /etc/group $MNTOBD # create a new file -plog ln -s goodbye $MNTOBD/newlink # create a new symlink diff --git a/lustre/doc/.cvsignore b/lustre/doc/.cvsignore deleted file mode 100644 index 249de7d..0000000 --- a/lustre/doc/.cvsignore +++ /dev/null @@ -1,14 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -tags -TAGS -OBD-HOWTO.html -OBD-HOWTO.txt -lustre-HOWTO.txt -*.eps -master.pdf diff --git a/lustre/doc/Makefile.am b/lustre/doc/Makefile.am deleted file mode 100644 index 46eddde..0000000 --- a/lustre/doc/Makefile.am +++ /dev/null @@ -1,35 +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 = .lyx .pdf .sgml .html .txt .fig .eps - -DOCS = master.pdf lustre-HOWTO.txt -IMAGES = bigpicture.eps intermezzo.eps mds.eps portals-lib.eps client.eps layering.eps metadata.eps sb.eps cow.eps lockacq.eps obdfs.eps snapsetup.eps dirbodyapi.eps loraid.eps ost.eps updates.eps hotmigrate.eps lustreclusters.eps osthw.eps portals-lib.eps -CLEANFILES = $(IMAGES) $(DOCS) - -EXTRA_DIST = $(DOCS) - -all: $(DOCS) - -.lyx.pdf: - @$(LYX2PDF) $< || printf "\n*** Warning: not creating PDF docs; install lyx to rectify this\n" - -.lyx.txt: - @$(LYX2TXT) $< || printf "\n*** Warning: not creating PDF docs; install lyx to rectify this\n" - -.lyx.html: - @$(LYX2HTML) $< || printf "\n*** Warning: not creating PDF docs; install lyx to rectify this\n" - -.fig.eps: - -fig2dev -L eps $< > $@ - -master.pdf: master.lyx $(IMAGES) - -dist-hook: - rm -rf $(distdir)/figs/CVS - -include $(top_srcdir)/Rules diff --git a/lustre/doc/VERSIONING b/lustre/doc/VERSIONING deleted file mode 100644 index 56a525b..0000000 --- a/lustre/doc/VERSIONING +++ /dev/null @@ -1,67 +0,0 @@ -Lustre versioning -================= - -0.0.1 2/19/2002 -0.0.2 3/14/2002 describe branches / stable tag - -This document describes versioning of source and binaries for Lustre. - -CVS -=== - -Versions will have 4 digits: - major.minor.patch.test - -Such versions will be tagged in CVS as: - v1_2_11_7 -and referred to as: - 1.2.11.7 -encoded as: - 0x01021107 - -Usage: ------- - -New numbers are used as follows: - -1. major: - - increased when major new functionality becomes available -2. minor: - - even: for each new release with new functionality - - odd : when a new development cycle starts after a release -3. patch: - - when a development snapshot or release update becomes available - - all these are announced on lustre-devel@lists.sf.net -4. test: - - when developers feel it is time to exchange a named version - -What will run, what won't ? ---------------------------- - -1. If the test level is non-zero no guarantees of any kind are made. - -2. For three digit releases/tags the code should perform - according to the announcement. - -Moving tags ------------ - -The last stable release will be tagged: CVS tag "stable" -The last operational development snapshot will be CVS tag "dstable" - -Branches --------- - -For even minor releases a branch tag will be created. The branch tag -will be of the form: - -bmajor_minor - -Note that the CVS head is where development is going. If developers -use a branch they must eventually merge that back into the head. -Typically this is done by importing changes into the branch and -removing the sticky tags: - -cvs update -A - -fixing any conflicts and then committing. \ No newline at end of file diff --git a/lustre/extN/.cvsignore b/lustre/extN/.cvsignore deleted file mode 100644 index c4268fe..0000000 --- a/lustre/extN/.cvsignore +++ /dev/null @@ -1,18 +0,0 @@ -.Xrefs -Makefile -Makefile.in -.deps -TAGS -balloc.c -bitmap.c -dir.c -file.c -fsync.c -ialloc.c -inode.c -ioctl.c -namei.c -super.c -symlink.c -xattr.c -patch-stamp diff --git a/lustre/extN/Makefile.am b/lustre/extN/Makefile.am deleted file mode 100644 index 5202d9e..0000000 --- a/lustre/extN/Makefile.am +++ /dev/null @@ -1,74 +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 - -DEFS:=-DEXPORT_SYMTAB -MODULE = extN -modulefs_DATA = extN.o -EXTRA_PROGRAMS = extN - -EXTNP = htree-ext3-2.4.18.diff linux-2.4.18ea-0.8.26.diff -EXTNP+= ext3-2.4.18-ino_sb_macro.diff extN-misc-fixup.diff -EXTNC = balloc.c bitmap.c dir.c file.c fsync.c ialloc.c inode.c ioctl.c -EXTNC+= namei.c super.c symlink.c -EXTNI = extN_fs.h extN_fs_i.h extN_fs_sb.h extN_jbd.h -EXTN_EXTRA = include/linux/xattr.h include/linux/extN_xattr.h fs/extN/xattr.c -extN_SOURCES = $(EXTNC) $(EXTNI) xattr.c # punch.c -extN_DEPENDENCIES = patch-stamp -EXTRA_DIST = $(EXTNP) extN-2.4.18-ino_sb_fixup.diff extN-2.4.18-exports.diff -DISTCLEANFILES = $(EXTNC) $(EXTNI) patch-stamp *.orig *.rej -SUB=-e "s/ext3/extN/g" -e "s/EXT3/EXTN/g" - -include $(top_srcdir)/Rules - -# Create a fresh ext2 patch. -diff: - $(RM) extN.patchT - for f in $(EXTNC); do diff -u $(top_srcdir)/fs/extN/$$f $$f >> extN.patchT ; done - mv -f ext2.patchT $(srcdir)/ext2.patch-$(RELEASE) -.PHONY: diff - -# Patch the kernel files with our ext3 patches. We need to go through some -# extra hoops because the include files are in a different tree and because -# patch likes to make local copies of files with (sym)links when it is patching -# them. To avoid this, we copy/patch in the source dir instead of the build -# dir (if they are different). -patch-stamp: $(EXTNP) - $(RM) $@ - test -e $(top_srcdir)/fs || ln -sf . $(top_srcdir)/fs - set -vx;\ - list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(top_srcdir)/$$f; done - set -vx;\ - list='$(EXTNC)'; for f in $$list; do \ - sed $(SUB) $(LINUX)/fs/ext3/$$f > $(top_srcdir)/fs/extN/$$f; \ - done - set -vx;\ - list='$(EXTNI)'; for i in $$list; do \ - s=`echo $$i | sed "s/extN/ext3/"`; \ - sed $(SUB) $(LINUX)/include/linux/$$s > \ - $(top_srcdir)/include/linux/$$i; \ - done - set -vx;\ - if [ -f $(srcdir)/extN.patch-$(RELEASE) ]; then \ - patch -p0 < $(srcdir)/extN.patch-$(RELEASE); \ - else \ - list='$(EXTNP)'; for p in $$list; do \ - sed $(SUB) $(srcdir)/$$p|(cd $(top_srcdir);patch -p1)||exit -1;\ - done; \ - echo "It is OK if the following patch fails"; \ - (cd $(top_srcdir); patch -N -p1) < $(srcdir)/extN-2.4.18-exports.diff; \ - (cd $(top_srcdir); patch -p1) < $(srcdir)/extN-2.4.18-ino_sb_fixup.diff; \ - fi - echo timestamp > $@ - -$(EXTNC) $(EXTNI) $(EXTN_EXTRA) xattr.c: patch-stamp - -# Don't distribute any patched files. -dist-hook: - $(RM) $(top_srcdir)/fs - list='$(EXTNC)'; for f in $$list; do $(RM) $(distdir)/$$f; done - list='$(EXTNI)'; for i in $$list; do \ - $(RM) $(distdir)/../include/linux/$$i; \ - done - list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(distdir)/../$$f; done diff --git a/lustre/extN/ext3-2.4.18-ino_sb_macro.diff b/lustre/extN/ext3-2.4.18-ino_sb_macro.diff deleted file mode 100644 index 8fbbcd1..0000000 --- a/lustre/extN/ext3-2.4.18-ino_sb_macro.diff +++ /dev/null @@ -1,1657 +0,0 @@ ---- ./fs/ext3/balloc.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/balloc.c Tue May 7 15:35:59 2002 -@@ -46,18 +46,18 @@ struct ext3_group_desc * ext3_get_group_ - unsigned long desc; - struct ext3_group_desc * gdp; - -- if (block_group >= sb->u.ext3_sb.s_groups_count) { -+ if (block_group >= EXT3_SB(sb)->s_groups_count) { - ext3_error (sb, "ext3_get_group_desc", - "block_group >= groups_count - " - "block_group = %d, groups_count = %lu", -- block_group, sb->u.ext3_sb.s_groups_count); -+ block_group, EXT3_SB(sb)->s_groups_count); - - return NULL; - } - - group_desc = block_group / EXT3_DESC_PER_BLOCK(sb); - desc = block_group % EXT3_DESC_PER_BLOCK(sb); -- if (!sb->u.ext3_sb.s_group_desc[group_desc]) { -+ if (!EXT3_SB(sb)->s_group_desc[group_desc]) { - ext3_error (sb, "ext3_get_group_desc", - "Group descriptor not loaded - " - "block_group = %d, group_desc = %lu, desc = %lu", -@@ -66,9 +66,9 @@ struct ext3_group_desc * ext3_get_group_ - } - - gdp = (struct ext3_group_desc *) -- sb->u.ext3_sb.s_group_desc[group_desc]->b_data; -+ EXT3_SB(sb)->s_group_desc[group_desc]->b_data; - if (bh) -- *bh = sb->u.ext3_sb.s_group_desc[group_desc]; -+ *bh = EXT3_SB(sb)->s_group_desc[group_desc]; - return gdp + desc; - } - -@@ -104,8 +104,8 @@ static int read_block_bitmap (struct sup - * this group. The IO will be retried next time. - */ - error_out: -- sb->u.ext3_sb.s_block_bitmap_number[bitmap_nr] = block_group; -- sb->u.ext3_sb.s_block_bitmap[bitmap_nr] = bh; -+ EXT3_SB(sb)->s_block_bitmap_number[bitmap_nr] = block_group; -+ EXT3_SB(sb)->s_block_bitmap[bitmap_nr] = bh; - return retval; - } - -@@ -128,16 +128,17 @@ static int __load_block_bitmap (struct s - int i, j, retval = 0; - unsigned long block_bitmap_number; - struct buffer_head * block_bitmap; -+ struct ext3_sb_info *sbi = EXT3_SB(sb); - -- if (block_group >= sb->u.ext3_sb.s_groups_count) -+ if (block_group >= sbi->s_groups_count) - ext3_panic (sb, "load_block_bitmap", - "block_group >= groups_count - " - "block_group = %d, groups_count = %lu", -- block_group, sb->u.ext3_sb.s_groups_count); -+ block_group, EXT3_SB(sb)->s_groups_count); - -- if (sb->u.ext3_sb.s_groups_count <= EXT3_MAX_GROUP_LOADED) { -- if (sb->u.ext3_sb.s_block_bitmap[block_group]) { -- if (sb->u.ext3_sb.s_block_bitmap_number[block_group] == -+ if (sbi->s_groups_count <= EXT3_MAX_GROUP_LOADED) { -+ if (sbi->s_block_bitmap[block_group]) { -+ if (sbi->s_block_bitmap_number[block_group] == - block_group) - return block_group; - ext3_error (sb, "__load_block_bitmap", -@@ -149,21 +150,20 @@ static int __load_block_bitmap (struct s - return block_group; - } - -- for (i = 0; i < sb->u.ext3_sb.s_loaded_block_bitmaps && -- sb->u.ext3_sb.s_block_bitmap_number[i] != block_group; i++) -+ for (i = 0; i < sbi->s_loaded_block_bitmaps && -+ sbi->s_block_bitmap_number[i] != block_group; i++) - ; -- if (i < sb->u.ext3_sb.s_loaded_block_bitmaps && -- sb->u.ext3_sb.s_block_bitmap_number[i] == block_group) { -- block_bitmap_number = sb->u.ext3_sb.s_block_bitmap_number[i]; -- block_bitmap = sb->u.ext3_sb.s_block_bitmap[i]; -+ if (i < sbi->s_loaded_block_bitmaps && -+ sbi->s_block_bitmap_number[i] == block_group) { -+ block_bitmap_number = sbi->s_block_bitmap_number[i]; -+ block_bitmap = sbi->s_block_bitmap[i]; - for (j = i; j > 0; j--) { -- sb->u.ext3_sb.s_block_bitmap_number[j] = -- sb->u.ext3_sb.s_block_bitmap_number[j - 1]; -- sb->u.ext3_sb.s_block_bitmap[j] = -- sb->u.ext3_sb.s_block_bitmap[j - 1]; -+ sbi->s_block_bitmap_number[j] = -+ sbi->s_block_bitmap_number[j - 1]; -+ sbi->s_block_bitmap[j] = sbi->s_block_bitmap[j - 1]; - } -- sb->u.ext3_sb.s_block_bitmap_number[0] = block_bitmap_number; -- sb->u.ext3_sb.s_block_bitmap[0] = block_bitmap; -+ sbi->s_block_bitmap_number[0] = block_bitmap_number; -+ sbi->s_block_bitmap[0] = block_bitmap; - - /* - * There's still one special case here --- if block_bitmap == 0 -@@ -173,17 +173,14 @@ static int __load_block_bitmap (struct s - if (!block_bitmap) - retval = read_block_bitmap (sb, block_group, 0); - } else { -- if (sb->u.ext3_sb.s_loaded_block_bitmapsu.ext3_sb.s_loaded_block_bitmaps++; -+ if (sbi->s_loaded_block_bitmapss_loaded_block_bitmaps++; - else -- brelse (sb->u.ext3_sb.s_block_bitmap -- [EXT3_MAX_GROUP_LOADED - 1]); -- for (j = sb->u.ext3_sb.s_loaded_block_bitmaps - 1; -- j > 0; j--) { -- sb->u.ext3_sb.s_block_bitmap_number[j] = -- sb->u.ext3_sb.s_block_bitmap_number[j - 1]; -- sb->u.ext3_sb.s_block_bitmap[j] = -- sb->u.ext3_sb.s_block_bitmap[j - 1]; -+ brelse(sbi->s_block_bitmap[EXT3_MAX_GROUP_LOADED - 1]); -+ for (j = sbi->s_loaded_block_bitmaps - 1; j > 0; j--) { -+ sbi->s_block_bitmap_number[j] = -+ sbi->s_block_bitmap_number[j - 1]; -+ sbi->s_block_bitmap[j] = sbi->s_block_bitmap[j - 1]; - } - retval = read_block_bitmap (sb, block_group, 0); - } -@@ -206,24 +203,25 @@ static int __load_block_bitmap (struct s - static inline int load_block_bitmap (struct super_block * sb, - unsigned int block_group) - { -+ struct ext3_sb_info *sbi = EXT3_SB(sb); - int slot; -- -+ - /* - * Do the lookup for the slot. First of all, check if we're asking - * for the same slot as last time, and did we succeed that last time? - */ -- if (sb->u.ext3_sb.s_loaded_block_bitmaps > 0 && -- sb->u.ext3_sb.s_block_bitmap_number[0] == block_group && -- sb->u.ext3_sb.s_block_bitmap[0]) { -+ if (sbi->s_loaded_block_bitmaps > 0 && -+ sbi->s_block_bitmap_number[0] == block_group && -+ sbi->s_block_bitmap[0]) { - return 0; - } - /* - * Or can we do a fast lookup based on a loaded group on a filesystem - * small enough to be mapped directly into the superblock? - */ -- else if (sb->u.ext3_sb.s_groups_count <= EXT3_MAX_GROUP_LOADED && -- sb->u.ext3_sb.s_block_bitmap_number[block_group]==block_group -- && sb->u.ext3_sb.s_block_bitmap[block_group]) { -+ else if (sbi->s_groups_count <= EXT3_MAX_GROUP_LOADED && -+ sbi->s_block_bitmap_number[block_group] == block_group -+ && sbi->s_block_bitmap[block_group]) { - slot = block_group; - } - /* -@@ -243,7 +241,7 @@ static inline int load_block_bitmap (str - * If it's a valid slot, we may still have cached a previous IO error, - * in which case the bh in the superblock cache will be zero. - */ -- if (!sb->u.ext3_sb.s_block_bitmap[slot]) -+ if (!sbi->s_block_bitmap[slot]) - return -EIO; - - /* -@@ -275,8 +273,9 @@ void ext3_free_blocks (handle_t *handle, - return; - } - lock_super (sb); -- es = sb->u.ext3_sb.s_es; -- if (block < le32_to_cpu(es->s_first_data_block) || -+ es = EXT3_SB(sb)->s_es; -+ if (block < le32_to_cpu(es->s_first_data_block) || -+ block + count < block || - (block + count) > le32_to_cpu(es->s_blocks_count)) { - ext3_error (sb, "ext3_free_blocks", - "Freeing blocks not in datazone - " -@@ -304,22 +303,11 @@ do_more: - if (bitmap_nr < 0) - goto error_return; - -- bitmap_bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr]; -+ bitmap_bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr]; - gdp = ext3_get_group_desc (sb, block_group, &gd_bh); - if (!gdp) - goto error_return; - -- if (in_range (le32_to_cpu(gdp->bg_block_bitmap), block, count) || -- in_range (le32_to_cpu(gdp->bg_inode_bitmap), block, count) || -- in_range (block, le32_to_cpu(gdp->bg_inode_table), -- sb->u.ext3_sb.s_itb_per_group) || -- in_range (block + count - 1, le32_to_cpu(gdp->bg_inode_table), -- sb->u.ext3_sb.s_itb_per_group)) -- ext3_error (sb, "ext3_free_blocks", -- "Freeing blocks in system zones - " -- "Block = %lu, count = %lu", -- block, count); -- - /* - * We are about to start releasing blocks in the bitmap, - * so we need undo access. -@@ -340,19 +328,29 @@ do_more: - if (err) - goto error_return; - -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); -- err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access"); -+ err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); - if (err) - goto error_return; - -- for (i = 0; i < count; i++) { -+ for (i = 0; i < count; i++, block++) { -+ if (block == le32_to_cpu(gdp->bg_block_bitmap) || -+ block == le32_to_cpu(gdp->bg_inode_bitmap) || -+ in_range(block, le32_to_cpu(gdp->bg_inode_table), -+ EXT3_SB(sb)->s_itb_per_group)) { -+ ext3_error(sb, __FUNCTION__, -+ "Freeing block in system zone - block = %lu", -+ block); -+ continue; -+ } -+ - /* - * An HJ special. This is expensive... - */ - #ifdef CONFIG_JBD_DEBUG - { - struct buffer_head *debug_bh; -- debug_bh = sb_get_hash_table(sb, block + i); -+ debug_bh = sb_get_hash_table(sb, block); - if (debug_bh) { - BUFFER_TRACE(debug_bh, "Deleted!"); - if (!bh2jh(bitmap_bh)->b_committed_data) -@@ -365,9 +363,8 @@ do_more: - #endif - BUFFER_TRACE(bitmap_bh, "clear bit"); - if (!ext3_clear_bit (bit + i, bitmap_bh->b_data)) { -- ext3_error (sb, __FUNCTION__, -- "bit already cleared for block %lu", -- block + i); -+ ext3_error(sb, __FUNCTION__, -+ "bit already cleared for block %lu", block); - BUFFER_TRACE(bitmap_bh, "bit already cleared"); - } else { - dquot_freed_blocks++; -@@ -410,12 +407,11 @@ do_more: - if (!err) err = ret; - - /* And the superblock */ -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "dirtied superblock"); -- ret = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "dirtied superblock"); -+ ret = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); - if (!err) err = ret; - - if (overflow && !err) { -- block += count; - count = overflow; - goto do_more; - } -@@ -564,17 +560,18 @@ int ext3_new_block (handle_t *handle, st - } - - lock_super (sb); -- es = sb->u.ext3_sb.s_es; -+ es = EXT3_SB(sb)->s_es; - if (le32_to_cpu(es->s_free_blocks_count) <= - le32_to_cpu(es->s_r_blocks_count) && -- ((sb->u.ext3_sb.s_resuid != current->fsuid) && -- (sb->u.ext3_sb.s_resgid == 0 || -- !in_group_p (sb->u.ext3_sb.s_resgid)) && -+ ((EXT3_SB(sb)->s_resuid != current->fsuid) && -+ (EXT3_SB(sb)->s_resgid == 0 || -+ !in_group_p (EXT3_SB(sb)->s_resgid)) && - !capable(CAP_SYS_RESOURCE))) - goto out; - - ext3_debug ("goal=%lu.\n", goal); - -+repeat: - /* - * First, test whether the goal block is free. - */ -@@ -598,7 +595,7 @@ int ext3_new_block (handle_t *handle, st - if (bitmap_nr < 0) - goto io_error; - -- bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr]; -+ bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr]; - - ext3_debug ("goal is at %d:%d.\n", i, j); - -@@ -621,9 +618,9 @@ int ext3_new_block (handle_t *handle, st - * Now search the rest of the groups. We assume that - * i and gdp correctly point to the last group visited. - */ -- for (k = 0; k < sb->u.ext3_sb.s_groups_count; k++) { -+ for (k = 0; k < EXT3_SB(sb)->s_groups_count; k++) { - i++; -- if (i >= sb->u.ext3_sb.s_groups_count) -+ if (i >= EXT3_SB(sb)->s_groups_count) - i = 0; - gdp = ext3_get_group_desc (sb, i, &bh2); - if (!gdp) { -@@ -635,7 +632,7 @@ int ext3_new_block (handle_t *handle, st - if (bitmap_nr < 0) - goto io_error; - -- bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr]; -+ bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr]; - j = find_next_usable_block(-1, bh, - EXT3_BLOCKS_PER_GROUP(sb)); - if (j >= 0) -@@ -674,8 +671,8 @@ got_block: - fatal = ext3_journal_get_write_access(handle, bh2); - if (fatal) goto out; - -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); -- fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access"); -+ fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); - if (fatal) goto out; - - tmp = j + i * EXT3_BLOCKS_PER_GROUP(sb) -@@ -684,10 +681,21 @@ got_block: - if (tmp == le32_to_cpu(gdp->bg_block_bitmap) || - tmp == le32_to_cpu(gdp->bg_inode_bitmap) || - in_range (tmp, le32_to_cpu(gdp->bg_inode_table), -- sb->u.ext3_sb.s_itb_per_group)) -- ext3_error (sb, "ext3_new_block", -- "Allocating block in system zone - " -- "block = %u", tmp); -+ EXT3_SB(sb)->s_itb_per_group)) { -+ ext3_error(sb, __FUNCTION__, -+ "Allocating block in system zone - block = %u", tmp); -+ -+ /* Note: This will potentially use up one of the handle's -+ * buffer credits. Normally we have way too many credits, -+ * so that is OK. In _very_ rare cases it might not be OK. -+ * We will trigger an assertion if we run out of credits, -+ * and we will have to do a full fsck of the filesystem - -+ * better than randomly corrupting filesystem metadata. -+ */ -+ ext3_set_bit(j, bh->b_data); -+ goto repeat; -+ } -+ - - /* The superblock lock should guard against anybody else beating - * us to this point! */ -@@ -796,7 +804,7 @@ got_block: - if (!fatal) fatal = err; - - BUFFER_TRACE(bh, "journal_dirty_metadata for superblock"); -- err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); -+ err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); - if (!fatal) fatal = err; - - sb->s_dirt = 1; -@@ -829,11 +837,11 @@ unsigned long ext3_count_free_blocks (st - int i; - - lock_super (sb); -- es = sb->u.ext3_sb.s_es; -+ es = EXT3_SB(sb)->s_es; - desc_count = 0; - bitmap_count = 0; - gdp = NULL; -- for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { -+ for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) { - gdp = ext3_get_group_desc (sb, i, NULL); - if (!gdp) - continue; -@@ -842,7 +850,7 @@ unsigned long ext3_count_free_blocks (st - if (bitmap_nr < 0) - continue; - -- x = ext3_count_free (sb->u.ext3_sb.s_block_bitmap[bitmap_nr], -+ x = ext3_count_free (EXT3_SB(sb)->s_block_bitmap[bitmap_nr], - sb->s_blocksize); - printk ("group %d: stored = %d, counted = %lu\n", - i, le16_to_cpu(gdp->bg_free_blocks_count), x); -@@ -853,7 +861,7 @@ unsigned long ext3_count_free_blocks (st - unlock_super (sb); - return bitmap_count; - #else -- return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_blocks_count); -+ return le32_to_cpu(EXT3_SB(sb)->s_es->s_free_blocks_count); - #endif - } - -@@ -862,7 +870,7 @@ static inline int block_in_use (unsigned - unsigned char * map) - { - return ext3_test_bit ((block - -- le32_to_cpu(sb->u.ext3_sb.s_es->s_first_data_block)) % -+ le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) % - EXT3_BLOCKS_PER_GROUP(sb), map); - } - -@@ -930,11 +938,11 @@ void ext3_check_blocks_bitmap (struct su - struct ext3_group_desc * gdp; - int i; - -- es = sb->u.ext3_sb.s_es; -+ es = EXT3_SB(sb)->s_es; - desc_count = 0; - bitmap_count = 0; - gdp = NULL; -- for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { -+ for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) { - gdp = ext3_get_group_desc (sb, i, NULL); - if (!gdp) - continue; -@@ -968,7 +976,7 @@ void ext3_check_blocks_bitmap (struct su - "Inode bitmap for group %d is marked free", - i); - -- for (j = 0; j < sb->u.ext3_sb.s_itb_per_group; j++) -+ for (j = 0; j < EXT3_SB(sb)->s_itb_per_group; j++) - if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j, - sb, bh->b_data)) - ext3_error (sb, "ext3_check_blocks_bitmap", ---- ./fs/ext3/dir.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/dir.c Tue May 7 14:54:13 2002 -@@ -52,7 +52,7 @@ int ext3_check_dir_entry (const char * f - else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize) - error_msg = "directory entry across blocks"; - else if (le32_to_cpu(de->inode) > -- le32_to_cpu(dir->i_sb->u.ext3_sb.s_es->s_inodes_count)) -+ le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count)) - error_msg = "inode out of bounds"; - - if (error_msg != NULL) ---- ./fs/ext3/ialloc.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/ialloc.c Tue May 7 15:39:26 2002 -@@ -73,8 +73,8 @@ static int read_inode_bitmap (struct sup - * this group. The IO will be retried next time. - */ - error_out: -- sb->u.ext3_sb.s_inode_bitmap_number[bitmap_nr] = block_group; -- sb->u.ext3_sb.s_inode_bitmap[bitmap_nr] = bh; -+ EXT3_SB(sb)->s_inode_bitmap_number[bitmap_nr] = block_group; -+ EXT3_SB(sb)->s_inode_bitmap[bitmap_nr] = bh; - return retval; - } - -@@ -225,7 +225,7 @@ void ext3_free_inode (handle_t *handle, - clear_inode (inode); - - lock_super (sb); -- es = sb->u.ext3_sb.s_es; -+ es = EXT3_SB(sb)->s_es; - if (ino < EXT3_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) { - ext3_error (sb, "ext3_free_inode", - "reserved or nonexistent inode %lu", ino); -@@ -237,7 +237,7 @@ void ext3_free_inode (handle_t *handle, - if (bitmap_nr < 0) - goto error_return; - -- bh = sb->u.ext3_sb.s_inode_bitmap[bitmap_nr]; -+ bh = EXT3_SB(sb)->s_inode_bitmap[bitmap_nr]; - - BUFFER_TRACE(bh, "get_write_access"); - fatal = ext3_journal_get_write_access(handle, bh); -@@ -255,8 +255,8 @@ void ext3_free_inode (handle_t *handle, - fatal = ext3_journal_get_write_access(handle, bh2); - if (fatal) goto error_return; - -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get write access"); -- fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get write access"); -+ fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); - if (fatal) goto error_return; - - if (gdp) { -@@ -271,9 +271,9 @@ void ext3_free_inode (handle_t *handle, - if (!fatal) fatal = err; - es->s_free_inodes_count = - cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) + 1); -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, -+ BUFFER_TRACE(EXT3_SB(sb)->s_sbh, - "call ext3_journal_dirty_metadata"); -- err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); -+ err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); - if (!fatal) fatal = err; - } - BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); -@@ -305,6 +305,8 @@ struct inode * ext3_new_inode (handle_t - int i, j, avefreei; - struct inode * inode; - int bitmap_nr; -+ struct ext3_inode_info *ei; -+ struct ext3_sb_info *sbi; - struct ext3_group_desc * gdp; - struct ext3_group_desc * tmp; - struct ext3_super_block * es; -@@ -318,19 +320,21 @@ struct inode * ext3_new_inode (handle_t - inode = new_inode(sb); - if (!inode) - return ERR_PTR(-ENOMEM); -- init_rwsem(&inode->u.ext3_i.truncate_sem); -+ sbi = EXT3_SB(sb); -+ ei = EXT3_I(inode); -+ init_rwsem(&ei->truncate_sem); - - lock_super (sb); -- es = sb->u.ext3_sb.s_es; -+ es = sbi->s_es; - repeat: - gdp = NULL; - i = 0; - - if (S_ISDIR(mode)) { - avefreei = le32_to_cpu(es->s_free_inodes_count) / -- sb->u.ext3_sb.s_groups_count; -+ sbi->s_groups_count; - if (!gdp) { -- for (j = 0; j < sb->u.ext3_sb.s_groups_count; j++) { -+ for (j = 0; j < sbi->s_groups_count; j++) { - struct buffer_head *temp_buffer; - tmp = ext3_get_group_desc (sb, j, &temp_buffer); - if (tmp && -@@ -350,7 +354,7 @@ repeat: - /* - * Try to place the inode in its parent directory - */ -- i = dir->u.ext3_i.i_block_group; -+ i = EXT3_I(dir)->i_block_group; - tmp = ext3_get_group_desc (sb, i, &bh2); - if (tmp && le16_to_cpu(tmp->bg_free_inodes_count)) - gdp = tmp; -@@ -360,10 +364,10 @@ repeat: - * Use a quadratic hash to find a group with a - * free inode - */ -- for (j = 1; j < sb->u.ext3_sb.s_groups_count; j <<= 1) { -+ for (j = 1; j < sbi->s_groups_count; j <<= 1) { - i += j; -- if (i >= sb->u.ext3_sb.s_groups_count) -- i -= sb->u.ext3_sb.s_groups_count; -+ if (i >= sbi->s_groups_count) -+ i -= sbi->s_groups_count; - tmp = ext3_get_group_desc (sb, i, &bh2); - if (tmp && - le16_to_cpu(tmp->bg_free_inodes_count)) { -@@ -376,9 +380,9 @@ repeat: - /* - * That failed: try linear search for a free inode - */ -- i = dir->u.ext3_i.i_block_group + 1; -- for (j = 2; j < sb->u.ext3_sb.s_groups_count; j++) { -- if (++i >= sb->u.ext3_sb.s_groups_count) -+ i = EXT3_I(dir)->i_block_group + 1; -+ for (j = 2; j < sbi->s_groups_count; j++) { -+ if (++i >= sbi->s_groups_count) - i = 0; - tmp = ext3_get_group_desc (sb, i, &bh2); - if (tmp && -@@ -399,11 +403,11 @@ repeat: - if (bitmap_nr < 0) - goto fail; - -- bh = sb->u.ext3_sb.s_inode_bitmap[bitmap_nr]; -+ bh = sbi->s_inode_bitmap[bitmap_nr]; - - if ((j = ext3_find_first_zero_bit ((unsigned long *) bh->b_data, -- EXT3_INODES_PER_GROUP(sb))) < -- EXT3_INODES_PER_GROUP(sb)) { -+ sbi->s_inodes_per_group)) < -+ sbi->s_inodes_per_group) { - BUFFER_TRACE(bh, "get_write_access"); - err = ext3_journal_get_write_access(handle, bh); - if (err) goto fail; -@@ -436,8 +440,8 @@ repeat: - } - goto repeat; - } -- j += i * EXT3_INODES_PER_GROUP(sb) + 1; -- if (j < EXT3_FIRST_INO(sb) || j > le32_to_cpu(es->s_inodes_count)) { -+ j += i * sbi->s_inodes_per_group + 1; -+ if (j < sbi->s_first_ino || j > le32_to_cpu(es->s_inodes_count)) { - ext3_error (sb, "ext3_new_inode", - "reserved inode or inode > inodes count - " - "block_group = %d,inode=%d", i, j); -@@ -457,13 +461,13 @@ repeat: - err = ext3_journal_dirty_metadata(handle, bh2); - if (err) goto fail; - -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); -- err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(sbi->s_sbh, "get_write_access"); -+ err = ext3_journal_get_write_access(handle, sbi->s_sbh); - if (err) goto fail; - es->s_free_inodes_count = - cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) - 1); -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "call ext3_journal_dirty_metadata"); -- err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(sbi->s_sbh, "call ext3_journal_dirty_metadata"); -+ err = ext3_journal_dirty_metadata(handle, sbi->s_sbh); - sb->s_dirt = 1; - if (err) goto fail; - -@@ -483,31 +487,31 @@ repeat: - inode->i_blksize = PAGE_SIZE; - inode->i_blocks = 0; - inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; -- inode->u.ext3_i.i_flags = dir->u.ext3_i.i_flags & ~EXT3_INDEX_FL; -+ ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL; - if (S_ISLNK(mode)) -- inode->u.ext3_i.i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL); -+ ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL); - #ifdef EXT3_FRAGMENTS -- inode->u.ext3_i.i_faddr = 0; -- inode->u.ext3_i.i_frag_no = 0; -- inode->u.ext3_i.i_frag_size = 0; -+ ei->i_faddr = 0; -+ ei->i_frag_no = 0; -+ ei->i_frag_size = 0; - #endif -- inode->u.ext3_i.i_file_acl = 0; -- inode->u.ext3_i.i_dir_acl = 0; -- inode->u.ext3_i.i_dtime = 0; -- INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan); -+ ei->i_file_acl = 0; -+ ei->i_dir_acl = 0; -+ ei->i_dtime = 0; -+ INIT_LIST_HEAD(&ei->i_orphan); - #ifdef EXT3_PREALLOCATE -- inode->u.ext3_i.i_prealloc_count = 0; -+ ei->i_prealloc_count = 0; - #endif -- inode->u.ext3_i.i_block_group = i; -+ ei->i_block_group = i; - -- if (inode->u.ext3_i.i_flags & EXT3_SYNC_FL) -+ if (ei->i_flags & EXT3_SYNC_FL) - inode->i_flags |= S_SYNC; - if (IS_SYNC(inode)) - handle->h_sync = 1; - insert_inode_hash(inode); -- inode->i_generation = sb->u.ext3_sb.s_next_generation++; -+ inode->i_generation = sbi->s_next_generation++; - -- inode->u.ext3_i.i_state = EXT3_STATE_NEW; -+ ei->i_state = EXT3_STATE_NEW; - err = ext3_mark_inode_dirty(handle, inode); - if (err) goto fail; - -@@ -585,19 +589,19 @@ struct inode *ext3_orphan_get (struct su - - unsigned long ext3_count_free_inodes (struct super_block * sb) - { -+ struct ext3_sb_info *sbi = EXT3_SB(sb); -+ struct ext3_super_block *es = sbi->s_es; - #ifdef EXT3FS_DEBUG -- struct ext3_super_block * es; - unsigned long desc_count, bitmap_count, x; - int bitmap_nr; - struct ext3_group_desc * gdp; - int i; - - lock_super (sb); -- es = sb->u.ext3_sb.s_es; - desc_count = 0; - bitmap_count = 0; - gdp = NULL; -- for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { -+ for (i = 0; i < sbi->s_groups_count; i++) { - gdp = ext3_get_group_desc (sb, i, NULL); - if (!gdp) - continue; -@@ -606,8 +610,8 @@ unsigned long ext3_count_free_inodes (st - if (bitmap_nr < 0) - continue; - -- x = ext3_count_free (sb->u.ext3_sb.s_inode_bitmap[bitmap_nr], -- EXT3_INODES_PER_GROUP(sb) / 8); -+ x = ext3_count_free(sbi->s_inode_bitmap[bitmap_nr], -+ sbi->s_inodes_per_group / 8); - printk ("group %d: stored = %d, counted = %lu\n", - i, le16_to_cpu(gdp->bg_free_inodes_count), x); - bitmap_count += x; -@@ -617,7 +621,7 @@ unsigned long ext3_count_free_inodes (st - unlock_super (sb); - return desc_count; - #else -- return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_inodes_count); -+ return le32_to_cpu(es->s_free_inodes_count); - #endif - } - -@@ -626,16 +630,18 @@ unsigned long ext3_count_free_inodes (st - void ext3_check_inodes_bitmap (struct super_block * sb) - { - struct ext3_super_block * es; -+ struct ext3_sb_info *sbi; - unsigned long desc_count, bitmap_count, x; - int bitmap_nr; - struct ext3_group_desc * gdp; - int i; - -- es = sb->u.ext3_sb.s_es; -+ sbi = EXT3_SB(sb); -+ es = sbi->s_es; - desc_count = 0; - bitmap_count = 0; - gdp = NULL; -- for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { -+ for (i = 0; i < sbi->s_groups_count; i++) { - gdp = ext3_get_group_desc (sb, i, NULL); - if (!gdp) - continue; -@@ -644,7 +650,7 @@ void ext3_check_inodes_bitmap (struct su - if (bitmap_nr < 0) - continue; - -- x = ext3_count_free (sb->u.ext3_sb.s_inode_bitmap[bitmap_nr], -+ x = ext3_count_free (sbi->s_inode_bitmap[bitmap_nr], - EXT3_INODES_PER_GROUP(sb) / 8); - if (le16_to_cpu(gdp->bg_free_inodes_count) != x) - ext3_error (sb, "ext3_check_inodes_bitmap", ---- ./fs/ext3/inode.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/inode.c Tue May 7 15:41:23 2002 -@@ -196,7 +196,7 @@ void ext3_delete_inode (struct inode * i - * (Well, we could do this if we need to, but heck - it works) - */ - ext3_orphan_del(handle, inode); -- inode->u.ext3_i.i_dtime = CURRENT_TIME; -+ EXT3_I(inode)->i_dtime = CURRENT_TIME; - - /* - * One subtle ordering requirement: if anything has gone wrong -@@ -220,13 +220,14 @@ no_delete: - void ext3_discard_prealloc (struct inode * inode) - { - #ifdef EXT3_PREALLOCATE -+ struct ext3_inode_info *ei = EXT3_I(inode); - lock_kernel(); - /* Writer: ->i_prealloc* */ -- if (inode->u.ext3_i.i_prealloc_count) { -- unsigned short total = inode->u.ext3_i.i_prealloc_count; -- unsigned long block = inode->u.ext3_i.i_prealloc_block; -- inode->u.ext3_i.i_prealloc_count = 0; -- inode->u.ext3_i.i_prealloc_block = 0; -+ if (ei->i_prealloc_count) { -+ unsigned short total = ei->i_prealloc_count; -+ unsigned long block = ei->i_prealloc_block; -+ ei->i_prealloc_count = 0; -+ ei->i_prealloc_block = 0; - /* Writer: end */ - ext3_free_blocks (inode, block, total); - } -@@ -243,13 +244,15 @@ static int ext3_alloc_block (handle_t *h - unsigned long result; - - #ifdef EXT3_PREALLOCATE -+ struct ext3_inode_info *ei = EXT3_I(inode); -+ - /* Writer: ->i_prealloc* */ -- if (inode->u.ext3_i.i_prealloc_count && -- (goal == inode->u.ext3_i.i_prealloc_block || -- goal + 1 == inode->u.ext3_i.i_prealloc_block)) -+ if (ei->i_prealloc_count && -+ (goal == ei->i_prealloc_block || -+ goal + 1 == ei->i_prealloc_block)) - { -- result = inode->u.ext3_i.i_prealloc_block++; -- inode->u.ext3_i.i_prealloc_count--; -+ result = ei->i_prealloc_block++; -+ ei->i_prealloc_count--; - /* Writer: end */ - ext3_debug ("preallocation hit (%lu/%lu).\n", - ++alloc_hits, ++alloc_attempts); -@@ -259,8 +262,8 @@ static int ext3_alloc_block (handle_t *h - alloc_hits, ++alloc_attempts); - if (S_ISREG(inode->i_mode)) - result = ext3_new_block (inode, goal, -- &inode->u.ext3_i.i_prealloc_count, -- &inode->u.ext3_i.i_prealloc_block, err); -+ &ei->i_prealloc_count, -+ &ei->i_prealloc_block, err); - else - result = ext3_new_block (inode, goal, 0, 0, err); - /* -@@ -394,7 +397,7 @@ static Indirect *ext3_get_branch(struct - - *err = 0; - /* i_data is not going away, no lock needed */ -- add_chain (chain, NULL, inode->u.ext3_i.i_data + *offsets); -+ add_chain (chain, NULL, EXT3_I(inode)->i_data + *offsets); - if (!p->key) - goto no_block; - while (--depth) { -@@ -437,7 +440,8 @@ no_block: - - static inline unsigned long ext3_find_near(struct inode *inode, Indirect *ind) - { -- u32 *start = ind->bh ? (u32*) ind->bh->b_data : inode->u.ext3_i.i_data; -+ struct ext3_inode_info *ei = EXT3_I(inode); -+ u32 *start = ind->bh ? (u32*) ind->bh->b_data : ei->i_data; - u32 *p; - - /* Try to find previous block */ -@@ -453,9 +456,8 @@ static inline unsigned long ext3_find_ne - * It is going to be refered from inode itself? OK, just put it into - * the same cylinder group then. - */ -- return (inode->u.ext3_i.i_block_group * -- EXT3_BLOCKS_PER_GROUP(inode->i_sb)) + -- le32_to_cpu(inode->i_sb->u.ext3_sb.s_es->s_first_data_block); -+ return (ei->i_block_group * EXT3_BLOCKS_PER_GROUP(inode->i_sb)) + -+ le32_to_cpu(EXT3_SB(inode->i_sb)->s_es->s_first_data_block); - } - - /** -@@ -474,14 +477,15 @@ - static int ext3_find_goal(struct inode *inode, long block, Indirect chain[4], - Indirect *partial, unsigned long *goal) - { -+ struct ext3_inode_info *ei = EXT3_I(inode); - /* Writer: ->i_next_alloc* */ -- if (block == inode->u.ext3_i.i_next_alloc_block + 1) { -- inode->u.ext3_i.i_next_alloc_block++; -- inode->u.ext3_i.i_next_alloc_goal++; -+ if (block == ei->i_next_alloc_block + 1) { -+ ei->i_next_alloc_block++; -+ ei->i_next_alloc_goal++; - } - #ifdef SEARCH_FROM_ZERO -- inode->u.ext3_i.i_next_alloc_block = 0; -- inode->u.ext3_i.i_next_alloc_goal = 0; -+ ei->i_next_alloc_block = 0; -+ ei->i_next_alloc_goal = 0; - #endif - /* Writer: end */ - /* Reader: pointers, ->i_next_alloc* */ -@@ -490,8 +493,8 @@ static int ext3_find_goal(struct inode * - * try the heuristic for sequential allocation, - * failing that at least try to get decent locality. - */ -- if (block == inode->u.ext3_i.i_next_alloc_block) -- *goal = inode->u.ext3_i.i_next_alloc_goal; -+ if (block == ei->i_next_alloc_block) -+ *goal = ei->i_next_alloc_goal; - if (!*goal) - *goal = ext3_find_near(inode, partial); - #ifdef SEARCH_FROM_ZERO -@@ -619,6 +621,7 @@ - { - int i; - int err = 0; -+ struct ext3_inode_info *ei = EXT3_I(inode); - - /* - * If we're splicing into a [td]indirect block (as opposed to the -@@ -641,11 +644,11 @@ static int ext3_splice_branch(handle_t * - /* That's it */ - - *where->p = where->key; -- inode->u.ext3_i.i_next_alloc_block = block; -- inode->u.ext3_i.i_next_alloc_goal = le32_to_cpu(where[num-1].key); -+ ei->i_next_alloc_block = block; -+ ei->i_next_alloc_goal = le32_to_cpu(where[num-1].key); - #ifdef SEARCH_FROM_ZERO -- inode->u.ext3_i.i_next_alloc_block = 0; -- inode->u.ext3_i.i_next_alloc_goal = 0; -+ ei->i_next_alloc_block = 0; -+ ei->i_next_alloc_goal = 0; - #endif - /* Writer: end */ - -@@ -729,6 +732,7 @@ - unsigned long goal; - int left; - int depth = ext3_block_to_path(inode, iblock, offsets); -+ struct ext3_inode_info *ei = EXT3_I(inode); - loff_t new_size; - - J_ASSERT(handle != NULL || create == 0); -@@ -782,7 +785,7 @@ out: - /* - * Block out ext3_truncate while we alter the tree - */ -- down_read(&inode->u.ext3_i.truncate_sem); -+ down_read(&ei->truncate_sem); - err = ext3_alloc_branch(handle, inode, left, goal, - offsets+(partial-chain), partial); - -@@ -794,7 +797,7 @@ out: - if (!err) - err = ext3_splice_branch(handle, inode, iblock, chain, - partial, left); -- up_read(&inode->u.ext3_i.truncate_sem); -+ up_read(&ei->truncate_sem); - if (err == -EAGAIN) - goto changed; - if (err) -@@ -807,8 +810,8 @@ out: - * truncate is in progress. It is racy between multiple parallel - * instances of get_block, but we have the BKL. - */ -- if (new_size > inode->u.ext3_i.i_disksize) -- inode->u.ext3_i.i_disksize = new_size; -+ if (new_size > ei->i_disksize) -+ ei->i_disksize = new_size; - - bh_result->b_state |= (1UL << BH_New); - goto got_it; -@@ -921,7 +924,7 @@ struct buffer_head *ext3_bread(handle_t - struct buffer_head *tmp_bh; - - for (i = 1; -- inode->u.ext3_i.i_prealloc_count && -+ EXT3_I(inode)->i_prealloc_count && - i < EXT3_SB(inode->i_sb)->s_es->s_prealloc_dir_blocks; - i++) { - /* -@@ -1015,8 +1018,8 @@ static int ext3_prepare_write(struct fil - unsigned from, unsigned to) - { - struct inode *inode = page->mapping->host; -- handle_t *handle = ext3_journal_current_handle(); - int ret, needed_blocks = ext3_writepage_trans_blocks(inode); -+ handle_t *handle; - - lock_kernel(); - handle = ext3_journal_start(inode, needed_blocks); -@@ -1131,8 +1134,8 @@ static int ext3_commit_write(struct file - kunmap(page); - } - } -- if (inode->i_size > inode->u.ext3_i.i_disksize) { -- inode->u.ext3_i.i_disksize = inode->i_size; -+ if (inode->i_size > EXT3_I(inode)->i_disksize) { -+ EXT3_I(inode)->i_disksize = inode->i_size; - ret2 = ext3_mark_inode_dirty(handle, inode); - if (!ret) - ret = ret2; -@@ -1832,7 +1835,8 @@ static void ext3_free_branches(handle_t - void ext3_truncate(struct inode * inode) - { - handle_t *handle; -- u32 *i_data = inode->u.ext3_i.i_data; -+ struct ext3_inode_info *ei = EXT3_I(inode); -+ u32 *i_data = EXT3_I(inode)->i_data; - int addr_per_block = EXT3_ADDR_PER_BLOCK(inode->i_sb); - int offsets[4]; - Indirect chain[4]; -@@ -1884,13 +1887,13 @@ void ext3_truncate(struct inode * inode) - * on-disk inode. We do this via i_disksize, which is the value which - * ext3 *really* writes onto the disk inode. - */ -- inode->u.ext3_i.i_disksize = inode->i_size; -+ ei->i_disksize = inode->i_size; - - /* - * From here we block out all ext3_get_block() callers who want to - * modify the block allocation tree. - */ -- down_write(&inode->u.ext3_i.truncate_sem); -+ down_write(&ei->truncate_sem); - - if (n == 1) { /* direct blocks */ - ext3_free_data(handle, inode, NULL, i_data+offsets[0], -@@ -1954,7 +1957,7 @@ do_indirects: - case EXT3_TIND_BLOCK: - ; - } -- up_write(&inode->u.ext3_i.truncate_sem); -+ up_write(&ei->truncate_sem); - inode->i_mtime = inode->i_ctime = CURRENT_TIME; - ext3_mark_inode_dirty(handle, inode); - -@@ -1983,6 +1986,8 @@ out_stop: - - int ext3_get_inode_loc (struct inode *inode, struct ext3_iloc *iloc) - { -+ struct super_block *sb = inode->i_sb; -+ struct ext3_sb_info *sbi = EXT3_SB(sb); - struct buffer_head *bh = 0; - unsigned long block; - unsigned long block_group; -@@ -1995,25 +2000,21 @@ int ext3_get_inode_loc (struct inode *in - inode->i_ino != EXT3_ACL_IDX_INO && - inode->i_ino != EXT3_ACL_DATA_INO && - inode->i_ino != EXT3_JOURNAL_INO && -- inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) || -- inode->i_ino > le32_to_cpu( -- inode->i_sb->u.ext3_sb.s_es->s_inodes_count)) { -- ext3_error (inode->i_sb, "ext3_get_inode_loc", -- "bad inode number: %lu", inode->i_ino); -+ inode->i_ino < EXT3_FIRST_INO(sb)) || -+ inode->i_ino > le32_to_cpu(sbi->s_es->s_inodes_count)) { -+ ext3_error (sb, __FUNCTION__, "bad inode #%lu", inode->i_ino); - goto bad_inode; - } -- block_group = (inode->i_ino - 1) / EXT3_INODES_PER_GROUP(inode->i_sb); -- if (block_group >= inode->i_sb->u.ext3_sb.s_groups_count) { -- ext3_error (inode->i_sb, "ext3_get_inode_loc", -- "group >= groups count"); -+ block_group = (inode->i_ino - 1) / sbi->s_inodes_per_group; -+ if (block_group >= sbi->s_groups_count) { -+ ext3_error(sb, __FUNCTION__, "group >= groups count"); - goto bad_inode; - } -- group_desc = block_group >> EXT3_DESC_PER_BLOCK_BITS(inode->i_sb); -- desc = block_group & (EXT3_DESC_PER_BLOCK(inode->i_sb) - 1); -- bh = inode->i_sb->u.ext3_sb.s_group_desc[group_desc]; -+ group_desc = block_group >> sbi->s_desc_per_block_bits; -+ desc = block_group & (sbi->s_desc_per_block - 1); -+ bh = sbi->s_group_desc[group_desc]; - if (!bh) { -- ext3_error (inode->i_sb, "ext3_get_inode_loc", -- "Descriptor not loaded"); -+ ext3_error(sb, __FUNCTION__, "Descriptor not loaded"); - goto bad_inode; - } - -@@ -2021,17 +2022,17 @@ int ext3_get_inode_loc (struct inode *in - /* - * Figure out the offset within the block group inode table - */ -- offset = ((inode->i_ino - 1) % EXT3_INODES_PER_GROUP(inode->i_sb)) * -- EXT3_INODE_SIZE(inode->i_sb); -+ offset = ((inode->i_ino - 1) % sbi->s_inodes_per_group) * -+ sbi->s_inode_size; - block = le32_to_cpu(gdp[desc].bg_inode_table) + -- (offset >> EXT3_BLOCK_SIZE_BITS(inode->i_sb)); -- if (!(bh = sb_bread(inode->i_sb, block))) { -- ext3_error (inode->i_sb, "ext3_get_inode_loc", -+ (offset >> EXT3_BLOCK_SIZE_BITS(sb)); -+ if (!(bh = sb_bread(sb, block))) { -+ ext3_error (sb, __FUNCTION__, - "unable to read inode block - " - "inode=%lu, block=%lu", inode->i_ino, block); - goto bad_inode; - } -- offset &= (EXT3_BLOCK_SIZE(inode->i_sb) - 1); -+ offset &= (EXT3_BLOCK_SIZE(sb) - 1); - - iloc->bh = bh; - iloc->raw_inode = (struct ext3_inode *) (bh->b_data + offset); -@@ -2047,6 +2048,7 @@ void ext3_read_inode(struct inode * inod - { - struct ext3_iloc iloc; - struct ext3_inode *raw_inode; -+ struct ext3_inode_info *ei = EXT3_I(inode); - struct buffer_head *bh; - int block; - -@@ -2054,7 +2056,7 @@ void ext3_read_inode(struct inode * inod - goto bad_inode; - bh = iloc.bh; - raw_inode = iloc.raw_inode; -- init_rwsem(&inode->u.ext3_i.truncate_sem); -+ init_rwsem(&ei->truncate_sem); - inode->i_mode = le16_to_cpu(raw_inode->i_mode); - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); -@@ -2067,7 +2069,7 @@ void ext3_read_inode(struct inode * inod - inode->i_atime = le32_to_cpu(raw_inode->i_atime); - inode->i_ctime = le32_to_cpu(raw_inode->i_ctime); - inode->i_mtime = le32_to_cpu(raw_inode->i_mtime); -- inode->u.ext3_i.i_dtime = le32_to_cpu(raw_inode->i_dtime); -+ ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); - /* We now have enough fields to check if the inode was active or not. - * This is needed because nfsd might try to access dead inodes - * the test is that same one that e2fsck uses -@@ -2075,7 +2077,7 @@ void ext3_read_inode(struct inode * inod - */ - if (inode->i_nlink == 0) { - if (inode->i_mode == 0 || -- !(inode->i_sb->u.ext3_sb.s_mount_state & EXT3_ORPHAN_FS)) { -+ !(EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ORPHAN_FS)) { - /* this inode is deleted */ - brelse (bh); - goto bad_inode; -@@ -2090,33 +2092,33 @@ void ext3_read_inode(struct inode * inod - * size */ - inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); - inode->i_version = ++event; -- inode->u.ext3_i.i_flags = le32_to_cpu(raw_inode->i_flags); -+ ei->i_flags = le32_to_cpu(raw_inode->i_flags); - #ifdef EXT3_FRAGMENTS -- inode->u.ext3_i.i_faddr = le32_to_cpu(raw_inode->i_faddr); -- inode->u.ext3_i.i_frag_no = raw_inode->i_frag; -- inode->u.ext3_i.i_frag_size = raw_inode->i_fsize; -+ ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); -+ ei->i_frag_no = raw_inode->i_frag; -+ ei->i_frag_size = raw_inode->i_fsize; - #endif -- inode->u.ext3_i.i_file_acl = le32_to_cpu(raw_inode->i_file_acl); -+ ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl); - if (!S_ISREG(inode->i_mode)) { -- inode->u.ext3_i.i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl); -+ ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl); - } else { - inode->i_size |= - ((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32; - } -- inode->u.ext3_i.i_disksize = inode->i_size; -+ ei->i_disksize = inode->i_size; - inode->i_generation = le32_to_cpu(raw_inode->i_generation); - #ifdef EXT3_PREALLOCATE -- inode->u.ext3_i.i_prealloc_count = 0; -+ ei->i_prealloc_count = 0; - #endif -- inode->u.ext3_i.i_block_group = iloc.block_group; -+ ei->i_block_group = iloc.block_group; - - /* - * NOTE! The in-memory inode i_data array is in little-endian order - * even on big-endian machines: we do NOT byteswap the block numbers! - */ - for (block = 0; block < EXT3_N_BLOCKS; block++) -- inode->u.ext3_i.i_data[block] = iloc.raw_inode->i_block[block]; -- INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan); -+ ei->i_data[block] = iloc.raw_inode->i_block[block]; -+ INIT_LIST_HEAD(&ei->i_orphan); - - brelse (iloc.bh); - -@@ -2143,17 +2145,17 @@ void ext3_read_inode(struct inode * inod - /* inode->i_attr_flags = 0; unused */ -- if (inode->u.ext3_i.i_flags & EXT3_SYNC_FL) { -+ if (ei->i_flags & EXT3_SYNC_FL) { - /* inode->i_attr_flags |= ATTR_FLAG_SYNCRONOUS; unused */ - inode->i_flags |= S_SYNC; - } -- if (inode->u.ext3_i.i_flags & EXT3_APPEND_FL) { -+ if (ei->i_flags & EXT3_APPEND_FL) { - /* inode->i_attr_flags |= ATTR_FLAG_APPEND; unused */ - inode->i_flags |= S_APPEND; - } -- if (inode->u.ext3_i.i_flags & EXT3_IMMUTABLE_FL) { -+ if (ei->i_flags & EXT3_IMMUTABLE_FL) { - /* inode->i_attr_flags |= ATTR_FLAG_IMMUTABLE; unused */ - inode->i_flags |= S_IMMUTABLE; - } -- if (inode->u.ext3_i.i_flags & EXT3_NOATIME_FL) { -+ if (ei->i_flags & EXT3_NOATIME_FL) { - /* inode->i_attr_flags |= ATTR_FLAG_NOATIME; unused */ - inode->i_flags |= S_NOATIME; - } -@@ -2175,6 +2177,7 @@ static int ext3_do_update_inode(handle_t - struct ext3_iloc *iloc) - { - struct ext3_inode *raw_inode = iloc->raw_inode; -+ struct ext3_inode_info *ei = EXT3_I(inode); - struct buffer_head *bh = iloc->bh; - int err = 0, rc, block; - -@@ -2192,7 +2195,7 @@ static int ext3_do_update_inode(handle_t - * Fix up interoperability with old kernels. Otherwise, old inodes get - * re-used with the upper 16 bits of the uid/gid intact - */ -- if(!inode->u.ext3_i.i_dtime) { -+ if(!ei->i_dtime) { - raw_inode->i_uid_high = - cpu_to_le16(high_16_bits(inode->i_uid)); - raw_inode->i_gid_high = -@@ -2210,34 +2213,33 @@ static int ext3_do_update_inode(handle_t - raw_inode->i_gid_high = 0; - } - raw_inode->i_links_count = cpu_to_le16(inode->i_nlink); -- raw_inode->i_size = cpu_to_le32(inode->u.ext3_i.i_disksize); -+ raw_inode->i_size = cpu_to_le32(ei->i_disksize); - raw_inode->i_atime = cpu_to_le32(inode->i_atime); - raw_inode->i_ctime = cpu_to_le32(inode->i_ctime); - raw_inode->i_mtime = cpu_to_le32(inode->i_mtime); - raw_inode->i_blocks = cpu_to_le32(inode->i_blocks); -- raw_inode->i_dtime = cpu_to_le32(inode->u.ext3_i.i_dtime); -- raw_inode->i_flags = cpu_to_le32(inode->u.ext3_i.i_flags); -+ raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); -+ raw_inode->i_flags = cpu_to_le32(ei->i_flags); - #ifdef EXT3_FRAGMENTS -- raw_inode->i_faddr = cpu_to_le32(inode->u.ext3_i.i_faddr); -- raw_inode->i_frag = inode->u.ext3_i.i_frag_no; -- raw_inode->i_fsize = inode->u.ext3_i.i_frag_size; -+ raw_inode->i_faddr = cpu_to_le32(ei->i_faddr); -+ raw_inode->i_frag = ei->i_frag_no; -+ raw_inode->i_fsize = ei->i_frag_size; - #else - /* If we are not tracking these fields in the in-memory inode, - * then preserve them on disk, but still initialise them to zero - * for new inodes. */ -- if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) { -+ if (ei->i_state & EXT3_STATE_NEW) { - raw_inode->i_faddr = 0; - raw_inode->i_frag = 0; - raw_inode->i_fsize = 0; - } - #endif -- raw_inode->i_file_acl = cpu_to_le32(inode->u.ext3_i.i_file_acl); -+ raw_inode->i_file_acl = cpu_to_le32(ei->i_file_acl); - if (!S_ISREG(inode->i_mode)) { -- raw_inode->i_dir_acl = cpu_to_le32(inode->u.ext3_i.i_dir_acl); -+ raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl); - } else { -- raw_inode->i_size_high = -- cpu_to_le32(inode->u.ext3_i.i_disksize >> 32); -- if (inode->u.ext3_i.i_disksize > 0x7fffffffULL) { -+ raw_inode->i_size_high = cpu_to_le32(ei->i_disksize >> 32); -+ if (ei->i_disksize > MAX_NON_LFS) { - struct super_block *sb = inode->i_sb; - if (!EXT3_HAS_RO_COMPAT_FEATURE(sb, - EXT3_FEATURE_RO_COMPAT_LARGE_FILE) || -@@ -2247,7 +2249,7 @@ static int ext3_do_update_inode(handle_t - * created, add a flag to the superblock. - */ - err = ext3_journal_get_write_access(handle, -- sb->u.ext3_sb.s_sbh); -+ EXT3_SB(sb)->s_sbh); - if (err) - goto out_brelse; - ext3_update_dynamic_rev(sb); -@@ -2256,7 +2258,7 @@ static int ext3_do_update_inode(handle_t - sb->s_dirt = 1; - handle->h_sync = 1; - err = ext3_journal_dirty_metadata(handle, -- sb->u.ext3_sb.s_sbh); -+ EXT3_SB(sb)->s_sbh); - } - } - } -@@ -2265,13 +2267,13 @@ static int ext3_do_update_inode(handle_t - raw_inode->i_block[0] = - cpu_to_le32(kdev_t_to_nr(inode->i_rdev)); - else for (block = 0; block < EXT3_N_BLOCKS; block++) -- raw_inode->i_block[block] = inode->u.ext3_i.i_data[block]; -+ raw_inode->i_block[block] = ei->i_data[block]; - - BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); - rc = ext3_journal_dirty_metadata(handle, bh); - if (!err) - err = rc; -- EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW; -+ ei->i_state &= ~EXT3_STATE_NEW; - - out_brelse: - brelse (bh); -@@ -2379,7 +2381,7 @@ int ext3_setattr(struct dentry *dentry, - } - - error = ext3_orphan_add(handle, inode); -- inode->u.ext3_i.i_disksize = attr->ia_size; -+ EXT3_I(inode)->i_disksize = attr->ia_size; - rc = ext3_mark_inode_dirty(handle, inode); - if (!error) - error = rc; -@@ -2622,9 +2624,9 @@ int ext3_change_inode_journal_flag(struc - */ - - if (val) -- inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL; -+ EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL; - else -- inode->u.ext3_i.i_flags &= ~EXT3_JOURNAL_DATA_FL; -+ EXT3_I(inode)->i_flags &= ~EXT3_JOURNAL_DATA_FL; - - journal_unlock_updates(journal); - ---- ./fs/ext3/ioctl.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/ioctl.c Tue May 7 15:20:52 2002 -@@ -18,13 +18,14 @@ - int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, - unsigned long arg) - { -+ struct ext3_inode_info *ei = EXT3_I(inode); - unsigned int flags; - - ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg); - - switch (cmd) { - case EXT3_IOC_GETFLAGS: -- flags = inode->u.ext3_i.i_flags & EXT3_FL_USER_VISIBLE; -+ flags = ei->i_flags & EXT3_FL_USER_VISIBLE; - return put_user(flags, (int *) arg); - case EXT3_IOC_SETFLAGS: { - handle_t *handle = NULL; -@@ -42,7 +42,7 @@ int ext3_ioctl (struct inode * inode, st - if (get_user(flags, (int *) arg)) - return -EFAULT; - -- oldflags = inode->u.ext3_i.i_flags; -+ oldflags = ei->i_flags; - - /* The JOURNAL_DATA flag is modifiable only by root */ - jflag = flags & EXT3_JOURNAL_DATA_FL; -@@ -79,7 +79,7 @@ int ext3_ioctl (struct inode * inode, st - - flags = flags & EXT3_FL_USER_MODIFIABLE; - flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE; -- inode->u.ext3_i.i_flags = flags; -+ ei->i_flags = flags; - - if (flags & EXT3_SYNC_FL) - inode->i_flags |= S_SYNC; -@@ -155,12 +155,12 @@ flags_err: - int ret = 0; - - set_current_state(TASK_INTERRUPTIBLE); -- add_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait); -- if (timer_pending(&sb->u.ext3_sb.turn_ro_timer)) { -+ add_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait); -+ if (timer_pending(&EXT3_SB(sb)->turn_ro_timer)) { - schedule(); - ret = 1; - } -- remove_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait); -+ remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait); - return ret; - } - #endif ---- ./fs/ext3/namei.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/namei.c Tue May 7 16:05:51 2002 -@@ -636,7 +636,7 @@ static struct buffer_head * ext3_find_en - } - - nblocks = dir->i_size >> EXT3_BLOCK_SIZE_BITS(sb); -- start = dir->u.ext3_i.i_dir_start_lookup; -+ start = EXT3_I(dir)->i_dir_start_lookup; - if (start >= nblocks) - start = 0; - block = start; -@@ -677,7 +677,7 @@ restart: - i = search_dirblock(bh, dir, dentry, - block << EXT3_BLOCK_SIZE_BITS(sb), res_dir); - if (i == 1) { -- dir->u.ext3_i.i_dir_start_lookup = block; -+ EXT3_I(dir)->i_dir_start_lookup = block; - ret = bh; - goto cleanup_and_exit; - } else { -@@ -1320,7 +1320,7 @@ static int ext3_mkdir(struct inode * dir - if (err) - goto out_no_entry; - dir->i_nlink++; -- dir->u.ext3_i.i_flags &= ~EXT3_INDEX_FL; -+ EXT3_I(dir)->i_flags &= ~EXT3_INDEX_FL; - ext3_mark_inode_dirty(handle, dir); - d_instantiate(dentry, inode); - out_stop: -@@ -1419,7 +1419,7 @@ int ext3_orphan_add(handle_t *handle, st - int err = 0, rc; - - lock_super(sb); -- if (!list_empty(&inode->u.ext3_i.i_orphan)) -+ if (!list_empty(&EXT3_I(inode)->i_orphan)) - goto out_unlock; - - /* Orphan handling is only valid for files with data blocks -@@ -1430,8 +1430,8 @@ int ext3_orphan_add(handle_t *handle, st - J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || - S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); - -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); -- err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access"); -+ err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); - if (err) - goto out_unlock; - -@@ -1442,7 +1442,7 @@ int ext3_orphan_add(handle_t *handle, st - /* Insert this inode at the head of the on-disk orphan list... */ - NEXT_ORPHAN(inode) = le32_to_cpu(EXT3_SB(sb)->s_es->s_last_orphan); - EXT3_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); -- err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); -+ err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); - rc = ext3_mark_iloc_dirty(handle, inode, &iloc); - if (!err) - err = rc; -@@ -1456,7 +1456,7 @@ int ext3_orphan_add(handle_t *handle, st - * This is safe: on error we're going to ignore the orphan list - * anyway on the next recovery. */ - if (!err) -- list_add(&inode->u.ext3_i.i_orphan, &EXT3_SB(sb)->s_orphan); -+ list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); - - jbd_debug(4, "superblock will point to %ld\n", inode->i_ino); - jbd_debug(4, "orphan inode %ld will point to %d\n", -@@ -714,25 +770,25 @@ - int ext3_orphan_del(handle_t *handle, struct inode *inode) - { - struct list_head *prev; -+ struct ext3_inode_info *ei = EXT3_I(inode); - struct ext3_sb_info *sbi; - ino_t ino_next; - struct ext3_iloc iloc; - int err = 0; - - lock_super(inode->i_sb); -- if (list_empty(&inode->u.ext3_i.i_orphan)) { -+ if (list_empty(&ei->i_orphan)) { - unlock_super(inode->i_sb); - return 0; - } - - ino_next = NEXT_ORPHAN(inode); -- prev = inode->u.ext3_i.i_orphan.prev; -+ prev = ei->i_orphan.prev; - sbi = EXT3_SB(inode->i_sb); - - jbd_debug(4, "remove inode %ld from orphan list\n", inode->i_ino); - -- list_del(&inode->u.ext3_i.i_orphan); -- INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan); -+ list_del_init(&ei->i_orphan); - - /* If we're on an error path, we may not have a valid - * transaction handle with which to update the orphan list on -@@ -1520,9 +1520,8 @@ int ext3_orphan_del(handle_t *handle, st - err = ext3_journal_dirty_metadata(handle, sbi->s_sbh); - } else { - struct ext3_iloc iloc2; -- struct inode *i_prev = -- list_entry(prev, struct inode, u.ext3_i.i_orphan); -- -+ struct inode *i_prev = orphan_list_entry(prev); -+ - jbd_debug(4, "orphan inode %ld will point to %ld\n", - i_prev->i_ino, ino_next); - err = ext3_reserve_inode_write(handle, i_prev, &iloc2); -@@ -1695,10 +1695,10 @@ static int ext3_symlink (struct inode * - goto out_no_entry; - } else { - inode->i_op = &ext3_fast_symlink_inode_operations; -- memcpy((char*)&inode->u.ext3_i.i_data,symname,l); -+ memcpy((char*)&EXT3_I(inode)->i_data,symname,l); - inode->i_size = l-1; - } -- inode->u.ext3_i.i_disksize = inode->i_size; -+ EXT3_I(inode)->i_disksize = inode->i_size; - ext3_mark_inode_dirty(handle, inode); - err = ext3_add_nondir(handle, dentry, inode); - out_stop: ---- ./fs/ext3/super.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/super.c Tue May 7 16:05:44 2002 -@@ -121,7 +121,7 @@ static int ext3_error_behaviour(struct s - /* If no overrides were specified on the mount, then fall back - * to the default behaviour set in the filesystem's superblock - * on disk. */ -- switch (le16_to_cpu(sb->u.ext3_sb.s_es->s_errors)) { -+ switch (le16_to_cpu(EXT3_SB(sb)->s_es->s_errors)) { - case EXT3_ERRORS_PANIC: - return EXT3_ERRORS_PANIC; - case EXT3_ERRORS_RO: -@@ -269,9 +269,9 @@ void ext3_abort (struct super_block * sb - return; - - printk (KERN_CRIT "Remounting filesystem read-only\n"); -- sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS; -+ EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; - sb->s_flags |= MS_RDONLY; -- sb->u.ext3_sb.s_mount_opt |= EXT3_MOUNT_ABORT; -+ EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; - journal_abort(EXT3_SB(sb)->s_journal, -EIO); - } - -@@ -377,8 +377,6 @@ static int ext3_blkdev_remove(struct ext3 - return ret; - } - --#define orphan_list_entry(l) list_entry((l), struct inode, u.ext3_i.i_orphan) -- - static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) - { - struct list_head *l; -@@ -818,7 +818,7 @@ static void ext3_orphan_cleanup (struct - sb->s_flags &= ~MS_RDONLY; - } - -- if (sb->u.ext3_sb.s_mount_state & EXT3_ERROR_FS) { -+ if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { - if (es->s_last_orphan) - jbd_debug(1, "Errors on filesystem, " - "clearing orphan list.\n"); -@@ -1463,12 +1463,14 @@ static void ext3_commit_super (struct su - struct ext3_super_block * es, - int sync) - { -+ struct buffer_head *sbh = EXT3_SB(sb)->s_sbh; -+ - es->s_wtime = cpu_to_le32(CURRENT_TIME); -- BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "marking dirty"); -- mark_buffer_dirty(sb->u.ext3_sb.s_sbh); -+ BUFFER_TRACE(sbh, "marking dirty"); -+ mark_buffer_dirty(sbh); - if (sync) { -- ll_rw_block(WRITE, 1, &sb->u.ext3_sb.s_sbh); -- wait_on_buffer(sb->u.ext3_sb.s_sbh); -+ ll_rw_block(WRITE, 1, &sbh); -+ wait_on_buffer(sbh); - } - } - -@@ -1519,7 +1521,7 @@ static void ext3_clear_journal_err(struc - ext3_warning(sb, __FUNCTION__, "Marking fs in need of " - "filesystem check."); - -- sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS; -+ EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; - es->s_state |= cpu_to_le16(EXT3_ERROR_FS); - ext3_commit_super (sb, es, 1); - ---- ./fs/ext3/symlink.c.orig Fri Apr 12 10:27:49 2002 -+++ ./fs/ext3/symlink.c Tue May 7 15:25:39 2002 -@@ -23,13 +23,13 @@ - - static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen) - { -- char *s = (char *)dentry->d_inode->u.ext3_i.i_data; -- return vfs_readlink(dentry, buffer, buflen, s); -+ struct ext3_inode_info *ei = EXT3_I(dentry->d_inode); -+ return vfs_readlink(dentry, buffer, buflen, (char *)ei->i_data); - } - - static int ext3_follow_link(struct dentry *dentry, struct nameidata *nd) - { -- char *s = (char *)dentry->d_inode->u.ext3_i.i_data; -- return vfs_follow_link(nd, s); -+ struct ext3_inode_info *ei = EXT3_I(dentry->d_inode); -+ return vfs_follow_link(nd, (char*)ei->i_data); - } - ---- ./include/linux/ext3_fs.h.orig Tue Apr 16 14:27:25 2002 -+++ ./include/linux/ext3_fs.h Tue May 7 16:47:36 2002 -@@ -84,22 +84,25 @@ - #define EXT3_MIN_BLOCK_SIZE 1024 - #define EXT3_MAX_BLOCK_SIZE 4096 - #define EXT3_MIN_BLOCK_LOG_SIZE 10 -+ - #ifdef __KERNEL__ --# define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize) --#else --# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size) --#endif --#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32)) --#ifdef __KERNEL__ --# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) --#else --# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) --#endif --#ifdef __KERNEL__ --#define EXT3_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_addr_per_block_bits) --#define EXT3_INODE_SIZE(s) ((s)->u.ext3_sb.s_inode_size) --#define EXT3_FIRST_INO(s) ((s)->u.ext3_sb.s_first_ino) -+#define EXT3_SB(sb) (&((sb)->u.ext3_sb)) -+#define EXT3_I(inode) (&((inode)->u.ext3_i)) -+ -+#define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize) -+#define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) -+#define EXT3_ADDR_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_addr_per_block_bits) -+#define EXT3_INODE_SIZE(s) (EXT3_SB(s)->s_inode_size) -+#define EXT3_FIRST_INO(s) (EXT3_SB(s)->s_first_ino) - #else -+ -+/* Assume that user mode programs are passing in an ext3fs superblock, not -+ * a kernel struct super_block. This will allow us to call the feature-test -+ * macros from user land. */ -+#define EXT3_SB(sb) (sb) -+ -+#define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size) -+#define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) - #define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \ - EXT3_GOOD_OLD_INODE_SIZE : \ - (s)->s_inode_size) -@@ -108,6 +110,7 @@ - EXT3_GOOD_OLD_FIRST_INO : \ - (s)->s_first_ino) - #endif -+#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32)) - - /* - * Macro-instructions used to manage fragments -@@ -116,8 +120,8 @@ - #define EXT3_MAX_FRAG_SIZE 4096 - #define EXT3_MIN_FRAG_LOG_SIZE 10 - #ifdef __KERNEL__ --# define EXT3_FRAG_SIZE(s) ((s)->u.ext3_sb.s_frag_size) --# define EXT3_FRAGS_PER_BLOCK(s) ((s)->u.ext3_sb.s_frags_per_block) -+# define EXT3_FRAG_SIZE(s) (EXT3_SB(s)->s_frag_size) -+# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_SB(s)->s_frags_per_block) - #else - # define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size) - # define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s)) -@@ -163,15 +167,13 @@ - /* - * Macro-instructions used to manage group descriptors - */ -+# define EXT3_BLOCKS_PER_GROUP(s) (EXT3_SB(s)->s_blocks_per_group) -+# define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group) - #ifdef __KERNEL__ --# define EXT3_BLOCKS_PER_GROUP(s) ((s)->u.ext3_sb.s_blocks_per_group) --# define EXT3_DESC_PER_BLOCK(s) ((s)->u.ext3_sb.s_desc_per_block) --# define EXT3_INODES_PER_GROUP(s) ((s)->u.ext3_sb.s_inodes_per_group) --# define EXT3_DESC_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_desc_per_block_bits) -+# define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block) -+# define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits) - #else --# define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) - # define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc)) --# define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) - #endif - - /* -@@ -344,7 +347,7 @@ - #ifndef _LINUX_EXT2_FS_H - #define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt - #define set_opt(o, opt) o |= EXT3_MOUNT_##opt --#define test_opt(sb, opt) ((sb)->u.ext3_sb.s_mount_opt & \ -+#define test_opt(sb, opt) (EXT3_SB(sb)->s_mount_opt & \ - EXT3_MOUNT_##opt) - #else - #define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD -@@ -441,17 +443,11 @@ - /*EC*/ __u32 s_reserved[197]; /* Padding to the end of the block */ - }; - --#ifdef __KERNEL__ --#define EXT3_SB(sb) (&((sb)->u.ext3_sb)) --#define EXT3_I(inode) (&((inode)->u.ext3_i)) --#else --/* Assume that user mode programs are passing in an ext3fs superblock, not -- * a kernel struct super_block. This will allow us to call the feature-test -- * macros from user land. */ --#define EXT3_SB(sb) (sb) --#endif -- --#define NEXT_ORPHAN(inode) (inode)->u.ext3_i.i_dtime -+#define NEXT_ORPHAN(inode) EXT3_I(inode)->i_dtime -+static inline struct inode *orphan_list_entry(struct list_head *l) -+{ -+ return list_entry(l, struct inode, u.ext3_i.i_orphan); -+} - - /* - * Codes for operating systems ---- ./include/linux/ext3_jbd.h.orig Tue May 7 14:44:08 2002 -+++ ./include/linux/ext3_jbd.h Tue May 7 14:44:43 2002 -@@ -291,7 +291,7 @@ - return 1; - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) - return 1; -- if (inode->u.ext3_i.i_flags & EXT3_JOURNAL_DATA_FL) -+ if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) - return 1; - return 0; - } diff --git a/lustre/extN/extN-2.4.18-exports.diff b/lustre/extN/extN-2.4.18-exports.diff deleted file mode 100644 index 8780209..0000000 --- a/lustre/extN/extN-2.4.18-exports.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- linux-2.4.17/fs/extN/super.c.orig Fri Dec 21 10:41:55 2001 -+++ linux-2.4.17/fs/extN/super.c Fri Mar 22 11:00:41 2002 -@@ -1742,7 +1742,7 @@ - unregister_filesystem(&extN_fs_type); - } - --EXPORT_NO_SYMBOLS; -+EXPORT_SYMBOL(extN_bread); - - 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/lustre/extN/extN-2.4.18-ino_sb_fixup.diff b/lustre/extN/extN-2.4.18-ino_sb_fixup.diff deleted file mode 100644 index ecca2de..0000000 --- a/lustre/extN/extN-2.4.18-ino_sb_fixup.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- ./include/linux/extN_fs.h.orig Tue May 7 17:06:03 2002 -+++ ./include/linux/extN_fs.h Tue May 7 17:07:11 2002 -@@ -17,6 +17,8 @@ - #define _LINUX_EXTN_FS_H - - #include -+#include -+#include - - /* - * The second extended filesystem constants/structures -@@ -86,8 +88,8 @@ - #define EXTN_MIN_BLOCK_LOG_SIZE 10 - - #ifdef __KERNEL__ --#define EXTN_SB(sb) (&((sb)->u.extN_sb)) --#define EXTN_I(inode) (&((inode)->u.extN_i)) -+#define EXTN_SB(sb) ((struct extN_sb_info *)&((sb)->u.generic_sbp)) -+#define EXTN_I(inode) ((struct extN_inode_info *)&((inode)->u.generic_ip)) - - #define EXTN_BLOCK_SIZE(s) ((s)->s_blocksize) - #define EXTN_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) -@@ -447,7 +447,9 @@ - #define NEXT_ORPHAN(inode) EXTN_I(inode)->i_dtime - static inline inode *orphan_list_entry(l) - { -- return list_entry(l, struct inode, u.extN_i.i_orphan); -+ return ((struct inode *)((char *)l - -+ (unsigned long)(offsetof(struct inode, u.generic_ip) + -+ offsetof(struct extN_inode_info, i_orphan)))); - } - - /* diff --git a/lustre/extN/extN-misc-fixup.diff b/lustre/extN/extN-misc-fixup.diff deleted file mode 100644 index 29b36fb..0000000 --- a/lustre/extN/extN-misc-fixup.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- linux-2.4.17/fs/extN/super.c.orig Fri Dec 21 10:41:55 2001 -+++ linux-2.4.17/fs/extN/super.c Fri Mar 22 11:00:41 2002 -@@ -1344,10 +1342,10 @@ - printk(KERN_ERR "EXTN-fs: I/O error on journal device\n"); - goto out_journal; - } -- if (ntohl(journal->j_superblock->s_nr_users) != 1) { -+ if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { - printk(KERN_ERR "EXTN-fs: External journal has more than one " - "user (unsupported) - %d\n", -- ntohl(journal->j_superblock->s_nr_users)); -+ be32_to_cpu(journal->j_superblock->s_nr_users)); - goto out_journal; - } - EXTN_SB(sb)->journal_bdev = bdev; diff --git a/lustre/extN/htree-ext3-2.4.18.diff b/lustre/extN/htree-ext3-2.4.18.diff deleted file mode 100644 index 284dc78..0000000 --- a/lustre/extN/htree-ext3-2.4.18.diff +++ /dev/null @@ -1,1216 +0,0 @@ ---- ./fs/ext3/dir.c 2002/03/05 06:18:59 2.1 -+++ ./fs/ext3/dir.c 2002/03/05 06:26:56 -@@ -26,7 +26,7 @@ - DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK - }; - --static int ext3_readdir(struct file *, void *, filldir_t); -+int ext3_readdir(struct file *, void *, filldir_t); - - struct file_operations ext3_dir_operations = { - read: generic_read_dir, -@@ -65,7 +65,7 @@ - return error_msg == NULL ? 1 : 0; - } - --static int ext3_readdir(struct file * filp, -+int ext3_readdir(struct file * filp, - void * dirent, filldir_t filldir) - { - int error = 0; ---- ./fs/ext3/super.c 2002/03/05 06:18:59 2.1 -+++ ./fs/ext3/super.c 2002/03/05 06:26:56 -@@ -529,6 +529,12 @@ - "EXT3 Check option not supported\n"); - #endif - } -+ else if (!strcmp (this_char, "index")) -+#ifdef CONFIG_EXT3_INDEX -+ set_opt (*mount_options, INDEX); -+#else -+ printk("EXT3 index option not supported\n"); -+#endif - else if (!strcmp (this_char, "debug")) - set_opt (*mount_options, DEBUG); - else if (!strcmp (this_char, "errors")) { -@@ -712,6 +718,10 @@ - EXT3_BLOCKS_PER_GROUP(sb), - EXT3_INODES_PER_GROUP(sb), - sbi->s_mount_opt); -+ -+ if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_DIR_INDEX)) -+ set_opt (EXT3_SB(sb)->s_mount_opt, INDEX); -+ - printk(KERN_INFO "EXT3 FS " EXT3FS_VERSION ", " EXT3FS_DATE " on %s, ", - bdevname(sb->s_dev)); - if (EXT3_SB(sb)->s_journal->j_inode == NULL) { ---- ./fs/ext3/namei.c 2002/03/05 06:18:59 2.1 -+++ ./fs/ext3/namei.c 2002/03/06 00:13:18 -@@ -16,6 +16,10 @@ - * David S. Miller (davem@caip.rutgers.edu), 1995 - * Directory entry file type support and forward compatibility hooks - * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998 -+ * Hash Tree Directory indexing (c) -+ * Daniel Phillips, 2001 -+ * Hash Tree Directory indexing porting -+ * Christopher Li, 2002 - */ - - #include -@@ -38,6 +42,439 @@ - #define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS) - #define NAMEI_RA_INDEX(c,b) (((c) * NAMEI_RA_BLOCKS) + (b)) - -+void ext3_add_compat_feature (struct super_block *sb, unsigned feature) -+{ -+ if (!EXT3_HAS_COMPAT_FEATURE(sb, feature)) -+ { -+ lock_super(sb); -+ ext3_update_dynamic_rev(sb); -+ EXT3_SET_COMPAT_FEATURE(sb, feature); -+ ext3_write_super(sb); -+ unlock_super(sb); -+ } -+} -+ -+static struct buffer_head *ext3_append(handle_t *handle, -+ struct inode *inode, -+ u32 *block, int *err) -+{ -+ struct buffer_head *bh; -+ -+ *block = inode->i_size >> inode->i_sb->s_blocksize_bits; -+ -+ if ((bh = ext3_bread(handle, inode, *block, 1, err))) { -+ inode->i_size += inode->i_sb->s_blocksize; -+ EXT3_I(inode)->i_disksize = inode->i_size; -+ ext3_journal_get_write_access(handle,bh); -+ } -+ return bh; -+} -+ -+#ifndef assert -+#define assert(test) J_ASSERT(test) -+#endif -+ -+#ifndef swap -+#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0) -+#endif -+ -+typedef struct { u32 v; } le_u32; -+typedef struct { u16 v; } le_u16; -+ -+#define dxtrace_on(command) command -+#define dxtrace_off(command) -+#define dxtrace dxtrace_off -+ -+struct fake_dirent -+{ -+ /*le*/u32 inode; -+ /*le*/u16 rec_len; -+ u8 name_len; -+ u8 file_type; -+}; -+ -+struct dx_countlimit -+{ -+ le_u16 limit; -+ le_u16 count; -+}; -+ -+struct dx_entry -+{ -+ le_u32 hash; -+ le_u32 block; -+}; -+ -+/* -+ * dx_root_info is laid out so that if it should somehow get overlaid by a -+ * dirent the two low bits of the hash version will be zero. Therefore, the -+ * hash version mod 4 should never be 0. Sincerely, the paranoia department. -+ */ -+ -+struct dx_root -+{ -+ struct fake_dirent fake1; -+ char dot1[4]; -+ struct fake_dirent fake2; -+ char dot2[4]; -+ struct dx_root_info -+ { -+ le_u32 reserved_zero; -+ u8 hash_version; /* 0 now, 1 at release */ -+ u8 info_length; /* 8 */ -+ u8 indirect_levels; -+ u8 unused_flags; -+ } -+ info; -+ struct dx_entry entries[0]; -+}; -+ -+struct dx_node -+{ -+ struct fake_dirent fake; -+ struct dx_entry entries[0]; -+}; -+ -+ -+struct dx_frame -+{ -+ struct buffer_head *bh; -+ struct dx_entry *entries; -+ struct dx_entry *at; -+}; -+ -+struct dx_map_entry -+{ -+ u32 hash; -+ u32 offs; -+}; -+ -+typedef struct ext3_dir_entry_2 ext3_dirent; -+static inline unsigned dx_get_block (struct dx_entry *entry); -+static void dx_set_block (struct dx_entry *entry, unsigned value); -+static inline unsigned dx_get_hash (struct dx_entry *entry); -+static void dx_set_hash (struct dx_entry *entry, unsigned value); -+static unsigned dx_get_count (struct dx_entry *entries); -+static unsigned dx_get_limit (struct dx_entry *entries); -+static void dx_set_count (struct dx_entry *entries, unsigned value); -+static void dx_set_limit (struct dx_entry *entries, unsigned value); -+static unsigned dx_root_limit (struct inode *dir, unsigned infosize); -+static unsigned dx_node_limit (struct inode *dir); -+static unsigned dx_hack_hash (const u8 *name, int len); -+static struct dx_frame *dx_probe (struct inode *dir, u32 hash, struct dx_frame *frame); -+static void dx_release (struct dx_frame *frames); -+static int dx_make_map (ext3_dirent *de, int size, struct dx_map_entry map[]); -+static void dx_sort_map(struct dx_map_entry *map, unsigned count); -+static ext3_dirent *dx_copy_dirents (char *from, char *to, -+ struct dx_map_entry *map, int count); -+static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block); -+ -+ -+#ifdef CONFIG_EXT3_INDEX -+/* -+ * Future: use high four bits of block for coalesce-on-delete flags -+ * Mask them off for now. -+ */ -+ -+static inline unsigned dx_get_block (struct dx_entry *entry) -+{ -+ return le32_to_cpu(entry->block.v) & 0x0fffffff; -+} -+ -+static inline void dx_set_block (struct dx_entry *entry, unsigned value) -+{ -+ entry->block.v = cpu_to_le32(value); -+} -+ -+static inline unsigned dx_get_hash (struct dx_entry *entry) -+{ -+ return le32_to_cpu(entry->hash.v); -+} -+ -+static inline void dx_set_hash (struct dx_entry *entry, unsigned value) -+{ -+ entry->hash.v = cpu_to_le32(value); -+} -+ -+static inline unsigned dx_get_count (struct dx_entry *entries) -+{ -+ return le16_to_cpu(((struct dx_countlimit *) entries)->count.v); -+} -+ -+static inline unsigned dx_get_limit (struct dx_entry *entries) -+{ -+ return le16_to_cpu(((struct dx_countlimit *) entries)->limit.v); -+} -+ -+static inline void dx_set_count (struct dx_entry *entries, unsigned value) -+{ -+ ((struct dx_countlimit *) entries)->count.v = cpu_to_le16(value); -+} -+ -+static inline void dx_set_limit (struct dx_entry *entries, unsigned value) -+{ -+ ((struct dx_countlimit *) entries)->limit.v = cpu_to_le16(value); -+} -+ -+static inline unsigned dx_root_limit (struct inode *dir, unsigned infosize) -+{ -+ unsigned entry_space = dir->i_sb->s_blocksize - 24 - infosize; -+ return 0? 20: entry_space / sizeof(struct dx_entry); -+} -+ -+static inline unsigned dx_node_limit (struct inode *dir) -+{ -+ unsigned entry_space = dir->i_sb->s_blocksize - sizeof(struct fake_dirent); -+ return 0? 22: entry_space / sizeof(struct dx_entry); -+} -+ -+/* Hash function - not bad, but still looking for an ideal default */ -+ -+static unsigned dx_hack_hash (const u8 *name, int len) -+{ -+ u32 hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; -+ while (len--) -+ { -+ u32 hash = hash1 + (hash0 ^ (*name++ * 7152373)); -+ if (hash & 0x80000000) hash -= 0x7fffffff; -+ hash1 = hash0; -+ hash0 = hash; -+ } -+ return 80; /* FIXME: for test only */ -+ return hash0; -+} -+ -+#define dx_hash(s,n) (dx_hack_hash(s,n) << 1) -+ -+/* -+ * Debug -+ */ -+static void dx_show_index (char * label, struct dx_entry *entries) -+{ -+ int i, n = dx_get_count (entries); -+ printk("%s index ", label); -+ for (i = 0; i < n; i++) -+ { -+ printk("%x->%u ", i? dx_get_hash(entries + i): 0, dx_get_block(entries + i)); -+ } -+ printk("\n"); -+} -+ -+struct stats -+{ -+ unsigned names; -+ unsigned space; -+ unsigned bcount; -+}; -+ -+static struct stats dx_show_leaf (ext3_dirent *de, int size, int show_names) -+{ -+ unsigned names = 0, space = 0; -+ char *base = (char *) de; -+ printk("names: "); -+ while ((char *) de < base + size) -+ { -+ if (de->inode) -+ { -+ if (show_names) -+ { -+ int len = de->name_len; -+ char *name = de->name; -+ while (len--) printk("%c", *name++); -+ printk(":%x.%u ", dx_hash (de->name, de->name_len), ((char *) de - base)); -+ } -+ space += EXT3_DIR_REC_LEN(de->name_len); -+ names++; -+ } -+ de = (ext3_dirent *) ((char *) de + le16_to_cpu(de->rec_len)); -+ } -+ printk("(%i)\n", names); -+ return (struct stats) { names, space, 1 }; -+} -+ -+struct stats dx_show_entries (struct inode *dir, struct dx_entry *entries, int levels) -+{ -+ unsigned blocksize = dir->i_sb->s_blocksize; -+ unsigned count = dx_get_count (entries), names = 0, space = 0, i; -+ unsigned bcount = 0; -+ struct buffer_head *bh; -+ int err; -+ printk("%i indexed blocks...\n", count); -+ for (i = 0; i < count; i++, entries++) -+ { -+ u32 block = dx_get_block(entries), hash = i? dx_get_hash(entries): 0; -+ u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash; -+ struct stats stats; -+ printk("%s%3u:%03u hash %8x/%8x ",levels?"":" ", i, block, hash, range); -+ if (!(bh = ext3_bread (NULL,dir, block, 0,&err))) continue; -+ stats = levels? -+ dx_show_entries (dir, ((struct dx_node *) bh->b_data)->entries, levels - 1): -+ dx_show_leaf ((ext3_dirent *) bh->b_data, blocksize, 0); -+ names += stats.names; -+ space += stats.space; -+ bcount += stats.bcount; -+ brelse (bh); -+ } -+ if (bcount) -+ printk("%snames %u, fullness %u (%u%%)\n", levels?"":" ", -+ names, space/bcount,(space/bcount)*100/blocksize); -+ return (struct stats) { names, space, bcount}; -+} -+ -+static void dx_show_buckets (struct inode *dir) -+{ -+ struct buffer_head *bh; -+ struct dx_root *root; -+ int err; -+ if (!(bh = ext3_bread (NULL,dir, 0, 0,&err))) return; -+ root = (struct dx_root *) bh->b_data; -+ dx_show_entries (dir, root->entries, root->info.indirect_levels); -+ brelse (bh); -+} -+ -+ssize_t hack_show_dir (struct file * filp, void * dirent, filldir_t filldir) -+{ -+ if (is_dx (filp->f_dentry->d_inode) && !filp->f_pos) -+ dx_show_buckets (filp->f_dentry->d_inode); -+ return ext3_readdir(filp,dirent,filldir); -+} -+ -+/* -+ * Probe for a directory leaf block to search -+ */ -+ -+static struct dx_frame *dx_probe (struct inode *dir, u32 hash, struct dx_frame *frame) -+{ -+ unsigned count, indirect; -+ struct dx_entry *at, *entries, *p, *q, *m; -+ struct dx_root *root; -+ struct buffer_head *bh; -+ int err; -+ if (!(bh = ext3_bread (NULL,dir, 0, 0,&err))) -+ goto fail; -+ root = (struct dx_root *) bh->b_data; -+ if (root->info.hash_version > 0 || root->info.unused_flags & 1) -+ goto fail; -+ if ((indirect = root->info.indirect_levels) > 1) -+ goto fail; -+ entries = (struct dx_entry *) (((char *) &root->info) + root->info.info_length); -+ assert (dx_get_limit(entries) == dx_root_limit(dir, root->info.info_length)); -+ dxtrace (printk("Look up %x", hash)); -+ while (1) -+ { -+ count = dx_get_count(entries); -+ assert (count && count <= dx_get_limit(entries)); -+ p = entries + 1; -+ q = entries + count - 1; -+ while (p <= q) -+ { -+ m = p + (q - p)/2; -+ dxtrace(printk(".")); -+ if (dx_get_hash(m) > hash) -+ q = m - 1; -+ else -+ p = m + 1; -+ } -+ -+ if (0) // linear search cross check -+ { -+ unsigned n = count - 1; -+ at = entries; -+ while (n--) -+ { -+ dxtrace(printk(",")); -+ if (dx_get_hash(++at) > hash) -+ { -+ at--; -+ break; -+ } -+ } -+ assert (at == p - 1); -+ } -+ -+ at = p - 1; -+ dxtrace(printk(" %x->%u\n", at == entries? 0: dx_get_hash(at), dx_get_block(at))); -+ frame->bh = bh; -+ frame->entries = entries; -+ frame->at = at; -+ if (!indirect--) return frame; -+ if (!(bh = ext3_bread (NULL,dir, dx_get_block(at), 0,&err))) -+ goto fail2; -+ at = entries = ((struct dx_node *) bh->b_data)->entries; -+ assert (dx_get_limit(entries) == dx_node_limit (dir)); -+ frame++; -+ } -+fail2: -+ brelse(frame->bh); -+fail: -+ return NULL; -+} -+ -+static void dx_release (struct dx_frame *frames) -+{ -+ if (((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels) -+ brelse (frames[1].bh); -+ brelse (frames[0].bh); -+} -+ -+/* -+ * Directory block splitting, compacting -+ */ -+ -+static int dx_make_map (ext3_dirent *de, int size, struct dx_map_entry map[]) -+{ -+ int count = 0; -+ char *base = (char *) de; -+ while ((char *) de < base + size) -+ { -+ map[count].hash = dx_hash (de->name, de->name_len); -+ map[count].offs = (u32) ((char *) de - base); -+ de = (ext3_dirent *) ((char *) de + le16_to_cpu(de->rec_len)); -+ count++; -+ } -+ return count; -+} -+ -+static void dx_sort_map (struct dx_map_entry *map, unsigned count) -+{ -+ struct dx_map_entry *p, *q, *top = map + count - 1; -+ int more; -+ /* Combsort until bubble sort doesn't suck */ -+ while (count > 2) -+ { -+ count = count*10/13; -+ if (count - 9 < 2) /* 9, 10 -> 11 */ -+ count = 11; -+ for (p = top, q = p - count; q >= map; p--, q--) -+ if (p->hash < q->hash) -+ swap(*p, *q); -+ } -+ /* Garden variety bubble sort */ -+ do { -+ more = 0; -+ q = top; -+ while (q-- > map) -+ { -+ if (q[1].hash >= q[0].hash) -+ continue; -+ swap(*(q+1), *q); -+ more = 1; -+ } -+ } while(more); -+} -+ -+static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block) -+{ -+ struct dx_entry *entries = frame->entries, *at = frame->at; -+ assert (dx_get_count (entries) < dx_get_limit (entries) && -+ frame->at < frame->entries+dx_get_count(entries)); -+ memmove (at + 2, at+1, (char *) (entries + dx_get_count(entries)) - (char *) (at)); -+ dx_set_hash(at + 1, hash); -+ dx_set_block(at + 1, block); -+ dx_set_count(entries, dx_get_count(entries) + 1); -+} -+#endif -+ - /* - * NOTE! unlike strncmp, ext3_match returns 1 for success, 0 for failure. - * -@@ -95,6 +529,15 @@ - } - - /* -+ * p is at least 6 bytes before the end of page -+ */ -+static inline ext3_dirent *ext3_next_entry(ext3_dirent *p) -+{ -+ return (ext3_dirent *)((char*)p + le16_to_cpu(p->rec_len)); -+} -+ -+ -+/* - * ext3_find_entry() - * - * finds an entry in the specified directory with the wanted name. It -@@ -105,6 +548,8 @@ - * The returned buffer_head has ->b_count elevated. The caller is expected - * to brelse() it when appropriate. - */ -+ -+ - static struct buffer_head * ext3_find_entry (struct dentry *dentry, - struct ext3_dir_entry_2 ** res_dir) - { -@@ -119,10 +564,76 @@ - int num = 0; - int nblocks, i, err; - struct inode *dir = dentry->d_parent->d_inode; -+ int namelen; -+ const u8 *name; -+ unsigned blocksize; -+ ext3_dirent *de, *top; - - *res_dir = NULL; - sb = dir->i_sb; -+ blocksize = sb->s_blocksize; -+ namelen = dentry->d_name.len; -+ name = dentry->d_name.name; -+ if (namelen > EXT3_NAME_LEN) -+ return NULL; -+ if (ext3_dx && is_dx(dir)) { -+ u32 hash = dx_hash (name, namelen); -+ struct dx_frame frames[2], *frame; -+ if (!(frame = dx_probe (dir, hash, frames))) -+ return NULL; -+dxnext: -+ block = dx_get_block(frame->at); -+ if (!(bh = ext3_bread (NULL,dir, block, 0, &err))) -+ goto dxfail; -+ de = (ext3_dirent *) bh->b_data; -+ top = (ext3_dirent *) ((char *) de + blocksize - -+ EXT3_DIR_REC_LEN(0)); -+ for (; de < top; de = ext3_next_entry(de)) -+ if (ext3_match (namelen, name, de)) { -+ if (!ext3_check_dir_entry("ext3_find_entry", -+ dir, de, bh, -+ (block<b_data))) { -+ brelse (bh); -+ goto dxfail; -+ } -+ *res_dir = de; -+ goto dxfound; -+ } -+ brelse (bh); -+ /* Same hash continues in next block? Search on. */ -+ if (++(frame->at) == frame->entries + dx_get_count(frame->entries)) -+ { -+ struct buffer_head *bh2; -+ if (frame == frames) -+ goto dxfail; -+ if (++(frames->at) == frames->entries + dx_get_count(frames->entries)) -+ goto dxfail; -+ /* should omit read if not continued */ -+ if (!(bh2 = ext3_bread (NULL, dir, -+ dx_get_block(frames->at), -+ 0, &err))) -+ goto dxfail; -+ brelse (frame->bh); -+ frame->bh = bh2; -+ frame->at = frame->entries = ((struct dx_node *) bh2->b_data)->entries; -+ /* Subtle: the 0th entry has the count, find the hash in frame above */ -+ if ((dx_get_hash(frames->at) & -2) == hash) -+ goto dxnext; -+ goto dxfail; -+ } -+ if ((dx_get_hash(frame->at) & -2) == hash) -+ goto dxnext; -+dxfail: -+ dxtrace(printk("%s not found\n", name)); -+ dx_release (frames); -+ return NULL; -+dxfound: -+ dx_release (frames); -+ return bh; - -+ } -+ - nblocks = dir->i_size >> EXT3_BLOCK_SIZE_BITS(sb); - start = dir->u.ext3_i.i_dir_start_lookup; - if (start >= nblocks) -@@ -237,6 +748,88 @@ - de->file_type = ext3_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; - } - -+static ext3_dirent * -+dx_copy_dirents (char *from, char *to, struct dx_map_entry *map, int count) -+{ -+ unsigned rec_len = 0; -+ -+ while (count--) { -+ ext3_dirent *de = (ext3_dirent *) (from + map->offs); -+ rec_len = EXT3_DIR_REC_LEN(de->name_len); -+ memcpy (to, de, rec_len); -+ ((ext3_dirent *) to)->rec_len = rec_len; -+ to += rec_len; -+ map++; -+ } -+ return (ext3_dirent *) (to - rec_len); -+} -+ -+#ifdef CONFIG_EXT3_INDEX -+static ext3_dirent *do_split(handle_t *handle, struct inode *dir, -+ struct buffer_head **bh,struct dx_frame *frame, -+ u32 hash, int *error) -+{ -+ unsigned blocksize = dir->i_sb->s_blocksize; -+ unsigned count, continued; -+ struct buffer_head *bh2; -+ u32 newblock; -+ unsigned MAX_DX_MAP = PAGE_CACHE_SIZE/EXT3_DIR_REC_LEN(1) + 1; -+ u32 hash2; -+ struct dx_map_entry map[MAX_DX_MAP]; -+ char *data1 = (*bh)->b_data, *data2, *data3; -+ unsigned split; -+ ext3_dirent *de, *de2; -+ -+ bh2 = ext3_append (handle, dir, &newblock, error); -+ if (!(bh2)) -+ { -+ brelse(*bh); -+ *bh = NULL; -+ return (ext3_dirent *)bh2; -+ } -+ -+ BUFFER_TRACE(*bh, "get_write_access"); -+ ext3_journal_get_write_access(handle, *bh); -+ BUFFER_TRACE(frame->bh, "get_write_access"); -+ ext3_journal_get_write_access(handle, frame->bh); -+ -+ data2 = bh2->b_data; -+ -+ count = dx_make_map ((ext3_dirent *) data1, blocksize, map); -+ split = count/2; // need to adjust to actual middle -+ dx_sort_map (map, count); -+ hash2 = map[split].hash; -+ continued = hash2 == map[split - 1].hash; -+ dxtrace(printk("Split block %i at %x, %i/%i\n", -+ dx_get_block(frame->at), hash2, split, count-split)); -+ -+ /* Fancy dance to stay within two buffers */ -+ de2 = dx_copy_dirents (data1, data2, map + split, count - split); -+ data3 = (char *) de2 + de2->rec_len; -+ de = dx_copy_dirents (data1, data3, map, split); -+ memcpy(data1, data3, (char *) de + de->rec_len - data3); -+ de = (ext3_dirent *) ((char *) de - data3 + data1); // relocate de -+ de->rec_len = cpu_to_le16(data1 + blocksize - (char *) de); -+ de2->rec_len = cpu_to_le16(data2 + blocksize - (char *) de2); -+ dxtrace(dx_show_leaf ((ext3_dirent *) data1, blocksize, 1)); -+ dxtrace(dx_show_leaf ((ext3_dirent *) data2, blocksize, 1)); -+ -+ /* Which block gets the new entry? */ -+ if (hash >= hash2) -+ { -+ swap(*bh, bh2); -+ de = de2; -+ } -+ dx_insert_block (frame, hash2 + continued, newblock); -+ ext3_journal_dirty_metadata (handle, bh2); -+ brelse (bh2); -+ ext3_journal_dirty_metadata (handle, frame->bh); -+ dxtrace(dx_show_index ("frame", frame->entries)); -+ return de; -+} -+#endif -+ -+ - /* - * ext3_add_entry() - * -@@ -251,6 +844,7 @@ - /* - * AKPM: the journalling code here looks wrong on the error paths - */ -+ - static int ext3_add_entry (handle_t *handle, struct dentry *dentry, - struct inode *inode) - { -@@ -258,117 +852,282 @@ - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - unsigned long offset; -- unsigned short rec_len; - struct buffer_head * bh; -- struct ext3_dir_entry_2 * de, * de1; -- struct super_block * sb; -+ ext3_dirent *de; -+ struct super_block * sb = dir->i_sb; - int retval; -+ unsigned short reclen = EXT3_DIR_REC_LEN(namelen); - -- sb = dir->i_sb; -+ unsigned blocksize = sb->s_blocksize; -+ unsigned nlen, rlen; -+ u32 block, blocks; -+ char *top; - - if (!namelen) - return -EINVAL; -- bh = ext3_bread (handle, dir, 0, 0, &retval); -- if (!bh) -- return retval; -- rec_len = EXT3_DIR_REC_LEN(namelen); -- offset = 0; -- de = (struct ext3_dir_entry_2 *) bh->b_data; -- while (1) { -- if ((char *)de >= sb->s_blocksize + bh->b_data) { -- brelse (bh); -- bh = NULL; -- bh = ext3_bread (handle, dir, -- offset >> EXT3_BLOCK_SIZE_BITS(sb), 1, &retval); -- if (!bh) -- return retval; -- if (dir->i_size <= offset) { -- if (dir->i_size == 0) { -- brelse(bh); -- return -ENOENT; -+ if (ext3_dx && is_dx(dir)) -+ { -+ struct dx_frame frames[2], *frame; -+ struct dx_entry *entries, *at; -+ u32 hash; -+ char *data1; -+ -+ hash = dx_hash (name, namelen); -+ frame = dx_probe (dir, hash, frames); // do something if null -+ entries = frame->entries; -+ at = frame->at; -+ -+ if (!(bh = ext3_bread (handle,dir, dx_get_block(frame->at), 0,&retval))) -+ goto dxfail1; -+ -+ BUFFER_TRACE(bh, "get_write_access"); -+ ext3_journal_get_write_access(handle, bh); -+ -+ data1 = bh->b_data; -+ de = (ext3_dirent *) data1; -+ top = data1 + (0? 200: blocksize); -+ while ((char *) de < top) -+ { -+ /* FIXME: check EEXIST and dir */ -+ nlen = EXT3_DIR_REC_LEN(de->name_len); -+ rlen = le16_to_cpu(de->rec_len); -+ if ((de->inode? rlen - nlen: rlen) >= reclen) -+ goto dx_add; -+ de = (ext3_dirent *) ((char *) de + rlen); -+ } -+ /* Block full, should compress but for now just split */ -+ dxtrace(printk("using %u of %u node entries\n", -+ dx_get_count(entries), dx_get_limit(entries))); -+ /* Need to split index? */ -+ if (dx_get_count(entries) == dx_get_limit(entries)) -+ { -+ u32 newblock; -+ unsigned icount = dx_get_count(entries); -+ int levels = frame - frames; -+ struct dx_entry *entries2; -+ struct dx_node *node2; -+ struct buffer_head *bh2; -+ if (levels && dx_get_count(frames->entries) == dx_get_limit(frames->entries)) -+ goto dxfull; -+ bh2 = ext3_append (handle, dir, &newblock, &retval); -+ if (!(bh2)) -+ goto dxfail2; -+ node2 = (struct dx_node *)(bh2->b_data); -+ entries2 = node2->entries; -+ node2->fake.rec_len = cpu_to_le16(blocksize); -+ node2->fake.inode = 0; -+ BUFFER_TRACE(frame->bh, "get_write_access"); -+ ext3_journal_get_write_access(handle, frame->bh); -+ if (levels) -+ { -+ unsigned icount1 = icount/2, icount2 = icount - icount1; -+ unsigned hash2 = dx_get_hash(entries + icount1); -+ dxtrace(printk("Split index %i/%i\n", icount1, icount2)); -+ -+ BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */ -+ ext3_journal_get_write_access(handle, frames[0].bh); -+ -+ memcpy ((char *) entries2, (char *) (entries + icount1), -+ icount2 * sizeof(struct dx_entry)); -+ dx_set_count (entries, icount1); -+ dx_set_count (entries2, icount2); -+ dx_set_limit (entries2, dx_node_limit(dir)); -+ -+ /* Which index block gets the new entry? */ -+ if (at - entries >= icount1) { -+ frame->at = at = at - entries - icount1 + entries2; -+ frame->entries = entries = entries2; -+ swap(frame->bh, bh2); - } -- -- ext3_debug ("creating next block\n"); -- -- BUFFER_TRACE(bh, "get_write_access"); -- ext3_journal_get_write_access(handle, bh); -- de = (struct ext3_dir_entry_2 *) bh->b_data; -- de->inode = 0; -- de->rec_len = le16_to_cpu(sb->s_blocksize); -- dir->u.ext3_i.i_disksize = -- dir->i_size = offset + sb->s_blocksize; -- dir->u.ext3_i.i_flags &= ~EXT3_INDEX_FL; -- ext3_mark_inode_dirty(handle, dir); -+ dx_insert_block (frames + 0, hash2, newblock); -+ dxtrace(dx_show_index ("node", frames[1].entries)); -+ dxtrace(dx_show_index ("node", -+ ((struct dx_node *) bh2->b_data)->entries)); -+ ext3_journal_dirty_metadata(handle, bh2); -+ brelse (bh2); - } else { -- -- ext3_debug ("skipping to next block\n"); -- -- de = (struct ext3_dir_entry_2 *) bh->b_data; -+ dxtrace(printk("Creating second level index...\n")); -+ memcpy((char *) entries2, (char *) entries, -+ icount * sizeof(struct dx_entry)); -+ dx_set_limit(entries2, dx_node_limit(dir)); -+ -+ /* Set up root */ -+ dx_set_count(entries, 1); -+ dx_set_block(entries + 0, newblock); -+ ((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1; -+ -+ /* Add new access path frame */ -+ frame = frames + 1; -+ frame->at = at = at - entries + entries2; -+ frame->entries = entries = entries2; -+ frame->bh = bh2; -+ ext3_journal_get_write_access(handle, frame->bh); - } -+ ext3_journal_dirty_metadata(handle, frames[0].bh); - } -- if (!ext3_check_dir_entry ("ext3_add_entry", dir, de, bh, -- offset)) { -- brelse (bh); -- return -ENOENT; -- } -- if (ext3_match (namelen, name, de)) { -+ de = do_split(handle, dir, &bh, frame, hash, &retval); -+ dx_release (frames); -+ if (!(de)) -+ goto fail; -+ nlen = EXT3_DIR_REC_LEN(de->name_len); -+ rlen = le16_to_cpu(de->rec_len); -+ goto add; -+ -+dx_add: -+ dx_release (frames); -+ goto add; -+ -+dxfull: -+ ext3_warning(sb, __FUNCTION__, "Directory index full!\n"); -+ retval = -ENOSPC; -+dxfail2: -+ brelse(bh); -+dxfail1: -+ dx_release (frames); -+ goto fail1; -+ } -+ -+ blocks = dir->i_size >> sb->s_blocksize_bits; -+ for (block = 0, offset = 0; block < blocks; block++) { -+ bh = ext3_bread(handle, dir, block, 0, &retval); -+ if(!bh) -+ return retval; -+ de = (ext3_dirent *)bh->b_data; -+ top = bh->b_data + blocksize - reclen; -+ while ((char *) de <= top) { -+ if (!ext3_check_dir_entry("ext3_add_entry", dir, de, -+ bh, offset)) { -+ brelse (bh); -+ return -EIO; -+ } -+ if (ext3_match (namelen, name, de)) { - brelse (bh); - return -EEXIST; -- } -- if ((le32_to_cpu(de->inode) == 0 && -- le16_to_cpu(de->rec_len) >= rec_len) || -- (le16_to_cpu(de->rec_len) >= -- EXT3_DIR_REC_LEN(de->name_len) + rec_len)) { -- BUFFER_TRACE(bh, "get_write_access"); -- ext3_journal_get_write_access(handle, bh); -- /* By now the buffer is marked for journaling */ -- offset += le16_to_cpu(de->rec_len); -- if (le32_to_cpu(de->inode)) { -- de1 = (struct ext3_dir_entry_2 *) ((char *) de + -- EXT3_DIR_REC_LEN(de->name_len)); -- de1->rec_len = -- cpu_to_le16(le16_to_cpu(de->rec_len) - -- EXT3_DIR_REC_LEN(de->name_len)); -- de->rec_len = cpu_to_le16( -- EXT3_DIR_REC_LEN(de->name_len)); -- de = de1; - } -- de->file_type = EXT3_FT_UNKNOWN; -- if (inode) { -- de->inode = cpu_to_le32(inode->i_ino); -- ext3_set_de_type(dir->i_sb, de, inode->i_mode); -- } else -- de->inode = 0; -- de->name_len = namelen; -- memcpy (de->name, name, namelen); -- /* -- * XXX shouldn't update any times until successful -- * completion of syscall, but too many callers depend -- * on this. -- * -- * XXX similarly, too many callers depend on -- * ext3_new_inode() setting the times, but error -- * recovery deletes the inode, so the worst that can -- * happen is that the times are slightly out of date -- * and/or different from the directory change time. -- */ -- dir->i_mtime = dir->i_ctime = CURRENT_TIME; -- dir->u.ext3_i.i_flags &= ~EXT3_INDEX_FL; -- ext3_mark_inode_dirty(handle, dir); -- dir->i_version = ++event; -- BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); -- ext3_journal_dirty_metadata(handle, bh); -+ nlen = EXT3_DIR_REC_LEN(de->name_len); -+ rlen = le16_to_cpu(de->rec_len); -+ if ((de->inode? rlen - nlen: rlen) >= reclen) -+ goto add; -+ de = (ext3_dirent *)((char *)de + rlen); -+ offset += rlen; -+ } -+ if (ext3_dx && blocks == 1 && test_opt(sb, INDEX)) -+ goto dx_make_index; -+ brelse(bh); -+ } -+ bh = ext3_append(handle, dir, &block, &retval); -+ if (!bh) -+ return retval; -+ de = (ext3_dirent *) bh->b_data; -+ de->inode = 0; -+ de->rec_len = cpu_to_le16(rlen = blocksize); -+ nlen = 0; -+ goto add; -+ -+add: -+ BUFFER_TRACE(bh, "get_write_access"); -+ ext3_journal_get_write_access(handle, bh); -+ /* By now the buffer is marked for journaling */ -+ if (de->inode) { -+ ext3_dirent *de1 = (ext3_dirent *)((char *)de + nlen); -+ de1->rec_len = cpu_to_le16(rlen - nlen); -+ de->rec_len = cpu_to_le16(nlen); -+ de = de1; -+ } -+ de->file_type = EXT3_FT_UNKNOWN; -+ if (inode) { -+ de->inode = cpu_to_le32(inode->i_ino); -+ ext3_set_de_type(dir->i_sb, de, inode->i_mode); -+ } else -+ de->inode = 0; -+ de->name_len = namelen; -+ memcpy (de->name, name, namelen); -+ /* -+ * XXX shouldn't update any times until successful -+ * completion of syscall, but too many callers depend -+ * on this. -+ * -+ * XXX similarly, too many callers depend on -+ * ext3_new_inode() setting the times, but error -+ * recovery deletes the inode, so the worst that can -+ * happen is that the times are slightly out of date -+ * and/or different from the directory change time. -+ */ -+ dir->i_mtime = dir->i_ctime = CURRENT_TIME; -+ /* EXT3_I(dir)->i_flags &= ~EXT3_INDEX_FL; */ -+ ext3_mark_inode_dirty(handle, dir); -+ dir->i_version = ++event; -+ BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); -+ ext3_journal_dirty_metadata(handle, bh); -+ brelse(bh); -+ return 0; -+ -+dx_make_index: -+ { -+ struct buffer_head *bh2; -+ struct dx_root *root; -+ struct dx_frame frames[2], *frame; -+ struct dx_entry *entries; -+ ext3_dirent *de2; -+ char *data1; -+ unsigned len; -+ u32 hash; -+ -+ dxtrace(printk("Creating index\n")); -+ ext3_journal_get_write_access(handle, bh); -+ root = (struct dx_root *) bh->b_data; -+ -+ ext3_add_compat_feature (sb, EXT3_FEATURE_COMPAT_DIR_INDEX); -+ EXT3_I(dir)->i_flags |= EXT3_INDEX_FL; -+ bh2 = ext3_append (handle, dir, &block, &retval); -+ if (!(bh2)) -+ { - brelse(bh); -- return 0; -+ return retval; - } -- offset += le16_to_cpu(de->rec_len); -- de = (struct ext3_dir_entry_2 *) -- ((char *) de + le16_to_cpu(de->rec_len)); -+ data1 = bh2->b_data; -+ -+ /* The 0th block becomes the root, move the dirents out */ -+ de = (ext3_dirent *) &root->info; -+ len = ((char *) root) + blocksize - (char *) de; -+ memcpy (data1, de, len); -+ de = (ext3_dirent *) data1; -+ top = data1 + len; -+ while (((char *) de2=(char*)de+le16_to_cpu(de->rec_len)) < top) -+ de = de2; -+ de->rec_len = cpu_to_le16(data1 + blocksize - (char *) de); -+ /* Initialize the root; the dot dirents already exist */ -+ de = (ext3_dirent *) (&root->fake2); -+ de->rec_len = cpu_to_le16(blocksize - EXT3_DIR_REC_LEN(2)); -+ memset (&root->info, 0, sizeof(root->info)); -+ root->info.info_length = sizeof(root->info); -+ entries = root->entries; -+ dx_set_block (entries, 1); -+ dx_set_count (entries, 1); -+ dx_set_limit (entries, dx_root_limit(dir, sizeof(root->info))); -+ -+ /* Initialize as for dx_probe */ -+ hash = dx_hash (name, namelen); -+ frame = frames; -+ frame->entries = entries; -+ frame->at = entries; -+ frame->bh = bh; -+ bh = bh2; -+ de = do_split(handle,dir, &bh, frame, hash, &retval); -+ dx_release (frames); -+ if (!(de)) -+ return retval; -+ nlen = EXT3_DIR_REC_LEN(de->name_len); -+ rlen = le16_to_cpu(de->rec_len); -+ goto add; - } -- brelse (bh); -- return -ENOSPC; -+fail1: -+ return retval; -+fail: -+ return -ENOENT; - } - -+ - /* - * ext3_delete_entry deletes a directory entry by merging it with the - * previous entry -@@ -451,7 +1212,8 @@ - struct inode * inode; - int err; - -- handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + 3); -+ handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + -+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3); - if (IS_ERR(handle)) - return PTR_ERR(handle); - -@@ -478,7 +1240,8 @@ - struct inode *inode; - int err; - -- handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + 3); -+ handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + -+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3); - if (IS_ERR(handle)) - return PTR_ERR(handle); - -@@ -507,7 +1270,8 @@ - if (dir->i_nlink >= EXT3_LINK_MAX) - return -EMLINK; - -- handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + 3); -+ handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + -+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3); - if (IS_ERR(handle)) - return PTR_ERR(handle); - -@@ -832,7 +1596,7 @@ - ext3_mark_inode_dirty(handle, inode); - dir->i_nlink--; - inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; -- dir->u.ext3_i.i_flags &= ~EXT3_INDEX_FL; -+ // EXT3_I(dir)->i_flags &= ~EXT3_INDEX_FL; - ext3_mark_inode_dirty(handle, dir); - - end_rmdir: -@@ -878,7 +1642,7 @@ - if (retval) - goto end_unlink; - dir->i_ctime = dir->i_mtime = CURRENT_TIME; -- dir->u.ext3_i.i_flags &= ~EXT3_INDEX_FL; -+ // EXT3_I(dir)->i_flags &= ~EXT3_INDEX_FL; - ext3_mark_inode_dirty(handle, dir); - inode->i_nlink--; - if (!inode->i_nlink) -@@ -904,7 +1668,8 @@ - if (l > dir->i_sb->s_blocksize) - return -ENAMETOOLONG; - -- handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + 5); -+ handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + -+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5); - if (IS_ERR(handle)) - return PTR_ERR(handle); - -@@ -959,7 +1724,8 @@ - if (inode->i_nlink >= EXT3_LINK_MAX) - return -EMLINK; - -- handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS); -+ handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS + -+ EXT3_INDEX_EXTRA_TRANS_BLOCKS); - if (IS_ERR(handle)) - return PTR_ERR(handle); - -@@ -995,7 +1761,8 @@ - - old_bh = new_bh = dir_bh = NULL; - -- handle = ext3_journal_start(old_dir, 2 * EXT3_DATA_TRANS_BLOCKS + 2); -+ handle = ext3_journal_start(old_dir, 2 * EXT3_DATA_TRANS_BLOCKS + -+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); - if (IS_ERR(handle)) - return PTR_ERR(handle); - -@@ -1077,7 +1844,7 @@ - new_inode->i_ctime = CURRENT_TIME; - } - old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; -- old_dir->u.ext3_i.i_flags &= ~EXT3_INDEX_FL; -+ // EXT3_I(old_dir)->i_flags &= ~EXT3_INDEX_FL; - if (dir_bh) { - BUFFER_TRACE(dir_bh, "get_write_access"); - ext3_journal_get_write_access(handle, dir_bh); -@@ -1089,7 +1856,7 @@ - new_inode->i_nlink--; - } else { - new_dir->i_nlink++; -- new_dir->u.ext3_i.i_flags &= ~EXT3_INDEX_FL; -+ // EXT3_I(new_dir)->i_flags &= ~EXT3_INDEX_FL; - ext3_mark_inode_dirty(handle, new_dir); - } - } ---- ./include/linux/ext3_fs.h 2002/03/05 06:18:59 2.1 -+++ ./include/linux/ext3_fs.h 2002/03/05 06:26:56 -@@ -339,6 +339,7 @@ - #define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */ - #define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */ - #define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */ -+#define EXT3_MOUNT_INDEX 0x4000 /* Enable directory index */ - - /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */ - #ifndef _LINUX_EXT2_FS_H -@@ -575,6 +576,24 @@ - #define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1) - #define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \ - ~EXT3_DIR_ROUND) -+/* -+ * Hash Tree Directory indexing -+ * (c) Daniel Phillips, 2001 -+ */ -+ -+#define CONFIG_EXT3_INDEX -+ -+#ifdef CONFIG_EXT3_INDEX -+ enum {ext3_dx = 1}; -+ #define is_dx(dir) (EXT3_I(dir)->i_flags & EXT3_INDEX_FL) -+#define EXT3_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT3_LINK_MAX) -+#define EXT3_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) -+#else -+ enum {ext3_dx = 0}; -+ #define is_dx(dir) 0 -+#define EXT3_DIR_LINK_MAX(dir) ((dir)->i_nlink >= EXT3_LINK_MAX) -+#define EXT3_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2) -+#endif - - #ifdef __KERNEL__ - /* ---- ./include/linux/ext3_jbd.h 2002/03/05 06:18:59 2.1 -+++ ./include/linux/ext3_jbd.h 2002/03/05 06:33:54 -@@ -63,6 +63,8 @@ - - #define EXT3_RESERVE_TRANS_BLOCKS 12 - -+#define EXT3_INDEX_EXTRA_TRANS_BLOCKS 8 -+ - int - ext3_mark_iloc_dirty(handle_t *handle, - struct inode *inode, diff --git a/lustre/extN/linux-2.4.18ea-0.8.26.diff b/lustre/extN/linux-2.4.18ea-0.8.26.diff deleted file mode 100644 index 7504fea..0000000 --- a/lustre/extN/linux-2.4.18ea-0.8.26.diff +++ /dev/null @@ -1,1787 +0,0 @@ -Linux Extended Attributes -- Kernel Patch -24 April 2002, 11:31:18 - - -This patch 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 patch 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 patch; if not, write to the Free Software Foundation, -Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -After extracting the linux-2.4.18.tar.gz package, apply this patch as follows: - - cd linux - patch -p1 < ../linux-2.4.18ea-0.8.26.patch - -diff -Nur linux-2.4.18/fs/ext3/ialloc.c linux-2.4.18ea/fs/ext3/ialloc.c ---- linux-2.4.18/fs/ext3/ialloc.c Sun Feb 24 04:42:59 2002 -+++ linux-2.4.18ea/fs/ext3/ialloc.c Sun Feb 24 04:34:43 2002 -@@ -17,6 +17,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -216,6 +217,7 @@ - * as writing the quota to disk may need the lock as well. - */ - DQUOT_INIT(inode); -+ ext3_xattr_drop_inode(handle, inode); - DQUOT_FREE_INODE(inode); - DQUOT_DROP(inode); - -diff -Nur linux-2.4.18/fs/ext3/inode.c linux-2.4.18ea/fs/ext3/inode.c ---- linux-2.4.18/fs/ext3/inode.c Sun Feb 24 04:42:59 2002 -+++ linux-2.4.18ea/fs/ext3/inode.c Thu Mar 14 21:51:59 2002 -@@ -39,6 +39,18 @@ - */ - #undef SEARCH_FROM_ZERO - -+/* -+ * Test whether an inode is a fast symlink. -+ */ -+static inline int ext3_inode_is_fast_symlink(struct inode *inode) -+{ -+ int ea_blocks = EXT3_I(inode)->i_file_acl ? -+ (inode->i_sb->s_blocksize >> 9) : 0; -+ -+ return (S_ISLNK(inode->i_mode) && -+ inode->i_blocks - ea_blocks == 0); -+} -+ - /* The ext3 forget function must perform a revoke if we are freeing data - * which has been journaled. Metadata (eg. indirect blocks) must be - * revoked in all cases. -@@ -48,7 +60,7 @@ - * still needs to be revoked. - */ - --static int ext3_forget(handle_t *handle, int is_metadata, -+int ext3_forget(handle_t *handle, int is_metadata, - struct inode *inode, struct buffer_head *bh, - int blocknr) - { -@@ -164,9 +176,7 @@ - { - handle_t *handle; - -- if (is_bad_inode(inode) || -- inode->i_ino == EXT3_ACL_IDX_INO || -- inode->i_ino == EXT3_ACL_DATA_INO) -+ if (is_bad_inode(inode)) - goto no_delete; - - lock_kernel(); -@@ -1845,6 +1855,8 @@ - if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || - S_ISLNK(inode->i_mode))) - return; -+ if (ext3_inode_is_fast_symlink(inode)) -+ return; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) - return; - -@@ -1992,8 +2004,6 @@ - struct ext3_group_desc * gdp; - - if ((inode->i_ino != EXT3_ROOT_INO && -- inode->i_ino != EXT3_ACL_IDX_INO && -- inode->i_ino != EXT3_ACL_DATA_INO && - inode->i_ino != EXT3_JOURNAL_INO && - inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) || - inode->i_ino > le32_to_cpu( -@@ -2120,10 +2130,7 @@ - - brelse (iloc.bh); - -- if (inode->i_ino == EXT3_ACL_IDX_INO || -- inode->i_ino == EXT3_ACL_DATA_INO) -- /* Nothing to do */ ; -- else if (S_ISREG(inode->i_mode)) { -+ if (S_ISREG(inode->i_mode)) { - inode->i_op = &ext3_file_inode_operations; - inode->i_fop = &ext3_file_operations; - inode->i_mapping->a_ops = &ext3_aops; -@@ -2131,7 +2138,7 @@ - inode->i_op = &ext3_dir_inode_operations; - inode->i_fop = &ext3_dir_operations; - } else if (S_ISLNK(inode->i_mode)) { -- if (!inode->i_blocks) -+ if (ext3_inode_is_fast_symlink(inode)) - inode->i_op = &ext3_fast_symlink_inode_operations; - else { - inode->i_op = &page_symlink_inode_operations; -diff -Nur linux-2.4.18/fs/ext3/namei.c linux-2.4.18ea/fs/ext3/namei.c ---- linux-2.4.18/fs/ext3/namei.c Fri Nov 9 23:25:04 2001 -+++ linux-2.4.18ea/fs/ext3/namei.c Mon Mar 11 03:27:00 2002 -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -466,6 +467,8 @@ - inode->i_mapping->a_ops = &ext3_aops; - ext3_mark_inode_dirty(handle, inode); - err = ext3_add_nondir(handle, dentry, inode); -+ if (err) -+ ext3_xattr_drop_inode(handle, inode); - } - ext3_journal_stop(handle, dir); - return err; -@@ -491,6 +494,8 @@ - init_special_inode(inode, mode, rdev); - ext3_mark_inode_dirty(handle, inode); - err = ext3_add_nondir(handle, dentry, inode); -+ if (err) -+ ext3_xattr_drop_inode(handle, inode); - } - ext3_journal_stop(handle, dir); - return err; -@@ -514,7 +519,7 @@ - if (IS_SYNC(dir)) - handle->h_sync = 1; - -- inode = ext3_new_inode (handle, dir, S_IFDIR); -+ inode = ext3_new_inode (handle, dir, S_IFDIR | mode); - err = PTR_ERR(inode); - if (IS_ERR(inode)) - goto out_stop; -@@ -522,7 +527,6 @@ - inode->i_op = &ext3_dir_inode_operations; - inode->i_fop = &ext3_dir_operations; -- inode->i_size = inode->u.ext3_i.i_disksize = inode->i_sb->s_blocksize; -- inode->i_blocks = 0; -+ inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize; - dir_block = ext3_bread (handle, inode, 0, 1, &err); - if (!dir_block) { - inode->i_nlink--; /* is this nlink == 0? */ -@@ -549,9 +553,6 @@ - BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata"); - ext3_journal_dirty_metadata(handle, dir_block); - brelse (dir_block); -- inode->i_mode = S_IFDIR | mode; -- if (dir->i_mode & S_ISGID) -- inode->i_mode |= S_ISGID; - ext3_mark_inode_dirty(handle, inode); - err = ext3_add_entry (handle, dentry, inode); - if (err) -@@ -565,6 +566,7 @@ - return err; - - out_no_entry: -+ ext3_xattr_drop_inode(handle, inode); - inode->i_nlink = 0; - ext3_mark_inode_dirty(handle, inode); - iput (inode); -@@ -917,5 +919,5 @@ - goto out_stop; - -- if (l > sizeof (inode->u.ext3_i.i_data)) { -+ if (l > sizeof(EXT3_I(inode)->i_data)) { - inode->i_op = &page_symlink_inode_operations; - inode->i_mapping->a_ops = &ext3_aops; -diff -Nur linux-2.4.18/fs/ext3/super.c linux-2.4.18ea/fs/ext3/super.c ---- linux-2.4.18/fs/ext3/super.c Sun Feb 24 04:42:59 2002 -+++ linux-2.4.18ea/fs/ext3/super.c Thu Apr 4 21:41:05 2002 -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -404,6 +405,7 @@ - kdev_t j_dev = sbi->s_journal->j_dev; - int i; - -+ ext3_xattr_put_super(sb); - journal_destroy(sbi->s_journal); - if (!(sb->s_flags & MS_RDONLY)) { - EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); -@@ -1734,14 +1772,25 @@ - - static DECLARE_FSTYPE_DEV(ext3_fs_type, "ext3", ext3_read_super); - --static int __init init_ext3_fs(void) -+static void exit_ext3_fs(void) - { -- return register_filesystem(&ext3_fs_type); -+ unregister_filesystem(&ext3_fs_type); -+ exit_ext3_xattr_user(); -+ exit_ext3_xattr(); - } - --static void __exit exit_ext3_fs(void) -+static int __init init_ext3_fs(void) - { -- unregister_filesystem(&ext3_fs_type); -+ int error = init_ext3_xattr(); -+ if (!error) -+ error = init_ext3_xattr_user(); -+ if (!error) -+ error = register_filesystem(&ext3_fs_type); -+ if (!error) -+ return 0; -+ -+ exit_ext3_fs(); -+ return error; - } - - EXPORT_NO_SYMBOLS; -diff -Nur linux-2.4.18/fs/ext3/xattr.c linux-2.4.18ea/fs/ext3/xattr.c ---- linux-2.4.18/fs/ext3/xattr.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.18ea/fs/ext3/xattr.c Wed Apr 3 13:19:05 2002 -@@ -0,0 +1,1247 @@ -+/* -+ * linux/fs/ext3/xattr.c -+ * -+ * Copyright (C) 2001 by Andreas Gruenbacher, -+ * -+ * Fix by Harrison Xing . -+ * Ext3 code with a lot of help from Eric Jarman . -+ * Extended attributes for symlinks and special files added per -+ * suggestion of Luka Renko . -+ */ -+ -+/* -+ * Extended attributes are stored on disk blocks allocated outside of -+ * any inode. The i_file_acl field is then made to point to this allocated -+ * block. If all extended attributes of an inode are identical, these -+ * inodes may share the same extended attribute block. Such situations -+ * are automatically detected by keeping a cache of recent attribute block -+ * numbers and hashes over the block's contents in memory. -+ * -+ * -+ * Extended attribute block layout: -+ * -+ * +------------------+ -+ * | header | -+ * ¦ entry 1 | | -+ * | entry 2 | | growing downwards -+ * | entry 3 | v -+ * | four null bytes | -+ * | . . . | -+ * | value 1 | ^ -+ * | value 3 | | growing upwards -+ * | value 2 | | -+ * +------------------+ -+ * -+ * The block header is followed by multiple entry descriptors. These entry -+ * descriptors are variable in size, and alligned to EXT3_XATTR_PAD -+ * byte boundaries. The entry descriptors are sorted by attribute name, -+ * so that two extended attribute blocks can be compared efficiently. -+ * -+ * Attribute values are aligned to the end of the block, stored in -+ * no specific order. They are also padded to EXT3_XATTR_PAD byte -+ * boundaries. No additional gaps are left between them. -+ * -+ * Locking strategy -+ * ---------------- -+ * The VFS already holds the BKL and the inode->i_sem semaphore when any of -+ * the xattr inode operations are called, so we are guaranteed that only one -+ * processes accesses extended attributes of an inode at any time. -+ * -+ * For writing we also grab the ext3_xattr_sem semaphore. This ensures that -+ * only a single process is modifying an extended attribute block, even -+ * if the block is shared among inodes. -+ * -+ * Note for porting to 2.5 -+ * ----------------------- -+ * The BKL will no longer be held in the xattr inode operations. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#ifdef CONFIG_EXT3_FS_XATTR_SHARING -+#include -+#endif -+#include -+#include -+#include -+#include -+ -+/* These symbols may be needed by a module. */ -+EXPORT_SYMBOL(extN_xattr_register); -+EXPORT_SYMBOL(extN_xattr_unregister); -+EXPORT_SYMBOL(extN_xattr_get); -+EXPORT_SYMBOL(extN_xattr_list); -+EXPORT_SYMBOL(extN_xattr_set); -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) -+# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1) -+#endif -+ -+#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data)) -+#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr)) -+#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1) -+#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0) -+ -+#ifdef EXT3_XATTR_DEBUG -+# define ea_idebug(inode, f...) do { \ -+ printk(KERN_DEBUG "inode %s:%ld: ", \ -+ kdevname(inode->i_dev), inode->i_ino); \ -+ printk(f); \ -+ printk("\n"); \ -+ } while (0) -+# define ea_bdebug(bh, f...) do { \ -+ printk(KERN_DEBUG "block %s:%ld: ", \ -+ kdevname(bh->b_dev), bh->b_blocknr); \ -+ printk(f); \ -+ printk("\n"); \ -+ } while (0) -+#else -+# define ea_idebug(f...) -+# define ea_bdebug(f...) -+#endif -+ -+static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *, -+ struct ext3_xattr_header *); -+ -+#ifdef CONFIG_EXT3_FS_XATTR_SHARING -+ -+static int ext3_xattr_cache_insert(struct buffer_head *); -+static struct buffer_head *ext3_xattr_cache_find(struct inode *, -+ struct ext3_xattr_header *); -+static void ext3_xattr_cache_remove(struct buffer_head *); -+static void ext3_xattr_rehash(struct ext3_xattr_header *, -+ struct ext3_xattr_entry *); -+ -+static struct mb_cache *ext3_xattr_cache; -+ -+#else -+# define ext3_xattr_cache_insert(bh) 0 -+# define ext3_xattr_cache_find(inode, header) NULL -+# define ext3_xattr_cache_remove(bh) do {} while(0) -+# define ext3_xattr_rehash(header, entry) do {} while(0) -+#endif -+ -+/* -+ * If a file system does not share extended attributes among inodes, -+ * we should not need the ext3_xattr_sem semaphore. However, the -+ * filesystem may still contain shared blocks, so we always take -+ * the lock. -+ */ -+ -+DECLARE_MUTEX(ext3_xattr_sem); -+ -+static inline void -+ext3_xattr_lock(void) -+{ -+ down(&ext3_xattr_sem); -+} -+ -+static inline void -+ext3_xattr_unlock(void) -+{ -+ up(&ext3_xattr_sem); -+} -+ -+static inline int -+ext3_xattr_new_block(handle_t *handle, struct inode *inode, -+ int * errp, int force) -+{ -+ struct super_block *sb = inode->i_sb; -+ int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + -+ EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb); -+ -+ /* How can we enforce the allocation? */ -+ int block = ext3_new_block(handle, inode, goal, 0, 0, errp); -+#ifdef OLD_QUOTAS -+ if (!*errp) -+ inode->i_blocks += inode->i_sb->s_blocksize >> 9; -+#endif -+ return block; -+} -+ -+static inline int -+ext3_xattr_quota_alloc(struct inode *inode, int force) -+{ -+ /* How can we enforce the allocation? */ -+#ifdef OLD_QUOTAS -+ int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1); -+ if (!error) -+ inode->i_blocks += inode->i_sb->s_blocksize >> 9; -+#else -+ int error = DQUOT_ALLOC_BLOCK(inode, 1); -+#endif -+ return error; -+} -+ -+#ifdef OLD_QUOTAS -+ -+static inline void -+ext3_xattr_quota_free(struct inode *inode) -+{ -+ DQUOT_FREE_BLOCK(inode->i_sb, inode, 1); -+ inode->i_blocks -= inode->i_sb->s_blocksize >> 9; -+} -+ -+static inline void -+ext3_xattr_free_block(handle_t *handle, struct inode * inode, -+ unsigned long block) -+{ -+ ext3_free_blocks(handle, inode, block, 1); -+ inode->i_blocks -= inode->i_sb->s_blocksize >> 9; -+} -+ -+#else -+# define ext3_xattr_quota_free(inode) \ -+ DQUOT_FREE_BLOCK(inode, 1) -+# define ext3_xattr_free_block(handle, inode, block) \ -+ ext3_free_blocks(handle, inode, block, 1) -+#endif -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) -+ -+static inline struct buffer_head * -+sb_bread(struct super_block *sb, int block) -+{ -+ return bread(sb->s_dev, block, sb->s_blocksize); -+} -+ -+static inline struct buffer_head * -+sb_getblk(struct super_block *sb, int block) -+{ -+ return getblk(sb->s_dev, block, sb->s_blocksize); -+} -+ -+#endif -+ -+struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX]; -+rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED; -+ -+int -+ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler) -+{ -+ int error = -EINVAL; -+ -+ if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) { -+ write_lock(&ext3_handler_lock); -+ if (!ext3_xattr_handlers[name_index-1]) { -+ ext3_xattr_handlers[name_index-1] = handler; -+ error = 0; -+ } -+ write_unlock(&ext3_handler_lock); -+ } -+ return error; -+} -+ -+void -+ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler) -+{ -+ if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) { -+ write_lock(&ext3_handler_lock); -+ ext3_xattr_handlers[name_index-1] = NULL; -+ write_unlock(&ext3_handler_lock); -+ } -+} -+ -+static inline const char * -+strcmp_prefix(const char *a, const char *a_prefix) -+{ -+ while (*a_prefix && *a == *a_prefix) { -+ a++; -+ a_prefix++; -+ } -+ return *a_prefix ? NULL : a; -+} -+ -+/* -+ * Decode the extended attribute name, and translate it into -+ * the name_index and name suffix. -+ */ -+static inline struct ext3_xattr_handler * -+ext3_xattr_resolve_name(const char **name) -+{ -+ struct ext3_xattr_handler *handler = NULL; -+ int i; -+ -+ if (!*name) -+ return NULL; -+ read_lock(&ext3_handler_lock); -+ for (i=0; iprefix); -+ if (n) { -+ handler = ext3_xattr_handlers[i]; -+ *name = n; -+ break; -+ } -+ } -+ } -+ read_unlock(&ext3_handler_lock); -+ return handler; -+} -+ -+static inline struct ext3_xattr_handler * -+ext3_xattr_handler(int name_index) -+{ -+ struct ext3_xattr_handler *handler = NULL; -+ if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) { -+ read_lock(&ext3_handler_lock); -+ handler = ext3_xattr_handlers[name_index-1]; -+ read_unlock(&ext3_handler_lock); -+ } -+ return handler; -+} -+ -+/* -+ * Inode operation getxattr() -+ * -+ * dentry->d_inode->i_sem down -+ * BKL held [before 2.5.x] -+ */ -+ssize_t -+ext3_getxattr(struct dentry *dentry, const char *name, -+ void *buffer, size_t size) -+{ -+ struct ext3_xattr_handler *handler; -+ struct inode *inode = dentry->d_inode; -+ -+ handler = ext3_xattr_resolve_name(&name); -+ if (!handler) -+ return -ENOTSUP; -+ return handler->get(inode, name, buffer, size); -+} -+ -+/* -+ * Inode operation listxattr() -+ * -+ * dentry->d_inode->i_sem down -+ * BKL held [before 2.5.x] -+ */ -+ssize_t -+ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) -+{ -+ return ext3_xattr_list(dentry->d_inode, buffer, size); -+} -+ -+/* -+ * Inode operation setxattr() -+ * -+ * dentry->d_inode->i_sem down -+ * BKL held [before 2.5.x] -+ */ -+int -+ext3_setxattr(struct dentry *dentry, const char *name, -+ void *value, size_t size, int flags) -+{ -+ struct ext3_xattr_handler *handler; -+ struct inode *inode = dentry->d_inode; -+ -+ if (size == 0) -+ value = ""; /* empty EA, do not remove */ -+ handler = ext3_xattr_resolve_name(&name); -+ if (!handler) -+ return -ENOTSUP; -+ return handler->set(inode, name, value, size, flags); -+} -+ -+/* -+ * Inode operation removexattr() -+ * -+ * dentry->d_inode->i_sem down -+ * BKL held [before 2.5.x] -+ */ -+int -+ext3_removexattr(struct dentry *dentry, const char *name) -+{ -+ struct ext3_xattr_handler *handler; -+ struct inode *inode = dentry->d_inode; -+ -+ handler = ext3_xattr_resolve_name(&name); -+ if (!handler) -+ return -ENOTSUP; -+ return handler->set(inode, name, NULL, 0, XATTR_REPLACE); -+} -+ -+/* -+ * 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. -+ * -+ * Returns a negative error number on failure, or the number of bytes -+ * used / required on success. -+ */ -+int -+ext3_xattr_get(struct inode *inode, int name_index, const char *name, -+ void *buffer, size_t buffer_size) -+{ -+ struct buffer_head *bh = NULL; -+ struct ext3_xattr_entry *entry; -+ unsigned int block, size; -+ char *end; -+ int name_len, error; -+ -+ ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", -+ name_index, name, buffer, (long)buffer_size); -+ -+ if (name == NULL) -+ return -EINVAL; -+ if (!EXT3_I(inode)->i_file_acl) -+ return -ENOATTR; -+ block = EXT3_I(inode)->i_file_acl; -+ ea_idebug(inode, "reading block %d", block); -+ bh = sb_bread(inode->i_sb, block); -+ 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, block); -+ error = -EIO; -+ goto cleanup; -+ } -+ /* find named attribute */ -+ name_len = strlen(name); -+ -+ error = -ERANGE; -+ if (name_len > 255) -+ goto cleanup; -+ 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) -+ goto found; -+ entry = next; -+ } -+ /* Check the remaining name entries */ -+ while (!IS_LAST_ENTRY(entry)) { -+ struct ext3_xattr_entry *next = -+ EXT3_XATTR_NEXT(entry); -+ if ((char *)next >= end) -+ goto bad_block; -+ entry = next; -+ } -+ if (ext3_xattr_cache_insert(bh)) -+ ea_idebug(inode, "cache insert failed"); -+ error = -ENOATTR; -+ goto cleanup; -+found: -+ /* check the buffer size */ -+ if (entry->e_value_block != 0) -+ goto bad_block; -+ size = le32_to_cpu(entry->e_value_size); -+ if (size > inode->i_sb->s_blocksize || -+ le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize) -+ goto bad_block; -+ -+ if (ext3_xattr_cache_insert(bh)) -+ ea_idebug(inode, "cache insert failed"); -+ if (buffer) { -+ error = -ERANGE; -+ if (size > buffer_size) -+ goto cleanup; -+ /* return value of attribute */ -+ memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs), -+ size); -+ } -+ error = size; -+ -+cleanup: -+ brelse(bh); -+ -+ return error; -+} -+ -+/* -+ * 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) -+{ -+ struct buffer_head *bh = NULL; -+ struct ext3_xattr_entry *entry; -+ unsigned int block, size = 0; -+ char *buf, *end; -+ int error; -+ -+ ea_idebug(inode, "buffer=%p, buffer_size=%ld", -+ buffer, (long)buffer_size); -+ -+ if (!EXT3_I(inode)->i_file_acl) -+ return 0; -+ block = EXT3_I(inode)->i_file_acl; -+ ea_idebug(inode, "reading block %d", block); -+ bh = sb_bread(inode->i_sb, block); -+ 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_list", -+ "inode %ld: bad block %d", inode->i_ino, block); -+ error = -EIO; -+ goto cleanup; -+ } -+ /* compute the size required for the list of attribute names */ -+ for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry); -+ entry = EXT3_XATTR_NEXT(entry)) { -+ struct ext3_xattr_handler *handler; -+ struct ext3_xattr_entry *next = -+ EXT3_XATTR_NEXT(entry); -+ if ((char *)next >= end) -+ goto bad_block; -+ -+ handler = ext3_xattr_handler(entry->e_name_index); -+ if (handler) { -+ size += handler->list(NULL, inode, entry->e_name, -+ entry->e_name_len) + 1; -+ } -+ } -+ -+ if (ext3_xattr_cache_insert(bh)) -+ ea_idebug(inode, "cache insert failed"); -+ if (!buffer) { -+ error = size; -+ goto cleanup; -+ } else { -+ error = -ERANGE; -+ if (size > buffer_size) -+ goto cleanup; -+ } -+ -+ /* list the attribute names */ -+ buf = buffer; -+ for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry); -+ entry = EXT3_XATTR_NEXT(entry)) { -+ struct ext3_xattr_handler *handler; -+ -+ handler = ext3_xattr_handler(entry->e_name_index); -+ if (handler) { -+ buf += handler->list(buf, inode, entry->e_name, -+ entry->e_name_len); -+ *buf++ = '\0'; -+ } -+ } -+ error = size; -+ -+cleanup: -+ brelse(bh); -+ -+ return error; -+} -+ -+/* -+ * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is -+ * not set, set it. -+ */ -+static void ext3_xattr_update_super_block(handle_t *handle, -+ struct super_block *sb) -+{ -+ if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR)) -+ return; -+ -+ lock_super(sb); -+ ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) -+ EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR; -+#endif -+ EXT3_SB(sb)->s_es->s_feature_compat |= -+ cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR); -+ sb->s_dirt = 1; -+ ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); -+ unlock_super(sb); -+} -+ -+/* -+ * ext3_xattr_set() -+ * -+ * Create, replace or remove an extended attribute for this inode. Buffer -+ * is NULL to remove an existing extended attribute, and non-NULL to -+ * either replace an existing extended attribute, or create a new extended -+ * attribute. The flags XATTR_REPLACE and XATTR_CREATE -+ * specify that an extended attribute must exist and must not exist -+ * previous to the call, respectively. -+ * -+ * Returns 0, or a negative error number on failure. -+ */ -+int -+ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index, -+ const char *name, void *value, size_t value_len, int flags) -+{ -+ struct super_block *sb = inode->i_sb; -+ struct buffer_head *bh = NULL; -+ struct ext3_xattr_header *header = NULL; -+ struct ext3_xattr_entry *here, *last; -+ unsigned int name_len; -+ int min_offs = sb->s_blocksize, not_found = 1, free, error; -+ char *end; -+ -+ /* -+ * header -- Points either into bh, or to a temporarily -+ * allocated buffer. -+ * here -- The named entry found, or the place for inserting, within -+ * the block pointed to by header. -+ * last -- Points right after the last named entry within the block -+ * pointed to by header. -+ * min_offs -- The offset of the first value (values are aligned -+ * 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; -+ ext3_xattr_lock(); -+ -+ if (EXT3_I(inode)->i_file_acl) { -+ /* The inode already has an extended attribute block. */ -+ int block = EXT3_I(inode)->i_file_acl; -+ -+ bh = sb_bread(sb, block); -+ error = -EIO; -+ if (!bh) -+ goto cleanup; -+ ea_bdebug(bh, "b_count=%d, refcount=%d", -+ atomic_read(&(bh->b_count)), -+ le32_to_cpu(HDR(bh)->h_refcount)); -+ header = HDR(bh); -+ end = bh->b_data + bh->b_size; -+ if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) || -+ header->h_blocks != cpu_to_le32(1)) { -+bad_block: ext3_error(sb, "ext3_xattr_set", -+ "inode %ld: bad block %d", inode->i_ino, block); -+ error = -EIO; -+ goto cleanup; -+ } -+ /* Find the named attribute. */ -+ here = FIRST_ENTRY(bh); -+ while (!IS_LAST_ENTRY(here)) { -+ struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here); -+ if ((char *)next >= end) -+ goto bad_block; -+ if (!here->e_value_block && here->e_value_size) { -+ int offs = le16_to_cpu(here->e_value_offs); -+ if (offs < min_offs) -+ min_offs = offs; -+ } -+ not_found = name_index - here->e_name_index; -+ if (!not_found) -+ not_found = name_len - here->e_name_len; -+ if (!not_found) -+ not_found = memcmp(name, here->e_name,name_len); -+ if (not_found <= 0) -+ break; -+ here = next; -+ } -+ last = here; -+ /* We still need to compute min_offs and last. */ -+ while (!IS_LAST_ENTRY(last)) { -+ struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last); -+ if ((char *)next >= end) -+ goto bad_block; -+ if (!last->e_value_block && last->e_value_size) { -+ int offs = le16_to_cpu(last->e_value_offs); -+ if (offs < min_offs) -+ min_offs = offs; -+ } -+ last = next; -+ } -+ -+ /* Check whether we have enough space left. */ -+ free = min_offs - ((char*)last - (char*)header) - sizeof(__u32); -+ } else { -+ /* We will use a new extended attribute block. */ -+ free = sb->s_blocksize - -+ sizeof(struct ext3_xattr_header) - sizeof(__u32); -+ here = last = NULL; /* avoid gcc uninitialized warning. */ -+ } -+ -+ if (not_found) { -+ /* Request to remove a nonexistent attribute? */ -+ error = -ENOATTR; -+ if (flags & XATTR_REPLACE) -+ goto cleanup; -+ error = 0; -+ if (value == NULL) -+ goto cleanup; -+ else -+ free -= EXT3_XATTR_LEN(name_len); -+ } else { -+ /* Request to create an existing attribute? */ -+ error = -EEXIST; -+ if (flags & XATTR_CREATE) -+ goto cleanup; -+ if (!here->e_value_block && here->e_value_size) { -+ unsigned int size = le32_to_cpu(here->e_value_size); -+ -+ if (le16_to_cpu(here->e_value_offs) + size > -+ sb->s_blocksize || size > sb->s_blocksize) -+ goto bad_block; -+ free += EXT3_XATTR_SIZE(size); -+ } -+ } -+ free -= EXT3_XATTR_SIZE(value_len); -+ error = -ENOSPC; -+ if (free < 0) -+ goto cleanup; -+ -+ /* Here we know that we can set the new attribute. */ -+ -+ if (header) { -+ if (header->h_refcount == cpu_to_le32(1)) { -+ ea_bdebug(bh, "modifying in-place"); -+ ext3_xattr_cache_remove(bh); -+ error = ext3_journal_get_write_access(handle, bh); -+ if (error) -+ goto cleanup; -+ } else { -+ int offset; -+ -+ ea_bdebug(bh, "cloning"); -+ header = kmalloc(bh->b_size, GFP_KERNEL); -+ error = -ENOMEM; -+ if (header == NULL) -+ goto cleanup; -+ memcpy(header, HDR(bh), bh->b_size); -+ header->h_refcount = cpu_to_le32(1); -+ offset = (char *)header - bh->b_data; -+ here = ENTRY((char *)here + offset); -+ last = ENTRY((char *)last + offset); -+ } -+ } else { -+ /* Allocate a buffer where we construct the new block. */ -+ header = kmalloc(sb->s_blocksize, GFP_KERNEL); -+ error = -ENOMEM; -+ if (header == NULL) -+ goto cleanup; -+ memset(header, 0, sb->s_blocksize); -+ end = (char *)header + sb->s_blocksize; -+ header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC); -+ header->h_blocks = header->h_refcount = cpu_to_le32(1); -+ last = here = ENTRY(header+1); -+ } -+ -+ if (not_found) { -+ /* Insert the new name. */ -+ int size = EXT3_XATTR_LEN(name_len); -+ int rest = (char *)last - (char *)here; -+ memmove((char *)here + size, here, rest); -+ memset(here, 0, size); -+ here->e_name_index = name_index; -+ here->e_name_len = name_len; -+ memcpy(here->e_name, name, name_len); -+ } else { -+ /* Remove the old value. */ -+ if (!here->e_value_block && here->e_value_size) { -+ char *first_val = (char *)header + min_offs; -+ int offs = le16_to_cpu(here->e_value_offs); -+ char *val = (char *)header + offs; -+ size_t size = EXT3_XATTR_SIZE( -+ le32_to_cpu(here->e_value_size)); -+ memmove(first_val + size, first_val, val - first_val); -+ memset(first_val, 0, size); -+ here->e_value_offs = 0; -+ min_offs += size; -+ -+ /* Adjust all value offsets. */ -+ last = ENTRY(header+1); -+ while (!IS_LAST_ENTRY(last)) { -+ int o = le16_to_cpu(last->e_value_offs); -+ if (!last->e_value_block && o < offs) -+ last->e_value_offs = -+ cpu_to_le16(o + size); -+ last = EXT3_XATTR_NEXT(last); -+ } -+ } -+ if (value == NULL) { -+ /* Remove this attribute. */ -+ if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) { -+ /* This block is now empty. */ -+ error = ext3_xattr_set2(handle, inode, bh,NULL); -+ goto cleanup; -+ } else { -+ /* Remove the old name. */ -+ int size = EXT3_XATTR_LEN(name_len); -+ last = ENTRY((char *)last - size); -+ memmove(here, (char*)here + size, -+ (char*)last - (char*)here); -+ memset(last, 0, size); -+ } -+ } -+ } -+ -+ if (value != NULL) { -+ /* Insert the new value. */ -+ here->e_value_size = cpu_to_le32(value_len); -+ if (value_len) { -+ size_t size = EXT3_XATTR_SIZE(value_len); -+ char *val = (char *)header + min_offs - size; -+ here->e_value_offs = -+ cpu_to_le16((char *)val - (char *)header); -+ memset(val + size - EXT3_XATTR_PAD, 0, -+ EXT3_XATTR_PAD); /* Clear the pad bytes. */ -+ memcpy(val, value, value_len); -+ } -+ } -+ ext3_xattr_rehash(header, here); -+ -+ error = ext3_xattr_set2(handle, inode, bh, header); -+ -+cleanup: -+ brelse(bh); -+ if (!(bh && header == HDR(bh))) -+ kfree(header); -+ ext3_xattr_unlock(); -+ -+ return error; -+} -+ -+/* -+ * Second half of ext3_xattr_set(): Update the file system. -+ */ -+static int -+ext3_xattr_set2(handle_t *handle, struct inode *inode, -+ struct buffer_head *old_bh, struct ext3_xattr_header *header) -+{ -+ struct super_block *sb = inode->i_sb; -+ struct buffer_head *new_bh = NULL; -+ int error; -+ -+ if (header) { -+ new_bh = ext3_xattr_cache_find(inode, header); -+ if (new_bh) { -+ /* -+ * We found an identical block in the cache. -+ * The old block will be released after updating -+ * the inode. -+ */ -+ ea_bdebug(old_bh, "reusing block %ld", -+ new_bh->b_blocknr); -+ -+ error = -EDQUOT; -+ if (ext3_xattr_quota_alloc(inode, 1)) -+ goto cleanup; -+ -+ error = ext3_journal_get_write_access(handle, new_bh); -+ if (error) -+ goto cleanup; -+ HDR(new_bh)->h_refcount = cpu_to_le32( -+ le32_to_cpu(HDR(new_bh)->h_refcount) + 1); -+ ea_bdebug(new_bh, "refcount now=%d", -+ le32_to_cpu(HDR(new_bh)->h_refcount)); -+ } else if (old_bh && header == HDR(old_bh)) { -+ /* Keep this block. */ -+ new_bh = old_bh; -+ (void)ext3_xattr_cache_insert(new_bh); -+ } else { -+ /* We need to allocate a new block */ -+ int force = EXT3_I(inode)->i_file_acl != 0; -+ int block = ext3_xattr_new_block(handle, inode, -+ &error, force); -+ if (error) -+ goto cleanup; -+ ea_idebug(inode, "creating block %d", block); -+ -+ new_bh = sb_getblk(sb, block); -+ if (!new_bh) { -+getblk_failed: ext3_xattr_free_block(handle, inode, block); -+ error = -EIO; -+ goto cleanup; -+ } -+ lock_buffer(new_bh); -+ error = ext3_journal_get_create_access(handle, new_bh); -+ if (error) { -+ unlock_buffer(new_bh); -+ goto getblk_failed; -+ } -+ memcpy(new_bh->b_data, header, new_bh->b_size); -+ mark_buffer_uptodate(new_bh, 1); -+ unlock_buffer(new_bh); -+ (void)ext3_xattr_cache_insert(new_bh); -+ ext3_xattr_update_super_block(handle, sb); -+ } -+ error = ext3_journal_dirty_metadata(handle, new_bh); -+ if (error) -+ goto cleanup; -+ } -+ -+ /* Update the inode. */ -+ EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0; -+ inode->i_ctime = CURRENT_TIME; -+ ext3_mark_inode_dirty(handle, inode); -+ if (IS_SYNC(inode)) -+ handle->h_sync = 1; -+ -+ error = 0; -+ if (old_bh && old_bh != new_bh) { -+ /* -+ * If there was an old block, and we are not still using it, -+ * we now release the old block. -+ */ -+ unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount); -+ -+ error = ext3_journal_get_write_access(handle, old_bh); -+ if (error) -+ goto cleanup; -+ if (refcount == 1) { -+ /* Free the old block. */ -+ ea_bdebug(old_bh, "freeing"); -+ ext3_xattr_free_block(handle, inode, old_bh->b_blocknr); -+ -+ /* ext3_forget() calls bforget() for us, but we -+ let our caller release old_bh, so we need to -+ duplicate the handle before. */ -+ get_bh(old_bh); -+ ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr); -+ } else { -+ /* Decrement the refcount only. */ -+ refcount--; -+ HDR(old_bh)->h_refcount = cpu_to_le32(refcount); -+ ext3_xattr_quota_free(inode); -+ ext3_journal_dirty_metadata(handle, old_bh); -+ ea_bdebug(old_bh, "refcount now=%d", refcount); -+ } -+ } -+ -+cleanup: -+ if (old_bh != new_bh) -+ brelse(new_bh); -+ -+ return error; -+} -+ -+/* -+ * ext3_xattr_drop_inode() -+ * -+ * Free extended attribute resources associated with this inode. This -+ * is called immediately before an inode is freed. -+ */ -+void -+ext3_xattr_drop_inode(handle_t *handle, struct inode *inode) -+{ -+ struct buffer_head *bh; -+ unsigned int block = EXT3_I(inode)->i_file_acl; -+ -+ if (!block) -+ return; -+ ext3_xattr_lock(); -+ -+ bh = sb_bread(inode->i_sb, block); -+ if (!bh) { -+ ext3_error(inode->i_sb, "ext3_xattr_drop_inode", -+ "inode %ld: block %d read error", inode->i_ino, block); -+ goto cleanup; -+ } -+ ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count))); -+ if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) || -+ HDR(bh)->h_blocks != cpu_to_le32(1)) { -+ ext3_error(inode->i_sb, "ext3_xattr_drop_inode", -+ "inode %ld: bad block %d", inode->i_ino, block); -+ goto cleanup; -+ } -+ ext3_journal_get_write_access(handle, bh); -+ ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1); -+ if (HDR(bh)->h_refcount == cpu_to_le32(1)) { -+ ext3_xattr_cache_remove(bh); -+ ext3_xattr_free_block(handle, inode, block); -+ ext3_forget(handle, 1, inode, bh, block); -+ bh = NULL; -+ } else { -+ HDR(bh)->h_refcount = cpu_to_le32( -+ le32_to_cpu(HDR(bh)->h_refcount) - 1); -+ ext3_journal_dirty_metadata(handle, bh); -+ if (IS_SYNC(inode)) -+ handle->h_sync = 1; -+ ext3_xattr_quota_free(inode); -+ } -+ EXT3_I(inode)->i_file_acl = 0; -+ -+cleanup: -+ brelse(bh); -+ ext3_xattr_unlock(); -+} -+ -+/* -+ * ext3_xattr_put_super() -+ * -+ * This is called when a file system is unmounted. -+ */ -+void -+ext3_xattr_put_super(struct super_block *sb) -+{ -+#ifdef CONFIG_EXT3_FS_XATTR_SHARING -+ mb_cache_shrink(ext3_xattr_cache, sb->s_dev); -+#endif -+} -+ -+#ifdef CONFIG_EXT3_FS_XATTR_SHARING -+ -+/* -+ * ext3_xattr_cache_insert() -+ * -+ * Create a new entry in the extended attribute cache, and insert -+ * it unless such an entry is already in the cache. -+ * -+ * Returns 0, or a negative error number on failure. -+ */ -+static int -+ext3_xattr_cache_insert(struct buffer_head *bh) -+{ -+ __u32 hash = le32_to_cpu(HDR(bh)->h_hash); -+ struct mb_cache_entry *ce; -+ int error; -+ -+ ce = mb_cache_entry_alloc(ext3_xattr_cache); -+ if (!ce) -+ return -ENOMEM; -+ error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash); -+ if (error) { -+ mb_cache_entry_free(ce); -+ if (error == -EBUSY) { -+ ea_bdebug(bh, "already in cache (%d cache entries)", -+ atomic_read(&ext3_xattr_cache->c_entry_count)); -+ error = 0; -+ } -+ } else { -+ ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash, -+ atomic_read(&ext3_xattr_cache->c_entry_count)); -+ mb_cache_entry_release(ce); -+ } -+ return error; -+} -+ -+/* -+ * ext3_xattr_cmp() -+ * -+ * Compare two extended attribute blocks for equality. -+ * -+ * Returns 0 if the blocks are equal, 1 if they differ, and -+ * a negative error number on errors. -+ */ -+static int -+ext3_xattr_cmp(struct ext3_xattr_header *header1, -+ struct ext3_xattr_header *header2) -+{ -+ struct ext3_xattr_entry *entry1, *entry2; -+ -+ entry1 = ENTRY(header1+1); -+ entry2 = ENTRY(header2+1); -+ while (!IS_LAST_ENTRY(entry1)) { -+ if (IS_LAST_ENTRY(entry2)) -+ return 1; -+ if (entry1->e_hash != entry2->e_hash || -+ entry1->e_name_len != entry2->e_name_len || -+ entry1->e_value_size != entry2->e_value_size || -+ memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len)) -+ return 1; -+ if (entry1->e_value_block != 0 || entry2->e_value_block != 0) -+ return -EIO; -+ if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs), -+ (char *)header2 + le16_to_cpu(entry2->e_value_offs), -+ le32_to_cpu(entry1->e_value_size))) -+ return 1; -+ -+ entry1 = EXT3_XATTR_NEXT(entry1); -+ entry2 = EXT3_XATTR_NEXT(entry2); -+ } -+ if (!IS_LAST_ENTRY(entry2)) -+ return 1; -+ return 0; -+} -+ -+/* -+ * ext3_xattr_cache_find() -+ * -+ * Find an identical extended attribute block. -+ * -+ * Returns a pointer to the block found, or NULL if such a block was -+ * not found or an error occurred. -+ */ -+static struct buffer_head * -+ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header) -+{ -+ __u32 hash = le32_to_cpu(header->h_hash); -+ struct mb_cache_entry *ce; -+ -+ if (!header->h_hash) -+ return NULL; /* never share */ -+ ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); -+ ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash); -+ while (ce) { -+ struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block); -+ -+ if (!bh) { -+ ext3_error(inode->i_sb, "ext3_xattr_cache_find", -+ "inode %ld: block %ld read error", -+ inode->i_ino, ce->e_block); -+ } else if (le32_to_cpu(HDR(bh)->h_refcount) > -+ EXT3_XATTR_REFCOUNT_MAX) { -+ ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block, -+ le32_to_cpu(HDR(bh)->h_refcount), -+ EXT3_XATTR_REFCOUNT_MAX); -+ } else if (!ext3_xattr_cmp(header, HDR(bh))) { -+ ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count))); -+ mb_cache_entry_release(ce); -+ return bh; -+ } -+ brelse(bh); -+ ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash); -+ } -+ return NULL; -+} -+ -+/* -+ * ext3_xattr_cache_remove() -+ * -+ * Remove the cache entry of a block from the cache. Called when a -+ * block becomes invalid. -+ */ -+static void -+ext3_xattr_cache_remove(struct buffer_head *bh) -+{ -+ struct mb_cache_entry *ce; -+ -+ ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr); -+ if (ce) { -+ ea_bdebug(bh, "removing (%d cache entries remaining)", -+ atomic_read(&ext3_xattr_cache->c_entry_count)-1); -+ mb_cache_entry_free(ce); -+ } else -+ ea_bdebug(bh, "no cache entry"); -+} -+ -+#define NAME_HASH_SHIFT 5 -+#define VALUE_HASH_SHIFT 16 -+ -+/* -+ * ext3_xattr_hash_entry() -+ * -+ * Compute the hash of an extended attribute. -+ */ -+static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header, -+ struct ext3_xattr_entry *entry) -+{ -+ __u32 hash = 0; -+ char *name = entry->e_name; -+ int n; -+ -+ for (n=0; n < entry->e_name_len; n++) { -+ hash = (hash << NAME_HASH_SHIFT) ^ -+ (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^ -+ *name++; -+ } -+ -+ if (entry->e_value_block == 0 && entry->e_value_size != 0) { -+ __u32 *value = (__u32 *)((char *)header + -+ le16_to_cpu(entry->e_value_offs)); -+ for (n = (le32_to_cpu(entry->e_value_size) + -+ EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) { -+ hash = (hash << VALUE_HASH_SHIFT) ^ -+ (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^ -+ le32_to_cpu(*value++); -+ } -+ } -+ entry->e_hash = cpu_to_le32(hash); -+} -+ -+#undef NAME_HASH_SHIFT -+#undef VALUE_HASH_SHIFT -+ -+#define BLOCK_HASH_SHIFT 16 -+ -+/* -+ * ext3_xattr_rehash() -+ * -+ * Re-compute the extended attribute hash value after an entry has changed. -+ */ -+static void ext3_xattr_rehash(struct ext3_xattr_header *header, -+ struct ext3_xattr_entry *entry) -+{ -+ struct ext3_xattr_entry *here; -+ __u32 hash = 0; -+ -+ ext3_xattr_hash_entry(header, entry); -+ here = ENTRY(header+1); -+ while (!IS_LAST_ENTRY(here)) { -+ if (!here->e_hash) { -+ /* Block is not shared if an entry's hash value == 0 */ -+ hash = 0; -+ break; -+ } -+ hash = (hash << BLOCK_HASH_SHIFT) ^ -+ (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^ -+ le32_to_cpu(here->e_hash); -+ here = EXT3_XATTR_NEXT(here); -+ } -+ header->h_hash = cpu_to_le32(hash); -+} -+ -+#undef BLOCK_HASH_SHIFT -+ -+int __init -+init_ext3_xattr(void) -+{ -+ ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL, -+ sizeof(struct mb_cache_entry) + -+ sizeof(struct mb_cache_entry_index), 1, 61); -+ if (!ext3_xattr_cache) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+void -+exit_ext3_xattr(void) -+{ -+ if (ext3_xattr_cache) -+ mb_cache_destroy(ext3_xattr_cache); -+ ext3_xattr_cache = NULL; -+} -+ -+#else /* CONFIG_EXT3_FS_XATTR_SHARING */ -+ -+int __init -+init_ext3_xattr(void) -+{ -+ return 0; -+} -+ -+void -+exit_ext3_xattr(void) -+{ -+} -+ -+#endif /* CONFIG_EXT3_FS_XATTR_SHARING */ -diff -Nur linux-2.4.18/include/linux/ext3_fs.h linux-2.4.18ea/include/linux/ext3_fs.h ---- linux-2.4.18/include/linux/ext3_fs.h Sun Feb 24 04:42:59 2002 -+++ linux-2.4.18ea/include/linux/ext3_fs.h Mon Mar 11 03:27:00 2002 -@@ -58,8 +58,6 @@ - */ - #define EXT3_BAD_INO 1 /* Bad blocks inode */ - #define EXT3_ROOT_INO 2 /* Root inode */ --#define EXT3_ACL_IDX_INO 3 /* ACL inode */ --#define EXT3_ACL_DATA_INO 4 /* ACL inode */ - #define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */ - #define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */ - #define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */ -@@ -89,7 +87,6 @@ - #else - # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size) - #endif --#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry)) - #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32)) - #ifdef __KERNEL__ - # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) -@@ -124,28 +121,6 @@ - #endif - - /* -- * ACL structures -- */ --struct ext3_acl_header /* Header of Access Control Lists */ --{ -- __u32 aclh_size; -- __u32 aclh_file_count; -- __u32 aclh_acle_count; -- __u32 aclh_first_acle; --}; -- --struct ext3_acl_entry /* Access Control List Entry */ --{ -- __u32 acle_size; -- __u16 acle_perms; /* Access permissions */ -- __u16 acle_type; /* Type of entry */ -- __u16 acle_tag; /* User or group identity */ -- __u16 acle_pad1; -- __u32 acle_next; /* Pointer on next entry for the */ -- /* same inode or on next free entry */ --}; -- --/* - * Structure of a blocks group descriptor - */ - struct ext3_group_desc -@@ -512,7 +487,7 @@ - #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ - #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ - --#define EXT3_FEATURE_COMPAT_SUPP 0 -+#define EXT3_FEATURE_COMPAT_SUPP EXT3_FEATURE_COMPAT_EXT_ATTR - #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \ - EXT3_FEATURE_INCOMPAT_RECOVER) - #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \ -@@ -603,4 +578,22 @@ - */ - -+/* Defined for extended attributes */ -+#define CONFIG_EXT3_FS_XATTR y -+#ifndef ENOATTR -+#define ENOATTR ENODATA /* No such attribute */ -+#endif -+#ifndef ENOTSUP -+#define ENOTSUP EOPNOTSUPP /* Operation not supported */ -+#endif -+#ifndef XATTR_NAME_MAX -+#define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */ -+#define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ -+#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ -+#endif -+#ifndef XATTR_CREATE -+#define XATTR_CREATE 1 /* set value, fail if attr already exists */ -+#define XATTR_REPLACE 2 /* set value, fail if attr does not exist */ -+#endif -+ - /* - * Ok, these declarations are also in but none of the -@@ -628,6 +603,7 @@ - extern unsigned long ext3_count_free (struct buffer_head *, unsigned); - - /* inode.c */ -+extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int); - 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 *); - -diff -Nur linux-2.4.18/include/linux/ext3_jbd.h linux-2.4.18ea/include/linux/ext3_jbd.h ---- linux-2.4.18/include/linux/ext3_jbd.h Fri Dec 21 18:42:03 2001 -+++ linux-2.4.18ea/include/linux/ext3_jbd.h Mon Mar 25 00:11:36 2002 -@@ -30,13 +30,19 @@ - - #define EXT3_SINGLEDATA_TRANS_BLOCKS 8 - -+/* Extended attributes may touch two data buffers, two bitmap buffers, -+ * and two group and summaries. */ -+ -+#define EXT3_XATTR_TRANS_BLOCKS 8 -+ - /* Define the minimum size for a transaction which modifies data. This - * needs to take into account the fact that we may end up modifying two - * quota files too (one for the group, one for the user quota). The - * superblock only gets updated once, of course, so don't bother - * counting that again for the quota updates. */ - --#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2) -+#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \ -+ EXT3_XATTR_TRANS_BLOCKS - 2) - - extern int ext3_writepage_trans_blocks(struct inode *inode); - -diff -Nur linux-2.4.18/include/linux/ext3_xattr.h linux-2.4.18ea/include/linux/ext3_xattr.h ---- linux-2.4.18/include/linux/ext3_xattr.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.18ea/include/linux/ext3_xattr.h Fri Apr 5 10:08:01 2002 -@@ -0,0 +1,155 @@ -+/* -+ File: linux/ext3_xattr.h -+ -+ On-disk format of extended attributes for the ext3 filesystem. -+ -+ (C) 2001 Andreas Gruenbacher, -+*/ -+ -+#include -+#include -+#include -+ -+/* Magic value in attribute blocks */ -+#define EXT3_XATTR_MAGIC 0xEA020000 -+ -+/* Maximum number of references to one attribute block */ -+#define EXT3_XATTR_REFCOUNT_MAX 1024 -+ -+/* Name indexes */ -+#define EXT3_XATTR_INDEX_MAX 10 -+#define EXT3_XATTR_INDEX_USER 1 -+ -+struct ext3_xattr_header { -+ __u32 h_magic; /* magic number for identification */ -+ __u32 h_refcount; /* reference count */ -+ __u32 h_blocks; /* number of disk blocks used */ -+ __u32 h_hash; /* hash value of all attributes */ -+ __u32 h_reserved[4]; /* zero right now */ -+}; -+ -+struct ext3_xattr_entry { -+ __u8 e_name_len; /* length of name */ -+ __u8 e_name_index; /* attribute name index */ -+ __u16 e_value_offs; /* offset in disk block of value */ -+ __u32 e_value_block; /* disk block attribute is stored on (n/i) */ -+ __u32 e_value_size; /* size of attribute value */ -+ __u32 e_hash; /* hash value of name and value */ -+ char e_name[0]; /* attribute name */ -+}; -+ -+#define EXT3_XATTR_PAD_BITS 2 -+#define EXT3_XATTR_PAD (1<e_name_len)) ) -+#define EXT3_XATTR_SIZE(size) \ -+ (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND) -+ -+#ifdef __KERNEL__ -+ -+# ifdef CONFIG_EXT3_FS_XATTR -+ -+struct ext3_xattr_handler { -+ char *prefix; -+ size_t (*list)(char *list, struct inode *inode, const char *name, -+ int name_len); -+ int (*get)(struct inode *inode, const char *name, void *buffer, -+ size_t size); -+ int (*set)(struct inode *inode, const char *name, void *buffer, -+ size_t size, int flags); -+}; -+ -+extern int ext3_xattr_register(int, struct ext3_xattr_handler *); -+extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *); -+ -+extern int ext3_setxattr(struct dentry *, const char *, void *, size_t, int); -+extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t); -+extern ssize_t ext3_listxattr(struct dentry *, char *, size_t); -+extern int ext3_removexattr(struct dentry *, const char *); -+ -+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(handle_t *handle, struct inode *, int, const char *, void *, size_t, int); -+ -+extern void ext3_xattr_drop_inode(handle_t *, struct inode *); -+extern void ext3_xattr_put_super(struct super_block *); -+ -+extern int init_ext3_xattr(void) __init; -+extern void exit_ext3_xattr(void); -+ -+# else /* CONFIG_EXT3_FS_XATTR */ -+# define ext3_setxattr NULL -+# define ext3_getxattr NULL -+# define ext3_listxattr NULL -+# define ext3_removexattr NULL -+ -+static inline int -+ext3_xattr_get(struct inode *inode, int name_index, const char *name, -+ void *buffer, size_t size, int flags) -+{ -+ return -ENOTSUP; -+} -+ -+static inline int -+ext3_xattr_list(struct inode *inode, void *buffer, size_t size, int flags) -+{ -+ return -ENOTSUP; -+} -+ -+static inline int -+ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index, -+ const char *name, void *value, size_t size, int flags) -+{ -+ return -ENOTSUP; -+} -+ -+static inline void -+ext3_xattr_drop_inode(handle_t *handle, struct inode *inode) -+{ -+} -+ -+static inline void -+ext3_xattr_put_super(struct super_block *sb) -+{ -+} -+ -+static inline int -+init_ext3_xattr(void) -+{ -+ return 0; -+} -+ -+static inline void -+exit_ext3_xattr(void) -+{ -+} -+ -+# endif /* CONFIG_EXT3_FS_XATTR */ -+ -+# ifdef CONFIG_EXT3_FS_XATTR_USER -+ -+extern int init_ext3_xattr_user(void) __init; -+extern void exit_ext3_xattr_user(void); -+ -+# else /* CONFIG_EXT3_FS_XATTR_USER */ -+ -+static inline int -+init_ext3_xattr_user(void) -+{ -+ return 0; -+} -+ -+static inline void -+exit_ext3_xattr_user(void) -+{ -+} -+ -+#endif /* CONFIG_EXT3_FS_XATTR_USER */ -+ -+#endif /* __KERNEL__ */ -+ -diff -Nur linux-2.4.18/include/linux/xattr.h linux-2.4.18ea/include/linux/xattr.h ---- linux-2.4.18/include/linux/xattr.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.18ea/include/linux/xattr.h Sun Mar 24 23:42:21 2002 -@@ -0,0 +1,15 @@ -+/* -+ File: linux/xattr.h -+ -+ Extended attributes handling. -+ -+ Copyright (C) 2001 by Andreas Gruenbacher -+ Copyright (C) 2001 SGI - Silicon Graphics, Inc -+*/ -+#ifndef _LINUX_XATTR_H -+#define _LINUX_XATTR_H -+ -+#define XATTR_CREATE 1 /* set value, fail if attr already exists */ -+#define XATTR_REPLACE 2 /* set value, fail if attr does not exist */ -+ -+#endif /* _LINUX_XATTR_H */ diff --git a/lustre/include/.cvsignore b/lustre/include/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/include/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/include/linux/.cvsignore b/lustre/include/linux/.cvsignore deleted file mode 100644 index ce9b313..0000000 --- a/lustre/include/linux/.cvsignore +++ /dev/null @@ -1,14 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS -extN_fs.h -extN_fs_i.h -extN_fs_sb.h -extN_jbd.h -extN_xattr.h -xattr.h diff --git a/lustre/include/linux/Makefile b/lustre/include/linux/Makefile deleted file mode 100644 index c263b40..0000000 --- a/lustre/include/linux/Makefile +++ /dev/null @@ -1,7 +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 - -all .DEFAULT: - $(MAKE) -C ../.. $@ diff --git a/lustre/include/linux/inofs.h b/lustre/include/linux/inofs.h deleted file mode 100644 index 1ed3220..0000000 --- a/lustre/include/linux/inofs.h +++ /dev/null @@ -1,77 +0,0 @@ -/* object based disk file system - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C), 1999, Stelias Computing Inc - * - * - */ - - -#ifndef _INOFS_H -#define INOFS_H -#include - -#include - -/* super.c */ -void inofs_read_inode(struct inode *inode); - - -/* file.c */ -ssize_t inofs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos); - - -/* rw.c */ -struct page *inofs_getpage(struct inode *inode, unsigned long offset, int create, int locked); -int inofs_writepage(struct file *file, struct page *page); -int inofs_write_one_page(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf); - -/* namei.c */ -struct dentry *inofs_lookup(struct inode * dir, struct dentry *dentry); -int inofs_create (struct inode * dir, struct dentry * dentry, int mode); -int inofs_mkdir(struct inode *dir, struct dentry *dentry, int mode); -int inofs_rmdir(struct inode *dir, struct dentry *dentry); -int inofs_unlink(struct inode *dir, struct dentry *dentry); -int inofs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev); -int inofs_symlink(struct inode *dir, struct dentry *dentry, const char *symname); -int inofs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry); -int inofs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); - -/* dir.c */ -int inofs_readdir(struct file * filp, void * dirent, filldir_t filldir); - -struct inofs_sb_info { - struct list_head osi_list; /* list of supers */ - struct obd_conn osi_conn; - struct super_block *osi_super; - struct obd_device *osi_obd; - struct obd_ops *osi_ops; - struct list_head osi_inodes; /* list of dirty inodes */ - unsigned long osi_cache_count; - struct semaphore osi_list_mutex; -}; - -void inofs_sysctl_init(void); -void inofs_sysctl_clean(void); - -struct inofs_inode_info; - -extern struct file_operations inofs_file_ops; -extern struct inode_operations inofs_inode_ops; - -static inline struct obd_ops *iops(struct inode *i) -{ - struct inofs_sb_info *sbi = (struct inofs_sb_info *) i->i_sb->u.generic_sbp; - return sbi->osi_ops; -} - -#define NOLOCK 0 -#define LOCKED 1 - - -#define INOFS_SUPER_MAGIC 0x4711 - -#endif - diff --git a/lustre/include/linux/lustre_debug.h b/lustre/include/linux/lustre_debug.h deleted file mode 100644 index a31430d..0000000 --- a/lustre/include/linux/lustre_debug.h +++ /dev/null @@ -1,51 +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 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 _LUSTRE_DEBUG_H -#define _LUSTRE_DEBUG_H - -#include - -#define ASSERT_MAX_SIZE_MB 60000ULL -#define ASSERT_PAGE_INDEX(index, OP) \ -do { if (index > ASSERT_MAX_SIZE_MB << (20 - PAGE_SHIFT)) { \ - CERROR("bad page index %lu > %Lu\n", index, \ - ASSERT_MAX_SIZE_MB << (20 - PAGE_SHIFT)); \ - portal_debug = ~0UL; \ - OP; \ -}} while(0) - -#define ASSERT_FILE_OFFSET(offset, OP) \ -do { if (offset > ASSERT_MAX_SIZE_MB << 20) { \ - CERROR("bad file offset %Lu > %Lu\n", offset, \ - ASSERT_MAX_SIZE_MB << 20); \ - portal_debug = ~0UL; \ - OP; \ -}} while(0) - -/* lib/debug.c */ -int dump_lniobuf(struct niobuf_local *lnb); -int dump_rniobuf(struct niobuf_remote *rnb); -int dump_ioo(struct obd_ioobj *nb); -int dump_req(struct ptlrpc_request *req); -int dump_obdo(struct obdo *oa); -#endif diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h deleted file mode 100644 index 42621d9..0000000 --- a/lustre/include/linux/lustre_dlm.h +++ /dev/null @@ -1,266 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ - -#ifndef _LUSTRE_DLM_H__ -#define _LUSTRE_DLM_H__ - -#ifdef __KERNEL__ - -#include -#include - -#define OBD_LDLM_DEVICENAME "ldlm" - -typedef int cluster_host; -typedef int cluster_pid; - -typedef enum { - ELDLM_OK = 0, - - ELDLM_LOCK_CHANGED = 300, - - ELDLM_NAMESPACE_EXISTS = 400, - ELDLM_BAD_NAMESPACE = 401 -} ldlm_error_t; - -#define LDLM_FL_LOCK_CHANGED (1 << 0) -#define LDLM_FL_BLOCK_GRANTED (1 << 1) -#define LDLM_FL_BLOCK_CONV (1 << 2) -#define LDLM_FL_BLOCK_WAIT (1 << 3) -#define LDLM_FL_DYING (1 << 4) - -#define L2B(c) (1 << c) - -/* compatibility matrix */ -#define LCK_COMPAT_EX L2B(LCK_NL) -#define LCK_COMPAT_PW (LCK_COMPAT_EX | L2B(LCK_CR)) -#define LCK_COMPAT_PR (LCK_COMPAT_PW | L2B(LCK_PR)) -#define LCK_COMPAT_CW (LCK_COMPAT_PW | L2B(LCK_CW)) -#define LCK_COMPAT_CR (LCK_COMPAT_CW | L2B(LCK_PR) | L2B(LCK_PW)) -#define LCK_COMPAT_NL (LCK_COMPAT_CR | L2B(LCK_EX)) - -static ldlm_mode_t lck_compat_array[] = { - [LCK_EX] LCK_COMPAT_EX, - [LCK_PW] LCK_COMPAT_PW, - [LCK_PR] LCK_COMPAT_PR, - [LCK_CW] LCK_COMPAT_CW, - [LCK_CR] LCK_COMPAT_CR, - [LCK_NL] LCK_COMPAT_NL -}; - -static inline int lockmode_compat(ldlm_mode_t exist, ldlm_mode_t new) -{ - if (exist < LCK_EX || exist > LCK_NL) - LBUG(); - if (new < LCK_EX || new > LCK_NL) - LBUG(); - - return (lck_compat_array[exist] & L2B(new)); -} - -/* - * - * cluster name spaces - * - */ - -#define DLM_OST_NAMESPACE 1 -#define DLM_MDS_NAMESPACE 2 - -/* XXX - - do we just separate this by security domains and use a prefix for - multiple namespaces in the same domain? - - -*/ - -struct ldlm_namespace { - struct obd_device *ns_obddev; - __u32 ns_local; /* is this a local lock tree? */ - struct list_head *ns_hash; /* hash table for ns */ - __u32 ns_refcount; /* count of resources in the hash */ - struct list_head ns_root_list; /* all root resources in ns */ - spinlock_t ns_lock; /* protects hash, refcount, list */ -}; - -/* - * - * Resource hash table - * - */ - -#define RES_HASH_BITS 14 -#define RES_HASH_SIZE (1UL << RES_HASH_BITS) -#define RES_HASH_MASK (RES_HASH_SIZE - 1) - -struct ldlm_lock; - -typedef int (*ldlm_lock_callback)(struct ldlm_lock *lock, struct ldlm_lock *new, - void *data, __u32 data_len); - -struct ldlm_lock { - struct ldlm_resource *l_resource; - struct ldlm_lock *l_parent; - struct list_head l_children; - struct list_head l_childof; - struct list_head l_res_link; /*position in one of three res lists*/ - - ldlm_mode_t l_req_mode; - ldlm_mode_t l_granted_mode; - - ldlm_lock_callback l_completion_ast; - ldlm_lock_callback l_blocking_ast; - - struct ptlrpc_connection *l_connection; - struct ptlrpc_client *l_client; - __u32 l_flags; - struct ldlm_handle l_remote_handle; - void *l_data; - __u32 l_data_len; - struct ldlm_extent l_extent; - //void *l_event; - //XXX cluster_host l_holder; - __u32 l_version[RES_VERSION_SIZE]; - - __u32 l_readers; - __u32 l_writers; - - /* If the lock is granted, a process sleeps on this waitq to learn when - * it's no longer in use. If the lock is not granted, a process sleeps - * on this waitq to learn when it becomes granted. */ - wait_queue_head_t l_waitq; - spinlock_t l_lock; -}; - -typedef int (*ldlm_res_compat)(struct ldlm_lock *child, struct ldlm_lock *new); -typedef int (*ldlm_res_policy)(struct ldlm_resource *parent, - struct ldlm_extent *req_ex, - struct ldlm_extent *new_ex, - ldlm_mode_t mode, void *data); - -#define LDLM_PLAIN 0 -#define LDLM_EXTENT 1 -#define LDLM_MDSINTENT 2 - -#define LDLM_MAX_TYPE 2 - -extern ldlm_res_compat ldlm_res_compat_table []; -extern ldlm_res_policy ldlm_res_policy_table []; - -struct ldlm_resource { - struct ldlm_namespace *lr_namespace; - struct list_head lr_hash; - struct list_head lr_rootlink; /* link all root resources in NS */ - struct ldlm_resource *lr_parent; /* 0 for a root resource */ - struct list_head lr_children; /* list head for child resources */ - struct list_head lr_childof; /* part of child list of parent */ - - struct list_head lr_granted; - struct list_head lr_converting; - struct list_head lr_waiting; - ldlm_mode_t lr_most_restr; - __u32 lr_type; /* PLAIN, EXTENT, or MDSINTENT */ - struct ldlm_resource *lr_root; - //XXX cluster_host lr_master; - __u64 lr_name[RES_NAME_SIZE]; - __u32 lr_version[RES_VERSION_SIZE]; - __u32 lr_refcount; - spinlock_t lr_lock; /* protects lists, refcount */ -}; - -static inline struct ldlm_extent *ldlm_res2extent(struct ldlm_resource *res) -{ - return (struct ldlm_extent *)(res->lr_name); -} - -static inline void *ldlm_handle2object(struct ldlm_handle *handle) -{ - if (handle) - return (void *)(unsigned long)(handle->addr); - return NULL; -} - -static inline void ldlm_object2handle(void *object, struct ldlm_handle *handle) -{ - handle->addr = (__u64)(unsigned long)object; -} - -extern struct obd_ops ldlm_obd_ops; - -/* ldlm_extent.c */ -int ldlm_extent_compat(struct ldlm_lock *, struct ldlm_lock *); -int ldlm_extent_policy(struct ldlm_resource *, struct ldlm_extent *, - struct ldlm_extent *, ldlm_mode_t, void *); - -/* ldlm_lock.c */ -void ldlm_lock_free(struct ldlm_lock *lock); -void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc); -void ldlm_lock_addref(struct ldlm_lock *lock, __u32 mode); -void ldlm_lock_decref(struct ldlm_lock *lock, __u32 mode); -void ldlm_grant_lock(struct ldlm_resource *res, struct ldlm_lock *lock); -int ldlm_local_lock_match(struct ldlm_namespace *ns, __u64 *res_id, __u32 type, - struct ldlm_extent *extent, ldlm_mode_t mode, - struct ldlm_handle *lockh); -ldlm_error_t ldlm_local_lock_create(struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock_handle, - __u64 *res_id, __u32 type, - ldlm_mode_t mode, - void *data, - __u32 data_len, - struct ldlm_handle *lockh); -ldlm_error_t ldlm_local_lock_enqueue(struct ldlm_handle *lockh, - struct ldlm_extent *req_ex, - int *flags, - ldlm_lock_callback completion, - ldlm_lock_callback blocking); -struct ldlm_resource *ldlm_local_lock_convert(struct ldlm_handle *lockh, - int new_mode, int *flags); -struct ldlm_resource *ldlm_local_lock_cancel(struct ldlm_lock *lock); -void ldlm_reprocess_all(struct ldlm_resource *res); -void ldlm_lock_dump(struct ldlm_lock *lock); - -/* ldlm_test.c */ -int ldlm_test(struct obd_device *device, struct ptlrpc_connection *conn); - -/* resource.c */ -struct ldlm_namespace *ldlm_namespace_new(struct obd_device *, __u32 local); -int ldlm_namespace_free(struct ldlm_namespace *ns); -struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, - struct ldlm_resource *parent, - __u64 *name, __u32 type, int create); -int ldlm_resource_put(struct ldlm_resource *res); -void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, - struct ldlm_lock *lock); -void ldlm_resource_del_lock(struct ldlm_lock *lock); -void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc); -void ldlm_resource_dump(struct ldlm_resource *res); - -/* ldlm_request.c */ -int ldlm_cli_enqueue(struct ptlrpc_client *cl, struct ptlrpc_connection *peer, - struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock_handle, - __u64 *res_id, - __u32 type, - struct ldlm_extent *req_ex, - ldlm_mode_t mode, - int *flags, - void *data, - __u32 data_len, - struct ldlm_handle *lockh); -int ldlm_cli_callback(struct ldlm_lock *lock, struct ldlm_lock *new, - void *data, __u32 data_len); -int ldlm_cli_convert(struct ptlrpc_client *, struct ldlm_handle *, - int new_mode, int *flags); -int ldlm_cli_cancel(struct ptlrpc_client *, struct ldlm_lock *); - - -#endif /* __KERNEL__ */ - -/* ioctls for trying requests */ -#define IOC_LDLM_TYPE 'f' -#define IOC_LDLM_MIN_NR 40 - -#define IOC_LDLM_TEST _IOWR('f', 40, long) -#define IOC_LDLM_MAX_NR 41 - -#endif diff --git a/lustre/include/linux/lustre_ha.h b/lustre/include/linux/lustre_ha.h deleted file mode 100644 index 6598be0..0000000 --- a/lustre/include/linux/lustre_ha.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - */ - -#ifndef _LUSTRE_HA_H -#define _LUSTRE_HA_H - -#include - -#define LUSTRE_HA_NAME "ptlrpc" - -#define CONNMGR_CONNECT 1 - -extern struct recovd_obd *ptlrpc_connmgr; - -struct connmgr_thread { - struct recovd_obd *mgr; - char *name; -}; - -struct connmgr_body { - __u64 conn; - __u64 conn_token; - __u32 generation; - __u8 conn_uuid[37]; -}; - -int connmgr_connect(struct recovd_obd *mgr, struct ptlrpc_connection *conn); -int connmgr_handle(struct obd_device *dev, struct ptlrpc_service *svc, - struct ptlrpc_request *req); -void recovd_cli_fail(struct ptlrpc_client *cli); -void recovd_cli_manage(struct recovd_obd *mgr, struct ptlrpc_client *cli); -void recovd_cli_fixed(struct ptlrpc_client *cli); -int recovd_setup(struct recovd_obd *mgr); -int recovd_cleanup(struct recovd_obd *mgr); - -#endif diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h deleted file mode 100644 index a1e329e..0000000 --- a/lustre/include/linux/lustre_idl.h +++ /dev/null @@ -1,577 +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. - * - * (Un)packing of OST requests - */ - -#ifndef __LUSTRE_IDL_H__ -#define __LUSTRE_IDL_H__ - -#ifdef __KERNEL__ -# include -# include -# include -#else -# define __KERNEL__ -# include -# undef __KERNEL__ -# include -#endif -/* - * this file contains all data structures used in Lustre interfaces: - * - obdo and obd_request records - * - mds_request records - * - ldlm data - * - ioctl's - */ - -#define PTL_RPC_MSG_REQUEST 4711 -#define PTL_RPC_MSG_ERR 4712 - -struct lustre_msg { - __u64 conn; - __u64 token; - - __u32 opc; - __u32 xid; - __u64 last_rcvd; - __u64 last_committed; - __u64 transno; - __u32 status; - __u32 type; - __u32 connid; - __u32 bufcount; - __u32 buflens[0]; -}; - -struct niobuf_remote { - __u64 offset; - __u32 len; - __u32 xid; - __u32 flags; -}; - -struct niobuf_local { - __u64 offset; - __u32 len; - __u32 xid; - __u32 flags; - void *addr; - struct page *page; - void *target_private; - struct dentry *dentry; -}; - -#define N_LOCAL_TEMP_PAGE 0x00000001 - -/* - * OST requests: OBDO & OBD request records - */ - -/* opcodes */ -#define OST_GETATTR 1 -#define OST_SETATTR 2 -#define OST_BRW 3 -#define OST_CREATE 4 -#define OST_DESTROY 5 -#define OST_GET_INFO 6 -#define OST_CONNECT 7 -#define OST_DISCONNECT 8 -#define OST_PUNCH 9 -#define OST_OPEN 10 -#define OST_CLOSE 11 -#define OST_STATFS 12 - - -typedef uint64_t obd_id; -typedef uint64_t obd_gr; -typedef uint64_t obd_time; -typedef uint64_t obd_size; -typedef uint64_t obd_off; -typedef uint64_t obd_blocks; -typedef uint32_t obd_blksize; -typedef uint32_t obd_mode; -typedef uint32_t obd_uid; -typedef uint32_t obd_gid; -typedef uint32_t obd_rdev; -typedef uint32_t obd_flag; -typedef uint32_t obd_count; - -#define OBD_FL_INLINEDATA (0x00000001UL) -#define OBD_FL_OBDMDEXISTS (0x00000002UL) - -#define OBD_INLINESZ 60 -#define OBD_OBDMDSZ 60 -/* Note: 64-bit types are 64-bit aligned in structure */ -struct obdo { - obd_id o_id; - obd_gr o_gr; - obd_time o_atime; - obd_time o_mtime; - obd_time o_ctime; - obd_size o_size; - obd_blocks o_blocks; - obd_blksize o_blksize; - obd_mode o_mode; - obd_uid o_uid; - obd_gid o_gid; - obd_flag o_flags; - obd_flag o_obdflags; - obd_count o_nlink; - obd_count o_generation; - obd_flag o_valid; /* hot fields in this obdo */ - char o_inline[OBD_INLINESZ]; - char o_obdmd[OBD_OBDMDSZ]; - struct list_head o_list; - struct obd_ops *o_op; -}; - -#define OBD_MD_FLALL 0xffffffff -#define OBD_MD_FLID (0x00000001) -#define OBD_MD_FLATIME (0x00000002) -#define OBD_MD_FLMTIME (0x00000004) -#define OBD_MD_FLCTIME (0x00000008) -#define OBD_MD_FLSIZE (0x00000010) -#define OBD_MD_FLBLOCKS (0x00000020) -#define OBD_MD_FLBLKSZ (0x00000040) -#define OBD_MD_FLMODE (0x00000080) -#define OBD_MD_FLTYPE (0x00000100) -#define OBD_MD_FLUID (0x00000200) -#define OBD_MD_FLGID (0x00000400) -#define OBD_MD_FLFLAGS (0x00000800) -#define OBD_MD_FLOBDFLG (0x00001000) -#define OBD_MD_FLNLINK (0x00002000) -#define OBD_MD_FLGENER (0x00004000) -#define OBD_MD_FLINLINE (0x00008000) -#define OBD_MD_FLOBDMD (0x00010000) -#define OBD_MD_FLOBJID (0x00020000) -#define OBD_MD_LINKNAME (0x00040000) -#define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDMD | OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS |\ - OBD_MD_LINKNAME)) - -/* request structure for OST's */ - -#define OST_REQ_HAS_OA1 0x1 - -struct ost_body { - __u32 connid; - __u32 data; - struct obdo oa; -}; - -struct obd_ioobj { - obd_id ioo_id; - obd_gr ioo_gr; - __u32 ioo_type; - __u32 ioo_bufcnt; -}; - -/* - * MDS REQ RECORDS - */ - -/* opcodes */ -#define MDS_GETATTR 1 -#define MDS_OPEN 2 -#define MDS_CLOSE 3 -#define MDS_REINT 4 -#define MDS_READPAGE 6 -#define MDS_CONNECT 7 -#define MDS_STATFS 8 - -#define REINT_SETATTR 1 -#define REINT_CREATE 2 -#define REINT_LINK 3 -#define REINT_UNLINK 4 -#define REINT_RENAME 5 -#define REINT_RECREATE 6 -#define REINT_MAX 6 - -struct ll_fid { - __u64 id; - __u32 generation; - __u32 f_type; -}; - -struct mds_body { - struct ll_fid fid1; - struct ll_fid fid2; - __u64 objid; - __u64 size; - __u32 valid; - __u32 mode; - __u32 uid; - __u32 gid; - __u32 mtime; - __u32 ctime; - __u32 atime; - __u32 flags; - __u32 major; - __u32 minor; - __u32 ino; - __u32 nlink; - __u32 generation; - __u32 last_xid; -}; - -/* MDS update records */ -struct mds_update_record_hdr { - __u32 ur_opcode; -}; - -struct mds_rec_setattr { - __u32 sa_opcode; - struct ll_fid sa_fid; - __u32 sa_valid; - __u32 sa_mode; - __u32 sa_uid; - __u32 sa_gid; - __u64 sa_size; - __u64 sa_atime; - __u64 sa_mtime; - __u64 sa_ctime; - __u32 sa_attr_flags; -}; - -struct mds_rec_create { - __u32 cr_opcode; - struct ll_fid cr_fid; - __u32 cr_uid; - __u32 cr_gid; - __u64 cr_time; - __u32 cr_mode; - /* overloaded: id for create, tgtlen for symlink, rdev for mknod */ - __u64 cr_id; -}; - -struct mds_rec_link { - __u32 lk_opcode; - struct ll_fid lk_fid1; - struct ll_fid lk_fid2; -}; - -struct mds_rec_unlink { - __u32 ul_opcode; - struct ll_fid ul_fid1; - struct ll_fid ul_fid2; -}; - -struct mds_rec_rename { - __u32 rn_opcode; - struct ll_fid rn_fid1; - struct ll_fid rn_fid2; -}; - - -/* - * LDLM requests: - */ - -/* opcodes */ -#define LDLM_ENQUEUE 1 -#define LDLM_CONVERT 2 -#define LDLM_CANCEL 3 -#define LDLM_CALLBACK 4 - -#define RES_NAME_SIZE 3 -#define RES_VERSION_SIZE 4 - -/* lock types */ -typedef enum { - LCK_EX = 1, - LCK_PW, - LCK_PR, - LCK_CW, - LCK_CR, - LCK_NL -} ldlm_mode_t; - -struct ldlm_handle { - __u64 addr; - __u64 cookie; -}; - -struct ldlm_extent { - __u64 start; - __u64 end; -}; - -struct ldlm_resource_desc { - __u32 lr_type; - __u64 lr_name[RES_NAME_SIZE]; - __u64 lr_version[RES_VERSION_SIZE]; -}; - -struct ldlm_lock_desc { - struct ldlm_resource_desc l_resource; - ldlm_mode_t l_req_mode; - ldlm_mode_t l_granted_mode; - struct ldlm_extent l_extent; - __u32 l_version[RES_VERSION_SIZE]; -}; - -struct ldlm_request { - __u32 flags; - struct ldlm_lock_desc lock_desc; - struct ldlm_handle lock_handle1; - struct ldlm_handle lock_handle2; -}; - -struct ldlm_reply { - __u32 flags; - struct ldlm_handle lock_handle; - struct ldlm_extent lock_extent; -}; - -/* - * OBD IOCTLS - */ - - -#define OBD_IOCTL_VERSION 0x00010001 - -struct obd_ioctl_data { - uint32_t ioc_len; - uint32_t ioc_version; - uint32_t ioc_conn1; - uint32_t ioc_conn2; - struct obdo ioc_obdo1; - struct obdo ioc_obdo2; - obd_size ioc_count; - obd_off ioc_offset; - uint32_t ioc_dev; - - /* buffers the kernel will treat as user pointers */ - uint32_t ioc_plen1; - char *ioc_pbuf1; - uint32_t ioc_plen2; - char *ioc_pbuf2; - - /* two inline buffers */ - uint32_t ioc_inllen1; - char *ioc_inlbuf1; - uint32_t ioc_inllen2; - char *ioc_inlbuf2; - - char ioc_bulk[0]; -}; - -struct obd_ioctl_hdr { - uint32_t ioc_len; - uint32_t ioc_version; -}; - -static inline int obd_ioctl_packlen(struct obd_ioctl_data *data) -{ - int len = sizeof(struct obd_ioctl_data); - len += size_round(data->ioc_inllen1); - len += size_round(data->ioc_inllen2); - return len; -} - -static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data) -{ - if (data->ioc_len > (1<<30)) { - printk("OBD ioctl: ioc_len larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen1 > (1<<30)) { - printk("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen2 > (1<<30)) { - printk("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inlbuf1 && !data->ioc_inllen1) { - printk("OBD ioctl: inlbuf1 pointer but 0 length\n"); - return 1; - } - if (data->ioc_inlbuf2 && !data->ioc_inllen2) { - printk("OBD ioctl: inlbuf2 pointer but 0 length\n"); - return 1; - } - if (data->ioc_pbuf1 && !data->ioc_plen1) { - printk("OBD ioctl: pbuf1 pointer but 0 length\n"); - return 1; - } - if (data->ioc_pbuf2 && !data->ioc_plen2) { - printk("OBD ioctl: pbuf2 pointer but 0 length\n"); - return 1; - } - /* - if (data->ioc_inllen1 && !data->ioc_inlbuf1) { - printk("OBD ioctl: inllen1 set but NULL pointer\n"); - return 1; - } - if (data->ioc_inllen2 && !data->ioc_inlbuf2) { - printk("OBD ioctl: inllen2 set but NULL pointer\n"); - return 1; - } - if (data->ioc_plen1 && !data->ioc_pbuf1) { - printk("OBD ioctl: plen1 set but NULL pointer\n"); - return 1; - } - if (data->ioc_plen2 && !data->ioc_pbuf2) { - printk("OBD ioctl: plen2 set but NULL pointer\n"); - return 1; - } - */ - if (obd_ioctl_packlen(data) != data->ioc_len ) { - printk("OBD ioctl: packlen exceeds ioc_len\n"); - return 1; - } - if (data->ioc_inllen1 && - data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') { - printk("OBD 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') { - printk("OBD ioctl: inlbuf2 not 0 terminated\n"); - return 1; - } - return 0; -} - -#ifndef __KERNEL__ -static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, - int max) -{ - char *ptr; - struct obd_ioctl_data *overlay; - data->ioc_len = obd_ioctl_packlen(data); - data->ioc_version = OBD_IOCTL_VERSION; - - if (*pbuf && obd_ioctl_packlen(data) > max) - return 1; - if (*pbuf == NULL) { - *pbuf = malloc(data->ioc_len); - } - if (!*pbuf) - return 1; - overlay = (struct obd_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 (obd_ioctl_is_invalid(overlay)) - return 1; - - return 0; -} -#else - - -/* buffer MUST be at least the size of obd_ioctl_hdr */ -static inline int obd_ioctl_getdata(char *buf, char *end, void *arg) -{ - struct obd_ioctl_hdr *hdr; - struct obd_ioctl_data *data; - int err; - ENTRY; - - hdr = (struct obd_ioctl_hdr *)buf; - data = (struct obd_ioctl_data *)buf; - - err = copy_from_user(buf, (void *)arg, sizeof(*hdr)); - if ( err ) { - EXIT; - return err; - } - - if (hdr->ioc_version != OBD_IOCTL_VERSION) { - printk("OBD: version mismatch kernel vs application\n"); - return -EINVAL; - } - - if (hdr->ioc_len + buf >= end) { - printk("OBD: user buffer exceeds kernel buffer\n"); - return -EINVAL; - } - - - if (hdr->ioc_len < sizeof(struct obd_ioctl_data)) { - printk("OBD: user buffer too small for ioctl\n"); - return -EINVAL; - } - - err = copy_from_user(buf, (void *)arg, hdr->ioc_len); - if ( err ) { - EXIT; - return err; - } - - if (obd_ioctl_is_invalid(data)) { - printk("OBD: 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); - } - - EXIT; - return 0; -} -#endif - - -#define OBD_IOC_CREATE _IOR ('f', 101, long) -#define OBD_IOC_SETUP _IOW ('f', 102, long) -#define OBD_IOC_CLEANUP _IO ('f', 103 ) -#define OBD_IOC_DESTROY _IOW ('f', 104, long) -#define OBD_IOC_PREALLOCATE _IOWR('f', 105, long) -#define OBD_IOC_DEC_USE_COUNT _IO ('f', 106 ) -#define OBD_IOC_SETATTR _IOW ('f', 107, long) -#define OBD_IOC_GETATTR _IOR ('f', 108, long) -#define OBD_IOC_READ _IOWR('f', 109, long) -#define OBD_IOC_WRITE _IOWR('f', 110, long) -#define OBD_IOC_CONNECT _IOR ('f', 111, long) -#define OBD_IOC_DISCONNECT _IOW ('f', 112, long) -#define OBD_IOC_STATFS _IOWR('f', 113, long) -#define OBD_IOC_SYNC _IOR ('f', 114, long) -#define OBD_IOC_READ2 _IOWR('f', 115, long) -#define OBD_IOC_FORMAT _IOWR('f', 116, long) -#define OBD_IOC_PARTITION _IOWR('f', 117, long) -#define OBD_IOC_ATTACH _IOWR('f', 118, long) -#define OBD_IOC_DETACH _IOWR('f', 119, long) -#define OBD_IOC_COPY _IOWR('f', 120, long) -#define OBD_IOC_MIGR _IOWR('f', 121, long) -#define OBD_IOC_PUNCH _IOWR('f', 122, long) -#define OBD_IOC_DEVICE _IOWR('f', 123, long) -#define OBD_IOC_MODULE_DEBUG _IOWR('f', 124, long) -#define OBD_IOC_BRW_READ _IOWR('f', 125, long) -#define OBD_IOC_BRW_WRITE _IOWR('f', 126, long) -#define OBD_IOC_NAME2DEV _IOWR('f', 127, long) -#define OBD_IOC_NEWDEV _IOWR('f', 128, long) - -#define OBD_IOC_RECOVD_NEWCONN _IOWR('f', 131, long) - -#define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 132 ) - -#endif diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h deleted file mode 100644 index e7ae204..0000000 --- a/lustre/include/linux/lustre_lib.h +++ /dev/null @@ -1,70 +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 Lustre library routines. - * - */ - -#ifndef _LUSTRE_LIB_H -#define _LUSTRE_LIB_H - -#include - -#ifndef __KERNEL__ -# include -#endif - -#ifdef __KERNEL__ -/* page.c */ -inline void lustre_put_page(struct page *page); -struct page *lustre_get_page_read(struct inode *dir, unsigned long index); -struct page *lustre_get_page_write(struct inode *dir, unsigned long index); -int lustre_commit_page(struct page *page, unsigned from, unsigned to); -void set_page_clean(struct page *page); -void set_page_dirty(struct page *page); - -/* simple.c */ -struct obd_run_ctxt; -void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new); -void pop_ctxt(struct obd_run_ctxt *saved); -struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode); -int lustre_fread(struct file *file, char *str, int len, loff_t *off); -int lustre_fwrite(struct file *file, const char *str, int len, loff_t *off); -int lustre_fsync(struct file *file); - -static inline void l_dput(struct dentry *de) -{ - if (!de || IS_ERR(de)) - return; - shrink_dcache_parent(de); - dput(de); -} - -static inline void ll_sleep(int t) -{ - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(t * HZ); - set_current_state(TASK_RUNNING); -} -#endif - -#include - -#endif /* _LUSTRE_LIB_H */ diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h deleted file mode 100644 index 3a9188f..0000000 --- a/lustre/include/linux/lustre_lite.h +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lustre lite cluster file system - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * - * - - - -#ifndef _LL_H -#define _LL_H - -#include -#include - -#include -#include -#include -#include - -extern kmem_cache_t *ll_file_data_slab; -struct ll_file_data { - __u64 fd_mdshandle; - struct ptlrpc_request *fd_req; - __u32 fd_flags; -}; - -#define LL_IOC_GETFLAGS _IOR ('f', 151, long) -#define LL_IOC_SETFLAGS _IOW ('f', 152, long) -#define LL_IOC_CLRFLAGS _IOW ('f', 153, long) - -#define LL_FILE_IGNORE_LOCK 0x00000001 - -#define LL_INLINESZ 60 -struct ll_inode_info { - int lli_flags; - __u64 lli_objid; - char lli_inline[LL_INLINESZ]; -}; - -#define LL_SUPER_MAGIC 0x0BD00BD0 - -#define LL_COMMITCBD_STOPPING 0x1 -#define LL_COMMITCBD_STOPPED 0x2 -#define LL_COMMITCBD_RUNNING 0x4 - -struct ll_sb_info { - struct obd_conn ll_conn; - ino_t ll_rootino; /* number of root inode */ - struct ptlrpc_client ll_mds_client; - struct ptlrpc_connection *ll_mds_conn; - struct ldlm_namespace *ll_namespace; - - wait_queue_head_t ll_commitcbd_waitq; - wait_queue_head_t ll_commitcbd_ctl_waitq; - int ll_commitcbd_flags; - struct task_struct *ll_commitcbd_thread; - time_t ll_commitcbd_waketime; - time_t ll_commitcbd_timeout; - spinlock_t ll_commitcbd_lock; -}; - - -static inline struct ll_sb_info *ll_s2sbi(struct super_block *sb) -{ - return (struct ll_sb_info *)(sb->u.generic_sbp); -} - -static inline struct obd_conn *ll_s2obdconn(struct super_block *sb) -{ - return &(ll_s2sbi(sb))->ll_conn; -} - -static inline struct ll_sb_info *ll_i2sbi(struct inode *inode) -{ - return ll_s2sbi(inode->i_sb); -} - -static inline struct ll_inode_info *ll_i2info(struct inode *inode) -{ - return (struct ll_inode_info *)&(inode->u.generic_ip); -} - -static inline int ll_has_inline(struct inode *inode) -{ - return (ll_i2info(inode)->lli_flags & OBD_FL_INLINEDATA); -} - - -static inline struct obd_conn *ll_i2obdconn(struct inode *inode) -{ - return ll_s2obdconn(inode->i_sb); -} - -static inline void ll_ino2fid(struct ll_fid *fid, ino_t ino, __u32 generation, - int type) -{ - fid->id = (__u64)ino; - fid->generation = generation; - fid->f_type = type; -} - -static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode) -{ - ll_ino2fid(fid, inode->i_ino, inode->i_generation, - inode->i_mode & S_IFMT); -} - -/* dir.c */ -extern struct file_operations ll_dir_operations; -extern struct inode_operations ll_dir_inode_operations; - -/* file.c */ -extern struct file_operations ll_file_operations; -extern struct inode_operations ll_file_inode_operations; - -/* rw.c */ -struct page *ll_getpage(struct inode *inode, unsigned long offset, - int create, int locked); -void ll_truncate(struct inode *inode); - -/* symlink.c */ -extern struct inode_operations ll_fast_symlink_inode_operations; -extern struct inode_operations ll_symlink_inode_operations; - -/* sysctl.c */ -void ll_sysctl_init(void); -void ll_sysctl_clean(void); - -#endif diff --git a/lustre/include/linux/lustre_mds.h b/lustre/include/linux/lustre_mds.h deleted file mode 100644 index ffd84d1..0000000 --- a/lustre/include/linux/lustre_mds.h +++ /dev/null @@ -1,256 +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. - * - * MDS data structures. - * See also lustre_idl.h for wire formats of requests. - * - */ - -#ifndef _LUSTRE_MDS_H -#define _LUSTRE_MDS_H - -#ifdef __KERNEL__ - -#include -#include -#include - -#define LUSTRE_MDS_NAME "mds" - -struct mds_update_record { - __u32 ur_opcode; - struct ll_fid *ur_fid1; - struct ll_fid *ur_fid2; - int ur_namelen; - char *ur_name; - int ur_tgtlen; - char *ur_tgt; - struct iattr ur_iattr; - __u64 ur_id; - __u32 ur_mode; - __u32 ur_uid; - __u32 ur_gid; - __u64 ur_time; -}; - -#define MDS_LR_CLIENT 8192 -#define MDS_LR_SIZE 128 - -#define MDS_CLIENT_SLOTS 17 - -#define MDS_MOUNT_RECOV 2 - -/* Data stored per server at the head of the last_rcvd file. In le32 order. */ -struct mds_server_data { - __u8 msd_uuid[37]; /* server UUID */ - __u8 uuid_padding[3]; /* unused */ - __u64 msd_last_rcvd; /* last completed transaction ID */ - __u64 msd_mount_count; /* MDS incarnation number */ - __u8 padding[512 - 56]; -}; - -/* Data stored per client in the last_rcvd file. In le32 order. */ -struct mds_client_data { - __u8 mcd_uuid[37]; /* client UUID */ - __u8 uuid_padding[3]; /* unused */ - __u64 mcd_last_rcvd; /* last completed transaction ID */ - __u64 mcd_mount_count; /* MDS incarnation number */ - __u32 mcd_last_xid; /* client RPC xid for the last transaction */ - __u8 padding[MDS_LR_SIZE - 60]; -}; - -/* In-memory access to client data from MDS struct */ -struct mds_client_info { - struct list_head mci_list; - struct list_head mci_open_head; - struct mds_client_data *mci_mcd; - int mci_off; -}; - -/* file data for open files on MDS */ -struct mds_file_data { - struct list_head mfd_list; - struct file * mfd_file; - __u64 mfd_clientfd; - __u32 mfd_clientcookie; -}; - -/* mds/mds_reint.c */ -int mds_reint_rec(struct mds_update_record *r, struct ptlrpc_request *req); -struct mds_client_info *mds_uuid_to_mci(struct mds_obd *mds, __u8 *uuid); - -/* lib/mds_updates.c */ -void mds_pack_req_body(struct ptlrpc_request *); -void mds_pack_rep_body(struct ptlrpc_request *); -void mds_unpack_req_body(struct ptlrpc_request *); -void mds_unpack_rep_body(struct ptlrpc_request *); -int mds_update_unpack(struct ptlrpc_request *, struct mds_update_record *); - -void mds_setattr_pack(struct mds_rec_setattr *, struct inode *, struct iattr *); -void mds_create_pack(struct mds_rec_create *, struct inode *, __u32 mode, - __u64 id, __u32 uid, __u32 gid, __u64 time); -void mds_unlink_pack(struct mds_rec_unlink *, struct inode *inode, - struct inode *child); -void mds_link_pack(struct mds_rec_link *, struct inode *ino, struct inode *dir); -void mds_rename_pack(struct mds_rec_rename *, struct inode *srcdir, - struct inode *tgtdir); - -/* mds/handler.c */ -struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vfsmount **mnt); - -/* mdc/mdc_request.c */ -int mdc_connect(struct ptlrpc_client *, struct ptlrpc_connection *, - struct ll_fid *rootfid, __u64 *last_committed, __u64 *last_rcvd, - __u32 *last_xid, struct ptlrpc_request **); -int mdc_getattr(struct ptlrpc_client *, struct ptlrpc_connection *, ino_t ino, - int type, unsigned long valid, size_t ea_size, - struct ptlrpc_request **); -int mdc_setattr(struct ptlrpc_client *, struct ptlrpc_connection *, - struct inode *, struct iattr *iattr, struct ptlrpc_request **); -int mdc_open(struct ptlrpc_client *, struct ptlrpc_connection *, ino_t ino, - int type, int flags, __u64 cookie, __u64 *fh, struct ptlrpc_request **req); -int mdc_close(struct ptlrpc_client *cl, struct ptlrpc_connection *peer, - ino_t ino, int type, __u64 fh, struct ptlrpc_request **req); -int mdc_readpage(struct ptlrpc_client *, struct ptlrpc_connection *, ino_t ino, - int type, __u64 offset, char *addr, struct ptlrpc_request **); -int mdc_create(struct ptlrpc_client *, struct ptlrpc_connection *, - struct inode *dir, const char *name, int namelen, - const char *tgt, int tgtlen, - int mode, __u64 id, __u32 uid, __u32 gid, __u64 time, - struct ptlrpc_request **); -int mdc_unlink(struct ptlrpc_client *, struct ptlrpc_connection *, - struct inode *dir, struct inode *child, const char *name, - int namelen, struct ptlrpc_request **); -int mdc_link(struct ptlrpc_client *, struct ptlrpc_connection *, - struct dentry *src, struct inode *dir, const char *name, - int namelen, struct ptlrpc_request **); -int mdc_rename(struct ptlrpc_client *, struct ptlrpc_connection *, - struct inode *src, struct inode *tgt, const char *old, - int oldlen, const char *new, int newlen, - struct ptlrpc_request **); -int mdc_create_client(char *uuid, struct ptlrpc_client *cl); - -extern int mds_client_add(struct mds_obd *mds, struct mds_client_data *mcd, - int cl_off); - -/* mds/mds_fs.c */ -struct mds_fs_operations { - void *(* fs_start)(struct inode *inode, int op); - int (* fs_commit)(struct inode *inode, void *handle); - int (* fs_setattr)(struct dentry *dentry, void *handle, - struct iattr *iattr); - int (* fs_set_objid)(struct inode *inode, void *handle, obd_id id); - int (* fs_get_objid)(struct inode *inode, obd_id *id); - ssize_t (* fs_readpage)(struct file *file, char *buf, size_t count, - loff_t *offset); - void (* fs_delete_inode)(struct inode *inode); - void (* cl_delete_inode)(struct inode *inode); - int (* fs_journal_data)(struct file *file); - int (* fs_set_last_rcvd)(struct mds_obd *mds, void *handle); -}; - -extern int mds_register_fs_type(struct mds_fs_operations *op, const char *name); -extern void mds_unregister_fs_type(const char *name); -extern int mds_fs_setup(struct mds_obd *mds, struct vfsmount *mnt); -extern void mds_fs_cleanup(struct mds_obd *mds); - -static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode, - int op) -{ - return mds->mds_fsops->fs_start(inode, op); -} - -static inline int mds_fs_commit(struct mds_obd *mds, struct inode *inode, - void *handle) -{ - return mds->mds_fsops->fs_commit(inode, handle); -} - -static inline int mds_fs_setattr(struct mds_obd *mds, struct dentry *dentry, - void *handle, struct iattr *iattr) -{ - /* - * NOTE: we probably don't need to take i_sem here when changing - * ATTR_SIZE because the MDS never needs to truncate a file. - * The ext2/ext3 code never truncates a directory, and files - * stored on the MDS are entirely sparse (no data blocks). - * If we do need to get it, we can do it here. - */ - return mds->mds_fsops->fs_setattr(dentry, handle, iattr); -} - -static inline int mds_fs_set_objid(struct mds_obd *mds, struct inode *inode, - void *handle, __u64 id) -{ - return mds->mds_fsops->fs_set_objid(inode, handle, id); -} - -static inline int mds_fs_get_objid(struct mds_obd *mds, struct inode *inode, - __u64 *id) -{ - return mds->mds_fsops->fs_get_objid(inode, id); -} - -static inline ssize_t mds_fs_readpage(struct mds_obd *mds, struct file *file, - char *buf, size_t count, loff_t *offset) -{ - return mds->mds_fsops->fs_readpage(file, buf, count, offset); -} - -/* Set up callback to update mds->mds_last_committed with the current - * value of mds->mds_last_recieved when this transaction is on disk. - */ -static inline int mds_fs_set_last_rcvd(struct mds_obd *mds, void *handle) -{ - return mds->mds_fsops->fs_set_last_rcvd(mds, handle); -} - -/* Enable data journaling on the given file */ -static inline ssize_t mds_fs_journal_data(struct mds_obd *mds, - struct file *file) -{ - return mds->mds_fsops->fs_journal_data(file); -} - -#define MDS_FSOP_UNLINK 1 -#define MDS_FSOP_RMDIR 2 -#define MDS_FSOP_RENAME 3 -#define MDS_FSOP_CREATE 4 -#define MDS_FSOP_MKDIR 5 -#define MDS_FSOP_SYMLINK 6 -#define MDS_FSOP_MKNOD 7 -#define MDS_FSOP_SETATTR 8 -#define MDS_FSOP_LINK 9 - -#endif /* __KERNEL__ */ - -/* ioctls for trying requests */ -#define IOC_REQUEST_TYPE 'f' -#define IOC_REQUEST_MIN_NR 30 - -#define IOC_REQUEST_GETATTR _IOWR('f', 30, long) -#define IOC_REQUEST_READPAGE _IOWR('f', 31, long) -#define IOC_REQUEST_SETATTR _IOWR('f', 32, long) -#define IOC_REQUEST_CREATE _IOWR('f', 33, long) -#define IOC_REQUEST_OPEN _IOWR('f', 34, long) -#define IOC_REQUEST_CLOSE _IOWR('f', 35, long) -#define IOC_REQUEST_MAX_NR 35 - -#endif diff --git a/lustre/include/linux/lustre_net.h b/lustre/include/linux/lustre_net.h deleted file mode 100644 index ae665db..0000000 --- a/lustre/include/linux/lustre_net.h +++ /dev/null @@ -1,317 +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 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 _LUSTRE_NET_H -#define _LUSTRE_NET_H - -#include -#include -#include -#include -#include - -/* FOO_REQUEST_PORTAL is for incoming requests on the FOO - * FOO_REPLY_PORTAL is for incoming replies on the FOO - * FOO_BULK_PORTAL is for incoming bulk on the FOO - */ - -#define CONNMGR_REQUEST_PORTAL 1 -#define CONNMGR_REPLY_PORTAL 2 -#define OSC_REQUEST_PORTAL 3 -#define OSC_REPLY_PORTAL 4 -#define OSC_BULK_PORTAL 5 -#define OST_REQUEST_PORTAL 6 -#define OST_REPLY_PORTAL 7 -#define OST_BULK_PORTAL 8 -#define MDC_REQUEST_PORTAL 9 -#define MDC_REPLY_PORTAL 10 -#define MDC_BULK_PORTAL 11 -#define MDS_REQUEST_PORTAL 12 -#define MDS_REPLY_PORTAL 13 -#define MDS_BULK_PORTAL 14 -#define LDLM_REQUEST_PORTAL 15 -#define LDLM_REPLY_PORTAL 16 -#define LDLM_CLI_REQUEST_PORTAL 17 -#define LDLM_CLI_REPLY_PORTAL 18 - -/* default rpc ring length */ -#define RPC_RING_LENGTH 2 - -#define SVC_KILLED 1 -#define SVC_EVENT 2 -#define SVC_SIGNAL 4 -#define SVC_RUNNING 8 -#define SVC_STOPPING 16 -#define SVC_STOPPED 32 - -#define RECOVD_STOPPING 1 /* how cleanup tells recovd to quit */ -#define RECOVD_IDLE 2 /* normal state */ -#define RECOVD_STOPPED 4 /* after recovd has stopped */ -#define RECOVD_FAIL 8 /* RPC timeout: wakeup recovd, sets flag */ -#define RECOVD_TIMEOUT 16 /* set when recovd detects a timeout */ -#define RECOVD_UPCALL_WAIT 32 /* an upcall has been placed */ -#define RECOVD_UPCALL_ANSWER 64 /* an upcall has been answered */ - -#define LUSTRE_CONN_NEW 1 -#define LUSTRE_CONN_CON 2 -#define LUSTRE_CONN_RECOVD 3 -#define LUSTRE_CONN_FULL 4 - -struct ptlrpc_connection { - struct list_head c_link; - struct lustre_peer c_peer; - __u8 c_local_uuid[37]; /* XXX do we need this? */ - __u8 c_remote_uuid[37]; - - int c_level; - __u32 c_generation; /* changes upon new connection */ - __u32 c_epoch; /* changes when peer changes */ - __u32 c_bootcount; /* peer's boot count */ - - spinlock_t c_lock; - __u32 c_xid_in; - __u32 c_xid_out; - - atomic_t c_refcount; - __u64 c_token; - __u64 c_remote_conn; - __u64 c_remote_token; -}; - -struct ptlrpc_client { - struct obd_device *cli_obd; - __u32 cli_request_portal; - __u32 cli_reply_portal; - __u64 cli_last_rcvd; - __u64 cli_last_committed; - - void *cli_data; - struct semaphore cli_rpc_sem; /* limits outstanding requests */ - - spinlock_t cli_lock; /* protects lists */ - struct list_head cli_delayed_head; /* delayed until after recovery */ - struct list_head cli_sending_head; - struct list_head cli_dying_head; - struct list_head cli_ha_item; - int (*cli_recover)(struct ptlrpc_client *); - - struct recovd_obd *cli_recovd; - char *cli_name; -}; - -/* packet types */ -#define PTL_RPC_TYPE_REQUEST 2 -#define PTL_RPC_TYPE_REPLY 3 - -/* state flags of requests */ -#define PTL_RPC_FL_INTR (1 << 0) -#define PTL_RPC_FL_REPLIED (1 << 1) /* reply was received */ -#define PTL_RPC_FL_SENT (1 << 2) -#define PTL_BULK_FL_SENT (1 << 3) -#define PTL_BULK_FL_RCVD (1 << 4) -#define PTL_RPC_FL_ERR (1 << 5) -#define PTL_RPC_FL_TIMEOUT (1 << 6) -#define PTL_RPC_FL_RESEND (1 << 7) -#define PTL_RPC_FL_RECOVERY (1 << 8) /* retransmission for recovery */ -#define PTL_RPC_FL_FINISHED (1 << 9) -#define PTL_RPC_FL_RETAIN (1 << 10) /* retain for replay after reply */ -#define PTL_RPC_FL_REPLAY (1 << 11) /* replay upon recovery */ -#define PTL_RPC_FL_ALLOCREP (1 << 12) /* reply buffer allocated */ - -struct ptlrpc_request { - int rq_type; /* one of PTL_RPC_REQUEST, PTL_RPC_REPLY, PTL_RPC_BULK */ - struct list_head rq_list; - struct obd_device *rq_obd; - int rq_status; - int rq_flags; - __u32 rq_connid; - atomic_t rq_refcount; - - int rq_reqlen; - struct lustre_msg *rq_reqmsg; - - int rq_replen; - struct lustre_msg *rq_repmsg; - __u64 rq_transno; - __u64 rq_xid; - - char *rq_bulkbuf; - int rq_bulklen; - - int rq_level; - time_t rq_time; - time_t rq_timeout; - // void * rq_reply_handle; - wait_queue_head_t rq_wait_for_rep; - - /* incoming reply */ - ptl_md_t rq_reply_md; - ptl_handle_md_t rq_reply_md_h; - ptl_handle_me_t rq_reply_me_h; - - /* outgoing req/rep */ - ptl_md_t rq_req_md; - ptl_handle_md_t rq_req_md_h; - - struct ptlrpc_connection *rq_connection; - struct ptlrpc_client *rq_client; -}; - -struct ptlrpc_bulk_page { - struct ptlrpc_bulk_desc *b_desc; - struct list_head b_link; - char *b_buf; - int b_buflen; - struct page *b_page; - __u32 b_xid; - __u32 b_flags; - struct dentry *b_dentry; - int (*b_cb)(struct ptlrpc_bulk_page *); - - ptl_md_t b_md; - ptl_handle_md_t b_md_h; - ptl_handle_me_t b_me_h; -}; - -struct ptlrpc_bulk_desc { - int b_flags; - struct ptlrpc_connection *b_connection; - struct ptlrpc_client *b_client; - __u32 b_portal; - int (*b_cb)(struct ptlrpc_bulk_desc *); - struct obd_conn b_conn; - - wait_queue_head_t b_waitq; - struct list_head b_page_list; - __u32 b_page_count; - __u32 b_finished_count; - void *b_desc_private; -}; - -struct ptlrpc_thread { - struct list_head t_link; - - __u32 t_flags; - wait_queue_head_t t_ctl_waitq; -}; - -struct ptlrpc_service { - time_t srv_time; - time_t srv_timeout; - - /* incoming request buffers */ - /* FIXME: perhaps a list of EQs, if multiple NIs are used? */ - char *srv_buf[RPC_RING_LENGTH]; - __u32 srv_ref_count[RPC_RING_LENGTH]; - ptl_handle_me_t srv_me_h[RPC_RING_LENGTH]; - __u32 srv_buf_size; - __u32 srv_ring_length; - __u32 srv_req_portal; - __u32 srv_rep_portal; - - __u32 srv_xid; - - /* event queue */ - ptl_handle_eq_t srv_eq_h; - - struct lustre_peer srv_self; - - wait_queue_head_t srv_waitq; /* all threads sleep on this */ - - spinlock_t srv_lock; - struct list_head srv_reqs; - struct list_head srv_threads; - int (*srv_handler)(struct obd_device *obddev, - struct ptlrpc_service *svc, - struct ptlrpc_request *req); -}; - -typedef int (*svc_handler_t)(struct obd_device *obddev, - struct ptlrpc_service *svc, - struct ptlrpc_request *req); - -/* rpc/connection.c */ -void ptlrpc_readdress_connection(struct ptlrpc_connection *conn, char *uuid); -struct ptlrpc_connection *ptlrpc_get_connection(struct lustre_peer *peer); -int ptlrpc_put_connection(struct ptlrpc_connection *c); -struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *); -void ptlrpc_init_connection(void); -void ptlrpc_cleanup_connection(void); - -/* rpc/niobuf.c */ -int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *); -int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *); -int ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *bulk); -int ptlrpc_reply(struct ptlrpc_service *svc, struct ptlrpc_request *req); -int ptlrpc_error(struct ptlrpc_service *svc, struct ptlrpc_request *req); -void ptlrpc_resend_req(struct ptlrpc_request *request); -int ptl_send_rpc(struct ptlrpc_request *request); -void ptlrpc_link_svc_me(struct ptlrpc_service *service, int i); - -/* rpc/client.c */ -void ptlrpc_init_client(struct recovd_obd *, - int (*recover)(struct ptlrpc_client *), - int req_portal, int rep_portal, - struct ptlrpc_client *); -void ptlrpc_cleanup_client(struct ptlrpc_client *cli); -__u8 *ptlrpc_req_to_uuid(struct ptlrpc_request *req); -struct ptlrpc_connection *ptlrpc_uuid_to_connection(char *uuid); - -int ptlrpc_queue_wait(struct ptlrpc_request *req); -void ptlrpc_continue_req(struct ptlrpc_request *req); -int ptlrpc_replay_req(struct ptlrpc_request *req); -void ptlrpc_restart_req(struct ptlrpc_request *req); - -struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, - struct ptlrpc_connection *u, int opcode, - int count, int *lengths, char **bufs); -void ptlrpc_free_req(struct ptlrpc_request *request); -void ptlrpc_req_finished(struct ptlrpc_request *request); -struct ptlrpc_bulk_desc *ptlrpc_prep_bulk(struct ptlrpc_connection *); -void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk); -struct ptlrpc_bulk_page *ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc); -void ptlrpc_free_bulk_page(struct ptlrpc_bulk_page *page); -int ptlrpc_check_status(struct ptlrpc_request *req, int err); - -/* rpc/service.c */ -struct ptlrpc_service * -ptlrpc_init_svc(__u32 bufsize, int req_portal, int rep_portal, char *uuid, - svc_handler_t); -void ptlrpc_stop_all_threads(struct ptlrpc_service *svc); -int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc, - char *name); -int rpc_unregister_service(struct ptlrpc_service *service); - -struct ptlrpc_svc_data { - char *name; - struct ptlrpc_service *svc; - struct ptlrpc_thread *thread; - struct obd_device *dev; -}; - -/* rpc/pack_generic.c */ -int lustre_pack_msg(int count, int *lens, char **bufs, int *len, - struct lustre_msg **msg); -int lustre_msg_size(int count, int *lengths); -int lustre_unpack_msg(struct lustre_msg *m, int len); -void *lustre_msg_buf(struct lustre_msg *m, int n); -#endif diff --git a/lustre/include/linux/lustre_req.h b/lustre/include/linux/lustre_req.h deleted file mode 100644 index d726766..0000000 --- a/lustre/include/linux/lustre_req.h +++ /dev/null @@ -1,32 +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. - * - * Definitions related to request handling - */ - -#ifndef __LUSTRE_REQ_H__ -#define __LUSTRE_REQ_H__ - -struct lustre_connection { - - -}; - -#endif diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h deleted file mode 100644 index 2c63782..0000000 --- a/lustre/include/linux/obd.h +++ /dev/null @@ -1,262 +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 code is issued under the GNU General Public License. - * See the file COPYING in this distribution - */ - -#ifndef __OBD_H -#define __OBD_H -#include -#include -#include - -#include - -struct obd_conn_info { - unsigned int conn_id; /* handle */ -}; - -struct obd_type { - struct list_head typ_chain; - struct obd_ops *typ_ops; - char *typ_name; - int typ_refcnt; -}; - -struct obd_run_ctxt { - struct vfsmount *pwdmnt; - struct dentry *pwd; - mm_segment_t fs; -}; - -struct obd_conn { - struct obd_device *oc_dev; - uint32_t oc_id; -}; - -struct obd_devicename { - uint32_t len; - char *name; - struct dentry *dentry; /* file system obd device names */ - __u8 _uuid[16]; /* uuid obd device names */ -}; - - -/* Individual type definitions */ - -struct ext2_obd { - struct super_block *e2_sb; - struct vfsmount *e2_vfsmnt; -}; - -struct filter_obd { - char *fo_fstype; - struct super_block *fo_sb; - struct vfsmount *fo_vfsmnt; - struct obd_run_ctxt fo_ctxt; - struct dentry *fo_dentry_O; - struct dentry *fo_dentry_O_mode[16]; - spinlock_t fo_lock; - __u64 fo_lastino; - struct file_operations *fo_fop; - struct inode_operations *fo_iop; - struct address_space_operations *fo_aops; -}; - -struct mds_client_info; -struct mds_server_data; - -struct mds_obd { - struct ptlrpc_service *mds_service; - - char *mds_fstype; - struct super_block *mds_sb; - struct super_operations *mds_sop; - struct vfsmount *mds_vfsmnt; - struct obd_run_ctxt mds_ctxt; - struct file_operations *mds_fop; - struct inode_operations *mds_iop; - struct address_space_operations *mds_aops; - struct mds_fs_operations *mds_fsops; - struct file *mds_rcvd_filp; - __u64 mds_last_committed; - __u64 mds_last_rcvd; - __u64 mds_mount_count; - struct ll_fid mds_rootfid; - int mds_client_count; - struct list_head mds_client_info; - struct mds_server_data *mds_server_data; -}; - -struct ldlm_obd { - struct ptlrpc_service *ldlm_service; - struct ptlrpc_client *ldlm_client; - struct ptlrpc_connection *ldlm_server_conn; -}; - -struct echo_obd { - char *eo_fstype; - struct super_block *eo_sb; - struct vfsmount *eo_vfsmnt; - struct obd_run_ctxt eo_ctxt; - spinlock_t eo_lock; - __u64 eo_lastino; - struct file_operations *eo_fop; - struct inode_operations *eo_iop; - struct address_space_operations *eo_aops; -}; - -struct recovd_obd { - time_t recovd_waketime; - time_t recovd_timeout; - struct ptlrpc_service *recovd_service; - struct ptlrpc_client *recovd_client; - __u32 recovd_flags; - __u32 recovd_wakeup_flag; - spinlock_t recovd_lock; - struct list_head recovd_clients_lh; /* clients managed */ - struct list_head recovd_troubled_lh; /* clients in trouble */ - wait_queue_head_t recovd_recovery_waitq; - wait_queue_head_t recovd_ctl_waitq; - wait_queue_head_t recovd_waitq; - struct task_struct *recovd_thread; -}; - -struct trace_obd { - struct obdtrace_opstats *stats; -}; - -#if 0 -struct snap_obd { - unsigned int snap_index; /* which snapshot index are we accessing */ - int snap_tableno; -}; - -struct raid1_obd { - unsigned int raid1_count; /* how many replicas */ - /* devices to replicate on */ - struct obd_device *raid1_devlist[MAX_RAID1]; - /* connections we make */ - struct obd_conn_info raid1_connections[MAX_RAID1]; - struct list_head raid1_clients; /* clients we have */ -}; -#endif - -struct ost_obd { - struct ptlrpc_service *ost_service; - - struct obd_device *ost_tgt; - struct obd_conn ost_conn; -}; - -struct osc_obd { - struct obd_device *osc_tgt; - struct ptlrpc_client *osc_client; - struct ptlrpc_client *osc_ldlm_client; - struct ptlrpc_connection *osc_conn; -}; - -struct lov_obd { - int lov_count; - struct obd_conn *lov_targets; -}; - -/* corresponds to one of the obd's */ -#define MAX_MULTI 16 -struct obd_device { - struct obd_type *obd_type; - char *obd_name; - __u8 obd_uuid[37]; - - int obd_minor; - int obd_flags; - int obd_refcnt; - struct obd_devicename obd_fsname; - struct proc_dir_entry *obd_proc_entry; - int obd_multi_count; - struct obd_conn obd_multi_conn[MAX_MULTI]; - unsigned int obd_gen_last_id; - unsigned long obd_gen_prealloc_quota; - struct list_head obd_gen_clients; - struct list_head obd_req_list; - wait_queue_head_t obd_req_waitq; - struct ldlm_namespace *obd_namespace; - union { - struct ext2_obd ext2; - struct filter_obd filter; - struct mds_obd mds; - struct ost_obd ost; - struct osc_obd osc; - struct ldlm_obd ldlm; - struct echo_obd echo; - struct recovd_obd recovd; - struct trace_obd trace; - struct lov_obd lov; -#if 0 - struct raid1_obd raid1; - struct snap_obd snap; -#endif - } u; -}; - -struct obd_ops { - int (*o_iocontrol)(long cmd, struct obd_conn *, int len, void *karg, - void *uarg); - int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key, - obd_count *vallen, void **val); - int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key, - obd_count vallen, void *val); - int (*o_attach)(struct obd_device *dev, obd_count len, void *data); - int (*o_detach)(struct obd_device *dev); - int (*o_setup) (struct obd_device *dev, obd_count len, void *data); - int (*o_cleanup)(struct obd_device *dev); - int (*o_connect)(struct obd_conn *conn); - int (*o_disconnect)(struct obd_conn *conn); - - - int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs); - int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids); - int (*o_create)(struct obd_conn *conn, struct obdo *oa); - int (*o_destroy)(struct obd_conn *conn, struct obdo *oa); - int (*o_setattr)(struct obd_conn *conn, struct obdo *oa); - int (*o_getattr)(struct obd_conn *conn, struct obdo *oa); - int (*o_open)(struct obd_conn *conn, struct obdo *oa); - int (*o_close)(struct obd_conn *conn, struct obdo *oa); - int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf, - obd_size *count, obd_off offset); - int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf, - obd_size *count, obd_off offset); - int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa, - struct obdo **oa, obd_count *oa_bufs, struct page **buf, - obd_size *count, obd_off *offset, obd_flag *flags); - int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count, - obd_off offset); - int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count, - obd_off offset); - int (*o_migrate)(struct obd_conn *conn, struct obdo *dst, - struct obdo *src, obd_size count, obd_off offset); - int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst, - struct obd_conn *srconn, struct obdo *src, - obd_size count, obd_off offset); - int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *), - obd_id *startid, obd_gr group, void *data); - int (*o_preprw)(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_remote *remote, - struct niobuf_local *local, void **desc_private); - int (*o_commitrw)(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_local *local, - void *desc_private); - int (*o_enqueue)(struct obd_conn *conn, struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock, __u64 *res_id, - __u32 type, struct ldlm_extent *, __u32 mode, - int *flags, void *data, int datalen, - struct ldlm_handle *lockh); - int (*o_cancel)(struct obd_conn *, __u32 mode, struct ldlm_handle *); -}; - -#endif diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h deleted file mode 100644 index 40d7343..0000000 --- a/lustre/include/linux/obd_class.h +++ /dev/null @@ -1,710 +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 __LINUX_CLASS_OBD_H -#define __LINUX_CLASS_OBD_H - -#ifndef __KERNEL__ -# include -# define __KERNEL__ -# include -# undef __KERNEL__ -#else -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#endif - -/* - * ======== OBD Device Declarations =========== - */ -#define MAX_OBD_DEVICES 8 -extern struct obd_device obd_dev[MAX_OBD_DEVICES]; - -#define OBD_ATTACHED 0x1 -#define OBD_SET_UP 0x2 - -extern struct proc_dir_entry * -proc_lustre_register_obd_device(struct obd_device *obd); -extern void proc_lustre_release_obd_device(struct obd_device *obd); -extern void proc_lustre_remove_obd_entry(const char* name, - struct obd_device *obd); - -/* - * ======== OBD Operations Declarations =========== - */ - -#define OBD_BRW_READ 1 -#define OBD_BRW_WRITE 2 -#define OBD_BRW_RWMASK OBD_BRW_READ | OBD_BRW_WRITE -#define OBD_BRW_CREATE 4 - -#ifdef __KERNEL__ -struct obd_request { - struct obdo *oa; - struct obd_conn *conn; - __u32 plen1; - char *pbuf1; -}; - -static inline int obd_check_conn(struct obd_conn *conn) -{ - struct obd_device *obd; - if (!conn) { - CERROR("obd_check_conn: NULL conn\n"); - RETURN(-ENOTCONN); - } - obd = conn->oc_dev; - if (!obd) { - CERROR("obd_check_conn: NULL obd\n"); - RETURN(-ENODEV); - } - - if (!obd->obd_flags & OBD_ATTACHED ) { - CERROR("obd_check_conn: obd %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); - } - - if (!obd->obd_flags & OBD_SET_UP) { - CERROR("obd_check_conn: obd %d not setup\n", obd->obd_minor); - RETURN(-ENODEV); - } - - if (!obd->obd_type) { - CERROR("obd_check_conn: obd %d not typed\n", obd->obd_minor); - RETURN(-ENODEV); - } - - if (!obd->obd_type->typ_ops) { - CERROR("obd_check_conn: obd %d no operations\n", - obd->obd_minor); - RETURN(-EOPNOTSUPP); - } - return 0; -} - -#define OBT(dev) (dev)->obd_type -#define OBP(dev,op) (dev)->obd_type->typ_ops->o_ ## op - -#define OBD_CHECK_SETUP(conn) \ -do { \ - if (!(conn)) { \ - CERROR("NULL connection\n"); \ - RETURN(-EINVAL); \ - } \ - \ - if (!((conn)->oc_dev)) { \ - CERROR("NULL device\n"); \ - RETURN(-EINVAL); \ - } \ - \ - if ( !((conn)->oc_dev->obd_flags & OBD_SET_UP) ) { \ - CERROR("Device %d not setup\n", \ - (conn)->oc_dev->obd_minor); \ - RETURN(-EINVAL); \ - } \ -} while (0) - -#define OBD_CHECK_OP(conn,op) \ -do { \ - int rc = obd_check_conn(conn); \ - if (rc) { \ - CERROR("obd: error in operation: " #op "\n"); \ - RETURN(rc); \ - } \ - if (!OBP(conn->oc_dev,op)) { \ - CERROR("obd_" #op ": dev %d no operation\n", \ - conn->oc_dev->obd_minor); \ - RETURN(-EOPNOTSUPP); \ - } \ -} while (0) - -static inline int obd_get_info(struct obd_conn *conn, obd_count keylen, - void *key, obd_count *vallen, void **val) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,get_info); - - rc = OBP(conn->oc_dev, get_info)(conn, keylen, key, vallen, val); - RETURN(rc); -} - -static inline int obd_set_info(struct obd_conn *conn, obd_count keylen, - void *key, obd_count vallen, void *val) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,set_info); - - rc = OBP(conn->oc_dev, set_info)(conn, keylen, key, vallen, val); - RETURN(rc); -} - -static inline int obd_setup(struct obd_device *obd, int datalen, void *data) -{ - struct obd_conn conn; - int rc; - conn.oc_dev = obd; - - OBD_CHECK_OP((&conn),setup); - - rc = OBP(conn.oc_dev, setup)(obd, datalen, data); - RETURN(rc); -} - -static inline int obd_cleanup(struct obd_device *obd) -{ - struct obd_conn conn; - int rc; - conn.oc_dev = obd; - - OBD_CHECK_SETUP(&conn); - OBD_CHECK_OP((&conn),cleanup); - - rc = OBP(conn.oc_dev, cleanup)(obd); - RETURN(rc); -} - -static inline int obd_create(struct obd_conn *conn, struct obdo *obdo) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,create); - - rc = OBP(conn->oc_dev, create)(conn, obdo); - RETURN(rc); -} - -static inline int obd_destroy(struct obd_conn *conn, struct obdo *obdo) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,destroy); - - rc = OBP(conn->oc_dev, destroy)(conn, obdo); - RETURN(rc); -} - -static inline int obd_getattr(struct obd_conn *conn, struct obdo *obdo) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,getattr); - - rc = OBP(conn->oc_dev, getattr)(conn, obdo); - RETURN(rc); -} - -static inline int obd_close(struct obd_conn *conn, struct obdo *obdo) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,close); - - rc = OBP(conn->oc_dev, close)(conn, obdo); - RETURN(rc); -} -static inline int obd_open(struct obd_conn *conn, struct obdo *obdo) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,open); - - rc = OBP(conn->oc_dev, open) (conn, obdo); - RETURN(rc); -} - -static inline int obd_setattr(struct obd_conn *conn, struct obdo *obdo) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,setattr); - - rc = OBP(conn->oc_dev, setattr)(conn, obdo); - RETURN(rc); -} - -static inline int obd_connect(struct obd_conn *conn) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,connect); - - rc = OBP(conn->oc_dev, connect)(conn); - RETURN(rc); -} - -static inline int obd_disconnect(struct obd_conn *conn) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,disconnect); - - rc = OBP(conn->oc_dev, disconnect)(conn); - RETURN(rc); -} - -static inline int obd_statfs(struct obd_conn *conn, struct statfs *buf) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,statfs); - - rc = OBP(conn->oc_dev, statfs)(conn, buf); - RETURN(rc); -} - -static inline int obd_punch(struct obd_conn *conn, struct obdo *tgt, - obd_size count, obd_off offset) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,punch); - - rc = OBP(conn->oc_dev, punch)(conn, tgt, count, offset); - RETURN(rc); -} - -static inline int obd_brw(int rw, struct obd_conn *conn, obd_count num_oa, - struct obdo **oa, obd_count *oa_bufs, - struct page **buf, obd_size *count, obd_off *offset, - obd_flag *flags) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn,brw); - - rc = OBP(conn->oc_dev, brw)(rw, conn, num_oa, oa, oa_bufs, buf, - count, offset, flags); - RETURN(rc); -} - -static inline int obd_preprw(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_remote *remote, - struct niobuf_local *local, void **desc_private) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn, preprw); - - rc = OBP(conn->oc_dev, preprw)(cmd, conn, objcount, obj, niocount, - remote, local, desc_private); - RETURN(rc); -} - -static inline int obd_commitrw(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_local *local, - void *desc_private) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn, commitrw); - - rc = OBP(conn->oc_dev, commitrw)(cmd, conn, objcount, obj, niocount, - local, desc_private); - RETURN(rc); -} - -static inline int obd_iocontrol(int cmd, struct obd_conn *conn, - int len, void *karg, void *uarg) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn, iocontrol); - - rc = OBP(conn->oc_dev, iocontrol)(cmd, conn, len, karg, uarg); - RETURN(rc); -} - -static inline int obd_enqueue(struct obd_conn *conn, struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock, __u64 *res_id, - __u32 type, struct ldlm_extent *extent, - __u32 mode, int *flags, void *data, int datalen, - struct ldlm_handle *lockh) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn, enqueue); - - rc = OBP(conn->oc_dev, enqueue)(conn, ns, parent_lock, res_id, type, - extent, mode, flags, data, datalen, - lockh); - RETURN(rc); -} - -static inline int obd_cancel(struct obd_conn *conn, __u32 mode, - struct ldlm_handle *lockh) -{ - int rc; - OBD_CHECK_SETUP(conn); - OBD_CHECK_OP(conn, cancel); - - rc = OBP(conn->oc_dev, cancel)(conn, mode, lockh); - RETURN(rc); -} - -#endif - -/* - * ======== OBD Metadata Support =========== - */ - -extern int obd_init_obdo_cache(void); -extern void obd_cleanup_obdo_cache(void); - - -static inline int obdo_has_inline(struct obdo *obdo) -{ - return (obdo->o_valid & OBD_MD_FLINLINE && - obdo->o_obdflags & OBD_FL_INLINEDATA); -}; - -static inline int obdo_has_obdmd(struct obdo *obdo) -{ - return (obdo->o_valid & OBD_MD_FLOBDMD && - obdo->o_obdflags & OBD_FL_OBDMDEXISTS); -}; - -#ifdef __KERNEL__ -/* support routines */ -extern kmem_cache_t *obdo_cachep; - -static __inline__ struct obdo *obdo_alloc(void) -{ - struct obdo *oa = NULL; - - oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL); - memset(oa, 0, sizeof (*oa)); - - return oa; -} - -static __inline__ void obdo_free(struct obdo *oa) -{ - if (!oa) - return; - kmem_cache_free(obdo_cachep, oa); -} - -static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id, - obd_mode mode, obd_flag valid) -{ - struct obdo *oa; - int err; - - ENTRY; - oa = obdo_alloc(); - if ( !oa ) { - RETURN(ERR_PTR(-ENOMEM)); - } - - oa->o_id = id; - oa->o_mode = mode; - oa->o_valid = valid; - if ((err = OBP(conn->oc_dev, getattr)(conn, oa))) { - obdo_free(oa); - RETURN(ERR_PTR(err)); - } - RETURN(oa); -} - -static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr) -{ - unsigned int ia_valid = attr->ia_valid; - - if (ia_valid & ATTR_ATIME) { - oa->o_atime = attr->ia_atime; - oa->o_valid |= OBD_MD_FLATIME; - } - if (ia_valid & ATTR_MTIME) { - oa->o_mtime = attr->ia_mtime; - oa->o_valid |= OBD_MD_FLMTIME; - } - if (ia_valid & ATTR_CTIME) { - oa->o_ctime = attr->ia_ctime; - oa->o_valid |= OBD_MD_FLCTIME; - } - if (ia_valid & ATTR_SIZE) { - oa->o_size = attr->ia_size; - oa->o_valid |= OBD_MD_FLSIZE; - } - if (ia_valid & ATTR_MODE) { - oa->o_mode = attr->ia_mode; - oa->o_valid |= OBD_MD_FLMODE; - if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID)) - oa->o_mode &= ~S_ISGID; - } - if (ia_valid & ATTR_UID) - { - oa->o_uid = attr->ia_uid; - oa->o_valid |= OBD_MD_FLUID; - } - if (ia_valid & ATTR_GID) { - oa->o_gid = attr->ia_gid; - oa->o_valid |= OBD_MD_FLGID; - } -} - - -static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa) -{ - unsigned int ia_valid = oa->o_valid; - - memset(attr, 0, sizeof(*attr)); - if (ia_valid & OBD_MD_FLATIME) { - attr->ia_atime = oa->o_atime; - attr->ia_valid |= ATTR_ATIME; - } - if (ia_valid & OBD_MD_FLMTIME) { - attr->ia_mtime = oa->o_mtime; - attr->ia_valid |= ATTR_MTIME; - } - if (ia_valid & OBD_MD_FLCTIME) { - attr->ia_ctime = oa->o_ctime; - attr->ia_valid |= ATTR_CTIME; - } - if (ia_valid & OBD_MD_FLSIZE) { - attr->ia_size = oa->o_size; - attr->ia_valid |= ATTR_SIZE; - } - if (ia_valid & OBD_MD_FLMODE) { - attr->ia_mode = oa->o_mode; - attr->ia_valid |= ATTR_MODE; - if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID)) - attr->ia_mode &= ~S_ISGID; - } - if (ia_valid & OBD_MD_FLUID) - { - attr->ia_uid = oa->o_uid; - attr->ia_valid |= ATTR_UID; - } - if (ia_valid & OBD_MD_FLGID) { - attr->ia_gid = oa->o_gid; - attr->ia_valid |= ATTR_GID; - } -} - - -/* WARNING: the file systems must take care not to tinker with - attributes they don't manage (such as blocks). */ - -static __inline__ void obdo_from_inode(struct obdo *dst, struct inode *src) -{ - if ( dst->o_valid & OBD_MD_FLID ) - dst->o_id = src->i_ino; - if ( dst->o_valid & OBD_MD_FLATIME ) - dst->o_atime = src->i_atime; - if ( dst->o_valid & OBD_MD_FLMTIME ) - dst->o_mtime = src->i_mtime; - if ( dst->o_valid & OBD_MD_FLCTIME ) - dst->o_ctime = src->i_ctime; - if ( dst->o_valid & OBD_MD_FLSIZE ) - dst->o_size = src->i_size; - if ( dst->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */ - dst->o_blocks = src->i_blocks; - if ( dst->o_valid & OBD_MD_FLBLKSZ ) - dst->o_blksize = src->i_blksize; - if ( dst->o_valid & OBD_MD_FLMODE ) - dst->o_mode = src->i_mode; - if ( dst->o_valid & OBD_MD_FLUID ) - dst->o_uid = src->i_uid; - if ( dst->o_valid & OBD_MD_FLGID ) - dst->o_gid = src->i_gid; - if ( dst->o_valid & OBD_MD_FLFLAGS ) - dst->o_flags = src->i_flags; - if ( dst->o_valid & OBD_MD_FLNLINK ) - dst->o_nlink = src->i_nlink; - if ( dst->o_valid & OBD_MD_FLGENER ) - dst->o_generation = src->i_generation; -} - -static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src) -{ - - if ( src->o_valid & OBD_MD_FLID ) - dst->i_ino = src->o_id; - if ( src->o_valid & OBD_MD_FLATIME ) - dst->i_atime = src->o_atime; - if ( src->o_valid & OBD_MD_FLMTIME ) - dst->i_mtime = src->o_mtime; - if ( src->o_valid & OBD_MD_FLCTIME ) - dst->i_ctime = src->o_ctime; - if ( src->o_valid & OBD_MD_FLSIZE ) - dst->i_size = src->o_size; - if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */ - dst->i_blocks = src->o_blocks; - if ( src->o_valid & OBD_MD_FLBLKSZ ) - dst->i_blksize = src->o_blksize; - if ( src->o_valid & OBD_MD_FLMODE ) - dst->i_mode = src->o_mode; - if ( src->o_valid & OBD_MD_FLUID ) - dst->i_uid = src->o_uid; - if ( src->o_valid & OBD_MD_FLGID ) - dst->i_gid = src->o_gid; - if ( src->o_valid & OBD_MD_FLFLAGS ) - dst->i_flags = src->o_flags; - if ( src->o_valid & OBD_MD_FLNLINK ) - dst->i_nlink = src->o_nlink; - if ( src->o_valid & OBD_MD_FLGENER ) - dst->i_generation = src->o_generation; -} - -#endif - -static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src) -{ -#ifdef __KERNEL__ - CDEBUG(D_INODE, "src obdo %Ld valid 0x%x, dst obdo %Ld\n", - (unsigned long long)src->o_id, src->o_valid, - (unsigned long long)dst->o_id); -#endif - if ( src->o_valid & OBD_MD_FLATIME ) - dst->o_atime = src->o_atime; - if ( src->o_valid & OBD_MD_FLMTIME ) - dst->o_mtime = src->o_mtime; - if ( src->o_valid & OBD_MD_FLCTIME ) - dst->o_ctime = src->o_ctime; - if ( src->o_valid & OBD_MD_FLSIZE ) - dst->o_size = src->o_size; - if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */ - dst->o_blocks = src->o_blocks; - if ( src->o_valid & OBD_MD_FLBLKSZ ) - dst->o_blksize = src->o_blksize; - if ( src->o_valid & OBD_MD_FLMODE ) - dst->o_mode = src->o_mode; - if ( src->o_valid & OBD_MD_FLUID ) - dst->o_uid = src->o_uid; - if ( src->o_valid & OBD_MD_FLGID ) - dst->o_gid = src->o_gid; - if ( src->o_valid & OBD_MD_FLFLAGS ) - dst->o_flags = src->o_flags; - /* - if ( src->o_valid & OBD_MD_FLOBDFLG ) - dst->o_obdflags = src->o_obdflags; - */ - if ( src->o_valid & OBD_MD_FLNLINK ) - dst->o_nlink = src->o_nlink; - if ( src->o_valid & OBD_MD_FLGENER ) - dst->o_generation = src->o_generation; - if ( src->o_valid & OBD_MD_FLINLINE && - src->o_obdflags & OBD_FL_INLINEDATA) { - memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline)); - dst->o_obdflags |= OBD_FL_INLINEDATA; - } - if ( src->o_valid & OBD_MD_FLOBDMD && - src->o_obdflags & OBD_FL_OBDMDEXISTS) { - memcpy(dst->o_obdmd, src->o_obdmd, sizeof(src->o_obdmd)); - dst->o_obdflags |= OBD_FL_OBDMDEXISTS; - } - - dst->o_valid |= src->o_valid; -} - - -/* returns FALSE if comparison (by flags) is same, TRUE if changed */ -static __inline__ int obdo_cmp_md(struct obdo *dst, struct obdo *src, - obd_flag compare) -{ - int res = 0; - - if ( compare & OBD_MD_FLATIME ) - res = (res || (dst->o_atime != src->o_atime)); - if ( compare & OBD_MD_FLMTIME ) - res = (res || (dst->o_mtime != src->o_mtime)); - if ( compare & OBD_MD_FLCTIME ) - res = (res || (dst->o_ctime != src->o_ctime)); - if ( compare & OBD_MD_FLSIZE ) - res = (res || (dst->o_size != src->o_size)); - if ( compare & OBD_MD_FLBLOCKS ) /* allocation of space */ - res = (res || (dst->o_blocks != src->o_blocks)); - if ( compare & OBD_MD_FLBLKSZ ) - res = (res || (dst->o_blksize != src->o_blksize)); - if ( compare & OBD_MD_FLMODE ) - res = (res || (dst->o_mode != src->o_mode)); - if ( compare & OBD_MD_FLUID ) - res = (res || (dst->o_uid != src->o_uid)); - if ( compare & OBD_MD_FLGID ) - res = (res || (dst->o_gid != src->o_gid)); - if ( compare & OBD_MD_FLFLAGS ) - res = (res || (dst->o_flags != src->o_flags)); - if ( compare & OBD_MD_FLNLINK ) - res = (res || (dst->o_nlink != src->o_nlink)); - if ( compare & OBD_MD_FLGENER ) - res = (res || (dst->o_generation != src->o_generation)); - /* XXX Don't know if thses should be included here - wasn't previously - if ( compare & OBD_MD_FLINLINE ) - res = (res || memcmp(dst->o_inline, src->o_inline)); - if ( compare & OBD_MD_FLOBDMD ) - res = (res || memcmp(dst->o_obdmd, src->o_obdmd)); - */ - return res; -} - - -#ifdef __KERNEL__ -int obd_register_type(struct obd_ops *ops, char *nm); -int obd_unregister_type(char *nm); - -struct obd_client { - struct list_head cli_chain; - struct obd_device *cli_obd; - unsigned int cli_id; - unsigned long cli_prealloc_quota; - struct list_head cli_prealloc_inodes; -}; - - -struct obd_prealloc_inode { - struct list_head obd_prealloc_chain; - unsigned long inode; -}; - -/* generic operations shared by various OBD types */ -int gen_multi_setup(struct obd_device *obddev, uint32_t len, void *data); -int gen_multi_cleanup(struct obd_device *obddev); -int gen_multi_attach(struct obd_device *obddev, uint32_t len, void *data); -int gen_multi_detach(struct obd_device *obddev); -int gen_connect (struct obd_conn *conn); -int gen_disconnect(struct obd_conn *conn); -struct obd_client *gen_client(const struct obd_conn *); -int gen_cleanup(struct obd_device *obddev); -int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst, - struct obd_conn *src_conn, struct obdo *src, - obd_size count, obd_off offset); - -#endif - -/* sysctl.c */ -extern void obd_sysctl_init (void); -extern void obd_sysctl_clean (void); - -#endif /* __LINUX_CLASS_OBD_H */ diff --git a/lustre/include/linux/obd_echo.h b/lustre/include/linux/obd_echo.h deleted file mode 100644 index 67ccf6a..0000000 --- a/lustre/include/linux/obd_echo.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _OBD_ECHO_H -#define _OBD_ECHO_H -/* - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - */ - - -#ifndef OBD_ECHO_DEVICENAME -#define OBD_ECHO_DEVICENAME "obdecho" -#endif - -extern struct obd_ops echo_obd_ops; - -#endif - diff --git a/lustre/include/linux/obd_ext2.h b/lustre/include/linux/obd_ext2.h deleted file mode 100644 index 73b4b0b..0000000 --- a/lustre/include/linux/obd_ext2.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _OBD_EXT2 -#define _OBD_EXT2 -/* - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - */ - -#define OBD_EXT2_RUNIT _IOWR('f', 61, long) - -#ifndef OBD_EXT2_DEVICENAME -#define OBD_EXT2_DEVICENAME "obdext2" -#endif - -/* development definitions */ -extern struct obdfs_sb_info *obd_sbi; -extern struct file_operations *obd_fso; - -/* ext2_obd.c */ -extern struct obd_ops ext2_obd_ops; - -#include -#include - -/* super.c */ -#ifdef EXT2_OBD_DEBUG -# undef ext2_debug -# define ext2_debug(format, a...) CDEBUG(D_EXT2, format, ## a) -# define ext2_error ext2_warning -# define ext2_panic ext2_warning -# define ext2_warning(sb, func, format, a...) CDEBUG(D_WARNING, format, ## a) -#else -# undef ext2_debug -# define ext2_debug(format, a...) {} -# define ext2_error(sb, func, format, a...) printk(KERN_ERR "%s: " format, func, ## a) -# define ext2_panic(sb, func, format, a...) printk(KERN_CRIT "%s: " format, func, ## a) -# define ext2_warning(sb, func, format, a...) printk(KERN_WARNING "%s: " format, func, ## a) -#endif - -extern struct super_operations ext2_sops; -int obd_remount (struct super_block * sb, int * flags, char * data); -struct super_block * ext2_read_super (struct super_block * sb, void * data, - int silent); -/* punch.c */ -void ext2_truncate (struct inode * inode); -int ext2_punch (struct inode * inode, loff_t start, size_t count); - -#endif diff --git a/lustre/include/linux/obd_filter.h b/lustre/include/linux/obd_filter.h deleted file mode 100644 index b87c50e..0000000 --- a/lustre/include/linux/obd_filter.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _OBD_FILTER_H -#define _OBD_FILTER_H -/* - * 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 - -#ifndef OBD_FILTER_DEVICENAME -#define OBD_FILTER_DEVICENAME "obdfilter" -#endif - -extern struct obd_ops filter_obd_ops; - -#endif diff --git a/lustre/include/linux/obd_ost.h b/lustre/include/linux/obd_ost.h deleted file mode 100644 index 8ad6e6a..0000000 --- a/lustre/include/linux/obd_ost.h +++ /dev/null @@ -1,42 +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. - * - * Data structures for object storage targets and client: OST & OSC's - * - * See also lustre_idl.h for wire formats of requests. - * - */ - -#ifndef _LUSTRE_OST_H -#define _LUSTRE_OST_H - -#include - -#define LUSTRE_OST_NAME "ost" -#define LUSTRE_OSC_NAME "osc" - -/* ost/ost_pack.c */ -void ost_pack_niobuf(void **tmp, __u64 offset, __u32 len, __u32 flags, - __u32 xid); -void ost_unpack_niobuf(void **tmp, struct niobuf_remote **nbp); -void ost_pack_ioo(void **tmp, struct obdo *oa, int bufcnt); -void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop); - -#endif diff --git a/lustre/include/linux/obd_raid1.h b/lustre/include/linux/obd_raid1.h deleted file mode 100644 index 97aa870..0000000 --- a/lustre/include/linux/obd_raid1.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _OBD_RAID1 -#define _OBD_RAID1 -/* - * 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 - -#define MAX_RAID1 16 - -#ifndef OBD_RAID1_DEVICENAME -#define OBD_RAID1_DEVICENAME "obdraid1" -#endif - -/* development definitions */ -extern struct obdfs_sb_info *obd_sbi; -extern struct file_operations *obd_fso; - -/* obd_raid1.c */ -extern struct obd_ops raid1_obd_ops; -inline long ext2_block_map (struct inode * inode, long block); - -#endif diff --git a/lustre/include/linux/obd_rpc.h b/lustre/include/linux/obd_rpc.h deleted file mode 100644 index e0847bc..0000000 --- a/lustre/include/linux/obd_rpc.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef __OBD_RPC_H -#define __OBD_RPC_H -/* - * 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 -#define OBD_TGT_VERSION 001 - -#define OBD_TGT_TCP 0x1 -#define OBD_TGT_INTR 0x2 -#define OBD_TGT_SOFT 0x4 - - -/* generic wrappable next */ - -#define NEXT_INDEX(index, max) \ - (((index + 1) >= max) ? 0 : (index + 1)) - - -/* error codes */ - -enum obd_stat { - OBD_OK = 0, - OBDERR_PERM = 1, - OBDERR_NOENT = 2, - OBDERR_IO = 5, - OBDERR_NXIO = 6, - OBDERR_ACCESS = 13, - OBDERR_EXIST = 17, - OBDERR_XDEV = 18, - OBDERR_NODEV = 19, - OBDERR_INVAL = 22, - OBDERR_FBIG = 27, - OBDERR_NOSPC = 28, - OBDERR_ROFS = 30, - OBDERR_OPNOTSUPP = 45, - OBDERR_DQUOT = 69 -}; - - -extern struct rpc_program obd_program; - - -struct obd_target { - struct sockaddr_in tgt_addr; - int tgt_flags; - int tgt_timeo; - int tgt_retrans; - int tgt_hostnamelen; - char tgt_hostname[0]; - -}; - - -struct rpc_obd { - struct rpc_clnt * handle; /* RPC client handle */ - struct sockaddr_in addr; - int flags; /* various flags */ - int timeo; - int retrans; - int rsize; /* read size */ - int wsize; /* write size */ - unsigned int bsize; /* server block size */ - char * hostname; /* remote hostname */ -}; - - -#define OBD_PROGRAM 300001 -#define OBD_VERSION 1 -#define OBDPROC_NULL 0 -#define OBDPROC_ECHOINT 1 - -#ifdef OBD_NEED_XDR_TYPES - -struct obd_echoint_in { - __u32 in; -}; - -struct obd_echoint_out { - __u32 out; -}; - - -#endif /* OBD_NEED_XDR_TYPES */ - - -int obd_proc_echoint(struct rpc_obd *target, __u32 in, __u32 *out); - - -#endif diff --git a/lustre/include/linux/obd_snap.h b/lustre/include/linux/obd_snap.h deleted file mode 100644 index b7641d4..0000000 --- a/lustre/include/linux/obd_snap.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _OBD_SNAP -#define _OBD_SNAP -/* - * 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 - -#define OBD_SNAP_MAGIC 0xfffffff3 /* an unlikely block number */ - -#ifndef OBD_SNAP_DEVICENAME -#define OBD_SNAP_DEVICENAME "obdsnap" -#endif - -/* ioctls for manipulating snapshots 40 - 60 */ -#define OBD_SNAP_SETTABLE _IOWR('f', 40, long) -#define OBD_SNAP_PRINTTABLE _IOWR('f', 41, long) -#define OBD_SNAP_DELETE _IOWR('f', 42, long) -#define OBD_SNAP_RESTORE _IOWR('f', 43, long) - -void snap_use(int table_no, int snap_index) ; -void snap_unuse(int table_no, int snap_index) ; -int snap_is_used(int table_no, int snap_index) ; -int snap_table_attach(int tableno, int snap_index); - -#endif diff --git a/lustre/include/linux/obd_snap_support.h b/lustre/include/linux/obd_snap_support.h deleted file mode 100644 index e7dd012..0000000 --- a/lustre/include/linux/obd_snap_support.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef __OBD_SNAP_SUPP_H -#define __OBD_SNAP_SUPP_H -/* - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - */ - -/* What we use to point to IDs in the obdmd data for snapshots. If we use - * obd_id (8 bytes) instead of ino_t (4 bytes), we halve the number of - * available snapshot slots (14 in 56 bytes vs. 7 in 56 bytes until we - * increase the size of OBD_OBDMDSZ). - */ -typedef ino_t snap_id; - -/* maximum number of snapshot tables we maintain in the kernel */ -#define SNAP_MAX_TABLES 8 - -/* maximum number of snapshots per device - must fit in "o_obdmd" area of struct obdo */ -#define SNAP_MAX ((OBD_OBDMDSZ - sizeof(uint32_t))/sizeof(snap_id)) - -struct snap_md { - uint32_t m_magic; - snap_id m_ids[SNAP_MAX]; /* id of snaps; slot 0 has current id */ -}; - - -/* if time is 0 this designates the "current" snapshot, i.e. - the head of the tree -*/ -struct snap { - time_t time; - int index; -}; - -/* snap ioctl data for attach: current always in first slot of this array */ -struct snap_obd_data { - int snap_dev; /* which device contains the data */ - unsigned int snap_index;/* which snapshot is ours */ - unsigned int snap_table;/* which table do we use */ -}; - - -/* snap ioctl data for table fiddling */ -struct snap_table_data { - int tblcmd_no; /* which table */ - unsigned int tblcmd_count; /* how many snaps */ - struct snap tblcmd_snaps[SNAP_MAX]; /* sorted times! */ -}; - - -struct snap_table { - spinlock_t tbl_lock; - unsigned int tbl_count; /* how many snapshots exist in this table*/ - int tbl_used; /* bitmap of snaps in use by a device */ - time_t tbl_times[SNAP_MAX]; - int tbl_index[SNAP_MAX]; -}; - -struct snap_iterdata { - struct obd_conn *conn; - struct obd_conn *ch_conn; - int index; - int previndex; - int currentindex; - int prevslot; - time_t prevtime; -}; - -inline struct obd_conn *child_conn(struct obd_conn *conn); -int snap_deleteobj(obd_id id, obd_gr group, void *data); -int snap_restoreobj(obd_id id, obd_gr group, void *data); -int snap_printobj(obd_id id, obd_gr group, void *data); -int snap_iocontrol(int cmd, struct obd_conn *conn, int len, void *karg, void *uarg); - -/* In the future, this function may have to deal with offsets into the obdmd. - * Currently, we assume we have the whole obdmd struct. - */ -static __inline__ struct snap_md *snap_obdmd(struct obdo *oa) -{ - return ((struct snap_md *)(&oa->o_obdmd)); -} -#endif diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h deleted file mode 100644 index 0112ac7..0000000 --- a/lustre/include/linux/obd_support.h +++ /dev/null @@ -1,148 +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 _OBD_SUPPORT -#define _OBD_SUPPORT - -#include -#include -#include - -/* global variables */ -extern unsigned long obd_memory; -extern unsigned long obd_fail_loc; - -#define OBD_FAIL_MDS 0x100 -#define OBD_FAIL_MDS_HANDLE_UNPACK 0x101 -#define OBD_FAIL_MDS_GETATTR_NET 0x102 -#define OBD_FAIL_MDS_GETATTR_PACK 0x103 -#define OBD_FAIL_MDS_READPAGE_NET 0x104 -#define OBD_FAIL_MDS_READPAGE_PACK 0x105 -#define OBD_FAIL_MDS_SENDPAGE 0x106 -#define OBD_FAIL_MDS_REINT_NET 0x107 -#define OBD_FAIL_MDS_REINT_UNPACK 0x108 -#define OBD_FAIL_MDS_REINT_SETATTR 0x109 -#define OBD_FAIL_MDS_REINT_SETATTR_WRITE 0x10a -#define OBD_FAIL_MDS_REINT_CREATE 0x10b -#define OBD_FAIL_MDS_REINT_CREATE_WRITE 0x10c -#define OBD_FAIL_MDS_REINT_UNLINK 0x10d -#define OBD_FAIL_MDS_REINT_UNLINK_WRITE 0x10e -#define OBD_FAIL_MDS_REINT_LINK 0x10f -#define OBD_FAIL_MDS_REINT_LINK_WRITE 0x110 -#define OBD_FAIL_MDS_REINT_RENAME 0x111 -#define OBD_FAIL_MDS_REINT_RENAME_WRITE 0x112 -#define OBD_FAIL_MDS_OPEN_NET 0x113 -#define OBD_FAIL_MDS_OPEN_PACK 0x114 -#define OBD_FAIL_MDS_CLOSE_NET 0x115 -#define OBD_FAIL_MDS_CLOSE_PACK 0x116 -#define OBD_FAIL_MDS_CONNECT_NET 0x117 -#define OBD_FAIL_MDS_CONNECT_PACK 0x118 -#define OBD_FAIL_MDS_REINT_NET_REP 0x119 - -#define OBD_FAIL_OST 0x200 -#define OBD_FAIL_OST_CONNECT_NET 0x201 -#define OBD_FAIL_OST_DISCONNECT_NET 0x202 -#define OBD_FAIL_OST_GET_INFO_NET 0x203 -#define OBD_FAIL_OST_CREATE_NET 0x204 -#define OBD_FAIL_OST_DESTROY_NET 0x205 -#define OBD_FAIL_OST_GETATTR_NET 0x206 -#define OBD_FAIL_OST_SETATTR_NET 0x207 -#define OBD_FAIL_OST_OPEN_NET 0x208 -#define OBD_FAIL_OST_CLOSE_NET 0x209 -#define OBD_FAIL_OST_BRW_NET 0x20a -#define OBD_FAIL_OST_PUNCH_NET 0x20b -#define OBD_FAIL_OST_STATFS_NET 0x20c - -#define OBB_FAIL_LDLM 0x300 -#define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301 -#define OBD_FAIL_LDLM_ENQUEUE 0x302 -#define OBD_FAIL_LDLM_CONVERT 0x303 -#define OBD_FAIL_LDLM_CANCEL 0x304 -#define OBD_FAIL_LDLM_CALLBACK 0x305 - -/* preparation for a more advanced failure testbed (not functional yet) */ -#define OBD_FAIL_MASK_SYS 0x0000FF00 -#define OBD_FAIL_MASK_LOC (0x000000FF | OBD_FAIL_MASK_SYS) -#define OBD_FAIL_ONCE 0x80000000 -#define OBD_FAILED 0x40000000 -#define OBD_FAIL_MDS_ALL_NET 0x01000000 -#define OBD_FAIL_OST_ALL_NET 0x02000000 - -#define OBD_FAIL_CHECK(id) ((obd_fail_loc & OBD_FAIL_MASK_LOC) == (id) && \ - ((obd_fail_loc & (OBD_FAILED | OBD_FAIL_ONCE))!=\ - (OBD_FAILED | OBD_FAIL_ONCE))) - -#define OBD_FAIL_RETURN(id, ret) \ -do { \ - if (OBD_FAIL_CHECK(id)) { \ - CERROR("obd_fail_loc=%x, fail operation rc=%d\n", id, ret); \ - obd_fail_loc |= OBD_FAILED; \ - if ((id) & OBD_FAIL_ONCE) \ - obd_fail_loc |= OBD_FAIL_ONCE; \ - RETURN(ret); \ - } \ -} while(0) - -#include -#include - -static inline void OBD_FAIL_WRITE(int id, kdev_t dev) -{ - if (OBD_FAIL_CHECK(id)) { -#ifdef CONFIG_DEV_RDONLY - CERROR("obd_fail_loc=%x, fail write operation on %s\n", - id, bdevname(dev)); - dev_set_rdonly(dev, 2); -#else - CERROR("obd_fail_loc=%x, can't fail write operation on %s\n", - id, bdevname(dev)); -#endif - /* We set FAIL_ONCE because we never "un-fail" a device */ - obd_fail_loc |= OBD_FAILED | OBD_FAIL_ONCE; - } -} - -#define OBD_ALLOC(ptr, size) \ -do { \ - long s = (size); \ - (ptr) = kmalloc(s, GFP_KERNEL); \ - if ((ptr) == NULL) { \ - CERROR("kmalloc of '" #ptr "' (%ld bytes) failed " \ - "at %s:%d\n", s, __FILE__, __LINE__); \ - } else { \ - memset((ptr), 0, s); \ - obd_memory += s; \ - CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at " \ - "%p (tot %ld).\n", s, (ptr), obd_memory); \ - } \ -} while (0) - -#define OBD_FREE(ptr, size) \ -do { \ - int s = (size); \ - kfree((ptr)); \ - obd_memory -= s; \ - CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %ld).\n", \ - s, (ptr), obd_memory); \ -} while (0) - -#endif diff --git a/lustre/include/linux/obd_trace.h b/lustre/include/linux/obd_trace.h deleted file mode 100644 index 524889d..0000000 --- a/lustre/include/linux/obd_trace.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * obdtrace (header file) - is useful for tracing and performance - * debug of the Lustre obd protocol stack. obdtrace is a transparent - * logical obd driver that prints commands their in- and outbound - * parameters. obdtrace maintains statistics about number and latency - * of the obd commands that pass through it. As such it is also use - * for performance analysis. - * - * Copyright (c) 2001 Rumi Zahir - */ - -#ifndef __OBD_TRACE_H -#define __OBD_TRACE_H - -#include - -#endif diff --git a/lustre/include/linux/obdfs.h b/lustre/include/linux/obdfs.h deleted file mode 100644 index 4e68938..0000000 --- a/lustre/include/linux/obdfs.h +++ /dev/null @@ -1,165 +0,0 @@ -/* object based disk file system - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C), 1999, Stelias Computing Inc - * - * - */ - - -#ifndef _OBDFS_H -#define _OBDFS_H -#include -#include -#include - -/* super.c */ -struct obdfs_pgrq { - struct list_head rq_plist; /* linked list of req's */ - unsigned long rq_jiffies; - struct page *rq_page; /* page to be written */ -}; - -extern struct list_head obdfs_super_list; /* list of all OBDFS superblocks */ - - - -/* dir.c */ -extern struct file_operations obdfs_dir_operations; -extern struct inode_operations obdfs_dir_inode_operations; - -/* file.c */ -extern struct file_operations obdfs_file_operations; -extern struct inode_operations obdfs_file_inode_operations; - -/* flush.c */ -void obdfs_dequeue_pages(struct inode *inode); -int obdfs_flushd_init(void); -int obdfs_flushd_cleanup(void); -int obdfs_flush_reqs(struct list_head *inode_list, unsigned long check_time); -int obdfs_flush_dirty_pages(unsigned long check_time); - -/* namei.c */ - -/* rw.c */ -int obdfs_do_writepage(struct page *, int sync); -int obdfs_init_pgrqcache(void); -void obdfs_cleanup_pgrqcache(void); -inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq); -int obdfs_readpage(struct file *file, struct page *page); -int obdfs_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to); -int obdfs_commit_write(struct file *file, struct page *page, unsigned from, unsigned to); -int obdfs_writepage(struct page *page); -struct page *obdfs_getpage(struct inode *inode, unsigned long offset, - int create, int locked); -int obdfs_write_one_page(struct file *file, struct page *page, - unsigned long offset, unsigned long bytes, - const char * buf); -int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa, - struct obdo **obdos, obd_count *oa_bufs, - struct page **pages, char **bufs, obd_size *counts, - obd_off *offsets, obd_flag *flags); -void obdfs_truncate(struct inode *inode); - -/* super.c */ -extern long obdfs_cache_count; -extern long obdfs_mutex_start; - -/* symlink.c */ -extern struct inode_operations obdfs_fast_symlink_inode_operations; -extern struct inode_operations obdfs_symlink_inode_operations; - -/* sysctl.c */ -void obdfs_sysctl_init(void); -void obdfs_sysctl_clean(void); - -static inline struct obdfs_sb_info *obdfs_i2sbi(struct inode *inode) -{ - return (struct obdfs_sb_info *) &(inode->i_sb->u.generic_sbp); -} - -static inline struct list_head *obdfs_iplist(struct inode *inode) -{ - struct obdfs_inode_info *info = obdfs_i2info(inode); - - return &info->oi_pages; -} - -static inline struct list_head *obdfs_islist(struct inode *inode) -{ - struct obdfs_inode_info *info = obdfs_i2info(inode); - - return &info->oi_inodes; -} - -static inline struct list_head *obdfs_slist(struct inode *inode) -{ - struct obdfs_sb_info *sbi = obdfs_i2sbi(inode); - - return &sbi->osi_inodes; -} - -static void inline obdfs_set_size (struct inode *inode, obd_size size) -{ - inode->i_size = size; - inode->i_blocks = (inode->i_size + inode->i_sb->s_blocksize - 1) >> - inode->i_sb->s_blocksize_bits; -} /* obdfs_set_size */ - - -#if 0 /* PAGE CACHE DISABLED */ - -#define obd_down(mutex) { \ - /* CDEBUG(D_INFO, "get lock\n"); */ \ - obdfs_mutex_start = jiffies; \ - down(mutex); \ - if (jiffies - obdfs_mutex_start) \ - CDEBUG(D_CACHE, "waited on mutex %ld jiffies\n", \ - jiffies - obdfs_mutex_start); \ -} - -#define obd_up(mutex) { \ - up(mutex); \ - if (jiffies - obdfs_mutex_start > 1) \ - CDEBUG(D_CACHE, "held mutex for %ld jiffies\n", \ - jiffies - obdfs_mutex_start); \ - /* CDEBUG(D_INFO, "free lock\n"); */ \ -} - -/* We track if a page has been added to the OBD page cache by stting a - * flag on the page. We have chosen a bit that will hopefully not be - * used for a while. - */ -#define PG_obdcache 29 -#define OBDAddCachePage(page) test_and_set_bit(PG_obdcache, &(page)->flags) -#define OBDClearCachePage(page) clear_bit(PG_obdcache, &(page)->flags) - -static inline void obdfs_print_plist(struct inode *inode) -{ - struct list_head *page_list = obdfs_iplist(inode); - struct list_head *tmp; - - CDEBUG(D_INFO, "inode %ld: page", inode->i_ino); - /* obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); */ - if (list_empty(page_list)) { - CDEBUG(D_INFO, " list empty\n"); - obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); - return; - } - - tmp = page_list; - while ( (tmp = tmp->next) != page_list) { - struct obdfs_pgrq *pgrq; - pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist); - CDEBUG(D_INFO, " %p", pgrq->rq_page); - } - CDEBUG(D_INFO, "\n"); - /* obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); */ -} -#endif - - -#endif - diff --git a/lustre/include/linux/obdo.h b/lustre/include/linux/obdo.h deleted file mode 100644 index 4255482..0000000 --- a/lustre/include/linux/obdo.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef OBD_H -#define OBD_H -/* - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - */ - -struct obdfs_inode_info { - int oi_flags; - struct list_head oi_inodes; - struct list_head oi_pages; - char oi_inline[OBD_INLINESZ]; -}; - -struct obdfs_sb_info { - struct list_head osi_list; /* list of supers */ - struct obd_conn osi_conn; - struct super_block *osi_super; - struct obd_device *osi_obd; - ino_t osi_rootino; /* number of root inode */ - int osi_minor; /* minor of /dev/obdX */ - struct list_head osi_inodes; /* list of dirty inodes */ - unsigned long osi_cache_count; - struct semaphore osi_list_mutex; -}; - - -static inline struct obdfs_inode_info *obdfs_i2info(struct inode *inode) -{ - return (struct obdfs_inode_info *)&(inode->u.generic_ip); -} - -static inline int obdfs_has_inline(struct inode *inode) -{ - return (obdfs_i2info(inode)->oi_flags & OBD_FL_INLINEDATA); -} - -static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode) -{ - struct obdfs_inode_info *oinfo = obdfs_i2info(inode); - - CDEBUG(D_INFO, "src inode %ld, dst obdo %ld valid 0x%08x\n", - inode->i_ino, (long)oa->o_id, oa->o_valid); - obdo_from_inode(oa, inode); - if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { - CDEBUG(D_INODE, "copying device %x from inode to obdo\n", - inode->i_rdev); - *((obd_rdev *)oa->o_inline) = kdev_t_to_nr(inode->i_rdev); - oa->o_obdflags |= OBD_FL_INLINEDATA; - oa->o_valid |= OBD_MD_FLINLINE; - } else if (obdfs_has_inline(inode)) { - CDEBUG(D_INODE, "copying inline data from inode to obdo\n"); - memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ); - oa->o_obdflags |= OBD_FL_INLINEDATA; - oa->o_valid |= OBD_MD_FLINLINE; - } -} /* obdfs_from_inode */ - -static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa) -{ - struct obdfs_inode_info *oinfo = obdfs_i2info(inode); - - CDEBUG(D_INFO, "src obdo %ld valid 0x%08x, dst inode %ld\n", - (long)oa->o_id, oa->o_valid, inode->i_ino); - - obdo_to_inode(inode, oa); - - if (obdo_has_inline(oa)) { - if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || - S_ISFIFO(inode->i_mode)) { - obd_rdev rdev = *((obd_rdev *)oa->o_inline); - CDEBUG(D_INODE, - "copying device %x from obdo to inode\n", rdev); - init_special_inode(inode, inode->i_mode, rdev); - } else { - CDEBUG(D_INFO, "copying inline from obdo to inode\n"); - memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ); - } - oinfo->oi_flags |= OBD_FL_INLINEDATA; - } -} /* obdfs_to_inode */ - -#define NOLOCK 0 -#define LOCKED 1 - -#ifdef OPS -#warning "*** WARNING redefining OPS" -#else -#define OPS(sb,op) ((struct obdfs_sb_info *)(& (sb)->u.generic_sbp))->osi_ops->o_ ## op -#define IOPS(inode,op) ((struct obdfs_sb_info *)(&(inode)->i_sb->u.generic_sbp))->osi_ops->o_ ## op -#endif - -#ifdef ID -#warning "*** WARNING redefining ID" -#else -#define ID(sb) (&((struct obdfs_sb_info *)( &(sb)->u.generic_sbp))->osi_conn) -#define IID(inode) (&((struct obdfs_sb_info *)( &(inode)->i_sb->u.generic_sbp))->osi_conn) -#endif - -#define OBDFS_SUPER_MAGIC 0x4711 - -#endif diff --git a/lustre/install-sh b/lustre/install-sh deleted file mode 100755 index e9de238..0000000 --- a/lustre/install-sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/lustre/ldlm/.cvsignore b/lustre/ldlm/.cvsignore deleted file mode 100644 index e995588..0000000 --- a/lustre/ldlm/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -.deps -Makefile -Makefile.in diff --git a/lustre/ldlm/Makefile.am b/lustre/ldlm/Makefile.am deleted file mode 100644 index da6256a..0000000 --- a/lustre/ldlm/Makefile.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 - -DEFS:= -MODULE = ldlm -modulefs_DATA = ldlm.o -EXTRA_PROGRAMS = ldlm - -ldlm_SOURCES = ldlm_lock.c ldlm_resource.c ldlm_test.c ldlm_lockd.c \ -ldlm_extent.c ldlm_request.c - -include $(top_srcdir)/Rules - diff --git a/lustre/ldlm/ldlm_extent.c b/lustre/ldlm/ldlm_extent.c deleted file mode 100644 index 3e7c723..0000000 --- a/lustre/ldlm/ldlm_extent.c +++ /dev/null @@ -1,85 +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 code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Cluster File Systems, Inc. - * authors, Peter Braam & - * Phil Schwan - */ - -#define DEBUG_SUBSYSTEM S_LDLM - -#include - -/* This function will be called to judge if the granted queue of another child - * (read: another extent) is conflicting and needs its granted queue walked to - * issue callbacks. - * - * This helps to find conflicts between read and write locks on overlapping - * extents. */ -int ldlm_extent_compat(struct ldlm_lock *a, struct ldlm_lock *b) -{ - if (MAX(a->l_extent.start, b->l_extent.start) <= - MIN(a->l_extent.end, b->l_extent.end)) - RETURN(0); - - RETURN(1); -} - -static void policy_internal(struct list_head *queue, struct ldlm_extent *req_ex, - struct ldlm_extent *new_ex, ldlm_mode_t mode) -{ - struct list_head *tmp; - - list_for_each(tmp, queue) { - struct ldlm_lock *lock; - lock = list_entry(tmp, struct ldlm_lock, l_res_link); - - if (lock->l_extent.end < req_ex->start) - new_ex->start = MIN(lock->l_extent.end, new_ex->start); - else { - if (lock->l_extent.start < req_ex->start && - !lockmode_compat(lock->l_req_mode, mode)) - /* Policy: minimize conflict overlap */ - new_ex->start = req_ex->start; - } - if (lock->l_extent.start > req_ex->end) - new_ex->end = MAX(lock->l_extent.start, new_ex->end); - else { - if (lock->l_extent.end > req_ex->end && - !lockmode_compat(lock->l_req_mode, mode)) - /* Policy: minimize conflict overlap */ - new_ex->end = req_ex->end; - } - } -} - -/* The purpose of this function is to return: - * - the maximum extent - * - containing the requested extent - * - and not overlapping existing extents outside the requested one - * - * An alternative policy is to not shrink the new extent when conflicts exist. - * - * To reconstruct our formulas, take a deep breath. */ -int ldlm_extent_policy(struct ldlm_resource *res, struct ldlm_extent *req_ex, - struct ldlm_extent *new_ex, ldlm_mode_t mode, void *data) -{ - new_ex->start = 0; - new_ex->end = ~0; - - if (!res) - LBUG(); - - policy_internal(&res->lr_granted, req_ex, new_ex, mode); - policy_internal(&res->lr_converting, req_ex, new_ex, mode); - policy_internal(&res->lr_waiting, req_ex, new_ex, mode); - - if (new_ex->end != req_ex->end || new_ex->start != req_ex->start) - return ELDLM_LOCK_CHANGED; - return 0; -} diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c deleted file mode 100644 index 30a99c0..0000000 --- a/lustre/ldlm/ldlm_lock.c +++ /dev/null @@ -1,527 +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 code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Cluster File Systems, Inc. - * authors, Peter Braam & - * Phil Schwan - */ - -#define DEBUG_SUBSYSTEM S_LDLM - -#include -#include - -extern kmem_cache_t *ldlm_lock_slab; - -static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b); -static int ldlm_intent_compat(struct ldlm_lock *a, struct ldlm_lock *b); - -ldlm_res_compat ldlm_res_compat_table [] = { - [LDLM_PLAIN] ldlm_plain_compat, - [LDLM_EXTENT] ldlm_extent_compat, - [LDLM_MDSINTENT] ldlm_intent_compat -}; - -ldlm_res_policy ldlm_res_policy_table [] = { - [LDLM_PLAIN] NULL, - [LDLM_EXTENT] ldlm_extent_policy, - [LDLM_MDSINTENT] NULL -}; - -static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b) -{ - return lockmode_compat(a->l_req_mode, b->l_req_mode); -} - -static int ldlm_intent_compat(struct ldlm_lock *a, struct ldlm_lock *b) -{ - LBUG(); - return 0; -} - -/* Args: referenced, unlocked parent (or NULL) - * referenced, unlocked resource - * Locks: parent->l_lock */ -static struct ldlm_lock *ldlm_lock_new(struct ldlm_lock *parent, - struct ldlm_resource *resource) -{ - struct ldlm_lock *lock; - - if (resource == NULL) - LBUG(); - - lock = kmem_cache_alloc(ldlm_lock_slab, SLAB_KERNEL); - if (lock == NULL) - return NULL; - - memset(lock, 0, sizeof(*lock)); - lock->l_resource = resource; - INIT_LIST_HEAD(&lock->l_children); - INIT_LIST_HEAD(&lock->l_res_link); - init_waitqueue_head(&lock->l_waitq); - lock->l_lock = SPIN_LOCK_UNLOCKED; - - if (parent != NULL) { - spin_lock(&parent->l_lock); - lock->l_parent = parent; - list_add(&lock->l_childof, &parent->l_children); - spin_unlock(&parent->l_lock); - } - - return lock; -} - -/* Args: unreferenced, locked lock - * - * Caller must do its own ldlm_resource_put() on lock->l_resource */ -void ldlm_lock_free(struct ldlm_lock *lock) -{ - if (!list_empty(&lock->l_children)) { - CERROR("lock %p still has children (%p)!\n", lock, - lock->l_children.next); - ldlm_lock_dump(lock); - LBUG(); - } - - if (lock->l_readers || lock->l_writers) - CDEBUG(D_INFO, "lock still has references (%d readers, %d " - "writers)\n", lock->l_readers, lock->l_writers); - - if (lock->l_connection) - ptlrpc_put_connection(lock->l_connection); - kmem_cache_free(ldlm_lock_slab, lock); -} - -void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc) -{ - ldlm_res2desc(lock->l_resource, &desc->l_resource); - desc->l_req_mode = lock->l_req_mode; - desc->l_granted_mode = lock->l_granted_mode; - memcpy(&desc->l_extent, &lock->l_extent, sizeof(desc->l_extent)); - memcpy(desc->l_version, lock->l_version, sizeof(desc->l_version)); -} - -/* Args: unlocked lock */ -void ldlm_lock_addref(struct ldlm_lock *lock, __u32 mode) -{ - spin_lock(&lock->l_lock); - if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR) - lock->l_readers++; - else - lock->l_writers++; - spin_unlock(&lock->l_lock); -} - -/* Args: unlocked lock */ -void ldlm_lock_decref(struct ldlm_lock *lock, __u32 mode) -{ - int rc; - - spin_lock(&lock->l_lock); - if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR) - lock->l_readers--; - else - lock->l_writers--; - if (!lock->l_readers && !lock->l_writers && - lock->l_flags & LDLM_FL_DYING) { - /* Read this lock its rights. */ - if (!lock->l_resource->lr_namespace->ns_local) { - CERROR("LDLM_FL_DYING set on non-local lock!\n"); - LBUG(); - } - - CDEBUG(D_INFO, "final decref done on dying lock, " - "cancelling.\n"); - spin_unlock(&lock->l_lock); - rc = ldlm_cli_cancel(lock->l_client, lock); - if (rc) { - /* FIXME: do something more dramatic */ - CERROR("ldlm_cli_cancel: %d\n", rc); - } - } else - spin_unlock(&lock->l_lock); -} - -/* Args: locked lock */ -static int _ldlm_lock_compat(struct ldlm_lock *lock, int send_cbs, - struct list_head *queue) -{ - struct list_head *tmp, *pos; - int rc = 0; - - list_for_each_safe(tmp, pos, queue) { - struct ldlm_lock *child; - ldlm_res_compat compat; - - child = list_entry(tmp, struct ldlm_lock, l_res_link); - if (lock == child) - continue; - - compat = ldlm_res_compat_table[child->l_resource->lr_type]; - if (compat(child, lock)) { - CDEBUG(D_OTHER, "compat function succeded, next.\n"); - continue; - } - if (lockmode_compat(child->l_granted_mode, lock->l_req_mode)) { - CDEBUG(D_OTHER, "lock modes are compatible, next.\n"); - continue; - } - - rc = 1; - - CDEBUG(D_OTHER, "compat function failed and lock modes are " - "incompatible; sending blocking AST.\n"); - if (send_cbs && child->l_blocking_ast != NULL) - child->l_blocking_ast(child, lock, child->l_data, - child->l_data_len); - } - - return rc; -} - -/* Args: unlocked lock */ -static int ldlm_lock_compat(struct ldlm_lock *lock, int send_cbs) -{ - int rc; - ENTRY; - - rc = _ldlm_lock_compat(lock, send_cbs, &lock->l_resource->lr_granted); - rc |= _ldlm_lock_compat(lock, send_cbs, - &lock->l_resource->lr_converting); - - RETURN(rc); -} - -/* Args: locked lock, locked resource */ -void ldlm_grant_lock(struct ldlm_resource *res, struct ldlm_lock *lock) -{ - ENTRY; - - ldlm_resource_add_lock(res, &res->lr_granted, lock); - lock->l_granted_mode = lock->l_req_mode; - - if (lock->l_granted_mode < res->lr_most_restr) - res->lr_most_restr = lock->l_granted_mode; - - if (lock->l_completion_ast) - lock->l_completion_ast(lock, NULL, - lock->l_data, lock->l_data_len); - EXIT; -} - -static int search_queue(struct list_head *queue, ldlm_mode_t mode, - struct ldlm_extent *extent, struct ldlm_handle *lockh) -{ - struct list_head *tmp; - - list_for_each(tmp, queue) { - struct ldlm_lock *lock; - lock = list_entry(tmp, struct ldlm_lock, l_res_link); - - if (lock->l_flags & LDLM_FL_DYING) - continue; - - /* lock_convert() takes the resource lock, so we're sure that - * req_mode, lr_type, and l_extent won't change beneath us */ - if (lock->l_req_mode != mode) - continue; - - if (lock->l_resource->lr_type == LDLM_EXTENT && - (lock->l_extent.start > extent->start || - lock->l_extent.end < extent->end)) - continue; - - ldlm_lock_addref(lock, mode); - ldlm_object2handle(lock, lockh); - return 1; - } - - return 0; -} - -/* Must be called with no resource or lock locks held. - * - * Returns 1 if it finds an already-existing lock that is compatible; in this - * case, lockh is filled in with a addref()ed lock */ -int ldlm_local_lock_match(struct ldlm_namespace *ns, __u64 *res_id, __u32 type, - struct ldlm_extent *extent, ldlm_mode_t mode, - struct ldlm_handle *lockh) -{ - struct ldlm_resource *res; - int rc = 0; - ENTRY; - - res = ldlm_resource_get(ns, NULL, res_id, type, 0); - if (res == NULL) - RETURN(0); - - spin_lock(&res->lr_lock); - if (search_queue(&res->lr_granted, mode, extent, lockh)) - GOTO(out, rc = 1); - if (search_queue(&res->lr_converting, mode, extent, lockh)) - GOTO(out, rc = 1); - if (search_queue(&res->lr_waiting, mode, extent, lockh)) - GOTO(out, rc = 1); - - EXIT; - out: - ldlm_resource_put(res); - spin_unlock(&res->lr_lock); - return rc; -} - -/* Must be called without the resource lock held. Returns a referenced, - * unlocked ldlm_lock. */ -ldlm_error_t ldlm_local_lock_create(struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock_handle, - __u64 *res_id, __u32 type, - ldlm_mode_t mode, - void *data, - __u32 data_len, - struct ldlm_handle *lockh) -{ - struct ldlm_resource *res, *parent_res = NULL; - struct ldlm_lock *lock, *parent_lock; - - parent_lock = ldlm_handle2object(parent_lock_handle); - if (parent_lock) - parent_res = parent_lock->l_resource; - - res = ldlm_resource_get(ns, parent_res, res_id, type, 1); - if (res == NULL) - RETURN(-ENOMEM); - - lock = ldlm_lock_new(parent_lock, res); - if (lock == NULL) { - spin_lock(&res->lr_lock); - ldlm_resource_put(res); - spin_unlock(&res->lr_lock); - RETURN(-ENOMEM); - } - - lock->l_req_mode = mode; - lock->l_data = data; - lock->l_data_len = data_len; - ldlm_lock_addref(lock, mode); - - ldlm_object2handle(lock, lockh); - return ELDLM_OK; -} - -/* Must be called with lock->l_lock and lock->l_resource->lr_lock not held */ -ldlm_error_t ldlm_local_lock_enqueue(struct ldlm_handle *lockh, - struct ldlm_extent *req_ex, - int *flags, - ldlm_lock_callback completion, - ldlm_lock_callback blocking) -{ - struct ldlm_resource *res; - struct ldlm_lock *lock; - int incompat = 0, local; - ldlm_res_policy policy; - ENTRY; - - lock = ldlm_handle2object(lockh); - res = lock->l_resource; - local = res->lr_namespace->ns_local; - spin_lock(&res->lr_lock); - - lock->l_blocking_ast = blocking; - - if ((res->lr_type == LDLM_EXTENT && !req_ex) || - (res->lr_type != LDLM_EXTENT && req_ex)) - LBUG(); - - if ((policy = ldlm_res_policy_table[res->lr_type])) { - struct ldlm_extent new_ex; - int rc = policy(res, req_ex, &new_ex, lock->l_req_mode, NULL); - if (rc == ELDLM_LOCK_CHANGED) { - *flags |= LDLM_FL_LOCK_CHANGED; - memcpy(req_ex, &new_ex, sizeof(new_ex)); - } - } - - if (req_ex) - memcpy(&lock->l_extent, req_ex, sizeof(*req_ex)); - - if (local && lock->l_req_mode == lock->l_granted_mode) { - /* The server returned a blocked lock, but it was granted before - * we got a chance to actually enqueue it. We don't need to do - * anything else. */ - GOTO(out, ELDLM_OK); - } - - /* If this is a local resource, put it on the appropriate list. */ - if (local) { - if (*flags & LDLM_FL_BLOCK_CONV) - ldlm_resource_add_lock(res, res->lr_converting.prev, - lock); - else if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED)) - ldlm_resource_add_lock(res, res->lr_waiting.prev, lock); - else - ldlm_grant_lock(res, lock); - GOTO(out, ELDLM_OK); - } - - /* FIXME: We may want to optimize by checking lr_most_restr */ - if (!list_empty(&res->lr_converting)) { - ldlm_resource_add_lock(res, res->lr_waiting.prev, lock); - *flags |= LDLM_FL_BLOCK_CONV; - GOTO(out, ELDLM_OK); - } - if (!list_empty(&res->lr_waiting)) { - ldlm_resource_add_lock(res, res->lr_waiting.prev, lock); - *flags |= LDLM_FL_BLOCK_WAIT; - GOTO(out, ELDLM_OK); - } - incompat = ldlm_lock_compat(lock, 0); - if (incompat) { - ldlm_resource_add_lock(res, res->lr_waiting.prev, lock); - *flags |= LDLM_FL_BLOCK_GRANTED; - GOTO(out, ELDLM_OK); - } - - ldlm_grant_lock(res, lock); - EXIT; - out: - /* Don't set 'completion_ast' until here so that if the lock is granted - * immediately we don't do an unnecessary completion call. */ - lock->l_completion_ast = completion; - spin_unlock(&res->lr_lock); - return ELDLM_OK; -} - -/* Must be called with resource->lr_lock taken. */ -static int ldlm_reprocess_queue(struct ldlm_resource *res, - struct list_head *converting) -{ - struct list_head *tmp, *pos; - ENTRY; - - list_for_each_safe(tmp, pos, converting) { - struct ldlm_lock *pending; - pending = list_entry(tmp, struct ldlm_lock, l_res_link); - - /* the resource lock protects ldlm_lock_compat */ - if (ldlm_lock_compat(pending, 1)) - RETURN(1); - - list_del_init(&pending->l_res_link); - ldlm_grant_lock(res, pending); - - ldlm_lock_addref(pending, pending->l_req_mode); - ldlm_lock_decref(pending, pending->l_granted_mode); - } - - RETURN(0); -} - -/* Must be called with resource->lr_lock not taken. */ -void ldlm_reprocess_all(struct ldlm_resource *res) -{ - /* Local lock trees don't get reprocessed. */ - if (res->lr_namespace->ns_local) - return; - - spin_lock(&res->lr_lock); - ldlm_reprocess_queue(res, &res->lr_converting); - if (list_empty(&res->lr_converting)) - ldlm_reprocess_queue(res, &res->lr_waiting); - spin_unlock(&res->lr_lock); -} - -/* Must be called with lock and lock->l_resource unlocked */ -struct ldlm_resource *ldlm_local_lock_cancel(struct ldlm_lock *lock) -{ - struct ldlm_resource *res; - ENTRY; - - res = lock->l_resource; - - spin_lock(&res->lr_lock); - spin_lock(&lock->l_lock); - - if (lock->l_readers || lock->l_writers) - CDEBUG(D_INFO, "lock still has references (%d readers, %d " - "writers)\n", lock->l_readers, lock->l_writers); - - ldlm_resource_del_lock(lock); - if (ldlm_resource_put(res)) - res = NULL; /* res was freed, nothing else to do. */ - else - spin_unlock(&res->lr_lock); - ldlm_lock_free(lock); - - RETURN(res); -} - -/* Must be called with lock and lock->l_resource unlocked */ -struct ldlm_resource *ldlm_local_lock_convert(struct ldlm_handle *lockh, - int new_mode, int *flags) -{ - struct ldlm_lock *lock; - struct ldlm_resource *res; - ENTRY; - - lock = ldlm_handle2object(lockh); - res = lock->l_resource; - - spin_lock(&res->lr_lock); - - lock->l_req_mode = new_mode; - list_del_init(&lock->l_res_link); - - /* If this is a local resource, put it on the appropriate list. */ - if (res->lr_namespace->ns_local) { - if (*flags & LDLM_FL_BLOCK_CONV) - ldlm_resource_add_lock(res, res->lr_converting.prev, - lock); - else if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED)) - ldlm_resource_add_lock(res, res->lr_waiting.prev, lock); - else - ldlm_grant_lock(res, lock); - } else { - list_add(&lock->l_res_link, res->lr_converting.prev); - } - - spin_unlock(&res->lr_lock); - - RETURN(res); -} - -void ldlm_lock_dump(struct ldlm_lock *lock) -{ - char ver[128]; - - if (!(portal_debug & D_OTHER)) - return; - - if (RES_VERSION_SIZE != 4) - LBUG(); - - if (!lock) { - CDEBUG(D_OTHER, " NULL LDLM lock\n"); - return; - } - - snprintf(ver, sizeof(ver), "%x %x %x %x", - lock->l_version[0], lock->l_version[1], - lock->l_version[2], lock->l_version[3]); - - CDEBUG(D_OTHER, " -- Lock dump: %p (%s)\n", lock, ver); - CDEBUG(D_OTHER, " Parent: %p\n", lock->l_parent); - CDEBUG(D_OTHER, " Resource: %p\n", lock->l_resource); - CDEBUG(D_OTHER, " Requested mode: %d, granted mode: %d\n", - (int)lock->l_req_mode, (int)lock->l_granted_mode); - CDEBUG(D_OTHER, " Readers: %u ; Writers; %u\n", - lock->l_readers, lock->l_writers); - if (lock->l_resource->lr_type == LDLM_EXTENT) - CDEBUG(D_OTHER, " Extent: %Lu -> %Lu\n", - (unsigned long long)lock->l_extent.start, - (unsigned long long)lock->l_extent.end); -} diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c deleted file mode 100644 index 58d3a8f7..0000000 --- a/lustre/ldlm/ldlm_lockd.c +++ /dev/null @@ -1,441 +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 code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Cluster File Systems, Inc. - */ - -#define EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_LDLM - -#include -#include -#include - -extern kmem_cache_t *ldlm_resource_slab; -extern kmem_cache_t *ldlm_lock_slab; - -#define LOOPBACK(x) (((x) & cpu_to_be32(0xff000000)) == cpu_to_be32(0x7f000000)) - -static int is_local_conn(struct ptlrpc_connection *conn) -{ - ENTRY; - if (conn == NULL) - RETURN(1); - - RETURN(LOOPBACK(conn->c_peer.peer_nid)); -} - -/* _ldlm_callback and local_callback setup the variables then call this common - * code */ -static int common_callback(struct ldlm_lock *lock, struct ldlm_lock *new, - ldlm_mode_t mode, void *data, __u32 data_len) -{ - ENTRY; - ldlm_lock_dump(lock); - - if (!lock) - LBUG(); - if (!lock->l_resource) - LBUG(); - - spin_lock(&lock->l_resource->lr_lock); - spin_lock(&lock->l_lock); - if (!new) { - CDEBUG(D_INFO, "Got local completion AST for lock %p.\n", lock); - lock->l_req_mode = mode; - list_del_init(&lock->l_res_link); - ldlm_grant_lock(lock->l_resource, lock); - wake_up(&lock->l_waitq); - spin_unlock(&lock->l_lock); - spin_unlock(&lock->l_resource->lr_lock); - } else { - CDEBUG(D_INFO, "Got local blocking AST for lock %p.\n", lock); - lock->l_flags |= LDLM_FL_DYING; - spin_unlock(&lock->l_lock); - spin_unlock(&lock->l_resource->lr_lock); - if (!lock->l_readers && !lock->l_writers) { - CDEBUG(D_INFO, "Lock already unused, canceling.\n"); - if (ldlm_cli_cancel(lock->l_client, lock)) - LBUG(); - } else { - CDEBUG(D_INFO, "Lock still has references; lock will be" - " cancelled later.\n"); - } - } - RETURN(0); -} - -static int local_callback(struct ldlm_lock *l, struct ldlm_lock *new, - void *data, __u32 data_len) -{ - struct ldlm_lock *lock; - /* the 'remote handle' is the lock in the FS's namespace */ - lock = ldlm_handle2object(&l->l_remote_handle); - - return common_callback(lock, new, l->l_granted_mode, data, data_len); -} - -static int _ldlm_enqueue(struct obd_device *obddev, struct ptlrpc_service *svc, - struct ptlrpc_request *req) -{ - struct ldlm_reply *dlm_rep; - struct ldlm_request *dlm_req; - int rc, size = sizeof(*dlm_rep); - ldlm_error_t err; - struct ldlm_lock *lock = NULL; - ldlm_lock_callback callback; - ENTRY; - - /* Is this lock managed locally? */ - if (is_local_conn(req->rq_connection)) - callback = local_callback; - else - callback = ldlm_cli_callback; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) { - CERROR("out of memory\n"); - RETURN(-ENOMEM); - } - dlm_rep = lustre_msg_buf(req->rq_repmsg, 0); - dlm_req = lustre_msg_buf(req->rq_reqmsg, 0); - - memcpy(&dlm_rep->lock_extent, &dlm_req->lock_desc.l_extent, - sizeof(dlm_rep->lock_extent)); - dlm_rep->flags = dlm_req->flags; - - err = ldlm_local_lock_create(obddev->obd_namespace, - &dlm_req->lock_handle2, - dlm_req->lock_desc.l_resource.lr_name, - dlm_req->lock_desc.l_resource.lr_type, - dlm_req->lock_desc.l_req_mode, - lustre_msg_buf(req->rq_reqmsg, 1), - req->rq_reqmsg->buflens[1], - &dlm_rep->lock_handle); - if (err != ELDLM_OK) - GOTO(out, err); - - err = ldlm_local_lock_enqueue(&dlm_rep->lock_handle, - &dlm_rep->lock_extent, - &dlm_rep->flags, - callback, callback); - if (err != ELDLM_OK) - GOTO(out, err); - - lock = ldlm_handle2object(&dlm_rep->lock_handle); - memcpy(&lock->l_remote_handle, &dlm_req->lock_handle1, - sizeof(lock->l_remote_handle)); - lock->l_connection = ptlrpc_connection_addref(req->rq_connection); - EXIT; - out: - req->rq_status = err; - CDEBUG(D_INFO, "err = %d\n", err); - - if (ptlrpc_reply(svc, req)) - LBUG(); - - if (!err) { - ldlm_reprocess_all(lock->l_resource); - } - - return 0; -} - -static int _ldlm_convert(struct ptlrpc_service *svc, struct ptlrpc_request *req) -{ - struct ldlm_request *dlm_req, *dlm_rep; - struct ldlm_resource *res; - int rc, size = sizeof(*dlm_rep); - ENTRY; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) { - CERROR("out of memory\n"); - RETURN(-ENOMEM); - } - dlm_req = lustre_msg_buf(req->rq_reqmsg, 0); - dlm_rep = lustre_msg_buf(req->rq_repmsg, 0); - dlm_rep->flags = dlm_req->flags; - - res = ldlm_local_lock_convert(&dlm_req->lock_handle1, - dlm_req->lock_desc.l_req_mode, - &dlm_rep->flags); - req->rq_status = 0; - if (ptlrpc_reply(svc, req) != 0) - LBUG(); - - ldlm_reprocess_all(res); - - RETURN(0); -} - -static int _ldlm_cancel(struct ptlrpc_service *svc, struct ptlrpc_request *req) -{ - struct ldlm_request *dlm_req; - struct ldlm_lock *lock; - struct ldlm_resource *res; - int rc; - ENTRY; - - rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) { - CERROR("out of memory\n"); - RETURN(-ENOMEM); - } - dlm_req = lustre_msg_buf(req->rq_reqmsg, 0); - - lock = ldlm_handle2object(&dlm_req->lock_handle1); - res = ldlm_local_lock_cancel(lock); - req->rq_status = 0; - if (ptlrpc_reply(svc, req) != 0) - LBUG(); - - if (res != NULL) - ldlm_reprocess_all(res); - - RETURN(0); -} - -static int _ldlm_callback(struct ptlrpc_service *svc, - struct ptlrpc_request *req) -{ - struct ldlm_request *dlm_req; - struct ldlm_lock *lock1, *lock2; - int rc; - ENTRY; - - rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) { - CERROR("out of memory\n"); - RETURN(-ENOMEM); - } - dlm_req = lustre_msg_buf(req->rq_reqmsg, 0); - - /* We must send the reply first, so that the thread is free to handle - * any requests made in common_callback() */ - rc = ptlrpc_reply(svc, req); - if (rc != 0) - RETURN(rc); - - lock1 = ldlm_handle2object(&dlm_req->lock_handle1); - lock2 = ldlm_handle2object(&dlm_req->lock_handle2); - - common_callback(lock1, lock2, dlm_req->lock_desc.l_granted_mode, NULL, - 0); - RETURN(0); -} - -static int ldlm_handle(struct obd_device *dev, struct ptlrpc_service *svc, - struct ptlrpc_request *req) -{ - int rc; - ENTRY; - - rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen); - if (rc) { - CERROR("lustre_ldlm: Invalid request\n"); - GOTO(out, rc); - } - - if (req->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) { - CERROR("lustre_ldlm: wrong packet type sent %d\n", - req->rq_reqmsg->type); - GOTO(out, rc = -EINVAL); - } - - switch (req->rq_reqmsg->opc) { - case LDLM_ENQUEUE: - CDEBUG(D_INODE, "enqueue\n"); - OBD_FAIL_RETURN(OBD_FAIL_LDLM_ENQUEUE, 0); - rc = _ldlm_enqueue(dev, svc, req); - break; - - case LDLM_CONVERT: - CDEBUG(D_INODE, "convert\n"); - OBD_FAIL_RETURN(OBD_FAIL_LDLM_CONVERT, 0); - rc = _ldlm_convert(svc, req); - break; - - case LDLM_CANCEL: - CDEBUG(D_INODE, "cancel\n"); - OBD_FAIL_RETURN(OBD_FAIL_LDLM_CANCEL, 0); - rc = _ldlm_cancel(svc, req); - break; - - case LDLM_CALLBACK: - CDEBUG(D_INODE, "callback\n"); - OBD_FAIL_RETURN(OBD_FAIL_LDLM_CALLBACK, 0); - rc = _ldlm_callback(svc, req); - break; - - default: - rc = ptlrpc_error(svc, req); - RETURN(rc); - } - - EXIT; -out: - if (rc) - RETURN(ptlrpc_error(svc, req)); - return 0; -} - -static int ldlm_iocontrol(long cmd, struct obd_conn *conn, int len, void *karg, - void *uarg) -{ - struct obd_device *obddev = conn->oc_dev; - struct ptlrpc_connection *connection; - int err; - ENTRY; - - if (_IOC_TYPE(cmd) != IOC_LDLM_TYPE || _IOC_NR(cmd) < IOC_LDLM_MIN_NR || - _IOC_NR(cmd) > IOC_LDLM_MAX_NR) { - CDEBUG(D_IOCTL, "invalid ioctl (type %ld, nr %ld, size %ld)\n", - _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd)); - RETURN(-EINVAL); - } - - ptlrpc_init_client(NULL, NULL, - LDLM_REQUEST_PORTAL, LDLM_REPLY_PORTAL, - obddev->u.ldlm.ldlm_client); - connection = ptlrpc_uuid_to_connection("ldlm"); - if (!connection) - CERROR("No LDLM UUID found: assuming ldlm is local.\n"); - - switch (cmd) { - case IOC_LDLM_TEST: { - err = ldlm_test(obddev, connection); - CERROR("-- done err %d\n", err); - GOTO(out, err); - } - default: - GOTO(out, err = -EINVAL); - } - - out: - if (connection) - ptlrpc_put_connection(connection); - return err; -} - -static int ldlm_setup(struct obd_device *obddev, obd_count len, void *buf) -{ - struct ldlm_obd *ldlm = &obddev->u.ldlm; - int err; - ENTRY; - - obddev->obd_namespace = ldlm_namespace_new(obddev, 0); - if (obddev->obd_namespace == NULL) - LBUG(); - - ldlm->ldlm_service = - ptlrpc_init_svc(64 * 1024, LDLM_REQUEST_PORTAL, - LDLM_REPLY_PORTAL, "self", ldlm_handle); - if (!ldlm->ldlm_service) - LBUG(); - - err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm"); - if (err) { - CERROR("cannot start thread\n"); - LBUG(); - } - err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm"); - if (err) { - CERROR("cannot start thread\n"); - LBUG(); - } - - OBD_ALLOC(ldlm->ldlm_client, sizeof(*ldlm->ldlm_client)); - if (ldlm->ldlm_client == NULL) - LBUG(); - ptlrpc_init_client(NULL, NULL, - LDLM_REQUEST_PORTAL, LDLM_REPLY_PORTAL, - ldlm->ldlm_client); - - MOD_INC_USE_COUNT; - RETURN(0); -} - -static int ldlm_cleanup(struct obd_device *obddev) -{ - struct ldlm_obd *ldlm = &obddev->u.ldlm; - ENTRY; - - ldlm_namespace_free(obddev->obd_namespace); - - ptlrpc_stop_all_threads(ldlm->ldlm_service); - rpc_unregister_service(ldlm->ldlm_service); - - if (!list_empty(&ldlm->ldlm_service->srv_reqs)) { - // XXX reply with errors and clean up - CERROR("Request list not empty!\n"); - } - - OBD_FREE(ldlm->ldlm_client, sizeof(*ldlm->ldlm_client)); - OBD_FREE(ldlm->ldlm_service, sizeof(*ldlm->ldlm_service)); - - MOD_DEC_USE_COUNT; - RETURN(0); -} - -struct obd_ops ldlm_obd_ops = { - o_iocontrol: ldlm_iocontrol, - o_setup: ldlm_setup, - o_cleanup: ldlm_cleanup, - o_connect: gen_connect, - o_disconnect: gen_disconnect -}; - - -static int __init ldlm_init(void) -{ - int rc = obd_register_type(&ldlm_obd_ops, OBD_LDLM_DEVICENAME); - if (rc != 0) - return rc; - - ldlm_resource_slab = kmem_cache_create("ldlm_resources", - sizeof(struct ldlm_resource), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ldlm_resource_slab == NULL) - return -ENOMEM; - - ldlm_lock_slab = kmem_cache_create("ldlm_locks", - sizeof(struct ldlm_lock), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ldlm_lock_slab == NULL) { - kmem_cache_destroy(ldlm_resource_slab); - return -ENOMEM; - } - - return 0; -} - -static void __exit ldlm_exit(void) -{ - obd_unregister_type(OBD_LDLM_DEVICENAME); - kmem_cache_destroy(ldlm_resource_slab); - kmem_cache_destroy(ldlm_lock_slab); -} - -EXPORT_SYMBOL(ldlm_local_lock_match); -EXPORT_SYMBOL(ldlm_lock_addref); -EXPORT_SYMBOL(ldlm_lock_decref); -EXPORT_SYMBOL(ldlm_cli_convert); -EXPORT_SYMBOL(ldlm_cli_enqueue); -EXPORT_SYMBOL(ldlm_handle2object); -EXPORT_SYMBOL(ldlm_test); -EXPORT_SYMBOL(ldlm_lock_dump); -EXPORT_SYMBOL(ldlm_namespace_new); -EXPORT_SYMBOL(ldlm_namespace_free); - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Lustre Lock Management Module v0.1"); -MODULE_LICENSE("GPL"); - -module_init(ldlm_init); -module_exit(ldlm_exit); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c deleted file mode 100644 index 9275214..0000000 --- a/lustre/ldlm/ldlm_request.c +++ /dev/null @@ -1,252 +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 code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Cluster File Systems, Inc. - */ - -#define DEBUG_SUBSYSTEM S_LDLM - -#include - -int ldlm_cli_enqueue(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock_handle, - __u64 *res_id, - __u32 type, - struct ldlm_extent *req_ex, - ldlm_mode_t mode, - int *flags, - void *data, - __u32 data_len, - struct ldlm_handle *lockh) -{ - struct ldlm_lock *lock; - struct ldlm_request *body; - struct ldlm_reply *reply; - struct ptlrpc_request *req; - char *bufs[2] = {NULL, data}; - int rc, size[2] = {sizeof(*body), data_len}; - ENTRY; - - *flags = 0; - rc = ldlm_local_lock_create(ns, parent_lock_handle, res_id, type, mode, - NULL, 0, lockh); - if (rc != ELDLM_OK) - GOTO(out, rc); - - lock = ldlm_handle2object(lockh); - - req = ptlrpc_prep_req(cl, conn, LDLM_ENQUEUE, 2, size, bufs); - if (!req) - GOTO(out, rc = -ENOMEM); - - /* Dump all of this data into the request buffer */ - body = lustre_msg_buf(req->rq_reqmsg, 0); - body->lock_desc.l_resource.lr_type = type; - memcpy(body->lock_desc.l_resource.lr_name, res_id, - sizeof(body->lock_desc.l_resource.lr_name)); - - body->lock_desc.l_req_mode = mode; - if (req_ex) - memcpy(&body->lock_desc.l_extent, req_ex, - sizeof(body->lock_desc.l_extent)); - body->flags = *flags; - - memcpy(&body->lock_handle1, lockh, sizeof(body->lock_handle1)); - - if (parent_lock_handle) - memcpy(&body->lock_handle2, parent_lock_handle, - sizeof(body->lock_handle2)); - - /* Continue as normal. */ - size[0] = sizeof(*reply); - req->rq_replen = lustre_msg_size(1, size); - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - if (rc != ELDLM_OK) { - spin_lock(&lock->l_resource->lr_lock); - ldlm_resource_put(lock->l_resource); - spin_unlock(&lock->l_resource->lr_lock); - ldlm_lock_free(lock); - GOTO(out, rc); - } - - lock->l_connection = conn; - lock->l_client = cl; - reply = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&lock->l_remote_handle, &reply->lock_handle, - sizeof(lock->l_remote_handle)); - memcpy(req_ex, &reply->lock_extent, sizeof(*req_ex)); - *flags = reply->flags; - - CDEBUG(D_INFO, "remote handle: %p, flags: %d\n", - (void *)(unsigned long)reply->lock_handle.addr, *flags); - CDEBUG(D_INFO, "extent: %Lu -> %Lu\n", - (unsigned long long)reply->lock_extent.start, - (unsigned long long)reply->lock_extent.end); - - ptlrpc_free_req(req); - - rc = ldlm_local_lock_enqueue(lockh, req_ex, flags, NULL, NULL); - - if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | - LDLM_FL_BLOCK_CONV)) { - /* Go to sleep until the lock is granted. */ - /* FIXME: or cancelled. */ - CDEBUG(D_NET, "enqueue returned a blocked lock (%p), " - "going to sleep.\n", lock); - ldlm_lock_dump(lock); - wait_event_interruptible(lock->l_waitq, lock->l_req_mode == - lock->l_granted_mode); - CDEBUG(D_NET, "waking up, the lock must be granted.\n"); - } - EXIT; - out: - return rc; -} - -int ldlm_cli_callback(struct ldlm_lock *lock, struct ldlm_lock *new, - void *data, __u32 data_len) -{ - struct ldlm_request *body; - struct ptlrpc_request *req; - struct obd_device *obddev = lock->l_resource->lr_namespace->ns_obddev; - struct ptlrpc_client *cl = obddev->u.ldlm.ldlm_client; - int rc, size[2] = {sizeof(*body), data_len}; - char *bufs[2] = {NULL, data}; - ENTRY; - - req = ptlrpc_prep_req(cl, lock->l_connection, LDLM_CALLBACK, 2, size, - bufs); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0); - memcpy(&body->lock_handle1, &lock->l_remote_handle, - sizeof(body->lock_handle1)); - - if (new == NULL) { - CDEBUG(D_NET, "Sending granted AST\n"); - ldlm_lock2desc(lock, &body->lock_desc); - } else { - CDEBUG(D_NET, "Sending blocked AST\n"); - ldlm_lock2desc(new, &body->lock_desc); - ldlm_object2handle(new, &body->lock_handle2); - } - - req->rq_replen = lustre_msg_size(0, NULL); - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - ptlrpc_free_req(req); - - EXIT; - out: - return rc; -} - -int ldlm_cli_convert(struct ptlrpc_client *cl, struct ldlm_handle *lockh, - int new_mode, int *flags) -{ - struct ldlm_request *body; - struct ldlm_lock *lock; - struct ldlm_resource *res; - struct ptlrpc_request *req; - int rc, size[2] = {sizeof(*body), 0}; - char *bufs[2] = {NULL, NULL}; - ENTRY; - - lock = ldlm_handle2object(lockh); - *flags = 0; - - size[1] = lock->l_data_len; - bufs[1] = lock->l_data; - req = ptlrpc_prep_req(cl, lock->l_connection, LDLM_CONVERT, 2, size, - bufs); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0); - memcpy(&body->lock_handle1, &lock->l_remote_handle, - sizeof(body->lock_handle1)); - - body->lock_desc.l_req_mode = new_mode; - body->flags = *flags; - - req->rq_replen = lustre_msg_size(1, size); - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - if (rc != ELDLM_OK) - GOTO(out, rc); - - body = lustre_msg_buf(req->rq_repmsg, 0); - res = ldlm_local_lock_convert(lockh, new_mode, &body->flags); - if (res != NULL) - ldlm_reprocess_all(res); - if (lock->l_req_mode != lock->l_granted_mode) { - /* Go to sleep until the lock is granted. */ - /* FIXME: or cancelled. */ - CDEBUG(D_NET, "convert returned a blocked lock, " - "going to sleep.\n"); - wait_event_interruptible(lock->l_waitq, lock->l_req_mode == - lock->l_granted_mode); - CDEBUG(D_NET, "waking up, the lock must be granted.\n"); - } - EXIT; - out: - ptlrpc_free_req(req); - return rc; -} - -int ldlm_cli_cancel(struct ptlrpc_client *cl, struct ldlm_lock *lock) -{ - struct ldlm_request *body; - struct ptlrpc_request *req; - struct ldlm_resource *res; - int rc, size[2] = {sizeof(*body), 0}; - char *bufs[2] = {NULL, NULL}; - ENTRY; - - if (lock->l_data_len == sizeof(struct inode)) { - /* FIXME: do something better than throwing away everything */ - struct inode *inode = lock->l_data; - if (inode == NULL) - LBUG(); - down(&inode->i_sem); - invalidate_inode_pages(inode); - up(&inode->i_sem); - } - - size[1] = lock->l_data_len; - bufs[1] = lock->l_data; - req = ptlrpc_prep_req(cl, lock->l_connection, LDLM_CANCEL, 2, size, - bufs); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0); - memcpy(&body->lock_handle1, &lock->l_remote_handle, - sizeof(body->lock_handle1)); - - req->rq_replen = lustre_msg_size(0, NULL); - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - ptlrpc_free_req(req); - if (rc != ELDLM_OK) - GOTO(out, rc); - - res = ldlm_local_lock_cancel(lock); - if (res != NULL) - ldlm_reprocess_all(res); - EXIT; - out: - return rc; -} diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c deleted file mode 100644 index 4a8dcde..0000000 --- a/lustre/ldlm/ldlm_resource.c +++ /dev/null @@ -1,342 +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 code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Cluster File Systems, Inc. - */ - -#define DEBUG_SUBSYSTEM S_LDLM - -#include - -kmem_cache_t *ldlm_resource_slab, *ldlm_lock_slab; - -struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obddev, - __u32 local) -{ - struct ldlm_namespace *ns; - struct list_head *bucket; - - OBD_ALLOC(ns, sizeof(*ns)); - if (!ns) { - LBUG(); - RETURN(NULL); - } - ns->ns_hash = vmalloc(sizeof(*ns->ns_hash) * RES_HASH_SIZE); - if (!ns->ns_hash) { - OBD_FREE(ns, sizeof(*ns)); - LBUG(); - RETURN(NULL); - } - - ns->ns_obddev = obddev; - INIT_LIST_HEAD(&ns->ns_root_list); - ns->ns_lock = SPIN_LOCK_UNLOCKED; - ns->ns_refcount = 0; - ns->ns_local = local; - - for (bucket = ns->ns_hash + RES_HASH_SIZE - 1; bucket >= ns->ns_hash; - bucket--) - INIT_LIST_HEAD(bucket); - - return ns; -} - -static int cleanup_resource(struct ldlm_resource *res, struct list_head *q) -{ - struct list_head *tmp, *pos; - int rc = 0; - - list_for_each_safe(tmp, pos, q) { - struct ldlm_lock *lock; - - if (rc) { - /* Res was already cleaned up. */ - LBUG(); - } - - lock = list_entry(tmp, struct ldlm_lock, l_res_link); - spin_lock(&lock->l_lock); - ldlm_resource_del_lock(lock); - ldlm_lock_free(lock); - - rc = ldlm_resource_put(res); - } - - return rc; -} - -int ldlm_namespace_free(struct ldlm_namespace *ns) -{ - struct list_head *tmp, *pos; - int i, rc; - - /* We should probably take the ns_lock, but then ldlm_resource_put - * couldn't take it. Hmm. */ - for (i = 0; i < RES_HASH_SIZE; i++) { - list_for_each_safe(tmp, pos, &(ns->ns_hash[i])) { - struct ldlm_resource *res; - res = list_entry(tmp, struct ldlm_resource, lr_hash); - - spin_lock(&res->lr_lock); - rc = cleanup_resource(res, &res->lr_granted); - if (!rc) - rc = cleanup_resource(res, &res->lr_converting); - if (!rc) - rc = cleanup_resource(res, &res->lr_waiting); - - if (rc == 0) { - CERROR("Resource refcount nonzero after lock " - "cleanup; forcing cleanup.\n"); - res->lr_refcount = 1; - rc = ldlm_resource_put(res); - } - } - } - - vfree(ns->ns_hash /* , sizeof(struct list_head) * RES_HASH_SIZE */); - OBD_FREE(ns, sizeof(*ns)); - - return ELDLM_OK; -} - -static __u32 ldlm_hash_fn(struct ldlm_resource *parent, __u64 *name) -{ - __u32 hash = 0; - int i; - - for (i = 0; i < RES_NAME_SIZE; i++) - hash += name[i]; - - hash += (__u32)((unsigned long)parent >> 4); - - return (hash & RES_HASH_MASK); -} - -static struct ldlm_resource *ldlm_resource_new(void) -{ - struct ldlm_resource *res; - - res = kmem_cache_alloc(ldlm_resource_slab, SLAB_KERNEL); - if (res == NULL) { - LBUG(); - return NULL; - } - memset(res, 0, sizeof(*res)); - - INIT_LIST_HEAD(&res->lr_children); - INIT_LIST_HEAD(&res->lr_childof); - INIT_LIST_HEAD(&res->lr_granted); - INIT_LIST_HEAD(&res->lr_converting); - INIT_LIST_HEAD(&res->lr_waiting); - - res->lr_lock = SPIN_LOCK_UNLOCKED; - res->lr_refcount = 1; - - return res; -} - -/* Args: locked namespace - * Returns: newly-allocated, referenced, unlocked resource */ -static struct ldlm_resource *ldlm_resource_add(struct ldlm_namespace *ns, - struct ldlm_resource *parent, - __u64 *name, __u32 type) -{ - struct list_head *bucket; - struct ldlm_resource *res; - ENTRY; - - if (type < 0 || type > LDLM_MAX_TYPE) { - LBUG(); - RETURN(NULL); - } - - res = ldlm_resource_new(); - if (!res) { - LBUG(); - RETURN(NULL); - } - - memcpy(res->lr_name, name, sizeof(res->lr_name)); - res->lr_namespace = ns; - ns->ns_refcount++; - - res->lr_type = type; - res->lr_most_restr = LCK_NL; - - bucket = ns->ns_hash + ldlm_hash_fn(parent, name); - list_add(&res->lr_hash, bucket); - - if (parent == NULL) { - res->lr_parent = res; - list_add(&res->lr_rootlink, &ns->ns_root_list); - } else { - res->lr_parent = parent; - list_add(&res->lr_childof, &parent->lr_children); - } - - RETURN(res); -} - -/* Args: unlocked namespace - * Locks: takes and releases ns->ns_lock and res->lr_lock - * Returns: referenced, unlocked ldlm_resource or NULL */ -struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, - struct ldlm_resource *parent, - __u64 *name, __u32 type, int create) -{ - struct list_head *bucket; - struct list_head *tmp = bucket; - struct ldlm_resource *res = NULL; - - ENTRY; - - if (ns->ns_hash == NULL) - RETURN(NULL); - - spin_lock(&ns->ns_lock); - bucket = ns->ns_hash + ldlm_hash_fn(parent, name); - - list_for_each(tmp, bucket) { - struct ldlm_resource *chk; - chk = list_entry(tmp, struct ldlm_resource, lr_hash); - - if (memcmp(chk->lr_name, name, sizeof(chk->lr_name)) == 0) { - res = chk; - spin_lock(&res->lr_lock); - res->lr_refcount++; - spin_unlock(&res->lr_lock); - EXIT; - break; - } - } - - if (res == NULL && create) - res = ldlm_resource_add(ns, parent, name, type); - spin_unlock(&ns->ns_lock); - - RETURN(res); -} - -/* Args: locked resource - * Locks: takes and releases res->lr_lock - * takes and releases ns->ns_lock iff res->lr_refcount falls to 0 - */ -int ldlm_resource_put(struct ldlm_resource *res) -{ - int rc = 0; - - if (res->lr_refcount == 1) { - struct ldlm_namespace *ns = res->lr_namespace; - ENTRY; - - spin_unlock(&res->lr_lock); - spin_lock(&ns->ns_lock); - spin_lock(&res->lr_lock); - - if (res->lr_refcount != 1) { - spin_unlock(&ns->ns_lock); - goto out; - } - - if (!list_empty(&res->lr_granted)) - LBUG(); - - if (!list_empty(&res->lr_converting)) - LBUG(); - - if (!list_empty(&res->lr_waiting)) - LBUG(); - - if (!list_empty(&res->lr_children)) - LBUG(); - - ns->ns_refcount--; - list_del(&res->lr_hash); - list_del(&res->lr_rootlink); - list_del(&res->lr_childof); - - kmem_cache_free(ldlm_resource_slab, res); - spin_unlock(&ns->ns_lock); - rc = 1; - } else { - ENTRY; - out: - res->lr_refcount--; - if (res->lr_refcount < 0) - LBUG(); - } - - RETURN(rc); -} - -/* Must be called with resource->lr_lock taken */ -void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, - struct ldlm_lock *lock) -{ - list_add(&lock->l_res_link, head); - res->lr_refcount++; -} - -/* Must be called with resource->lr_lock taken */ -void ldlm_resource_del_lock(struct ldlm_lock *lock) -{ - list_del_init(&lock->l_res_link); - lock->l_resource->lr_refcount--; -} - -int ldlm_get_resource_handle(struct ldlm_resource *res, struct ldlm_handle *h) -{ - LBUG(); - return 0; -} - -void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc) -{ - desc->lr_type = res->lr_type; - memcpy(desc->lr_name, res->lr_name, sizeof(desc->lr_name)); - memcpy(desc->lr_version, res->lr_version, sizeof(desc->lr_version)); -} - -void ldlm_resource_dump(struct ldlm_resource *res) -{ - struct list_head *tmp; - char name[256]; - - if (RES_NAME_SIZE != 3) - LBUG(); - - snprintf(name, sizeof(name), "%Lx %Lx %Lx", - (unsigned long long)res->lr_name[0], - (unsigned long long)res->lr_name[1], - (unsigned long long)res->lr_name[2]); - - CDEBUG(D_OTHER, "--- Resource: %p (%s)\n", res, name); - CDEBUG(D_OTHER, "Namespace: %p\n", res->lr_namespace); - CDEBUG(D_OTHER, "Parent: %p, root: %p\n", res->lr_parent, res->lr_root); - - CDEBUG(D_OTHER, "Granted locks:\n"); - list_for_each(tmp, &res->lr_granted) { - struct ldlm_lock *lock; - lock = list_entry(tmp, struct ldlm_lock, l_res_link); - ldlm_lock_dump(lock); - } - - CDEBUG(D_OTHER, "Converting locks:\n"); - list_for_each(tmp, &res->lr_converting) { - struct ldlm_lock *lock; - lock = list_entry(tmp, struct ldlm_lock, l_res_link); - ldlm_lock_dump(lock); - } - - CDEBUG(D_OTHER, "Waiting locks:\n"); - list_for_each(tmp, &res->lr_waiting) { - struct ldlm_lock *lock; - lock = list_entry(tmp, struct ldlm_lock, l_res_link); - ldlm_lock_dump(lock); - } -} diff --git a/lustre/ldlm/ldlm_test.c b/lustre/ldlm/ldlm_test.c deleted file mode 100644 index fc88099..0000000 --- a/lustre/ldlm/ldlm_test.c +++ /dev/null @@ -1,165 +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 code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Cluster File Systems, Inc. - */ - -#define DEBUG_SUBSYSTEM S_LDLM - -#include - -static int ldlm_test_callback(struct ldlm_lock *lock, struct ldlm_lock *new, - void *data, __u32 data_len) -{ - printk("ldlm_test_callback: lock=%p, new=%p\n", lock, new); - return 0; -} - -int ldlm_test_basics(struct obd_device *obddev) -{ - struct ldlm_namespace *ns; - struct ldlm_resource *res; - __u64 res_id[RES_NAME_SIZE] = {1, 2, 3}; - ldlm_error_t err; - struct ldlm_handle lockh_1, lockh_2; - int flags; - - ns = ldlm_namespace_new(obddev, 0); - if (ns == NULL) - LBUG(); - - err = ldlm_local_lock_create(ns, NULL, res_id, LDLM_PLAIN, LCK_CR, - NULL, 0, &lockh_1); - err = ldlm_local_lock_enqueue(&lockh_1, NULL, &flags, - ldlm_test_callback, ldlm_test_callback); - if (err != ELDLM_OK) - LBUG(); - - err = ldlm_local_lock_create(ns, NULL, res_id, LDLM_PLAIN, LCK_EX, - NULL, 0, &lockh_2); - err = ldlm_local_lock_enqueue(&lockh_2, NULL, &flags, - ldlm_test_callback, ldlm_test_callback); - if (err != ELDLM_OK) - LBUG(); - if (!(flags & LDLM_FL_BLOCK_GRANTED)) - LBUG(); - - res = ldlm_resource_get(ns, NULL, res_id, LDLM_PLAIN, 1); - if (res == NULL) - LBUG(); - ldlm_resource_dump(res); - - res = ldlm_local_lock_convert(&lockh_1, LCK_NL, &flags); - if (res != NULL) - ldlm_reprocess_all(res); - - ldlm_resource_dump(res); - ldlm_namespace_free(ns); - - return 0; -} - -int ldlm_test_extents(struct obd_device *obddev) -{ - struct ldlm_namespace *ns; - struct ldlm_resource *res; - struct ldlm_lock *lock; - __u64 res_id[RES_NAME_SIZE] = {0, 0, 0}; - struct ldlm_extent ext1 = {4, 6}, ext2 = {6, 9}, ext3 = {10, 11}; - struct ldlm_handle ext1_h, ext2_h, ext3_h; - ldlm_error_t err; - int flags; - - ns = ldlm_namespace_new(obddev, 0); - if (ns == NULL) - LBUG(); - - flags = 0; - err = ldlm_local_lock_create(ns, NULL, res_id, LDLM_EXTENT, LCK_PR, - NULL, 0, &ext1_h); - err = ldlm_local_lock_enqueue(&ext1_h, &ext1, &flags, NULL, NULL); - if (err != ELDLM_OK) - LBUG(); - if (!(flags & LDLM_FL_LOCK_CHANGED)) - LBUG(); - - flags = 0; - err = ldlm_local_lock_create(ns, NULL, res_id, LDLM_EXTENT, LCK_PR, - NULL, 0, &ext2_h); - err = ldlm_local_lock_enqueue(&ext2_h, &ext2, &flags, NULL, NULL); - if (err != ELDLM_OK) - LBUG(); - if (!(flags & LDLM_FL_LOCK_CHANGED)) - LBUG(); - - flags = 0; - err = ldlm_local_lock_create(ns, NULL, res_id, LDLM_EXTENT, LCK_EX, - NULL, 0, &ext3_h); - err = ldlm_local_lock_enqueue(&ext3_h, &ext3, &flags, NULL, NULL); - if (err != ELDLM_OK) - LBUG(); - if (!(flags & LDLM_FL_BLOCK_GRANTED)) - LBUG(); - if (flags & LDLM_FL_LOCK_CHANGED) - LBUG(); - - /* Convert/cancel blocking locks */ - flags = 0; - res = ldlm_local_lock_convert(&ext1_h, LCK_NL, &flags); - if (res != NULL) - ldlm_reprocess_all(res); - - flags = 0; - lock = ldlm_handle2object(&ext2_h); - res = ldlm_local_lock_cancel(lock); - if (res != NULL) - ldlm_reprocess_all(res); - - /* Dump the results */ - res = ldlm_resource_get(ns, NULL, res_id, LDLM_EXTENT, 0); - if (res == NULL) - LBUG(); - ldlm_resource_dump(res); - ldlm_namespace_free(ns); - - return 0; -} - -static int ldlm_test_network(struct obd_device *obddev, - struct ptlrpc_connection *conn) -{ - struct ldlm_obd *ldlm = &obddev->u.ldlm; - - __u64 res_id[RES_NAME_SIZE] = {1, 2, 3}; - struct ldlm_extent ext = {4, 6}; - struct ldlm_handle lockh1; - int flags = 0; - ldlm_error_t err; - - err = ldlm_cli_enqueue(ldlm->ldlm_client, conn, obddev->obd_namespace, - NULL, res_id, LDLM_EXTENT, &ext, LCK_PR, &flags, - NULL, 0, &lockh1); - CERROR("ldlm_cli_enqueue: %d\n", err); - - RETURN(err); -} - -int ldlm_test(struct obd_device *obddev, struct ptlrpc_connection *conn) -{ - int rc; - rc = ldlm_test_basics(obddev); - if (rc) - RETURN(rc); - - rc = ldlm_test_extents(obddev); - if (rc) - RETURN(rc); - - rc = ldlm_test_network(obddev, conn); - RETURN(rc); -} diff --git a/lustre/lib/.cvsignore b/lustre/lib/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/lib/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/lib/Makefile.am b/lustre/lib/Makefile.am deleted file mode 100644 index ce88106..0000000 --- a/lustre/lib/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -EXTRA_DIST = mds_updates.c obd_pack.c page.c - -include $(top_srcdir)/Rules diff --git a/lustre/lib/debug.c b/lustre/lib/debug.c deleted file mode 100644 index c3a2721..0000000 --- a/lustre/lib/debug.c +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Helper routines for dumping data structs for debugging. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copryright (C) 2002 Cluster File Systems, Inc. - * - */ - -#define DEBUG_SUBSYSTEM D_OTHER - -#include -#include - -int dump_ioo(struct obd_ioobj *ioo) -{ - CERROR("obd_ioobj: ioo_id=%Ld, ioo_gr=%Ld, ioo_type=%d, ioo_bufct=%d\n", - ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type, ioo->ioo_bufcnt); - return -EINVAL; -} - -int dump_lniobuf(struct niobuf_local *nb) -{ - CERROR("niobuf_local: addr=%p, offset=%Ld, len=%d, xid=%d, page=%p\n", - nb->addr, nb->offset, nb->len, nb->xid, nb->page); - CERROR("nb->page: index = %ld\n", nb->page ? nb->page->index : -1); - - return -EINVAL; -} - -int dump_rniobuf(struct niobuf_remote *nb) -{ - CERROR("niobuf_remote: offset=%Ld, len=%d, flags=%x, xid=%d\n", - nb->offset, nb->len, nb->flags, nb->xid); - - return -EINVAL; -} - -int dump_obdo(struct obdo *oa) -{ - CERROR("obdo: o_valid = %08x\n", oa->o_valid); - if (oa->o_valid & OBD_MD_FLID) - CERROR("obdo: o_id = %Ld\n", oa->o_id); - if (oa->o_valid & OBD_MD_FLATIME) - CERROR("obdo: o_atime = %Ld\n", oa->o_atime); - if (oa->o_valid & OBD_MD_FLMTIME) - CERROR("obdo: o_mtime = %Ld\n", oa->o_mtime); - if (oa->o_valid & OBD_MD_FLCTIME) - CERROR("obdo: o_ctime = %Ld\n", oa->o_ctime); - if (oa->o_valid & OBD_MD_FLSIZE) - CERROR("obdo: o_size = %Ld\n", oa->o_size); - if (oa->o_valid & OBD_MD_FLBLOCKS) /* allocation of space */ - CERROR("obdo: o_blocks = %Ld\n", oa->o_blocks); - if (oa->o_valid & OBD_MD_FLBLKSZ) - CERROR("obdo: o_blksize = %d\n", oa->o_blksize); - if (oa->o_valid & OBD_MD_FLMODE) - CERROR("obdo: o_mode = %o\n", oa->o_mode); - if (oa->o_valid & OBD_MD_FLUID) - CERROR("obdo: o_uid = %d\n", oa->o_uid); - if (oa->o_valid & OBD_MD_FLGID) - CERROR("obdo: o_gid = %d\n", oa->o_gid); - if (oa->o_valid & OBD_MD_FLFLAGS) - CERROR("obdo: o_flags = %x\n", oa->o_flags); - if (oa->o_valid & OBD_MD_FLNLINK) - CERROR("obdo: o_nlink = %d\n", oa->o_nlink); - if (oa->o_valid & OBD_MD_FLGENER) - CERROR("obdo: o_generation = %d\n", oa->o_generation); - - return -EINVAL; -} - -/* XXX assumes only a single page in request */ -int dump_req(struct ptlrpc_request *req) -{ - struct ost_body *body = lustre_msg_buf(req->rq_reqmsg, 0); - struct obd_ioobj *ioo = lustre_msg_buf(req->rq_reqmsg, 1); - //struct niobuf *nb = lustre_msg_buf(req->rq_reqmsg, 2); - - CERROR("ost_body: connid = %d, data = %d\n", body->connid, body->data); - dump_obdo(&body->oa); - //dump_niobuf(nb); - dump_ioo(ioo); - - return -EINVAL; -} - diff --git a/lustre/lib/mds_updates.c b/lustre/lib/mds_updates.c deleted file mode 100644 index 2f49c34..0000000 --- a/lustre/lib/mds_updates.c +++ /dev/null @@ -1,319 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Lustre Light Update Records - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copryright (C) 2002 Cluster File Systems, Inc. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_MDS - -#include -#include -#include -#include - -void mds_pack_fid(struct ll_fid *fid) -{ - fid->id = HTON__u64(fid->id); - fid->generation = HTON__u32(fid->generation); - fid->f_type = HTON__u32(fid->f_type); -} - -static void mds_pack_body(struct mds_body *b) -{ - if (b == NULL) - LBUG(); - - mds_pack_fid(&b->fid1); - mds_pack_fid(&b->fid2); - b->objid = HTON__u64(b->objid); - b->size = HTON__u64(b->size); - b->valid = HTON__u32(b->valid); - b->mode = HTON__u32(b->mode); - b->uid = HTON__u32(b->uid); - b->gid = HTON__u32(b->gid); - b->mtime = HTON__u32(b->mtime); - b->ctime = HTON__u32(b->ctime); - b->atime = HTON__u32(b->atime); - b->flags = HTON__u32(b->flags); - b->major = HTON__u32(b->major); - b->minor = HTON__u32(b->minor); - b->ino = HTON__u32(b->ino); - b->nlink = HTON__u32(b->nlink); - b->generation = HTON__u32(b->generation); - b->last_xid = HTON__u32(b->last_xid); -} - -void mds_pack_req_body(struct ptlrpc_request *req) -{ - struct mds_body *b = lustre_msg_buf(req->rq_reqmsg, 0); - mds_pack_body(b); -} - -void mds_pack_rep_body(struct ptlrpc_request *req) -{ - struct mds_body *b = lustre_msg_buf(req->rq_repmsg, 0); - mds_pack_body(b); -} - - -/* packing of MDS records */ -void mds_create_pack(struct mds_rec_create *rec, struct inode *inode, - __u32 mode, __u64 id, __u32 uid, __u32 gid, __u64 time) -{ - /* XXX do something about time, uid, gid */ - rec->cr_opcode = HTON__u32(REINT_CREATE); - ll_inode2fid(&rec->cr_fid, inode); - rec->cr_mode = HTON__u32(mode); - rec->cr_id = HTON__u64(id); - rec->cr_uid = HTON__u32(uid); - rec->cr_gid = HTON__u32(gid); - rec->cr_time = HTON__u64(time); -} - -void mds_setattr_pack(struct mds_rec_setattr *rec, struct inode *inode, - struct iattr *iattr) -{ - rec->sa_opcode = HTON__u32(REINT_SETATTR); - ll_inode2fid(&rec->sa_fid, inode); - rec->sa_valid = HTON__u32(iattr->ia_valid); - rec->sa_mode = HTON__u32(iattr->ia_mode); - rec->sa_uid = HTON__u32(iattr->ia_uid); - rec->sa_gid = HTON__u32(iattr->ia_gid); - rec->sa_size = HTON__u64(iattr->ia_size); - rec->sa_atime = HTON__u64(iattr->ia_atime); - rec->sa_mtime = HTON__u64(iattr->ia_mtime); - rec->sa_ctime = HTON__u64(iattr->ia_ctime); - rec->sa_attr_flags = HTON__u32(iattr->ia_attr_flags); -} - -void mds_unlink_pack(struct mds_rec_unlink *rec, struct inode *inode, - struct inode *child) -{ - rec->ul_opcode = HTON__u32(REINT_UNLINK); - ll_inode2fid(&rec->ul_fid1, inode); - ll_inode2fid(&rec->ul_fid2, child); -} - -void mds_link_pack(struct mds_rec_link *rec, - struct inode *inode, struct inode *dir) -{ - rec->lk_opcode = HTON__u32(REINT_LINK); - ll_inode2fid(&rec->lk_fid1, inode); - ll_inode2fid(&rec->lk_fid2, dir); -} - -void mds_rename_pack(struct mds_rec_rename *rec, struct inode *srcdir, - struct inode *tgtdir) -{ - /* XXX do something about time, uid, gid */ - rec->rn_opcode = HTON__u32(REINT_RENAME); - ll_inode2fid(&rec->rn_fid1, srcdir); - ll_inode2fid(&rec->rn_fid2, tgtdir); -} - -/* unpacking */ -void mds_unpack_fid(struct ll_fid *fid) -{ - fid->id = NTOH__u64(fid->id); - fid->generation = NTOH__u32(fid->generation); - fid->f_type = NTOH__u32(fid->f_type); -} - -static void mds_unpack_body(struct mds_body *b) -{ - if (b == NULL) - LBUG(); - - mds_unpack_fid(&b->fid1); - mds_unpack_fid(&b->fid2); - b->objid = NTOH__u64(b->objid); - b->size = NTOH__u64(b->size); - b->valid = NTOH__u32(b->valid); - b->mode = NTOH__u32(b->mode); - b->uid = NTOH__u32(b->uid); - b->gid = NTOH__u32(b->gid); - b->mtime = NTOH__u32(b->mtime); - b->ctime = NTOH__u32(b->ctime); - b->atime = NTOH__u32(b->atime); - b->flags = NTOH__u32(b->flags); - b->major = NTOH__u32(b->major); - b->minor = NTOH__u32(b->minor); - b->ino = NTOH__u32(b->ino); - b->nlink = NTOH__u32(b->nlink); - b->generation = NTOH__u32(b->generation); - b->last_xid = NTOH__u32(b->last_xid); -} - - -void mds_unpack_req_body(struct ptlrpc_request *req) -{ - struct mds_body *b = lustre_msg_buf(req->rq_reqmsg, 0); - mds_unpack_body(b); -} - -void mds_unpack_rep_body(struct ptlrpc_request *req) -{ - struct mds_body *b = lustre_msg_buf(req->rq_repmsg, 0); - mds_unpack_body(b); -} - -static int mds_setattr_unpack(struct ptlrpc_request *req, - struct mds_update_record *r) -{ - struct iattr *attr = &r->ur_iattr; - struct mds_rec_setattr *rec = lustre_msg_buf(req->rq_reqmsg, 0); - ENTRY; - - if (req->rq_reqmsg->bufcount != 1 || - req->rq_reqmsg->buflens[0] != sizeof(*rec)) - RETURN(-EFAULT); - - r->ur_fid1 = &rec->sa_fid; - attr->ia_valid = NTOH__u32(rec->sa_valid); - attr->ia_mode = NTOH__u32(rec->sa_mode); - attr->ia_uid = NTOH__u32(rec->sa_uid); - attr->ia_gid = NTOH__u32(rec->sa_gid); - attr->ia_size = NTOH__u64(rec->sa_size); - attr->ia_atime = NTOH__u64(rec->sa_atime); - attr->ia_mtime = NTOH__u64(rec->sa_mtime); - attr->ia_ctime = NTOH__u64(rec->sa_ctime); - attr->ia_attr_flags = NTOH__u32(rec->sa_attr_flags); - RETURN(0); -} - -static int mds_create_unpack(struct ptlrpc_request *req, - struct mds_update_record *r) -{ - struct mds_rec_create *rec = lustre_msg_buf(req->rq_reqmsg, 0); - ENTRY; - - if (req->rq_reqmsg->bufcount != 3 || - req->rq_reqmsg->buflens[0] != sizeof(*rec)) - RETURN(-EFAULT); - - r->ur_fid1 = &rec->cr_fid; - r->ur_mode = NTOH__u32(rec->cr_mode); - r->ur_id = NTOH__u64(rec->cr_id); - r->ur_uid = NTOH__u32(rec->cr_uid); - r->ur_gid = NTOH__u32(rec->cr_gid); - r->ur_time = NTOH__u64(rec->cr_time); - - r->ur_name = lustre_msg_buf(req->rq_reqmsg, 1); - r->ur_namelen = req->rq_reqmsg->buflens[1]; - - r->ur_tgt = lustre_msg_buf(req->rq_reqmsg, 2); - r->ur_tgtlen = req->rq_reqmsg->buflens[2]; - RETURN(0); -} - -static int mds_link_unpack(struct ptlrpc_request *req, - struct mds_update_record *r) -{ - struct mds_rec_link *rec = lustre_msg_buf(req->rq_reqmsg, 0); - ENTRY; - - if (req->rq_reqmsg->bufcount != 2 || - req->rq_reqmsg->buflens[0] != sizeof(*rec)) - RETURN(-EFAULT); - - r->ur_fid1 = &rec->lk_fid1; - r->ur_fid2 = &rec->lk_fid2; - - r->ur_name = lustre_msg_buf(req->rq_reqmsg, 1); - r->ur_namelen = req->rq_reqmsg->buflens[1]; - RETURN(0); -} - -static int mds_unlink_unpack(struct ptlrpc_request *req, - struct mds_update_record *r) -{ - struct mds_rec_unlink *rec = lustre_msg_buf(req->rq_reqmsg, 0); - ENTRY; - - if (req->rq_reqmsg->bufcount != 2 || - req->rq_reqmsg->buflens[0] != sizeof(*rec)) - RETURN(-EFAULT); - - r->ur_fid1 = &rec->ul_fid1; - r->ur_fid2 = &rec->ul_fid2; - - r->ur_name = lustre_msg_buf(req->rq_reqmsg, 1); - r->ur_namelen = req->rq_reqmsg->buflens[1]; - RETURN(0); -} - -static int mds_rename_unpack(struct ptlrpc_request *req, - struct mds_update_record *r) -{ - struct mds_rec_rename *rec = lustre_msg_buf(req->rq_reqmsg, 0); - ENTRY; - - if (req->rq_reqmsg->bufcount != 3 || - req->rq_reqmsg->buflens[0] != sizeof(*rec)) - RETURN(-EFAULT); - - r->ur_fid1 = &rec->rn_fid1; - r->ur_fid2 = &rec->rn_fid2; - - r->ur_name = lustre_msg_buf(req->rq_reqmsg, 1); - r->ur_namelen = req->rq_reqmsg->buflens[1]; - - r->ur_tgt = lustre_msg_buf(req->rq_reqmsg, 2); - r->ur_tgtlen = req->rq_reqmsg->buflens[2]; - RETURN(0); -} - -typedef int (*update_unpacker)(struct ptlrpc_request *req, - struct mds_update_record *r); - -static update_unpacker mds_unpackers[REINT_MAX + 1] = { - [REINT_SETATTR] mds_setattr_unpack, - [REINT_CREATE] mds_create_unpack, - [REINT_LINK] mds_link_unpack, - [REINT_UNLINK] mds_unlink_unpack, - [REINT_RENAME] mds_rename_unpack, - [REINT_RECREATE] mds_create_unpack, -}; - -int mds_update_unpack(struct ptlrpc_request *req, struct mds_update_record *rec) -{ - struct mds_update_record_hdr *hdr = lustre_msg_buf(req->rq_reqmsg, 0); - int rc; - ENTRY; - - if (!hdr || req->rq_reqmsg->buflens[0] < sizeof(__u32)) - RETURN(-EFAULT); - - rec->ur_opcode = NTOH__u32(hdr->ur_opcode); - - if (rec->ur_opcode < 0 || rec->ur_opcode > REINT_MAX) - RETURN(-EFAULT); - - rc = mds_unpackers[rec->ur_opcode](req, rec); - RETURN(rc); -} diff --git a/lustre/lib/obd_pack.c b/lustre/lib/obd_pack.c deleted file mode 100644 index ec4bbbe..0000000 --- a/lustre/lib/obd_pack.c +++ /dev/null @@ -1,80 +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. - * - * (Un)packing of OST requests - * - */ - -#define DEBUG_SUBSYSTEM S_OST - -#include -#include - -void ost_pack_ioo(void **tmp, struct obdo *oa, int bufcnt) -{ - struct obd_ioobj *ioo = *tmp; - char *c = *tmp; - - ioo->ioo_id = HTON__u64(oa->o_id); - ioo->ioo_gr = HTON__u64(oa->o_gr); - ioo->ioo_type = HTON__u32(oa->o_mode); - ioo->ioo_bufcnt = HTON__u32(bufcnt); - *tmp = c + sizeof(*ioo); -} - -void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop) -{ - char *c = *tmp; - struct obd_ioobj *ioo = *tmp; - *ioop = *tmp; - - ioo->ioo_id = NTOH__u64(ioo->ioo_id); - ioo->ioo_gr = NTOH__u64(ioo->ioo_gr); - ioo->ioo_type = NTOH__u32(ioo->ioo_type); - ioo->ioo_bufcnt = NTOH__u32(ioo->ioo_bufcnt); - *tmp = c + sizeof(*ioo); -} - -void ost_pack_niobuf(void **tmp, __u64 offset, __u32 len, __u32 flags, - __u32 xid) -{ - struct niobuf_remote *nb = *tmp; - char *c = *tmp; - - nb->offset = HTON__u64(offset); - nb->len = HTON__u32(len); - nb->flags = HTON__u32(flags); - nb->xid = HTON__u32(xid); - *tmp = c + sizeof(*nb); -} - -void ost_unpack_niobuf(void **tmp, struct niobuf_remote **nbp) -{ - char *c = *tmp; - struct niobuf_remote *nb = *tmp; - - *nbp = *tmp; - - nb->offset = NTOH__u64(nb->offset); - nb->len = NTOH__u32(nb->len); - nb->flags = NTOH__u32(nb->flags); - - *tmp = c + sizeof(*nb); -} diff --git a/lustre/lib/page.c b/lustre/lib/page.c deleted file mode 100644 index 334b326..0000000 --- a/lustre/lib/page.c +++ /dev/null @@ -1,217 +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.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 -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_OST - -#include -#include - -/* - * Remove page from dirty list - */ -static void __set_page_clean(struct page *page) -{ - struct address_space *mapping = page->mapping; - struct inode *inode; - - if (!mapping) - return; - -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,9)) - spin_lock(&pagecache_lock); -#endif - - list_del(&page->list); - list_add(&page->list, &mapping->clean_pages); - - inode = mapping->host; - if (list_empty(&mapping->dirty_pages)) { - CDEBUG(D_INODE, "inode clean\n"); - inode->i_state &= ~I_DIRTY_PAGES; - } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,10)) - spin_unlock(&pagecache_lock); -#endif - EXIT; -} - -inline void set_page_clean(struct page *page) -{ - if (PageDirty(page)) { - ClearPageDirty(page); - __set_page_clean(page); - } -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)) -/* - * Add a page to the dirty page list. - */ -void __set_page_dirty(struct page *page) -{ - struct address_space *mapping; - spinlock_t *pg_lock; - - pg_lock = PAGECACHE_LOCK(page); - spin_lock(pg_lock); - - mapping = page->mapping; - spin_lock(&mapping->page_lock); - - list_del(&page->list); - list_add(&page->list, &mapping->dirty_pages); - - spin_unlock(&mapping->page_lock); - spin_unlock(pg_lock); - - if (mapping->host) - mark_inode_dirty_pages(mapping->host); -} -#else -/* - * Add a page to the dirty page list. - */ -void set_page_dirty(struct page *page) -{ - if (!test_and_set_bit(PG_dirty, &page->flags)) { - struct address_space *mapping = page->mapping; - - if (mapping) { - spin_lock(&pagecache_lock); - list_del(&page->list); - list_add(&page->list, &mapping->dirty_pages); - spin_unlock(&pagecache_lock); - - if (mapping->host) - mark_inode_dirty_pages(mapping->host); - } - } -} -#endif - -inline void lustre_put_page(struct page *page) -{ - kunmap(page); - page_cache_release(page); -} - -struct page *lustre_get_page_read(struct inode *inode, unsigned long index) -{ - struct address_space *mapping = inode->i_mapping; - struct page *page; - int rc; - - page = read_cache_page(mapping, index, - (filler_t*)mapping->a_ops->readpage, NULL); - if (!IS_ERR(page)) { - wait_on_page(page); - kmap(page); - if (!Page_Uptodate(page)) { - CERROR("page index %lu not uptodate\n", index); - GOTO(err_page, rc = -EIO); - } - if (PageError(page)) { - CERROR("page index %lu has error\n", index); - GOTO(err_page, rc = -EIO); - } - } - return page; - -err_page: - lustre_put_page(page); - return ERR_PTR(rc); -} - -struct page *lustre_get_page_write(struct inode *inode, unsigned long index) -{ - struct address_space *mapping = inode->i_mapping; - struct page *page; - int rc; - - page = grab_cache_page(mapping, index); /* locked page */ - - if (!IS_ERR(page)) { - kmap(page); - /* Note: Called with "O" and "PAGE_SIZE" this is essentially - * a no-op for most filesystems, because we write the whole - * page. For partial-page I/O this will read in the page. - */ - rc = mapping->a_ops->prepare_write(NULL, page, 0, PAGE_SIZE); - if (rc) { - CERROR("page index %lu, rc = %d\n", index, rc); - if (rc != -ENOSPC) - LBUG(); - GOTO(err_unlock, rc); - } - /* XXX not sure if we need this if we are overwriting page */ - if (PageError(page)) { - CERROR("error on page index %lu, rc = %d\n", index, rc); - LBUG(); - GOTO(err_unlock, rc = -EIO); - } - } - return page; - -err_unlock: - unlock_page(page); - lustre_put_page(page); - return ERR_PTR(rc); -} - -int lustre_commit_page(struct page *page, unsigned from, unsigned to) -{ - struct inode *inode = page->mapping->host; - int err = 0; - - SetPageUptodate(page); - set_page_clean(page); - - page->mapping->a_ops->commit_write(NULL, page, from, to); - if (IS_SYNC(inode)) - err = waitfor_one_page(page); - UnlockPage(page); - lustre_put_page(page); - return err; -} diff --git a/lustre/lib/simple.c b/lustre/lib/simple.c deleted file mode 100644 index dee3013..0000000 --- a/lustre/lib/simple.c +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lib/simple.c - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Peter Braam - * and Andreas Dilger - */ - -#define EXPORT_SYMTAB - -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_FILTER - -#include -#include -#include - - -/* push / pop to root of obd store */ -void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new) -{ - save->fs = get_fs(); - save->pwd = dget(current->fs->pwd); - save->pwdmnt = mntget(current->fs->pwdmnt); - - set_fs(new->fs); - set_fs_pwd(current->fs, new->pwdmnt, new->pwd); -} - -void pop_ctxt(struct obd_run_ctxt *saved) -{ - set_fs(saved->fs); - set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd); - - dput(saved->pwd); - mntput(saved->pwdmnt); -} - -/* utility to make a directory */ -struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode) -{ - struct dentry *dchild; - int err; - ENTRY; - - CDEBUG(D_INODE, "creating directory %*s\n", strlen(name), name); - dchild = lookup_one_len(name, dir, strlen(name)); - if (IS_ERR(dchild)) - RETURN(dchild); - - if (dchild->d_inode) { - if (!S_ISDIR(dchild->d_inode->i_mode)) - GOTO(out, err = -ENOTDIR); - - RETURN(dchild); - } - - err = vfs_mkdir(dir->d_inode, dchild, mode); - EXIT; -out: - if (err) { - dput(dchild); - RETURN(ERR_PTR(err)); - } - - RETURN(dchild); -} - -int lustre_fread(struct file *file, char *str, int len, loff_t *off) -{ - if (!file || !file->f_op || !file->f_op->read || !off) - RETURN(-ENOSYS); - - return file->f_op->read(file, str, len, off); -} - -int lustre_fwrite(struct file *file, const char *str, int len, loff_t *off) -{ - if (!file || !file->f_op || !off) - RETURN(-ENOSYS); - - if (!file->f_op->write) - RETURN(-EROFS); - - return file->f_op->write(file, str, len, off); -} - -int lustre_fsync(struct file *file) -{ - if (!file || !file->f_op || !file->f_op->fsync) - RETURN(-ENOSYS); - - return file->f_op->fsync(file, file->f_dentry, 0); -} diff --git a/lustre/llite/.cvsignore b/lustre/llite/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/llite/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/llite/Makefile.am b/lustre/llite/Makefile.am deleted file mode 100644 index defc532..0000000 --- a/lustre/llite/Makefile.am +++ /dev/null @@ -1,22 +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 - -DEFS:= - -MODULE = llite -modulefs_DATA = llite.o -EXTRA_PROGRAMS = llite - -page.c: - test -e page.c || ln -sf $(top_srcdir)/lib/page.c - - -LINX=page.c -llite_SOURCES = recover.c commit_callback.c page.c super.c rw.c file.c dir.c sysctl.c namei.c symlink.c - -dist-hook: - list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done - -include $(top_srcdir)/Rules diff --git a/lustre/llite/commit_callback.c b/lustre/llite/commit_callback.c deleted file mode 100644 index 3bb7820..0000000 --- a/lustre/llite/commit_callback.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * The daemon that causes completed but not committed transactions - * on the MDS to be flushed periodically when they are committed. - * A gratuitous getattr RPC is made to the MDS to discover the - * last committed record. - * - * Lustre High Availability Daemon - * - * 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 - * - * by Peter Braam - * - */ - -#define EXPORT_SYMTAB - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include - -static int ll_commitcbd_check_event(struct ll_sb_info *sbi) -{ - int rc = 0; - ENTRY; - - spin_lock(&sbi->ll_commitcbd_lock); - if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING) { - GOTO(out, rc = 1); - } - - out: - spin_unlock(&sbi->ll_commitcbd_lock); - RETURN(rc); -} - -static int ll_commitcbd_main(void *arg) -{ - struct ll_sb_info *sbi = (struct ll_sb_info *)arg; - - ENTRY; - - lock_kernel(); - daemonize(); - spin_lock_irq(¤t->sigmask_lock); - sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); - - sprintf(current->comm, "lustre_commitcbd"); - - /* Record that the thread is running */ - sbi->ll_commitcbd_waketime = CURRENT_TIME; - sbi->ll_commitcbd_timeout = 10 * HZ; - sbi->ll_commitcbd_thread = current; - sbi->ll_commitcbd_flags = LL_COMMITCBD_RUNNING; - wake_up(&sbi->ll_commitcbd_ctl_waitq); - - /* And now, loop forever on requests */ - while (1) { - wait_event_interruptible - (sbi->ll_commitcbd_waitq, - ll_commitcbd_check_event(sbi)); - - spin_lock(&sbi->ll_commitcbd_lock); - if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING) { - spin_unlock(&sbi->ll_commitcbd_lock); - CERROR("lustre_commitd quitting\n"); - EXIT; - break; - } - - schedule_timeout(sbi->ll_commitcbd_timeout); - CERROR("commit callback daemon woken up - FIXME\n"); - spin_unlock(&sbi->ll_commitcbd_lock); - } - - sbi->ll_commitcbd_thread = NULL; - sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPED; - wake_up(&sbi->ll_commitcbd_ctl_waitq); - CDEBUG(D_NET, "commit callback daemon exiting %d\n", current->pid); - RETURN(0); -} - - - -int ll_commitcbd_setup(struct ll_sb_info *sbi) -{ - int rc; - ENTRY; - - rc = kernel_thread(ll_commitcbd_main, (void *) sbi, - CLONE_VM | CLONE_FS | CLONE_FILES); - if (rc < 0) { - CERROR("cannot start thread\n"); - RETURN(rc); - } - wait_event(sbi->ll_commitcbd_ctl_waitq, - sbi->ll_commitcbd_flags & LL_COMMITCBD_RUNNING); - RETURN(0); -} - - -int ll_commitcbd_cleanup(struct ll_sb_info *sbi) -{ - sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPING; - - wake_up(&sbi->ll_commitcbd_waitq); - wait_event_interruptible - (sbi->ll_commitcbd_ctl_waitq, - sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPED); - RETURN(0); -} diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c deleted file mode 100644 index 433056d..0000000 --- a/lustre/llite/dcache.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 2001, Cluster File Systems, Inc. - * - */ - -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include - -extern struct address_space_operations ll_aops; - -int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it) -{ - ENTRY; - - - RETURN(1); -} - - -struct dentry_operations ll_d_ops = { - d_revalidate2: ll_revalidate2 -}; diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c deleted file mode 100644 index 3d91ae6..0000000 --- a/lustre/llite/dir.c +++ /dev/null @@ -1,703 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/fs/minix/dir.c - * linux/fs/ext2/dir.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * ext2 directory handling functions - * - * Big-endian to little-endian byte-swapping/bitmaps by - * David S. Miller (davem@caip.rutgers.edu), 1995 - * - * All code that works with directory layout had been switched to pagecache - * and moved here. AV - * - * Adapted for Lustre Light - * Copyright (C) 2002, Cluster File Systems, Inc. - * - */ - -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include - -typedef struct ext2_dir_entry_2 ext2_dirent; - -#define PageChecked(page) test_bit(PG_checked, &(page)->flags) -#define SetPageChecked(page) set_bit(PG_checked, &(page)->flags) - - -static int ll_dir_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) -{ - return 0; -} - -/* returns the page unlocked, but with a reference */ -static int ll_dir_readpage(struct file *file, struct page *page) -{ - struct inode *inode = page->mapping->host; - struct ll_sb_info *sbi = ll_i2sbi(inode); - char *buf; - __u64 offset; - int rc = 0; - struct ptlrpc_request *request = NULL; - - ENTRY; - - if ((inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_SHIFT <= page->index){ - memset(kmap(page), 0, PAGE_CACHE_SIZE); - kunmap(page); - EXIT; - goto readpage_out; - } - - if (Page_Uptodate(page)) { - CERROR("Explain this please?\n"); - EXIT; - goto readpage_out; - } - - offset = page->index << PAGE_SHIFT; - buf = kmap(page); - rc = mdc_readpage(&sbi->ll_mds_client, sbi->ll_mds_conn, inode->i_ino, - S_IFDIR, offset, buf, &request); - kunmap(page); - ptlrpc_free_req(request); - EXIT; - - readpage_out: - if ( !rc ) - SetPageUptodate(page); - - UnlockPage(page); - return rc; -} /* ll_dir_readpage */ - -struct address_space_operations ll_dir_aops = { - readpage: ll_dir_readpage, - prepare_write: ll_dir_prepare_write -}; - -int waitfor_one_page(struct page *page) -{ - int error = 0; - struct buffer_head *bh, *head = page->buffers; - - bh = head; - do { - wait_on_buffer(bh); - if (buffer_req(bh) && !buffer_uptodate(bh)) - error = -EIO; - } while ((bh = bh->b_this_page) != head); - return error; -} - -/* - * ext2 uses block-sized chunks. Arguably, sector-sized ones would be - * more robust, but we have what we have - */ -static inline unsigned ext2_chunk_size(struct inode *inode) -{ - return inode->i_sb->s_blocksize; -} - -static inline void ext2_put_page(struct page *page) -{ - kunmap(page); - page_cache_release(page); -} - -static inline unsigned long dir_pages(struct inode *inode) -{ - return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; -} - -extern void set_page_clean(struct page *page); - -static int ext2_commit_chunk(struct page *page, unsigned from, unsigned to) -{ - struct inode *dir = page->mapping->host; - loff_t new_size = (page->index << PAGE_CACHE_SHIFT) + to; - int err = 0; - - dir->i_version = ++event; - if (new_size > dir->i_size) - dir->i_size = new_size; - SetPageUptodate(page); - set_page_clean(page); - - //page->mapping->a_ops->commit_write(NULL, page, from, to); - //if (IS_SYNC(dir)) - // err = waitfor_one_page(page); - return err; -} - -static void ext2_check_page(struct page *page) -{ - struct inode *dir = page->mapping->host; - unsigned chunk_size = ext2_chunk_size(dir); - char *kaddr = page_address(page); - // u32 max_inumber = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count); - unsigned offs, rec_len; - unsigned limit = PAGE_CACHE_SIZE; - ext2_dirent *p; - char *error; - - if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) { - limit = dir->i_size & ~PAGE_CACHE_MASK; - if (limit & (chunk_size - 1)) { - CERROR("limit %d dir size %lld index %ld\n", - limit, dir->i_size, page->index); - goto Ebadsize; - } - for (offs = limit; offsrec_len = cpu_to_le16(chunk_size); - } - if (!limit) - goto out; - } - for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) { - p = (ext2_dirent *)(kaddr + offs); - rec_len = le16_to_cpu(p->rec_len); - - if (rec_len < EXT2_DIR_REC_LEN(1)) - goto Eshort; - if (rec_len & 3) - goto Ealign; - if (rec_len < EXT2_DIR_REC_LEN(p->name_len)) - goto Enamelen; - if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1)) - goto Espan; - // if (le32_to_cpu(p->inode) > max_inumber) - //goto Einumber; - } - if (offs != limit) - goto Eend; -out: - SetPageChecked(page); - return; - - /* Too bad, we had an error */ - -Ebadsize: - CERROR("ext2_check_page" - "size of directory #%lu is not a multiple of chunk size\n", - dir->i_ino - ); - goto fail; -Eshort: - error = "rec_len is smaller than minimal"; - goto bad_entry; -Ealign: - error = "unaligned directory entry"; - goto bad_entry; -Enamelen: - error = "rec_len is too small for name_len"; - goto bad_entry; -Espan: - error = "directory entry across blocks"; - goto bad_entry; - //Einumber: - // error = "inode out of bounds"; -bad_entry: - CERROR("ext2_check_page: bad entry in directory #%lu: %s - " - "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", - dir->i_ino, error, (page->index<inode), - rec_len, p->name_len); - goto fail; -Eend: - p = (ext2_dirent *)(kaddr + offs); - CERROR("ext2_check_page" - "entry in directory #%lu spans the page boundary" - "offset=%lu, inode=%lu", - dir->i_ino, (page->index<inode)); -fail: - SetPageChecked(page); - SetPageError(page); - LBUG(); -} - -static struct page * ext2_get_page(struct inode *dir, unsigned long n) -{ - struct address_space *mapping = dir->i_mapping; - struct page *page = read_cache_page(mapping, n, - (filler_t*)mapping->a_ops->readpage, NULL); - if (!IS_ERR(page)) { - wait_on_page(page); - kmap(page); - if (!Page_Uptodate(page)) - goto fail; - if (!PageChecked(page)) - ext2_check_page(page); - if (PageError(page)) - goto fail; - } - return page; - -fail: - ext2_put_page(page); - return ERR_PTR(-EIO); -} - -/* - * NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure. - * - * len <= EXT2_NAME_LEN and de != NULL are guaranteed by caller. - */ -static inline int ext2_match (int len, const char * const name, - struct ext2_dir_entry_2 * de) -{ - if (len != de->name_len) - return 0; - if (!de->inode) - return 0; - return !memcmp(name, de->name, len); -} - -/* - * p is at least 6 bytes before the end of page - */ -static inline ext2_dirent *ext2_next_entry(ext2_dirent *p) -{ - return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len)); -} - -static inline unsigned -ext2_validate_entry(char *base, unsigned offset, unsigned mask) -{ - ext2_dirent *de = (ext2_dirent*)(base + offset); - ext2_dirent *p = (ext2_dirent*)(base + (offset&mask)); - while ((char*)p < (char*)de) - p = ext2_next_entry(p); - return (char *)p - base; -} - -static unsigned char ext2_filetype_table[EXT2_FT_MAX] = { - [EXT2_FT_UNKNOWN] DT_UNKNOWN, - [EXT2_FT_REG_FILE] DT_REG, - [EXT2_FT_DIR] DT_DIR, - [EXT2_FT_CHRDEV] DT_CHR, - [EXT2_FT_BLKDEV] DT_BLK, - [EXT2_FT_FIFO] DT_FIFO, - [EXT2_FT_SOCK] DT_SOCK, - [EXT2_FT_SYMLINK] DT_LNK, -}; - -static unsigned int ll_dt2fmt[DT_WHT + 1] = { - [EXT2_FT_UNKNOWN] 0, - [EXT2_FT_REG_FILE] S_IFREG, - [EXT2_FT_DIR] S_IFDIR, - [EXT2_FT_CHRDEV] S_IFCHR, - [EXT2_FT_BLKDEV] S_IFBLK, - [EXT2_FT_FIFO] S_IFIFO, - [EXT2_FT_SOCK] S_IFSOCK, - [EXT2_FT_SYMLINK] S_IFLNK -}; - -#define S_SHIFT 12 -static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = { - [S_IFREG >> S_SHIFT] EXT2_FT_REG_FILE, - [S_IFDIR >> S_SHIFT] EXT2_FT_DIR, - [S_IFCHR >> S_SHIFT] EXT2_FT_CHRDEV, - [S_IFBLK >> S_SHIFT] EXT2_FT_BLKDEV, - [S_IFIFO >> S_SHIFT] EXT2_FT_FIFO, - [S_IFSOCK >> S_SHIFT] EXT2_FT_SOCK, - [S_IFLNK >> S_SHIFT] EXT2_FT_SYMLINK, -}; - -static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode) -{ - mode_t mode = inode->i_mode; - de->file_type = ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; -} - -int -new_ll_readdir (struct file * filp, void * dirent, filldir_t filldir) -{ - loff_t pos = filp->f_pos; - struct inode *inode = filp->f_dentry->d_inode; - // XXX struct super_block *sb = inode->i_sb; - unsigned offset = pos & ~PAGE_CACHE_MASK; - unsigned long n = pos >> PAGE_CACHE_SHIFT; - unsigned long npages = dir_pages(inode); - unsigned chunk_mask = ~(ext2_chunk_size(inode)-1); - unsigned char *types = NULL; - int need_revalidate = (filp->f_version != inode->i_version); - - if (pos > inode->i_size - EXT2_DIR_REC_LEN(1)) - GOTO(done, 0); - - types = ext2_filetype_table; - - for ( ; n < npages; n++, offset = 0) { - char *kaddr, *limit; - ext2_dirent *de; - struct page *page = ext2_get_page(inode, n); - - if (IS_ERR(page)) - continue; - kaddr = page_address(page); - if (need_revalidate) { - offset = ext2_validate_entry(kaddr, offset, chunk_mask); - need_revalidate = 0; - } - de = (ext2_dirent *)(kaddr+offset); - limit = kaddr + PAGE_CACHE_SIZE - EXT2_DIR_REC_LEN(1); - for ( ;(char*)de <= limit; de = ext2_next_entry(de)) - if (de->inode) { - int over; - unsigned char d_type = DT_UNKNOWN; - - if (types && de->file_type < EXT2_FT_MAX) - d_type = types[de->file_type]; - - offset = (char *)de - kaddr; - over = filldir(dirent, de->name, de->name_len, - (n<inode), d_type); - if (over) { - ext2_put_page(page); - GOTO(done,0); - } - } - ext2_put_page(page); - } - -done: - filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset; - filp->f_version = inode->i_version; - UPDATE_ATIME(inode); - return 0; -} - -/* - * ext2_find_entry() - * - * finds an entry in the specified directory with the wanted name. It - * returns the page in which the entry was found, and the entry itself - * (as a parameter - res_dir). Page is returned mapped and unlocked. - * Entry is guaranteed to be valid. - */ -struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir, - struct dentry *dentry, struct page ** res_page) -{ - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - unsigned reclen = EXT2_DIR_REC_LEN(namelen); - unsigned long start, n; - unsigned long npages = dir_pages(dir); - struct page *page = NULL; - ext2_dirent * de; - - /* OFFSET_CACHE */ - *res_page = NULL; - - // start = dir->u.ext2_i.i_dir_start_lookup; - start = 0; - if (start >= npages) - start = 0; - n = start; - do { - char *kaddr; - page = ext2_get_page(dir, n); - if (!IS_ERR(page)) { - kaddr = page_address(page); - de = (ext2_dirent *) kaddr; - kaddr += PAGE_CACHE_SIZE - reclen; - while ((char *) de <= kaddr) { - if (ext2_match (namelen, name, de)) - goto found; - de = ext2_next_entry(de); - } - ext2_put_page(page); - } - if (++n >= npages) - n = 0; - } while (n != start); - return NULL; - -found: - *res_page = page; - // dir->u.ext2_i.i_dir_start_lookup = n; - return de; -} - -struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p) -{ - struct page *page = ext2_get_page(dir, 0); - ext2_dirent *de = NULL; - - if (!IS_ERR(page)) { - de = ext2_next_entry((ext2_dirent *) page_address(page)); - *p = page; - } - return de; -} - -ino_t ll_inode_by_name(struct inode * dir, struct dentry *dentry, int *type) -{ - ino_t res = 0; - struct ext2_dir_entry_2 * de; - struct page *page; - - de = ext2_find_entry (dir, dentry, &page); - if (de) { - res = le32_to_cpu(de->inode); - *type = ll_dt2fmt[de->file_type]; - kunmap(page); - page_cache_release(page); - } - return res; -} - -/* Releases the page */ -void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, - struct page *page, struct inode *inode) -{ - unsigned from = (char *) de - (char *) page_address(page); - unsigned to = from + le16_to_cpu(de->rec_len); - int err; - - lock_page(page); - err = page->mapping->a_ops->prepare_write(NULL, page, from, to); - if (err) - LBUG(); - de->inode = cpu_to_le32(inode->i_ino); - ext2_set_de_type (de, inode); - dir->i_mtime = dir->i_ctime = CURRENT_TIME; - err = ext2_commit_chunk(page, from, to); - UnlockPage(page); - ext2_put_page(page); -} - -/* - * Parent is locked. - */ -int ll_add_link (struct dentry *dentry, struct inode *inode) -{ - struct inode *dir = dentry->d_parent->d_inode; - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - unsigned reclen = EXT2_DIR_REC_LEN(namelen); - unsigned short rec_len, name_len; - struct page *page = NULL; - ext2_dirent * de; - unsigned long npages = dir_pages(dir); - unsigned long n; - char *kaddr; - unsigned from, to; - int err; - - /* We take care of directory expansion in the same loop */ - for (n = 0; n <= npages; n++) { - page = ext2_get_page(dir, n); - err = PTR_ERR(page); - if (IS_ERR(page)) - goto out; - kaddr = page_address(page); - de = (ext2_dirent *)kaddr; - kaddr += PAGE_CACHE_SIZE - reclen; - while ((char *)de <= kaddr) { - err = -EEXIST; - if (ext2_match (namelen, name, de)) - goto out_page; - name_len = EXT2_DIR_REC_LEN(de->name_len); - rec_len = le16_to_cpu(de->rec_len); - if ( n==npages && rec_len == 0) { - CERROR("Fatal dir behaviour\n"); - goto out_page; - } - if (!de->inode && rec_len >= reclen) - goto got_it; - if (rec_len >= name_len + reclen) - goto got_it; - de = (ext2_dirent *) ((char *) de + rec_len); - } - ext2_put_page(page); - } - LBUG(); - return -EINVAL; - -got_it: - from = (char*)de - (char*)page_address(page); - to = from + rec_len; - lock_page(page); - err = page->mapping->a_ops->prepare_write(NULL, page, from, to); - if (err) - goto out_unlock; - if (de->inode) { - ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len); - de1->rec_len = cpu_to_le16(rec_len - name_len); - de->rec_len = cpu_to_le16(name_len); - de = de1; - } - de->name_len = namelen; - memcpy (de->name, name, namelen); - de->inode = cpu_to_le32(inode->i_ino); - ext2_set_de_type (de, inode); - CDEBUG(D_INODE, "type set to %o\n", de->file_type); - dir->i_mtime = dir->i_ctime = CURRENT_TIME; - err = ext2_commit_chunk(page, from, to); - - // change_inode happens with the commit_chunk - /* XXX OFFSET_CACHE */ - -out_unlock: - UnlockPage(page); -out_page: - ext2_put_page(page); -out: - return err; -} - -/* - * ext2_delete_entry deletes a directory entry by merging it with the - * previous entry. Page is up-to-date. Releases the page. - */ -int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) -{ - struct address_space *mapping = page->mapping; - struct inode *inode = mapping->host; - char *kaddr = page_address(page); - unsigned from = ((char*)dir - kaddr) & ~(ext2_chunk_size(inode)-1); - unsigned to = ((char*)dir - kaddr) + le16_to_cpu(dir->rec_len); - ext2_dirent * pde = NULL; - ext2_dirent * de = (ext2_dirent *) (kaddr + from); - int err; - - while ((char*)de < (char*)dir) { - pde = de; - de = ext2_next_entry(de); - } - if (pde) - from = (char*)pde - (char*)page_address(page); - lock_page(page); - err = mapping->a_ops->prepare_write(NULL, page, from, to); - if (err) - LBUG(); - if (pde) - pde->rec_len = cpu_to_le16(to-from); - dir->inode = 0; - inode->i_ctime = inode->i_mtime = CURRENT_TIME; - err = ext2_commit_chunk(page, from, to); - UnlockPage(page); - ext2_put_page(page); - return err; -} - -/* - * Set the first fragment of directory. - */ -int ext2_make_empty(struct inode *inode, struct inode *parent) -{ - struct address_space *mapping = inode->i_mapping; - struct page *page = grab_cache_page(mapping, 0); - unsigned chunk_size = ext2_chunk_size(inode); - struct ext2_dir_entry_2 * de; - char *base; - int err; - ENTRY; - - if (!page) - return -ENOMEM; - err = mapping->a_ops->prepare_write(NULL, page, 0, chunk_size); - if (err) - goto fail; - - base = page_address(page); - - de = (struct ext2_dir_entry_2 *) base; - de->name_len = 1; - de->rec_len = cpu_to_le16(EXT2_DIR_REC_LEN(1)); - memcpy (de->name, ".\0\0", 4); - de->inode = cpu_to_le32(inode->i_ino); - ext2_set_de_type (de, inode); - - de = (struct ext2_dir_entry_2 *) (base + EXT2_DIR_REC_LEN(1)); - de->name_len = 2; - de->rec_len = cpu_to_le16(chunk_size - EXT2_DIR_REC_LEN(1)); - de->inode = cpu_to_le32(parent->i_ino); - memcpy (de->name, "..\0", 4); - ext2_set_de_type (de, inode); - - err = ext2_commit_chunk(page, 0, chunk_size); -fail: - UnlockPage(page); - page_cache_release(page); - ENTRY; - return err; -} - -/* - * routine to check that the specified directory is empty (for rmdir) - */ -int ext2_empty_dir (struct inode * inode) -{ - struct page *page = NULL; - unsigned long i, npages = dir_pages(inode); - - for (i = 0; i < npages; i++) { - char *kaddr; - ext2_dirent * de; - page = ext2_get_page(inode, i); - - if (IS_ERR(page)) - continue; - - kaddr = page_address(page); - de = (ext2_dirent *)kaddr; - kaddr += PAGE_CACHE_SIZE-EXT2_DIR_REC_LEN(1); - - while ((char *)de <= kaddr) { - if (de->inode != 0) { - /* check for . and .. */ - if (de->name[0] != '.') - goto not_empty; - if (de->name_len > 2) - goto not_empty; - if (de->name_len < 2) { - if (de->inode != - cpu_to_le32(inode->i_ino)) - goto not_empty; - } else if (de->name[1] != '.') - goto not_empty; - } - de = ext2_next_entry(de); - } - ext2_put_page(page); - } - return 1; - -not_empty: - ext2_put_page(page); - return 0; -} - -struct file_operations ll_dir_operations = { - read: generic_read_dir, - readdir: new_ll_readdir -}; diff --git a/lustre/llite/file.c b/lustre/llite/file.c deleted file mode 100644 index 834c35b..0000000 --- a/lustre/llite/file.c +++ /dev/null @@ -1,334 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/fs/ext2/file.c - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/fs/minix/file.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * ext2 fs regular file handling primitives - * - * 64-bit file support on 64-bit platforms by Jakub Jelinek - * (jj@sunsite.ms.mff.cuni.cz) - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include - -int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc); -extern int ll_setattr(struct dentry *de, struct iattr *attr); -extern inline struct obdo * ll_oa_from_inode(struct inode *inode, - unsigned long valid); - -static int ll_file_open(struct inode *inode, struct file *file) -{ - int rc; - struct ptlrpc_request *req = NULL; - struct ll_file_data *fd; - struct obdo *oa; - struct ll_sb_info *sbi = ll_i2sbi(inode); - ENTRY; - - if (file->private_data) - LBUG(); - - fd = kmem_cache_alloc(ll_file_data_slab, SLAB_KERNEL); - if (!fd) - GOTO(out, rc = -ENOMEM); - memset(fd, 0, sizeof(*fd)); - - rc = mdc_open(&sbi->ll_mds_client, sbi->ll_mds_conn, inode->i_ino, - S_IFREG, file->f_flags, (__u64)(unsigned long)file, - &fd->fd_mdshandle, &req); - fd->fd_req = req; - ptlrpc_req_finished(req); - if (rc) - GOTO(out_req, -abs(rc)); - if (!fd->fd_mdshandle) { - CERROR("mdc_open didn't assign fd_mdshandle\n"); - /* XXX handle this how, abort or is it non-fatal? */ - } - - oa = ll_oa_from_inode(inode, (OBD_MD_FLMODE | OBD_MD_FLID)); - if (oa == NULL) { - LBUG(); - GOTO(out_mdc, rc = -ENOMEM); - } - rc = obd_open(ll_i2obdconn(inode), oa); - obdo_free(oa); - if (rc) { - GOTO(out_mdc, rc = -abs(rc)); - } - - file->private_data = fd; - - EXIT; - - return 0; -out_mdc: - mdc_close(&sbi->ll_mds_client, sbi->ll_mds_conn, inode->i_ino, - S_IFREG, fd->fd_mdshandle, &req); -out_req: - ptlrpc_free_req(req); -//out_fd: - kmem_cache_free(ll_file_data_slab, fd); - file->private_data = NULL; -out: - return rc; -} - -static int ll_file_release(struct inode *inode, struct file *file) -{ - int rc; - struct ptlrpc_request *req = NULL; - struct ll_file_data *fd; - struct obdo *oa; - struct ll_sb_info *sbi = ll_i2sbi(inode); - - ENTRY; - - fd = (struct ll_file_data *)file->private_data; - if (!fd || !fd->fd_mdshandle) { - LBUG(); - GOTO(out, rc = -EINVAL); - } - - oa = ll_oa_from_inode(inode, (OBD_MD_FLMODE | OBD_MD_FLID)); - if (oa == NULL) { - LBUG(); - GOTO(out_fd, rc = -ENOENT); - } - rc = obd_close(ll_i2obdconn(inode), oa); - obdo_free(oa); - if (rc) { - GOTO(out_fd, abs(rc)); - } - - if (file->f_mode & FMODE_WRITE) { - struct iattr attr; - attr.ia_valid = ATTR_MTIME | ATTR_CTIME | ATTR_ATIME | ATTR_SIZE; - attr.ia_mtime = inode->i_mtime; - attr.ia_ctime = inode->i_ctime; - attr.ia_atime = inode->i_atime; - attr.ia_size = inode->i_size; - - /* XXX: this introduces a small race that we should evaluate */ - rc = ll_inode_setattr(inode, &attr, 0); - if (rc) { - CERROR("failed - %d.\n", rc); - rc = -EIO; /* XXX - GOTO(out)? -phil */ - } - } - - rc = mdc_close(&sbi->ll_mds_client, sbi->ll_mds_conn, inode->i_ino, - S_IFREG, fd->fd_mdshandle, &req); - ptlrpc_req_finished(req); - if (rc) { - if (rc > 0) - rc = -rc; - GOTO(out, rc); - } - ptlrpc_free_req(fd->fd_req); - - EXIT; - -out_fd: - kmem_cache_free(ll_file_data_slab, fd); - file->private_data = NULL; -out: - return rc; -} - - -static inline void ll_remove_suid(struct inode *inode) -{ - unsigned int mode; - - /* set S_IGID if S_IXGRP is set, and always set S_ISUID */ - mode = (inode->i_mode & S_IXGRP)*(S_ISGID/S_IXGRP) | S_ISUID; - - /* was any of the uid bits set? */ - mode &= inode->i_mode; - if (mode && !capable(CAP_FSETID)) { - inode->i_mode &= ~mode; - // XXX careful here - we cannot change the size - } -} - -static void ll_update_atime(struct inode *inode) -{ - struct iattr attr; - - attr.ia_atime = CURRENT_TIME; - attr.ia_valid = ATTR_ATIME; - - if (inode->i_atime == attr.ia_atime) return; - if (IS_RDONLY(inode)) return; - if (IS_NOATIME(inode)) return; - - /* ll_inode_setattr() sets inode->i_atime from attr.ia_atime */ - ll_inode_setattr(inode, &attr, 0); -} - -static ssize_t ll_file_read(struct file *filp, char *buf, size_t count, - loff_t *ppos) -{ - struct ll_file_data *fd = (struct ll_file_data *)filp->private_data; - struct inode *inode = filp->f_dentry->d_inode; - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ldlm_extent extent; - struct ldlm_handle lockh; - __u64 res_id[RES_NAME_SIZE] = {inode->i_ino}; - int flags = 0; - ldlm_error_t err; - ssize_t retval; - ENTRY; - - if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK)) { - extent.start = *ppos; - extent.end = *ppos + count; - CDEBUG(D_INFO, "Locking inode %ld, start %Lu end %Lu\n", - inode->i_ino, extent.start, extent.end); - - err = obd_enqueue(&sbi->ll_conn, sbi->ll_namespace, NULL, - res_id, LDLM_EXTENT, &extent, LCK_PR, &flags, - inode, sizeof(*inode), &lockh); - if (err != ELDLM_OK) - CERROR("lock enqueue: err: %d\n", err); - ldlm_lock_dump((void *)(unsigned long)lockh.addr); - } - - CDEBUG(D_INFO, "Reading inode %ld, %d bytes, offset %Ld\n", - inode->i_ino, count, *ppos); - retval = generic_file_read(filp, buf, count, ppos); - if (retval > 0) - ll_update_atime(inode); - - if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK)) { - err = obd_cancel(&sbi->ll_conn, LCK_PR, &lockh); - if (err != ELDLM_OK) - CERROR("lock cancel: err: %d\n", err); - } - - RETURN(retval); -} - -/* - * Write to a file (through the page cache). - */ -static ssize_t -ll_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos) -{ - struct ll_file_data *fd = (struct ll_file_data *)file->private_data; - struct inode *inode = file->f_dentry->d_inode; - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ldlm_extent extent; - struct ldlm_handle lockh; - __u64 res_id[RES_NAME_SIZE] = {inode->i_ino}; - int flags = 0; - ldlm_error_t err; - ssize_t retval; - ENTRY; - - if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK)) { - extent.start = *ppos; - extent.end = *ppos + count; - CDEBUG(D_INFO, "Locking inode %ld, start %Lu end %Lu\n", - inode->i_ino, extent.start, extent.end); - - err = obd_enqueue(&sbi->ll_conn, sbi->ll_namespace, NULL, - res_id, LDLM_EXTENT, &extent, LCK_PW, &flags, - inode, sizeof(*inode), &lockh); - if (err != ELDLM_OK) - CERROR("lock enqueue: err: %d\n", err); - ldlm_lock_dump((void *)(unsigned long)lockh.addr); - } - - CDEBUG(D_INFO, "Writing inode %ld, %ld bytes, offset %Ld\n", - inode->i_ino, (long)count, *ppos); - - retval = generic_file_write(file, buf, count, ppos); - - if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK)) { - err = obd_cancel(&sbi->ll_conn, LCK_PW, &lockh); - if (err != ELDLM_OK) - CERROR("lock cancel: err: %d\n", err); - } - - RETURN(retval); -} - -int ll_file_ioctl(struct inode *inode, struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct ll_file_data *fd = (struct ll_file_data *)file->private_data; - int flags; - - switch(cmd) { - case LL_IOC_GETFLAGS: - /* Get the current value of the file flags */ - return put_user(fd->fd_flags, (int *)arg); - case LL_IOC_SETFLAGS: - case LL_IOC_CLRFLAGS: - /* Set or clear specific file flags */ - /* XXX This probably needs checks to ensure the flags are - * not abused, and to handle any flag side effects. - */ - if (get_user(flags, (int *) arg)) - return -EFAULT; - - if (cmd == LL_IOC_SETFLAGS) - fd->fd_flags |= flags; - else - fd->fd_flags &= ~flags; - return 0; - - /* We need to special case any other ioctls we want to handle, - * to send them to the MDS/OST as appropriate and to properly - * network encode the arg field. - case EXT2_IOC_GETFLAGS: - case EXT2_IOC_SETFLAGS: - case EXT2_IOC_GETVERSION_OLD: - case EXT2_IOC_GETVERSION_NEW: - case EXT2_IOC_SETVERSION_OLD: - case EXT2_IOC_SETVERSION_NEW: - */ - default: - return -ENOTTY; - } -} - -/* XXX this does not need to do anything for data, it _does_ need to - call setattr */ -int ll_fsync(struct file *file, struct dentry *dentry, int data) -{ - return 0; -} - -struct file_operations ll_file_operations = { - read: ll_file_read, - write: ll_file_write, - ioctl: ll_file_ioctl, - open: ll_file_open, - release: ll_file_release, - mmap: generic_file_mmap, - fsync: NULL -}; - -struct inode_operations ll_file_inode_operations = { - truncate: ll_truncate, - setattr: ll_setattr -}; diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c deleted file mode 100644 index 91f13b3..0000000 --- a/lustre/llite/namei.c +++ /dev/null @@ -1,550 +0,0 @@ -/* - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/fs/ext2/namei.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * Big-endian to little-endian byte-swapping/bitmaps by - * David S. Miller (davem@caip.rutgers.edu), 1995 - * Directory entry file type support and forward compatibility hooks - * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998 - * - * Changes for use in OBDFS - * Copyright (c) 1999, Seagate Technology Inc. - * Copyright (C) 2001, Cluster File Systems, Inc. - * Rewritten based on recent ext2 page cache use. - * - */ - -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -extern struct address_space_operations ll_aops; - -/* from super.c */ -extern void ll_change_inode(struct inode *inode); -extern int ll_setattr(struct dentry *de, struct iattr *attr); - -/* from dir.c */ -extern int ll_add_link (struct dentry *dentry, struct inode *inode); -ino_t ll_inode_by_name(struct inode * dir, struct dentry *dentry, int *typ); -int ext2_make_empty(struct inode *inode, struct inode *parent); -struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir, - struct dentry *dentry, struct page ** res_page); -int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ); -int ext2_empty_dir (struct inode * inode); -struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p); -void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, - struct page *page, struct inode *inode); - -/* - * Couple of helper functions - make the code slightly cleaner. - */ -static inline void ext2_inc_count(struct inode *inode) -{ - inode->i_nlink++; -} - -/* postpone the disk update until the inode really goes away */ -static inline void ext2_dec_count(struct inode *inode) -{ - inode->i_nlink--; -} - -static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) -{ - int err; - err = ll_add_link(dentry, inode); - if (!err) { - d_instantiate(dentry, inode); - return 0; - } - ext2_dec_count(inode); - iput(inode); - return err; -} - -/* methods */ -static int ll_find_inode(struct inode *inode, unsigned long ino, void *opaque) -{ - struct mds_body *body = (struct mds_body *)opaque; - - if (inode->i_generation != body->generation) - return 0; - - return 1; -} - -static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry) -{ - struct ptlrpc_request *request = NULL; - struct inode * inode = NULL; - struct ll_sb_info *sbi = ll_i2sbi(dir); - int err; - int type; - ino_t ino; - - ENTRY; - if (dentry->d_name.len > EXT2_NAME_LEN) - RETURN(ERR_PTR(-ENAMETOOLONG)); - - ino = ll_inode_by_name(dir, dentry, &type); - if (!ino) - GOTO(negative, NULL); - - err = mdc_getattr(&sbi->ll_mds_client, sbi->ll_mds_conn, ino, type, - OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request); - if (err) { - CERROR("failure %d inode %ld\n", err, (long)ino); - ptlrpc_free_req(request); - RETURN(ERR_PTR(-abs(err))); - } - - inode = iget4(dir->i_sb, ino, ll_find_inode, - lustre_msg_buf(request->rq_repmsg, 0)); - - ptlrpc_free_req(request); - if (!inode) - RETURN(ERR_PTR(-ENOMEM)); - - EXIT; - negative: - d_add(dentry, inode); - return NULL; -} - -static struct inode *ll_create_node(struct inode *dir, const char *name, - int namelen, const char *tgt, int tgtlen, - int mode, __u64 id) -{ - struct inode *inode; - struct ptlrpc_request *request = NULL; - struct mds_body *body; - int err; - time_t time = CURRENT_TIME; - struct ll_sb_info *sbi = ll_i2sbi(dir); - - ENTRY; - - err = mdc_create(&sbi->ll_mds_client, sbi->ll_mds_conn, dir, name, - namelen, tgt, tgtlen, mode, id, current->fsuid, - current->fsgid, time, &request); - if (err) { - inode = ERR_PTR(err); - GOTO(out, err); - } - body = lustre_msg_buf(request->rq_repmsg, 0); - body->valid = (__u32)OBD_MD_FLNOTOBD; - - body->objid = id; - body->nlink = 1; - body->atime = body->ctime = body->mtime = time; - body->uid = current->fsuid; - body->gid = current->fsgid; - body->mode = mode; - CDEBUG(D_INODE, "-- new_inode: objid %lld, ino %d, mode %o\n", - (unsigned long long)body->objid, body->ino, body->mode); - - inode = iget4(dir->i_sb, body->ino, ll_find_inode, body); - if (IS_ERR(inode)) { - CERROR("new_inode -fatal: %ld\n", PTR_ERR(inode)); - inode = ERR_PTR(-EIO); - LBUG(); - GOTO(out, -EIO); - } - - if (!list_empty(&inode->i_dentry)) { - CERROR("new_inode -fatal: inode %d, ct %d lnk %d\n", - body->ino, atomic_read(&inode->i_count), - inode->i_nlink); - iput(inode); - LBUG(); - inode = ERR_PTR(-EIO); - GOTO(out, -EIO); - } - - EXIT; - out: - ptlrpc_free_req(request); - return inode; -} - -int ll_mdc_unlink(struct inode *dir, struct inode *child, - const char *name, int len) -{ - struct ptlrpc_request *request = NULL; - int err; - struct ll_sb_info *sbi = ll_i2sbi(dir); - - ENTRY; - - err = mdc_unlink(&sbi->ll_mds_client, sbi->ll_mds_conn, dir, child, - name, len, &request); - ptlrpc_free_req(request); - - EXIT; - return err; -} - -int ll_mdc_link(struct dentry *src, struct inode *dir, - const char *name, int len) -{ - struct ptlrpc_request *request = NULL; - int err; - struct ll_sb_info *sbi = ll_i2sbi(dir); - - ENTRY; - - err = mdc_link(&sbi->ll_mds_client, sbi->ll_mds_conn, src, dir, name, - len, &request); - ptlrpc_free_req(request); - - EXIT; - return err; -} - -int ll_mdc_rename(struct inode *src, struct inode *tgt, - struct dentry *old, struct dentry *new) -{ - struct ptlrpc_request *request = NULL; - int err; - struct ll_sb_info *sbi = ll_i2sbi(src); - - ENTRY; - - err = mdc_rename(&sbi->ll_mds_client, sbi->ll_mds_conn, src, tgt, - old->d_name.name, old->d_name.len, - new->d_name.name, new->d_name.len, &request); - ptlrpc_free_req(request); - - EXIT; - return err; -} - -/* - * By the time this is called, we already have created - * the directory cache entry for the new file, but it - * is so far negative - it has no inode. - * - * If the create succeeds, we fill in the inode information - * with d_instantiate(). - */ - -static int ll_create (struct inode * dir, struct dentry * dentry, int mode) -{ - int err, rc; - struct obdo oa; - struct inode * inode; - - memset(&oa, 0, sizeof(oa)); - oa.o_valid = OBD_MD_FLMODE; - oa.o_mode = S_IFREG | 0600; - rc = obd_create(ll_i2obdconn(dir), &oa); - if (rc) { - CERROR("error creating OST object: rc = %d\n", rc); - RETURN(rc); - } - - mode = mode | S_IFREG; - CDEBUG(D_DENTRY, "name %s mode %o o_id %lld\n", - dentry->d_name.name, mode, (unsigned long long)oa.o_id); - inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, - NULL, 0, mode, oa.o_id); - - if (IS_ERR(inode)) { - rc = PTR_ERR(inode); - CERROR("error creating MDS object for id %Ld: rc = %d\n", - (unsigned long long)oa.o_id, rc); - GOTO(out_destroy, rc); - } - - inode->i_op = &ll_file_inode_operations; - inode->i_fop = &ll_file_operations; - inode->i_mapping->a_ops = &ll_aops; - rc = ext2_add_nondir(dentry, inode); - /* XXX Handle err, but this will probably get more complex anyways */ - - RETURN(rc); - -out_destroy: - err = obd_destroy(ll_i2obdconn(dir), &oa); - if (err) - CERROR("error destroying object %Ld in error path: err = %d\n", - (unsigned long long)oa.o_id, err); - return err; -} /* ll_create */ - - -static int ll_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev) -{ - struct inode * inode = ll_create_node(dir, dentry->d_name.name, - dentry->d_name.len, NULL, 0, - mode, 0); - int err = PTR_ERR(inode); - if (!IS_ERR(inode)) { - init_special_inode(inode, mode, rdev); - err = ext2_add_nondir(dentry, inode); - } - return err; -} - -static int ll_symlink (struct inode * dir, struct dentry * dentry, - const char * symname) -{ - int err = -ENAMETOOLONG; - unsigned l = strlen(symname); - struct inode * inode; - struct ll_inode_info *oinfo; - - if (l > LL_INLINESZ) - return err; - - inode = ll_create_node(dir, dentry->d_name.name, - dentry->d_name.len, symname, l, - S_IFLNK | S_IRWXUGO, 0); - err = PTR_ERR(inode); - if (IS_ERR(inode)) - return err; - - oinfo = ll_i2info(inode); - - inode->i_op = &ll_fast_symlink_inode_operations; - memcpy(oinfo->lli_inline, symname, l); - inode->i_size = l-1; - - err = ext2_add_nondir(dentry, inode); - - if (err) { - ext2_dec_count(inode); - iput (inode); - } - return err; -} - -static int ll_link (struct dentry * old_dentry, struct inode * dir, - struct dentry *dentry) -{ - int err; - struct inode *inode = old_dentry->d_inode; - - if (S_ISDIR(inode->i_mode)) - return -EPERM; - - if (inode->i_nlink >= EXT2_LINK_MAX) - return -EMLINK; - - err = ll_mdc_link(old_dentry, dir, - dentry->d_name.name, dentry->d_name.len); - if (err) { - EXIT; - return err; - } - - inode->i_ctime = CURRENT_TIME; - ext2_inc_count(inode); - atomic_inc(&inode->i_count); - - return ext2_add_nondir(dentry, inode); -} - - -static int ll_mkdir(struct inode * dir, struct dentry * dentry, int mode) -{ - struct inode * inode; - int err = -EMLINK; - ENTRY; - - if (dir->i_nlink >= EXT2_LINK_MAX) - goto out; - - ext2_inc_count(dir); - - inode = ll_create_node (dir, dentry->d_name.name, - dentry->d_name.len, NULL, 0, - S_IFDIR | mode, 0); - err = PTR_ERR(inode); - if (IS_ERR(inode)) - goto out_dir; - - inode->i_op = &ll_dir_inode_operations; - inode->i_fop = &ll_dir_operations; - inode->i_mapping->a_ops = &ll_aops; - inode->i_nlink = 1; - ext2_inc_count(inode); - - err = ext2_make_empty(inode, dir); - if (err) - goto out_fail; - - err = ll_add_link(dentry, inode); - if (err) - goto out_fail; - - d_instantiate(dentry, inode); -out: - EXIT; - return err; - -out_fail: - ext2_dec_count(inode); - ext2_dec_count(inode); - iput(inode); - EXIT; -out_dir: - ext2_dec_count(dir); - EXIT; - goto out; -} - -static int ll_unlink(struct inode * dir, struct dentry *dentry) -{ - struct inode * inode = dentry->d_inode; - struct ext2_dir_entry_2 * de; - struct page * page; - int err = -ENOENT; - - de = ext2_find_entry (dir, dentry, &page); - if (!de) - goto out; - - err = ll_mdc_unlink(dir, dentry->d_inode, - dentry->d_name.name, dentry->d_name.len); - if (err) - goto out; - - err = ext2_delete_entry (de, page); - if (err) - goto out; - - inode->i_ctime = dir->i_ctime; - ext2_dec_count(inode); - err = 0; -out: - return err; -} - -static int ll_rmdir(struct inode * dir, struct dentry *dentry) -{ - struct inode * inode = dentry->d_inode; - int err = -ENOTEMPTY; - - if (ext2_empty_dir(inode)) { - err = ll_unlink(dir, dentry); - if (!err) { - inode->i_size = 0; - ext2_dec_count(inode); - ext2_dec_count(dir); - } - } - return err; -} - -static int ll_rename (struct inode * old_dir, struct dentry * old_dentry, - struct inode * new_dir, struct dentry * new_dentry ) -{ - struct inode * old_inode = old_dentry->d_inode; - struct inode * new_inode = new_dentry->d_inode; - struct page * dir_page = NULL; - struct ext2_dir_entry_2 * dir_de = NULL; - struct page * old_page; - struct ext2_dir_entry_2 * old_de; - int err = -ENOENT; - - err = ll_mdc_rename(old_dir, new_dir, old_dentry, new_dentry); - if (err) - goto out; - - old_de = ext2_find_entry (old_dir, old_dentry, &old_page); - if (!old_de) - goto out; - - if (S_ISDIR(old_inode->i_mode)) { - err = -EIO; - dir_de = ext2_dotdot(old_inode, &dir_page); - if (!dir_de) - goto out_old; - } - - if (new_inode) { - struct page *new_page; - struct ext2_dir_entry_2 *new_de; - - err = -ENOTEMPTY; - if (dir_de && !ext2_empty_dir (new_inode)) - goto out_dir; - - err = -ENOENT; - new_de = ext2_find_entry (new_dir, new_dentry, &new_page); - if (!new_de) - goto out_dir; - ext2_inc_count(old_inode); - ext2_set_link(new_dir, new_de, new_page, old_inode); - new_inode->i_ctime = CURRENT_TIME; - if (dir_de) - new_inode->i_nlink--; - ext2_dec_count(new_inode); - } else { - if (dir_de) { - err = -EMLINK; - if (new_dir->i_nlink >= EXT2_LINK_MAX) - goto out_dir; - } - ext2_inc_count(old_inode); - err = ll_add_link(new_dentry, old_inode); - if (err) { - ext2_dec_count(old_inode); - goto out_dir; - } - if (dir_de) - ext2_inc_count(new_dir); - } - - ext2_delete_entry (old_de, old_page); - ext2_dec_count(old_inode); - - if (dir_de) { - ext2_set_link(old_inode, dir_de, dir_page, new_dir); - ext2_dec_count(old_dir); - } - return 0; - - -out_dir: - if (dir_de) { - kunmap(dir_page); - page_cache_release(dir_page); - } -out_old: - kunmap(old_page); - page_cache_release(old_page); -out: - return err; -} - -struct inode_operations ll_dir_inode_operations = { - create: ll_create, - lookup: ll_lookup, - link: ll_link, - unlink: ll_unlink, - symlink: ll_symlink, - mkdir: ll_mkdir, - rmdir: ll_rmdir, - mknod: ll_mknod, - rename: ll_rename, - setattr: ll_setattr -}; diff --git a/lustre/llite/recover.c b/lustre/llite/recover.c deleted file mode 100644 index bad0c4a..0000000 --- a/lustre/llite/recover.c +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Lustre Light Super operations - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copryright (C) 1996 Peter J. Braam - * Copryright (C) 1999 Stelias Computing Inc. - * Copryright (C) 1999 Seagate Technology Inc. - * Copryright (C) 2001 Mountain View Data, Inc. - * Copryright (C) 2002 Cluster File Systems, Inc. - * - */ - -#include -#include - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include - -static int ll_reconnect(struct ll_sb_info *sbi) -{ - struct ll_fid rootfid; - __u64 last_committed, last_rcvd; - __u32 last_xid; - int err; - struct ptlrpc_request *request; - - ptlrpc_readdress_connection(sbi->ll_mds_conn, "mds"); - - err = connmgr_connect(ptlrpc_connmgr, sbi->ll_mds_conn); - if (err) { - CERROR("cannot connect to MDS: rc = %d\n", err); - ptlrpc_put_connection(sbi->ll_mds_conn); - GOTO(out_disc, err = -ENOTCONN); - } - sbi->ll_mds_conn->c_level = LUSTRE_CONN_CON; - - /* XXX: need to store the last_* values somewhere */ - err = mdc_connect(&sbi->ll_mds_client, sbi->ll_mds_conn, - &rootfid, &last_committed, - &last_rcvd, - &last_xid, - &request); - if (err) { - CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_disc, err = -ENOTCONN); - } - sbi->ll_mds_client.cli_last_rcvd = last_xid; - sbi->ll_mds_conn->c_level = LUSTRE_CONN_RECOVD; - - out_disc: - return err; -} - - -int ll_recover(struct ptlrpc_client *cli) -{ - struct ptlrpc_request *req; - struct list_head *tmp, *pos; - struct ll_sb_info *sbi = cli->cli_data; - int rc = 0; - ENTRY; - - /* 1. reconnect */ - ll_reconnect(sbi); - - /* 2. walk the request list */ - spin_lock(&cli->cli_lock); - list_for_each_safe(tmp, pos, &cli->cli_sending_head) { - req = list_entry(tmp, struct ptlrpc_request, rq_list); - - /* replay what needs to be replayed */ - if (req->rq_flags & PTL_RPC_FL_REPLAY) { - CDEBUG(D_INODE, "req %Ld needs replay [last rcvd %Ld]\n", - req->rq_xid, cli->cli_last_rcvd); - rc = ptlrpc_replay_req(req); - if (rc) { - CERROR("recovery replay error %d for request %Ld\n", - rc, req->rq_xid); - GOTO(out, rc); - } - } - - /* server has seen req, we have reply: skip */ - if ((req->rq_flags & PTL_RPC_FL_REPLIED) && - req->rq_xid <= cli->cli_last_rcvd) { - CDEBUG(D_INODE, "req %Ld was complete: skip [last rcvd %Ld]\n", - req->rq_xid, cli->cli_last_rcvd); - continue; - } - - /* server has lost req, we have reply: resend, ign reply */ - if ((req->rq_flags & PTL_RPC_FL_REPLIED) && - req->rq_xid > cli->cli_last_rcvd) { - CDEBUG(D_INODE, "lost req %Ld have rep: replay [last rcvd %Ld]\n", - req->rq_xid, cli->cli_last_rcvd); - rc = ptlrpc_replay_req(req); - if (rc) { - CERROR("request resend error %d for request %Ld\n", - rc, req->rq_xid); - GOTO(out, rc); - } - } - - /* server has seen req, we have lost reply: -ERESTARTSYS */ - if ( !(req->rq_flags & PTL_RPC_FL_REPLIED) && - req->rq_xid <= cli->cli_last_rcvd) { - CDEBUG(D_INODE, "lost rep %Ld srv did req: restart [last rcvd %Ld]\n", - req->rq_xid, cli->cli_last_rcvd); - ptlrpc_restart_req(req); - } - - /* service has not seen req, no reply: resend */ - if ( !(req->rq_flags & PTL_RPC_FL_REPLIED) && - req->rq_xid > cli->cli_last_rcvd) { - CDEBUG(D_INODE, "lost rep/req %Ld: resend [last rcvd %Ld]\n", - req->rq_xid, cli->cli_last_rcvd); - ptlrpc_resend_req(req); - } - - } - - sbi->ll_mds_conn->c_level = LUSTRE_CONN_FULL; - recovd_cli_fixed(cli); - - /* Finally, continue what we delayed since recovery started */ - list_for_each_safe(tmp, pos, &cli->cli_delayed_head) { - req = list_entry(tmp, struct ptlrpc_request, rq_list); - ptlrpc_continue_req(req); - } - - EXIT; - out: - spin_unlock(&cli->cli_lock); - return rc; -} diff --git a/lustre/llite/super.c b/lustre/llite/super.c deleted file mode 100644 index 83093a1..0000000 --- a/lustre/llite/super.c +++ /dev/null @@ -1,455 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Lustre Light Super operations - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copryright (C) 1996 Peter J. Braam - * Copryright (C) 1999 Stelias Computing Inc. - * Copryright (C) 1999 Seagate Technology Inc. - * Copryright (C) 2001 Mountain View Data, Inc. - * Copryright (C) 2002 Cluster File Systems, Inc. - * - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include - -kmem_cache_t *ll_file_data_slab; -extern struct address_space_operations ll_aops; -extern struct address_space_operations ll_dir_aops; -struct super_operations ll_super_operations; - -extern int ll_recover(struct ptlrpc_client *); -extern int ll_commitcbd_setup(struct ll_sb_info *); -extern int ll_commitcbd_cleanup(struct ll_sb_info *); - -static char *ll_read_opt(const char *opt, char *data) -{ - char *value; - char *retval; - ENTRY; - - CDEBUG(D_INFO, "option: %s, data %s\n", opt, data); - if ( strncmp(opt, data, strlen(opt)) ) - RETURN(NULL); - if ( (value = strchr(data, '=')) == NULL ) - RETURN(NULL); - - value++; - OBD_ALLOC(retval, strlen(value) + 1); - if ( !retval ) { - CERROR("out of memory!\n"); - RETURN(NULL); - } - - memcpy(retval, value, strlen(value)+1); - CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); - RETURN(retval); -} - -static void ll_options(char *options, char **dev, char **vers) -{ - char *this_char; - ENTRY; - - if (!options) { - EXIT; - return; - } - - for (this_char = strtok (options, ","); - this_char != NULL; - this_char = strtok (NULL, ",")) { - CDEBUG(D_INFO, "this_char %s\n", this_char); - if ( (!*dev && (*dev = ll_read_opt("device", this_char)))|| - (!*vers && (*vers = ll_read_opt("version", this_char))) ) - continue; - } - EXIT; -} - -static struct super_block * ll_read_super(struct super_block *sb, - void *data, int silent) -{ - struct inode *root = 0; - struct ll_sb_info *sbi; - char *device = NULL; - char *version = NULL; - int devno; - int err; - struct ll_fid rootfid; - __u64 last_committed, last_rcvd; - __u32 last_xid; - struct ptlrpc_request *request = NULL; - - ENTRY; - MOD_INC_USE_COUNT; - - OBD_ALLOC(sbi, sizeof(*sbi)); - if (!sbi) { - MOD_DEC_USE_COUNT; - RETURN(NULL); - } - - sb->u.generic_sbp = sbi; - - ll_options(data, &device, &version); - - if (!device) { - CERROR("no device\n"); - GOTO(out_free, sb = NULL); - } - - devno = simple_strtoul(device, NULL, 0); - if (devno >= MAX_OBD_DEVICES) { - CERROR("device of %s too high\n", device); - GOTO(out_free, sb = NULL); - } - - sbi->ll_conn.oc_dev = &obd_dev[devno]; - err = obd_connect(&sbi->ll_conn); - if (err) { - CERROR("cannot connect to %s: rc = %d\n", device, err); - GOTO(out_free, sb = NULL); - } - - sbi->ll_namespace = ldlm_namespace_new(NULL, 1); - if (sbi->ll_namespace == NULL) { - CERROR("failed to create local lock namespace\n"); - GOTO(out_obd, sb = NULL); - } - - ptlrpc_init_client(ptlrpc_connmgr, ll_recover, - MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, - &sbi->ll_mds_client); - - sbi->ll_mds_client.cli_data = sbi; - sbi->ll_mds_client.cli_name = "mdc"; - sbi->ll_mds_conn = ptlrpc_uuid_to_connection("mds"); - if (!sbi->ll_mds_conn) { - CERROR("cannot find MDS\n"); - GOTO(out_ldlm, sb = NULL); - } - - err = connmgr_connect(ptlrpc_connmgr, sbi->ll_mds_conn); - if (err) { - CERROR("cannot connect to MDS: rc = %d\n", err); - GOTO(out_rpc, sb = NULL); - } - - sbi->ll_mds_conn->c_level = LUSTRE_CONN_FULL; - - /* XXX: need to store the last_* values somewhere */ - err = mdc_connect(&sbi->ll_mds_client, sbi->ll_mds_conn, - &rootfid, &last_committed, &last_rcvd, &last_xid, - &request); - if (err) { - CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_disc, sb = NULL); - } - CDEBUG(D_SUPER, "rootfid %ld\n", (unsigned long)rootfid.id); - sbi->ll_rootino = rootfid.id; - - sb->s_maxbytes = 1ULL << 36; - /* XXX get this with a get_info call (like we have in OBDFS), - this info call should return the blocksize of the MDS */ - sb->s_blocksize = 4096; - sb->s_blocksize_bits = 12; - sb->s_magic = LL_SUPER_MAGIC; - sb->s_op = &ll_super_operations; - - /* make root inode */ - err = mdc_getattr(&sbi->ll_mds_client, sbi->ll_mds_conn, - sbi->ll_rootino, S_IFDIR, - OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request); - if (err) { - CERROR("mdc_getattr failed for root: rc = %d\n", err); - GOTO(out_mdc, sb = NULL); - } - - /* initialize committed transaction callback daemon */ - spin_lock_init(&sbi->ll_commitcbd_lock); - init_waitqueue_head(&sbi->ll_commitcbd_waitq); - init_waitqueue_head(&sbi->ll_commitcbd_ctl_waitq); - sbi->ll_commitcbd_flags = 0; - err = ll_commitcbd_setup(sbi); - if (err) { - CERROR("failed to start commit callback daemon: rc = %d\n",err); - GOTO(out_mdc, sb = NULL); - } - - root = iget4(sb, sbi->ll_rootino, NULL, - lustre_msg_buf(request->rq_repmsg, 0)); - if (root) { - sb->s_root = d_alloc_root(root); - } else { - CERROR("lustre_lite: bad iget4 for root\n"); - GOTO(out_cdb, sb = NULL); - } - - ptlrpc_free_req(request); - -out_dev: - if (device) - OBD_FREE(device, strlen(device) + 1); - if (version) - OBD_FREE(version, strlen(version) + 1); - - RETURN(sb); - -out_cdb: - ll_commitcbd_cleanup(sbi); -out_mdc: - ptlrpc_cleanup_client(&sbi->ll_mds_client); -out_disc: - ptlrpc_free_req(request); -out_rpc: - ptlrpc_put_connection(sbi->ll_mds_conn); -out_ldlm: - ldlm_namespace_free(sbi->ll_namespace); -out_obd: - obd_disconnect(&sbi->ll_conn); -out_free: - OBD_FREE(sbi, sizeof(*sbi)); - - MOD_DEC_USE_COUNT; - goto out_dev; -} /* ll_read_super */ - -static void ll_put_super(struct super_block *sb) -{ - struct ll_sb_info *sbi = sb->u.generic_sbp; - ENTRY; - ll_commitcbd_cleanup(sbi); - ptlrpc_cleanup_client(&sbi->ll_mds_client); - ptlrpc_put_connection(sbi->ll_mds_conn); - ldlm_namespace_free(sbi->ll_namespace); - obd_disconnect(&sbi->ll_conn); - OBD_FREE(sb->u.generic_sbp, sizeof(*sbi)); - MOD_DEC_USE_COUNT; - EXIT; -} /* ll_put_super */ - - -extern inline struct obdo * ll_oa_from_inode(struct inode *inode, int valid); - -static void ll_delete_inode(struct inode *inode) -{ - if (S_ISREG(inode->i_mode)) { - int err; - struct obdo *oa = ll_oa_from_inode(inode, OBD_MD_FLNOTOBD); - - if (!oa) { - CERROR("no memory\n"); - GOTO(out, -ENOMEM); - } - - err = obd_destroy(ll_i2obdconn(inode), oa); - CDEBUG(D_INODE, "obd destroy of %Ld error %d\n", - (unsigned long long)oa->o_id, err); - obdo_free(oa); - } -out: - clear_inode(inode); -} - -/* like inode_setattr, but doesn't mark the inode dirty */ -static int ll_attr2inode(struct inode * inode, struct iattr * attr, int trunc) -{ - unsigned int ia_valid = attr->ia_valid; - int error = 0; - - if ((ia_valid & ATTR_SIZE) && trunc ) { - error = vmtruncate(inode, attr->ia_size); - if (error) - goto out; - } else if (ia_valid & ATTR_SIZE) { - inode->i_size = attr->ia_size; - } - - if (ia_valid & ATTR_UID) - inode->i_uid = attr->ia_uid; - if (ia_valid & ATTR_GID) - inode->i_gid = attr->ia_gid; - if (ia_valid & ATTR_ATIME) - inode->i_atime = attr->ia_atime; - if (ia_valid & ATTR_MTIME) - inode->i_mtime = attr->ia_mtime; - if (ia_valid & ATTR_CTIME) - inode->i_ctime = attr->ia_ctime; - if (ia_valid & ATTR_MODE) { - inode->i_mode = attr->ia_mode; - if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) - inode->i_mode &= ~S_ISGID; - } -out: - return error; -} - -int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc) -{ - struct ptlrpc_request *request = NULL; - struct ll_sb_info *sbi = ll_i2sbi(inode); - int err; - - ENTRY; - - /* change incore inode */ - ll_attr2inode(inode, attr, do_trunc); - - err = mdc_setattr(&sbi->ll_mds_client, sbi->ll_mds_conn, inode, attr, - &request); - if (err) - CERROR("mdc_setattr fails (%d)\n", err); - - ptlrpc_req_finished(request); - - RETURN(err); -} - -int ll_setattr(struct dentry *de, struct iattr *attr) -{ - return ll_inode_setattr(de->d_inode, attr, 1); -} - -static int ll_statfs(struct super_block *sb, struct statfs *buf) -{ - struct statfs tmp; - int err; - ENTRY; - - err = obd_statfs(&ll_s2sbi(sb)->ll_conn, &tmp); - if (err) { - CERROR("obd_statfs fails (%d)\n", err); - RETURN(err); - } - memcpy(buf, &tmp, sizeof(*buf)); - CDEBUG(D_SUPER, "statfs returns avail %ld\n", tmp.f_bavail); - - RETURN(err); -} - -static void inline ll_to_inode(struct inode *dst, struct mds_body *body) -{ - struct ll_inode_info *ii = - (struct ll_inode_info *) &dst->u.generic_ip; - - /* core attributes first */ - if ( body->valid & OBD_MD_FLID ) - dst->i_ino = body->ino; - if ( body->valid & OBD_MD_FLATIME ) - dst->i_atime = body->atime; - if ( body->valid & OBD_MD_FLMTIME ) - dst->i_mtime = body->mtime; - if ( body->valid & OBD_MD_FLCTIME ) - dst->i_ctime = body->ctime; - if ( body->valid & OBD_MD_FLSIZE ) - dst->i_size = body->size; - if ( body->valid & OBD_MD_FLMODE ) - dst->i_mode = body->mode; - if ( body->valid & OBD_MD_FLUID ) - dst->i_uid = body->uid; - if ( body->valid & OBD_MD_FLGID ) - dst->i_gid = body->gid; - if ( body->valid & OBD_MD_FLFLAGS ) - dst->i_flags = body->flags; - if ( body->valid & OBD_MD_FLNLINK ) - dst->i_nlink = body->nlink; - if ( body->valid & OBD_MD_FLGENER ) - dst->i_generation = body->generation; - - /* this will become more elaborate for striping etc */ - if (body->valid & OBD_MD_FLOBJID) - ii->lli_objid = body->objid; -#if 0 - - if (obdo_has_inline(oa)) { - if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || - S_ISFIFO(inode->i_mode)) { - obd_rdev rdev = *((obd_rdev *)oa->o_inline); - CDEBUG(D_INODE, - "copying device %x from obdo to inode\n", rdev); - init_special_inode(inode, inode->i_mode, rdev); - } else { - CDEBUG(D_INFO, "copying inline from obdo to inode\n"); - memcpy(oinfo->lli_inline, oa->o_inline, OBD_INLINESZ); - } - oinfo->lli_flags |= OBD_FL_INLINEDATA; - } -#endif -} /* ll_to_inode */ - -static inline void ll_read_inode2(struct inode *inode, void *opaque) -{ - struct mds_body *body = opaque; - - ENTRY; - ll_to_inode(inode, body); - - /* OIDEBUG(inode); */ - - if (S_ISREG(inode->i_mode)) { - inode->i_op = &ll_file_inode_operations; - inode->i_fop = &ll_file_operations; - inode->i_mapping->a_ops = &ll_aops; - EXIT; - } else if (S_ISDIR(inode->i_mode)) { - inode->i_op = &ll_dir_inode_operations; - inode->i_fop = &ll_dir_operations; - inode->i_mapping->a_ops = &ll_dir_aops; - EXIT; - } else if (S_ISLNK(inode->i_mode)) { - inode->i_op = &ll_fast_symlink_inode_operations; - EXIT; - } else { - init_special_inode(inode, inode->i_mode, - ((int *)ll_i2info(inode)->lli_inline)[0]); - EXIT; - } - - return; -} - -/* exported operations */ -struct super_operations ll_super_operations = -{ - read_inode2: ll_read_inode2, - delete_inode: ll_delete_inode, - put_super: ll_put_super, - statfs: ll_statfs -}; - -struct file_system_type lustre_lite_fs_type = { - "lustre_lite", 0, ll_read_super, NULL -}; - -static int __init init_lustre_lite(void) -{ - printk(KERN_INFO "Lustre Lite 0.0.1, braam@clusterfs.com\n"); - ll_file_data_slab = kmem_cache_create("ll_file_data", - sizeof(struct ll_file_data), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ll_file_data_slab == NULL) - return -ENOMEM; - return register_filesystem(&lustre_lite_fs_type); -} - -static void __exit exit_lustre_lite(void) -{ - unregister_filesystem(&lustre_lite_fs_type); - kmem_cache_destroy(ll_file_data_slab); -} - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Lustre Lite Client File System v1.0"); -MODULE_LICENSE("GPL"); - -module_init(init_lustre_lite); -module_exit(exit_lustre_lite); diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c deleted file mode 100644 index ab87a92..0000000 --- a/lustre/llite/symlink.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * linux/fs/ext2/symlink.c - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * ext2 symlink handling code - * - * Modified for OBDFS: - * Copyright (C) 1999 Seagate Technology Inc. (author: braam@stelias.com) - */ - -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LLITE - -#include /* for ENTRY and EXIT only */ -#include - -static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) -{ - struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode); - struct ptlrpc_request *request; - char *tmp; - int rc, size; - ENTRY; - - rc = mdc_getattr(&sbi->ll_mds_client, sbi->ll_mds_conn, - dentry->d_inode->i_ino, S_IFLNK, - OBD_MD_LINKNAME, dentry->d_inode->i_size, &request); - if (rc) { - CERROR("failure %d inode %ld\n", rc, - (long)dentry->d_inode->i_ino); - ptlrpc_free_req(request); - RETURN(rc); - } - - tmp = lustre_msg_buf(request->rq_repmsg, 1); - size = MIN(request->rq_repmsg->buflens[1], buflen); - rc = copy_to_user(buffer, tmp, size); - if (rc == 0) - rc = size; - - ptlrpc_free_req(request); - RETURN(rc); -} - -extern int ll_setattr(struct dentry *de, struct iattr *attr); -struct inode_operations ll_fast_symlink_inode_operations = { - readlink: ll_readlink, - setattr: ll_setattr -}; diff --git a/lustre/llite/sysctl.c b/lustre/llite/sysctl.c deleted file mode 100644 index 3c4ce1f..0000000 --- a/lustre/llite/sysctl.c +++ /dev/null @@ -1,65 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct ctl_table_header *ll_table_header = NULL; - -int ll_debug_level = 0; -int ll_print_entry = 1; - - -#define LL_SYSCTL 1 - -#define LL_DEBUG 1 /* control debugging */ -#define LL_ENTRY 2 /* control enter/leave pattern */ -#define LL_TIMEOUT 3 /* timeout on upcalls to become intrble */ -#define LL_HARD 4 /* mount type "hard" or "soft" */ -#define LL_VARS 5 -#define LL_INDEX 6 -#define LL_RESET 7 - -#define LL_VARS_SLOT 2 - -static ctl_table ll_table[] = { - {LL_DEBUG, "debug", &ll_debug_level, sizeof(int), 0644, NULL, &proc_dointvec}, - {LL_ENTRY, "trace", &ll_print_entry, sizeof(int), 0644, NULL, &proc_dointvec}, - { 0 } -}; - -static ctl_table top_table[] = { - {LL_SYSCTL, "lustre_light", NULL, 0, 0555, ll_table}, - {0} -}; - -void ll_sysctl_init (void) -{ - -#ifdef CONFIG_SYSCTL - if ( !ll_table_header ) - ll_table_header = register_sysctl_table(top_table, 0); -#endif -} - -void ll_sysctl_clean (void) -{ -#ifdef CONFIG_SYSCTL - if ( ll_table_header ) - unregister_sysctl_table(ll_table_header); - ll_table_header = NULL; -#endif -} diff --git a/lustre/lov/Makefile.am b/lustre/lov/Makefile.am deleted file mode 100644 index 8351f5b..0000000 --- a/lustre/lov/Makefile.am +++ /dev/null @@ -1,14 +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 - -DEFS := - -#MODULE = lov -#modulefs_DATA = lov.o -#EXTRA_PROGRAMS = lov - -#lov_SOURCES = lov_obd.c - -include $(top_srcdir)/Rules diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c deleted file mode 100644 index e74d0fe..0000000 --- a/lustre/lov/lov_obd.c +++ /dev/null @@ -1,353 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * lov/lov.c - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * Author: Phil Schwan - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - */ - -#define EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_LOV - -#include -#include - -extern struct obd_device obd_dev[MAX_OBD_DEVICES]; - -/* obd methods */ -static int lov_connect(struct obd_conn *conn) -{ - int rc; - - MOD_INC_USE_COUNT; - rc = gen_connect(conn); - - if (rc) - MOD_DEC_USE_COUNT; - - return rc; -} - -static int lov_disconnect(struct obd_conn *conn) -{ - int rc; - - rc = gen_disconnect(conn); - if (!rc) - MOD_DEC_USE_COUNT; - - /* XXX cleanup preallocated inodes */ - return rc; -} - -static int lov_getattr(struct obd_conn *conn, struct obdo *oa) -{ - int rc; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - rc = obd_getattr(&conn->oc_dev->obd_multi_conn[0], oa); - RETURN(rc); -} - -static int lov_setattr(struct obd_conn *conn, struct obdo *oa) -{ - int rc, retval, i; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - for (i = 0; i < conn->oc_dev->obd_multi_count; i++) { - rc = obd_setattr(&conn->oc_dev->obd_multi_conn[i], oa); - if (i == 0) - retval = rc; - else if (retval != rc) - CERROR("different results on multiple OBDs!\n"); - } - - RETURN(rc); -} - -static int lov_open(struct obd_conn *conn, struct obdo *oa) -{ - int rc, retval, i; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - for (i = 0; i < conn->oc_dev->obd_multi_count; i++) { - rc = obd_open(&conn->oc_dev->obd_multi_conn[i], oa); - if (i == 0) - retval = rc; - else if (retval != rc) - CERROR("different results on multiple OBDs!\n"); - } - - RETURN(rc); -} - -static int lov_close(struct obd_conn *conn, struct obdo *oa) -{ - int rc, retval, i; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - for (i = 0; i < conn->oc_dev->obd_multi_count; i++) { - rc = obd_close(&conn->oc_dev->obd_multi_conn[i], oa); - if (i == 0) - retval = rc; - else if (retval != rc) - CERROR("different results on multiple OBDs!\n"); - } - - RETURN(rc); -} - -static int lov_create(struct obd_conn *conn, struct obdo *oa) -{ - int rc, i; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - for (i = 0; i < conn->oc_dev->obd_multi_count; i++) - rc = obd_create(&conn->oc_dev->obd_multi_conn[i], oa); - - return rc; -} - -static int filter_destroy(struct obd_conn *conn, struct obdo *oa) -{ -#if 0 - struct obd_device * obddev; - struct obd_client * cli; - struct inode * inode; - struct file *dir; - struct file *object; - int rc; - struct obd_run_ctxt saved; - - if (!(cli = gen_client(conn))) { - CERROR("invalid client %u\n", conn->oc_id); - EXIT; - return -EINVAL; - } - - obddev = conn->oc_dev; - object = filter_obj_open(obddev, oa->o_id, oa->o_mode); - if (!object || IS_ERR(object)) { - EXIT; - return -ENOENT; - } - - inode = object->f_dentry->d_inode; - inode->i_nlink = 1; - inode->i_mode = 010000; - - push_ctxt(&saved, &obddev->u.filter.fo_ctxt); - dir = filter_parent(oa->o_id, oa->o_mode); - if (IS_ERR(dir)) { - rc = PTR_ERR(dir); - EXIT; - goto out; - } - dget(dir->f_dentry); - dget(object->f_dentry); - rc = vfs_unlink(dir->f_dentry->d_inode, object->f_dentry); - - filp_close(dir, 0); - filp_close(object, 0); -out: - pop_ctxt(&saved); - EXIT; - return rc; -#endif - return 0; -} - -/* FIXME: maybe we'll just make one node the authoritative attribute node, then - * we can send this 'punch' to just the authoritative node and the nodes - * that the punch will affect. */ -static int lov_punch(struct obd_conn *conn, struct obdo *oa, - obd_size count, obd_off offset) -{ - int rc, retval, i; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - for (i = 0; i < conn->oc_dev->obd_multi_count; i++) { - rc = obd_punch(&conn->oc_dev->obd_multi_conn[i], oa, count, - offset); - if (i == 0) - retval = rc; - else if (retval != rc) - CERROR("different results on multiple OBDs!\n"); - } - - RETURN(rc); -} - -/* buffer must lie in user memory here */ -static int lov_read(struct obd_conn *conn, struct obdo *oa, char *buf, - obd_size *count, obd_off offset) -{ - int rc, i; - obd_off off = offset; - obd_size retval = 0; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - while (off < offset + count) { - int stripe, conn; - obd_size size, tmp; - - stripe = off / conn->oc_dev->u.lov.lov_stripe_size; - size = (stripe + 1) * conn->oc_dev->u.lov.lov_strip_size - off; - if (size > *count) - size = *count; - - - conn = stripe % conn->oc_dev->obd_multi_count; - - tmp = size; - rc = obd_read(&conn->oc_dev->obd_multi_conn[conn], oa, buf, - &size, off); - if (rc == 0) - retval += size; - else { - CERROR("read(off=%Lu, count=%Lu): %d\n", - (unsigned long long)off, - (unsigned long long)size, rc); - break; - } - - buf += size; - } - - *count = retval; - RETURN(rc); -} - - -/* buffer must lie in user memory here */ -static int filter_write(struct obd_conn *conn, struct obdo *oa, char *buf, - obd_size *count, obd_off offset) -{ - int err; - struct file * file; - unsigned long retval; - - ENTRY; - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "invalid client %u\n", conn->oc_id); - EXIT; - return -EINVAL; - } - - file = filter_obj_open(conn->oc_dev, oa->o_id, oa->o_mode); - if (!file || IS_ERR(file)) { - EXIT; - return -PTR_ERR(file); - } - - /* count doubles as retval */ - retval = file->f_op->write(file, buf, *count, (loff_t *)&offset); - filp_close(file, 0); - - if ( retval >= 0 ) { - err = 0; - *count = retval; - EXIT; - } else { - err = retval; - *count = 0; - EXIT; - } - - return err; -} - -static int lov_enqueue(struct obd_conn *conn, struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock, __u64 *res_id, - __u32 type, struct ldlm_extent *extent, __u32 mode, - int *flags, void *data, int datalen, - struct ldlm_handle *lockh) -{ - int rc; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - rc = obd_enqueue(&conn->oc_dev->obd_multi_conn[0], ns, parent_lock, - res_id, type, extent, mode, flags, data, datalen, - lockh); - RETURN(rc); -} - -static int lov_cancel(struct obd_conn *conn, __u32 mode, - struct ldlm_handle *lockh) -{ - int rc; - ENTRY; - - if (!gen_client(conn)) - RETURN(-EINVAL); - - rc = obd_cancel(&conn->oc_dev->obd_multi_conn[0], oa); - RETURN(rc); -} - -struct obd_ops lov_obd_ops = { - o_setup: gen_multi_setup, - o_cleanup: gen_multi_cleanup, - o_create: lov_create, - o_destroy: lov_destroy, - o_getattr: lov_getattr, - o_setattr: lov_setattr, - o_open: lov_open, - o_close: lov_close, - o_connect: lov_connect, - o_disconnect: lov_disconnect, - o_brw: lov_pgcache_brw, - o_punch: lov_punch, - o_enqueue: lov_enqueue, - o_cancel: lov_cancel -}; - - -#define LOV_VERSION "v0.1" - -static int __init lov_init(void) -{ - printk(KERN_INFO "Lustre Logical Object Volume driver " LOV_VERSION - ", phil@clusterfs.com\n"); - return obd_register_type(&lov_obd_ops, OBD_LOV_DEVICENAME); -} - -static void __exit lov_exit(void) -{ - obd_unregister_type(OBD_LOV_DEVICENAME); -} - -MODULE_AUTHOR("Phil Schwan "); -MODULE_DESCRIPTION("Lustre Logical Object Volume OBD driver v0.1"); -MODULE_LICENSE("GPL"); - -module_init(lov_init); -module_exit(lov_exit); diff --git a/lustre/mdc/.cvsignore b/lustre/mdc/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/mdc/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/mdc/Makefile.am b/lustre/mdc/Makefile.am deleted file mode 100644 index 4069f6b..0000000 --- a/lustre/mdc/Makefile.am +++ /dev/null @@ -1,22 +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 - -DEFS:= - -MODULE = mdc -modulefs_DATA = mdc.o -EXTRA_PROGRAMS = mdc - -LINX=mds_updates.c -mdc_SOURCES = mdc_request.c mdc_reint.c $(LINX) - -mds_updates.c: - test -e mds_updates.c || ln -sf $(top_srcdir)/lib/mds_updates.c . - -dist-hook: - list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done - - -include $(top_srcdir)/Rules diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c deleted file mode 100644 index 2f59c2e..0000000 --- a/lustre/mdc/mdc_reint.c +++ /dev/null @@ -1,219 +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.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 EXPORT_SYMTAB - -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_MDC - -#include -#include - -static int mdc_reint(struct ptlrpc_client *cl, struct ptlrpc_request *request, int level) -{ - int rc; - request->rq_level = level; - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - - if (rc) - CERROR("error in handling %d\n", rc); - - return rc; -} - -int mdc_setattr(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - struct inode *inode, struct iattr *iattr, - struct ptlrpc_request **request) -{ - struct mds_rec_setattr *rec; - struct ptlrpc_request *req; - int rc, size = sizeof(*rec); - ENTRY; - - req = ptlrpc_prep_req(cl, conn, MDS_REINT, 1, &size, NULL); - if (!req) - RETURN(-ENOMEM); - - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_setattr_pack(rec, inode, iattr); - - size = sizeof(struct mds_body); - req->rq_replen = lustre_msg_size(1, &size); - - rc = mdc_reint(cl, req, LUSTRE_CONN_FULL); - *request = req; - if (rc == -ERESTARTSYS ) - rc = 0; - - RETURN(rc); -} - -int mdc_create(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - struct inode *dir, const char *name, int namelen, - const char *tgt, int tgtlen, int mode, __u64 id, __u32 uid, - __u32 gid, __u64 time, struct ptlrpc_request **request) -{ - struct mds_rec_create *rec; - struct ptlrpc_request *req; - int rc, size[3] = {sizeof(*rec), namelen + 1, tgtlen + 1}; - char *tmp; - int level; - ENTRY; - - req = ptlrpc_prep_req(cl, conn, MDS_REINT, 3, size, NULL); - if (!req) - RETURN(-ENOMEM); - - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_create_pack(rec, dir, mode, id, uid, gid, time); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(name, namelen, tmp); - - if (tgt) { - tmp = lustre_msg_buf(req->rq_reqmsg, 2); - LOGL0(tgt, tgtlen, tmp); - } - - size[0] = sizeof(struct mds_body); - req->rq_replen = lustre_msg_size(1, size); - - level = LUSTRE_CONN_FULL; - resend: - rc = mdc_reint(cl, req, level); - if (rc == -ERESTARTSYS) { - struct mds_update_record_hdr *hdr = - lustre_msg_buf(req->rq_reqmsg, 0); - level = LUSTRE_CONN_RECOVD; - CERROR("Lost reply: re-create rep.\n"); - req->rq_flags = 0; - hdr->ur_opcode = NTOH__u32(REINT_RECREATE); - goto resend; - } - - *request = req; - RETURN(rc); -} - -int mdc_unlink(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - struct inode *dir, struct inode *child, const char *name, - int namelen, struct ptlrpc_request **request) -{ - struct mds_rec_unlink *rec; - struct ptlrpc_request *req; - int rc, size[2] = {sizeof(*rec), namelen + 1}; - char *tmp; - ENTRY; - - req = ptlrpc_prep_req(cl, conn, MDS_REINT, 2, size, NULL); - if (!req) - RETURN(-ENOMEM); - - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_unlink_pack(rec, dir, child); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(name, namelen, tmp); - - size[0] = sizeof(struct mds_body); - req->rq_replen = lustre_msg_size(1, size); - - rc = mdc_reint(cl, req, LUSTRE_CONN_FULL); - *request = req; - if (rc == -ERESTARTSYS ) - rc = 0; - - RETURN(rc); -} - -int mdc_link(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - struct dentry *src, struct inode *dir, const char *name, - int namelen, struct ptlrpc_request **request) -{ - struct mds_rec_link *rec; - struct ptlrpc_request *req; - int rc, size[2] = {sizeof(*rec), namelen + 1}; - char *tmp; - ENTRY; - - req = ptlrpc_prep_req(cl, conn, MDS_REINT, 2, size, NULL); - if (!req) - RETURN(-ENOMEM); - - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_link_pack(rec, src->d_inode, dir); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(name, namelen, tmp); - - size[0] = sizeof(struct mds_body); - req->rq_replen = lustre_msg_size(1, size); - - rc = mdc_reint(cl, req, LUSTRE_CONN_FULL); - *request = req; - if (rc == -ERESTARTSYS ) - rc = 0; - - RETURN(rc); -} - -int mdc_rename(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - struct inode *src, struct inode *tgt, const char *old, - int oldlen, const char *new, int newlen, - struct ptlrpc_request **request) -{ - struct mds_rec_rename *rec; - struct ptlrpc_request *req; - int rc, size[3] = {sizeof(*rec), oldlen + 1, newlen + 1}; - char *tmp; - ENTRY; - - req = ptlrpc_prep_req(cl, conn, MDS_REINT, 3, size, NULL); - if (!req) - RETURN(-ENOMEM); - - rec = lustre_msg_buf(req->rq_reqmsg, 0); - mds_rename_pack(rec, src, tgt); - - tmp = lustre_msg_buf(req->rq_reqmsg, 1); - LOGL0(old, oldlen, tmp); - - if (tgt) { - tmp = lustre_msg_buf(req->rq_reqmsg, 2); - LOGL0(new, newlen, tmp); - } - - size[0] = sizeof(struct mds_body); - req->rq_replen = lustre_msg_size(1, size); - - rc = mdc_reint(cl, req, LUSTRE_CONN_FULL); - *request = req; - if (rc == -ERESTARTSYS ) - rc = 0; - - RETURN(rc); -} diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c deleted file mode 100644 index ed4c5b2e..0000000 --- a/lustre/mdc/mdc_request.c +++ /dev/null @@ -1,398 +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.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 EXPORT_SYMTAB - -#include -#include - -#define DEBUG_SUBSYSTEM S_MDC - -#include -#include - -#define REQUEST_MINOR 244 - -extern int mds_queue_req(struct ptlrpc_request *); - -int mdc_connect(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - struct ll_fid *rootfid, __u64 *last_committed, __u64 *last_rcvd, - __u32 *last_xid, struct ptlrpc_request **request) -{ - struct ptlrpc_request *req; - struct mds_body *body; - int rc, size = sizeof(*body); - ENTRY; - - req = ptlrpc_prep_req(cl, conn, MDS_CONNECT, 1, &size, NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0); - req->rq_level = LUSTRE_CONN_CON; - req->rq_replen = lustre_msg_size(1, &size); - - mds_pack_req_body(req); - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - - if (!rc) { - mds_unpack_rep_body(req); - body = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(rootfid, &body->fid1, sizeof(*rootfid)); - *last_committed = req->rq_repmsg->last_committed; - *last_rcvd = req->rq_repmsg->last_rcvd; - *last_xid = body->last_xid; - - CDEBUG(D_NET, "root ino=%ld, last_committed=%Lu, last_rcvd=%Lu," - " last_xid=%d\n", - (unsigned long)rootfid->id, - (unsigned long long)*last_committed, - (unsigned long long)*last_rcvd, - body->last_xid); - } - - EXIT; - out: - ptlrpc_free_req(req); - return rc; -} - - -int mdc_getattr(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - ino_t ino, int type, unsigned long valid, size_t ea_size, - struct ptlrpc_request **request) -{ - struct ptlrpc_request *req; - struct mds_body *body; - int rc, size[2] = {sizeof(*body), 0}, bufcount = 1; - ENTRY; - - req = ptlrpc_prep_req(cl, conn, MDS_GETATTR, 1, size, NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0); - ll_ino2fid(&body->fid1, ino, 0, type); - body->valid = valid; - - if (valid & OBD_MD_LINKNAME) { - bufcount = 2; - size[1] = ea_size; - } - req->rq_replen = lustre_msg_size(bufcount, size); - req->rq_level = LUSTRE_CONN_FULL; - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - - if (!rc) { - mds_unpack_rep_body(req); - body = lustre_msg_buf(req->rq_repmsg, 0); - CDEBUG(D_NET, "mode: %o\n", body->mode); - } - - EXIT; - out: - *request = req; - return rc; -} - -int mdc_open(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - ino_t ino, int type, int flags, __u64 cookie, __u64 *fh, - struct ptlrpc_request **request) -{ - struct mds_body *body; - int rc, size = sizeof(*body); - struct ptlrpc_request *req; - - req = ptlrpc_prep_req(cl, conn, MDS_OPEN, 1, &size, NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - req->rq_flags |= PTL_RPC_FL_REPLAY; - req->rq_level = LUSTRE_CONN_FULL; - body = lustre_msg_buf(req->rq_reqmsg, 0); - ll_ino2fid(&body->fid1, ino, 0, type); - body->flags = HTON__u32(flags); - body->objid = cookie; - - req->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - - if (!rc) { - mds_unpack_rep_body(req); - body = lustre_msg_buf(req->rq_repmsg, 0); - *fh = body->objid; - } - - EXIT; - out: - *request = req; - return rc; -} - -int mdc_close(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - ino_t ino, int type, __u64 fh, struct ptlrpc_request **request) -{ - struct mds_body *body; - int rc, size = sizeof(*body); - struct ptlrpc_request *req; - - req = ptlrpc_prep_req(cl, conn, MDS_CLOSE, 1, &size, NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0); - ll_ino2fid(&body->fid1, ino, 0, type); - body->objid = fh; - - req->rq_level = LUSTRE_CONN_FULL; - req->rq_replen = lustre_msg_size(0, NULL); - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - - EXIT; - out: - *request = req; - return rc; -} - -int mdc_readpage(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, - ino_t ino, int type, __u64 offset, char *addr, - struct ptlrpc_request **request) -{ - struct ptlrpc_request *req = NULL; - struct ptlrpc_bulk_desc *desc = NULL; - struct ptlrpc_bulk_page *bulk = NULL; - struct mds_body *body; - int rc, size = sizeof(*body); - ENTRY; - - CDEBUG(D_INODE, "inode: %ld\n", (long)ino); - - desc = ptlrpc_prep_bulk(conn); - if (desc == NULL) - GOTO(out, rc = -ENOMEM); - - req = ptlrpc_prep_req(cl, conn, MDS_READPAGE, 1, &size, NULL); - if (!req) - GOTO(out2, rc = -ENOMEM); - - bulk = ptlrpc_prep_bulk_page(desc); - bulk->b_buflen = PAGE_SIZE; - bulk->b_buf = addr; - bulk->b_xid = req->rq_reqmsg->xid; - desc->b_portal = MDS_BULK_PORTAL; - - rc = ptlrpc_register_bulk(desc); - if (rc) { - CERROR("couldn't setup bulk sink: error %d.\n", rc); - GOTO(out2, rc); - } - - body = lustre_msg_buf(req->rq_reqmsg, 0); - body->fid1.id = ino; - body->fid1.f_type = type; - body->size = offset; - - req->rq_replen = lustre_msg_size(1, &size); - req->rq_level = LUSTRE_CONN_FULL; - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - if (rc) { - ptlrpc_abort_bulk(desc); - GOTO(out2, rc); - } else - mds_unpack_rep_body(req); - - EXIT; - out2: - ptlrpc_free_bulk(desc); - out: - *request = req; - return rc; -} - -static int request_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - int err = 0; - struct ptlrpc_client cl; - struct ptlrpc_connection *conn; - struct ptlrpc_request *request; - - ENTRY; - - if (MINOR(inode->i_rdev) != REQUEST_MINOR) - RETURN(-EINVAL); - - if (_IOC_TYPE(cmd) != IOC_REQUEST_TYPE || - _IOC_NR(cmd) < IOC_REQUEST_MIN_NR || - _IOC_NR(cmd) > IOC_REQUEST_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); - } - - ptlrpc_init_client(NULL, NULL, - MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, &cl); - conn = ptlrpc_uuid_to_connection("mds"); - if (!conn) { - CERROR("cannot create client\n"); - RETURN(-EINVAL); - } - - switch (cmd) { - case IOC_REQUEST_GETATTR: { - CERROR("-- getting attr for ino %lu\n", arg); - err = mdc_getattr(&cl, conn, arg, S_IFDIR, ~0, 0, &request); - CERROR("-- done err %d\n", err); - - GOTO(out, err); - } - - case IOC_REQUEST_READPAGE: { - char *buf; - OBD_ALLOC(buf, PAGE_SIZE); - if (!buf) { - err = -ENOMEM; - GOTO(out, err); - } - CERROR("-- readpage 0 for ino %lu\n", arg); - err = mdc_readpage(&cl, conn, arg, S_IFDIR, 0, buf, &request); - CERROR("-- done err %d\n", err); - OBD_FREE(buf, PAGE_SIZE); - - GOTO(out, err); - } - - case IOC_REQUEST_SETATTR: { - struct inode inode; - struct iattr iattr; - - inode.i_ino = arg; - inode.i_generation = 0; - iattr.ia_mode = 040777; - iattr.ia_atime = 0; - iattr.ia_valid = ATTR_MODE | ATTR_ATIME; - - err = mdc_setattr(&cl, conn, &inode, &iattr, &request); - CERROR("-- done err %d\n", err); - - GOTO(out, err); - } - - case IOC_REQUEST_CREATE: { - struct inode inode; - struct iattr iattr; - - inode.i_ino = arg; - inode.i_generation = 0; - iattr.ia_mode = 040777; - iattr.ia_atime = 0; - iattr.ia_valid = ATTR_MODE | ATTR_ATIME; - - err = mdc_create(&cl, conn, &inode, - "foofile", strlen("foofile"), - NULL, 0, 0100707, 47114711, - 11, 47, 0, &request); - CERROR("-- done err %d\n", err); - - GOTO(out, err); - } - - case IOC_REQUEST_OPEN: { - __u64 fh, ino; - copy_from_user(&ino, (__u64 *)arg, sizeof(ino)); - CERROR("-- opening ino %llu\n", (unsigned long long)ino); - err = mdc_open(&cl, conn, ino, S_IFDIR, O_RDONLY, 4711, &fh, - &request); - copy_to_user((__u64 *)arg, &fh, sizeof(fh)); - CERROR("-- done err %d (fh=%Lu)\n", err, - (unsigned long long)fh); - - GOTO(out, err); - } - - case IOC_REQUEST_CLOSE: { - CERROR("-- closing ino 2, filehandle %lu\n", arg); - err = mdc_close(&cl, conn, 2, S_IFDIR, arg, &request); - CERROR("-- done err %d\n", err); - - GOTO(out, err); - } - - default: - GOTO(out, err = -EINVAL); - } - - out: - ptlrpc_free_req(request); - ptlrpc_put_connection(conn); - ptlrpc_cleanup_client(&cl); - - RETURN(err); -} - - -static struct file_operations requestdev_fops = { - ioctl: request_ioctl, -}; - -static struct miscdevice request_dev = { - REQUEST_MINOR, - "request", - &requestdev_fops -}; - -static int __init ptlrpc_request_init(void) -{ - misc_register(&request_dev); - return 0; -} - -static void __exit ptlrpc_request_exit(void) -{ - misc_deregister(&request_dev); -} - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Lustre MDS Request Tester v1.0"); -MODULE_LICENSE("GPL"); - -EXPORT_SYMBOL(mdc_connect); -EXPORT_SYMBOL(mdc_getattr); -EXPORT_SYMBOL(mdc_create); -EXPORT_SYMBOL(mdc_unlink); -EXPORT_SYMBOL(mdc_rename); -EXPORT_SYMBOL(mdc_link); -EXPORT_SYMBOL(mdc_readpage); -EXPORT_SYMBOL(mdc_setattr); -EXPORT_SYMBOL(mdc_close); -EXPORT_SYMBOL(mdc_open); - -module_init(ptlrpc_request_init); -module_exit(ptlrpc_request_exit); diff --git a/lustre/mds/.cvsignore b/lustre/mds/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/mds/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/mds/Makefile.am b/lustre/mds/Makefile.am deleted file mode 100644 index 8c94e54..0000000 --- a/lustre/mds/Makefile.am +++ /dev/null @@ -1,25 +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 - -DEFS:= - -MODULE = mds -modulefs_DATA = mds.o mds_ext2.o mds_ext3.o mds_extN.o -EXTRA_PROGRAMS = mds mds_ext2 mds_ext3 mds_extN - -LINX=mds_updates.c simple.c -mds_updates.c: - test -e mds_updates.c || ln -sf $(top_srcdir)/lib/mds_updates.c - -simple.c: - test -e simple.c || ln -sf $(top_srcdir)/lib/simple.c - -mds_SOURCES = handler.c mds_reint.c mds_fs.c $(LINX) - -dist-hook: - list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done - -include $(top_srcdir)/Rules - diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c deleted file mode 100644 index 5098093..0000000 --- a/lustre/mds/handler.c +++ /dev/null @@ -1,719 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/mds/handler.c - * - * Lustre Metadata Server (mds) request handler - * - * 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 - * - * by Peter Braam - * - * This server is single threaded at present (but can easily be multi threaded) - * - */ - -#define EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_MDS - -#include -#include - -static -int mds_sendpage(struct ptlrpc_request *req, struct file *file, __u64 offset) -{ - int rc = 0; - mm_segment_t oldfs = get_fs(); - struct ptlrpc_bulk_desc *desc; - struct ptlrpc_bulk_page *bulk; - char *buf; - ENTRY; - - desc = ptlrpc_prep_bulk(req->rq_connection); - if (desc == NULL) - GOTO(out, rc = -ENOMEM); - - bulk = ptlrpc_prep_bulk_page(desc); - if (bulk == NULL) - GOTO(cleanup_bulk, rc = -ENOMEM); - - OBD_ALLOC(buf, PAGE_SIZE); - if (buf == NULL) - GOTO(cleanup_bulk, rc = -ENOMEM); - - set_fs(KERNEL_DS); - rc = mds_fs_readpage(&req->rq_obd->u.mds, file, buf, PAGE_SIZE, - (loff_t *)&offset); - set_fs(oldfs); - - if (rc != PAGE_SIZE) - GOTO(cleanup_buf, rc = -EIO); - - bulk->b_xid = req->rq_reqmsg->xid; - bulk->b_buf = buf; - bulk->b_buflen = PAGE_SIZE; - desc->b_portal = MDS_BULK_PORTAL; - - rc = ptlrpc_send_bulk(desc); - if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE)) { - CERROR("obd_fail_loc=%x, fail operation rc=%d\n", - OBD_FAIL_MDS_SENDPAGE, rc); - ptlrpc_abort_bulk(desc); - GOTO(cleanup_buf, rc); - } - - EXIT; - cleanup_buf: - OBD_FREE(buf, PAGE_SIZE); - cleanup_bulk: - ptlrpc_free_bulk(desc); - out: - return rc; -} - -struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, - struct vfsmount **mnt) -{ - /* stolen from NFS */ - struct super_block *sb = mds->mds_sb; - unsigned long ino = fid->id; - __u32 generation = fid->generation; - struct inode *inode; - struct list_head *lp; - struct dentry *result; - - if (ino == 0) - RETURN(ERR_PTR(-ESTALE)); - - inode = iget(sb, ino); - if (inode == NULL) - RETURN(ERR_PTR(-ENOMEM)); - - CDEBUG(D_DENTRY, "--> mds_fid2dentry: sb %p\n", inode->i_sb); - - if (is_bad_inode(inode) || - (generation && inode->i_generation != generation)) { - /* we didn't find the right inode.. */ - CERROR("bad inode %lu, link: %d ct: %d or version %u/%u\n", - inode->i_ino, inode->i_nlink, - atomic_read(&inode->i_count), inode->i_generation, - generation); - LBUG(); - iput(inode); - RETURN(ERR_PTR(-ESTALE)); - } - - /* now to find a dentry. - * If possible, get a well-connected one - */ - if (mnt) - *mnt = mds->mds_vfsmnt; - spin_lock(&dcache_lock); - for (lp = inode->i_dentry.next; lp != &inode->i_dentry ; lp=lp->next) { - result = list_entry(lp,struct dentry, d_alias); - if (! (result->d_flags & DCACHE_NFSD_DISCONNECTED)) { - dget_locked(result); - result->d_vfs_flags |= DCACHE_REFERENCED; - spin_unlock(&dcache_lock); - iput(inode); - if (mnt) - mntget(*mnt); - return result; - } - } - spin_unlock(&dcache_lock); - result = d_alloc_root(inode); - if (result == NULL) { - iput(inode); - return ERR_PTR(-ENOMEM); - } - if (mnt) - mntget(*mnt); - result->d_flags |= DCACHE_NFSD_DISCONNECTED; - return result; -} - -static -int mds_connect(struct ptlrpc_request *req) -{ - struct mds_body *body; - struct mds_obd *mds = &req->rq_obd->u.mds; - struct mds_client_info *mci; - struct mds_client_data *mcd; - int rc, size = sizeof(*body); - ENTRY; - - CDEBUG(D_INFO, "MDS connect from UUID '%s'\n", ptlrpc_req_to_uuid(req)); - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_CONNECT_PACK)) { - CERROR("mds: out of memory for message: size=%d\n", size); - req->rq_status = -ENOMEM; - RETURN(0); - } - - body = lustre_msg_buf(req->rq_reqmsg, 0); - mds_unpack_req_body(req); - /* Anything we need to do here with the client's trans no or so? */ - - body = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1)); - - mci = mds_uuid_to_mci(mds, ptlrpc_req_to_uuid(req)); - if (!mci) { - /* We don't have any old connection data for this client */ - int rc; - - CDEBUG(D_INFO, "allocating new client data for UUID '%s'", - ptlrpc_req_to_uuid(req)); - - OBD_ALLOC(mcd, sizeof(*mcd)); - if (!mcd) { - CERROR("mds: out of memory for client data\n"); - req->rq_status = -ENOMEM; - RETURN(0); - } - rc = mds_client_add(mds, mcd, -1); - if (rc) { - req->rq_status = rc; - RETURN(0); - } - } else { - /* We have old connection data for this client... */ - mcd = mci->mci_mcd; - CDEBUG(D_INFO, "found existing data for UUID '%s' at #%d\n", - mcd->mcd_uuid, mci->mci_off); - } - /* mcd_last_xid is is stored in little endian on the disk and - mds_pack_rep_body converts it to network order */ - body->last_xid = le32_to_cpu(mcd->mcd_last_xid); - mds_pack_rep_body(req); - RETURN(0); -} - -static -int mds_getattr(struct ptlrpc_request *req) -{ - struct dentry *de; - struct inode *inode; - struct mds_body *body; - struct mds_obd *mds = &req->rq_obd->u.mds; - int rc, size[2] = {sizeof(*body)}, count = 1; - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - de = mds_fid2dentry(mds, &body->fid1, NULL); - if (IS_ERR(de)) { - req->rq_status = -ENOENT; - RETURN(0); - } - inode = de->d_inode; - if (body->valid & OBD_MD_LINKNAME) { - count = 2; - size[1] = inode->i_size; - } - - rc = lustre_pack_msg(count, size, NULL, &req->rq_replen, - &req->rq_repmsg); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) { - CERROR("mds: out of memory\n"); - req->rq_status = -ENOMEM; - GOTO(out, 0); - } - - if (body->valid & OBD_MD_LINKNAME) { - char *tmp = lustre_msg_buf(req->rq_repmsg, 1); - mm_segment_t oldfs; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - rc = inode->i_op->readlink(de, tmp, size[1]); - set_fs(oldfs); - - if (rc < 0) { - req->rq_status = rc; - CERROR("readlink failed: %d\n", rc); - GOTO(out, 0); - } - } - - body = lustre_msg_buf(req->rq_repmsg, 0); - body->ino = inode->i_ino; - body->generation = inode->i_generation; - body->atime = inode->i_atime; - body->ctime = inode->i_ctime; - body->mtime = inode->i_mtime; - body->uid = inode->i_uid; - body->gid = inode->i_gid; - body->size = inode->i_size; - body->mode = inode->i_mode; - body->nlink = inode->i_nlink; - if (S_ISREG(inode->i_mode)) { - rc = mds_fs_get_objid(mds, inode, &body->objid); - if (rc < 0) { - req->rq_status = rc; - CERROR("readlink failed: %d\n", rc); - GOTO(out, 0); - } - } - body->valid = ~0; /* FIXME: should be more selective */ - out: - l_dput(de); - RETURN(0); -} - -static -int mds_open(struct ptlrpc_request *req) -{ - struct mds_obd *mds = &req->rq_obd->u.mds; - struct dentry *de; - struct mds_body *body; - struct file *file; - struct vfsmount *mnt; - struct mds_client_info *mci; - __u32 flags; - struct list_head *tmp; - struct mds_file_data *mfd; - int rc, size = sizeof(*body); - ENTRY; - - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) { - CERROR("mds: out of memory\n"); - req->rq_status = -ENOMEM; - RETURN(0); - } - - - mci = mds_uuid_to_mci(mds, ptlrpc_req_to_uuid(req)); - if (!mci) { - CERROR("mds: no mci!\n"); - req->rq_status = -ENOTCONN; - RETURN(0); - } - - body = lustre_msg_buf(req->rq_reqmsg, 0); - - /* was this animal open already? */ - list_for_each(tmp, &mci->mci_open_head) { - struct mds_file_data *fd; - fd = list_entry(tmp, struct mds_file_data, mfd_list); - if (body->objid == fd->mfd_clientfd && - body->fid1.id == fd->mfd_file->f_dentry->d_inode->i_ino) { - CERROR("Re opening %Ld\n", body->fid1.id); - RETURN(0); - } - } - - OBD_ALLOC(mfd, sizeof(*mfd)); - if (!mfd) { - CERROR("mds: out of memory\n"); - req->rq_status = -ENOMEM; - RETURN(0); - } - - de = mds_fid2dentry(mds, &body->fid1, &mnt); - if (IS_ERR(de)) { - req->rq_status = -ENOENT; - RETURN(0); - } - - flags = body->flags; - file = dentry_open(de, mnt, flags); - if (!file || IS_ERR(file)) { - req->rq_status = -EINVAL; - OBD_FREE(mfd, sizeof(*mfd)); - RETURN(0); - } - - file->private_data = mfd; - mfd->mfd_file = file; - mfd->mfd_clientfd = body->objid; - list_add(&mfd->mfd_list, &mci->mci_open_head); - - body = lustre_msg_buf(req->rq_repmsg, 0); - body->objid = (__u64) (unsigned long)file; - RETURN(0); -} - -static -int mds_close(struct ptlrpc_request *req) -{ - struct dentry *de; - struct mds_body *body; - struct file *file; - struct vfsmount *mnt; - struct mds_file_data *mfd; - int rc; - ENTRY; - - rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) { - CERROR("mds: out of memory\n"); - req->rq_status = -ENOMEM; - RETURN(0); - } - - body = lustre_msg_buf(req->rq_reqmsg, 0); - de = mds_fid2dentry(&req->rq_obd->u.mds, &body->fid1, &mnt); - if (IS_ERR(de)) { - req->rq_status = -ENOENT; - RETURN(0); - } - - file = (struct file *)(unsigned long)body->objid; - if (!file->f_dentry) - LBUG(); - mfd = (struct mds_file_data *)file->private_data; - list_del(&mfd->mfd_list); - OBD_FREE(mfd, sizeof(*mfd)); - - req->rq_status = filp_close(file, 0); - l_dput(de); - mntput(mnt); - - RETURN(0); -} - -int mds_readpage(struct ptlrpc_request *req) -{ - struct vfsmount *mnt; - struct dentry *de; - struct file *file; - struct mds_body *body; - int rc, size = sizeof(*body); - ENTRY; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_PACK)) { - CERROR("mds: out of memory\n"); - req->rq_status = -ENOMEM; - RETURN(0); - } - - body = lustre_msg_buf(req->rq_reqmsg, 0); - de = mds_fid2dentry(&req->rq_obd->u.mds, &body->fid1, &mnt); - if (IS_ERR(de)) { - req->rq_status = PTR_ERR(de); - RETURN(0); - } - - CDEBUG(D_INODE, "ino %ld\n", de->d_inode->i_ino); - - file = dentry_open(de, mnt, O_RDONLY | O_LARGEFILE); - /* note: in case of an error, dentry_open puts dentry */ - if (IS_ERR(file)) { - req->rq_status = PTR_ERR(file); - RETURN(0); - } - - /* to make this asynchronous make sure that the handling function - doesn't send a reply when this function completes. Instead a - callback function would send the reply */ - rc = mds_sendpage(req, file, body->size); - - filp_close(file, 0); - req->rq_status = rc; - RETURN(0); -} - -int mds_reint(struct ptlrpc_request *req) -{ - int rc; - struct mds_update_record rec; - - rc = mds_update_unpack(req, &rec); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNPACK)) { - CERROR("invalid record\n"); - req->rq_status = -EINVAL; - RETURN(0); - } - /* rc will be used to interrupt a for loop over multiple records */ - rc = mds_reint_rec(&rec, req); - return 0; -} - -int mds_handle(struct obd_device *dev, struct ptlrpc_service *svc, - struct ptlrpc_request *req) -{ - struct mds_obd *mds = &req->rq_obd->u.mds; - int rc; - ENTRY; - - rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_HANDLE_UNPACK)) { - CERROR("lustre_mds: Invalid request\n"); - GOTO(out, rc); - } - - if (req->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) { - CERROR("lustre_mds: wrong packet type sent %d\n", - req->rq_reqmsg->type); - GOTO(out, rc = -EINVAL); - } - - switch (req->rq_reqmsg->opc) { - case MDS_CONNECT: - CDEBUG(D_INODE, "getattr\n"); - OBD_FAIL_RETURN(OBD_FAIL_MDS_CONNECT_NET, 0); - rc = mds_connect(req); - break; - - case MDS_GETATTR: - CDEBUG(D_INODE, "getattr\n"); - OBD_FAIL_RETURN(OBD_FAIL_MDS_GETATTR_NET, 0); - rc = mds_getattr(req); - break; - - case MDS_READPAGE: - CDEBUG(D_INODE, "readpage\n"); - OBD_FAIL_RETURN(OBD_FAIL_MDS_READPAGE_NET, 0); - rc = mds_readpage(req); - - if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE)) - return 0; - break; - - case MDS_REINT: - CDEBUG(D_INODE, "reint\n"); - OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET, 0); - rc = mds_reint(req); - OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET_REP, 0); - break; - - case MDS_OPEN: - CDEBUG(D_INODE, "open\n"); - OBD_FAIL_RETURN(OBD_FAIL_MDS_OPEN_NET, 0); - rc = mds_open(req); - break; - - case MDS_CLOSE: - CDEBUG(D_INODE, "close\n"); - OBD_FAIL_RETURN(OBD_FAIL_MDS_CLOSE_NET, 0); - rc = mds_close(req); - break; - - default: - rc = ptlrpc_error(svc, req); - RETURN(rc); - } - - EXIT; -out: - /* Still not 100% sure whether we should reply with the server - * last_rcvd or that of this client. I'm not sure it even makes - * a difference on a per-client basis, because last_rcvd is global - * and we are not supposed to allow transactions while in recovery. - */ - req->rq_repmsg->last_rcvd = HTON__u64(mds->mds_last_rcvd); - req->rq_repmsg->last_committed = HTON__u64(mds->mds_last_committed); - CDEBUG(D_INFO, "last_rcvd %Lu, last_committed %Lu, xid %d\n", - (unsigned long long)mds->mds_last_rcvd, - (unsigned long long)mds->mds_last_committed, - cpu_to_le32(req->rq_reqmsg->xid)); - if (rc) { - ptlrpc_error(svc, req); - } else { - CDEBUG(D_NET, "sending reply\n"); - ptlrpc_reply(svc, req); - } - - return 0; -} - -/* Update the server data on disk. This stores the new mount_count and - * also the last_rcvd value to disk. If we don't have a clean shutdown, - * then the server last_rcvd value may be less than that of the clients. - * This will alert us that we may need to do client recovery. - */ -static -int mds_update_server_data(struct mds_obd *mds) -{ - struct obd_run_ctxt saved; - struct mds_server_data *msd = mds->mds_server_data; - struct file *filp = mds->mds_rcvd_filp; - loff_t off = 0; - int rc; - - msd->msd_last_rcvd = cpu_to_le64(mds->mds_last_rcvd); - msd->msd_mount_count = cpu_to_le64(mds->mds_mount_count); - - CDEBUG(D_SUPER, "MDS mount_count is %Lu, last_rcvd is %Lu\n", - (unsigned long long)mds->mds_mount_count, - (unsigned long long)mds->mds_last_rcvd); - push_ctxt(&saved, &mds->mds_ctxt); - rc = lustre_fwrite(filp, (char *)msd, sizeof(*msd), &off); - if (rc != sizeof(*msd)) { - CERROR("error writing MDS server data: rc = %d\n", rc); - if (rc > 0) - RETURN(-EIO); - RETURN(rc); - } - rc = fsync_dev(filp->f_dentry->d_inode->i_rdev); - pop_ctxt(&saved); - if (rc) - CERROR("error flushing MDS server data: rc = %d\n", rc); - - return 0; -} - -/* Do recovery actions for the MDS */ -static int mds_recover(struct obd_device *obddev) -{ - struct mds_obd *mds = &obddev->u.mds; - int rc; - - /* This happens at the end when recovery is complete */ - ++mds->mds_mount_count; - rc = mds_update_server_data(mds); - - return rc; -} - -/* mount the file system (secretly) */ -static int mds_setup(struct obd_device *obddev, obd_count len, void *buf) -{ - struct obd_ioctl_data* data = buf; - struct mds_obd *mds = &obddev->u.mds; - struct vfsmount *mnt; - int rc = 0; - ENTRY; - - MOD_INC_USE_COUNT; -#ifdef CONFIG_DEV_RDONLY - dev_clear_rdonly(2); -#endif - if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2) - GOTO(err_dec, rc = -EINVAL); - - mds->mds_fstype = strdup(data->ioc_inlbuf2); - - mnt = do_kern_mount(mds->mds_fstype, 0, data->ioc_inlbuf1, NULL); - if (IS_ERR(mnt)) { - rc = PTR_ERR(mnt); - CERROR("do_kern_mount failed: rc = %d\n", rc); - GOTO(err_kfree, rc); - } - - mds->mds_sb = mnt->mnt_root->d_inode->i_sb; - if (!mds->mds_sb) - GOTO(err_put, rc = -ENODEV); - - rc = mds_fs_setup(mds, mnt); - if (rc) { - CERROR("MDS filesystem method init failed: rc = %d\n", rc); - GOTO(err_put, rc); - } - - mds->mds_service = ptlrpc_init_svc(128 * 1024, - MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, "self", mds_handle); - if (!mds->mds_service) { - CERROR("failed to start service\n"); - GOTO(err_fs, rc = -EINVAL); - } - - rc = ptlrpc_start_thread(obddev, mds->mds_service, "lustre_mds"); - if (rc) { - CERROR("cannot start thread: rc = %d\n", rc); - GOTO(err_svc, rc); - } - - rc = mds_recover(obddev); - if (rc) - GOTO(err_thread, rc); - - RETURN(0); - -err_thread: - ptlrpc_stop_all_threads(mds->mds_service); -err_svc: - rpc_unregister_service(mds->mds_service); - OBD_FREE(mds->mds_service, sizeof(*mds->mds_service)); -err_fs: - mds_fs_cleanup(mds); -err_put: - unlock_kernel(); - mntput(mds->mds_vfsmnt); - mds->mds_sb = 0; - lock_kernel(); -err_kfree: - kfree(mds->mds_fstype); -err_dec: - MOD_DEC_USE_COUNT; - return rc; -} - -static int mds_cleanup(struct obd_device * obddev) -{ - struct super_block *sb; - struct mds_obd *mds = &obddev->u.mds; - - ENTRY; - - if ( !list_empty(&obddev->obd_gen_clients) ) { - CERROR("still has clients!\n"); - RETURN(-EBUSY); - } - - ptlrpc_stop_all_threads(mds->mds_service); - rpc_unregister_service(mds->mds_service); - if (!list_empty(&mds->mds_service->srv_reqs)) { - // XXX reply with errors and clean up - CERROR("Request list not empty!\n"); - } - OBD_FREE(mds->mds_service, sizeof(*mds->mds_service)); - - sb = mds->mds_sb; - if (!mds->mds_sb) - RETURN(0); - - mds_update_server_data(mds); - - if (mds->mds_rcvd_filp) { - int rc = filp_close(mds->mds_rcvd_filp, 0); - mds->mds_rcvd_filp = NULL; - - if (rc) - CERROR("last_rcvd file won't close, rc=%d\n", rc); - } - - unlock_kernel(); - mntput(mds->mds_vfsmnt); - mds->mds_sb = 0; - kfree(mds->mds_fstype); - lock_kernel(); -#ifdef CONFIG_DEV_RDONLY - dev_clear_rdonly(2); -#endif - mds_fs_cleanup(mds); - - MOD_DEC_USE_COUNT; - RETURN(0); -} - -/* use obd ops to offer management infrastructure */ -static struct obd_ops mds_obd_ops = { - o_setup: mds_setup, - o_cleanup: mds_cleanup, -}; - -static int __init mds_init(void) -{ - obd_register_type(&mds_obd_ops, LUSTRE_MDS_NAME); - return 0; -} - -static void __exit mds_exit(void) -{ - obd_unregister_type(LUSTRE_MDS_NAME); -} - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Lustre Metadata Server (MDS) v0.01"); -MODULE_LICENSE("GPL"); - -module_init(mds_init); -module_exit(mds_exit); diff --git a/lustre/mds/mds_ext2.c b/lustre/mds/mds_ext2.c deleted file mode 100644 index b760102..0000000 --- a/lustre/mds/mds_ext2.c +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/mds/mds_null.c - * - * Lustre Metadata Server (mds) journal abstraction routines - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * author: Andreas Dilger - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - */ - -#define DEBUG_SUBSYSTEM S_MDS - -#include -#include -#include -#include - -static void *mds_ext2_start(struct inode *inode, int nblocks) -{ - return (void *)1; -} - -static int mds_ext2_stop(struct inode *inode, void *handle) -{ - return 0; -} - -static int mds_ext2_setattr(struct dentry *dentry, void *handle, - struct iattr *iattr) -{ - struct inode *inode = dentry->d_inode; - - /* a _really_ horrible hack to avoid removing the data stored - in the block pointers; this data is the object id - this will go into an extended attribute at some point. - */ - if (iattr->ia_valid & ATTR_SIZE) { - /* ATTR_SIZE would invoke truncate: clear it */ - iattr->ia_valid &= ~ATTR_SIZE; - inode->i_size = iattr->ia_size; - - /* make sure _something_ gets set - so new inode - goes to disk (probably won't work over XFS */ - if (!iattr->ia_valid & ATTR_MODE) { - iattr->ia_valid |= ATTR_MODE; - iattr->ia_mode = inode->i_mode; - } - } - - if (inode->i_op->setattr) - return inode->i_op->setattr(dentry, iattr); - else - return inode_setattr(inode, iattr); -} - -/* - * FIXME: nasty hack - store the object id in the first two - * direct block spots. This should be done with EAs... - */ -static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id) -{ - (__u64)(inode->u.ext2_i.i_data[0]) = cpu_to_le64(id); - return 0; -} - -static int mds_ext2_get_objid(struct inode *inode, obd_id *id) -{ - *id = le64_to_cpu(inode->u.ext2_i.i_data[0]); - - return 0; -} - -static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count, - loff_t *offset) -{ - if (S_ISREG(file->f_dentry->d_inode->i_mode)) - return file->f_op->read(file, buf, count, offset); - else - return generic_file_read(file, buf, count, offset); -} - -static struct mds_fs_operations mds_ext2_fs_ops; - -static void mds_ext2_delete_inode(struct inode *inode) -{ - if (S_ISREG(inode->i_mode)) - mds_ext2_set_objid(inode, NULL, 0); - - mds_ext2_fs_ops.cl_delete_inode(inode); -} - -static int mds_ext2_set_last_rcvd(struct mds_obd *mds, void *handle) -{ - /* Bail for ext2 - can't tell when it is on disk anyways, sync? */ - mds->mds_last_committed = mds->mds_last_rcvd; - - return 0; -} - -static int mds_ext2_journal_data(struct file *filp) -{ - return 0; -} - -static struct mds_fs_operations mds_ext2_fs_ops = { - fs_start: mds_ext2_start, - fs_commit: mds_ext2_stop, - fs_setattr: mds_ext2_setattr, - fs_set_objid: mds_ext2_set_objid, - fs_get_objid: mds_ext2_get_objid, - fs_readpage: mds_ext2_readpage, - fs_delete_inode:mds_ext2_delete_inode, - cl_delete_inode:clear_inode, - fs_journal_data:mds_ext2_journal_data, - fs_set_last_rcvd:mds_ext2_set_last_rcvd, -}; - -static int __init mds_ext2_init(void) -{ - return mds_register_fs_type(&mds_ext2_fs_ops, "ext2"); -} - -static void __exit mds_ext2_exit(void) -{ - mds_unregister_fs_type("ext2"); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Lustre MDS ext2 Filesystem Helper v0.1"); -MODULE_LICENSE("GPL"); - -module_init(mds_ext2_init); -module_exit(mds_ext2_exit); diff --git a/lustre/mds/mds_ext3.c b/lustre/mds/mds_ext3.c deleted file mode 100644 index 26c385e..0000000 --- a/lustre/mds/mds_ext3.c +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/mds/mds_ext3.c - * - * Lustre Metadata Server (mds) journal abstraction routines - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * author: Andreas Dilger - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - */ - -#define DEBUG_SUBSYSTEM S_MDS - -#include -#include -#include -#include -#include -#include - -static struct mds_fs_operations mds_ext3_fs_ops; -static kmem_cache_t *jcb_cache; -static int jcb_cache_count; - -struct mds_cb_data { - struct journal_callback cb_jcb; - struct mds_obd *cb_mds; - __u64 cb_last_rcvd; -}; - -/* - * We don't currently need any additional blocks for rmdir and - * unlink transactions because we are storing the OST oa_id inside - * the inode (which we will be changing anyways as part of this - * transaction). - */ -static void *mds_ext3_start(struct inode *inode, int op) -{ - /* For updates to the last recieved file */ - int nblocks = EXT3_DATA_TRANS_BLOCKS; - - switch(op) { - case MDS_FSOP_RMDIR: - case MDS_FSOP_UNLINK: - nblocks += EXT3_DELETE_TRANS_BLOCKS; - break; - case MDS_FSOP_RENAME: - /* We may be modifying two directories */ - nblocks += EXT3_DATA_TRANS_BLOCKS; - case MDS_FSOP_SYMLINK: - /* Possible new block + block bitmap + GDT for long symlink */ - nblocks += 3; - case MDS_FSOP_CREATE: - case MDS_FSOP_MKDIR: - case MDS_FSOP_MKNOD: - /* New inode + block bitmap + GDT for new file */ - nblocks += 3; - case MDS_FSOP_LINK: - /* Change parent directory */ - nblocks += EXT3_DATA_TRANS_BLOCKS; - break; - case MDS_FSOP_SETATTR: - /* Setattr on inode */ - nblocks += 1; - break; - default: CERROR("unknown transaction start op %d\n", op); - LBUG(); - } - - return journal_start(EXT3_JOURNAL(inode), nblocks); -} - -static int mds_ext3_commit(struct inode *inode, void *handle) -{ - return journal_stop((handle_t *)handle); -} - -static int mds_ext3_setattr(struct dentry *dentry, void *handle, - struct iattr *iattr) -{ - struct inode *inode = dentry->d_inode; - - /* a _really_ horrible hack to avoid removing the data stored - in the block pointers; this data is the object id - this will go into an extended attribute at some point. - */ - if (iattr->ia_valid & ATTR_SIZE) { - /* ATTR_SIZE would invoke truncate: clear it */ - iattr->ia_valid &= ~ATTR_SIZE; - inode->i_size = iattr->ia_size; - - /* an _even_more_ horrible hack to make this hack work with - * ext3. This is because ext3 keeps a separate inode size - * until the inode is committed to ensure consistency. This - * will also go away with the move to EAs. - */ - EXT3_I(inode)->i_disksize = inode->i_size; - - /* make sure _something_ gets set - so new inode - goes to disk (probably won't work over XFS */ - if (!iattr->ia_valid & ATTR_MODE) { - iattr->ia_valid |= ATTR_MODE; - iattr->ia_mode = inode->i_mode; - } - } - - if (inode->i_op->setattr) - return inode->i_op->setattr(dentry, iattr); - else - return inode_setattr(inode, iattr); -} - -/* - * FIXME: nasty hack - store the object id in the first two - * direct block spots. This should be done with EAs... - * Note also that this does not currently mark the inode - * dirty (it currently is used with other operations that - * subsequently also mark the inode dirty). - */ -static int mds_ext3_set_objid(struct inode *inode, void *handle, obd_id id) -{ - (__u64)EXT3_I(inode)->i_data[0] = cpu_to_le64(id); - return 0; -} - -static int mds_ext3_get_objid(struct inode *inode, obd_id *id) -{ - *id = le64_to_cpu(EXT3_I(inode)->i_data[0]); - - return 0; -} - -static ssize_t mds_ext3_readpage(struct file *file, char *buf, size_t count, - loff_t *offset) -{ - struct inode *inode = file->f_dentry->d_inode; - int rc = 0; - - if (S_ISREG(inode->i_mode)) - rc = file->f_op->read(file, buf, count, offset); - else { - struct buffer_head *bh; - - /* FIXME: this assumes the blocksize == count, but the calling - * function will detect this as an error for now */ - bh = ext3_bread(NULL, inode, - *offset >> inode->i_sb->s_blocksize_bits, - 0, &rc); - - if (bh) { - memcpy(buf, bh->b_data, inode->i_blksize); - brelse(bh); - rc = inode->i_blksize; - } - } - - return rc; -} - -static void mds_ext3_delete_inode(struct inode *inode) -{ - if (S_ISREG(inode->i_mode)) { - void *handle = mds_ext3_start(inode, MDS_FSOP_UNLINK); - - if (IS_ERR(handle)) { - CERROR("unable to start transaction"); - EXIT; - return; - } - if (mds_ext3_set_objid(inode, handle, 0)) - CERROR("error clearing objid on %ld\n", inode->i_ino); - - if (mds_ext3_fs_ops.cl_delete_inode) - mds_ext3_fs_ops.cl_delete_inode(inode); - - if (mds_ext3_commit(inode, handle)) - CERROR("error closing handle on %ld\n", inode->i_ino); - } else - mds_ext3_fs_ops.cl_delete_inode(inode); -} - -static void mds_ext3_callback_status(void *jcb, int error) -{ - struct mds_cb_data *mcb = (struct mds_cb_data *)jcb; - - CDEBUG(D_EXT2, "got callback for last_rcvd %Ld: rc = %d\n", - mcb->cb_last_rcvd, error); - if (!error && mcb->cb_last_rcvd > mcb->cb_mds->mds_last_committed) - mcb->cb_mds->mds_last_committed = mcb->cb_last_rcvd; - - kmem_cache_free(jcb_cache, mcb); - //OBD_FREE(mcb, sizeof(*mcb)); - --jcb_cache_count; -} - -#ifdef HAVE_JOURNAL_CALLBACK -static void mds_ext3_callback_func(void *cb_data) -{ - mds_ext3_callback_status(cb_data, 0); -} -#endif - -static int mds_ext3_set_last_rcvd(struct mds_obd *mds, void *handle) -{ - struct mds_cb_data *mcb; - - //OBD_ALLOC(mcb, sizeof(*mcb)); - mcb = kmem_cache_alloc(jcb_cache, GFP_NOFS); - if (!mcb) - RETURN(-ENOMEM); - - ++jcb_cache_count; - mcb->cb_mds = mds; - mcb->cb_last_rcvd = mds->mds_last_rcvd; - -#ifdef HAVE_JOURNAL_CALLBACK_STATUS - CDEBUG(D_EXT2, "set callback for last_rcvd: %Ld\n", - (unsigned long long)mcb->cb_last_rcvd); - journal_callback_set(handle, mds_ext3_callback_status, - (void *)mcb); -#elif defined(HAVE_JOURNAL_CALLBACK) - /* XXX original patch version - remove soon */ -#warning "using old journal callback kernel patch, please update" - CDEBUG(D_EXT2, "set callback for last_rcvd: %Ld\n", - (unsigned long long)mcb->cb_last_rcvd); - journal_callback_set(handle, mds_ext3_callback_func, mcb); -#else -#warning "no journal callback kernel patch, faking it..." - { - static long next = 0; - - if (time_after(jiffies, next)) { - CERROR("no journal callback kernel patch, faking it...\n"); - next = jiffies + 300 * HZ; - } - } - mds_ext3_callback_status((struct journal_callback *)mcb, 0); -#endif - - return 0; -} - -static int mds_ext3_journal_data(struct file *filp) -{ - struct inode *inode = filp->f_dentry->d_inode; - - EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL; - - return 0; -} - -static struct mds_fs_operations mds_ext3_fs_ops = { - fs_start: mds_ext3_start, - fs_commit: mds_ext3_commit, - fs_setattr: mds_ext3_setattr, - fs_set_objid: mds_ext3_set_objid, - fs_get_objid: mds_ext3_get_objid, - fs_readpage: mds_ext3_readpage, - fs_delete_inode:mds_ext3_delete_inode, - cl_delete_inode:clear_inode, - fs_journal_data:mds_ext3_journal_data, - fs_set_last_rcvd:mds_ext3_set_last_rcvd, -}; - -static int __init mds_ext3_init(void) -{ - int rc; - - jcb_cache = kmem_cache_create("mds_ext3_jcb", - sizeof(struct mds_cb_data), 0, - 0, NULL, NULL); - if (!jcb_cache) { - CERROR("error allocating MDS journal callback cache\n"); - GOTO(out, rc = -ENOMEM); - } - - rc = mds_register_fs_type(&mds_ext3_fs_ops, "ext3"); - - if (rc) - kmem_cache_destroy(jcb_cache); -out: - return rc; -} - -static void __exit mds_ext3_exit(void) -{ - int rc = 0; - - mds_unregister_fs_type("ext3"); - rc = kmem_cache_destroy(jcb_cache); - - if (rc || jcb_cache_count) { - CERROR("can't free MDS callback cache: count %d, rc = %d\n", - jcb_cache_count, rc); - } -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Lustre MDS ext3 Filesystem Helper v0.1"); -MODULE_LICENSE("GPL"); - -module_init(mds_ext3_init); -module_exit(mds_ext3_exit); diff --git a/lustre/mds/mds_extN.c b/lustre/mds/mds_extN.c deleted file mode 100644 index 714943d..0000000 --- a/lustre/mds/mds_extN.c +++ /dev/null @@ -1,338 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/mds/mds_extN.c - * - * Lustre Metadata Server (mds) journal abstraction routines - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * author: Andreas Dilger - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - */ - -#define DEBUG_SUBSYSTEM S_MDS - -#include -#include -#include -#include -#include -#include -#include - -static struct mds_fs_operations mds_extN_fs_ops; -static kmem_cache_t *jcb_cache; -static int jcb_cache_count; - -struct mds_cb_data { - struct journal_callback cb_jcb; - struct mds_obd *cb_mds; - __u64 cb_last_rcvd; -}; - -struct mds_objid { - __u16 mo_magic; - __u8 mo_unused; - __u8 mo_ost; - __u64 mo_id; -}; - -#define EXTN_XATTR_INDEX_LUSTRE 5 -#define XATTR_LUSTRE_MDS_OBJID "system.lustre_mds_objid" - -#define XATTR_MDS_MO_MAGIC 0x4711 - -/* - * We don't currently need any additional blocks for rmdir and - * unlink transactions because we are storing the OST oa_id inside - * the inode (which we will be changing anyways as part of this - * transaction). - */ -static void *mds_extN_start(struct inode *inode, int op) -{ - /* For updates to the last recieved file */ - int nblocks = EXTN_DATA_TRANS_BLOCKS; - - switch(op) { - case MDS_FSOP_RMDIR: - case MDS_FSOP_UNLINK: - nblocks += EXTN_DELETE_TRANS_BLOCKS; - break; - case MDS_FSOP_RENAME: - /* We may be modifying two directories */ - nblocks += EXTN_DATA_TRANS_BLOCKS; - case MDS_FSOP_SYMLINK: - /* Possible new block + block bitmap + GDT for long symlink */ - nblocks += 3; - case MDS_FSOP_CREATE: - case MDS_FSOP_MKDIR: - case MDS_FSOP_MKNOD: - /* New inode + block bitmap + GDT for new file */ - nblocks += 3; - case MDS_FSOP_LINK: - /* Change parent directory */ - nblocks += EXTN_INDEX_EXTRA_TRANS_BLOCKS+EXTN_DATA_TRANS_BLOCKS; - break; - case MDS_FSOP_SETATTR: - /* Setattr on inode */ - nblocks += 1; - break; - default: CERROR("unknown transaction start op %d\n", op); - LBUG(); - } - - return journal_start(EXTN_JOURNAL(inode), nblocks); -} - -static int mds_extN_commit(struct inode *inode, void *handle) -{ - return journal_stop((handle_t *)handle); -} - -static int mds_extN_setattr(struct dentry *dentry, void *handle, - struct iattr *iattr) -{ - struct inode *inode = dentry->d_inode; - - if (inode->i_op->setattr) - return inode->i_op->setattr(dentry, iattr); - else - return inode_setattr(inode, iattr); -} - -static int mds_extN_set_objid(struct inode *inode, void *handle, obd_id id) -{ - struct mds_objid data; - int rc; - - data.mo_magic = cpu_to_le16(XATTR_MDS_MO_MAGIC); - data.mo_unused = 0; - data.mo_ost = 0; /* FIXME: store OST index here */ - data.mo_id = cpu_to_le64(id); - - lock_kernel(); - down(&inode->i_sem); - if (id == 0) { - rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE, - XATTR_LUSTRE_MDS_OBJID, NULL, 0, 0); - } else { - rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE, - XATTR_LUSTRE_MDS_OBJID, &data, - sizeof(struct mds_objid), XATTR_CREATE); - } - up(&inode->i_sem); - unlock_kernel(); - - if (rc) - CERROR("error adding objectid %Ld to inode %ld\n", - (unsigned long long)id, inode->i_ino); - return rc; -} - -static int mds_extN_get_objid(struct inode *inode, obd_id *id) -{ - struct mds_objid data; - int rc; - - lock_kernel(); - down(&inode->i_sem); - rc = extN_xattr_get(inode, EXTN_XATTR_INDEX_LUSTRE, - XATTR_LUSTRE_MDS_OBJID, &data, - sizeof(struct mds_objid)); - up(&inode->i_sem); - unlock_kernel(); - - if (rc < 0) { - CERROR("error getting EA %s from MDS inode %ld: rc = %d\n", - XATTR_LUSTRE_MDS_OBJID, inode->i_ino, rc); - *id = 0; - } else if (data.mo_magic != cpu_to_le16(XATTR_MDS_MO_MAGIC)) { - CERROR("MDS object id %Ld has bad magic %x\n", - (unsigned long long)le64_to_cpu(data.mo_id), - le16_to_cpu(data.mo_magic)); - rc = -EINVAL; - } else { - *id = le64_to_cpu(data.mo_id); - /* FIXME: will actually use data.mo_ost at some point */ - if (data.mo_ost) - CERROR("MDS objid %Ld with ost index %d!\n", - *id, data.mo_ost); - } - - return rc; -} - -static ssize_t mds_extN_readpage(struct file *file, char *buf, size_t count, - loff_t *offset) -{ - struct inode *inode = file->f_dentry->d_inode; - int rc = 0; - - if (S_ISREG(inode->i_mode)) - rc = file->f_op->read(file, buf, count, offset); - else { - struct buffer_head *bh; - - /* FIXME: this assumes the blocksize == count, but the calling - * function will detect this as an error for now */ - bh = extN_bread(NULL, inode, - *offset >> inode->i_sb->s_blocksize_bits, - 0, &rc); - - if (bh) { - memcpy(buf, bh->b_data, inode->i_blksize); - brelse(bh); - rc = inode->i_blksize; - } - } - - return rc; -} - -static void mds_extN_delete_inode(struct inode *inode) -{ - if (S_ISREG(inode->i_mode)) { - void *handle = mds_extN_start(inode, MDS_FSOP_UNLINK); - - if (IS_ERR(handle)) { - CERROR("unable to start transaction"); - EXIT; - return; - } - if (mds_extN_set_objid(inode, handle, 0)) - CERROR("error clearing objid on %ld\n", inode->i_ino); - - if (mds_extN_fs_ops.cl_delete_inode) - mds_extN_fs_ops.cl_delete_inode(inode); - - if (mds_extN_commit(inode, handle)) - CERROR("error closing handle on %ld\n", inode->i_ino); - } else - mds_extN_fs_ops.cl_delete_inode(inode); -} - -static void mds_extN_callback_status(void *jcb, int error) -{ - struct mds_cb_data *mcb = (struct mds_cb_data *)jcb; - - CDEBUG(D_EXT2, "got callback for last_rcvd %Ld: rc = %d\n", - mcb->cb_last_rcvd, error); - if (!error && mcb->cb_last_rcvd > mcb->cb_mds->mds_last_committed) - mcb->cb_mds->mds_last_committed = mcb->cb_last_rcvd; - - kmem_cache_free(jcb_cache, jcb); - --jcb_cache_count; -} - -#ifdef HAVE_JOURNAL_CALLBACK -static void mds_extN_callback_func(void *cb_data) -{ - mds_extN_callback_status(cb_data, 0); -} -#endif - -static int mds_extN_set_last_rcvd(struct mds_obd *mds, void *handle) -{ - struct mds_cb_data *mcb; - - mcb = kmem_cache_alloc(jcb_cache, GFP_NOFS); - if (!mcb) - RETURN(-ENOMEM); - - ++jcb_cache_count; - mcb->cb_mds = mds; - mcb->cb_last_rcvd = mds->mds_last_rcvd; - -#ifdef HAVE_JOURNAL_CALLBACK_STATUS - CDEBUG(D_EXT2, "set callback for last_rcvd: %Ld\n", - (unsigned long long)mcb->cb_last_rcvd); - journal_callback_set(handle, mds_extN_callback_status, - (void *)mcb); -#elif defined(HAVE_JOURNAL_CALLBACK) - /* XXX original patch version - remove soon */ -#warning "using old journal callback kernel patch, please update" - CDEBUG(D_EXT2, "set callback for last_rcvd: %Ld\n", - (unsigned long long)mcb->cb_last_rcvd); - journal_callback_set(handle, mds_extN_callback_func, mcb); -#else -#warning "no journal callback kernel patch, faking it..." - { - static long next = 0; - - if (time_after(jiffies, next)) { - CERROR("no journal callback kernel patch, faking it...\n"); - next = jiffies + 300 * HZ; - } - } - mds_extN_callback_status((struct journal_callback *)mcb, 0); -#endif - - return 0; -} - -static int mds_extN_journal_data(struct file *filp) -{ - struct inode *inode = filp->f_dentry->d_inode; - - EXTN_I(inode)->i_flags |= EXTN_JOURNAL_DATA_FL; - - return 0; -} - -static struct mds_fs_operations mds_extN_fs_ops = { - fs_start: mds_extN_start, - fs_commit: mds_extN_commit, - fs_setattr: mds_extN_setattr, - fs_set_objid: mds_extN_set_objid, - fs_get_objid: mds_extN_get_objid, - fs_readpage: mds_extN_readpage, - fs_delete_inode: mds_extN_delete_inode, - cl_delete_inode: clear_inode, - fs_journal_data: mds_extN_journal_data, - fs_set_last_rcvd: mds_extN_set_last_rcvd, -}; - -static int __init mds_extN_init(void) -{ - int rc; - - //rc = extN_xattr_register(); - jcb_cache = kmem_cache_create("mds_extN_jcb", - sizeof(struct mds_cb_data), 0, - 0, NULL, NULL); - if (!jcb_cache) { - CERROR("error allocating MDS journal callback cache\n"); - GOTO(out, rc = -ENOMEM); - } - rc = mds_register_fs_type(&mds_extN_fs_ops, "extN"); - - if (rc) - kmem_cache_destroy(jcb_cache); -out: - return rc; -} - -static void __exit mds_extN_exit(void) -{ - int rc; - - mds_unregister_fs_type("extN"); - rc = kmem_cache_destroy(jcb_cache); - - if (rc || jcb_cache_count) { - CERROR("can't free MDS callback cache: count %d, rc = %d\n", - jcb_cache_count, rc); - } - - //rc = extN_xattr_unregister(); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Lustre MDS extN Filesystem Helper v0.1"); -MODULE_LICENSE("GPL"); - -module_init(mds_extN_init); -module_exit(mds_extN_exit); diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c deleted file mode 100644 index c65d088..0000000 --- a/lustre/mds/mds_fs.c +++ /dev/null @@ -1,463 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/mds/mds_fs.c - * - * Lustre Metadata Server (MDS) filesystem interface code - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Andreas Dilger - * - */ - -#define EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_MDS - -#include -#include -#include - -LIST_HEAD(mds_fs_types); - -struct mds_fs_type { - struct list_head mft_list; - struct mds_fs_operations *mft_ops; - char *mft_name; -}; - -/* This will be a hash table at some point. */ -static int mds_init_client_data(struct mds_obd *mds) -{ - INIT_LIST_HEAD(&mds->mds_client_info); - return 0; -} - -#define MDS_MAX_CLIENTS 1024 -#define MDS_MAX_CLIENT_WORDS (MDS_MAX_CLIENTS / sizeof(unsigned long)) - -static unsigned long last_rcvd_slots[MDS_MAX_CLIENT_WORDS]; - -/* Add client data to the MDS. The in-memory storage will be a hash at some - * point. We use a bitmap to locate a free space in the last_rcvd file if - * cl_off is -1 (i.e. a new client). Otherwise, we have just read the data - * from the last_rcvd file and we know its offset. - */ -int mds_client_add(struct mds_obd *mds, struct mds_client_data *mcd, int cl_off) -{ - struct mds_client_info *mci; - - OBD_ALLOC(mci, sizeof(*mci)); - if (!mci) { - CERROR("no memory for MDS client info\n"); - RETURN(-ENOMEM); - } - INIT_LIST_HEAD(&mci->mci_open_head); - - CDEBUG(D_INFO, "client at offset %d with UUID '%s' added\n", - cl_off, mcd->mcd_uuid); - - if (cl_off == -1) { - unsigned long *word; - int bit; - - repeat: - word = last_rcvd_slots; - while(*word == ~0UL) - ++word; - if (word - last_rcvd_slots >= MDS_MAX_CLIENT_WORDS) { - CERROR("no room in client MDS bitmap - fix code\n"); - return -ENOMEM; - } - bit = ffz(*word); - if (test_and_set_bit(bit, word)) { - CERROR("found bit %d set for word %d - fix code\n", - bit, word - last_rcvd_slots); - goto repeat; - } - cl_off = word - last_rcvd_slots + bit; - } else { - if (test_and_set_bit(cl_off, last_rcvd_slots)) { - CERROR("bit %d already set in bitmap - bad bad\n", - cl_off); - LBUG(); - } - } - - mci->mci_mcd = mcd; - mci->mci_off = cl_off; - - /* For now we just put the clients in a list, not a hashed list */ - list_add_tail(&mci->mci_list, &mds->mds_client_info); - - mds->mds_client_count++; - - return 0; -} - -void mds_client_del(struct mds_obd *mds, struct mds_client_info *mci) -{ - unsigned long *word; - int bit; - - word = last_rcvd_slots + mci->mci_off / sizeof(unsigned long); - bit = mci->mci_off % sizeof(unsigned long); - - if (!test_and_clear_bit(bit, word)) { - CERROR("bit %d already clear in word %d - bad bad\n", - bit, word - last_rcvd_slots); - LBUG(); - } - - --mds->mds_client_count; - list_del(&mci->mci_list); - OBD_FREE(mci->mci_mcd, sizeof(*mci->mci_mcd)); - OBD_FREE(mci, sizeof (*mci)); -} - -static int mds_client_free_all(struct mds_obd *mds) -{ - struct list_head *p, *n; - - list_for_each_safe(p, n, &mds->mds_client_info) { - struct mds_client_info *mci; - - mci = list_entry(p, struct mds_client_info, mci_list); - mds_client_del(mds, mci); - } - - return 0; -} - -static int mds_server_free_data(struct mds_obd *mds) -{ - OBD_FREE(mds->mds_server_data, sizeof(*mds->mds_server_data)); - mds->mds_server_data = NULL; - - return 0; -} - -#define LAST_RCVD "last_rcvd" - -static int mds_read_last_rcvd(struct mds_obd *mds, struct file *f) -{ - struct mds_server_data *msd; - struct mds_client_data *mcd = NULL; - loff_t fsize = f->f_dentry->d_inode->i_size; - loff_t off = 0; - int cl_off; - __u64 last_rcvd = 0; - __u64 last_mount; - int rc = 0; - - OBD_ALLOC(msd, sizeof(*msd)); - if (!msd) - RETURN(-ENOMEM); - rc = lustre_fread(f, (char *)msd, sizeof(*msd), &off); - - mds->mds_server_data = msd; - if (rc == 0) { - CERROR("empty MDS %s, new MDS?\n", LAST_RCVD); - RETURN(0); - } else if (rc != sizeof(*msd)) { - CERROR("error reading MDS %s: rc = %d\n", LAST_RCVD, rc); - if (rc > 0) { - rc = -EIO; - } - GOTO(err_msd, rc); - } - - /* - * When we do a clean MDS shutdown, we save the last_rcvd into - * the header. If we find clients with higher last_rcvd values - * then those clients may need recovery done. - */ - last_rcvd = le64_to_cpu(msd->msd_last_rcvd); - mds->mds_last_rcvd = last_rcvd; - CDEBUG(D_INODE, "got %Lu for server last_rcvd value\n", - (unsigned long long)last_rcvd); - - last_mount = le64_to_cpu(msd->msd_mount_count); - mds->mds_mount_count = last_mount; - CDEBUG(D_INODE, "got %Lu for server last_mount value\n", - (unsigned long long)last_mount); - - for (off = MDS_LR_CLIENT, cl_off = 0, rc = sizeof(*mcd); - off <= fsize - sizeof(*mcd) && rc == sizeof(*mcd); - off = MDS_LR_CLIENT + ++cl_off * MDS_LR_SIZE) { - if (!mcd) - OBD_ALLOC(mcd, sizeof(*mcd)); - if (!mcd) - GOTO(err_msd, rc = -ENOMEM); - - rc = lustre_fread(f, (char *)mcd, sizeof(*mcd), &off); - if (rc != sizeof(*mcd)) { - CERROR("error reading MDS %s offset %d: rc = %d\n", - LAST_RCVD, cl_off, rc); - if (rc > 0) - rc = -EIO; - break; - } - - last_rcvd = le64_to_cpu(mcd->mcd_last_rcvd); - last_mount = le64_to_cpu(mcd->mcd_mount_count); - - if (last_rcvd && - last_mount - mcd->mcd_mount_count < MDS_MOUNT_RECOV) { - rc = mds_client_add(mds, mcd, cl_off); - if (rc) { - rc = 0; - break; - } - mcd = NULL; - } else { - CDEBUG(D_INFO, - "client at offset %d with UUID '%s' ignored\n", - cl_off, mcd->mcd_uuid); - } - - if (last_rcvd > mds->mds_last_rcvd) { - CDEBUG(D_OTHER, - "client at offset %d has last_rcvd = %Lu\n", - cl_off, (unsigned long long)last_rcvd); - mds->mds_last_rcvd = last_rcvd; - } - } - CDEBUG(D_INODE, "got %Lu for highest last_rcvd value, %d clients\n", - (unsigned long long)mds->mds_last_rcvd, mds->mds_client_count); - - /* After recovery, there can be no local uncommitted transactions */ - mds->mds_last_committed = mds->mds_last_rcvd; - - return 0; - -err_msd: - mds_server_free_data(mds); - return rc; -} - -static int mds_fs_prep(struct mds_obd *mds) -{ - struct obd_run_ctxt saved; - struct dentry *dentry; - struct file *f; - int rc; - - push_ctxt(&saved, &mds->mds_ctxt); - dentry = simple_mkdir(current->fs->pwd, "ROOT", 0700); - if (IS_ERR(dentry)) { - rc = PTR_ERR(dentry); - CERROR("cannot create ROOT directory: rc = %d\n", rc); - GOTO(err_pop, rc); - } - /* XXX probably want to hold on to this later... */ - dput(dentry); - f = filp_open("ROOT", O_RDONLY, 0); - if (IS_ERR(f)) { - rc = PTR_ERR(f); - CERROR("cannot open ROOT: rc = %d\n", rc); - LBUG(); - GOTO(err_pop, rc); - } - - mds->mds_rootfid.id = f->f_dentry->d_inode->i_ino; - mds->mds_rootfid.generation = f->f_dentry->d_inode->i_generation; - mds->mds_rootfid.f_type = S_IFDIR; - - rc = filp_close(f, 0); - if (rc) { - CERROR("cannot close ROOT: rc = %d\n", rc); - LBUG(); - } - - dentry = simple_mkdir(current->fs->pwd, "FH", 0700); - if (IS_ERR(dentry)) { - rc = PTR_ERR(dentry); - CERROR("cannot create FH directory: rc = %d\n", rc); - GOTO(err_pop, rc); - } - /* XXX probably want to hold on to this later... */ - dput(dentry); - - rc = mds_init_client_data(mds); - if (rc) - GOTO(err_pop, rc); - - f = filp_open(LAST_RCVD, O_RDWR | O_CREAT, 0644); - if (IS_ERR(f)) { - rc = PTR_ERR(f); - CERROR("cannot open/create %s file: rc = %d\n", LAST_RCVD, rc); - GOTO(err_pop, rc = PTR_ERR(f)); - } - if (!S_ISREG(f->f_dentry->d_inode->i_mode)) { - CERROR("%s is not a regular file!: mode = %o\n", LAST_RCVD, - f->f_dentry->d_inode->i_mode); - GOTO(err_pop, rc = -ENOENT); - } - - rc = mds_fs_journal_data(mds, f); - if (rc) { - CERROR("cannot journal data on %s: rc = %d\n", LAST_RCVD, rc); - GOTO(err_filp, rc); - } - - rc = mds_read_last_rcvd(mds, f); - if (rc) { - CERROR("cannot read %s: rc = %d\n", LAST_RCVD, rc); - GOTO(err_client, rc); - } - mds->mds_rcvd_filp = f; - pop_ctxt(&saved); - - RETURN(0); - -err_client: - mds_client_free_all(mds); -err_filp: - if (filp_close(f, 0)) - CERROR("can't close %s after error\n", LAST_RCVD); -err_pop: - pop_ctxt(&saved); - - return rc; -} - -static struct mds_fs_operations *mds_search_fs_type(const char *name) -{ - struct list_head *p; - struct mds_fs_type *type; - - /* lock mds_fs_types list */ - list_for_each(p, &mds_fs_types) { - type = list_entry(p, struct mds_fs_type, mft_list); - if (!strcmp(type->mft_name, name)) { - /* unlock mds_fs_types list */ - return type->mft_ops; - } - } - /* unlock mds_fs_types list */ - return NULL; -} - -int mds_register_fs_type(struct mds_fs_operations *ops, const char *name) -{ - struct mds_fs_operations *found; - struct mds_fs_type *type; - - if ((found = mds_search_fs_type(name))) { - if (found != ops) { - CERROR("different operations for type %s\n", name); - RETURN(-EEXIST); - } - return 0; - } - OBD_ALLOC(type, sizeof(*type)); - if (!type) - RETURN(-ENOMEM); - - INIT_LIST_HEAD(&type->mft_list); - type->mft_ops = ops; - type->mft_name = strdup(name); - if (!type->mft_name) { - OBD_FREE(type, sizeof(*type)); - RETURN(-ENOMEM); - } - MOD_INC_USE_COUNT; - list_add(&type->mft_list, &mds_fs_types); - - return 0; -} - -void mds_unregister_fs_type(const char *name) -{ - struct list_head *p; - - /* lock mds_fs_types list */ - list_for_each(p, &mds_fs_types) { - struct mds_fs_type *type; - - type = list_entry(p, struct mds_fs_type, mft_list); - if (!strcmp(type->mft_name, name)) { - list_del(p); - kfree(type->mft_name); - OBD_FREE(type, sizeof(*type)); - MOD_DEC_USE_COUNT; - break; - } - } - /* unlock mds_fs_types list */ -} - -int mds_fs_setup(struct mds_obd *mds, struct vfsmount *mnt) -{ - struct mds_fs_operations *fs_ops; - int rc; - - if (!(fs_ops = mds_search_fs_type(mds->mds_fstype))) { - char name[32]; - - snprintf(name, sizeof(name) - 1, "mds_%s", mds->mds_fstype); - name[sizeof(name) - 1] = '\0'; - - if ((rc = request_module(name))) { - fs_ops = mds_search_fs_type(mds->mds_fstype); - CDEBUG(D_INFO, "Loaded module '%s'\n", name); - if (!fs_ops) - rc = -ENOENT; - } - - if (rc) { - CERROR("Can't find MDS fs interface '%s'\n", name); - RETURN(rc); - } - } - - mds->mds_fsops = fs_ops; - mds->mds_vfsmnt = mnt; - mds->mds_ctxt.pwdmnt = mnt; - mds->mds_ctxt.pwd = mnt->mnt_root; - mds->mds_ctxt.fs = KERNEL_DS; - - /* - * Replace the client filesystem delete_inode method with our own, - * so that we can clear the object ID before the inode is deleted. - * The fs_delete_inode method will call cl_delete_inode for us. - * We need to do this for the MDS superblock only, hence we install - * a modified copy of the original superblock method table. - * - * We still assume that there is only a single MDS client filesystem - * type, as we don't have access to the mds struct in delete_inode - * and store the client delete_inode method in a global table. This - * will only become a problem if/when multiple MDSs are running on a - * single host with different underlying filesystems. - */ - OBD_ALLOC(mds->mds_sop, sizeof(*mds->mds_sop)); - if (!mds->mds_sop) - RETURN(-ENOMEM); - - memcpy(mds->mds_sop, mds->mds_sb->s_op, sizeof(*mds->mds_sop)); - mds->mds_fsops->cl_delete_inode = mds->mds_sop->delete_inode; - mds->mds_sop->delete_inode = mds->mds_fsops->fs_delete_inode; - mds->mds_sb->s_op = mds->mds_sop; - - rc = mds_fs_prep(mds); - - if (rc) - OBD_FREE(mds->mds_sop, sizeof(*mds->mds_sop)); - - return rc; -} - -void mds_fs_cleanup(struct mds_obd *mds) -{ - mds_client_free_all(mds); - mds_server_free_data(mds); - - OBD_FREE(mds->mds_sop, sizeof(*mds->mds_sop)); -} - -EXPORT_SYMBOL(mds_register_fs_type); -EXPORT_SYMBOL(mds_unregister_fs_type); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c deleted file mode 100644 index 4426492..0000000 --- a/lustre/mds/mds_reint.c +++ /dev/null @@ -1,559 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/mds/mds_reint.c - * - * Lustre Metadata Server (mds) reintegration routines - * - * Copyright (C) 2002 Cluster File Systems, Inc. - * author: Peter Braam - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - */ - -// XXX - add transaction sequence numbers - -#define EXPORT_SYMTAB - -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_MDS - -#include -#include -#include -#include -#include -#include -#include - -struct mds_client_info *mds_uuid_to_mci(struct mds_obd *mds, __u8 *uuid) -{ - struct list_head *p; - - if (!uuid) - return NULL; - - list_for_each(p, &mds->mds_client_info) { - struct mds_client_info *mci; - - mci = list_entry(p, struct mds_client_info, mci_list); - CDEBUG(D_INFO, "checking client UUID '%s'\n", - mci->mci_mcd->mcd_uuid); - if (!strncmp(mci->mci_mcd->mcd_uuid, uuid, - sizeof(mci->mci_mcd->mcd_uuid))) - return mci; - } - CDEBUG(D_INFO, "no mds client info found for UUID '%s'\n", uuid); - return NULL; -} - -int mds_update_last_rcvd(struct mds_obd *mds, void *handle, - struct ptlrpc_request *req) -{ - /* get from req->rq_connection-> or req->rq_client */ - struct obd_run_ctxt saved; - struct mds_client_info *mci; - loff_t off; - int rc; - - mci = mds_uuid_to_mci(mds, req->rq_connection->c_remote_uuid); - if (!mci) { - CERROR("unable to locate MDS client data for UUID '%s'\n", - ptlrpc_req_to_uuid(req)); - /* This will be a real error once everything is working */ - //LBUG(); - RETURN(0); - } - - off = MDS_LR_CLIENT + mci->mci_off * MDS_LR_SIZE; - - ++mds->mds_last_rcvd; /* lock this, or make it an LDLM function? */ - req->rq_repmsg->transno = HTON__u64(mds->mds_last_rcvd); - mci->mci_mcd->mcd_last_rcvd = cpu_to_le64(mds->mds_last_rcvd); - mci->mci_mcd->mcd_mount_count = cpu_to_le64(mds->mds_mount_count); - mci->mci_mcd->mcd_last_xid = cpu_to_le32(req->rq_reqmsg->xid); - - mds_fs_set_last_rcvd(mds, handle); - push_ctxt(&saved, &mds->mds_ctxt); - rc = lustre_fwrite(mds->mds_rcvd_filp, (char *)mci->mci_mcd, - sizeof(*mci->mci_mcd), &off); - pop_ctxt(&saved); - CDEBUG(D_INODE, "wrote trans #%Ld for client '%s' at #%d: rc = %d\n", - mds->mds_last_rcvd, mci->mci_mcd->mcd_uuid, mci->mci_off, rc); - // store new value and last committed value in req struct - - if (rc == sizeof(*mci->mci_mcd)) - rc = 0; - else { - CERROR("error writing to last_rcvd file: rc = %d\n", rc); - if (rc >= 0) - rc = -EIO; - } - - return rc; -} - -static int mds_reint_setattr(struct mds_update_record *rec, - struct ptlrpc_request *req) -{ - struct mds_obd *mds = &req->rq_obd->u.mds; - struct dentry *de; - void *handle; - int rc = 0; - - de = mds_fid2dentry(mds, rec->ur_fid1, NULL); - if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_SETATTR)) { - GOTO(out_setattr, rc = -ESTALE); - } - - CDEBUG(D_INODE, "ino %ld\n", de->d_inode->i_ino); - - OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_SETATTR_WRITE, - de->d_inode->i_sb->s_dev); - - handle = mds_fs_start(mds, de->d_inode, MDS_FSOP_SETATTR); - if (!handle) - GOTO(out_setattr_de, rc = PTR_ERR(handle)); - rc = mds_fs_setattr(mds, de, handle, &rec->ur_iattr); - - if (!rc) - rc = mds_update_last_rcvd(mds, handle, req); - /* FIXME: need to return last_rcvd, last_committed */ - - EXIT; - - /* FIXME: keep rc intact */ - rc = mds_fs_commit(mds, de->d_inode, handle); -out_setattr_de: - l_dput(de); -out_setattr: - req->rq_status = rc; - return(0); -} - -static int mds_reint_recreate(struct mds_update_record *rec, - struct ptlrpc_request *req) -{ - struct dentry *de = NULL; - struct mds_obd *mds = &req->rq_obd->u.mds; - struct dentry *dchild = NULL; - struct inode *dir; - int rc = 0; - ENTRY; - - de = mds_fid2dentry(mds, rec->ur_fid1, NULL); - if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) { - LBUG(); - GOTO(out_create_de, rc = -ESTALE); - } - dir = de->d_inode; - CDEBUG(D_INODE, "parent ino %ld\n", dir->i_ino); - - down(&dir->i_sem); - dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1); - if (IS_ERR(dchild)) { - CERROR("child lookup error %ld\n", PTR_ERR(dchild)); - up(&dir->i_sem); - LBUG(); - GOTO(out_create_dchild, rc = -ESTALE); - } - - if (dchild->d_inode) { - struct mds_body *body; - rc = 0; - body = lustre_msg_buf(req->rq_repmsg, 0); - body->ino = dchild->d_inode->i_ino; - body->generation = dchild->d_inode->i_generation; - } else { - CERROR("child doesn't exist (dir %ld, name %s)\n", - dir->i_ino, rec->ur_name); - rc = -ENOENT; - LBUG(); - } - -out_create_dchild: - l_dput(dchild); - up(&dir->i_sem); -out_create_de: - l_dput(de); - req->rq_status = rc; - return 0; -} -static int mds_reint_create(struct mds_update_record *rec, - struct ptlrpc_request *req) -{ - struct dentry *de = NULL; - struct mds_obd *mds = &req->rq_obd->u.mds; - struct dentry *dchild = NULL; - struct inode *dir; - void *handle; - int rc = 0, type = rec->ur_mode & S_IFMT; - ENTRY; - - de = mds_fid2dentry(mds, rec->ur_fid1, NULL); - if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) { - LBUG(); - GOTO(out_create_de, rc = -ESTALE); - } - dir = de->d_inode; - CDEBUG(D_INODE, "parent ino %ld name %s mode %o\n", - dir->i_ino, rec->ur_name, rec->ur_mode); - - down(&dir->i_sem); - dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1); - if (IS_ERR(dchild)) { - CERROR("child lookup error %ld\n", PTR_ERR(dchild)); - up(&dir->i_sem); - LBUG(); - GOTO(out_create_dchild, rc = -ESTALE); - } - - if (dchild->d_inode) { - CERROR("child exists (dir %ld, name %s, ino %ld)\n", - dir->i_ino, rec->ur_name, dchild->d_inode->i_ino); - LBUG(); - GOTO(out_create_dchild, rc = -EEXIST); - } - - OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_CREATE_WRITE, dir->i_sb->s_dev); - - switch (type) { - case S_IFREG: { - handle = mds_fs_start(mds, dir, MDS_FSOP_CREATE); - if (!handle) - GOTO(out_create_dchild, PTR_ERR(handle)); - rc = vfs_create(dir, dchild, rec->ur_mode); - EXIT; - break; - } - case S_IFDIR: { - handle = mds_fs_start(mds, dir, MDS_FSOP_MKDIR); - if (!handle) - GOTO(out_create_dchild, PTR_ERR(handle)); - rc = vfs_mkdir(dir, dchild, rec->ur_mode); - EXIT; - break; - } - case S_IFLNK: { - handle = mds_fs_start(mds, dir, MDS_FSOP_SYMLINK); - if (!handle) - GOTO(out_create_dchild, PTR_ERR(handle)); - rc = vfs_symlink(dir, dchild, rec->ur_tgt); - EXIT; - break; - } - case S_IFCHR: - case S_IFBLK: - case S_IFIFO: - case S_IFSOCK: { - int rdev = rec->ur_id; - handle = mds_fs_start(mds, dir, MDS_FSOP_MKNOD); - if (!handle) - GOTO(out_create_dchild, PTR_ERR(handle)); - rc = vfs_mknod(dir, dchild, rec->ur_mode, rdev); - EXIT; - break; - } - default: - CERROR("bad file type %d for create of %s\n",type,rec->ur_name); - GOTO(out_create_dchild, rc = -EINVAL); - } - - if (rc) { - CERROR("error during create: %d\n", rc); - if (rc != -ENOSPC) LBUG(); - GOTO(out_create_commit, rc); - } else { - struct iattr iattr; - struct inode *inode = dchild->d_inode; - struct mds_body *body; - - CDEBUG(D_INODE, "created ino %ld\n", dchild->d_inode->i_ino); - if (type == S_IFREG) { - rc = mds_fs_set_objid(mds, inode, handle, rec->ur_id); - if (rc) - CERROR("error %d setting objid for %ld\n", - rc, inode->i_ino); - } - - iattr.ia_atime = rec->ur_time; - iattr.ia_ctime = rec->ur_time; - iattr.ia_mtime = rec->ur_time; - iattr.ia_uid = rec->ur_uid; - iattr.ia_gid = rec->ur_gid; - iattr.ia_valid = ATTR_UID | ATTR_GID | ATTR_ATIME | - ATTR_MTIME | ATTR_CTIME; - - rc = mds_fs_setattr(mds, dchild, handle, &iattr); - /* XXX should we abort here in case of error? */ - - //if (!rc) - rc = mds_update_last_rcvd(mds, handle, req); - - body = lustre_msg_buf(req->rq_repmsg, 0); - body->ino = inode->i_ino; - body->generation = inode->i_generation; - } - -out_create_commit: - /* FIXME: keep rc intact */ - rc = mds_fs_commit(mds, dir, handle); -out_create_dchild: - l_dput(dchild); - up(&dir->i_sem); -out_create_de: - l_dput(de); - req->rq_status = rc; - return 0; -} - -static int mds_reint_unlink(struct mds_update_record *rec, - struct ptlrpc_request *req) -{ - struct dentry *de = NULL; - struct dentry *dchild = NULL; - struct mds_obd *mds = &req->rq_obd->u.mds; - struct inode *dir, *inode; - void *handle; - int rc = 0; - ENTRY; - - de = mds_fid2dentry(mds, rec->ur_fid1, NULL); - if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNLINK)) { - LBUG(); - GOTO(out_unlink, rc = -ESTALE); - } - dir = de->d_inode; - CDEBUG(D_INODE, "parent ino %ld\n", dir->i_ino); - - down(&dir->i_sem); - dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1); - if (IS_ERR(dchild)) { - CERROR("child lookup error %ld\n", PTR_ERR(dchild)); - LBUG(); - GOTO(out_unlink_de, rc = -ESTALE); - } - - inode = dchild->d_inode; - if (!inode) { - CERROR("child doesn't exist (dir %ld, name %s\n", - dir->i_ino, rec->ur_name); - LBUG(); - GOTO(out_unlink_dchild, rc = -ESTALE); - } - - if (inode->i_ino != rec->ur_fid2->id) { - CERROR("inode and FID ID do not match (%ld != %Ld)\n", - inode->i_ino, rec->ur_fid2->id); - LBUG(); - GOTO(out_unlink_dchild, rc = -ESTALE); - } - if (inode->i_generation != rec->ur_fid2->generation) { - CERROR("inode and FID GENERATION do not match (%d != %d)\n", - inode->i_generation, rec->ur_fid2->generation); - LBUG(); - GOTO(out_unlink_dchild, rc = -ESTALE); - } - - OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_UNLINK_WRITE, dir->i_sb->s_dev); - - switch (dchild->d_inode->i_mode & S_IFMT) { - case S_IFDIR: - handle = mds_fs_start(mds, dir, MDS_FSOP_RMDIR); - if (!handle) - GOTO(out_unlink_dchild, rc = PTR_ERR(handle)); - rc = vfs_rmdir(dir, dchild); - break; - default: - handle = mds_fs_start(mds, dir, MDS_FSOP_UNLINK); - if (!handle) - GOTO(out_unlink_dchild, rc = PTR_ERR(handle)); - rc = vfs_unlink(dir, dchild); - break; - } - - if (!rc) - rc = mds_update_last_rcvd(mds, handle, req); - /* FIXME: need to return last_rcvd, last_committed */ - /* FIXME: keep rc intact */ - rc = mds_fs_commit(mds, dir, handle); - - EXIT; -out_unlink_dchild: - l_dput(dchild); -out_unlink_de: - up(&dir->i_sem); - l_dput(de); -out_unlink: - req->rq_status = rc; - return 0; -} - -static int mds_reint_link(struct mds_update_record *rec, - struct ptlrpc_request *req) -{ - struct dentry *de_src = NULL; - struct dentry *de_tgt_dir = NULL; - struct dentry *dchild = NULL; - struct mds_obd *mds = &req->rq_obd->u.mds; - void *handle; - int rc = 0; - - ENTRY; - de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL); - if (IS_ERR(de_src) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_LINK)) { - GOTO(out_link, rc = -ESTALE); - } - - de_tgt_dir = mds_fid2dentry(mds, rec->ur_fid2, NULL); - if (IS_ERR(de_tgt_dir)) { - GOTO(out_link_de_src, rc = -ESTALE); - } - - down(&de_tgt_dir->d_inode->i_sem); - dchild = lookup_one_len(rec->ur_name, de_tgt_dir, rec->ur_namelen - 1); - if (IS_ERR(dchild)) { - CERROR("child lookup error %ld\n", PTR_ERR(dchild)); - GOTO(out_link_de_tgt_dir, rc = -ESTALE); - } - - if (dchild->d_inode) { - CERROR("child exists (dir %ld, name %s\n", - de_tgt_dir->d_inode->i_ino, rec->ur_name); - GOTO(out_link_dchild, rc = -EEXIST); - } - - OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_LINK_WRITE, - dchild->d_inode->i_sb->s_dev); - - handle = mds_fs_start(mds, de_tgt_dir->d_inode, MDS_FSOP_LINK); - if (!handle) - GOTO(out_link_dchild, rc = PTR_ERR(handle)); - - rc = vfs_link(de_src, de_tgt_dir->d_inode, dchild); - - if (!rc) - rc = mds_update_last_rcvd(mds, handle, req); - - /* FIXME: need to return last_rcvd, last_committed */ - /* FIXME: keep rc intact */ - rc = mds_fs_commit(mds, de_tgt_dir->d_inode, handle); - EXIT; - -out_link_dchild: - l_dput(dchild); -out_link_de_tgt_dir: - up(&de_tgt_dir->d_inode->i_sem); - l_dput(de_tgt_dir); -out_link_de_src: - l_dput(de_src); -out_link: - req->rq_status = rc; - return 0; -} - -static int mds_reint_rename(struct mds_update_record *rec, - struct ptlrpc_request *req) -{ - struct dentry *de_srcdir = NULL; - struct dentry *de_tgtdir = NULL; - struct dentry *de_old = NULL; - struct dentry *de_new = NULL; - struct mds_obd *mds = &req->rq_obd->u.mds; - void *handle; - int rc = 0; - ENTRY; - - de_srcdir = mds_fid2dentry(mds, rec->ur_fid1, NULL); - if (IS_ERR(de_srcdir)) { - GOTO(out_rename, rc = -ESTALE); - } - - de_tgtdir = mds_fid2dentry(mds, rec->ur_fid2, NULL); - if (IS_ERR(de_tgtdir)) { - GOTO(out_rename_srcdir, rc = -ESTALE); - } - - de_old = lookup_one_len(rec->ur_name, de_srcdir, rec->ur_namelen - 1); - if (IS_ERR(de_old)) { - CERROR("old child lookup error %ld\n", PTR_ERR(de_old)); - GOTO(out_rename_tgtdir, rc = -ESTALE); - } - - de_new = lookup_one_len(rec->ur_tgt, de_tgtdir, rec->ur_tgtlen - 1); - if (IS_ERR(de_new)) { - CERROR("new child lookup error %ld\n", PTR_ERR(de_new)); - GOTO(out_rename_deold, rc = -ESTALE); - } - - OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_RENAME_WRITE, - de_srcdir->d_inode->i_sb->s_dev); - - handle = mds_fs_start(mds, de_tgtdir->d_inode, MDS_FSOP_RENAME); - if (!handle) - GOTO(out_rename_denew, rc = PTR_ERR(handle)); - rc = vfs_rename(de_srcdir->d_inode, de_old, de_tgtdir->d_inode, de_new); - - if (!rc) - rc = mds_update_last_rcvd(mds, handle, req); - - /* FIXME: need to return last_rcvd, last_committed */ - /* FIXME: keep rc intact */ - rc = mds_fs_commit(mds, de_tgtdir->d_inode, handle); - EXIT; - -out_rename_denew: - l_dput(de_new); -out_rename_deold: - l_dput(de_old); -out_rename_tgtdir: - l_dput(de_tgtdir); -out_rename_srcdir: - l_dput(de_srcdir); -out_rename: - req->rq_status = rc; - return 0; -} - -typedef int (*mds_reinter)(struct mds_update_record *, struct ptlrpc_request*); - -static mds_reinter reinters[REINT_MAX+1] = { - [REINT_SETATTR] mds_reint_setattr, - [REINT_CREATE] mds_reint_create, - [REINT_UNLINK] mds_reint_unlink, - [REINT_LINK] mds_reint_link, - [REINT_RENAME] mds_reint_rename, - [REINT_RECREATE] mds_reint_recreate, -}; - -int mds_reint_rec(struct mds_update_record *rec, struct ptlrpc_request *req) -{ - int rc, size = sizeof(struct mds_body); - - if (rec->ur_opcode < 1 || rec->ur_opcode > REINT_MAX) { - CERROR("opcode %d not valid\n", rec->ur_opcode); - rc = req->rq_status = -EINVAL; - RETURN(rc); - } - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) { - CERROR("mds: out of memory\n"); - rc = req->rq_status = -ENOMEM; - RETURN(rc); - } - - rc = reinters[rec->ur_opcode](rec, req); - - return rc; -} diff --git a/lustre/missing b/lustre/missing deleted file mode 100755 index 7789652..0000000 --- a/lustre/missing +++ /dev/null @@ -1,190 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997 Free Software Foundation, Inc. -# Franc,ois Pinard , 1996. - -# 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, 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. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing - GNU libit 0.0" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`configure.in'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`configure.in'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`configure.in'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/lustre/mkinstalldirs b/lustre/mkinstalldirs deleted file mode 100755 index a08f3ca..0000000 --- a/lustre/mkinstalldirs +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -# $Id: mkinstalldirs,v 1.1 2002/05/27 16:48:11 pschwan Exp $ - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here diff --git a/lustre/nodist b/lustre/nodist deleted file mode 100644 index 91aecad..0000000 --- a/lustre/nodist +++ /dev/null @@ -1,21 +0,0 @@ -obd-*/obd-* -CVS -*~ -make.rules -config.* -*.o -*.orig -*.backup -.depfiles -ext2obd/dir.c -ext2obd/file.c -ext2obd/ialloc.c -ext2obd/inode.c -ext2obd/super.c -ext2obd/fsync.c -ext2obd/ioctl.c -ext2obd/balloc.c -ext2obd/acl.c -ext2obd/namei.c -ext2obd/symlink.c -ext2obd/bitmap.c diff --git a/lustre/obdclass/.cvsignore b/lustre/obdclass/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/obdclass/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/obdclass/Makefile.am b/lustre/obdclass/Makefile.am deleted file mode 100644 index 01eed46..0000000 --- a/lustre/obdclass/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -DEFS:= -MODULE = obdclass -modulefs_DATA = obdclass.o -EXTRA_PROGRAMS = obdclass -obdclass_SOURCES = genops.c proc_lustre.c class_obd.c sysctl.c - -include $(top_srcdir)/Rules diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c deleted file mode 100644 index 2c215ad..0000000 --- a/lustre/obdclass/class_obd.c +++ /dev/null @@ -1,684 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * An implementation of a loadable kernel mode driver providing - * multiple kernel/user space bidirectional communications links. - * - * Author: Alan Cox - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * Adapted to become the Linux 2.0 Coda pseudo device - * Peter Braam - * Michael Callahan - * - * Changes for Linux 2.1 - * Copyright (c) 1997 Carnegie-Mellon University - * - * Redone again for Intermezzo - * Copyright (c) 1998 Peter J. Braam - * - * Hacked up again for simulated OBD - * Copyright (c) 1999 Stelias Computing, Inc. - * (authors {pschwan,braam}@stelias.com) - * Copyright (C) 1999 Seagate Technology, Inc. - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * - */ - -#define EXPORT_SYMTAB -#include /* for CONFIG_PROC_FS */ -#include -#include -#include -#include -#include /* for request_module() */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include - -static int obd_init_magic; -unsigned long obd_memory = 0; -unsigned long obd_fail_loc = 0; -struct obd_device obd_dev[MAX_OBD_DEVICES]; -struct list_head obd_types; - -/* opening /dev/obd */ -static int obd_class_open(struct inode * inode, struct file * file) -{ - ENTRY; - - file->private_data = NULL; - MOD_INC_USE_COUNT; - RETURN(0); -} - -/* closing /dev/obd */ -static int obd_class_release(struct inode * inode, struct file * file) -{ - ENTRY; - - if (file->private_data) - file->private_data = NULL; - - MOD_DEC_USE_COUNT; - RETURN(0); -} - -static int obd_class_name2dev(char *name) -{ - int res = -1; - int i; - - for (i=0; i < MAX_OBD_DEVICES; i++) { - struct obd_device *obd = &obd_dev[i]; - if (obd->obd_name && strcmp(name, obd->obd_name) == 0) { - res = i; - return res; - } - } - - return res; -} - -/* - * support functions: we could use inter-module communication, but this - * is more portable to other OS's - */ -static struct obd_type *obd_search_type(char *nm) -{ - struct list_head *tmp; - struct obd_type *type; - CDEBUG(D_INFO, "SEARCH %s\n", nm); - - tmp = &obd_types; - while ( (tmp = tmp->next) != &obd_types ) { - type = list_entry(tmp, struct obd_type, typ_chain); - CDEBUG(D_INFO, "TYP %s\n", type->typ_name); - if (strlen(type->typ_name) == strlen(nm) && - strcmp(type->typ_name, nm) == 0 ) { - return type; - } - } - return NULL; -} - -static struct obd_type *obd_nm_to_type(char *nm) -{ - struct obd_type *type = obd_search_type(nm); - -#ifdef CONFIG_KMOD - if ( !type ) { - if ( !request_module(nm) ) { - CDEBUG(D_INFO, "Loaded module '%s'\n", nm); - type = obd_search_type(nm); - } else { - CDEBUG(D_INFO, "Can't load module '%s'\n", nm); - } - } -#endif - return type; -} - -/* to control /dev/obd */ -static int obd_class_ioctl (struct inode * inode, struct file * filp, - unsigned int cmd, unsigned long arg) -{ - /* NOTE this must be larger than any of the ioctl data structs */ - char buf[1024]; - struct obd_ioctl_data *data; - struct obd_device *obd = filp->private_data; - struct obd_conn conn; - int rw = OBD_BRW_READ; - int err = 0; - ENTRY; - - memset(buf, 0, sizeof(buf)); - - if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS && - cmd != OBD_IOC_NAME2DEV && cmd != OBD_IOC_NEWDEV) { - CERROR("OBD ioctl: No device\n"); - RETURN(-EINVAL); - } - if (obd_ioctl_getdata(buf, buf + 800, (void *)arg)) { - CERROR("OBD ioctl: data error\n"); - RETURN(-EINVAL); - } - data = (struct obd_ioctl_data *)buf; - - switch (cmd) { - case TCGETS: - RETURN(-EINVAL); - case OBD_IOC_DEVICE: { - CDEBUG(D_IOCTL, "\n"); - if (data->ioc_dev >= MAX_OBD_DEVICES || data->ioc_dev < 0) { - CERROR("OBD ioctl: DEVICE insufficient devices\n"); - RETURN(-EINVAL); - } - CDEBUG(D_IOCTL, "device %d\n", data->ioc_dev); - - filp->private_data = &obd_dev[data->ioc_dev]; - RETURN(0); - } - - case OBD_IOC_NAME2DEV: { - /* Resolve a device name. This does not change the - * currently selected device. - */ - int dev; - - if (!data->ioc_inlbuf1) { - CERROR("No name passed!\n"); - RETURN(-EINVAL); - } - CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1); - dev = obd_class_name2dev(data->ioc_inlbuf1); - data->ioc_dev = dev; - if (dev == -1) { - CDEBUG(D_IOCTL, "No device for name %s!\n", - data->ioc_inlbuf1); - RETURN(-EINVAL); - } - - CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1, - dev); - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - - case OBD_IOC_NEWDEV: { - int dev = -1; - int i; - - filp->private_data = NULL; - for (i = 0 ; i < MAX_OBD_DEVICES ; i++) { - struct obd_device *obd = &obd_dev[i]; - if (!obd->obd_type) { - filp->private_data = obd; - dev = i; - break; - } - } - - - data->ioc_dev = dev; - if (dev == -1) - RETURN(-EINVAL); - - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - - case OBD_IOC_ATTACH: { - struct obd_type *type; - - /* have we attached a type to this device */ - if (obd->obd_flags & OBD_ATTACHED) { - CERROR("OBD: Device %d already typed as %s.\n", - obd->obd_minor, MKSTR(obd->obd_type->typ_name)); - RETURN(-EBUSY); - } - - CDEBUG(D_IOCTL, "attach %s %s\n", MKSTR(data->ioc_inlbuf1), - MKSTR(data->ioc_inlbuf2)); - - /* find the type */ - type = obd_nm_to_type(data->ioc_inlbuf1); - if (!type) { - CERROR("OBD: unknown type dev %d\n", obd->obd_minor); - RETURN(-EINVAL); - } - - obd->obd_type = type; - obd->obd_multi_count = 0; - INIT_LIST_HEAD(&obd->obd_gen_clients); - INIT_LIST_HEAD(&obd->obd_req_list); - - /* do the attach */ - if (OBT(obd) && OBP(obd, attach)) - err = OBP(obd,attach)(obd, sizeof(*data), data); - if (err) { - obd->obd_type = NULL; - } else { - obd->obd_flags |= OBD_ATTACHED; - type->typ_refcnt++; - CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n", - obd->obd_minor, data->ioc_inlbuf1); - obd->obd_proc_entry = - proc_lustre_register_obd_device(obd); - if (data->ioc_inlbuf2) { - int len = strlen(data->ioc_inlbuf2); - OBD_ALLOC(obd->obd_name, len + 1); - if (!obd->obd_name) { - CERROR("no memory\n"); - LBUG(); - } - memcpy(obd->obd_name, data->ioc_inlbuf2, len+1); - } - - MOD_INC_USE_COUNT; - } - - RETURN(err); - } - - case OBD_IOC_DETACH: { - ENTRY; - if (obd->obd_flags & OBD_SET_UP) { - CERROR("OBD device %d still set up\n", obd->obd_minor); - RETURN(-EBUSY); - } - if (! (obd->obd_flags & OBD_ATTACHED) ) { - CERROR("OBD device %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); - } - if ( !list_empty(&obd->obd_gen_clients) ) { - CERROR("OBD device %d has connected clients\n", - obd->obd_minor); - RETURN(-EBUSY); - } - if ( !list_empty(&obd->obd_req_list) ) { - CERROR("OBD device %d has hanging requests\n", - obd->obd_minor); - RETURN(-EBUSY); - } - - if (obd->obd_name) { - OBD_FREE(obd->obd_name, strlen(obd->obd_name)+ 1); - obd->obd_name = NULL; - } - - if (obd->obd_proc_entry) - proc_lustre_release_obd_device(obd); - - obd->obd_flags &= ~OBD_ATTACHED; - obd->obd_type->typ_refcnt--; - obd->obd_type = NULL; - MOD_DEC_USE_COUNT; - RETURN(0); - } - - case OBD_IOC_SETUP: { - /* have we attached a type to this device? */ - if (!(obd->obd_flags & OBD_ATTACHED)) { - CERROR("Device %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); - } - - /* has this been done already? */ - if ( obd->obd_flags & OBD_SET_UP ) { - CERROR("Device %d already setup (type %s)\n", - obd->obd_minor, obd->obd_type->typ_name); - RETURN(-EBUSY); - } - - if ( OBT(obd) && OBP(obd, setup) ) - err = obd_setup(obd, sizeof(*data), data); - - if (!err) { - obd->obd_type->typ_refcnt++; - obd->obd_flags |= OBD_SET_UP; - } - - RETURN(err); - } - case OBD_IOC_CLEANUP: { - /* have we attached a type to this device? */ - if (!(obd->obd_flags & OBD_ATTACHED)) { - CERROR("Device %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); - } - - if ( OBT(obd) && OBP(obd, cleanup) ) - err = obd_cleanup(obd); - - if (!err) { - obd->obd_flags &= ~OBD_SET_UP; - obd->obd_type->typ_refcnt--; - } - RETURN(err); - } - - case OBD_IOC_CONNECT: { - conn.oc_id = data->ioc_conn1; - conn.oc_dev = obd; - - err = obd_connect(&conn); - - CDEBUG(D_IOCTL, "assigned connection %d\n", conn.oc_id); - data->ioc_conn1 = conn.oc_id; - if (err) - RETURN(err); - - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - - case OBD_IOC_DISCONNECT: { - conn.oc_id = data->ioc_conn1; - conn.oc_dev = obd; - - err = obd_disconnect(&conn); - RETURN(err); - } - - case OBD_IOC_DEC_USE_COUNT: { - MOD_DEC_USE_COUNT; - RETURN(0); - } - - case OBD_IOC_CREATE: { - conn.oc_id = data->ioc_conn1; - conn.oc_dev = obd; - - err = obd_create(&conn, &data->ioc_obdo1); - if (err) - RETURN(err); - - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - - case OBD_IOC_GETATTR: { - conn.oc_id = data->ioc_conn1; - conn.oc_dev = obd; - - err = obd_getattr(&conn, &data->ioc_obdo1); - if (err) - RETURN(err); - - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - - case OBD_IOC_SETATTR: { - conn.oc_id = data->ioc_conn1; - conn.oc_dev = obd; - - err = obd_setattr(&conn, &data->ioc_obdo1); - if (err) - RETURN(err); - - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - - case OBD_IOC_DESTROY: { - conn.oc_id = data->ioc_conn1; - conn.oc_dev = obd; - - err = obd_destroy(&conn, &data->ioc_obdo1); - if (err) - RETURN(err); - - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - - case OBD_IOC_BRW_WRITE: - rw = OBD_BRW_WRITE; - case OBD_IOC_BRW_READ: { - /* FIXME: use a better ioctl data struct than obd_ioctl_data. - * We don't really support multiple-obdo I/Os here, - * for example offset and count are not per-obdo. - */ - struct obd_conn conns[2]; - struct obdo *obdos[2] = { NULL, NULL }; - obd_count oa_bufs[2] = { 0, 0 }; - struct page **bufs = NULL; - obd_size *counts = NULL; - obd_off *offsets = NULL; - obd_flag *flags = NULL; - int num = 1; - int pages; - int i, j; - - pages = oa_bufs[0] = data->ioc_plen1 / PAGE_SIZE; - if (data->ioc_obdo2.o_id) { - num = 2; - oa_bufs[1] = data->ioc_plen2 / PAGE_SIZE; - pages += oa_bufs[1]; - } - - CDEBUG(D_INODE, "BRW %s with %dx%d pages\n", - rw == OBD_BRW_READ ? "read" : "write", - num, oa_bufs[0]); - OBD_ALLOC(bufs, pages * sizeof(*bufs)); - OBD_ALLOC(counts, pages * sizeof(*counts)); - OBD_ALLOC(offsets, pages * sizeof(*offsets)); - OBD_ALLOC(flags, pages * sizeof(*flags)); - if (!bufs || !counts || !offsets || !flags) { - CERROR("no memory for %d BRW per-page data\n", pages); - err = -ENOMEM; - GOTO(brw_free, err); - } - - obdos[0] = &data->ioc_obdo1; - if (num > 1) - obdos[1] = &data->ioc_obdo2; - - for (i = 0, pages = 0; i < num; i++) { - unsigned long off; - void *from; - - conns[i].oc_id = (&data->ioc_conn1)[i]; - conns[i].oc_dev = obd; - - from = (&data->ioc_pbuf1)[i]; - off = data->ioc_offset; - - for (j = 0; j < oa_bufs[i]; - j++, pages++, off += PAGE_SIZE, from += PAGE_SIZE){ - unsigned long to; - - to = __get_free_pages(GFP_KERNEL, 0); - if (!to) { - /* || - copy_from_user((void *)to,from,PAGE_SIZE)) - free_pages(to, 0); - */ - CERROR("no memory for brw pages\n"); - err = -ENOMEM; - GOTO(brw_cleanup, err); - } - bufs[pages] = virt_to_page(to); - counts[pages] = PAGE_SIZE; - offsets[pages] = off; - flags[pages] = 0; - } - } - - err = obd_brw(rw, conns, num, obdos, oa_bufs, bufs, - counts, offsets, flags); - - EXIT; - brw_cleanup: - while (pages-- > 0) - __free_pages(bufs[pages], 0); - brw_free: - OBD_FREE(bufs, pages * sizeof(*bufs)); - OBD_FREE(counts, pages * sizeof(*counts)); - OBD_FREE(offsets, pages * sizeof(*offsets)); - OBD_FREE(flags, pages * sizeof(*flags)); - return err; - } - default: { - conn.oc_id = data->ioc_conn1; - conn.oc_dev = obd; - - err = obd_iocontrol(cmd, &conn, sizeof(*data), data, NULL); - if (err) - RETURN(err); - - err = copy_to_user((int *)arg, data, sizeof(*data)); - RETURN(err); - } - } -} /* obd_class_ioctl */ - - -/* Driver interface done, utility functions follow */ -int obd_register_type(struct obd_ops *ops, char *nm) -{ - struct obd_type *type; - - ENTRY; - - if (obd_init_magic != 0x11223344) { - CERROR("bad magic for type\n"); - RETURN(-EINVAL); - } - - if (obd_nm_to_type(nm)) { - CDEBUG(D_IOCTL, "Type %s already registered\n", nm); - RETURN(-EEXIST); - } - - OBD_ALLOC(type, sizeof(*type)); - if (!type) - RETURN(-ENOMEM); - INIT_LIST_HEAD(&type->typ_chain); - MOD_INC_USE_COUNT; - list_add(&type->typ_chain, obd_types.next); - type->typ_ops = ops; - type->typ_name = nm; - RETURN(0); -} - -int obd_unregister_type(char *nm) -{ - struct obd_type *type = obd_nm_to_type(nm); - - ENTRY; - - if ( !type ) { - MOD_DEC_USE_COUNT; - CERROR("unknown obd type\n"); - RETURN(-EINVAL); - } - - if ( type->typ_refcnt ) { - MOD_DEC_USE_COUNT; - CERROR("type %s has refcount (%d)\n", nm, type->typ_refcnt); - RETURN(-EBUSY); - } - - list_del(&type->typ_chain); - OBD_FREE(type, sizeof(*type)); - MOD_DEC_USE_COUNT; - RETURN(0); -} /* obd_unregister_type */ - -/* declare character device */ -static struct file_operations obd_psdev_fops = { - ioctl: obd_class_ioctl, /* ioctl */ - open: obd_class_open, /* open */ - release: obd_class_release, /* release */ -}; - -/* modules setup */ -#define OBD_MINOR 241 -static struct miscdevice obd_psdev = { - OBD_MINOR, - "obd_psdev", - &obd_psdev_fops -}; - -EXPORT_SYMBOL(obd_register_type); -EXPORT_SYMBOL(obd_unregister_type); - -EXPORT_SYMBOL(obd_dev); - -EXPORT_SYMBOL(gen_connect); -EXPORT_SYMBOL(gen_client); -EXPORT_SYMBOL(gen_cleanup); -EXPORT_SYMBOL(gen_disconnect); -EXPORT_SYMBOL(gen_copy_data); -EXPORT_SYMBOL(obdo_cachep); - -/* EXPORT_SYMBOL(gen_multi_attach); */ -EXPORT_SYMBOL(gen_multi_setup); -EXPORT_SYMBOL(gen_multi_cleanup); -EXPORT_SYMBOL(obd_memory); -EXPORT_SYMBOL(obd_fail_loc); - -static int __init init_obdclass(void) -{ - int err; - int i; - - printk(KERN_INFO "OBD class driver v0.01, braam@stelias.com\n"); - - INIT_LIST_HEAD(&obd_types); - - if ((err = misc_register(&obd_psdev))) { - CERROR("cannot register %d err %d\n", OBD_MINOR, err); - return err; - } - - for (i = 0; i < MAX_OBD_DEVICES; i++) { - memset(&(obd_dev[i]), 0, sizeof(obd_dev[i])); - obd_dev[i].obd_minor = i; - INIT_LIST_HEAD(&obd_dev[i].obd_gen_clients); - INIT_LIST_HEAD(&obd_dev[i].obd_req_list); - init_waitqueue_head(&obd_dev[i].obd_req_waitq); - } - - err = obd_init_obdo_cache(); - if (err) - return err; - obd_sysctl_init(); - obd_init_magic = 0x11223344; - return 0; -} - -static void __exit cleanup_obdclass(void) -{ - int i; - ENTRY; - - misc_deregister(&obd_psdev); - for (i = 0; i < MAX_OBD_DEVICES; i++) { - struct obd_device *obd = &obd_dev[i]; - if (obd->obd_type && (obd->obd_flags & OBD_SET_UP) && - OBT(obd) && OBP(obd, detach)) { - /* XXX should this call generic detach otherwise? */ - OBP(obd, detach)(obd); - } - } - - obd_cleanup_obdo_cache(); - obd_sysctl_clean(); - CERROR("obd memory leaked: %ld bytes\n", obd_memory); - obd_init_magic = 0; - EXIT; -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Lustre Class Driver v1.0"); -MODULE_LICENSE("GPL"); - -module_init(init_obdclass); -module_exit(cleanup_obdclass); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c deleted file mode 100644 index 35ee6b8..0000000 --- a/lustre/obdclass/genops.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - * linux/fs/ext2_obd/sim_obd.c - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * These are the only exported functions; they provide the simulated object- - * oriented disk. - * - */ - -#define DEBUG_SUBSYSTEM S_CLASS - -#include - -extern struct obd_device obd_dev[MAX_OBD_DEVICES]; -kmem_cache_t *obdo_cachep = NULL; - -int obd_init_obdo_cache(void) -{ - ENTRY; - if (obdo_cachep == NULL) { - CDEBUG(D_CACHE, "allocating obdo_cache\n"); - obdo_cachep = kmem_cache_create("obdo_cache", - sizeof(struct obdo), - 0, SLAB_HWCACHE_ALIGN, - NULL, NULL); - if (obdo_cachep == NULL) - RETURN(-ENOMEM); - else - CDEBUG(D_CACHE, "allocated cache at %p\n", obdo_cachep); - } else { - CDEBUG(D_CACHE, "using existing cache at %p\n", obdo_cachep); - } - RETURN(0); -} - -void obd_cleanup_obdo_cache(void) -{ - ENTRY; - if (obdo_cachep != NULL) { - CDEBUG(D_CACHE, "destroying obdo_cache at %p\n", obdo_cachep); - if (kmem_cache_destroy(obdo_cachep)) - CERROR("unable to free cache\n"); - } else - CERROR("called with NULL cache pointer\n"); - - obdo_cachep = NULL; - EXIT; -} - - -/* map connection to client */ -struct obd_client *gen_client(const struct obd_conn *conn) -{ - struct obd_device * obddev; - struct list_head * lh, * next; - struct obd_client * cli; - - if (!conn) - return NULL; - - obddev = conn->oc_dev; - lh = next = &obddev->obd_gen_clients; - while ((lh = lh->next) != &obddev->obd_gen_clients) { - cli = list_entry(lh, struct obd_client, cli_chain); - - if (cli->cli_id == conn->oc_id) - return cli; - } - - return NULL; -} /* gen_client */ - - -/* a connection defines a context in which preallocation can be managed. */ -int gen_connect (struct obd_conn *conn) -{ - struct obd_client * cli; - - OBD_ALLOC(cli, sizeof(*cli)); - if ( !cli ) { - CERROR("no memory! (minor %d)\n", conn->oc_dev->obd_minor); - return -ENOMEM; - } - - INIT_LIST_HEAD(&cli->cli_prealloc_inodes); - /* XXX this should probably spinlocked? */ - cli->cli_id = ++conn->oc_dev->obd_gen_last_id; - cli->cli_prealloc_quota = 0; - cli->cli_obd = conn->oc_dev; - list_add(&(cli->cli_chain), conn->oc_dev->obd_gen_clients.prev); - - CDEBUG(D_INFO, "connect: new ID %u\n", cli->cli_id); - conn->oc_id = cli->cli_id; - return 0; -} /* gen_connect */ - - -int gen_disconnect(struct obd_conn *conn) -{ - struct obd_client * cli; - ENTRY; - - if (!(cli = gen_client(conn))) { - CDEBUG(D_IOCTL, "disconnect: attempting to free " - "nonexistent client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - - list_del(&(cli->cli_chain)); - OBD_FREE(cli, sizeof(*cli)); - - CDEBUG(D_INFO, "disconnect: ID %u\n", conn->oc_id); - - RETURN(0); -} /* gen_obd_disconnect */ - -/* FIXME: Data is a space- or comma-separated list of device IDs. This will - * have to change. */ -int gen_multi_setup(struct obd_device *obddev, uint32_t len, void *data) -{ - int count, rc; - char *p; - ENTRY; - - for (p = data, count = 0; p < (char *)data + len; count++) { - char *end; - int tmp = simple_strtoul(p, &end, 0); - - if (p == end) { - CERROR("invalid device ID starting at: %s\n", p); - GOTO(err_disconnect, rc = -EINVAL); - } - - obddev->obd_multi_conn[count].oc_dev = &obd_dev[tmp]; - rc = obd_connect(&obddev->obd_multi_conn[count]); - if (rc) { - CERROR("cannot connect to device %d: rc = %d\n", tmp, - rc); - GOTO(err_disconnect, rc); - } - - CDEBUG(D_INFO, "target OBD %d is of type %s\n", count, - obd_dev[tmp].obd_type->typ_name); - - p = end + 1; - } - - obddev->obd_multi_count = count; - - RETURN(0); - - err_disconnect: - for (count--; count >= 0; count--) - obd_disconnect(&obddev->obd_multi_conn[count]); - return rc; -} - -/* - * remove all connections to this device - * close all connections to lower devices - * needed for forced unloads of OBD client drivers - */ -int gen_multi_cleanup(struct obd_device *obddev) -{ - int i; - - for (i = 0; i < obddev->obd_multi_count; i++) { - int rc = obd_disconnect(&obddev->obd_multi_conn[i]); - if (rc) - CERROR("disconnect failure %d\n", - obddev->obd_multi_conn[i].oc_dev->obd_minor); - } - return 0; -} - - -/* - * forced cleanup of the device: - * - remove connections from the device - * - cleanup the device afterwards - */ -int gen_cleanup(struct obd_device * obddev) -{ - struct list_head * lh, * tmp; - struct obd_client * cli; - - ENTRY; - - lh = tmp = &obddev->obd_gen_clients; - while ((tmp = tmp->next) != lh) { - cli = list_entry(tmp, struct obd_client, cli_chain); - CDEBUG(D_INFO, "Disconnecting obd_connection %d, at %p\n", - cli->cli_id, cli); - } - return 0; -} /* sim_cleanup_device */ - -void lck_page(struct page *page) -{ - while (TryLockPage(page)) - ___wait_on_page(page); -} - -int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst, - struct obd_conn *src_conn, struct obdo *src, - obd_size count, obd_off offset) -{ - struct page *page; - unsigned long index = 0; - int err = 0; - - ENTRY; - CDEBUG(D_INFO, "src: ino %Ld blocks %Ld, size %Ld, dst: ino %Ld\n", - (unsigned long long)src->o_id, (unsigned long long)src->o_blocks, - (unsigned long long)src->o_size, (unsigned long long)dst->o_id); - page = alloc_page(GFP_USER); - if (page == NULL) - RETURN(-ENOMEM); - - lck_page(page); - - /* XXX with brw vector I/O, we could batch up reads and writes here, - * all we need to do is allocate multiple pages to handle the I/Os - * and arrays to handle the request parameters. - */ - while (index < ((src->o_size + PAGE_SIZE - 1) >> PAGE_SHIFT)) { - obd_count num_oa = 1; - obd_count num_buf = 1; - obd_size brw_count = PAGE_SIZE; - obd_off brw_offset = (page->index) << PAGE_SHIFT; - obd_flag flagr = 0; - obd_flag flagw = OBD_BRW_CREATE; - - page->index = index; - err = OBP(src_conn->oc_dev, brw)(READ, src_conn, num_oa, &src, - &num_buf, &page, &brw_count, - &brw_offset, &flagr); - - if ( err ) { - EXIT; - break; - } - CDEBUG(D_INFO, "Read page %ld ...\n", page->index); - - err = OBP(dst_conn->oc_dev, brw)(WRITE, dst_conn, num_oa, &dst, - &num_buf, &page, &brw_count, - &brw_offset, &flagw); - - /* XXX should handle dst->o_size, dst->o_blocks here */ - if ( err ) { - EXIT; - break; - } - - CDEBUG(D_INFO, "Wrote page %ld ...\n", page->index); - - index++; - } - dst->o_size = src->o_size; - dst->o_blocks = src->o_blocks; - dst->o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); - UnlockPage(page); - __free_page(page); - - RETURN(err); -} diff --git a/lustre/obdclass/proc_lustre.c b/lustre/obdclass/proc_lustre.c deleted file mode 100644 index 714a0e5..0000000 --- a/lustre/obdclass/proc_lustre.c +++ /dev/null @@ -1,240 +0,0 @@ -/* proc_lustre.c manages /proc/lustre/obd. - * - * Copyright (c) 2001 Rumi Zahir - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * OBD devices materialize in /proc as a directory: - * /proc/lustre/obd/ - * when /dev/obd is opened. When the device is closed, the - * directory entry disappears. - * - * For each open OBD device, code in this file also creates a file - * named . "cat /proc/lustre/obd//status" gives - * information about the OBD device's configuration. - * The class driver manages the "status" entry. - * - * Other logical drivers can create their own entries. For example, - * the obdtrace driver creates /proc/lustre/obd//stats entry. - * - * This file defines three functions - * proc_lustre_register_obd_device() - * proc_lustre_release_obd_device() - * proc_lustre_remove_obd_entry() - * that dynamically create/delete /proc/lustre/obd entries: - * - * proc_lustre_register_obd_device() registers an obd device, - * and, if this is the first OBD device, creates /proc/lustre/obd. - * - * proc_lustre_release_obd_device() removes device information - * from /proc/lustre/obd, and if this is the last OBD device - * removes /proc/lustre/obd. - * - * proc_lustre_remove_obd_entry() removes a - * /proc/lustre/obd// entry by name. This is the only - * function that is exported to other modules. - */ - -#define EXPORT_SYMTAB -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include - -#ifdef CONFIG_PROC_FS -extern struct proc_dir_entry proc_root; - -static struct proc_dir_entry *proc_lustre_dir_entry = 0; -static struct proc_dir_entry *proc_lustre_obd_dir_entry = 0; - -static struct proc_dir_entry * -proc_lustre_mkdir(const char* dname, struct proc_dir_entry *parent) -{ - struct proc_dir_entry *child_dir_entry; - -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0) /*0x20300 */ - child_dir_entry = proc_mkdir(dname, parent); -#else - child_dir_entry = create_proc_entry(dname, - S_IFDIR | S_IRUGO | S_IXUGO, - &proc_root); -#endif - if (!child_dir_entry) - CERROR("lustre: failed to create /proc entry %s\n", dname); - - return child_dir_entry; -} - -static int read_lustre_status(char *page, char **start, off_t offset, - int count, int *eof, void *data) -{ - struct obd_device * obddev = (struct obd_device *) data; - int p; - - p = sprintf(&page[0], "/dev/obd%d: ", obddev->obd_minor); - - if (obddev->obd_refcnt==0) { - /* obd is unused */ - p += sprintf(&page[p], "open but unused\n"); - } - else { /* obd in use */ - p += sprintf(&page[p], "refcnt(%d)", obddev->obd_refcnt); - - if (obddev->obd_flags & OBD_ATTACHED) { - p += sprintf(&page[p], ", attached(%s)", - obddev->obd_type->typ_name); - } - - if (obddev->obd_flags & OBD_SET_UP) { - struct dentry *my_dentry; - struct vfsmount *root_mnt; - char *path; - char *pathpage; - - if (!(pathpage = (char*) __get_free_page(GFP_KERNEL))) - return -ENOMEM; - - my_dentry = obddev->obd_fsname.dentry; - root_mnt = mntget(current->fs->rootmnt); - path = d_path(my_dentry,root_mnt,pathpage,PAGE_SIZE); - - p += sprintf(&page[p], ", setup(%s)", path); - - free_page((unsigned long) pathpage); - } - - /* print connections */ - { - struct list_head * lh; - struct obd_client * cli=0; - - lh = &obddev->obd_gen_clients; - while ((lh = lh->next) != &obddev->obd_gen_clients) { - p += sprintf(&page[p], - ((cli==0) ? ", connections(" : ",") ); - cli = list_entry(lh, struct obd_client, cli_chain); - p += sprintf(&page[p], "%d", cli->cli_id); - } /* while */ - if (cli!=0) { /* there was at least one client */ - p += sprintf(&page[p], ")"); - } - } - - p += sprintf(&page[p], "\n"); - } - - /* Compute eof and return value */ - - if (offset + count >= p) { - *eof=1; - return (p - offset); - } - return count; -} - -struct proc_dir_entry * -proc_lustre_register_obd_device(struct obd_device *obd) -{ - char obdname[32]; - struct proc_dir_entry *obd_dir; - struct proc_dir_entry *obd_status = 0; - - if (!proc_lustre_dir_entry) { - proc_lustre_dir_entry = - proc_lustre_mkdir("lustre", &proc_root); - if (!proc_lustre_dir_entry) - return 0; - - proc_lustre_obd_dir_entry = - proc_lustre_mkdir("obd", proc_lustre_dir_entry); - if (!proc_lustre_obd_dir_entry) - return 0; - } - - sprintf(obdname, "%d", obd->obd_minor); - - obd_dir = proc_lustre_mkdir(obdname, proc_lustre_obd_dir_entry); - - if (obd_dir) - obd_status = create_proc_entry("status", S_IRUSR | S_IFREG, obd_dir); - - if (obd_status) { - obd_status->read_proc = read_lustre_status; - obd_status->data = (void*) obd; - } - - return obd_dir; -} - -void proc_lustre_remove_obd_entry(const char* name, struct obd_device *obd) -{ - struct proc_dir_entry *obd_entry = 0; - struct proc_dir_entry *obd_dir = obd->obd_proc_entry; - - remove_proc_entry(name, obd_dir); - - while (obd_dir->subdir==0) { - /* if we removed last entry in this directory, - * then remove parent directory unless this - * is /proc itself - */ - if (obd_dir == &proc_root) - break; - - obd_entry = obd_dir; - obd_dir = obd_dir->parent; - - /* If /proc/lustre/obd/foo or /proc/lustre/obd or - * /proc/lustre is being removed, then reset - * internal variables - */ - - if (obd_entry == obd->obd_proc_entry) - obd->obd_proc_entry=0; /* /proc/lustre/obd/foo */ - else - if (obd_entry == proc_lustre_obd_dir_entry) - proc_lustre_obd_dir_entry=0; - else - if (obd_entry == proc_lustre_dir_entry) - proc_lustre_dir_entry=0; - - remove_proc_entry(obd_entry->name, obd_dir); - } -} - -void proc_lustre_release_obd_device(struct obd_device *obd) -{ - proc_lustre_remove_obd_entry("status", obd); -} - - -#else /* CONFIG_PROC_FS */ - -struct proc_dir_entry *proc_lustre_register_obd_device(struct obd_device *obd) -{ - return 0; -} - -void proc_lustre_remove_obd_entry(const char* name, struct obd_device *obd) {} -void proc_lustre_release_obd_device(struct obd_device *obd) {} - -#endif /* CONFIG_PROC_FS */ - -EXPORT_SYMBOL(proc_lustre_remove_obd_entry); - - - - - - - - - - - diff --git a/lustre/obdclass/sysctl.c b/lustre/obdclass/sysctl.c deleted file mode 100644 index 57ae735..0000000 --- a/lustre/obdclass/sysctl.c +++ /dev/null @@ -1,128 +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. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_CLASS - -#include - -struct ctl_table_header *obd_table_header = NULL; - -static int vars[2]; -static int index = 0; - -static int obd_sctl_vars( ctl_table * table, int write, struct file * - filp, void * buffer, size_t * lenp ); -static int obd_sctl_reset( ctl_table * table, int write, struct file - * filp, void * buffer, size_t * lenp ); - -#define OBD_SYSCTL 300 - -#define OBD_FAIL_LOC 1 /* control test failures instrumentation */ -#define OBD_ENTRY 2 /* control enter/leave pattern */ -#define OBD_TIMEOUT 3 /* timeout on upcalls to become intrble */ -#define OBD_HARD 4 /* mount type "hard" or "soft" */ -#define OBD_VARS 5 -#define OBD_INDEX 6 -#define OBD_RESET 7 - -#define OBD_VARS_SLOT 2 - -static ctl_table obd_table[] = { - {OBD_FAIL_LOC, "fail_loc", &obd_fail_loc, sizeof(int), 0644, NULL, &proc_dointvec}, - {OBD_VARS, "vars", &vars[0], sizeof(int), 0644, NULL, &proc_dointvec}, - {OBD_INDEX, "index", &index, sizeof(int), 0644, NULL, &obd_sctl_vars}, - {OBD_RESET, "reset", NULL, 0, 0644, NULL, &obd_sctl_reset}, - { 0 } -}; - -static ctl_table parent_table[] = { - {OBD_SYSCTL, "lustre", NULL, 0, 0555, obd_table}, - {0} -}; - -void obd_sysctl_init (void) -{ -#ifdef CONFIG_SYSCTL - if ( !obd_table_header ) - obd_table_header = register_sysctl_table(parent_table, 0); -#endif -} - -void obd_sysctl_clean (void) -{ -#ifdef CONFIG_SYSCTL - if ( obd_table_header ) - unregister_sysctl_table(obd_table_header); - obd_table_header = NULL; -#endif -} - -int obd_sctl_reset (ctl_table * table, int write, - struct file * filp, void * buffer, - size_t * lenp) -{ - if ( write ) { - /* do something here */ - vars[0]=0; - vars[1]=0; - } - - *lenp = 0; - return 0; -} - -int obd_sctl_vars (ctl_table * table, int write, - struct file * filp, void * buffer, - size_t * lenp) -{ - int rc; - - rc = proc_dointvec(table, write, filp, buffer, lenp); - - if ( rc ) - return rc; - - if ( index < 0 || index > 1 ) { - CERROR("Illegal index %d!\n", index); - index = 0; - } else { - obd_table[OBD_VARS_SLOT].data = &vars[index]; - } - - return rc; -} diff --git a/lustre/obdecho/.cvsignore b/lustre/obdecho/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/obdecho/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/obdecho/Makefile.am b/lustre/obdecho/Makefile.am deleted file mode 100644 index bd6308f..0000000 --- a/lustre/obdecho/Makefile.am +++ /dev/null @@ -1,14 +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 - -DEFS:= -MODULE = obdecho -modulefs_DATA = obdecho.o -EXTRA_PROGRAMS = obdecho - -obdecho_SOURCES = echo.c - -include $(top_srcdir)/Rules - diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c deleted file mode 100644 index d3cd0a7..0000000 --- a/lustre/obdecho/echo.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/fs/ext2_obd/ext2_obd.c - * - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Peter Braam - */ - -#define EXPORT_SYMTAB - -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_ECHO - -#include -#include -#include - -extern struct obd_device obd_dev[MAX_OBD_DEVICES]; -static struct obdo OA; -static obd_count GEN; -static long echo_pages = 0; - -static int echo_connect(struct obd_conn *conn) -{ - int rc; - - MOD_INC_USE_COUNT; - rc = gen_connect(conn); - - if (rc) - MOD_DEC_USE_COUNT; - - return rc; -} - -static int echo_disconnect(struct obd_conn *conn) -{ - int rc; - - rc = gen_disconnect(conn); - if (!rc) - MOD_DEC_USE_COUNT; - - return rc; -} - -static int echo_getattr(struct obd_conn *conn, struct obdo *oa) -{ - memcpy(oa, &OA, sizeof(*oa)); - oa->o_mode = ++GEN; - - return 0; -} - -int echo_preprw(int cmd, struct obd_conn *conn, int objcount, - struct obd_ioobj *obj, int niocount, struct niobuf_remote *nb, - struct niobuf_local *res, void **desc_private) -{ - struct niobuf_local *r = res; - int rc = 0; - int i; - - ENTRY; - - memset(res, 0, sizeof(*res) * niocount); - - CDEBUG(D_PAGE, "%s %d obdos with %d IOs\n", - cmd == OBD_BRW_READ ? "reading" : "writing", objcount, niocount); - - for (i = 0; i < objcount; i++, obj++) { - int j; - - for (j = 0 ; j < obj->ioo_bufcnt ; j++, nb++, r++) { - unsigned long address; - - address = get_zeroed_page(GFP_KERNEL); - if (!address) { - CERROR("can't get new page %d/%d for id %Ld\n", - j, obj->ioo_bufcnt, - (unsigned long long)obj->ioo_id); - GOTO(preprw_cleanup, rc = -ENOMEM); - } - echo_pages++; - - /* - if (cmd == OBD_BRW_READ) { - __u64 *data = address; - - data[0] = obj->ioo_id; - data[1] = j; - data[2] = nb->offset; - data[3] = nb->len; - } - */ - - r->offset = nb->offset; - r->page = virt_to_page(address); - r->addr = kmap(r->page); - r->len = nb->len; - // r->flags - } - } - CDEBUG(D_PAGE, "%ld pages allocated after prep\n", echo_pages); - - RETURN(0); - -preprw_cleanup: - /* It is possible that we would rather handle errors by allow - * any already-set-up pages to complete, rather than tearing them - * all down again. I believe that this is what the in-kernel - * prep/commit operations do. - */ - CERROR("cleaning up %ld pages (%d obdos)\n", (long)(r - res), objcount); - while (r-- > res) { - kunmap(r->page); - - __free_pages(r->page, 0); - echo_pages--; - } - memset(res, 0, sizeof(*res) * niocount); - - return rc; -} - -int echo_commitrw(int cmd, struct obd_conn *conn, int objcount, - struct obd_ioobj *obj, int niocount, struct niobuf_local *res, - void *desc_private) -{ - struct niobuf_local *r = res; - int rc = 0; - int i; - ENTRY; - - CDEBUG(D_PAGE, "%s %d obdos with %d IOs\n", - cmd == OBD_BRW_READ ? "reading" : "writing", objcount, niocount); - - if (niocount && !r) { - CERROR("NULL res niobuf with niocount %d\n", niocount); - RETURN(-EINVAL); - } - - for (i = 0; i < objcount; i++, obj++) { - int j; - - for (j = 0 ; j < obj->ioo_bufcnt ; j++, r++) { - struct page *page = r->page; - unsigned long addr = (unsigned long)page_address(page); - - if (!addr || !kern_addr_valid(addr)) { - CERROR("bad page %p, id %Ld (%d), buf %d/%d\n", - page, (unsigned long long)obj->ioo_id, i, - j, obj->ioo_bufcnt); - GOTO(commitrw_cleanup, rc = -EFAULT); - } - - free_pages(addr, 0); - echo_pages--; - } - } - CDEBUG(D_PAGE, "%ld pages remain after commit\n", echo_pages); - RETURN(0); - -commitrw_cleanup: - CERROR("cleaning up %ld pages (%d obdos)\n", - niocount - (long)(r - res) - 1, objcount); - while (++r < res + niocount) { - struct page *page = r->page; - unsigned long addr = (unsigned long)page_address(page); - - free_pages(addr, 0); - echo_pages--; - } - return rc; -} - -struct obd_ops echo_obd_ops = { - o_connect: echo_connect, - o_disconnect: echo_disconnect, - o_getattr: echo_getattr, - o_preprw: echo_preprw, - o_commitrw: echo_commitrw, -}; - - -static int __init obdecho_init(void) -{ - printk(KERN_INFO "Echo OBD driver v0.001, braam@clusterfs.com\n"); - - return obd_register_type(&echo_obd_ops, OBD_ECHO_DEVICENAME); -} - -static void __exit obdecho_exit(void) -{ - CERROR("%ld prep/commitrw pages leaked\n", echo_pages); - obd_unregister_type(OBD_ECHO_DEVICENAME); -} - -MODULE_AUTHOR("Cluster Filesystems Inc. "); -MODULE_DESCRIPTION("Lustre Testing Echo OBD driver v1.0"); -MODULE_LICENSE("GPL"); - -module_init(obdecho_init); -module_exit(obdecho_exit); diff --git a/lustre/obdfilter/.cvsignore b/lustre/obdfilter/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/obdfilter/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/obdfilter/Makefile.am b/lustre/obdfilter/Makefile.am deleted file mode 100644 index f4c98f7..0000000 --- a/lustre/obdfilter/Makefile.am +++ /dev/null @@ -1,22 +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 - -DEFS:= -MODULE = obdfilter -modulefs_DATA = obdfilter.o -EXTRA_PROGRAMS = obdfilter - -LINX=simple.c -simple.c: - test -e simple.c || ln -sf $(top_srcdir)/lib/simple.c - -EXT2C = filter.c -obdfilter_SOURCES = filter.c $(LINX) - -dist-hook: - list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done - -include $(top_srcdir)/Rules - diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c deleted file mode 100644 index 0aa5381..0000000 --- a/lustre/obdfilter/filter.c +++ /dev/null @@ -1,1411 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * linux/fs/filter/filter.c - * - * Copyright (C) 2001 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * by Peter Braam - */ - -#define EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_FILTER - -#include -#include -#include -#include - -extern struct obd_device obd_dev[MAX_OBD_DEVICES]; -long filter_memory; - -#define FILTER_ROOTINO 2 - -#define S_SHIFT 12 -static char *obd_type_by_mode[S_IFMT >> S_SHIFT] = { - [0] NULL, - [S_IFREG >> S_SHIFT] "R", - [S_IFDIR >> S_SHIFT] "D", - [S_IFCHR >> S_SHIFT] "C", - [S_IFBLK >> S_SHIFT] "B", - [S_IFIFO >> S_SHIFT] "F", - [S_IFSOCK >> S_SHIFT] "S", - [S_IFLNK >> S_SHIFT] "L" -}; - -static inline const char *obd_mode_to_type(int mode) -{ - return obd_type_by_mode[(mode & S_IFMT) >> S_SHIFT]; -} - -/* write the pathname into the string */ -static int filter_id(char *buf, obd_id id, obd_mode mode) -{ - return sprintf(buf, "O/%s/%Ld", obd_mode_to_type(mode), - (unsigned long long)id); -} - -/* setup the object store with correct subdirectories */ -static int filter_prep(struct obd_device *obddev) -{ - struct obd_run_ctxt saved; - struct filter_obd *filter = &obddev->u.filter; - struct dentry *dentry; - struct file *file; - struct inode *inode; - loff_t off; - int rc = 0; - char rootid[128]; - __u64 lastino = 2; - int mode = 0; - - push_ctxt(&saved, &filter->fo_ctxt); - dentry = simple_mkdir(current->fs->pwd, "O", 0700); - CDEBUG(D_INODE, "got/created O: %p\n", dentry); - if (IS_ERR(dentry)) { - rc = PTR_ERR(dentry); - CERROR("cannot open/create O: rc = %d\n", rc); - GOTO(out, rc); - } - filter->fo_dentry_O = dentry; - dentry = simple_mkdir(current->fs->pwd, "P", 0700); - CDEBUG(D_INODE, "got/created P: %p\n", dentry); - if (IS_ERR(dentry)) { - rc = PTR_ERR(dentry); - CERROR("cannot open/create P: rc = %d\n", rc); - GOTO(out_O, rc); - } - CDEBUG(D_INODE, "putting P: %p, count = %d\n", dentry, - atomic_read(&dentry->d_count) - 1); - dput(dentry); - dentry = simple_mkdir(current->fs->pwd, "D", 0700); - CDEBUG(D_INODE, "got/created D: %p\n", dentry); - if (IS_ERR(dentry)) { - rc = PTR_ERR(dentry); - CERROR("cannot open/create D: rc = %d\n", rc); - GOTO(out_O, rc); - } - CDEBUG(D_INODE, "putting D: %p, count = %d\n", dentry, - atomic_read(&dentry->d_count) - 1); - dput(dentry); - - /* - * Create directories and/or get dentries for each object type. - * This saves us from having to do multiple lookups for each one. - */ - for (mode = 0; mode < (S_IFMT >> S_SHIFT); mode++) { - char *type = obd_type_by_mode[mode]; - - if (!type) { - filter->fo_dentry_O_mode[mode] = NULL; - continue; - } - dentry = simple_mkdir(filter->fo_dentry_O, type, 0700); - CDEBUG(D_INODE, "got/created O/%s: %p\n", type, dentry); - if (IS_ERR(dentry)) { - rc = PTR_ERR(dentry); - CERROR("cannot create O/%s: rc = %d\n", type, rc); - GOTO(out_O_mode, rc); - } - filter->fo_dentry_O_mode[mode] = dentry; - } - - filter_id(rootid, FILTER_ROOTINO, S_IFDIR); - file = filp_open(rootid, O_RDWR | O_CREAT, 0755); - if (IS_ERR(file)) { - rc = PTR_ERR(file); - CERROR("OBD filter: cannot open/create root %s: rc = %d\n", - rootid, rc); - GOTO(out_O_mode, rc); - } - filp_close(file, 0); - - file = filp_open("D/status", O_RDWR | O_CREAT, 0700); - if ( !file || IS_ERR(file) ) { - rc = PTR_ERR(file); - CERROR("OBD filter: cannot open/create status %s: rc = %d\n", - "D/status", rc); - GOTO(out_O_mode, rc); - } - - /* steal operations */ - inode = file->f_dentry->d_inode; - filter->fo_fop = file->f_op; - filter->fo_iop = inode->i_op; - filter->fo_aops = inode->i_mapping->a_ops; - - off = 0; - if (inode->i_size == 0) { - ssize_t retval = file->f_op->write(file, (char *)&lastino, - sizeof(lastino), &off); - if (retval != sizeof(lastino)) { - CDEBUG(D_INODE, "OBD filter: error writing lastino\n"); - filp_close(file, 0); - GOTO(out_O_mode, rc = -EIO); - } - } else { - ssize_t retval = file->f_op->read(file, (char *)&lastino, - sizeof(lastino), &off); - if (retval != sizeof(lastino)) { - CDEBUG(D_INODE, "OBD filter: error reading lastino\n"); - filp_close(file, 0); - GOTO(out_O_mode, rc = -EIO); - } - } - filter->fo_lastino = lastino; - filp_close(file, 0); - - rc = 0; - out: - pop_ctxt(&saved); - - return(rc); - -out_O_mode: - while (--mode >= 0) { - struct dentry *dentry = filter->fo_dentry_O_mode[mode]; - if (dentry) { - CDEBUG(D_INODE, "putting O/%s: %p, count = %d\n", - obd_type_by_mode[mode], dentry, - atomic_read(&dentry->d_count) - 1); - dput(dentry); - filter->fo_dentry_O_mode[mode] = NULL; - } - } -out_O: - CDEBUG(D_INODE, "putting O: %p, count = %d\n", filter->fo_dentry_O, - atomic_read(&filter->fo_dentry_O->d_count) - 1); - dput(filter->fo_dentry_O); - filter->fo_dentry_O = NULL; - goto out; -} - -/* cleanup the filter: write last used object id to status file */ -static void filter_post(struct obd_device *obddev) -{ - struct obd_run_ctxt saved; - struct filter_obd *filter = &obddev->u.filter; - long rc; - struct file *file; - loff_t off = 0; - int mode; - - push_ctxt(&saved, &filter->fo_ctxt); - file = filp_open("D/status", O_RDWR | O_CREAT, 0700); - if (IS_ERR(file)) { - CERROR("OBD filter: cannot create status file\n"); - goto out; - } - rc = file->f_op->write(file, (char *)&filter->fo_lastino, - sizeof(filter->fo_lastino), &off); - if (rc != sizeof(filter->fo_lastino)) - CERROR("OBD filter: error writing lastino: rc = %ld\n", rc); - - rc = filp_close(file, NULL); - if (rc) - CERROR("OBD filter: cannot close status file: rc = %ld\n", rc); - - for (mode = 0; mode < (S_IFMT >> S_SHIFT); mode++) { - struct dentry *dentry = filter->fo_dentry_O_mode[mode]; - if (dentry) { - CDEBUG(D_INODE, "putting O/%s: %p, count = %d\n", - obd_type_by_mode[mode], dentry, - atomic_read(&dentry->d_count) - 1); - dput(dentry); - filter->fo_dentry_O_mode[mode] = NULL; - } - } - CDEBUG(D_INODE, "putting O: %p, count = %d\n", filter->fo_dentry_O, - atomic_read(&filter->fo_dentry_O->d_count) - 1); - dput(filter->fo_dentry_O); -out: - pop_ctxt(&saved); -} - - -static __u64 filter_next_id(struct obd_device *obddev) -{ - __u64 id; - spin_lock(&obddev->u.filter.fo_lock); - obddev->u.filter.fo_lastino++; - id = obddev->u.filter.fo_lastino; - spin_unlock(&obddev->u.filter.fo_lock); - return id; -} - -/* how to get files, dentries, inodes from object id's */ -/* parent i_sem is already held if needed for exclusivity */ -static struct dentry *filter_fid2dentry(struct obd_device *obddev, - struct dentry *dparent, - __u64 id, __u32 type) -{ - struct super_block *sb = obddev->u.filter.fo_sb; - struct dentry *dchild; - char name[32]; - int len; - ENTRY; - - if (!sb || !sb->s_dev) { - CERROR("fatal: device not initialized.\n"); - RETURN(ERR_PTR(-ENXIO)); - } - - if (id == 0) { - CERROR("fatal: invalid object #0\n"); - RETURN(ERR_PTR(-ESTALE)); - } - - if (!(type & S_IFMT)) { - CERROR("OBD %s, object %Lu has bad type: %o\n", __FUNCTION__, - (unsigned long long)id, type); - RETURN(ERR_PTR(-EINVAL)); - } - - len = sprintf(name, "%Ld", id); - CDEBUG(D_INODE, "opening object O/%s/%s\n", obd_mode_to_type(type), - name); - dchild = lookup_one_len(name, dparent, len); - CDEBUG(D_INODE, "got child obj O/%s/%s: %p, count = %d\n", - obd_mode_to_type(type), name, dchild, - atomic_read(&dchild->d_count)); - - if (IS_ERR(dchild)) { - CERROR("child lookup error %ld\n", PTR_ERR(dchild)); - RETURN(dchild); - } - - RETURN(dchild); -} - -static struct file *filter_obj_open(struct obd_device *obddev, - __u64 id, __u32 type) -{ - struct super_block *sb = obddev->u.filter.fo_sb; - struct obd_run_ctxt saved; - char name[24]; - struct file *file; - ENTRY; - - if (!sb || !sb->s_dev) { - CERROR("fatal: device not initialized.\n"); - RETURN(ERR_PTR(-ENXIO)); - } - - if (!id) { - CERROR("fatal: invalid obdo %Lu\n", (unsigned long long)id); - RETURN(ERR_PTR(-ESTALE)); - } - - if (!(type & S_IFMT)) { - CERROR("OBD %s, no type (%Ld), mode %o!\n", __FUNCTION__, - (unsigned long long)id, type); - RETURN(ERR_PTR(-EINVAL)); - } - - filter_id(name, id, type); - push_ctxt(&saved, &obddev->u.filter.fo_ctxt); - file = filp_open(name, O_RDONLY | O_LARGEFILE, 0 /* type? */); - pop_ctxt(&saved); - - CDEBUG(D_INODE, "opening obdo %s: rc = %p\n", name, file); - - if (IS_ERR(file)) - file = NULL; - RETURN(file); -} - -static struct dentry *filter_parent(struct obd_device *obddev, obd_mode mode) -{ - struct filter_obd *filter = &obddev->u.filter; - - return filter->fo_dentry_O_mode[(mode & S_IFMT) >> S_SHIFT]; -} - - -static struct inode *filter_inode_from_obj(struct obd_device *obddev, - __u64 id, __u32 type) -{ - struct dentry *dentry; - struct inode *inode; - - dentry = filter_fid2dentry(obddev, filter_parent(obddev, type), - id, type); - if (IS_ERR(dentry)) { - CERROR("%s: lookup failed: rc = %ld\n", __FUNCTION__, - PTR_ERR(dentry)); - RETURN(NULL); - } - - lock_kernel(); - inode = iget(dentry->d_inode->i_sb, dentry->d_inode->i_ino); - unlock_kernel(); - CDEBUG(D_INODE, "put child %p, count = %d\n", dentry, - atomic_read(&dentry->d_count) - 1); - dput(dentry); - CDEBUG(D_INODE, "got inode %p (%ld), count = %d\n", inode, inode->i_ino, - atomic_read(&inode->i_count)); - return inode; -} - -/* obd methods */ -static int filter_connect(struct obd_conn *conn) -{ - int rc; - - MOD_INC_USE_COUNT; - rc = gen_connect(conn); - - if (rc) - MOD_DEC_USE_COUNT; - - return rc; -} - -static int filter_disconnect(struct obd_conn *conn) -{ - int rc; - - rc = gen_disconnect(conn); - if (!rc) - MOD_DEC_USE_COUNT; - - /* XXX cleanup preallocated inodes */ - return rc; -} - -/* mount the file system (secretly) */ -static int filter_setup(struct obd_device *obddev, obd_count len, void *buf) -{ - struct obd_ioctl_data* data = buf; - struct filter_obd *filter; - struct vfsmount *mnt; - int err = 0; - ENTRY; - - if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2) - RETURN(-EINVAL); - - MOD_INC_USE_COUNT; - mnt = do_kern_mount(data->ioc_inlbuf2, 0, data->ioc_inlbuf1, NULL); - err = PTR_ERR(mnt); - if (IS_ERR(mnt)) - GOTO(err_dec, err); - - filter = &obddev->u.filter;; - filter->fo_sb = mnt->mnt_root->d_inode->i_sb; - /* XXX is this even possible if do_kern_mount succeeded? */ - if (!filter->fo_sb) - GOTO(err_put, err = -ENODEV); - - filter->fo_vfsmnt = mnt; - filter->fo_fstype = strdup(data->ioc_inlbuf2); - - filter->fo_ctxt.pwdmnt = mnt; - filter->fo_ctxt.pwd = mnt->mnt_root; - filter->fo_ctxt.fs = KERNEL_DS; - - err = filter_prep(obddev); - if (err) - GOTO(err_kfree, err); - spin_lock_init(&filter->fo_lock); - - RETURN(0); - -err_kfree: - kfree(filter->fo_fstype); -err_put: - unlock_kernel(); - mntput(filter->fo_vfsmnt); - filter->fo_sb = 0; - lock_kernel(); - -err_dec: - MOD_DEC_USE_COUNT; - return err; -} - - -static int filter_cleanup(struct obd_device * obddev) -{ - struct super_block *sb; - ENTRY; - - if (!(obddev->obd_flags & OBD_SET_UP)) - RETURN(0); - - if (!list_empty(&obddev->obd_gen_clients)) { - CERROR("still has clients!\n"); - RETURN(-EBUSY); - } - - sb = obddev->u.filter.fo_sb; - if (!obddev->u.filter.fo_sb) - RETURN(0); - - filter_post(obddev); - - shrink_dcache_parent(sb->s_root); - unlock_kernel(); - mntput(obddev->u.filter.fo_vfsmnt); - obddev->u.filter.fo_sb = 0; - kfree(obddev->u.filter.fo_fstype); - - lock_kernel(); - - MOD_DEC_USE_COUNT; - RETURN(0); -} - - -static inline void filter_from_inode(struct obdo *oa, struct inode *inode) -{ - int type = oa->o_mode & S_IFMT; - ENTRY; - - CDEBUG(D_INFO, "src inode %ld, dst obdo %ld valid 0x%08x\n", - inode->i_ino, (long)oa->o_id, oa->o_valid); - obdo_from_inode(oa, inode); - oa->o_mode &= ~S_IFMT; - oa->o_mode |= type; - - if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { - obd_rdev rdev = kdev_t_to_nr(inode->i_rdev); - CDEBUG(D_INODE, "copying device %x from inode to obdo\n", - rdev); - *((obd_rdev *)oa->o_inline) = rdev; - oa->o_obdflags |= OBD_FL_INLINEDATA; - oa->o_valid |= OBD_MD_FLINLINE; - } - -#if 0 - else if (filter_has_inline(inode)) { - CDEBUG(D_INFO, "copying inline from inode to obdo\n"); - memcpy(oa->o_inline, inode->u.ext2_i.i_data, - MIN(sizeof(inode->u.ext2_i.i_data),OBD_INLINESZ)); - oa->o_obdflags |= OBD_FL_INLINEDATA; - oa->o_valid |= OBD_MD_FLINLINE; - } - - if (filter_has_obdmd(inode)) { - /* XXX this will change when we don't store the obdmd in data */ - CDEBUG(D_INFO, "copying obdmd from inode to obdo\n"); - memcpy(oa->o_obdmd, inode->u.ext2_i.i_data, - MIN(sizeof(inode->u.ext2_i.i_data),OBD_INLINESZ)); - oa->o_obdflags |= OBD_FL_OBDMDEXISTS; - oa->o_valid |= OBD_MD_FLOBDMD; - } -#endif - EXIT; -} - -static int filter_getattr(struct obd_conn *conn, struct obdo *oa) -{ - struct obd_device *obddev; - struct dentry *dentry; - ENTRY; - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "fatal: invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - obddev = conn->oc_dev; - dentry = filter_fid2dentry(obddev, filter_parent(obddev, oa->o_mode), - oa->o_id, oa->o_mode); - if (IS_ERR(dentry)) - RETURN(PTR_ERR(dentry)); - - oa->o_valid &= ~OBD_MD_FLID; - filter_from_inode(oa, dentry->d_inode); - - dput(dentry); - RETURN(0); -} - -static int filter_setattr(struct obd_conn *conn, struct obdo *oa) -{ - struct obd_run_ctxt saved; - struct obd_device *obddev; - struct dentry *dentry; - struct iattr iattr; - struct inode *inode; - int rc; - ENTRY; - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - obddev = conn->oc_dev; - dentry = filter_fid2dentry(obddev, filter_parent(obddev, oa->o_mode), - oa->o_id, oa->o_mode); - if (IS_ERR(dentry)) - RETURN(PTR_ERR(dentry)); - - inode = dentry->d_inode; - iattr_from_obdo(&iattr, oa); - iattr.ia_mode &= ~S_IFMT; - iattr.ia_mode |= S_IFREG; - lock_kernel(); - if (iattr.ia_mode & ATTR_SIZE) - down(&inode->i_sem); - push_ctxt(&saved, &conn->oc_dev->u.filter.fo_ctxt); - if (inode->i_op->setattr) - rc = inode->i_op->setattr(dentry, &iattr); - else - rc = inode_setattr(inode, &iattr); - pop_ctxt(&saved); - if (iattr.ia_mode & ATTR_SIZE) - up(&inode->i_sem); - unlock_kernel(); - - CDEBUG(D_INODE, "put dentry %p, count = %d\n", inode, - atomic_read(&dentry->d_count) - 1); - dput(dentry); - RETURN(rc); -} - -static int filter_open(struct obd_conn *conn, struct obdo *oa) -{ - struct obd_device *obddev; - struct dentry *dentry; - /* ENTRY; */ - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "fatal: invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - obddev = conn->oc_dev; - dentry = filter_fid2dentry(obddev, filter_parent(obddev, oa->o_mode), - oa->o_id, oa->o_mode); - if (IS_ERR(dentry)) - RETURN(PTR_ERR(dentry)); - - return 0; -} /* filter_open */ - -static int filter_close(struct obd_conn *conn, struct obdo *oa) -{ - struct obd_device *obddev; - struct dentry *dentry; - /* ENTRY; */ - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "fatal: invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - obddev = conn->oc_dev; - dentry = filter_fid2dentry(obddev, filter_parent(obddev, oa->o_mode), - oa->o_id, oa->o_mode); - if (IS_ERR(dentry)) - RETURN(PTR_ERR(dentry)); - - CDEBUG(D_INODE, "put dentry %p, count = %d\n", dentry, - atomic_read(&dentry->d_count) - 1); - dput(dentry); /* for the close */ - CDEBUG(D_INODE, "put dentry %p, count = %d\n", dentry, - atomic_read(&dentry->d_count) - 1); - dput(dentry); /* for this call */ - return 0; -} /* filter_close */ - -static int filter_create(struct obd_conn* conn, struct obdo *oa) -{ - char name[64]; - struct obd_run_ctxt saved; - struct file *file; - int mode; - struct obd_device *obddev = conn->oc_dev; - struct iattr; - ENTRY; - - if (!gen_client(conn)) { - CERROR("invalid client %u\n", conn->oc_id); - return -EINVAL; - } - - oa->o_id = filter_next_id(conn->oc_dev); - if (!(oa->o_mode && S_IFMT)) { - CERROR("filter obd: no type!\n"); - return -ENOENT; - } - - filter_id(name, oa->o_id, oa->o_mode); - mode = (oa->o_mode & ~S_IFMT) | S_IFREG; - push_ctxt(&saved, &obddev->u.filter.fo_ctxt); - file = filp_open(name, O_RDONLY | O_CREAT, mode); - pop_ctxt(&saved); - if (IS_ERR(file)) { - CERROR("Error mknod obj %s, err %ld\n", name, PTR_ERR(file)); - return -ENOENT; - } - filp_close(file, 0); - - /* Set flags for fields we have set in the inode struct */ - oa->o_valid |= OBD_MD_FLID | OBD_MD_FLBLKSZ | OBD_MD_FLBLOCKS | - OBD_MD_FLMTIME | OBD_MD_FLATIME | OBD_MD_FLCTIME | - OBD_MD_FLUID | OBD_MD_FLGID; - - /* XXX Hmm, shouldn't we copy the fields into the obdo here? */ - return 0; -} - -static int filter_destroy(struct obd_conn *conn, struct obdo *oa) -{ - struct obd_run_ctxt saved; - struct obd_device *obddev; - struct obd_client *cli; - struct inode *inode; - struct dentry *dir_dentry, *object_dentry; - int rc; - ENTRY; - - if (!(cli = gen_client(conn))) { - CERROR("invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - CDEBUG(D_INODE, "destroying object %Ld\n",oa->o_id); - obddev = conn->oc_dev; - - dir_dentry = filter_parent(obddev, oa->o_mode); - down(&dir_dentry->d_inode->i_sem); - - object_dentry = filter_fid2dentry(obddev, dir_dentry, oa->o_id, - oa->o_mode); - if (IS_ERR(object_dentry)) - GOTO(out, rc = -ENOENT); - - inode = object_dentry->d_inode; - if (inode->i_nlink != 1) { - CERROR("destroying inode with nlink = %d\n", inode->i_nlink); - inode->i_nlink = 1; - } - inode->i_mode = S_IFREG; - - push_ctxt(&saved, &obddev->u.filter.fo_ctxt); - rc = vfs_unlink(dir_dentry->d_inode, object_dentry); - pop_ctxt(&saved); - CDEBUG(D_INODE, "put child %p, count = %d\n", object_dentry, - atomic_read(&object_dentry->d_count) - 1); - dput(object_dentry); - - EXIT; -out: - up(&dir_dentry->d_inode->i_sem); - return rc; -} - -/* NB count and offset are used for punch, but not truncate */ -static int filter_truncate(struct obd_conn *conn, struct obdo *oa, - obd_size count, obd_off offset) -{ - int error; - ENTRY; - - CDEBUG(D_INODE, "calling truncate for object #%Ld, valid = %x, " - "o_size = %Ld\n", oa->o_id, oa->o_valid, oa->o_size); - error = filter_setattr(conn, oa); - oa->o_valid = OBD_MD_FLBLOCKS | OBD_MD_FLCTIME | OBD_MD_FLMTIME; - - RETURN(error); -} - -/* buffer must lie in user memory here */ -static int filter_read(struct obd_conn *conn, struct obdo *oa, char *buf, - obd_size *count, obd_off offset) -{ - struct file * file; - unsigned long retval; - int err; - ENTRY; - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - file = filter_obj_open(conn->oc_dev, oa->o_id, oa->o_mode); - if (IS_ERR(file)) - RETURN(PTR_ERR(file)); - - /* count doubles as retval */ - retval = file->f_op->read(file, buf, *count, (loff_t *)&offset); - filp_close(file, 0); - - if ( retval >= 0 ) { - err = 0; - *count = retval; - } else { - err = retval; - *count = 0; - } - - return err; -} - - -/* buffer must lie in user memory here */ -static int filter_write(struct obd_conn *conn, struct obdo *oa, char *buf, - obd_size *count, obd_off offset) -{ - struct obd_run_ctxt saved; - int err; - struct file * file; - unsigned long retval; - ENTRY; - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - file = filter_obj_open(conn->oc_dev, oa->o_id, oa->o_mode); - if (IS_ERR(file)) - RETURN(PTR_ERR(file)); - - /* count doubles as retval */ - push_ctxt(&saved, &conn->oc_dev->u.filter.fo_ctxt); - retval = file->f_op->write(file, buf, *count, (loff_t *)&offset); - pop_ctxt(&saved); - filp_close(file, 0); - - if ( retval >= 0 ) { - err = 0; - *count = retval; - EXIT; - } else { - err = retval; - *count = 0; - EXIT; - } - - return err; -} /* filter_write */ - -static int filter_pgcache_brw(int rw, struct obd_conn *conn, obd_count num_oa, - struct obdo **oa, obd_count *oa_bufs, - struct page **pages, obd_size *count, - obd_off *offset, obd_flag *flags) -{ - struct obd_run_ctxt saved; - struct super_block *sb; - int onum; /* index to oas */ - int pnum; /* index to pages (bufs) */ - unsigned long retval; - int error; - struct file *file; - ENTRY; - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - sb = conn->oc_dev->u.filter.fo_sb; - // if (rw == WRITE) - push_ctxt(&saved, &conn->oc_dev->u.filter.fo_ctxt); - pnum = 0; /* pnum indexes buf 0..num_pages */ - for (onum = 0; onum < num_oa; onum++) { - int pg; - - file = filter_obj_open(conn->oc_dev, oa[onum]->o_id, - oa[onum]->o_mode); - if (IS_ERR(file)) - GOTO(out, retval = PTR_ERR(file)); - - /* count doubles as retval */ - for (pg = 0; pg < oa_bufs[onum]; pg++) { - CDEBUG(D_INODE, "OP %d obdo no/pno: (%d,%d) (%ld,%ld) " - "off count (%Ld,%Ld)\n", - rw, onum, pnum, file->f_dentry->d_inode->i_ino, - (unsigned long)offset[pnum] >> PAGE_CACHE_SHIFT, - (unsigned long long)offset[pnum], - (unsigned long long)count[pnum]); - if (rw == WRITE) { - loff_t off; - char *buffer; - off = offset[pnum]; - buffer = kmap(pages[pnum]); - retval = file->f_op->write(file, buffer, count[pnum], &off); - kunmap(pages[pnum]); - CDEBUG(D_INODE, "retval %ld\n", retval); - } else { - loff_t off = offset[pnum]; - char *buffer = kmap(pages[pnum]); - - if (off >= file->f_dentry->d_inode->i_size) { - memset(buffer, 0, count[pnum]); - retval = count[pnum]; - } else { - retval = file->f_op->read(file, buffer, count[pnum], &off); - } - kunmap(pages[pnum]); - - if (retval != count[pnum]) { - filp_close(file, 0); - GOTO(out, retval = -EIO); - } - CDEBUG(D_INODE, "retval %ld\n", retval); - } - pnum++; - } - /* sizes and blocks are set by generic_file_write */ - /* ctimes/mtimes will follow with a setattr call */ - filp_close(file, 0); - } - - EXIT; -out: - // if (rw == WRITE) - pop_ctxt(&saved); - error = (retval >= 0) ? 0 : retval; - return error; -} - - -struct inode *ioobj_to_inode(struct obd_conn *conn, struct obd_ioobj *o) -{ - struct super_block *sb = conn->oc_dev->u.filter.fo_sb; - struct inode *inode = NULL; - ENTRY; - - if (!sb || !sb->s_dev) { - CDEBUG(D_SUPER, "fatal: device not initialized.\n"); - RETURN(NULL); - } - - if ( !o->ioo_id ) { - CDEBUG(D_INODE, "fatal: invalid obdo %lu\n", (long)o->ioo_id); - RETURN(NULL); - } - - inode = filter_inode_from_obj(conn->oc_dev, o->ioo_id, S_IFREG); - if (!inode || inode->i_nlink == 0 || is_bad_inode(inode)) { - CERROR("from obdo - fatal: invalid inode %ld (%s).\n", - (long)o->ioo_id, inode ? inode->i_nlink ? "bad inode" : - "no links" : "NULL"); - iput(inode); - RETURN(NULL); - } - - RETURN(inode); -} - -/* - * Calculate the number of buffer credits needed to write multiple pages in - * a single ext3/extN transaction. No, this shouldn't be here, but as yet - * ext3 doesn't have a nice API for calculating this sort of thing in advance. - * - * See comment above ext3_writepage_trans_blocks for details. We assume - * no data journaling is being done, but it does allow for all of the pages - * being non-contiguous. If we are guaranteed contiguous pages we could - * reduce the number of (d)indirect blocks a lot. - * - * With N blocks per page and P pages, for each inode we have at most: - * N*P indirect - * min(N*P, blocksize/4 + 1) dindirect blocks - * 1 tindirect - * - * For the entire filesystem, we have at most: - * min(sum(nindir + P), ngroups) bitmap blocks (from the above) - * min(sum(nindir + P), gdblocks) group descriptor blocks (from the above) - * 1 inode block - * 1 superblock - * 2 * EXT3_SINGLEDATA_TRANS_BLOCKS for the quota files - */ -static int ext3_credits_needed(struct super_block *sb, int objcount, - struct obd_ioobj *obj) -{ - struct obd_ioobj *o = obj; - int blockpp = 1 << (PAGE_CACHE_SHIFT - sb->s_blocksize_bits); - int addrpp = EXT3_ADDR_PER_BLOCK(sb) * blockpp; - int nbitmaps = 0; - int ngdblocks = 0; - int needed = objcount + 1; - int i; - - for (i = 0; i < objcount; i++, o++) { - int nblocks = o->ioo_bufcnt * blockpp; - int ndindirect = min(nblocks, addrpp + 1); - int nindir = nblocks + ndindirect + 1; - - nbitmaps += nindir + nblocks; - ngdblocks += nindir + nblocks; - - needed += nindir; - } - - if (nbitmaps > EXT3_SB(sb)->s_groups_count) - nbitmaps = EXT3_SB(sb)->s_groups_count; - if (ngdblocks > EXT3_SB(sb)->s_gdb_count) - ngdblocks = EXT3_SB(sb)->s_gdb_count; - - needed += nbitmaps + ngdblocks; - -#ifdef CONFIG_QUOTA - /* We assume that there will be 1 bit set in s_dquot.flags for each - * quota file that is active. This is at least true for now. - */ - needed += hweight32(sb_any_quota_enabled(sb)) * - EXT3_SINGLEDATA_TRANS_BLOCKS; -#endif - - return needed; -} - -/* We have to start a huge journal transaction here to hold all of the - * metadata for the pages being written here. This is necessitated by - * the fact that we do lots of prepare_write operations before we do - * any of the matching commit_write operations, so even if we split - * up to use "smaller" transactions none of them could complete until - * all of them were opened. By having a single journal transaction, - * we eliminate duplicate reservations for common blocks like the - * superblock and group descriptors or bitmaps. - * - * We will start the transaction here, but each prepare_write will - * add a refcount to the transaction, and each commit_write will - * remove a refcount. The transaction will be closed when all of - * the pages have been written. - */ -static void *ext3_filter_journal_start(struct filter_obd *filter, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_remote *nb) -{ - journal_t *journal = NULL; - handle_t *handle = NULL; - int needed; - - /* Assumes ext3 and extN have same sb_info layout, but avoids issues - * with having extN built properly before filterobd for now. - */ - journal = EXT3_SB(filter->fo_sb)->s_journal; - needed = ext3_credits_needed(filter->fo_sb, objcount, obj); - - /* The number of blocks we could _possibly_ dirty can very large. - * We reduce our request if it is absurd (and we couldn't get that - * many credits for a single handle anyways). - * - * At some point we have to limit the size of I/Os sent at one time, - * increase the size of the journal, or we have to calculate the - * actual journal requirements more carefully by checking all of - * the blocks instead of being maximally pessimistic. It remains to - * be seen if this is a real problem or not. - */ - if (needed > journal->j_max_transaction_buffers) { - CERROR("want too many journal credits (%d) using %d instead\n", - needed, journal->j_max_transaction_buffers); - needed = journal->j_max_transaction_buffers; - } - - handle = journal_start(journal, needed); - if (IS_ERR(handle)) - CERROR("can't get handle for %d credits: rc = %ld\n", needed, - PTR_ERR(handle)); - - return(handle); -} - -static void *filter_journal_start(void **journal_save, - struct filter_obd *filter, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_remote *nb) -{ - void *handle = NULL; - - /* This may not be necessary - we probably never have a - * transaction started when we enter here, so we can - * remove the saving of the journal state entirely. - * For now leave it in just to see if it ever happens. - */ - *journal_save = current->journal_info; - if (*journal_save) { - CERROR("Already have handle %p???\n", *journal_save); - LBUG(); - current->journal_info = NULL; - } - - if (!strcmp(filter->fo_fstype, "ext3") || - !strcmp(filter->fo_fstype, "extN")) - handle = ext3_filter_journal_start(filter, objcount, obj, - niocount, nb); - return handle; -} - -static int ext3_filter_journal_stop(void *handle) -{ - int rc; - - /* We got a refcount on the handle for each call to prepare_write, - * so we can drop the "parent" handle here to avoid the need for - * osc to call back into filterobd to close the handle. The - * remaining references will be dropped in commit_write. - */ - rc = journal_stop((handle_t *)handle); - - return rc; -} - -static int filter_journal_stop(void *journal_save, struct filter_obd *filter, - void *handle) -{ - int rc = 0; - - if (!strcmp(filter->fo_fstype, "ext3") || - !strcmp(filter->fo_fstype, "extN")) - rc = ext3_filter_journal_stop(handle); - - current->journal_info = journal_save; - - return rc; -} - -struct page *filter_get_page_write(struct inode *inode, unsigned long index, - struct niobuf_local *lnb) -{ - struct address_space *mapping = inode->i_mapping; - struct page *page; - int rc; - - //ASSERT_PAGE_INDEX(index, GOTO(err, rc = -EINVAL)); - page = grab_cache_page_nowait(mapping, index); /* locked page */ - - /* This page is currently locked, so we grab a new one temporarily */ - if (!page) { - unsigned long addr; - addr = __get_free_pages(GFP_KERNEL, 0); - if (!addr) { - CERROR("no memory for a temp page\n"); - LBUG(); - GOTO(err, rc = -ENOMEM); - } - page = virt_to_page(addr); - kmap(page); - page->index = index; - lnb->flags |= N_LOCAL_TEMP_PAGE; - } else if (!IS_ERR(page)) { - /* Note: Called with "O" and "PAGE_SIZE" this is essentially - * a no-op for most filesystems, because we write the whole - * page. For partial-page I/O this will read in the page. - */ - rc = mapping->a_ops->prepare_write(NULL, page, 0, PAGE_SIZE); - if (rc) { - CERROR("page index %lu, rc = %d\n", index, rc); - if (rc != -ENOSPC) - LBUG(); - GOTO(err_unlock, rc); - } - /* XXX not sure if we need this if we are overwriting page */ - if (PageError(page)) { - CERROR("error on page index %lu, rc = %d\n", index, rc); - LBUG(); - GOTO(err_unlock, rc = -EIO); - } - - kmap(page); - } - return page; - -err_unlock: - unlock_page(page); - lustre_put_page(page); -err: - return ERR_PTR(rc); -} - -static int filter_preprw(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_remote *nb, - struct niobuf_local *res, void **desc_private) -{ - struct obd_run_ctxt saved; - struct obd_device *obddev; - struct obd_ioobj *o = obj; - struct niobuf_remote *b = nb; - struct niobuf_local *r = res; - void *journal_save = NULL; - int rc = 0; - int i; - ENTRY; - - memset(res, 0, sizeof(*res) * niocount); - obddev = conn->oc_dev; - - push_ctxt(&saved, &obddev->u.filter.fo_ctxt); - - if (cmd == OBD_BRW_WRITE) { - *desc_private = filter_journal_start(&journal_save, - &obddev->u.filter, - objcount, obj, niocount, - nb); - if (IS_ERR(*desc_private)) - GOTO(out_ctxt, rc = PTR_ERR(*desc_private)); - } - - for (i = 0; i < objcount; i++, o++) { - struct dentry *dentry; - struct inode *inode; - int j; - - dentry = filter_fid2dentry(obddev, - filter_parent(obddev, S_IFREG), - o->ioo_id, S_IFREG); - inode = dentry->d_inode; - - for (j = 0; j < o->ioo_bufcnt; j++, b++, r++) { - unsigned long index = b->offset >> PAGE_SHIFT; - struct page *page; - - /* XXX We _might_ change this to a dcount if we - * wanted to pass a dentry pointer in the niobuf - * to avoid doing so many igets on an inode we - * already have. It appears to be solely for the - * purpose of having a refcount that we can drop - * in commitrw where we get one call per page. - */ - if (j > 0) - r->dentry = dget(dentry); - else - r->dentry = dentry; - - /* FIXME: we need to iput all inodes on error */ - if (!inode) - RETURN(-EINVAL); - - if (cmd == OBD_BRW_WRITE) { - page = filter_get_page_write(inode, index, r); - - /* We unlock the page to avoid deadlocks with - * the page I/O because we are preparing - * multiple pages at one time and we have lock - * ordering problems. Lustre I/O and disk I/O - * on this page can happen concurrently. - */ - } else - page = lustre_get_page_read(inode, index); - - /* FIXME: we need to clean up here... */ - if (IS_ERR(page)) - RETURN(PTR_ERR(page)); - - r->addr = page_address(page); - r->offset = b->offset; - r->page = page; - r->len = PAGE_SIZE; - } - } - - if (cmd == OBD_BRW_WRITE) { - /* FIXME: need to clean up here */ - rc = filter_journal_stop(journal_save, &obddev->u.filter, - *desc_private); - } -out_ctxt: - pop_ctxt(&saved); - RETURN(rc); -} - -static int filter_write_locked_page(struct niobuf_local *lnb) -{ - struct page *lpage; - int rc; - - lpage = lustre_get_page_write(lnb->dentry->d_inode, lnb->page->index); - /* XXX */ - - memcpy(page_address(lpage), kmap(lnb->page), PAGE_SIZE); - kunmap(lnb->page); - __free_pages(lnb->page, 0); - - rc = lustre_commit_page(lpage, 0, PAGE_SIZE); - dput(lnb->dentry); - - return rc; -} - -static int filter_commitrw(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf_local *res, - void *private) -{ - struct obd_run_ctxt saved; - struct obd_ioobj *o = obj; - struct niobuf_local *r = res; - void *journal_save; - int found_locked = 0; - int i; - ENTRY; - - // if (cmd == OBD_BRW_WRITE) - push_ctxt(&saved, &conn->oc_dev->u.filter.fo_ctxt); - journal_save = current->journal_info; - if (journal_save) - CERROR("Existing handle %p???\n", journal_save); - current->journal_info = private; - for (i = 0; i < objcount; i++, obj++) { - int j; - for (j = 0 ; j < o->ioo_bufcnt ; j++, r++) { - struct page *page = r->page; - - /* If there was an error setting up a particular page - * for I/O we still need to continue with the rest of - * the pages in order to balance prepate/commit_write - * calls, and to complete as much I/O as possible. - */ - if (!page) - LBUG(); - - if (r->flags & N_LOCAL_TEMP_PAGE) { - found_locked = 1; - continue; - } - - if (cmd == OBD_BRW_WRITE) { - int rc; - rc = lustre_commit_page(page, 0, PAGE_SIZE); - - /* FIXME: still need to iput the other inodes */ - if (rc) - RETURN(rc); - } else - lustre_put_page(page); - - CDEBUG(D_INODE, - "put inode %p (%ld), count = %d, nlink = %d\n", - page->mapping->host, - page->mapping->host->i_ino, - atomic_read(&page->mapping->host->i_count) - 1, - page->mapping->host->i_nlink); - dput(r->dentry); - } - } - if (!found_locked) - goto out; - - for (i = 0; i < objcount; i++, obj++) { - int j; - for (j = 0 ; j < o->ioo_bufcnt ; j++, r++) { - int rc; - if (!(r->flags & N_LOCAL_TEMP_PAGE)) - continue; - - rc = filter_write_locked_page(r); - /* XXX */ - } - } - -out: - current->journal_info = journal_save; - pop_ctxt(&saved); - RETURN(0); -} - -static int filter_statfs(struct obd_conn *conn, struct statfs * statfs) -{ - struct super_block *sb; - int err; - ENTRY; - - if (!gen_client(conn)) { - CDEBUG(D_IOCTL, "invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - sb = conn->oc_dev->u.filter.fo_sb; - - err = sb->s_op->statfs(sb, statfs); - RETURN(err); -} /* filter_statfs */ - - -static int filter_get_info(struct obd_conn *conn, obd_count keylen, - void *key, obd_count *vallen, void **val) -{ - struct obd_device *obddev; - struct obd_client * cli; - ENTRY; - - if (!(cli = gen_client(conn))) { - CDEBUG(D_IOCTL, "invalid client %u\n", conn->oc_id); - RETURN(-EINVAL); - } - - obddev = conn->oc_dev; - - if ( keylen == strlen("blocksize") && - memcmp(key, "blocksize", keylen) == 0 ) { - *vallen = sizeof(long); - *val = (void *)(long)obddev->u.filter.fo_sb->s_blocksize; - RETURN(0); - } - - if ( keylen == strlen("blocksize_bits") && - memcmp(key, "blocksize_bits", keylen) == 0 ){ - *vallen = sizeof(long); - *val = (void *)(long)obddev->u.filter.fo_sb->s_blocksize_bits; - RETURN(0); - } - - if ( keylen == strlen("root_ino") && - memcmp(key, "root_ino", keylen) == 0 ){ - *vallen = sizeof(long); - *val = (void *)(long)FILTER_ROOTINO; - RETURN(0); - } - - CDEBUG(D_IOCTL, "invalid key\n"); - RETURN(-EINVAL); -} - - -static struct obd_ops filter_obd_ops = { - o_get_info: filter_get_info, - o_setup: filter_setup, - o_cleanup: filter_cleanup, - o_connect: filter_connect, - o_disconnect: filter_disconnect, - o_statfs: filter_statfs, - o_getattr: filter_getattr, - o_create: filter_create, - o_setattr: filter_setattr, - o_destroy: filter_destroy, - o_open: filter_open, - o_close: filter_close, - o_read: filter_read, - o_write: filter_write, - o_brw: filter_pgcache_brw, - o_punch: filter_truncate, - o_preprw: filter_preprw, - o_commitrw: filter_commitrw -#if 0 - o_preallocate: filter_preallocate_inodes, - o_migrate: filter_migrate, - o_copy: gen_copy_data, - o_iterate: filter_iterate -#endif -}; - - -static int __init obdfilter_init(void) -{ - printk(KERN_INFO "Filtering OBD driver v0.001, braam@clusterfs.com\n"); - return obd_register_type(&filter_obd_ops, OBD_FILTER_DEVICENAME); -} - -static void __exit obdfilter_exit(void) -{ - obd_unregister_type(OBD_FILTER_DEVICENAME); -} - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Lustre Filtering OBD driver v1.0"); -MODULE_LICENSE("GPL"); - -module_init(obdfilter_init); -module_exit(obdfilter_exit); diff --git a/lustre/obdfs/.cvsignore b/lustre/obdfs/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/obdfs/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/obdfs/Makefile.am b/lustre/obdfs/Makefile.am deleted file mode 100644 index 8470dc1..0000000 --- a/lustre/obdfs/Makefile.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 - -DEFS= - -MODULE = obdfs -modulefs_DATA = obdfs.o -EXTRA_PROGRAMS = obdfs -obdfs_SOURCES = rw.c file.c dir.c sysctl.c super.c namei.c symlink.c - -include $(top_srcdir)/Rules diff --git a/lustre/obdfs/README b/lustre/obdfs/README deleted file mode 100644 index 12eb4d6..0000000 --- a/lustre/obdfs/README +++ /dev/null @@ -1,22 +0,0 @@ -OBDFS - v 0.001 - -This version can mount, list and set the attributes of the root -directory. - -1. configure the obd to use /dev/obd with a scratch file system - -2. make - -3. insmod obdfs - -4. mount -t obdfs -o device=/dev/obd0 /dev/obd0 /mnt/obd - -To verify: type mount (output: -/dev/obd on /mnt/obd type obdfs (rw)) - -5. ls -ld /mnt/obd - -6. chmod 711 /mnt/obd, ls -ld /mnt/obd - -7. chown disk /mnt/obd, ls -ld /mnt/obd - diff --git a/lustre/obdfs/dir.c b/lustre/obdfs/dir.c deleted file mode 100644 index f0a542d..0000000 --- a/lustre/obdfs/dir.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * linux/fs/ext2/dir.c - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/fs/minix/dir.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * ext2 directory handling functions - * - * Big-endian to little-endian byte-swapping/bitmaps by - * David S. Miller (davem@caip.rutgers.edu), 1995 - * - * All code that works with directory layout had been switched to pagecache - * and moved here. AV - */ - -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_OBDFS - -#include -#include - -typedef struct ext2_dir_entry_2 ext2_dirent; - -#define PageChecked(page) test_bit(PG_checked, &(page)->flags) -#define SetPageChecked(page) set_bit(PG_checked, &(page)->flags) - -int waitfor_one_page(struct page *page) -{ - int error = 0; - struct buffer_head *bh, *head = page->buffers; - - bh = head; - do { - wait_on_buffer(bh); - if (buffer_req(bh) && !buffer_uptodate(bh)) - error = -EIO; - } while ((bh = bh->b_this_page) != head); - return error; -} - -/* - * ext2 uses block-sized chunks. Arguably, sector-sized ones would be - * more robust, but we have what we have - */ -static inline unsigned ext2_chunk_size(struct inode *inode) -{ - //return inode->i_sb->s_blocksize; - return PAGE_SIZE; -} - -static inline void ext2_put_page(struct page *page) -{ - kunmap(page); - page_cache_release(page); -} - -static inline unsigned long dir_pages(struct inode *inode) -{ - return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; -} - -static int ext2_commit_chunk(struct page *page, unsigned from, unsigned to) -{ - struct inode *dir = page->mapping->host; - int err = 0; - dir->i_version = ++event; - page->mapping->a_ops->commit_write(NULL, page, from, to); - if (IS_SYNC(dir)) - err = waitfor_one_page(page); - return err; -} - -static void ext2_check_page(struct page *page) -{ - struct inode *dir = page->mapping->host; - unsigned chunk_size = ext2_chunk_size(dir); - char *kaddr = page_address(page); - // u32 max_inumber = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count); - unsigned offs, rec_len; - unsigned limit = PAGE_CACHE_SIZE; - ext2_dirent *p; - char *error; - - if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) { - limit = dir->i_size & ~PAGE_CACHE_MASK; - if (limit & (chunk_size - 1)) - goto Ebadsize; - for (offs = limit; offsrec_len = cpu_to_le16(chunk_size); - } - if (!limit) - goto out; - } - for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) { - p = (ext2_dirent *)(kaddr + offs); - rec_len = le16_to_cpu(p->rec_len); - - if (rec_len < EXT2_DIR_REC_LEN(1)) - goto Eshort; - if (rec_len & 3) - goto Ealign; - if (rec_len < EXT2_DIR_REC_LEN(p->name_len)) - goto Enamelen; - if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1)) - goto Espan; - // if (le32_to_cpu(p->inode) > max_inumber) - //goto Einumber; - } - if (offs != limit) - goto Eend; -out: - SetPageChecked(page); - return; - - /* Too bad, we had an error */ - -Ebadsize: - CERROR("ext2_check_page" - "size of directory #%lu is not a multiple of chunk size", - dir->i_ino - ); - goto fail; -Eshort: - error = "rec_len is smaller than minimal"; - goto bad_entry; -Ealign: - error = "unaligned directory entry"; - goto bad_entry; -Enamelen: - error = "rec_len is too small for name_len"; - goto bad_entry; -Espan: - error = "directory entry across blocks"; - goto bad_entry; - //Einumber: - // error = "inode out of bounds"; -bad_entry: - CERROR("ext2_check_page" "bad entry in directory #%lu: %s - " - "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", - dir->i_ino, error, (page->index<inode), - rec_len, p->name_len); - goto fail; -Eend: - p = (ext2_dirent *)(kaddr + offs); - CERROR("ext2_check_page" - "entry in directory #%lu spans the page boundary" - "offset=%lu, inode=%lu", - dir->i_ino, (page->index<inode)); -fail: - SetPageChecked(page); - SetPageError(page); -} - -static struct page * ext2_get_page(struct inode *dir, unsigned long n) -{ - struct address_space *mapping = dir->i_mapping; - struct page *page = read_cache_page(mapping, n, - (filler_t*)mapping->a_ops->readpage, NULL); - if (!IS_ERR(page)) { - wait_on_page(page); - kmap(page); - if (!Page_Uptodate(page)) - goto fail; - if (!PageChecked(page)) - ext2_check_page(page); - if (PageError(page)) - goto fail; - } - return page; - -fail: - ext2_put_page(page); - return ERR_PTR(-EIO); -} - -/* - * NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure. - * - * len <= EXT2_NAME_LEN and de != NULL are guaranteed by caller. - */ -static inline int ext2_match (int len, const char * const name, - struct ext2_dir_entry_2 * de) -{ - if (len != de->name_len) - return 0; - if (!de->inode) - return 0; - return !memcmp(name, de->name, len); -} - -/* - * p is at least 6 bytes before the end of page - */ -static inline ext2_dirent *ext2_next_entry(ext2_dirent *p) -{ - return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len)); -} - -static inline unsigned -ext2_validate_entry(char *base, unsigned offset, unsigned mask) -{ - ext2_dirent *de = (ext2_dirent*)(base + offset); - ext2_dirent *p = (ext2_dirent*)(base + (offset&mask)); - while ((char*)p < (char*)de) - p = ext2_next_entry(p); - return (char *)p - base; -} - -static unsigned char ext2_filetype_table[EXT2_FT_MAX] = { - [EXT2_FT_UNKNOWN] DT_UNKNOWN, - [EXT2_FT_REG_FILE] DT_REG, - [EXT2_FT_DIR] DT_DIR, - [EXT2_FT_CHRDEV] DT_CHR, - [EXT2_FT_BLKDEV] DT_BLK, - [EXT2_FT_FIFO] DT_FIFO, - [EXT2_FT_SOCK] DT_SOCK, - [EXT2_FT_SYMLINK] DT_LNK, -}; - -static unsigned int obdfs_dt2fmt[DT_WHT + 1] = { - [EXT2_FT_UNKNOWN] 0, - [EXT2_FT_REG_FILE] S_IFREG, - [EXT2_FT_DIR] S_IFDIR, - [EXT2_FT_CHRDEV] S_IFCHR, - [EXT2_FT_BLKDEV] S_IFBLK, - [EXT2_FT_FIFO] S_IFIFO, - [EXT2_FT_SOCK] S_IFSOCK, - [EXT2_FT_SYMLINK] S_IFLNK -}; - -#define S_SHIFT 12 -static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = { - [S_IFREG >> S_SHIFT] EXT2_FT_REG_FILE, - [S_IFDIR >> S_SHIFT] EXT2_FT_DIR, - [S_IFCHR >> S_SHIFT] EXT2_FT_CHRDEV, - [S_IFBLK >> S_SHIFT] EXT2_FT_BLKDEV, - [S_IFIFO >> S_SHIFT] EXT2_FT_FIFO, - [S_IFSOCK >> S_SHIFT] EXT2_FT_SOCK, - [S_IFLNK >> S_SHIFT] EXT2_FT_SYMLINK, -}; - -static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode) -{ - mode_t mode = inode->i_mode; - de->file_type = ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; -} - -int -new_obdfs_readdir (struct file * filp, void * dirent, filldir_t filldir) -{ - loff_t pos = filp->f_pos; - struct inode *inode = filp->f_dentry->d_inode; - // XXX struct super_block *sb = inode->i_sb; - unsigned offset = pos & ~PAGE_CACHE_MASK; - unsigned long n = pos >> PAGE_CACHE_SHIFT; - unsigned long npages = dir_pages(inode); - unsigned chunk_mask = ~(ext2_chunk_size(inode)-1); - unsigned char *types = NULL; - int need_revalidate = (filp->f_version != inode->i_version); - - if (pos > inode->i_size - EXT2_DIR_REC_LEN(1)) - goto done; - - types = ext2_filetype_table; - - for ( ; n < npages; n++, offset = 0) { - char *kaddr, *limit; - ext2_dirent *de; - struct page *page = ext2_get_page(inode, n); - - if (IS_ERR(page)) - continue; - kaddr = page_address(page); - if (need_revalidate) { - offset = ext2_validate_entry(kaddr, offset, chunk_mask); - need_revalidate = 0; - } - de = (ext2_dirent *)(kaddr+offset); - limit = kaddr + PAGE_CACHE_SIZE - EXT2_DIR_REC_LEN(1); - for ( ;(char*)de <= limit; de = ext2_next_entry(de)) - if (de->inode) { - int over; - unsigned char d_type = DT_UNKNOWN; - - if (types && de->file_type < EXT2_FT_MAX) - d_type = types[de->file_type]; - - offset = (char *)de - kaddr; - over = filldir(dirent, de->name, de->name_len, - (n<inode), d_type); - if (over) { - ext2_put_page(page); - goto done; - } - } - ext2_put_page(page); - } - -done: - filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset; - filp->f_version = inode->i_version; - UPDATE_ATIME(inode); - return 0; -} - -/* - * ext2_find_entry() - * - * finds an entry in the specified directory with the wanted name. It - * returns the page in which the entry was found, and the entry itself - * (as a parameter - res_dir). Page is returned mapped and unlocked. - * Entry is guaranteed to be valid. - */ -struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir, - struct dentry *dentry, struct page ** res_page) -{ - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - unsigned reclen = EXT2_DIR_REC_LEN(namelen); - unsigned long start, n; - unsigned long npages = dir_pages(dir); - struct page *page = NULL; - ext2_dirent * de; - - /* OFFSET_CACHE */ - *res_page = NULL; - - // start = dir->u.ext2_i.i_dir_start_lookup; - start = 0; - if (start >= npages) - start = 0; - n = start; - do { - char *kaddr; - page = ext2_get_page(dir, n); - if (!IS_ERR(page)) { - kaddr = page_address(page); - de = (ext2_dirent *) kaddr; - kaddr += PAGE_CACHE_SIZE - reclen; - while ((char *) de <= kaddr) { - if (ext2_match (namelen, name, de)) - goto found; - de = ext2_next_entry(de); - } - ext2_put_page(page); - } - if (++n >= npages) - n = 0; - } while (n != start); - return NULL; - -found: - *res_page = page; - // dir->u.ext2_i.i_dir_start_lookup = n; - return de; -} - -struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p) -{ - struct page *page = ext2_get_page(dir, 0); - ext2_dirent *de = NULL; - - if (!IS_ERR(page)) { - de = ext2_next_entry((ext2_dirent *) page_address(page)); - *p = page; - } - return de; -} - -ino_t obdfs_inode_by_name(struct inode * dir, struct dentry *dentry, int *type) -{ - ino_t res = 0; - struct ext2_dir_entry_2 * de; - struct page *page; - - de = ext2_find_entry (dir, dentry, &page); - if (de) { - res = le32_to_cpu(de->inode); - *type = obdfs_dt2fmt[de->file_type]; - kunmap(page); - page_cache_release(page); - } - return res; -} - -/* Releases the page */ -void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, - struct page *page, struct inode *inode) -{ - unsigned from = (char *) de - (char *) page_address(page); - unsigned to = from + le16_to_cpu(de->rec_len); - int err; - - lock_page(page); - err = page->mapping->a_ops->prepare_write(NULL, page, from, to); - if (err) - LBUG(); - de->inode = cpu_to_le32(inode->i_ino); - ext2_set_de_type (de, inode); - dir->i_mtime = dir->i_ctime = CURRENT_TIME; - err = ext2_commit_chunk(page, from, to); - UnlockPage(page); - ext2_put_page(page); -} - -/* - * Parent is locked. - */ -int ext2_add_link (struct dentry *dentry, struct inode *inode) -{ - struct inode *dir = dentry->d_parent->d_inode; - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - unsigned reclen = EXT2_DIR_REC_LEN(namelen); - unsigned short rec_len, name_len; - struct page *page = NULL; - ext2_dirent * de; - unsigned long npages = dir_pages(dir); - unsigned long n; - char *kaddr; - unsigned from, to; - int err; - - /* We take care of directory expansion in the same loop */ - for (n = 0; n <= npages; n++) { - page = ext2_get_page(dir, n); - err = PTR_ERR(page); - if (IS_ERR(page)) - goto out; - kaddr = page_address(page); - de = (ext2_dirent *)kaddr; - kaddr += PAGE_CACHE_SIZE - reclen; - while ((char *)de <= kaddr) { - err = -EEXIST; - if (ext2_match (namelen, name, de)) - goto out_page; - name_len = EXT2_DIR_REC_LEN(de->name_len); - rec_len = le16_to_cpu(de->rec_len); - if ( n==npages && rec_len == 0) { - CERROR("Fatal dir behaviour\n"); - goto out_page; - } - if (!de->inode && rec_len >= reclen) - goto got_it; - if (rec_len >= name_len + reclen) - goto got_it; - de = (ext2_dirent *) ((char *) de + rec_len); - } - ext2_put_page(page); - } - LBUG(); - return -EINVAL; - -got_it: - from = (char*)de - (char*)page_address(page); - to = from + rec_len; - lock_page(page); - err = page->mapping->a_ops->prepare_write(NULL, page, from, to); - if (err) - goto out_unlock; - if (de->inode) { - ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len); - de1->rec_len = cpu_to_le16(rec_len - name_len); - de->rec_len = cpu_to_le16(name_len); - de = de1; - } - de->name_len = namelen; - memcpy (de->name, name, namelen); - de->inode = cpu_to_le32(inode->i_ino); - ext2_set_de_type (de, inode); - CDEBUG(D_INODE, "type set to %o\n", de->file_type); - dir->i_mtime = dir->i_ctime = CURRENT_TIME; - err = ext2_commit_chunk(page, from, to); - - // change_inode happens with the commit_chunk - // obdfs_change_inode(dir); - /* OFFSET_CACHE */ -out_unlock: - UnlockPage(page); -out_page: - ext2_put_page(page); -out: - return err; -} - -/* - * ext2_delete_entry deletes a directory entry by merging it with the - * previous entry. Page is up-to-date. Releases the page. - */ -int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) -{ - struct address_space *mapping = page->mapping; - struct inode *inode = mapping->host; - char *kaddr = page_address(page); - unsigned from = ((char*)dir - kaddr) & ~(ext2_chunk_size(inode)-1); - unsigned to = ((char*)dir - kaddr) + le16_to_cpu(dir->rec_len); - ext2_dirent * pde = NULL; - ext2_dirent * de = (ext2_dirent *) (kaddr + from); - int err; - - while ((char*)de < (char*)dir) { - pde = de; - de = ext2_next_entry(de); - } - if (pde) - from = (char*)pde - (char*)page_address(page); - lock_page(page); - err = mapping->a_ops->prepare_write(NULL, page, from, to); - if (err) - LBUG(); - if (pde) - pde->rec_len = cpu_to_le16(to-from); - dir->inode = 0; - inode->i_ctime = inode->i_mtime = CURRENT_TIME; - err = ext2_commit_chunk(page, from, to); - UnlockPage(page); - ext2_put_page(page); - return err; -} - -/* - * Set the first fragment of directory. - */ -int ext2_make_empty(struct inode *inode, struct inode *parent) -{ - struct address_space *mapping = inode->i_mapping; - struct page *page = grab_cache_page(mapping, 0); - unsigned chunk_size = ext2_chunk_size(inode); - struct ext2_dir_entry_2 * de; - char *base; - int err; - ENTRY; - - if (!page) - return -ENOMEM; - err = mapping->a_ops->prepare_write(NULL, page, 0, chunk_size); - if (err) - goto fail; - - base = page_address(page); - - de = (struct ext2_dir_entry_2 *) base; - de->name_len = 1; - de->rec_len = cpu_to_le16(EXT2_DIR_REC_LEN(1)); - memcpy (de->name, ".\0\0", 4); - de->inode = cpu_to_le32(inode->i_ino); - ext2_set_de_type (de, inode); - - de = (struct ext2_dir_entry_2 *) (base + EXT2_DIR_REC_LEN(1)); - de->name_len = 2; - de->rec_len = cpu_to_le16(chunk_size - EXT2_DIR_REC_LEN(1)); - de->inode = cpu_to_le32(parent->i_ino); - memcpy (de->name, "..\0", 4); - ext2_set_de_type (de, inode); - - err = ext2_commit_chunk(page, 0, chunk_size); -fail: - UnlockPage(page); - page_cache_release(page); - ENTRY; - return err; -} - -/* - * routine to check that the specified directory is empty (for rmdir) - */ -int ext2_empty_dir (struct inode * inode) -{ - struct page *page = NULL; - unsigned long i, npages = dir_pages(inode); - - for (i = 0; i < npages; i++) { - char *kaddr; - ext2_dirent * de; - page = ext2_get_page(inode, i); - - if (IS_ERR(page)) - continue; - - kaddr = page_address(page); - de = (ext2_dirent *)kaddr; - kaddr += PAGE_CACHE_SIZE-EXT2_DIR_REC_LEN(1); - - while ((char *)de <= kaddr) { - if (de->inode != 0) { - /* check for . and .. */ - if (de->name[0] != '.') - goto not_empty; - if (de->name_len > 2) - goto not_empty; - if (de->name_len < 2) { - if (de->inode != - cpu_to_le32(inode->i_ino)) - goto not_empty; - } else if (de->name[1] != '.') - goto not_empty; - } - de = ext2_next_entry(de); - } - ext2_put_page(page); - } - return 1; - -not_empty: - ext2_put_page(page); - return 0; -} - -struct file_operations obdfs_dir_operations = { - read: generic_read_dir, - readdir: new_obdfs_readdir -}; diff --git a/lustre/obdfs/file.c b/lustre/obdfs/file.c deleted file mode 100644 index 45493d2..0000000 --- a/lustre/obdfs/file.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * linux/fs/ext2/file.c - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/fs/minix/file.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * ext2 fs regular file handling primitives - * - * 64-bit file support on 64-bit platforms by Jakub Jelinek - * (jj@sunsite.ms.mff.cuni.cz) - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_OBDFS - -#include -#include - -extern int obdfs_setattr(struct dentry *de, struct iattr *attr); -void obdfs_change_inode(struct inode *inode); - -static inline void obdfs_remove_suid(struct inode *inode) -{ - unsigned int mode; - - /* set S_IGID if S_IXGRP is set, and always set S_ISUID */ - mode = (inode->i_mode & S_IXGRP)*(S_ISGID/S_IXGRP) | S_ISUID; - - /* was any of the uid bits set? */ - mode &= inode->i_mode; - if (mode && !capable(CAP_FSETID)) { - inode->i_mode &= ~mode; - // XXX careful here - we cannot change the size - //obdfs_change_inode(inode); - } -} - -/* - * Write to a file (through the page cache). - */ -static ssize_t -obdfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos) -{ - ssize_t retval; - CDEBUG(D_INFO, "Writing inode %ld, %ld bytes, offset %Ld\n", - file->f_dentry->d_inode->i_ino, (long)count, *ppos); - - retval = generic_file_write(file, buf, count, ppos); - CDEBUG(D_INFO, "Wrote %ld\n", (long)retval); - - /* update mtime/ctime/atime here, NOT size */ - if (retval > 0) { - struct iattr attr; - attr.ia_valid = ATTR_MTIME | ATTR_CTIME | ATTR_ATIME; - attr.ia_mtime = attr.ia_ctime = attr.ia_atime = - CURRENT_TIME; - obdfs_setattr(file->f_dentry, &attr); - } - EXIT; - return retval; -} - - -/* XXX this does not need to do anything for data, it _does_ need to - call setattr */ -int obdfs_fsync(struct file *file, struct dentry *dentry, int data) -{ - return 0; -} - -struct file_operations obdfs_file_operations = { - read: generic_file_read, - write: obdfs_file_write, - mmap: generic_file_mmap, - fsync: NULL -}; - - -struct inode_operations obdfs_file_inode_operations = { - truncate: obdfs_truncate, - setattr: obdfs_setattr -}; - diff --git a/lustre/obdfs/flushd.c b/lustre/obdfs/flushd.c deleted file mode 100644 index 9ba45ee..0000000 --- a/lustre/obdfs/flushd.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * OBDFS Super operations - also used for Lustre file system - * - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1991, 1992 Linus Torvalds - * Copryright (C) 1999 Stelias Computing Inc. - * Copryright (C) 1999 Seagate Technology Inc. - * - */ -#define __NO_VERSION__ -#include -#include -#include - -#include -#include -#include - - -/* XXX temporary until the real function is available from kernel - * XXX set this to memory size in pages for max page cache size - */ -#define nr_free_buffer_pages() 32768 - -/* Defines for page buf daemon */ -struct pupd_prm { - int nfract; /* Percentage of buffer cache dirty to - activate bdflush */ - int ndirty; /* Maximum number of dirty blocks to write out per - wake-cycle */ - int nrefill; /* Number of clean buffers to try to obtain - each time we call refill */ - int nref_dirt; /* Dirty buffer threshold for activating bdflush - when trying to refill buffers. */ - int interval; /* jiffies delay between pupdate flushes */ - int age_buffer; /* Time for normal buffer to age before we flush it */ - int age_super; /* Time for superblock to age before we flush it */ -}; - - -static struct pupdated { - int active; - wait_queue_head_t waitq; - struct timer_list timer; - struct pupd_prm parms; -} pupdated = { - active: -1, - parms: {40, 1024, 64, 256, 1*HZ, 30*HZ, 5*HZ } -}; - - -/* Called with the superblock list lock held */ -static int obdfs_enqueue_pages(struct inode *inode, struct obdo **obdo, - int nr_slots, struct page **pages, char **bufs, - obd_size *counts, obd_off *offsets, - obd_flag *flag, unsigned long check_time) -{ - struct list_head *page_list = obdfs_iplist(inode); - struct list_head *tmp; - int num = 0; - - ENTRY; - - tmp = page_list; - /* Traverse list in reverse order, so we do FIFO, not LIFO order */ - while ( (tmp = tmp->prev) != page_list && num < nr_slots ) { - struct obdfs_pgrq *req; - struct page *page; - - req = list_entry(tmp, struct obdfs_pgrq, rq_plist); - page = req->rq_page; - - - if (req->rq_jiffies > check_time) - break; /* pages are in chronological order */ - - /* Only allocate the obdo if we will actually do I/O here */ - if ( !*obdo ) { - OIDEBUG(inode); - *obdo = obdo_fromid(IID(inode), inode->i_ino, - OBD_MD_FLNOTOBD); - if ( IS_ERR(*obdo) ) { - int err = PTR_ERR(*obdo); - *obdo = NULL; - - EXIT; - return err; - } - - /* FIXME revisit fromid & from_inode */ - obdfs_from_inode(*obdo, inode); - *flag = OBD_BRW_CREATE; - } - - /* Remove request from list before write to avoid conflict. - * Note that obdfs_pgrq_del() also deletes the request. - */ - obdfs_pgrq_del(req); - if ( !page ) { - CDEBUG(D_CACHE, "no page \n"); - continue; - } - - bufs[num] = (char *)page_address(page); - pages[num] = page; - counts[num] = PAGE_SIZE; - offsets[num] = ((obd_off)page->index) << PAGE_SHIFT; - CDEBUG(D_INFO, "ENQ inode %ld, page %p addr %p to vector\n", - inode->i_ino, page, (char *)page_address(page)); - num++; - } - - if (!list_empty(page_list)) - CDEBUG(D_INFO, "inode %ld list not empty\n", inode->i_ino); - CDEBUG(D_INFO, "added %d page(s) to vector\n", num); - - EXIT; - return num; -} /* obdfs_enqueue_pages */ - -/* Dequeue cached pages for a dying inode without writing them to disk. */ -void obdfs_dequeue_pages(struct inode *inode) -{ - struct list_head *tmp; - - ENTRY; - obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); - tmp = obdfs_islist(inode); - if ( list_empty(tmp) ) { - CDEBUG(D_INFO, "no dirty pages for inode %ld\n", inode->i_ino); - obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); - EXIT; - return; - } - - /* take it out of the super list */ - list_del(tmp); - INIT_LIST_HEAD(obdfs_islist(inode)); - - tmp = obdfs_iplist(inode); - while ( (tmp = tmp->prev) != obdfs_iplist(inode) ) { - struct obdfs_pgrq *req; - struct page *page; - - req = list_entry(tmp, struct obdfs_pgrq, rq_plist); - page = req->rq_page; - /* take it out of the list and free */ - obdfs_pgrq_del(req); - /* now put the page away */ - put_page(page); - } - - obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); - - /* decrement inode reference for page cache */ - atomic_dec(&inode->i_count); - EXIT; -} - -/* This value is not arbitrarily chosen. KIO_STATIC_PAGES from linux/iobuf.h */ -#define MAX_IOVEC (KIO_STATIC_PAGES - 1) - -/* Remove writeback requests for the superblock */ -int obdfs_flush_reqs(struct list_head *inode_list, unsigned long check_time) -{ - struct list_head *tmp; - unsigned long max_io, total_io = 0; - obd_count num_io; - obd_count num_obdos; - struct inode *inodes[MAX_IOVEC]; /* write data back to these */ - struct page *pages[MAX_IOVEC]; /* call put_page on these */ - struct obdo *obdos[MAX_IOVEC]; - char *bufs[MAX_IOVEC]; - obd_size counts[MAX_IOVEC]; - obd_off offsets[MAX_IOVEC]; - obd_flag flags[MAX_IOVEC]; - obd_count bufs_per_obdo[MAX_IOVEC]; - int err = 0; - struct obdfs_sb_info *sbi; - - ENTRY; - if (!inode_list) { - CDEBUG(D_INODE, "no list\n"); - EXIT; - return 0; - } - - sbi = list_entry(inode_list, struct obdfs_sb_info, osi_inodes); - - obd_down(&sbi->osi_list_mutex); - if ( list_empty(inode_list) ) { - CDEBUG(D_INFO, "list empty\n"); - obd_up(&sbi->osi_list_mutex); - EXIT; - return 0; - } - - /* If we are forcing a write, write out all dirty pages */ - max_io = check_time == ~0UL ? 1<<31 : pupdated.parms.ndirty; - CDEBUG(D_INFO, "max_io = %lu\n", max_io); - - /* Add each inode's dirty pages to a write vector, and write it. - * Traverse list in reverse order, so we do FIFO, not LIFO order - */ - again: - tmp = inode_list; - num_io = 0; - num_obdos = 0; - while ( (tmp = tmp->prev) != inode_list && total_io < max_io) { - struct obdfs_inode_info *ii; - struct inode *inode; - int res; - - ii = list_entry(tmp, struct obdfs_inode_info, oi_inodes); - inode = list_entry(ii, struct inode, u); - inodes[num_obdos] = inode; - obdos[num_obdos] = NULL; - CDEBUG(D_INFO, "checking inode %ld pages\n", inode->i_ino); - - /* Make sure we reference "inode" and not "inodes[num_obdos]", - * as num_obdos will change after the loop is run. - */ - if (!list_empty(obdfs_iplist(inode))) { - res = obdfs_enqueue_pages(inode, &obdos[num_obdos], - MAX_IOVEC - num_io, - &pages[num_io], &bufs[num_io], - &counts[num_io], - &offsets[num_io], - &flags[num_obdos], - check_time); - CDEBUG(D_INFO, "FLUSH inode %ld, pages flushed: %d\n", - inode->i_ino, res); - if ( res < 0 ) { - CDEBUG(D_INODE, - "fatal: unable to enqueue inode %ld (err %d)\n", - inode->i_ino, res); - /* XXX Move bad inode to end of list so we can - * continue with flushing list. This is a - * temporary measure to avoid machine lockups. - * Maybe if we have -ENOENT, simply discard. - */ - list_del(tmp); - list_add(tmp, inode_list); - err = res; - EXIT; - goto BREAK; - } - if (res == 0) - continue; - - num_io += res; - total_io += res; - bufs_per_obdo[num_obdos] = res; - num_obdos++; - - if ( num_io == MAX_IOVEC ) { - obd_up(&sbi->osi_list_mutex); - err = obdfs_do_vec_wr(inodes, num_io, num_obdos, - obdos, bufs_per_obdo, - pages, bufs, counts, - offsets, flags); - if ( err ) { - CDEBUG(D_INODE, - "fatal: do_vec_wr err=%d\n", - err); - EXIT; - goto ERR; - } - obd_down(&sbi->osi_list_mutex); - goto again; - } - } - } - -BREAK: - obd_up(&sbi->osi_list_mutex); - - /* flush any remaining I/Os */ - if ( num_io ) { - err = obdfs_do_vec_wr(inodes, num_io, num_obdos, obdos, - bufs_per_obdo, pages, bufs, counts, - offsets, flags); - if (err) - CDEBUG(D_INODE, "fatal: unable to do vec_wr (err %d)\n", err); - num_io = 0; - num_obdos = 0; - } - - /* Remove inode from superblock dirty list when no more pages. - * Make sure we don't point at the current inode with tmp - * when we re-init the list on the inode, or we will loop. - */ - obd_down(&sbi->osi_list_mutex); - tmp = inode_list; - while ( (tmp = tmp->prev) != inode_list ) { - struct obdfs_inode_info *ii; - struct inode *inode; - - ii = list_entry(tmp, struct obdfs_inode_info, oi_inodes); - inode = list_entry(ii, struct inode, u); - CDEBUG(D_INFO, "checking inode %ld empty\n", inode->i_ino); - if (list_empty(obdfs_iplist(inode))) { - CDEBUG(D_INFO, "remove inode %ld from dirty list\n", - inode->i_ino); - tmp = tmp->next; - list_del(obdfs_islist(inode)); - /* decrement inode reference for page cache */ - atomic_dec(&inode->i_count); - INIT_LIST_HEAD(obdfs_islist(inode)); - } - } - obd_up(&sbi->osi_list_mutex); - - CDEBUG(D_INFO, "flushed %ld pages in total\n", total_io); - EXIT; -ERR: - return err ? err : total_io; -} /* obdfs_flush_reqs */ - - -/* Walk all of the superblocks and write out blocks which are too old. - * Return the maximum number of blocks written for a single filesystem. - */ -int obdfs_flush_dirty_pages(unsigned long check_time) -{ - struct list_head *sl; - int max = 0; - - /* ENTRY; */ - sl = &obdfs_super_list; - while ( (sl = sl->prev) != &obdfs_super_list ) { - struct obdfs_sb_info *sbi = - list_entry(sl, struct obdfs_sb_info, osi_list); - int ret; - - /* walk write requests here, use the sb, check the time */ - ret = obdfs_flush_reqs(&sbi->osi_inodes, check_time); - /* XXX handle error? What to do with it? */ - - max = ret > max ? ret : max; - } - if (max) { EXIT; } - return max; -} /* obdfs_flush_dirty_pages */ - - -static void pupdate_wakeup(unsigned long l) -{ - wake_up_interruptible(&pupdated.waitq); -} - - -static int pupdate(void *unused) -{ - u_long flags; - int interval = pupdated.parms.interval; - long age = pupdated.parms.age_buffer; - int wrote = 0; - - if (pupdated.active >= 0) { - CDEBUG(D_CACHE, "attempted to run multiple pupdates\n"); - return 1; - } - - init_timer(&pupdated.timer); - init_waitqueue_head(&pupdated.waitq); - pupdated.timer.function = pupdate_wakeup; - - exit_files(current); - exit_mm(current); - daemonize(); - - current->session = 1; - current->pgrp = 1; - strcpy(current->comm, "pupdated"); - - CDEBUG(D_CACHE, "pupdated activated...\n"); - pupdated.active = 1; - - spin_lock_irqsave(¤t->sigmask_lock, flags); - flush_signals(current); - sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irqrestore(¤t->sigmask_lock, flags); - - do { - long dirty_limit; - - /* update interval */ - if (pupdated.active == 1 && interval) { - mod_timer(&pupdated.timer, jiffies + interval); - interruptible_sleep_on(&pupdated.waitq); - } - if (pupdated.active == 0) { - del_timer(&pupdated.timer); - /* If stopped, we flush one last time... */ - } - - /* asynchronous setattr etc for the future ... - obdfs_flush_dirty_inodes(jiffies - pupdated.parms.age_super); - */ - dirty_limit = nr_free_buffer_pages() * pupdated.parms.nfract / 100; - - if (obdfs_cache_count > dirty_limit) { - interval = 0; - if (wrote < pupdated.parms.ndirty) - age >>= 1; - if (wrote) - CDEBUG(D_CACHE, "wrote %d, age %ld, interval %d\n", - wrote, age, interval); - } else { - if (wrote < pupdated.parms.ndirty >> 1 && - obdfs_cache_count < dirty_limit / 2) { - interval = pupdated.parms.interval; - age = pupdated.parms.age_buffer; - if (wrote) - CDEBUG(D_INFO, - "wrote %d, age %ld, interval %d\n", - wrote, age, interval); - } else if (obdfs_cache_count > dirty_limit / 2) { - interval >>= 1; - if (wrote < pupdated.parms.ndirty) - age >>= 1; - if (wrote) - CDEBUG(D_CACHE, - "wrote %d, age %ld, interval %d\n", - wrote, age, interval); - } - } - - wrote = obdfs_flush_dirty_pages(jiffies - age); - if (wrote) { - CDEBUG(D_CACHE, - "dirty_limit %ld, cache_count %ld, wrote %d\n", - dirty_limit, obdfs_cache_count, wrote); - run_task_queue(&tq_disk); - } - } while (pupdated.active == 1); - - CDEBUG(D_CACHE, "pupdated stopped...\n"); - pupdated.active = -1; - wake_up_interruptible (&pupdated.waitq); - return 0; -} - - -int obdfs_flushd_init(void) -{ - /* - kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); - */ - kernel_thread(pupdate, NULL, 0); - CDEBUG(D_PSDEV, "flushd inited\n"); - return 0; -} - -int obdfs_flushd_cleanup(void) -{ - ENTRY; - - /* Shut down pupdated. */ - if (pupdated.active > 0) { - CDEBUG(D_CACHE, "inform pupdated\n"); - pupdated.active = 0; - wake_up_interruptible(&pupdated.waitq); - - CDEBUG(D_CACHE, "wait for pupdated\n"); - while (pupdated.active == 0) { - interruptible_sleep_on(&pupdated.waitq); - } - CDEBUG(D_CACHE, "done waiting for pupdated\n"); - } - - EXIT; - return 0; -} diff --git a/lustre/obdfs/namei.c b/lustre/obdfs/namei.c deleted file mode 100644 index 985521e..0000000 --- a/lustre/obdfs/namei.c +++ /dev/null @@ -1,466 +0,0 @@ -/* - * linux/fs/obdfs/namei.c - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/fs/ext2/namei.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * Big-endian to little-endian byte-swapping/bitmaps by - * David S. Miller (davem@caip.rutgers.edu), 1995 - * Directory entry file type support and forward compatibility hooks - * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998 - * - * Changes for use in OBDFS - * Copyright (c) 1999, Seagate Technology Inc. - * Copyright (C) 2001, Cluster File Systems, Inc. - * Rewritten based on recent ext2 page cache use. - * - */ - -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_OBDFS - -#include -#include -extern struct address_space_operations obdfs_aops; - -/* from super.c */ -extern void obdfs_change_inode(struct inode *inode); -extern int obdfs_setattr(struct dentry *de, struct iattr *attr); - -/* from dir.c */ -extern int ext2_add_link (struct dentry *dentry, struct inode *inode); -ino_t obdfs_inode_by_name(struct inode * dir, struct dentry *dentry, int *typ); -int ext2_make_empty(struct inode *inode, struct inode *parent); -struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir, - struct dentry *dentry, struct page ** res_page); -int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ); -int ext2_empty_dir (struct inode * inode); -struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p); -void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, - struct page *page, struct inode *inode); - -/* - * Couple of helper functions - make the code slightly cleaner. - */ -static inline void ext2_inc_count(struct inode *inode) -{ - inode->i_nlink++; - obdfs_change_inode(inode); -} - -/* postpone the disk update until the inode really goes away */ -static inline void ext2_dec_count(struct inode *inode) -{ - inode->i_nlink--; - if (inode->i_nlink > 0) - obdfs_change_inode(inode); -} - -static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) -{ - int err; - err = ext2_add_link(dentry, inode); - if (!err) { - d_instantiate(dentry, inode); - return 0; - } - ext2_dec_count(inode); - iput(inode); - return err; -} - -/* methods */ -static struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry) -{ - struct obdo *oa; - struct inode * inode = NULL; - int type; - ino_t ino; - - ENTRY; - if (dentry->d_name.len > EXT2_NAME_LEN) - return ERR_PTR(-ENAMETOOLONG); - - ino = obdfs_inode_by_name(dir, dentry, &type); - if (!ino) - goto negative; - - oa = obdo_fromid(IID(dir), ino, type, - (__u32)(OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS)); - if ( IS_ERR(oa) ) { - CERROR("obdo_fromid failed\n"); - EXIT; - return ERR_PTR(-EACCES); - } - - inode = iget4(dir->i_sb, ino, NULL, oa); - obdo_free(oa); - - if (!inode) - return ERR_PTR(-EACCES); - - negative: - d_add(dentry, inode); - return NULL; -} - - -/* - * NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure. - * - * `len <= EXT2_NAME_LEN' is guaranteed by caller. - * `de != NULL' is guaranteed by caller. - */ -static inline int ext2_match (int len, const char * const name, - struct ext2_dir_entry_2 * de) -{ - if (len != de->name_len) - return 0; - if (!de->inode) - return 0; - return !memcmp(name, de->name, len); -} - -static struct inode *obdfs_new_inode(struct inode *dir, int mode) -{ - struct obdo *oa; - struct inode *inode; - int err; - - ENTRY; - oa = obdo_alloc(); - if (!oa) { - EXIT; - return ERR_PTR(-ENOMEM); - } - - /* Send a hint to the create method on the type of file to create */ - oa->o_mode = mode; - oa->o_valid |= OBD_MD_FLMODE; - CDEBUG(D_INODE, "\n"); - err = obd_create(IID(dir), oa); - CDEBUG(D_INODE, "\n"); - - if ( err ) { - CERROR("new_inode - fatal: err %d\n", err); - obdo_free(oa); - EXIT; - return ERR_PTR(err); - } - CDEBUG(D_INODE, "obdo mode %o\n", oa->o_mode); - - inode = iget4(dir->i_sb, (ino_t)oa->o_id, NULL, oa); - CDEBUG(D_INODE, "\n"); - - if (!inode) { - CERROR("new_inode -fatal: %ld\n", (long)oa->o_id); - obd_destroy(IID(dir), oa); - obdo_free(oa); - EXIT; - return ERR_PTR(-EIO); - } - obdo_free(oa); - - if (!list_empty(&inode->i_dentry)) { - CERROR("new_inode -fatal: aliases %ld, ct %d lnk %d\n", - (long)oa->o_id, - atomic_read(&inode->i_count), - inode->i_nlink); - obd_destroy(IID(dir), oa); - iput(inode); - EXIT; - return ERR_PTR(-EIO); - } - - EXIT; - return inode; -} /* obdfs_new_inode */ - - -/* - * By the time this is called, we already have created - * the directory cache entry for the new file, but it - * is so far negative - it has no inode. - * - * If the create succeeds, we fill in the inode information - * with d_instantiate(). - */ -static int obdfs_create (struct inode * dir, struct dentry * dentry, int mode) -{ - struct inode * inode = obdfs_new_inode (dir, mode); - int err = PTR_ERR(inode); - if (!IS_ERR(inode)) { - inode->i_op = &obdfs_file_inode_operations; - inode->i_fop = &obdfs_file_operations; - inode->i_mapping->a_ops = &obdfs_aops; - err = ext2_add_nondir(dentry, inode); - } - return err; -} /* obdfs_create */ - - -static int obdfs_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev) -{ - struct inode * inode = obdfs_new_inode (dir, mode); - int err = PTR_ERR(inode); - if (!IS_ERR(inode)) { - init_special_inode(inode, mode, rdev); - obdfs_change_inode(inode); - err = ext2_add_nondir(dentry, inode); - } - return err; -} - -static int obdfs_symlink (struct inode * dir, struct dentry * dentry, - const char * symname) -{ - struct super_block * sb = dir->i_sb; - int err = -ENAMETOOLONG; - unsigned l = strlen(symname)+1; - struct inode * inode; - struct obdfs_inode_info *oinfo; - - if (l > sb->s_blocksize) - goto out; - - inode = obdfs_new_inode (dir, S_IFLNK | S_IRWXUGO); - err = PTR_ERR(inode); - if (IS_ERR(inode)) - goto out; - - oinfo = obdfs_i2info(inode); - if (l >= sizeof(oinfo->oi_inline)) { - /* slow symlink */ - inode->i_op = &page_symlink_inode_operations; - inode->i_mapping->a_ops = &obdfs_aops; - err = block_symlink(inode, symname, l); - if (err) - goto out_fail; - } else { - /* fast symlink */ - inode->i_op = &obdfs_fast_symlink_inode_operations; - memcpy(oinfo->oi_inline, symname, l); - inode->i_size = l-1; - } - obdfs_change_inode(inode); - - err = ext2_add_nondir(dentry, inode); -out: - return err; - -out_fail: - ext2_dec_count(inode); - iput (inode); - goto out; -} - - - -static int obdfs_link (struct dentry * old_dentry, struct inode * dir, - struct dentry *dentry) -{ - struct inode *inode = old_dentry->d_inode; - - if (S_ISDIR(inode->i_mode)) - return -EPERM; - - if (inode->i_nlink >= EXT2_LINK_MAX) - return -EMLINK; - - inode->i_ctime = CURRENT_TIME; - ext2_inc_count(inode); - atomic_inc(&inode->i_count); - - return ext2_add_nondir(dentry, inode); -} - - -static int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) -{ - struct inode * inode; - int err = -EMLINK; - ENTRY; - - if (dir->i_nlink >= EXT2_LINK_MAX) - goto out; - - ext2_inc_count(dir); - - inode = obdfs_new_inode (dir, S_IFDIR | mode); - err = PTR_ERR(inode); - if (IS_ERR(inode)) - goto out_dir; - - inode->i_op = &obdfs_dir_inode_operations; - inode->i_fop = &obdfs_dir_operations; - inode->i_mapping->a_ops = &obdfs_aops; - - ext2_inc_count(inode); - - err = ext2_make_empty(inode, dir); - if (err) - goto out_fail; - - err = ext2_add_link(dentry, inode); - if (err) - goto out_fail; - - d_instantiate(dentry, inode); -out: - EXIT; - return err; - -out_fail: - ext2_dec_count(inode); - ext2_dec_count(inode); - iput(inode); - EXIT; -out_dir: - ext2_dec_count(dir); - EXIT; - goto out; -} - -static int obdfs_unlink(struct inode * dir, struct dentry *dentry) -{ - struct inode * inode = dentry->d_inode; - struct ext2_dir_entry_2 * de; - struct page * page; - int err = -ENOENT; - - de = ext2_find_entry (dir, dentry, &page); - if (!de) - goto out; - - err = ext2_delete_entry (de, page); - if (err) - goto out; - - inode->i_ctime = dir->i_ctime; - ext2_dec_count(inode); - err = 0; -out: - return err; -} - - -static int obdfs_rmdir (struct inode * dir, struct dentry *dentry) -{ - struct inode * inode = dentry->d_inode; - int err = -ENOTEMPTY; - - if (ext2_empty_dir(inode)) { - err = obdfs_unlink(dir, dentry); - if (!err) { - inode->i_size = 0; - ext2_dec_count(inode); - ext2_dec_count(dir); - } - } - return err; -} - -static int obdfs_rename (struct inode * old_dir, struct dentry * old_dentry, - struct inode * new_dir, struct dentry * new_dentry ) -{ - struct inode * old_inode = old_dentry->d_inode; - struct inode * new_inode = new_dentry->d_inode; - struct page * dir_page = NULL; - struct ext2_dir_entry_2 * dir_de = NULL; - struct page * old_page; - struct ext2_dir_entry_2 * old_de; - int err = -ENOENT; - - old_de = ext2_find_entry (old_dir, old_dentry, &old_page); - if (!old_de) - goto out; - - if (S_ISDIR(old_inode->i_mode)) { - err = -EIO; - dir_de = ext2_dotdot(old_inode, &dir_page); - if (!dir_de) - goto out_old; - } - - if (new_inode) { - struct page *new_page; - struct ext2_dir_entry_2 *new_de; - - err = -ENOTEMPTY; - if (dir_de && !ext2_empty_dir (new_inode)) - goto out_dir; - - err = -ENOENT; - new_de = ext2_find_entry (new_dir, new_dentry, &new_page); - if (!new_de) - goto out_dir; - ext2_inc_count(old_inode); - ext2_set_link(new_dir, new_de, new_page, old_inode); - new_inode->i_ctime = CURRENT_TIME; - if (dir_de) - new_inode->i_nlink--; - ext2_dec_count(new_inode); - } else { - if (dir_de) { - err = -EMLINK; - if (new_dir->i_nlink >= EXT2_LINK_MAX) - goto out_dir; - } - ext2_inc_count(old_inode); - err = ext2_add_link(new_dentry, old_inode); - if (err) { - ext2_dec_count(old_inode); - goto out_dir; - } - if (dir_de) - ext2_inc_count(new_dir); - } - - ext2_delete_entry (old_de, old_page); - ext2_dec_count(old_inode); - - if (dir_de) { - ext2_set_link(old_inode, dir_de, dir_page, new_dir); - ext2_dec_count(old_dir); - } - return 0; - - -out_dir: - if (dir_de) { - kunmap(dir_page); - page_cache_release(dir_page); - } -out_old: - kunmap(old_page); - page_cache_release(old_page); -out: - return err; -} - -struct inode_operations obdfs_dir_inode_operations = { - create: obdfs_create, - lookup: obdfs_lookup, - link: obdfs_link, - unlink: obdfs_unlink, - symlink: obdfs_symlink, - mkdir: obdfs_mkdir, - rmdir: obdfs_rmdir, - mknod: obdfs_mknod, - rename: obdfs_rename, - setattr: obdfs_setattr -}; diff --git a/lustre/obdfs/rw.c b/lustre/obdfs/rw.c deleted file mode 100644 index ba43795..0000000 --- a/lustre/obdfs/rw.c +++ /dev/null @@ -1,728 +0,0 @@ -/* - * OBDFS Super operations - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1996, 1997, Olaf Kirch - * Copryright (C) 1999 Stelias Computing Inc, - * (author Peter J. Braam ) - * Copryright (C) 1999 Seagate Technology Inc. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_OBDFS - -#include -#include -#include - -void obdfs_change_inode(struct inode *inode); - -static int cache_writes = 0; - - -/* page cache support stuff */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) -/* - * Add a page to the dirty page list. - */ -void __set_page_dirty(struct page *page) -{ - struct address_space *mapping; - spinlock_t *pg_lock; - - pg_lock = PAGECACHE_LOCK(page); - spin_lock(pg_lock); - - mapping = page->mapping; - spin_lock(&mapping->page_lock); - - list_del(&page->list); - list_add(&page->list, &mapping->dirty_pages); - - spin_unlock(&mapping->page_lock); - spin_unlock(pg_lock); - - if (mapping->host) - mark_inode_dirty_pages(mapping->host); -} -/* - * Remove page from dirty list - */ -void __set_page_clean(struct page *page) -{ - struct address_space *mapping = page->mapping; - struct inode *inode; - - if (!mapping) - return; - - list_del(&page->list); - list_add(&page->list, &mapping->clean_pages); - - inode = mapping->host; - if (list_empty(&mapping->dirty_pages)) { - CDEBUG(D_INODE, "inode clean\n"); - inode->i_state &= ~I_DIRTY_PAGES; - } - EXIT; -} - -#else -/* - * Add a page to the dirty page list. - */ -void set_page_dirty(struct page *page) -{ - if (!test_and_set_bit(PG_dirty, &page->flags)) { - struct address_space *mapping = page->mapping; - - if (mapping) { - spin_lock(&pagecache_lock); - list_del(&page->list); - list_add(&page->list, &mapping->dirty_pages); - spin_unlock(&pagecache_lock); - - if (mapping->host) - mark_inode_dirty_pages(mapping->host); - } - } -} -/* - * Remove page from dirty list - */ -void __set_page_clean(struct page *page) -{ - struct address_space *mapping = page->mapping; - struct inode *inode; - - if (!mapping) - return; - - spin_lock(&pagecache_lock); - list_del(&page->list); - list_add(&page->list, &mapping->clean_pages); - - inode = mapping->host; - if (list_empty(&mapping->dirty_pages)) { - CDEBUG(D_INODE, "inode clean\n"); - inode->i_state &= ~I_DIRTY_PAGES; - } - spin_unlock(&pagecache_lock); - EXIT; -} - -#endif - - -inline void set_page_clean(struct page *page) -{ - if (PageDirty(page)) { - ClearPageDirty(page); - __set_page_clean(page); - } -} - -/* SYNCHRONOUS I/O to object storage for an inode -- object attr will be updated too */ -static int obdfs_brw(int rw, struct inode *inode, struct page *page, int create) -{ - obd_count num_obdo = 1; - obd_count bufs_per_obdo = 1; - struct obdo *oa; - obd_size count = PAGE_SIZE; - obd_off offset = ((obd_off)page->index) << PAGE_SHIFT; - obd_flag flags = create ? OBD_BRW_CREATE : 0; - int err; - - ENTRY; - - oa = obdo_alloc(); - if ( !oa ) { - EXIT; - return -ENOMEM; - } - oa->o_valid = (__u32)OBD_MD_FLNOTOBD; - obdfs_from_inode(oa, inode); - - err = obd_brw(rw, IID(inode), num_obdo, &oa, &bufs_per_obdo, - &page, &count, &offset, &flags); - //if ( !err ) - // obdfs_to_inode(inode, oa); /* copy o_blocks to i_blocks */ - - obdo_free(oa); - EXIT; - return err; -} /* obdfs_brw */ - -extern void set_page_clean(struct page *); - -/* SYNCHRONOUS I/O to object storage for an inode -- object attr will be updated too */ -static int obdfs_commit_page(struct page *page, int create, int from, int to) -{ - struct inode *inode = page->mapping->host; - obd_count num_obdo = 1; - obd_count bufs_per_obdo = 1; - struct obdo *oa; - obd_size count = to; - obd_off offset = (((obd_off)page->index) << PAGE_SHIFT); - obd_flag flags = create ? OBD_BRW_CREATE : 0; - int err; - - ENTRY; - oa = obdo_alloc(); - if ( !oa ) { - EXIT; - return -ENOMEM; - } - oa->o_valid = (__u32)OBD_MD_FLNOTOBD; - obdfs_from_inode(oa, inode); - - CDEBUG(D_INODE, "commit_page writing (at %d) to %d, count %Ld\n", - from, to, (unsigned long long)count); - - err = obd_brw(WRITE, IID(inode), num_obdo, &oa, &bufs_per_obdo, - &page, &count, &offset, &flags); - if ( !err ) { - SetPageUptodate(page); - set_page_clean(page); - } - - //if ( !err ) - // obdfs_to_inode(inode, oa); /* copy o_blocks to i_blocks */ - - obdo_free(oa); - EXIT; - return err; -} /* obdfs_brw */ - -/* returns the page unlocked, but with a reference */ -int obdfs_writepage(struct page *page) -{ - int rc; - struct inode *inode = page->mapping->host; - ENTRY; - CERROR("---> writepage called ino %ld!\n", inode->i_ino); - LBUG(); - rc = obdfs_brw(OBD_BRW_WRITE, inode, page, 1); - if ( !rc ) { - set_page_clean(page); - } else { - CDEBUG(D_INODE, "--> GRR %d\n", rc); - } - EXIT; - return rc; -} - - -void write_inode_pages(struct inode *inode) -{ - struct list_head *tmp = &inode->i_mapping->dirty_pages; - - while ( (tmp = tmp->next) != &inode->i_mapping->dirty_pages) { - struct page *page; - page = list_entry(tmp, struct page, list); - obdfs_writepage(page); - } -} - - -/* returns the page unlocked, but with a reference */ -int obdfs_readpage(struct file *file, struct page *page) -{ - struct inode *inode = page->mapping->host; - int rc; - - ENTRY; - - if ( ((inode->i_size + PAGE_CACHE_SIZE -1)>>PAGE_SHIFT) - <= page->index) { - memset(kmap(page), 0, PAGE_CACHE_SIZE); - kunmap(page); - goto readpage_out; - } - - if (Page_Uptodate(page)) { - EXIT; - goto readpage_out; - } - - rc = obdfs_brw(READ, inode, page, 0); - if ( rc ) { - EXIT; - return rc; - } - - readpage_out: - SetPageUptodate(page); - UnlockPage(page); - EXIT; - return 0; -} /* obdfs_readpage */ - -int obdfs_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) -{ - struct inode *inode = page->mapping->host; - obd_off offset = ((obd_off)page->index) << PAGE_SHIFT; - int rc = 0; - ENTRY; - - kmap(page); - if (Page_Uptodate(page)) { - EXIT; - goto prepare_done; - } - - if ( (from <= offset) && (to >= offset + PAGE_SIZE) ) { - EXIT; - return 0; - } - - rc = obdfs_brw(READ, inode, page, 0); - if ( !rc ) { - SetPageUptodate(page); - } - - prepare_done: - set_page_dirty(page); - //SetPageDirty(page); - EXIT; - return rc; -} - - -#if 0 - - - -static kmem_cache_t *obdfs_pgrq_cachep = NULL; - -int obdfs_init_pgrqcache(void) -{ - ENTRY; - if (obdfs_pgrq_cachep == NULL) { - CDEBUG(D_CACHE, "allocating obdfs_pgrq_cache\n"); - obdfs_pgrq_cachep = kmem_cache_create("obdfs_pgrq", - sizeof(struct obdfs_pgrq), - 0, SLAB_HWCACHE_ALIGN, - NULL, NULL); - if (obdfs_pgrq_cachep == NULL) { - EXIT; - return -ENOMEM; - } else { - CDEBUG(D_CACHE, "allocated cache at %p\n", - obdfs_pgrq_cachep); - } - } else { - CDEBUG(D_CACHE, "using existing cache at %p\n", - obdfs_pgrq_cachep); - } - EXIT; - return 0; -} /* obdfs_init_wreqcache */ - -inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq) -{ - --obdfs_cache_count; - CDEBUG(D_INFO, "deleting page %p from list [count %ld]\n", - pgrq->rq_page, obdfs_cache_count); - list_del(&pgrq->rq_plist); - OBDClearCachePage(pgrq->rq_page); - kmem_cache_free(obdfs_pgrq_cachep, pgrq); -} - -void obdfs_cleanup_pgrqcache(void) -{ - ENTRY; - if (obdfs_pgrq_cachep != NULL) { - CDEBUG(D_CACHE, "destroying obdfs_pgrqcache at %p, count %ld\n", - obdfs_pgrq_cachep, obdfs_cache_count); - if (kmem_cache_destroy(obdfs_pgrq_cachep)) - CERROR("unable to free all of cache\n"); - obdfs_pgrq_cachep = NULL; - } else - CERROR("called with NULL pointer\n"); - - EXIT; -} /* obdfs_cleanup_wreqcache */ - - -/* called with the list lock held */ -static struct page *obdfs_find_page_index(struct inode *inode, - unsigned long index) -{ - struct list_head *page_list = obdfs_iplist(inode); - struct list_head *tmp; - struct page *page; - - ENTRY; - - CDEBUG(D_INFO, "looking for inode %ld pageindex %ld\n", - inode->i_ino, index); - OIDEBUG(inode); - - if (list_empty(page_list)) { - EXIT; - return NULL; - } - tmp = page_list; - while ( (tmp = tmp->next) != page_list ) { - struct obdfs_pgrq *pgrq; - - pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist); - page = pgrq->rq_page; - if (index == page->index) { - CDEBUG(D_INFO, - "INDEX SEARCH found page %p, index %ld\n", - page, index); - EXIT; - return page; - } - } - - EXIT; - return NULL; -} /* obdfs_find_page_index */ - - -/* call and free pages from Linux page cache: called with io lock on inodes */ -int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, - obd_count num_obdos, struct obdo **obdos, - obd_count *oa_bufs, struct page **pages, char **bufs, - obd_size *counts, obd_off *offsets, obd_flag *flags) -{ - int err; - - ENTRY; - CDEBUG(D_INFO, "writing %d page(s), %d obdo(s) in vector\n", - num_io, num_obdos); - if (obd_debug_level & D_INFO) { /* DEBUGGING */ - int i; - printk("OBDOS: "); - for (i = 0; i < num_obdos; i++) - printk("%ld:0x%p ", (long)obdos[i]->o_id, obdos[i]); - - printk("\nPAGES: "); - for (i = 0; i < num_io; i++) - printk("0x%p ", pages[i]); - printk("\n"); - } - - err = obd_brw(OBD_BRW_WRITE, IID(inodes[0]), num_obdos, obdos, - oa_bufs, pages, counts, offsets, flags); - - CDEBUG(D_INFO, "BRW done\n"); - /* release the pages from the page cache */ - while ( num_io > 0 ) { - --num_io; - CDEBUG(D_INFO, "calling put_page for %p, index %ld\n", - pages[num_io], pages[num_io]->index); - put_page(pages[num_io]); - } - CDEBUG(D_INFO, "put_page done\n"); - - while ( num_obdos > 0) { - --num_obdos; - CDEBUG(D_INFO, "free obdo %ld\n",(long)obdos[num_obdos]->o_id); - /* copy o_blocks to i_blocks */ - obdfs_set_size (inodes[num_obdos], obdos[num_obdos]->o_size); - //obdfs_to_inode(inodes[num_obdos], obdos[num_obdos]); - obdo_free(obdos[num_obdos]); - } - CDEBUG(D_INFO, "obdo_free done\n"); - EXIT; - return err; -} - - -/* - * Add a page to the write request cache list for later writing. - * ASYNCHRONOUS write method. - */ -static int obdfs_add_page_to_cache(struct inode *inode, struct page *page) -{ - int err = 0; - ENTRY; - - /* The PG_obdcache bit is cleared by obdfs_pgrq_del() BEFORE the page - * is written, so at worst we will write the page out twice. - * - * If the page has the PG_obdcache bit set, then the inode MUST be - * on the superblock dirty list so we don't need to check this. - * Dirty inodes are removed from the superblock list ONLY when they - * don't have any more cached pages. It is possible to have an inode - * with no dirty pages on the superblock list, but not possible to - * have an inode with dirty pages NOT on the superblock dirty list. - */ - if (!OBDAddCachePage(page)) { - struct obdfs_pgrq *pgrq; - pgrq = kmem_cache_alloc(obdfs_pgrq_cachep, SLAB_KERNEL); - if (!pgrq) { - OBDClearCachePage(page); - EXIT; - return -ENOMEM; - } - /* not really necessary since we set all pgrq fields here - memset(pgrq, 0, sizeof(*pgrq)); - */ - - pgrq->rq_page = page; - pgrq->rq_jiffies = jiffies; - get_page(pgrq->rq_page); - - obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); - list_add(&pgrq->rq_plist, obdfs_iplist(inode)); - obdfs_cache_count++; - //CERROR("-- count %d\n", obdfs_cache_count); - - /* If inode isn't already on superblock inodes list, add it. - * - * We increment the reference count on the inode to keep it - * from being freed from memory. This _should_ be an iget() - * with an iput() in both flush_reqs() and put_inode(), but - * since put_inode() is called from iput() we can't call iput() - * again there. Instead we just increment/decrement i_count, - * which is mostly what iget/iput do for an inode in memory. - */ - if ( list_empty(obdfs_islist(inode)) ) { - atomic_inc(&inode->i_count); - CDEBUG(D_INFO, - "adding inode %ld to superblock list %p\n", - inode->i_ino, obdfs_slist(inode)); - list_add(obdfs_islist(inode), obdfs_slist(inode)); - } - obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); - - } - - /* XXX For testing purposes, we can write out the page here. - err = obdfs_flush_reqs(obdfs_slist(inode), ~0UL); - */ - - EXIT; - return err; -} /* obdfs_add_page_to_cache */ - -void rebalance(void) -{ - if (obdfs_cache_count > 60000) { - CERROR("-- count %ld\n", obdfs_cache_count); - //obdfs_flush_dirty_pages(~0UL); - CERROR("-- count %ld\n", obdfs_cache_count); - } -} - - - -/* select between SYNC and ASYNC I/O methods */ -int obdfs_do_writepage(struct page *page, int sync) -{ - struct inode *inode = page->mapping->host; - int err; - - ENTRY; - if ( sync ) - err = obdfs_brw(OBD_BRW_WRITE, inode, page, 1); - else { - err = obdfs_add_page_to_cache(inode, page); - CDEBUG(D_INFO, "DO_WR ino: %ld, page %p, err %d, uptodate %d\n", - inode->i_ino, page, err, Page_Uptodate(page)); - } - - if ( !err ) { - SetPageUptodate(page); - set_page_clean(page); - } - EXIT; - return err; -} /* obdfs_do_writepage */ - - - - -#endif - -int obdfs_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) -{ - struct inode *inode = page->mapping->host; - int rc = 0; - loff_t len = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; - ENTRY; - CDEBUG(D_INODE, "commit write ino %ld (end at %Ld) from %d to %d ,ind %ld\n", - inode->i_ino, len, from, to, page->index); - - - if (cache_writes == 0) { - rc = obdfs_commit_page(page, 1, from, to); - } - - if (len > inode->i_size) { - obdfs_set_size(inode, len); - } - - kunmap(page); - EXIT; - return rc; -} - - -/* - * This does the "real" work of the write. The generic routine has - * allocated the page, locked it, done all the page alignment stuff - * calculations etc. Now we should just copy the data from user - * space and write it back to the real medium.. - * - * If the writer ends up delaying the write, the writer needs to - * increment the page use counts until he is done with the page. - * - * Return value is the number of bytes written. - */ -int obdfs_write_one_page(struct file *file, struct page *page, - unsigned long offset, unsigned long bytes, - const char * buf) -{ - struct inode *inode = file->f_dentry->d_inode; - int err; - - ENTRY; - /* We check for complete page writes here, as we then don't have to - * get the page before writing over everything anyways. - */ - if ( !Page_Uptodate(page) && (offset != 0 || bytes != PAGE_SIZE) ) { - err = obdfs_brw(READ, inode, page, 0); - if ( err ) - return err; - SetPageUptodate(page); - } - - if (copy_from_user((u8*)page_address(page) + offset, buf, bytes)) - return -EFAULT; - - lock_kernel(); - err = obdfs_writepage(page); - unlock_kernel(); - - return (err < 0 ? err : bytes); -} /* obdfs_write_one_page */ - -/* - * return an up to date page: - * - if locked is true then is returned locked - * - if create is true the corresponding disk blocks are created - * - page is held, i.e. caller must release the page - * - * modeled on NFS code. - */ -struct page *obdfs_getpage(struct inode *inode, unsigned long offset, - int create, int locked) -{ - struct page * page; - int index; - int err; - - ENTRY; - - offset = offset & PAGE_CACHE_MASK; - CDEBUG(D_INFO, "ino: %ld, offset %ld, create %d, locked %d\n", - inode->i_ino, offset, create, locked); - index = offset >> PAGE_CACHE_SHIFT; - - page = grab_cache_page(&inode->i_data, index); - - /* Yuck, no page */ - if (! page) { - CERROR("grab_cache_page says no dice ...\n"); - EXIT; - return NULL; - } - - /* now check if the data in the page is up to date */ - if ( Page_Uptodate(page)) { - if (!locked) { - if (PageLocked(page)) - UnlockPage(page); - } else { - CERROR("expecting locked page\n"); - } - EXIT; - return page; - } - - err = obdfs_brw(READ, inode, page, create); - - if ( err ) { - SetPageError(page); - UnlockPage(page); - EXIT; - return page; - } - - if ( !locked ) - UnlockPage(page); - SetPageUptodate(page); - EXIT; - return page; -} /* obdfs_getpage */ - - -void obdfs_truncate(struct inode *inode) -{ - struct obdo *oa; - int err; - ENTRY; - - //obdfs_dequeue_pages(inode); - oa = obdo_alloc(); - if ( !oa ) { - err = -ENOMEM; - CERROR("obdo_alloc failed!\n"); - } else { - oa->o_valid = (__u32)OBD_MD_FLNOTOBD; - obdfs_from_inode(oa, inode); - - CDEBUG(D_INFO, "calling punch for %ld (%Lu bytes at 0)\n", - (long)oa->o_id, (unsigned long long)oa->o_size); - err = obd_punch(IID(inode), oa, oa->o_size, 0); - - obdo_free(oa); - } - - if (err) { - CERROR("obd_truncate fails (%d)\n", err); - EXIT; - return; - } - EXIT; -} /* obdfs_truncate */ - -struct address_space_operations obdfs_aops = { - readpage: obdfs_readpage, - writepage: obdfs_writepage, - sync_page: block_sync_page, - prepare_write: obdfs_prepare_write, - commit_write: obdfs_commit_write, - bmap: NULL -}; diff --git a/lustre/obdfs/super.c b/lustre/obdfs/super.c deleted file mode 100644 index fb74492..0000000 --- a/lustre/obdfs/super.c +++ /dev/null @@ -1,522 +0,0 @@ - -/* - * OBDFS Super operations - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copryright (C) 1996 Peter J. Braam - * Copryright (C) 1999 Stelias Computing Inc. - * Copryright (C) 1999 Seagate Technology Inc. - * Copryright (C) 2001 Mountain View Data, Inc. - * Copryright (C) 2002 Cluster File Systems, Inc. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_OBDFS - -#include -#include -#include - -struct list_head obdfs_super_list; -extern struct address_space_operations obdfs_aops; -struct super_operations obdfs_super_operations; -long obdfs_cache_count = 0; -long obdfs_mutex_start = 0; - -static char *obdfs_read_opt(const char *opt, char *data) -{ - char *value; - char *retval; - - CDEBUG(D_INFO, "option: %s, data %s\n", opt, data); - if ( strncmp(opt, data, strlen(opt)) ) - return NULL; - - if ( (value = strchr(data, '=')) == NULL ) - return NULL; - - value++; - OBD_ALLOC(retval, strlen(value) + 1); - if ( !retval ) { - CERROR("out of memory!\n"); - return NULL; - } - - memcpy(retval, value, strlen(value)+1); - CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); - return retval; -} - -static void obdfs_options(char *options, char **dev, char **vers) -{ - char *this_char; - - if (!options) - return; - - for (this_char = strtok (options, ","); - this_char != NULL; - this_char = strtok (NULL, ",")) { - CDEBUG(D_INFO, "this_char %s\n", this_char); - if ( (!*dev && (*dev = obdfs_read_opt("device", this_char)))|| - (!*vers && (*vers = obdfs_read_opt("version", this_char))) ) - continue; - - } -} - -static struct super_block * obdfs_read_super(struct super_block *sb, - void *data, int silent) -{ - struct inode *root = 0; - struct obdfs_sb_info *sbi = (struct obdfs_sb_info *)(&sb->u.generic_sbp); - struct obd_device *obddev; - char *device = NULL; - char *version = NULL; - int connected = 0; - int devno; - int err; - unsigned long blocksize; - unsigned long blocksize_bits; - unsigned long root_ino; - int scratch; - struct obdo *oa; - - - ENTRY; - MOD_INC_USE_COUNT; - - memset(sbi, 0, sizeof(*sbi)); - - CDEBUG(D_INFO, "\n"); - obdfs_options(data, &device, &version); - if ( !device ) { - CERROR("no device\n"); - EXIT; - goto ERR; - } - - devno = simple_strtoul(device, NULL, 0); - CDEBUG(D_INFO, "\n"); - if ( devno >= MAX_OBD_DEVICES ) { - CERROR("device of %s too high (%d)\n", device, devno); - EXIT; - goto ERR; - } - - CDEBUG(D_INFO, "\n"); - - obddev = &obd_dev[devno]; - sbi->osi_obd = obddev; - sbi->osi_conn.oc_dev = obddev; - - err = obd_connect(&sbi->osi_conn); - if ( err ) { - CERROR("OBDFS: cannot connect to %s\n", device); - EXIT; - goto ERR; - } - - connected = 1; - CDEBUG(D_INFO, "\n"); - /* list of dirty inodes, and a mutex to hold while modifying it */ - INIT_LIST_HEAD(&sbi->osi_inodes); - init_MUTEX (&sbi->osi_list_mutex); - - CDEBUG(D_INFO, "\n"); - sbi->osi_super = sb; - - CDEBUG(D_INFO, "\n"); - err = obd_get_info(&sbi->osi_conn, strlen("blocksize"), - "blocksize", &scratch, - (void *)&blocksize); - if ( err ) { - CERROR("getinfo call to drive failed (blocksize)\n"); - EXIT; - goto ERR; - } - - CDEBUG(D_INFO, "\n"); - err = obd_get_info(&sbi->osi_conn, strlen("blocksize_bits"), - "blocksize_bits", &scratch, - (void *)&blocksize_bits); - if ( err ) { - CERROR("getinfo call to drive failed (blocksize_bits)\n"); - EXIT; - goto ERR; - } - - CDEBUG(D_INFO, "\n"); - err = obd_get_info(&sbi->osi_conn, strlen("root_ino"), - "root_ino", &scratch, (void *)&root_ino); - if ( err ) { - CERROR("getinfo call to drive failed (root_ino)\n"); - EXIT; - goto ERR; - } - - CDEBUG(D_INFO, "\n"); - sb->s_maxbytes = 1LL << 36; - CERROR("Max bytes: %Lx\n", sb->s_maxbytes); - sb->s_blocksize = PAGE_SIZE; - sb->s_blocksize_bits = (unsigned char)PAGE_SHIFT; - sb->s_magic = OBDFS_SUPER_MAGIC; - sb->s_op = &obdfs_super_operations; - - /* XXX how to get "sb->s_flags |= MS_RDONLY" here for snapshots? */ - - /* make root inode */ - CDEBUG(D_INFO, "\n"); - oa = obdo_fromid(&sbi->osi_conn, root_ino, S_IFDIR, - (__u32)(OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS)); - CDEBUG(D_INFO, "mode %o\n", oa->o_mode); - if ( IS_ERR(oa) ) { - CERROR("obdo_fromid failed\n"); - iput(root); - EXIT; - goto ERR; - } - CDEBUG(D_INFO, "\n"); - root = iget4(sb, root_ino, NULL, oa); - obdo_free(oa); - CDEBUG(D_INFO, "\n"); - if (!root) { - CERROR("OBDFS: bad iget4 for root\n"); - sb->s_dev = 0; - err = -ENOENT; - EXIT; - goto ERR; - } - - CDEBUG(D_INFO, "sbdev %d, rootino: %ld, dev %s, " - "minor: %d, blocksize: %ld, blocksize bits %ld\n", - sb->s_dev, root->i_ino, device, MINOR(devno), - blocksize, blocksize_bits); - sb->s_root = d_alloc_root(root); - list_add(&sbi->osi_list, &obdfs_super_list); - OBD_FREE(device, strlen(device) + 1); - if (version) - OBD_FREE(version, strlen(version) + 1); - EXIT; - return sb; - -ERR: - MOD_DEC_USE_COUNT; - if (device) - OBD_FREE(device, strlen(device) + 1); - if (version) - OBD_FREE(version, strlen(version) + 1); - if (connected) - obd_disconnect(&sbi->osi_conn); - - if (sbi) { - sbi->osi_super = NULL; - } - if (root) { - iput(root); - } - sb->s_dev = 0; - return NULL; -} /* obdfs_read_super */ - - -static void obdfs_put_super(struct super_block *sb) -{ - struct obdfs_sb_info *sbi; - - ENTRY; - sb->s_dev = 0; - - sbi = (struct obdfs_sb_info *) &sb->u.generic_sbp; - //obdfs_flush_reqs(&sbi->osi_inodes, ~0UL); - - obd_disconnect(ID(sb)); - list_del(&sbi->osi_list); - - CERROR("OBDFS: Bye bye.\n"); - - MOD_DEC_USE_COUNT; - EXIT; -} /* obdfs_put_super */ - - -void obdfs_do_change_inode(struct inode *inode, int valid) -{ - struct obdo *oa; - int err; - - ENTRY; - oa = obdo_alloc(); - if ( !oa ) { - CERROR("obdo_alloc failed\n"); - EXIT; - return; - } - - oa->o_valid = OBD_MD_FLNOTOBD & (valid | OBD_MD_FLID); - obdfs_from_inode(oa, inode); - oa->o_mode = inode->i_mode; - err = obd_setattr(IID(inode), oa); - - if ( err ) - CERROR("obd_setattr fails (%d)\n", err); - - EXIT; - obdo_free(oa); -} /* obdfs_write_inode */ - -void obdfs_change_inode(struct inode *inode, int mask) -{ - return obdfs_do_change_inode(inode, OBD_MD_FLNLINK); -} - - -extern void write_inode_pages(struct inode *); -/* This routine is called from iput() (for each unlink on the inode). - * We can't put this call into delete_inode() since that is called only - * when i_count == 0, and we need to keep a reference on the inode while - * it is in the page cache, which means i_count > 0. Catch 22. - */ -static void obdfs_put_inode(struct inode *inode) -{ - ENTRY; - if (inode->i_nlink && (atomic_read(&inode->i_count) == 1)) { - write_inode_pages(inode); - EXIT; - return; - } - - //obdfs_dequeue_pages(inode); - EXIT; -} /* obdfs_put_inode */ - - -static void obdfs_delete_inode(struct inode *inode) -{ - obdfs_do_change_inode(inode, ~0); - clear_inode(inode); -} -#if 0 -{ - struct obdo *oa; - int err; - - ENTRY; - oa = obdo_alloc(); - if ( !oa ) { - CERROR("obdo_alloc failed\n"); - EXIT; - return; - } - oa->o_valid = OBD_MD_FLNOTOBD; - obdfs_from_inode(oa, inode); - - /* XXX how do we know that this inode is now clean? */ - CERROR("delete_inode ------> link %d\n", inode->i_nlink); - ODEBUG(oa); - err = obd_destroy(IID(inode), oa); - obdo_free(oa); - clear_inode(inode); - if (err) { - CERROR("obd_destroy fails (%d)\n", err); - EXIT; - return; - } - - EXIT; -} /* obdfs_delete_inode */ -#endif - - -static int obdfs_attr2inode(struct inode * inode, struct iattr * attr) -{ - unsigned int ia_valid = attr->ia_valid; - int error = 0; - - if (ia_valid & ATTR_SIZE) { - error = vmtruncate(inode, attr->ia_size); - if (error) - goto out; - } - - if (ia_valid & ATTR_UID) - inode->i_uid = attr->ia_uid; - if (ia_valid & ATTR_GID) - inode->i_gid = attr->ia_gid; - if (ia_valid & ATTR_ATIME) - inode->i_atime = attr->ia_atime; - if (ia_valid & ATTR_MTIME) - inode->i_mtime = attr->ia_mtime; - if (ia_valid & ATTR_CTIME) - inode->i_ctime = attr->ia_ctime; - if (ia_valid & ATTR_MODE) { - inode->i_mode = attr->ia_mode; - if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) - inode->i_mode &= ~S_ISGID; - } -out: - return error; -} - -int obdfs_setattr(struct dentry *de, struct iattr *attr) -{ - struct inode *inode = de->d_inode; - struct obdo *oa; - int err; - - ENTRY; - oa = obdo_alloc(); - if ( !oa ) { - CERROR("obdo_alloc failed\n"); - return -ENOMEM; - } - - obdfs_attr2inode(inode, attr); - oa->o_id = inode->i_ino; - oa->o_mode = inode->i_mode; - obdo_from_iattr(oa, attr); - err = obd_setattr(IID(inode), oa); - - if ( err ) - CERROR("obd_setattr fails (%d)\n", err); - - EXIT; - obdo_free(oa); - return err; -} /* obdfs_setattr */ - - - -static int obdfs_statfs(struct super_block *sb, struct statfs *buf) -{ - struct statfs tmp; - int err; - - ENTRY; - - err = obd_statfs(ID(sb), &tmp); - if ( err ) { - CERROR("obd_statfs fails (%d)\n", err); - return err; - } - memcpy(buf, &tmp, sizeof(*buf)); - CDEBUG(D_SUPER, "statfs returns avail %ld\n", tmp.f_bavail); - EXIT; - - return err; -} - -static inline void obdfs_read_inode2(struct inode *inode, void *opaque) -{ - struct obdo *oa = opaque; - - ENTRY; - obdfs_to_inode(inode, oa); - - INIT_LIST_HEAD(obdfs_iplist(inode)); /* list of dirty pages on inode */ - INIT_LIST_HEAD(obdfs_islist(inode)); /* list of inodes in superblock */ - - /* OIDEBUG(inode); */ - - if (S_ISREG(inode->i_mode)) { - inode->i_op = &obdfs_file_inode_operations; - inode->i_fop = &obdfs_file_operations; - inode->i_mapping->a_ops = &obdfs_aops; - EXIT; - } else if (S_ISDIR(inode->i_mode)) { - inode->i_op = &obdfs_dir_inode_operations; - inode->i_fop = &obdfs_dir_operations; - inode->i_mapping->a_ops = &obdfs_aops; - EXIT; - } else if (S_ISLNK(inode->i_mode)) { - if (inode->i_blocks) { - inode->i_op = &obdfs_symlink_inode_operations; - inode->i_mapping->a_ops = &obdfs_aops; - }else { - inode->i_op = &obdfs_fast_symlink_inode_operations; - } - EXIT; - } else { - init_special_inode(inode, inode->i_mode, - ((int *)obdfs_i2info(inode)->oi_inline)[0]); - } - - EXIT; - return; -} - -/* exported operations */ -struct super_operations obdfs_super_operations = -{ - read_inode2: obdfs_read_inode2, - put_inode: obdfs_put_inode, - delete_inode: obdfs_delete_inode, - put_super: obdfs_put_super, - statfs: obdfs_statfs -}; - - -struct file_system_type obdfs_fs_type = { - "obdfs", 0, obdfs_read_super, NULL -}; - -int init_obdfs(void) -{ - //int err; - - printk(KERN_INFO "OBDFS v0.1, braam@stelias.com\n"); - - obdfs_sysctl_init(); - - INIT_LIST_HEAD(&obdfs_super_list); - //err = obdfs_init_pgrqcache(); - //if (err) - //return err; - - //obdfs_flushd_init(); - return register_filesystem(&obdfs_fs_type); -} - - - - -#ifdef MODULE -int init_module(void) -{ - return init_obdfs(); -} - -void cleanup_module(void) -{ - ENTRY; - - //obdfs_flushd_cleanup(); - obdfs_sysctl_clean(); - //obdfs_cleanup_pgrqcache(); - unregister_filesystem(&obdfs_fs_type); - CDEBUG(D_MALLOC, "OBDFS mem used %ld\n", obd_memory); - EXIT; -} - -#endif diff --git a/lustre/obdfs/symlink.c b/lustre/obdfs/symlink.c deleted file mode 100644 index c5c851b..0000000 --- a/lustre/obdfs/symlink.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * linux/fs/ext2/symlink.c - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/fs/minix/symlink.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * ext2 symlink handling code - * - * Modified for OBDFS. - * Re-written Oct 2001. - * - * Copyright (C) 2001 Cluster File Systems, Inc. (author: braam@clusterfs.com) - */ - -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_OBDFS - -#include /* for ENTRY and EXIT only */ -#include - -static int obdfs_fast_readlink(struct dentry *dentry, char *buffer, int buflen) -{ - char *s = obdfs_i2info(dentry->d_inode)->oi_inline; - return vfs_readlink(dentry, buffer, buflen, s); -} - -static int obdfs_fast_follow_link(struct dentry *dentry, struct nameidata *nd) -{ - char *s = obdfs_i2info(dentry->d_inode)->oi_inline; - return vfs_follow_link(nd, s); -} - -extern int obdfs_setattr(struct dentry *de, struct iattr *attr); -struct inode_operations obdfs_fast_symlink_inode_operations = { - readlink: obdfs_fast_readlink, - follow_link: obdfs_fast_follow_link, - setattr: obdfs_setattr -}; - -static int obdfs_readlink(struct dentry *dentry, char *buffer, int buflen) -{ - struct page *page = NULL; - int res; - - ENTRY; - page = obdfs_getpage(dentry->d_inode, 0, 0, 0); - if (!page) { - EXIT; - return 0; - } - res = vfs_readlink(dentry, buffer, buflen, (char *)page_address(page)); - page_cache_release(page); - EXIT; - return res; -} /* obdfs_readlink */ - -static int obdfs_follow_link(struct dentry * dentry, - struct nameidata *nd) -{ - struct page *page = NULL; - int res; - - ENTRY; - page = obdfs_getpage(dentry->d_inode, 0, 0, 0); - if (!page) { - dput(nd->dentry); - EXIT; - return -EIO; - } - res = vfs_follow_link(nd, (char *)page_address(page)); - page_cache_release(page); - EXIT; - return res; -} - -struct inode_operations obdfs_symlink_inode_operations = { - readlink: obdfs_readlink, - follow_link: obdfs_follow_link, - setattr: obdfs_setattr -}; diff --git a/lustre/obdfs/sysctl.c b/lustre/obdfs/sysctl.c deleted file mode 100644 index c03b0289..0000000 --- a/lustre/obdfs/sysctl.c +++ /dev/null @@ -1,66 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -struct ctl_table_header *obdfs_table_header = NULL; - -int obdfs_debug_level = 0; -int obdfs_print_entry = 1; - - -#define OBDFS_SYSCTL 1 - -#define OBDFS_DEBUG 1 /* control debugging */ -#define OBDFS_ENTRY 2 /* control enter/leave pattern */ -#define OBDFS_TIMEOUT 3 /* timeout on upcalls to become intrble */ -#define OBDFS_HARD 4 /* mount type "hard" or "soft" */ -#define OBDFS_VARS 5 -#define OBDFS_INDEX 6 -#define OBDFS_RESET 7 - -#define OBDFS_VARS_SLOT 2 - -static ctl_table obdfs_table[] = { - {OBDFS_DEBUG, "debug", &obdfs_debug_level, sizeof(int), 0644, NULL, &proc_dointvec}, - {OBDFS_ENTRY, "trace", &obdfs_print_entry, sizeof(int), 0644, NULL, &proc_dointvec}, - { 0 } -}; - -static ctl_table top_table[] = { - {OBDFS_SYSCTL, "obdfs", NULL, 0, 0555, obdfs_table}, - {0} -}; - -void obdfs_sysctl_init (void) -{ - -#ifdef CONFIG_SYSCTL - if ( !obdfs_table_header ) - obdfs_table_header = register_sysctl_table(top_table, 0); -#endif -} - -void obdfs_sysctl_clean (void) -{ -#ifdef CONFIG_SYSCTL - if ( obdfs_table_header ) - unregister_sysctl_table(obdfs_table_header); - obdfs_table_header = NULL; -#endif -} diff --git a/lustre/osc/.cvsignore b/lustre/osc/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/osc/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/osc/Makefile.am b/lustre/osc/Makefile.am deleted file mode 100644 index d3e3be8..0000000 --- a/lustre/osc/Makefile.am +++ /dev/null @@ -1,21 +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 - -DEFS:= - -MODULE = osc -modulefs_DATA = osc.o -EXTRA_PROGRAMS = osc - -LINX= obd_pack.c -osc_SOURCES = obd_pack.c osc_request.c # super.c rw.c file.c dir.c sysctl.c super.c namei.c symlink.c - -obd_pack.c: - test -e obd_pack.c || ln -sf $(top_srcdir)/lib/obd_pack.c - -dist-hook: - list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done - -include $(top_srcdir)/Rules diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c deleted file mode 100644 index fe83d9b..0000000 --- a/lustre/osc/osc_request.c +++ /dev/null @@ -1,720 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copryright (C) 2001, 2002 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - * - * Author Peter Braam - * - * This server is single threaded at present (but can easily be multi - * threaded). For testing and management it is treated as an - * obd_device, although it does not export a full OBD method table - * (the requests are coming in over the wire, so object target - * modules do not have a full method table.) - * - */ - -#define EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_OSC - -#include -#include -#include - -static void osc_con2cl(struct obd_conn *conn, struct ptlrpc_client **cl, - struct ptlrpc_connection **connection) -{ - struct osc_obd *osc = &conn->oc_dev->u.osc; - *cl = osc->osc_client; - *connection = osc->osc_conn; -} - -static void osc_con2dlmcl(struct obd_conn *conn, struct ptlrpc_client **cl, - struct ptlrpc_connection **connection) -{ - struct osc_obd *osc = &conn->oc_dev->u.osc; - *cl = osc->osc_ldlm_client; - *connection = osc->osc_conn; -} - -static int osc_connect(struct obd_conn *conn) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_CONNECT, 0, NULL, NULL); - if (!request) - RETURN(-ENOMEM); - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) { - CERROR("%s failed: rc = %d\n", __FUNCTION__, rc); - GOTO(out, rc); - } - - body = lustre_msg_buf(request->rq_repmsg, 0); - CDEBUG(D_INODE, "received connid %d\n", body->connid); - - conn->oc_id = body->connid; - EXIT; - out: - ptlrpc_free_req(request); - return rc; -} - -static int osc_disconnect(struct obd_conn *conn) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_DISCONNECT, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - body->connid = conn->oc_id; - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - GOTO(out, rc); - out: - ptlrpc_free_req(request); - return rc; -} - -static int osc_getattr(struct obd_conn *conn, struct obdo *oa) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_GETATTR, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - memcpy(&body->oa, oa, sizeof(*oa)); - body->connid = conn->oc_id; - body->oa.o_valid = ~0; - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) { - CERROR("%s failed: rc = %d\n", __FUNCTION__, rc); - GOTO(out, rc); - } - - body = lustre_msg_buf(request->rq_repmsg, 0); - CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); - if (oa) - memcpy(oa, &body->oa, sizeof(*oa)); - - EXIT; - out: - ptlrpc_free_req(request); - return 0; -} - -static int osc_open(struct obd_conn *conn, struct obdo *oa) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_OPEN, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - memcpy(&body->oa, oa, sizeof(*oa)); - body->connid = conn->oc_id; - if (body->oa.o_valid != (OBD_MD_FLMODE | OBD_MD_FLID)) - LBUG(); - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) - GOTO(out, rc); - - body = lustre_msg_buf(request->rq_repmsg, 0); - CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); - if (oa) - memcpy(oa, &body->oa, sizeof(*oa)); - - EXIT; - out: - ptlrpc_free_req(request); - return 0; -} - -static int osc_close(struct obd_conn *conn, struct obdo *oa) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_CLOSE, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - memcpy(&body->oa, oa, sizeof(*oa)); - body->connid = conn->oc_id; - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) - GOTO(out, rc); - - body = lustre_msg_buf(request->rq_repmsg, 0); - CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); - if (oa) - memcpy(oa, &body->oa, sizeof(*oa)); - - EXIT; - out: - ptlrpc_free_req(request); - return 0; -} - -static int osc_setattr(struct obd_conn *conn, struct obdo *oa) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_SETATTR, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - memcpy(&body->oa, oa, sizeof(*oa)); - body->connid = conn->oc_id; - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - GOTO(out, rc); - - out: - ptlrpc_free_req(request); - return 0; -} - -static int osc_create(struct obd_conn *conn, struct obdo *oa) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - if (!oa) { - CERROR("oa NULL\n"); - RETURN(-EINVAL); - } - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_CREATE, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - memcpy(&body->oa, oa, sizeof(*oa)); - body->oa.o_valid = ~0; - body->connid = conn->oc_id; - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) - GOTO(out, rc); - - body = lustre_msg_buf(request->rq_repmsg, 0); - memcpy(oa, &body->oa, sizeof(*oa)); - - EXIT; - out: - ptlrpc_free_req(request); - return 0; -} - -static int osc_punch(struct obd_conn *conn, struct obdo *oa, obd_size count, - obd_off offset) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - if (!oa) { - CERROR("oa NULL\n"); - RETURN(-EINVAL); - } - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_PUNCH, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - memcpy(&body->oa, oa, sizeof(*oa)); - body->connid = conn->oc_id; - body->oa.o_valid = ~0; - body->oa.o_size = offset; - body->oa.o_blocks = count; - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) - GOTO(out, rc); - - body = lustre_msg_buf(request->rq_repmsg, 0); - memcpy(oa, &body->oa, sizeof(*oa)); - - EXIT; - out: - ptlrpc_free_req(request); - return 0; -} - -static int osc_destroy(struct obd_conn *conn, struct obdo *oa) -{ - struct ptlrpc_request *request; - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - if (!oa) { - CERROR("oa NULL\n"); - RETURN(-EINVAL); - } - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_DESTROY, 1, &size, NULL); - if (!request) - RETURN(-ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - memcpy(&body->oa, oa, sizeof(*oa)); - body->connid = conn->oc_id; - body->oa.o_valid = ~0; - - request->rq_replen = lustre_msg_size(1, &size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) - GOTO(out, rc); - - body = lustre_msg_buf(request->rq_repmsg, 0); - memcpy(oa, &body->oa, sizeof(*oa)); - - EXIT; - out: - ptlrpc_free_req(request); - return 0; -} - -static int osc_sendpage(struct ptlrpc_bulk_desc *desc, - struct niobuf_remote *dst, struct niobuf_local *src) -{ - struct ptlrpc_bulk_page *page; - ENTRY; - - page = ptlrpc_prep_bulk_page(desc); - if (page == NULL) - RETURN(-ENOMEM); - - page->b_buf = (void *)(unsigned long)src->addr; - page->b_buflen = src->len; - page->b_xid = dst->xid; - - RETURN(0); -} - -static int osc_brw_read(struct obd_conn *conn, obd_count num_oa, - struct obdo **oa, obd_count *oa_bufs, struct page **buf, - obd_size *count, obd_off *offset, obd_flag *flags) -{ - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ptlrpc_request *request; - struct ost_body *body; - struct list_head *tmp; - int pages, rc, i, j, size[3] = {sizeof(*body)}; - void *ptr1, *ptr2; - struct ptlrpc_bulk_desc *desc; - ENTRY; - - size[1] = num_oa * sizeof(struct obd_ioobj); - pages = 0; - for (i = 0; i < num_oa; i++) - pages += oa_bufs[i]; - size[2] = pages * sizeof(struct niobuf_remote); - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_BRW, 3, size, NULL); - if (!request) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(request->rq_reqmsg, 0); - body->data = OBD_BRW_READ; - - desc = ptlrpc_prep_bulk(connection); - if (!desc) - GOTO(out2, rc = -ENOMEM); - desc->b_portal = OST_BULK_PORTAL; - - ptr1 = lustre_msg_buf(request->rq_reqmsg, 1); - ptr2 = lustre_msg_buf(request->rq_reqmsg, 2); - for (pages = 0, i = 0; i < num_oa; i++) { - ost_pack_ioo(&ptr1, oa[i], oa_bufs[i]); - for (j = 0; j < oa_bufs[i]; j++, pages++) { - struct ptlrpc_bulk_page *bulk; - bulk = ptlrpc_prep_bulk_page(desc); - if (bulk == NULL) - GOTO(out3, rc = -ENOMEM); - - spin_lock(&connection->c_lock); - bulk->b_xid = ++connection->c_xid_out; - spin_unlock(&connection->c_lock); - - bulk->b_buf = kmap(buf[pages]); - bulk->b_page = buf[pages]; - bulk->b_buflen = PAGE_SIZE; - ost_pack_niobuf(&ptr2, offset[pages], count[pages], - flags[pages], bulk->b_xid); - } - } - - rc = ptlrpc_register_bulk(desc); - if (rc) - GOTO(out3, rc); - - request->rq_replen = lustre_msg_size(1, size); - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) - ptlrpc_abort_bulk(desc); - GOTO(out3, rc); - - out3: - list_for_each(tmp, &desc->b_page_list) { - struct ptlrpc_bulk_page *bulk; - bulk = list_entry(tmp, struct ptlrpc_bulk_page, b_link); - if (bulk->b_buf != NULL) - kunmap(bulk->b_page); - } - ptlrpc_free_bulk(desc); - out2: - ptlrpc_free_req(request); - out: - return rc; -} - -static int osc_brw_write(struct obd_conn *conn, obd_count num_oa, - struct obdo **oa, obd_count *oa_bufs, - struct page **pagearray, obd_size *count, obd_off *offset, - obd_flag *flags) -{ - struct ptlrpc_client *cl; - struct ptlrpc_connection *connection; - struct ptlrpc_request *request; - struct ptlrpc_bulk_desc *desc; - struct obd_ioobj ioo; - struct ost_body *body; - struct niobuf_local *local; - struct niobuf_remote *remote; - long pages; - int rc, i, j, size[3] = {sizeof(*body)}; - void *ptr1, *ptr2; - ENTRY; - - size[1] = num_oa * sizeof(ioo); - pages = 0; - for (i = 0; i < num_oa; i++) - pages += oa_bufs[i]; - size[2] = pages * sizeof(*remote); - - OBD_ALLOC(local, pages * sizeof(*local)); - if (local == NULL) - RETURN(-ENOMEM); - - osc_con2cl(conn, &cl, &connection); - request = ptlrpc_prep_req(cl, connection, OST_BRW, 3, size, NULL); - if (!request) - GOTO(out, rc = -ENOMEM); - body = lustre_msg_buf(request->rq_reqmsg, 0); - body->data = OBD_BRW_WRITE; - - ptr1 = lustre_msg_buf(request->rq_reqmsg, 1); - ptr2 = lustre_msg_buf(request->rq_reqmsg, 2); - for (pages = 0, i = 0; i < num_oa; i++) { - ost_pack_ioo(&ptr1, oa[i], oa_bufs[i]); - for (j = 0; j < oa_bufs[i]; j++, pages++) { - local[pages].addr = kmap(pagearray[pages]); - local[pages].offset = offset[pages]; - local[pages].len = count[pages]; - ost_pack_niobuf(&ptr2, offset[pages], count[pages], - flags[pages], 0); - } - } - - size[1] = pages * sizeof(struct niobuf_remote); - request->rq_replen = lustre_msg_size(2, size); - - rc = ptlrpc_queue_wait(request); - rc = ptlrpc_check_status(request, rc); - if (rc) - GOTO(out2, rc); - - ptr2 = lustre_msg_buf(request->rq_repmsg, 1); - if (ptr2 == NULL) - GOTO(out2, rc = -EINVAL); - - if (request->rq_repmsg->buflens[1] != - pages * sizeof(struct niobuf_remote)) { - CERROR("buffer length wrong (%d vs. %ld)\n", - request->rq_repmsg->buflens[1], - pages * sizeof(struct niobuf_remote)); - GOTO(out2, rc = -EINVAL); - } - - desc = ptlrpc_prep_bulk(connection); - desc->b_portal = OSC_BULK_PORTAL; - - for (pages = 0, i = 0; i < num_oa; i++) { - for (j = 0; j < oa_bufs[i]; j++, pages++) { - ost_unpack_niobuf(&ptr2, &remote); - rc = osc_sendpage(desc, remote, &local[pages]); - if (rc) - GOTO(out3, rc); - } - } - - rc = ptlrpc_send_bulk(desc); - GOTO(out3, rc); - - out3: - ptlrpc_free_bulk(desc); - out2: - ptlrpc_free_req(request); - for (pages = 0, i = 0; i < num_oa; i++) - for (j = 0; j < oa_bufs[i]; j++, pages++) - kunmap(pagearray[pages]); - out: - OBD_FREE(local, pages * sizeof(*local)); - - return rc; -} - -static int osc_brw(int rw, struct obd_conn *conn, obd_count num_oa, - struct obdo **oa, obd_count *oa_bufs, struct page **buf, - obd_size *count, obd_off *offset, obd_flag *flags) -{ - if (rw == OBD_BRW_READ) - return osc_brw_read(conn, num_oa, oa, oa_bufs, buf, count, - offset, flags); - else - return osc_brw_write(conn, num_oa, oa, oa_bufs, buf, count, - offset, flags); -} - -static int osc_enqueue(struct obd_conn *oconn, struct ldlm_namespace *ns, - struct ldlm_handle *parent_lock, __u64 *res_id, - __u32 type, struct ldlm_extent *extent, __u32 mode, - int *flags, void *data, int datalen, - struct ldlm_handle *lockh) -{ - struct ptlrpc_connection *conn; - struct ptlrpc_client *cl; - int rc; - __u32 mode2; - - /* Filesystem locks are given a bit of special treatment: first we - * fixup the lock to start and end on page boundaries. */ - extent->start &= PAGE_MASK; - extent->end = (extent->end + PAGE_SIZE - 1) & PAGE_MASK; - - /* Next, search for already existing extent locks that will cover us */ - osc_con2dlmcl(oconn, &cl, &conn); - rc = ldlm_local_lock_match(ns, res_id, type, extent, mode, lockh); - if (rc == 1) { - /* We already have a lock, and it's referenced */ - return 0; - } - - /* Next, search for locks that we can upgrade (if we're trying to write) - * or are more than we need (if we're trying to read). Because the VFS - * and page cache already protect us locally, lots of readers/writers - * can share a single PW lock. */ - if (mode == LCK_PW) - mode2 = LCK_PR; - else - mode2 = LCK_PW; - - rc = ldlm_local_lock_match(ns, res_id, type, extent, mode2, lockh); - if (rc == 1) { - int flags; - struct ldlm_lock *lock = ldlm_handle2object(lockh); - /* FIXME: This is not incredibly elegant, but it might - * be more elegant than adding another parameter to - * lock_match. I want a second opinion. */ - ldlm_lock_addref(lock, mode); - ldlm_lock_decref(lock, mode2); - - if (mode == LCK_PR) - return 0; - - rc = ldlm_cli_convert(cl, lockh, type, &flags); - if (rc) - LBUG(); - - return rc; - } - - rc = ldlm_cli_enqueue(cl, conn, ns, parent_lock, res_id, type, - extent, mode, flags, data, datalen, lockh); - return rc; -} - -static int osc_cancel(struct obd_conn *oconn, __u32 mode, - struct ldlm_handle *lockh) -{ - struct ldlm_lock *lock; - ENTRY; - - lock = ldlm_handle2object(lockh); - ldlm_lock_decref(lock, mode); - - RETURN(0); -} - -static int osc_setup(struct obd_device *obddev, obd_count len, void *buf) -{ - struct osc_obd *osc = &obddev->u.osc; - int rc; - ENTRY; - - osc->osc_conn = ptlrpc_uuid_to_connection("ost"); - if (!osc->osc_conn) - RETURN(-EINVAL); - - OBD_ALLOC(osc->osc_client, sizeof(*osc->osc_client)); - if (osc->osc_client == NULL) - GOTO(out_conn, rc = -ENOMEM); - - OBD_ALLOC(osc->osc_ldlm_client, sizeof(*osc->osc_ldlm_client)); - if (osc->osc_ldlm_client == NULL) - GOTO(out_client, rc = -ENOMEM); - - ptlrpc_init_client(NULL, NULL, OST_REQUEST_PORTAL, OSC_REPLY_PORTAL, - osc->osc_client); - ptlrpc_init_client(NULL, NULL, LDLM_REQUEST_PORTAL, LDLM_REPLY_PORTAL, - osc->osc_ldlm_client); - osc->osc_client->cli_name = "osc"; - osc->osc_ldlm_client->cli_name = "ldlm"; - - MOD_INC_USE_COUNT; - RETURN(0); - - out_client: - OBD_FREE(osc->osc_client, sizeof(*osc->osc_client)); - out_conn: - ptlrpc_put_connection(osc->osc_conn); - return rc; -} - -static int osc_cleanup(struct obd_device * obddev) -{ - struct osc_obd *osc = &obddev->u.osc; - - ptlrpc_cleanup_client(osc->osc_client); - OBD_FREE(osc->osc_client, sizeof(*osc->osc_client)); - ptlrpc_cleanup_client(osc->osc_ldlm_client); - OBD_FREE(osc->osc_ldlm_client, sizeof(*osc->osc_ldlm_client)); - ptlrpc_put_connection(osc->osc_conn); - - MOD_DEC_USE_COUNT; - return 0; -} - -struct obd_ops osc_obd_ops = { - o_setup: osc_setup, - o_cleanup: osc_cleanup, - o_create: osc_create, - o_destroy: osc_destroy, - o_getattr: osc_getattr, - o_setattr: osc_setattr, - o_open: osc_open, - o_close: osc_close, - o_connect: osc_connect, - o_disconnect: osc_disconnect, - o_brw: osc_brw, - o_punch: osc_punch, - o_enqueue: osc_enqueue, - o_cancel: osc_cancel -}; - -static int __init osc_init(void) -{ - obd_register_type(&osc_obd_ops, LUSTRE_OSC_NAME); - return 0; -} - -static void __exit osc_exit(void) -{ - obd_unregister_type(LUSTRE_OSC_NAME); -} - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Lustre Object Storage Client (OSC) v1.0"); -MODULE_LICENSE("GPL"); - -module_init(osc_init); -module_exit(osc_exit); diff --git a/lustre/ost/.cvsignore b/lustre/ost/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/ost/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/ost/Makefile.am b/lustre/ost/Makefile.am deleted file mode 100644 index 4189e5f..0000000 --- a/lustre/ost/Makefile.am +++ /dev/null @@ -1,23 +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 - -DEFS:= -MODULE = ost -modulefs_DATA = ost.o -EXTRA_PROGRAMS = ost - -LINX=page.c obd_pack.c -obd_pack.c: - test -e obd_pack.c || ln -sf $(top_srcdir)/lib/obd_pack.c - -page.c: - test -e page.c || ln -sf $(top_srcdir)/lib/page.c - -ost_SOURCES = $(LINX) ost_handler.c -dist-hook: - list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done - -include $(top_srcdir)/Rules - diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c deleted file mode 100644 index 1276c8b..0000000 --- a/lustre/ost/ost_handler.c +++ /dev/null @@ -1,685 +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: 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. - * - * Storage Target Handling functions - * Lustre Object Server Module (OST) - * - * This server is single threaded at present (but can easily be multi - * threaded). For testing and management it is treated as an - * obd_device, although it does not export a full OBD method table - * (the requests are coming in over the wire, so object target - * modules do not have a full method table.) - */ - -#define EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_OST - -#include -#include -#include - -static int ost_destroy(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - req->rq_status = obd_destroy(&conn, &body->oa); - RETURN(0); -} - -static int ost_getattr(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body, *repbody; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - repbody = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); - req->rq_status = obd_getattr(&conn, &repbody->oa); - RETURN(0); -} - -static int ost_open(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body, *repbody; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - repbody = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); - req->rq_status = obd_open(&conn, &repbody->oa); - RETURN(0); -} - -static int ost_close(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body, *repbody; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - repbody = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); - req->rq_status = obd_close(&conn, &repbody->oa); - RETURN(0); -} - -static int ost_create(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body, *repbody; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - repbody = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); - req->rq_status = obd_create(&conn, &repbody->oa); - RETURN(0); -} - -static int ost_punch(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body, *repbody; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - repbody = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); - req->rq_status = obd_punch(&conn, &repbody->oa, - repbody->oa.o_size, repbody->oa.o_blocks); - RETURN(0); -} - -static int ost_setattr(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body, *repbody; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - repbody = lustre_msg_buf(req->rq_repmsg, 0); - memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); - req->rq_status = obd_setattr(&conn, &repbody->oa); - RETURN(0); -} - -static int ost_connect(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - req->rq_status = obd_connect(&conn); - - CDEBUG(D_IOCTL, "rep buffer %p, id %d\n", req->rq_repmsg, conn.oc_id); - body = lustre_msg_buf(req->rq_repmsg, 0); - body->connid = conn.oc_id; - RETURN(0); -} - -static int ost_disconnect(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body; - int rc, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - CDEBUG(D_IOCTL, "Disconnecting %d\n", conn.oc_id); - req->rq_status = obd_disconnect(&conn); - RETURN(0); -} - -static int ost_get_info(struct ost_obd *ost, struct ptlrpc_request *req) -{ - struct obd_conn conn; - struct ost_body *body; - int rc, size[2] = {sizeof(*body)}; - char *bufs[2] = {NULL, NULL}, *ptr; - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - conn.oc_id = body->connid; - conn.oc_dev = ost->ost_tgt; - - ptr = lustre_msg_buf(req->rq_reqmsg, 1); - if (!ptr) - RETURN(-EINVAL); - - req->rq_status = obd_get_info(&conn, req->rq_reqmsg->buflens[1], ptr, - &(size[1]), (void **)&(bufs[1])); - - rc = lustre_pack_msg(2, size, bufs, &req->rq_replen, &req->rq_repmsg); - if (rc) - CERROR("cannot pack reply\n"); - - RETURN(rc); -} - -static int ost_brw_read(struct ost_obd *obddev, struct ptlrpc_request *req) -{ - struct ptlrpc_bulk_desc *desc; - struct obd_conn conn; - void *tmp1, *tmp2, *end2; - struct niobuf_remote *remote_nb; - struct niobuf_local *local_nb = NULL; - struct obd_ioobj *ioo; - struct ost_body *body; - int rc, cmd, i, j, objcount, niocount, size = sizeof(*body); - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - tmp1 = lustre_msg_buf(req->rq_reqmsg, 1); - tmp2 = lustre_msg_buf(req->rq_reqmsg, 2); - end2 = (char *)tmp2 + req->rq_reqmsg->buflens[2]; - objcount = req->rq_reqmsg->buflens[1] / sizeof(*ioo); - niocount = req->rq_reqmsg->buflens[2] / sizeof(*remote_nb); - cmd = body->data; - - conn.oc_id = body->connid; - conn.oc_dev = req->rq_obd->u.ost.ost_tgt; - - for (i = 0; i < objcount; i++) { - ost_unpack_ioo(&tmp1, &ioo); - if (tmp2 + ioo->ioo_bufcnt > end2) { - LBUG(); - GOTO(out, rc = -EFAULT); - } - for (j = 0; j < ioo->ioo_bufcnt; j++) - ost_unpack_niobuf(&tmp2, &remote_nb); - } - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - OBD_ALLOC(local_nb, sizeof(*local_nb) * niocount); - if (local_nb == NULL) - RETURN(-ENOMEM); - - /* The unpackers move tmp1 and tmp2, so reset them before using */ - tmp1 = lustre_msg_buf(req->rq_reqmsg, 1); - tmp2 = lustre_msg_buf(req->rq_reqmsg, 2); - req->rq_status = obd_preprw(cmd, &conn, objcount, - tmp1, niocount, tmp2, local_nb, NULL); - - if (req->rq_status) - GOTO(out_local, 0); - - desc = ptlrpc_prep_bulk(req->rq_connection); - if (desc == NULL) - GOTO(out_local, rc = -ENOMEM); - desc->b_portal = OST_BULK_PORTAL; - - for (i = 0; i < niocount; i++) { - struct ptlrpc_bulk_page *bulk; - bulk = ptlrpc_prep_bulk_page(desc); - if (bulk == NULL) - GOTO(out_bulk, rc = -ENOMEM); - remote_nb = &(((struct niobuf_remote *)tmp2)[i]); - bulk->b_xid = remote_nb->xid; - bulk->b_buf = (void *)(unsigned long)local_nb[i].addr; - bulk->b_buflen = PAGE_SIZE; - } - - rc = ptlrpc_send_bulk(desc); - if (rc) - GOTO(out_bulk, rc); - - /* The unpackers move tmp1 and tmp2, so reset them before using */ - tmp1 = lustre_msg_buf(req->rq_reqmsg, 1); - tmp2 = lustre_msg_buf(req->rq_reqmsg, 2); - req->rq_status = obd_commitrw(cmd, &conn, objcount, - tmp1, niocount, local_nb, NULL); - -out_bulk: - ptlrpc_free_bulk(desc); -out_local: - OBD_FREE(local_nb, sizeof(*local_nb) * niocount); -out: - RETURN(rc); -} - -static int ost_brw_write_cb(struct ptlrpc_bulk_page *bulk) -{ - struct obd_ioobj obj; - struct niobuf_local lnb; - int rc; - ENTRY; - - memset(&lnb, 0, sizeof(lnb)); - memset(&obj, 0, sizeof(obj)); - - lnb.page = bulk->b_page; - lnb.dentry = bulk->b_dentry; - lnb.flags = bulk->b_flags; - obj.ioo_bufcnt = 1; - - rc = obd_commitrw(OBD_BRW_WRITE, &bulk->b_desc->b_conn, 1, &obj, 1, - &lnb, bulk->b_desc->b_desc_private); - if (rc) - CERROR("ost_commit_page failed: %d\n", rc); - - RETURN(rc); -} - -static int ost_brw_write_finished_cb(struct ptlrpc_bulk_desc *desc) -{ - ptlrpc_free_bulk(desc); - - return 0; -} - -static int ost_brw_write(struct ost_obd *obddev, struct ptlrpc_request *req) -{ - struct ptlrpc_bulk_desc *desc; - struct obd_conn conn; - struct niobuf_remote *remote_nb; - struct niobuf_local *local_nb, *lnb; - struct obd_ioobj *ioo; - struct ost_body *body; - int cmd, rc, i, j, objcount, niocount, size[2] = {sizeof(*body)}; - void *tmp1, *tmp2, *end2; - void *desc_priv = NULL; - ENTRY; - - body = lustre_msg_buf(req->rq_reqmsg, 0); - tmp1 = lustre_msg_buf(req->rq_reqmsg, 1); - tmp2 = lustre_msg_buf(req->rq_reqmsg, 2); - end2 = (char *)tmp2 + req->rq_reqmsg->buflens[2]; - objcount = req->rq_reqmsg->buflens[1] / sizeof(*ioo); - niocount = req->rq_reqmsg->buflens[2] / sizeof(*remote_nb); - cmd = body->data; - - conn.oc_id = body->connid; - conn.oc_dev = req->rq_obd->u.ost.ost_tgt; - - for (i = 0; i < objcount; i++) { - ost_unpack_ioo((void *)&tmp1, &ioo); - if (tmp2 + ioo->ioo_bufcnt > end2) { - rc = -EFAULT; - break; - } - for (j = 0; j < ioo->ioo_bufcnt; j++) - ost_unpack_niobuf((void *)&tmp2, &remote_nb); - } - - size[1] = niocount * sizeof(*remote_nb); - rc = lustre_pack_msg(2, size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - GOTO(out, rc); - remote_nb = lustre_msg_buf(req->rq_repmsg, 1); - - OBD_ALLOC(local_nb, niocount * sizeof(*local_nb)); - if (local_nb == NULL) - GOTO(out, rc = -ENOMEM); - - /* The unpackers move tmp1 and tmp2, so reset them before using */ - tmp1 = lustre_msg_buf(req->rq_reqmsg, 1); - tmp2 = lustre_msg_buf(req->rq_reqmsg, 2); - req->rq_status = obd_preprw(cmd, &conn, objcount, - tmp1, niocount, tmp2, local_nb, &desc_priv); - if (req->rq_status) - GOTO(out_free, rc = 0); /* XXX is this correct? */ - - desc = ptlrpc_prep_bulk(req->rq_connection); - if (desc == NULL) - GOTO(fail_preprw, rc = -ENOMEM); - desc->b_cb = ost_brw_write_finished_cb; - desc->b_portal = OSC_BULK_PORTAL; - desc->b_desc_private = desc_priv; - memcpy(&(desc->b_conn), &conn, sizeof(conn)); - - for (i = 0, lnb = local_nb; i < niocount; i++, lnb++) { - struct ptlrpc_service *srv = req->rq_obd->u.ost.ost_service; - struct ptlrpc_bulk_page *bulk; - - bulk = ptlrpc_prep_bulk_page(desc); - if (bulk == NULL) - GOTO(fail_bulk, rc = -ENOMEM); - - spin_lock(&srv->srv_lock); - bulk->b_xid = srv->srv_xid++; - spin_unlock(&srv->srv_lock); - - bulk->b_buf = lnb->addr; - bulk->b_page = lnb->page; - bulk->b_flags = lnb->flags; - bulk->b_dentry = lnb->dentry; - bulk->b_buflen = PAGE_SIZE; - bulk->b_cb = ost_brw_write_cb; - - /* this advances remote_nb */ - ost_pack_niobuf((void **)&remote_nb, lnb->offset, lnb->len, 0, - bulk->b_xid); - } - - rc = ptlrpc_register_bulk(desc); - if (rc) - GOTO(fail_bulk, rc); - - EXIT; -out_free: - OBD_FREE(local_nb, niocount * sizeof(*local_nb)); -out: - return rc; - -fail_bulk: - ptlrpc_free_bulk(desc); -fail_preprw: - /* FIXME: how do we undo the preprw? */ - goto out_free; -} - -static int ost_brw(struct ost_obd *obddev, struct ptlrpc_request *req) -{ - struct ost_body *body = lustre_msg_buf(req->rq_reqmsg, 0); - - if (body->data == OBD_BRW_READ) - return ost_brw_read(obddev, req); - else - return ost_brw_write(obddev, req); -} - -static int ost_handle(struct obd_device *obddev, struct ptlrpc_service *svc, - struct ptlrpc_request *req) -{ - int rc; - struct ost_obd *ost = &obddev->u.ost; - ENTRY; - - rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen); - if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_HANDLE_UNPACK)) { - CERROR("lustre_mds: Invalid request\n"); - GOTO(out, rc); - } - - if (req->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) { - CERROR("lustre_mds: wrong packet type sent %d\n", - req->rq_reqmsg->type); - GOTO(out, rc = -EINVAL); - } - - switch (req->rq_reqmsg->opc) { - case OST_CONNECT: - CDEBUG(D_INODE, "connect\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_CONNECT_NET, 0); - rc = ost_connect(ost, req); - break; - case OST_DISCONNECT: - CDEBUG(D_INODE, "disconnect\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_DISCONNECT_NET, 0); - rc = ost_disconnect(ost, req); - break; - case OST_GET_INFO: - CDEBUG(D_INODE, "get_info\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_GET_INFO_NET, 0); - rc = ost_get_info(ost, req); - break; - case OST_CREATE: - CDEBUG(D_INODE, "create\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_CREATE_NET, 0); - rc = ost_create(ost, req); - break; - case OST_DESTROY: - CDEBUG(D_INODE, "destroy\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_DESTROY_NET, 0); - rc = ost_destroy(ost, req); - break; - case OST_GETATTR: - CDEBUG(D_INODE, "getattr\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_GETATTR_NET, 0); - rc = ost_getattr(ost, req); - break; - case OST_SETATTR: - CDEBUG(D_INODE, "setattr\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_SETATTR_NET, 0); - rc = ost_setattr(ost, req); - break; - case OST_OPEN: - CDEBUG(D_INODE, "setattr\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_OPEN_NET, 0); - rc = ost_open(ost, req); - break; - case OST_CLOSE: - CDEBUG(D_INODE, "setattr\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_CLOSE_NET, 0); - rc = ost_close(ost, req); - break; - case OST_BRW: - CDEBUG(D_INODE, "brw\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_BRW_NET, 0); - rc = ost_brw(ost, req); - break; - case OST_PUNCH: - CDEBUG(D_INODE, "punch\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_PUNCH_NET, 0); - rc = ost_punch(ost, req); - break; -#if 0 - case OST_STATFS: - CDEBUG(D_INODE, "statfs\n"); - OBD_FAIL_RETURN(OBD_FAIL_OST_STATFS_NET, 0); - rc = ost_statfs(ost, req); - break; -#endif - default: - req->rq_status = -ENOTSUPP; - rc = ptlrpc_error(svc, req); - RETURN(rc); - } - - EXIT; -out: - //req->rq_status = rc; - if (rc) { - CERROR("ost: processing error %d\n", rc); - ptlrpc_error(svc, req); - } else { - CDEBUG(D_INODE, "sending reply\n"); - ptlrpc_reply(svc, req); - } - - return 0; -} - -/* mount the file system (secretly) */ -static int ost_setup(struct obd_device *obddev, obd_count len, void *buf) -{ - struct obd_ioctl_data* data = buf; - struct ost_obd *ost = &obddev->u.ost; - struct obd_device *tgt; - int err; - ENTRY; - - if (data->ioc_dev < 0 || data->ioc_dev > MAX_OBD_DEVICES) - RETURN(-ENODEV); - - MOD_INC_USE_COUNT; - tgt = &obd_dev[data->ioc_dev]; - ost->ost_tgt = tgt; - if (!(tgt->obd_flags & OBD_ATTACHED) || - !(tgt->obd_flags & OBD_SET_UP)) { - CERROR("device not attached or not set up (%d)\n", - data->ioc_dev); - GOTO(error_dec, err = -EINVAL); - } - - ost->ost_conn.oc_dev = tgt; - err = obd_connect(&ost->ost_conn); - if (err) { - CERROR("fail to connect to device %d\n", data->ioc_dev); - GOTO(error_dec, err = -EINVAL); - } - - ost->ost_service = ptlrpc_init_svc(128 * 1024, - OST_REQUEST_PORTAL, OSC_REPLY_PORTAL, - "self", ost_handle); - if (!ost->ost_service) { - CERROR("failed to start service\n"); - GOTO(error_disc, err = -EINVAL); - } - - err = ptlrpc_start_thread(obddev, ost->ost_service, "lustre_ost"); - if (err) - GOTO(error_disc, err = -EINVAL); - err = ptlrpc_start_thread(obddev, ost->ost_service, "lustre_ost"); - if (err) - GOTO(error_disc, err = -EINVAL); - - RETURN(0); - -error_disc: - obd_disconnect(&ost->ost_conn); -error_dec: - MOD_DEC_USE_COUNT; - RETURN(err); -} - -static int ost_cleanup(struct obd_device * obddev) -{ - struct ost_obd *ost = &obddev->u.ost; - int err; - - ENTRY; - - if ( !list_empty(&obddev->obd_gen_clients) ) { - CERROR("still has clients!\n"); - RETURN(-EBUSY); - } - - ptlrpc_stop_all_threads(ost->ost_service); - rpc_unregister_service(ost->ost_service); - - if (!list_empty(&ost->ost_service->srv_reqs)) { - // XXX reply with errors and clean up - CERROR("Request list not empty!\n"); - } - OBD_FREE(ost->ost_service, sizeof(*ost->ost_service)); - - err = obd_disconnect(&ost->ost_conn); - if (err) { - CERROR("lustre ost: fail to disconnect device\n"); - RETURN(-EINVAL); - } - - MOD_DEC_USE_COUNT; - RETURN(0); -} - -/* use obd ops to offer management infrastructure */ -static struct obd_ops ost_obd_ops = { - o_setup: ost_setup, - o_cleanup: ost_cleanup, -}; - -static int __init ost_init(void) -{ - obd_register_type(&ost_obd_ops, LUSTRE_OST_NAME); - return 0; -} - -static void __exit ost_exit(void) -{ - obd_unregister_type(LUSTRE_OST_NAME); -} - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Lustre Object Storage Target (OST) v0.01"); -MODULE_LICENSE("GPL"); - -module_init(ost_init); -module_exit(ost_exit); diff --git a/lustre/patches/.cvsignore b/lustre/patches/.cvsignore deleted file mode 100644 index e530020..0000000 --- a/lustre/patches/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/patches/intent-lock.patch b/lustre/patches/intent-lock.patch deleted file mode 100644 index a476fc3..0000000 --- a/lustre/patches/intent-lock.patch +++ /dev/null @@ -1,739 +0,0 @@ ---- linux/include/linux/fs.h.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/include/linux/fs.h Tue Jun 4 09:24:48 2002 -@@ -314,8 +314,8 @@ - #include - #include - #include --#include - #include -+#include - #include - - /* -@@ -506,8 +506,8 @@ - struct proc_inode_info proc_i; - struct socket socket_i; - struct usbdev_inode_info usbdev_i; -- struct hostfs_inode_info hostfs_i; - struct jffs2_inode_info jffs2_i; -+ struct hostfs_inode_info hostfs_i; - void *generic_ip; - } u; - }; -@@ -536,6 +536,7 @@ - - /* needed for tty driver, and maybe others */ - void *private_data; -+ struct lookup_intent *f_intent; - - /* preallocated helper kiobuf to speedup O_DIRECT */ - struct kiobuf *f_iobuf; -@@ -779,7 +780,9 @@ - extern int vfs_link(struct dentry *, struct inode *, struct dentry *); - extern int vfs_rmdir(struct inode *, struct dentry *); - extern int vfs_unlink(struct inode *, struct dentry *); --extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); -+int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it); - - /* - * File types -@@ -840,6 +843,7 @@ - struct inode_operations { - int (*create) (struct inode *,struct dentry *,int); - struct dentry * (*lookup) (struct inode *,struct dentry *); -+ struct dentry * (*lookup2) (struct inode *,struct dentry *, struct lookup_intent *); - int (*link) (struct dentry *,struct inode *,struct dentry *); - int (*unlink) (struct inode *,struct dentry *); - int (*symlink) (struct inode *,struct dentry *,const char *); -@@ -855,6 +859,10 @@ - int (*revalidate) (struct dentry *); - int (*setattr) (struct dentry *, struct iattr *); - int (*getattr) (struct dentry *, struct iattr *); -+ int (*setxattr) (struct dentry *, const char *, void *, size_t, int); -+ ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); -+ ssize_t (*listxattr) (struct dentry *, char *, size_t); -+ int (*removexattr) (struct dentry *, const char *); - }; - - struct seq_file; -@@ -1307,6 +1315,7 @@ - extern loff_t default_llseek(struct file *file, loff_t offset, int origin); - - extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *)); -+extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it)); - extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *)); - extern int FASTCALL(path_walk(const char *, struct nameidata *)); - extern int FASTCALL(link_path_walk(const char *, struct nameidata *)); -@@ -1317,6 +1326,8 @@ - extern struct dentry * lookup_hash(struct qstr *, struct dentry *); - #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd) - #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd) -+#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it) -+#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it) - - extern void iput(struct inode *); - extern void force_delete(struct inode *); ---- linux/include/linux/dcache.h.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/include/linux/dcache.h Tue Jun 4 09:24:45 2002 -@@ -6,6 +6,28 @@ - #include - #include - -+#define IT_OPEN (1) -+#define IT_CREAT (1<<1) -+#define IT_MKDIR (1<<2) -+#define IT_LINK (1<<3) -+#define IT_SYMLINK (1<<4) -+#define IT_UNLINK (1<<5) -+#define IT_RMDIR (1<<6) -+#define IT_RENAME (1<<7) -+#define IT_READDIR (1<<8) -+#define IT_GETATTR (1<<9) -+#define IT_SETATTR (1<<10) -+#define IT_READLINK (1<<11) -+ -+struct lookup_intent { -+ int it_op; -+ int it_mode; -+ int it_disposition; -+ int it_status; -+ struct iattr *it_iattr; -+ void *it_data; -+}; -+ - /* - * linux/include/linux/dcache.h - * -@@ -79,17 +101,20 @@ - struct dentry_operations *d_op; - struct super_block * d_sb; /* The root of the dentry tree */ - unsigned long d_vfs_flags; -+ struct lookup_intent *d_it; - void * d_fsdata; /* fs-specific data */ - unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */ - }; - - struct dentry_operations { - int (*d_revalidate)(struct dentry *, int); -+ int (*d_revalidate2)(struct dentry *, int, struct lookup_intent *); - int (*d_hash) (struct dentry *, struct qstr *); - int (*d_compare) (struct dentry *, struct qstr *, struct qstr *); - int (*d_delete)(struct dentry *); - void (*d_release)(struct dentry *); - void (*d_iput)(struct dentry *, struct inode *); -+ void (*d_intent_rel)(struct dentry *); - }; - - /* the dentry parameter passed to d_hash and d_compare is the parent ---- linux/fs/namei.c.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/fs/namei.c Mon Jun 3 16:14:56 2002 -@@ -94,6 +94,14 @@ - * XEmacs seems to be relying on it... - */ - -+void intent_release(struct dentry *de) -+{ -+ if (de->d_op && de->d_op->d_intent_rel) -+ de->d_op->d_intent_rel(de); -+ de->d_it = NULL; -+} -+ -+ - /* In order to reduce some races, while at the same time doing additional - * checking and hopefully speeding things up, we copy filenames to the - * kernel data space before using them.. -@@ -260,10 +268,18 @@ - * Internal lookup() using the new generic dcache. - * SMP-safe - */ --static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags) -+static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it) - { - struct dentry * dentry = d_lookup(parent, name); - -+ if (dentry && dentry->d_op && dentry->d_op->d_revalidate2) { -+ if (!dentry->d_op->d_revalidate2(dentry, flags, it) && !d_invalidate(dentry)) { -+ dput(dentry); -+ dentry = NULL; -+ } -+ return dentry; -+ } -+ - if (dentry && dentry->d_op && dentry->d_op->d_revalidate) { - if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) { - dput(dentry); -@@ -281,7 +297,7 @@ - * make sure that nobody added the entry to the dcache in the meantime.. - * SMP-safe - */ --static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags) -+static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it) - { - struct dentry * result; - struct inode *dir = parent->d_inode; -@@ -300,6 +316,9 @@ - result = ERR_PTR(-ENOMEM); - if (dentry) { - lock_kernel(); -+ if (dir->i_op->lookup2) -+ result = dir->i_op->lookup2(dir, dentry, it); -+ else - result = dir->i_op->lookup(dir, dentry); - unlock_kernel(); - if (result) -@@ -322,6 +341,12 @@ - result = ERR_PTR(-ENOENT); - } - } -+ if (result->d_op && result->d_op->d_revalidate2) { -+ if (!result->d_op->d_revalidate2(result, flags, it) && !d_invalidate(result)) { -+ dput(result); -+ result = ERR_PTR(-ENOENT); -+ } -+ } - return result; - } - -@@ -445,7 +470,7 @@ - * - * We expect 'base' to be positive and a directory. - */ --int link_path_walk(const char * name, struct nameidata *nd) -+int link_path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it) - { - struct dentry *dentry; - struct inode *inode; -@@ -518,9 +543,9 @@ - break; - } - /* This does the actual lookups.. */ -- dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE); -+ dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL); - if (!dentry) { -- dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE); -+ dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL); - err = PTR_ERR(dentry); - if (IS_ERR(dentry)) - break; -@@ -554,7 +579,7 @@ - nd->dentry = dentry; - } - err = -ENOTDIR; -- if (!inode->i_op->lookup) -+ if (!inode->i_op->lookup && !inode->i_op->lookup2) - break; - continue; - /* here ends the main loop */ -@@ -581,9 +606,9 @@ - if (err < 0) - break; - } -- dentry = cached_lookup(nd->dentry, &this, 0); -+ dentry = cached_lookup(nd->dentry, &this, 0, it); - if (!dentry) { -- dentry = real_lookup(nd->dentry, &this, 0); -+ dentry = real_lookup(nd->dentry, &this, 0, it); - err = PTR_ERR(dentry); - if (IS_ERR(dentry)) - break; -@@ -607,7 +632,8 @@ - goto no_inode; - if (lookup_flags & LOOKUP_DIRECTORY) { - err = -ENOTDIR; -- if (!inode->i_op || !inode->i_op->lookup) -+ if (!inode->i_op || (!inode->i_op->lookup && -+ !inode->i_op->lookup2)) - break; - } - goto return_base; -@@ -636,12 +662,24 @@ - return err; - } - -+int link_path_walk(const char * name, struct nameidata *nd) -+{ -+ return link_path_walk_it(name, nd, NULL); -+} -+ -+int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it) -+{ -+ current->total_link_count = 0; -+ return link_path_walk_it(name, nd, it); -+} -+ - int path_walk(const char * name, struct nameidata *nd) - { - current->total_link_count = 0; -- return link_path_walk(name, nd); -+ return link_path_walk_it(name, nd, NULL); - } - -+ - /* SMP-safe */ - /* returns 1 if everything is done */ - static int __emul_lookup_dentry(const char *name, struct nameidata *nd) -@@ -742,7 +780,8 @@ - * needs parent already locked. Doesn't follow mounts. - * SMP-safe. - */ --struct dentry * lookup_hash(struct qstr *name, struct dentry * base) -+struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base, -+ struct lookup_intent *it) - { - struct dentry * dentry; - struct inode *inode; -@@ -765,13 +804,16 @@ - goto out; - } - -- dentry = cached_lookup(base, name, 0); -+ dentry = cached_lookup(base, name, 0, it); - if (!dentry) { - struct dentry *new = d_alloc(base, name); - dentry = ERR_PTR(-ENOMEM); - if (!new) - goto out; - lock_kernel(); -+ if (inode->i_op->lookup2) -+ dentry = inode->i_op->lookup2(inode, new, it); -+ else - dentry = inode->i_op->lookup(inode, new); - unlock_kernel(); - if (!dentry) -@@ -783,6 +825,12 @@ - return dentry; - } - -+struct dentry * lookup_hash(struct qstr *name, struct dentry * base) -+{ -+ return lookup_hash_it(name, base, NULL); -+} -+ -+ - /* SMP-safe */ - struct dentry * lookup_one_len(const char * name, struct dentry * base, int len) - { -@@ -804,7 +852,7 @@ - } - this.hash = end_name_hash(hash); - -- return lookup_hash(&this, base); -+ return lookup_hash_it(&this, base, NULL); - access: - return ERR_PTR(-EACCES); - } -@@ -836,6 +884,22 @@ - return err; - } - -+int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd, struct lookup_intent *it) -+{ -+ char *tmp; -+ int err; -+ -+ tmp = getname(name); -+ err = PTR_ERR(tmp); -+ if (!IS_ERR(tmp)) { -+ err = 0; -+ if (path_init(tmp, flags, nd)) -+ err = path_walk_it(tmp, nd, it); -+ putname(tmp); -+ } -+ return err; -+} -+ - /* - * It's inline, so penalty for filesystems that don't use sticky bit is - * minimal. -@@ -970,7 +1034,8 @@ - * for symlinks (where the permissions are checked later). - * SMP-safe - */ --int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) -+int open_namei_it(const char * pathname, int flag, int mode, struct nameidata *nd, -+ struct lookup_intent *it) - { - int acc_mode, error = 0; - struct inode *inode; -@@ -984,8 +1049,9 @@ - * The simplest case - just a plain lookup. - */ - if (!(flag & O_CREAT)) { -+ - if (path_init(pathname, lookup_flags(flag), nd)) -- error = path_walk(pathname, nd); -+ error = path_walk_it(pathname, nd, it); - if (error) - return error; - dentry = nd->dentry; -@@ -995,6 +1061,8 @@ - /* - * Create - we need to know the parent. - */ -+ if (it) -+ it->it_op |= IT_CREAT; - if (path_init(pathname, LOOKUP_PARENT, nd)) - error = path_walk(pathname, nd); - if (error) -@@ -1011,7 +1079,7 @@ - - dir = nd->dentry; - down(&dir->d_inode->i_sem); -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, it); - - do_last: - error = PTR_ERR(dentry); -@@ -1022,6 +1090,7 @@ - - /* Negative dentry, just create the file */ - if (!dentry->d_inode) { -+ dentry->d_it = it; - error = vfs_create(dir->d_inode, dentry, - mode & ~current->fs->umask); - up(&dir->d_inode->i_sem); -@@ -1181,13 +1250,20 @@ - } - dir = nd->dentry; - down(&dir->d_inode->i_sem); -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, NULL); - putname(nd->last.name); - goto do_last; - } - -+int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) -+{ -+ return open_namei_it(pathname, flag, mode, nd, NULL); -+} -+ -+ - /* SMP-safe */ --static struct dentry *lookup_create(struct nameidata *nd, int is_dir) -+static struct dentry *lookup_create(struct nameidata *nd, int is_dir, -+ struct lookup_intent *it) - { - struct dentry *dentry; - -@@ -1195,7 +1271,7 @@ - dentry = ERR_PTR(-EEXIST); - if (nd->last_type != LAST_NORM) - goto fail; -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, it); - if (IS_ERR(dentry)) - goto fail; - if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) -@@ -1241,6 +1317,7 @@ - char * tmp; - struct dentry * dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_CREAT , mode }; - - if (S_ISDIR(mode)) - return -EPERM; -@@ -1252,11 +1329,12 @@ - error = path_walk(tmp, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 0); -+ dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(dentry); - - mode &= ~current->fs->umask; - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - switch (mode & S_IFMT) { - case 0: case S_IFREG: - error = vfs_create(nd.dentry->d_inode,dentry,mode); -@@ -1272,6 +1350,7 @@ - } - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1310,6 +1389,7 @@ - { - int error = 0; - char * tmp; -+ struct lookup_intent it = { IT_MKDIR, mode }; - - tmp = getname(pathname); - error = PTR_ERR(tmp); -@@ -1321,13 +1401,15 @@ - error = path_walk(tmp, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 1); -+ dentry = lookup_create(&nd, 1, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_mkdir(nd.dentry->d_inode, dentry, - mode & ~current->fs->umask); - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1407,6 +1489,7 @@ - char * name; - struct dentry *dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_RMDIR, 0 }; - - name = getname(pathname); - if(IS_ERR(name)) -@@ -1429,10 +1512,12 @@ - goto exit1; - } - down(&nd.dentry->d_inode->i_sem); -- dentry = lookup_hash(&nd.last, nd.dentry); -+ dentry = lookup_hash_it(&nd.last, nd.dentry, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_rmdir(nd.dentry->d_inode, dentry); -+ intent_release(dentry); - dput(dentry); - } - up(&nd.dentry->d_inode->i_sem); -@@ -1476,6 +1561,7 @@ - char * name; - struct dentry *dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_UNLINK, 0 }; - - name = getname(pathname); - if(IS_ERR(name)) -@@ -1489,14 +1575,16 @@ - if (nd.last_type != LAST_NORM) - goto exit1; - down(&nd.dentry->d_inode->i_sem); -- dentry = lookup_hash(&nd.last, nd.dentry); -+ dentry = lookup_hash_it(&nd.last, nd.dentry, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - /* Why not before? Because we want correct error value */ - if (nd.last.name[nd.last.len]) - goto slashes; - error = vfs_unlink(nd.dentry->d_inode, dentry); - exit2: -+ intent_release(dentry); - dput(dentry); - } - up(&nd.dentry->d_inode->i_sem); -@@ -1543,6 +1631,7 @@ - int error = 0; - char * from; - char * to; -+ struct lookup_intent it = { IT_SYMLINK, 0 }; - - from = getname(oldname); - if(IS_ERR(from)) -@@ -1557,12 +1646,14 @@ - error = path_walk(to, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 0); -+ dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_symlink(nd.dentry->d_inode, dentry, from); - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1626,6 +1717,7 @@ - int error; - char * from; - char * to; -+ struct lookup_intent it = { IT_LINK, 0 }; - - from = getname(oldname); - if(IS_ERR(from)) -@@ -1648,12 +1740,14 @@ - error = -EXDEV; - if (old_nd.mnt != nd.mnt) - goto out_release; -- new_dentry = lookup_create(&nd, 0); -+ new_dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(new_dentry); - if (!IS_ERR(new_dentry)) { -+ new_dentry->d_it = ⁢ - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); - dput(new_dentry); - } -+ intent_release(new_dentry); - up(&nd.dentry->d_inode->i_sem); - out_release: - path_release(&nd); -@@ -1694,7 +1788,8 @@ - * locking]. - */ - int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - struct inode *target; -@@ -1748,12 +1843,14 @@ - } else - double_down(&old_dir->i_zombie, - &new_dir->i_zombie); -+ new_dentry->d_it = it; - if (IS_DEADDIR(old_dir)||IS_DEADDIR(new_dir)) - error = -ENOENT; - else if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) - error = -EBUSY; - else - error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); -+ intent_release(new_dentry); - if (target) { - if (!error) - target->i_flags |= S_DEAD; -@@ -1775,7 +1872,8 @@ - } - - int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - -@@ -1802,10 +1900,12 @@ - DQUOT_INIT(old_dir); - DQUOT_INIT(new_dir); - double_down(&old_dir->i_zombie, &new_dir->i_zombie); -+ new_dentry->d_it = it; - if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) - error = -EBUSY; - else - error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); -+ intent_release(new_dentry); - double_up(&old_dir->i_zombie, &new_dir->i_zombie); - if (error) - return error; -@@ -1817,13 +1917,14 @@ - } - - int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - if (S_ISDIR(old_dentry->d_inode->i_mode)) -- error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry); -+ error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry, it); - else -- error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); -+ error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry, it); - if (!error) { - if (old_dir == new_dir) - inode_dir_notify(old_dir, DN_RENAME); -@@ -1841,6 +1942,7 @@ - struct dentry * old_dir, * new_dir; - struct dentry * old_dentry, *new_dentry; - struct nameidata oldnd, newnd; -+ struct lookup_intent it = {IT_RENAME, 0}; - - if (path_init(oldname, LOOKUP_PARENT, &oldnd)) - error = path_walk(oldname, &oldnd); -@@ -1868,7 +1970,9 @@ - - double_lock(new_dir, old_dir); - -- old_dentry = lookup_hash(&oldnd.last, old_dir); -+ it.it_op = IT_RENAME; -+ it.it_mode = 0; -+ old_dentry = lookup_hash_it(&oldnd.last, old_dir, &it); - error = PTR_ERR(old_dentry); - if (IS_ERR(old_dentry)) - goto exit3; -@@ -1884,14 +1988,14 @@ - if (newnd.last.name[newnd.last.len]) - goto exit4; - } -- new_dentry = lookup_hash(&newnd.last, new_dir); -+ new_dentry = lookup_hash_it(&newnd.last, new_dir, &it); - error = PTR_ERR(new_dentry); - if (IS_ERR(new_dentry)) - goto exit4; - - lock_kernel(); - error = vfs_rename(old_dir->d_inode, old_dentry, -- new_dir->d_inode, new_dentry); -+ new_dir->d_inode, new_dentry, &it); - unlock_kernel(); - - dput(new_dentry); ---- linux/fs/open.c.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/fs/open.c Wed May 22 08:29:48 2002 -@@ -630,10 +630,15 @@ - * for the internal routines (ie open_namei()/follow_link() etc). 00 is - * used by symlinks. - */ -+extern int open_namei_it(const char *filename, int namei_flags, int mode, -+ struct nameidata *nd, struct lookup_intent *it); -+struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it); -+ - struct file *filp_open(const char * filename, int flags, int mode) - { - int namei_flags, error; - struct nameidata nd; -+ struct lookup_intent it = {IT_OPEN, 0}; - - namei_flags = flags; - if ((namei_flags+1) & O_ACCMODE) -@@ -641,14 +646,14 @@ - if (namei_flags & O_TRUNC) - namei_flags |= 2; - -- error = open_namei(filename, namei_flags, mode, &nd); -+ error = open_namei_it(filename, namei_flags, mode, &nd, &it); - if (!error) -- return dentry_open(nd.dentry, nd.mnt, flags); -+ return dentry_open_it(nd.dentry, nd.mnt, flags, &it); - - return ERR_PTR(error); - } - --struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) -+struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it) - { - struct file * f; - struct inode *inode; -@@ -690,6 +695,7 @@ - goto cleanup_all; - } - f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); -+ f->f_intent = it; - - return f; - -@@ -710,6 +716,13 @@ - return ERR_PTR(error); - } - -+struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) -+{ -+ return dentry_open_it(dentry, mnt, flags, NULL); -+ -+} -+ -+ - /* - * Find an empty file descriptor entry, and mark it busy. - */ diff --git a/lustre/patches/patch-2.2.10 b/lustre/patches/patch-2.2.10 deleted file mode 100644 index 62cd23c..0000000 --- a/lustre/patches/patch-2.2.10 +++ /dev/null @@ -1,51 +0,0 @@ ---- linux-2.2.10/include/linux/fs.h.org Tue Aug 3 15:09:33 1999 -+++ linux-2.2.10/include/linux/fs.h Tue Aug 3 15:10:34 1999 -@@ -897,6 +897,9 @@ - #include - #include - -+struct super_block *get_empty_super(void); -+void remove_vfsmnt(kdev_t dev); -+ - #endif /* __KERNEL__ */ - - #endif ---- linux-2.2.10/fs/super.c.org Tue Aug 3 15:08:09 1999 -+++ linux-2.2.10/fs/super.c Tue Aug 3 15:10:41 1999 -@@ -135,7 +135,7 @@ - return lptr; - } - --static void remove_vfsmnt(kdev_t dev) -+void remove_vfsmnt(kdev_t dev) - { - struct vfsmount *lptr, *tofree; - -@@ -508,7 +508,7 @@ - /* - * Find a super_block with no device assigned. - */ --static struct super_block *get_empty_super(void) -+struct super_block *get_empty_super(void) - { - struct super_block *s; - ---- linux-2.2.10/kernel/ksyms.c.org Tue Aug 3 15:10:55 1999 -+++ linux-2.2.10/kernel/ksyms.c Tue Aug 3 15:11:56 1999 -@@ -78,6 +78,16 @@ - #endif - EXPORT_SYMBOL(get_options); - -+/* obd stuff */ -+ -+ -+ -+EXPORT_SYMBOL(get_empty_super); -+EXPORT_SYMBOL(remove_vfsmnt); -+ -+ -+ -+ - /* process memory management */ - EXPORT_SYMBOL(do_mmap); - EXPORT_SYMBOL(do_munmap); diff --git a/lustre/patches/patch-2.3.15 b/lustre/patches/patch-2.3.15 deleted file mode 100644 index ba02eb1..0000000 --- a/lustre/patches/patch-2.3.15 +++ /dev/null @@ -1,43 +0,0 @@ ---- linux-2.2.10/include/linux/fs.h.org Tue Aug 3 15:09:33 1999 -+++ linux-2.2.10/include/linux/fs.h Tue Aug 3 15:10:34 1999 -@@ -897,6 +897,9 @@ - #include - #include - -+struct super_block *get_empty_super(void); -+void remove_vfsmnt(kdev_t dev); -+ - #endif /* __KERNEL__ */ - - #endif ---- linux-2.2.10/fs/super.c.org Tue Aug 3 15:08:09 1999 -+++ linux-2.2.10/fs/super.c Tue Aug 3 15:10:41 1999 -@@ -135,7 +135,7 @@ - return lptr; - } - --static void remove_vfsmnt(kdev_t dev) -+void remove_vfsmnt(kdev_t dev) - { - struct vfsmount *lptr, *tofree; - -@@ -508,7 +508,7 @@ - /* - * Find a super_block with no device assigned. - */ --static struct super_block *get_empty_super(void) -+struct super_block *get_empty_super(void) - { - struct super_block *s; - ---- linux/kernel/ksyms.c.org Tue Aug 31 05:25:11 1999 -+++ linux/kernel/ksyms.c Tue Aug 31 05:31:31 1999 -@@ -114,6 +114,8 @@ - EXPORT_SYMBOL(init_mm); - - /* filesystem internal functions */ -+EXPORT_SYMBOL(get_empty_super); -+EXPORT_SYMBOL(remove_vfsmnt); - EXPORT_SYMBOL(in_group_p); - EXPORT_SYMBOL(update_atime); - EXPORT_SYMBOL(get_super); diff --git a/lustre/patches/patch-2.3.21 b/lustre/patches/patch-2.3.21 deleted file mode 100644 index 2914b2d..0000000 --- a/lustre/patches/patch-2.3.21 +++ /dev/null @@ -1,60 +0,0 @@ ---- linux/include/linux/fs.h.org Tue Oct 12 10:39:59 1999 -+++ linux/include/linux/fs.h Tue Oct 12 11:32:46 1999 -@@ -934,6 +934,8 @@ - - - extern struct super_block *get_super(kdev_t); -+struct super_block *get_empty_super(void); -+void remove_vfsmnt(kdev_t dev); - extern void put_super(kdev_t); - unsigned long generate_cluster(kdev_t, int b[], int); - unsigned long generate_cluster_swab32(kdev_t, int b[], int); ---- linux/fs/super.c.org Tue Oct 12 10:39:05 1999 -+++ linux/fs/super.c Tue Oct 12 11:18:14 1999 -@@ -135,7 +135,7 @@ - return lptr; - } - --static void remove_vfsmnt(kdev_t dev) -+void remove_vfsmnt(kdev_t dev) - { - struct vfsmount *lptr, *tofree; - -@@ -508,7 +508,7 @@ - /* - * Find a super_block with no device assigned. - */ --static struct super_block *get_empty_super(void) -+struct super_block *get_empty_super(void) - { - struct super_block *s; - ---- linux/kernel/ksyms.c.or Tue Oct 12 10:40:21 1999 -+++ linux/kernel/ksyms.c Tue Oct 12 11:22:45 1999 -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -118,6 +119,8 @@ - EXPORT_SYMBOL(update_atime); - EXPORT_SYMBOL(get_super); - EXPORT_SYMBOL(get_fs_type); -+EXPORT_SYMBOL(get_empty_super); -+EXPORT_SYMBOL(remove_vfsmnt); - EXPORT_SYMBOL(getname); - EXPORT_SYMBOL(_fput); - EXPORT_SYMBOL(igrab); -@@ -140,6 +143,9 @@ - EXPORT_SYMBOL(d_path); - EXPORT_SYMBOL(__mark_buffer_dirty); - EXPORT_SYMBOL(__mark_inode_dirty); -+EXPORT_SYMBOL(free_kiovec); -+EXPORT_SYMBOL(brw_kiovec); -+EXPORT_SYMBOL(alloc_kiovec); - EXPORT_SYMBOL(get_empty_filp); - EXPORT_SYMBOL(init_private_file); - EXPORT_SYMBOL(filp_open); diff --git a/lustre/patches/patch-2.4.16 b/lustre/patches/patch-2.4.16 deleted file mode 100644 index 8e0c915..0000000 --- a/lustre/patches/patch-2.4.16 +++ /dev/null @@ -1,161 +0,0 @@ ---- /usr/src/linux-2.4.16/fs/reiserfs/file.c.obd-orig Thu Dec 13 14:35:00 2001 -+++ /usr/src/linux-2.4.16/fs/reiserfs/file.c Thu Dec 13 14:35:08 2001 -@@ -28,8 +28,8 @@ - struct reiserfs_transaction_handle th ; - int windex ; - -- if (!S_ISREG (inode->i_mode)) -- BUG (); -+ //if (!S_ISREG (inode->i_mode)) -+ //BUG (); - - /* fast out for when nothing needs to be done */ - if ((atomic_read(&inode->i_count) > 1 || ---- /usr/src/linux-2.4.16/fs/namespace.c.obd-orig Tue Dec 11 20:44:15 2001 -+++ /usr/src/linux-2.4.16/fs/namespace.c Tue Dec 11 20:44:35 2001 -@@ -332,7 +332,7 @@ - } - } - --static int do_umount(struct vfsmount *mnt, int flags) -+int do_umount(struct vfsmount *mnt, int flags) - { - struct super_block * sb = mnt->mnt_sb; - int retval = 0; ---- /usr/src/linux-2.4.16/kernel/ksyms.c.obd-orig Tue Dec 11 14:22:09 2001 -+++ /usr/src/linux-2.4.16/kernel/ksyms.c Tue Dec 11 18:05:30 2001 -@@ -268,6 +268,7 @@ - EXPORT_SYMBOL(__pollwait); - EXPORT_SYMBOL(poll_freewait); - EXPORT_SYMBOL(ROOT_DEV); -+EXPORT_SYMBOL(pagecache_lock); - EXPORT_SYMBOL(__find_get_page); - EXPORT_SYMBOL(__find_lock_page); - EXPORT_SYMBOL(grab_cache_page); ---- /usr/src/linux-2.4.16/mm/filemap.c.obd-orig Mon Nov 26 06:29:17 2001 -+++ /usr/src/linux-2.4.16/mm/filemap.c Tue Dec 11 14:29:50 2001 -@@ -2846,8 +2846,7 @@ - * file system has to do this all by itself, unfortunately. - * okir@monad.swb.de - */ --ssize_t --generic_file_write(struct file *file,const char *buf,size_t count, loff_t *ppos) -+ssize_t do_generic_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos, int (*actor)(char *, char *, size_t )) - { - struct address_space *mapping = file->f_dentry->d_inode->i_mapping; - struct inode *inode = mapping->host; -@@ -2862,8 +2861,10 @@ - if ((ssize_t) count < 0) - return -EINVAL; - -+#if 0 - if (!access_ok(VERIFY_READ, buf, count)) - return -EFAULT; -+#endif - - cached_page = NULL; - -@@ -2987,10 +2988,12 @@ - * same page as we're writing to, without it being marked - * up-to-date. - */ -+#if 0 - { volatile unsigned char dummy; - __get_user(dummy, buf); - __get_user(dummy, buf+bytes-1); - } -+#endif - - status = -ENOMEM; /* we'll assign it later anyway */ - page = __grab_cache_page(mapping, index, &cached_page); -@@ -3006,7 +3009,7 @@ - status = mapping->a_ops->prepare_write(file, page, offset, offset+bytes); - if (status) - goto unlock; -- page_fault = __copy_from_user(kaddr+offset, buf, bytes); -+ page_fault = actor(kaddr+offset, buf, bytes); - flush_dcache_page(page); - status = mapping->a_ops->commit_write(file, page, offset, offset+bytes); - if (page_fault) -@@ -3072,6 +3075,23 @@ - goto out_status; - } - -+ -+static inline int actor_from_user(char *dst, char *src, size_t len) -+{ -+ if (!access_ok(VERIFY_READ, src, len)) -+ return -EFAULT; -+ -+ return __copy_from_user(dst, src, len); -+} -+ -+ssize_t -+generic_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos) -+{ -+ return do_generic_file_write(file, buf, count, ppos, &actor_from_user); -+} -+ -+ -+ - void __init page_cache_init(unsigned long mempages) - { - unsigned long htable_size, order; ---- /usr/src/linux-2.4.16/include/linux/fs.h.obd-orig Tue Dec 11 14:23:29 2001 -+++ /usr/src/linux-2.4.16/include/linux/fs.h Tue Dec 11 20:45:00 2001 -@@ -978,8 +978,10 @@ - extern int register_filesystem(struct file_system_type *); - extern int unregister_filesystem(struct file_system_type *); - extern struct vfsmount *kern_mount(struct file_system_type *); -+struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data); - extern int may_umount(struct vfsmount *); - extern long do_mount(char *, char *, char *, unsigned long, void *); -+int do_umount(struct vfsmount *mnt, int flags); - - #define kern_umount mntput - -@@ -1044,6 +1046,35 @@ - - asmlinkage long sys_open(const char *, int, int); - asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */ -+asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t count); -+asmlinkage ssize_t sys_write(unsigned int fd, const char * buf, size_t count); -+asmlinkage long sys_truncate64(const char * path, loff_t length); -+asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length); -+asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type, -+ unsigned long flags, void * data); -+asmlinkage long sys_umount(char * name, int flags); -+asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf); -+asmlinkage long sys_mknod(const char * filename, int mode, dev_t dev); -+asmlinkage long sys_mkdir(const char * pathname, int mode); -+asmlinkage long sys_rmdir(const char * pathname); -+asmlinkage long sys_unlink(const char * pathname); -+asmlinkage long sys_symlink(const char * oldname, const char * newname); -+asmlinkage long sys_link(const char * oldname, const char * newname); -+asmlinkage long sys_rename(const char * oldname, const char * newname); -+asmlinkage long sys_lstat64(char * filename, struct stat64 * statbuf, long flags); -+asmlinkage long sys_stat64(char * filename, struct stat64 * statbuf, long flags); -+asmlinkage long sys_fstat64(unsigned long fd, struct stat64 * statbuf, long flags); -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - extern int do_truncate(struct dentry *, loff_t start); - - extern struct file *filp_open(const char *, int, int); -@@ -1395,6 +1426,8 @@ - extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *); - extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *); - extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t); -+ssize_t do_generic_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos, int (*actor)(char *, char *, size_t )); -+ - extern loff_t no_llseek(struct file *file, loff_t offset, int origin); - extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin); - extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *); diff --git a/lustre/patches/patch-2.4.17 b/lustre/patches/patch-2.4.17 deleted file mode 100644 index e51138c..0000000 --- a/lustre/patches/patch-2.4.17 +++ /dev/null @@ -1,47 +0,0 @@ ---- linux-2.4.17/kernel/ksyms.c.lustre Fri Feb 22 15:26:38 2002 -+++ linux-2.4.17/kernel/ksyms.c Fri Feb 22 15:27:44 2002 -@@ -282,6 +282,11 @@ - EXPORT_SYMBOL(lock_may_write); - EXPORT_SYMBOL(dcache_readdir); - -+/* lustre */ -+EXPORT_SYMBOL(pagecache_lock); -+EXPORT_SYMBOL(do_kern_mount); -+ -+ - /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */ - EXPORT_SYMBOL(default_llseek); - EXPORT_SYMBOL(dentry_open); ---- linux-2.4.17/include/linux/fs.h.lustre Fri Feb 22 15:27:53 2002 -+++ linux-2.4.17/include/linux/fs.h Fri Feb 22 15:28:52 2002 -@@ -983,7 +984,7 @@ - extern struct vfsmount *kern_mount(struct file_system_type *); - extern int may_umount(struct vfsmount *); - extern long do_mount(char *, char *, char *, unsigned long, void *); -- -+struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data); - #define kern_umount mntput - - extern int vfs_statfs(struct super_block *, struct statfs *); ---- linux-2.4.17/fs/ext3/Makefile.orig Fri Dec 21 10:41:55 2001 -+++ linux-2.4.17/fs/ext3/Makefile Fri Mar 22 11:00:58 2002 -@@ -8,6 +8,8 @@ - # Note 2! The CFLAGS definitions are now in the main makefile... - - O_TARGET := ext3.o -+ -+export-objs := super.o - - obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ - ioctl.o namei.o super.o symlink.o ---- linux-2.4.17/fs/ext3/super.c.orig Fri Dec 21 10:41:55 2001 -+++ linux-2.4.17/fs/ext3/super.c Fri Mar 22 11:00:41 2002 -@@ -1742,7 +1742,7 @@ - unregister_filesystem(&ext3_fs_type); - } - --EXPORT_NO_SYMBOLS; -+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"); diff --git a/lustre/patches/patch-2.4.18 b/lustre/patches/patch-2.4.18 deleted file mode 100644 index 72bf21a..0000000 --- a/lustre/patches/patch-2.4.18 +++ /dev/null @@ -1,1354 +0,0 @@ ---- tmp/linux/kernel/ksyms.c Mon Feb 25 12:38:13 2002 -+++ lum/kernel/ksyms.c Tue Jun 4 12:25:32 2002 -@@ -271,6 +271,11 @@ EXPORT_SYMBOL(lock_may_read); - EXPORT_SYMBOL(lock_may_write); - EXPORT_SYMBOL(dcache_readdir); - -+/* lustre */ -+EXPORT_SYMBOL(pagecache_lock); -+EXPORT_SYMBOL(do_kern_mount); -+ -+ - /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */ - EXPORT_SYMBOL(default_llseek); - EXPORT_SYMBOL(dentry_open); ---- tmp/linux/include/linux/fs.h Fri Jun 7 10:42:13 2002 -+++ lum/include/linux/fs.h Thu Jun 6 16:00:45 2002 -@@ -536,6 +536,7 @@ struct file { - - /* needed for tty driver, and maybe others */ - void *private_data; -+ struct lookup_intent *f_intent; - - /* preallocated helper kiobuf to speedup O_DIRECT */ - struct kiobuf *f_iobuf; -@@ -779,7 +780,9 @@ extern int vfs_symlink(struct inode *, s - extern int vfs_link(struct dentry *, struct inode *, struct dentry *); - extern int vfs_rmdir(struct inode *, struct dentry *); - extern int vfs_unlink(struct inode *, struct dentry *); --extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); -+int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it); - - /* - * File types -@@ -840,6 +843,7 @@ struct file_operations { - struct inode_operations { - int (*create) (struct inode *,struct dentry *,int); - struct dentry * (*lookup) (struct inode *,struct dentry *); -+ struct dentry * (*lookup2) (struct inode *,struct dentry *, struct lookup_intent *); - int (*link) (struct dentry *,struct inode *,struct dentry *); - int (*unlink) (struct inode *,struct dentry *); - int (*symlink) (struct inode *,struct dentry *,const char *); -@@ -986,7 +994,7 @@ extern int unregister_filesystem(struct - extern struct vfsmount *kern_mount(struct file_system_type *); - extern int may_umount(struct vfsmount *); - extern long do_mount(char *, char *, char *, unsigned long, void *); -- -+struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data); - #define kern_umount mntput - - extern int vfs_statfs(struct super_block *, struct statfs *); -@@ -1307,6 +1315,7 @@ typedef int (*read_actor_t)(read_descrip - extern loff_t default_llseek(struct file *file, loff_t offset, int origin); - - extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *)); -+extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it)); - extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *)); - extern int FASTCALL(path_walk(const char *, struct nameidata *)); - extern int FASTCALL(link_path_walk(const char *, struct nameidata *)); -@@ -1317,6 +1326,8 @@ extern struct dentry * lookup_one_len(co - extern struct dentry * lookup_hash(struct qstr *, struct dentry *); - #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd) - #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd) -+#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it) -+#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it) - - extern void iput(struct inode *); - extern void force_delete(struct inode *); ---- tmp/linux/fs/ext3/Makefile Fri Dec 21 10:41:55 2001 -+++ lum/fs/ext3/Makefile Tue Jun 4 12:25:33 2002 -@@ -9,6 +9,8 @@ - - O_TARGET := ext3.o - -+export-objs := super.o -+ - obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ - ioctl.o namei.o super.o symlink.o - obj-m := $(O_TARGET) ---- tmp/linux/fs/ext3/super.c Mon Feb 25 12:38:08 2002 -+++ lum/fs/ext3/super.c Tue Jun 4 12:25:33 2002 -@@ -1744,7 +1744,7 @@ static void __exit exit_ext3_fs(void) - unregister_filesystem(&ext3_fs_type); - } - --EXPORT_NO_SYMBOLS; -+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"); ---- tmp/linux/include/linux/blkdev.h Mon Nov 26 06:29:17 2001 -+++ lum/include/linux/blkdev.h Thu Jun 6 16:00:46 2002 -@@ -228,4 +228,8 @@ static inline unsigned int block_size(kd - return retval; - } - -+#define CONFIG_DEV_RDONLY -+void dev_set_rdonly(kdev_t, int); -+int dev_check_rdonly(kdev_t); -+void dev_clear_rdonly(int); - #endif ---- tmp/linux/drivers/block/blkpg.c Mon Feb 25 12:37:57 2002 -+++ lum/drivers/block/blkpg.c Tue Jun 4 12:25:33 2002 -@@ -294,3 +294,38 @@ int blk_ioctl(kdev_t dev, unsigned int c - } - - EXPORT_SYMBOL(blk_ioctl); -+ -+#define NUM_DEV_NO_WRITE 16 -+static int dev_no_write[NUM_DEV_NO_WRITE]; -+ -+/* -+ * Debug code for turning block devices "read-only" (will discard writes -+ * silently). This is for filesystem crash/recovery testing. -+ */ -+void dev_set_rdonly(kdev_t dev, int no_write) -+{ -+ if (dev) { -+ printk(KERN_WARNING "Turning device %s read-only\n", -+ bdevname(dev)); -+ dev_no_write[no_write] = 0xdead0000 + dev; -+ } -+} -+ -+int dev_check_rdonly(kdev_t dev) { -+ int i; -+ -+ for (i = 0; i < NUM_DEV_NO_WRITE; i++) { -+ if ((dev_no_write[i] & 0xffff0000) == 0xdead0000 && -+ dev == (dev_no_write[i] & 0xffff)) -+ return 1; -+ } -+ return 0; -+} -+ -+void dev_clear_rdonly(int no_write) { -+ dev_no_write[no_write] = 0; -+} -+ -+EXPORT_SYMBOL(dev_set_rdonly); -+EXPORT_SYMBOL(dev_check_rdonly); -+EXPORT_SYMBOL(dev_clear_rdonly); ---- tmp/linux/drivers/block/loop.c Fri Dec 21 10:41:53 2001 -+++ lum/drivers/block/loop.c Tue Jun 4 12:25:33 2002 -@@ -471,6 +471,11 @@ static int loop_make_request(request_que - spin_unlock_irq(&lo->lo_lock); - - if (rw == WRITE) { -+#ifdef CONFIG_DEV_RDONLY -+ if (dev_check_rdonly(rbh->b_rdev)) -+ goto err; -+#endif -+ - if (lo->lo_flags & LO_FLAGS_READ_ONLY) - goto err; - } else if (rw == READA) { ---- tmp/linux/drivers/ide/ide-disk.c Fri Dec 21 10:41:54 2001 -+++ lum/drivers/ide/ide-disk.c Tue Jun 4 12:25:33 2002 -@@ -367,6 +367,12 @@ static ide_startstop_t recal_intr (ide_d - */ - static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block) - { -+#ifdef CONFIG_DEV_RDONLY -+ if (rq->cmd == WRITE && dev_check_rdonly(rq->rq_dev)) { -+ ide_end_request(1, HWGROUP(drive)); -+ return ide_stopped; -+ } -+#endif - if (IDE_CONTROL_REG) - OUT_BYTE(drive->ctl,IDE_CONTROL_REG); - OUT_BYTE(0x00, IDE_FEATURE_REG); ---- tmp/linux/include/linux/jbd.h Mon Feb 25 12:38:13 2002 -+++ lum/include/linux/jbd.h Thu Jun 6 16:02:37 2002 -@@ -249,6 +249,13 @@ static inline struct journal_head *bh2jh - return bh->b_private; - } - -+#define HAVE_JOURNAL_CALLBACK_STATUS -+struct journal_callback { -+ struct list_head jcb_list; -+ void (*jcb_func)(void *cb_data, int error); -+ /* user data goes here */ -+}; -+ - struct jbd_revoke_table_s; - - /* The handle_t type represents a single atomic update being performed -@@ -279,6 +286,12 @@ struct handle_s - operations */ - int h_err; - -+ /* List of application registered callbacks for this handle. -+ * The function(s) will be called after the transaction that -+ * this handle is part of has been committed to disk. -+ */ -+ struct list_head h_jcb; -+ - /* Flags */ - unsigned int h_sync: 1; /* sync-on-close */ - unsigned int h_jdata: 1; /* force data journaling */ -@@ -398,6 +411,10 @@ struct transaction_s - - /* How many handles used this transaction? */ - int t_handle_count; -+ -+ /* List of registered callback functions for this transaction. -+ * Called when the transaction is committed. */ -+ struct list_head t_jcb; - }; - - -@@ -646,6 +663,8 @@ extern int journal_flushpage(journal_t - extern int journal_try_to_free_buffers(journal_t *, struct page *, int); - extern int journal_stop(handle_t *); - extern int journal_flush (journal_t *); -+extern void journal_callback_set(handle_t *handle, void (*fn)(void *, int), -+ void *cb_data); - - extern void journal_lock_updates (journal_t *); - extern void journal_unlock_updates (journal_t *); ---- tmp/linux/fs/jbd/commit.c Mon Feb 25 12:38:08 2002 -+++ lum/fs/jbd/commit.c Tue Jun 4 12:25:33 2002 -@@ -475,7 +475,7 @@ start_journal_io: - transaction's t_log_list queue, and metadata buffers are on - the t_iobuf_list queue. - -- Wait for the transactions in reverse order. That way we are -+ Wait for the buffers in reverse order. That way we are - less likely to be woken up until all IOs have completed, and - so we incur less scheduling load. - */ -@@ -566,8 +566,10 @@ start_journal_io: - - jbd_debug(3, "JBD: commit phase 6\n"); - -- if (is_journal_aborted(journal)) -+ if (is_journal_aborted(journal)) { -+ unlock_journal(journal); - goto skip_commit; -+ } - - /* Done it all: now write the commit record. We should have - * cleaned up our previous buffers by now, so if we are in abort -@@ -577,6 +579,7 @@ start_journal_io: - descriptor = journal_get_descriptor_buffer(journal); - if (!descriptor) { - __journal_abort_hard(journal); -+ unlock_journal(journal); - goto skip_commit; - } - -@@ -600,7 +603,6 @@ start_journal_io: - put_bh(bh); /* One for getblk() */ - journal_unlock_journal_head(descriptor); - } -- lock_journal(journal); - - /* End of a transaction! Finally, we can do checkpoint - processing: any buffers committed as a result of this -@@ -609,6 +611,25 @@ start_journal_io: - - skip_commit: - -+ /* Call any callbacks that had been registered for handles in this -+ * transaction. It is up to the callback to free any allocated -+ * memory. -+ */ -+ if (!list_empty(&commit_transaction->t_jcb)) { -+ struct list_head *p, *n; -+ int error = is_journal_aborted(journal); -+ -+ list_for_each_safe(p, n, &commit_transaction->t_jcb) { -+ struct journal_callback *jcb; -+ -+ jcb = list_entry(p, struct journal_callback, jcb_list); -+ list_del(p); -+ jcb->jcb_func(jcb, error); -+ } -+ } -+ -+ lock_journal(journal); -+ - jbd_debug(3, "JBD: commit phase 7\n"); - - J_ASSERT(commit_transaction->t_sync_datalist == NULL); ---- tmp/linux/fs/jbd/journal.c Mon Feb 25 12:38:08 2002 -+++ lum/fs/jbd/journal.c Tue Jun 4 12:25:33 2002 -@@ -58,6 +58,7 @@ EXPORT_SYMBOL(journal_sync_buffer); - #endif - EXPORT_SYMBOL(journal_flush); - EXPORT_SYMBOL(journal_revoke); -+EXPORT_SYMBOL(journal_callback_set); - - EXPORT_SYMBOL(journal_init_dev); - EXPORT_SYMBOL(journal_init_inode); ---- tmp/linux/fs/jbd/transaction.c Mon Feb 25 12:38:08 2002 -+++ lum/fs/jbd/transaction.c Tue Jun 4 12:25:33 2002 -@@ -57,6 +57,7 @@ static transaction_t * get_transaction ( - transaction->t_state = T_RUNNING; - transaction->t_tid = journal->j_transaction_sequence++; - transaction->t_expires = jiffies + journal->j_commit_interval; -+ INIT_LIST_HEAD(&transaction->t_jcb); - - /* Set up the commit timer for the new transaction. */ - J_ASSERT (!journal->j_commit_timer_active); -@@ -201,6 +202,20 @@ repeat_locked: - return 0; - } - -+/* Allocate a new handle. This should probably be in a slab... */ -+static handle_t *get_handle(int nblocks) -+{ -+ handle_t *handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ if (!handle) -+ return NULL; -+ memset(handle, 0, sizeof (handle_t)); -+ handle->h_buffer_credits = nblocks; -+ handle->h_ref = 1; -+ INIT_LIST_HEAD(&handle->h_jcb); -+ -+ return handle; -+} -+ - /* - * Obtain a new handle. - * -@@ -228,13 +243,10 @@ handle_t *journal_start(journal_t *journ - return handle; - } - -- handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ handle = get_handle(nblocks); - if (!handle) - return ERR_PTR(-ENOMEM); -- memset (handle, 0, sizeof (handle_t)); - -- handle->h_buffer_credits = nblocks; -- handle->h_ref = 1; - current->journal_info = handle; - - err = start_this_handle(journal, handle); -@@ -334,13 +346,10 @@ handle_t *journal_try_start(journal_t *j - if (is_journal_aborted(journal)) - return ERR_PTR(-EIO); - -- handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ handle = get_handle(nblocks); - if (!handle) - return ERR_PTR(-ENOMEM); -- memset (handle, 0, sizeof (handle_t)); - -- handle->h_buffer_credits = nblocks; -- handle->h_ref = 1; - current->journal_info = handle; - - err = try_start_this_handle(journal, handle); -@@ -1328,6 +1337,29 @@ out: - #endif - - /* -+ * Register a callback function for this handle. The function will be -+ * called when the transaction that this handle is part of has been -+ * committed to disk with the original callback data struct and the -+ * error status of the journal as parameters. There is no guarantee of -+ * ordering between handles within a single transaction, nor between -+ * callbacks registered on the same handle. -+ * -+ * The caller is responsible for allocating the journal_callback struct. -+ * This is to allow the caller to add as much extra data to the callback -+ * as needed, but reduce the overhead of multiple allocations. The caller -+ * allocated struct must start with a struct journal_callback at offset 0, -+ * and has the caller-specific data afterwards. -+ */ -+void journal_callback_set(handle_t *handle, void (*func)(void *, int), -+ void *cb_data) -+{ -+ struct journal_callback *jcb = cb_data; -+ -+ list_add(&jcb->jcb_list, &handle->h_jcb); -+ jcb->jcb_func = func; -+} -+ -+/* - * All done for a particular handle. - * - * There is not much action needed here. We just return any remaining -@@ -1393,6 +1425,9 @@ int journal_stop(handle_t *handle) - wake_up(&journal->j_wait_transaction_locked); - } - -+ /* Move callbacks from the handle to the transaction. */ -+ list_splice(&handle->h_jcb, &transaction->t_jcb); -+ - /* - * If the handle is marked SYNC, we need to set another commit - * going! We also want to force a commit if the current ---- tmp/linux/include/linux/dcache.h Thu Nov 22 12:46:18 2001 -+++ lum/include/linux/dcache.h Thu Jun 6 16:00:45 2002 -@@ -6,6 +6,28 @@ - #include - #include - -+#define IT_OPEN (1) -+#define IT_CREAT (1<<1) -+#define IT_MKDIR (1<<2) -+#define IT_LINK (1<<3) -+#define IT_SYMLINK (1<<4) -+#define IT_UNLINK (1<<5) -+#define IT_RMDIR (1<<6) -+#define IT_RENAME (1<<7) -+#define IT_READDIR (1<<8) -+#define IT_GETATTR (1<<9) -+#define IT_SETATTR (1<<10) -+#define IT_READLINK (1<<11) -+ -+struct lookup_intent { -+ int it_op; -+ int it_mode; -+ int it_disposition; -+ int it_status; -+ struct iattr *it_iattr; -+ void *it_data; -+}; -+ - /* - * linux/include/linux/dcache.h - * -@@ -79,17 +101,20 @@ struct dentry { - struct dentry_operations *d_op; - struct super_block * d_sb; /* The root of the dentry tree */ - unsigned long d_vfs_flags; -+ struct lookup_intent *d_it; - void * d_fsdata; /* fs-specific data */ - unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */ - }; - - struct dentry_operations { - int (*d_revalidate)(struct dentry *, int); -+ int (*d_revalidate2)(struct dentry *, int, struct lookup_intent *); - int (*d_hash) (struct dentry *, struct qstr *); - int (*d_compare) (struct dentry *, struct qstr *, struct qstr *); - int (*d_delete)(struct dentry *); - void (*d_release)(struct dentry *); - void (*d_iput)(struct dentry *, struct inode *); -+ void (*d_intent_rel)(struct dentry *); - }; - - /* the dentry parameter passed to d_hash and d_compare is the parent ---- tmp/linux/fs/namei.c Mon Feb 25 12:38:09 2002 -+++ lum/fs/namei.c Wed Jun 5 18:41:09 2002 -@@ -94,6 +94,14 @@ - * XEmacs seems to be relying on it... - */ - -+void intent_release(struct dentry *de) -+{ -+ if (de->d_op && de->d_op->d_intent_rel) -+ de->d_op->d_intent_rel(de); -+ de->d_it = NULL; -+} -+ -+ - /* In order to reduce some races, while at the same time doing additional - * checking and hopefully speeding things up, we copy filenames to the - * kernel data space before using them.. -@@ -260,10 +268,18 @@ void path_release(struct nameidata *nd) - * Internal lookup() using the new generic dcache. - * SMP-safe - */ --static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags) -+static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it) - { - struct dentry * dentry = d_lookup(parent, name); - -+ if (dentry && dentry->d_op && dentry->d_op->d_revalidate2) { -+ if (!dentry->d_op->d_revalidate2(dentry, flags, it) && !d_invalidate(dentry)) { -+ dput(dentry); -+ dentry = NULL; -+ } -+ return dentry; -+ } -+ - if (dentry && dentry->d_op && dentry->d_op->d_revalidate) { - if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) { - dput(dentry); -@@ -281,7 +297,7 @@ static struct dentry * cached_lookup(str - * make sure that nobody added the entry to the dcache in the meantime.. - * SMP-safe - */ --static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags) -+static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it) - { - struct dentry * result; - struct inode *dir = parent->d_inode; -@@ -300,6 +316,9 @@ static struct dentry * real_lookup(struc - result = ERR_PTR(-ENOMEM); - if (dentry) { - lock_kernel(); -+ if (dir->i_op->lookup2) -+ result = dir->i_op->lookup2(dir, dentry, it); -+ else - result = dir->i_op->lookup(dir, dentry); - unlock_kernel(); - if (result) -@@ -322,6 +341,12 @@ static struct dentry * real_lookup(struc - result = ERR_PTR(-ENOENT); - } - } -+ if (result->d_op && result->d_op->d_revalidate2) { -+ if (!result->d_op->d_revalidate2(result, flags, it) && !d_invalidate(result)) { -+ dput(result); -+ result = ERR_PTR(-ENOENT); -+ } -+ } - return result; - } - -@@ -445,7 +470,7 @@ static inline void follow_dotdot(struct - * - * We expect 'base' to be positive and a directory. - */ --int link_path_walk(const char * name, struct nameidata *nd) -+int link_path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it) - { - struct dentry *dentry; - struct inode *inode; -@@ -518,9 +543,9 @@ int link_path_walk(const char * name, st - break; - } - /* This does the actual lookups.. */ -- dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE); -+ dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL); - if (!dentry) { -- dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE); -+ dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL); - err = PTR_ERR(dentry); - if (IS_ERR(dentry)) - break; -@@ -554,7 +579,7 @@ int link_path_walk(const char * name, st - nd->dentry = dentry; - } - err = -ENOTDIR; -- if (!inode->i_op->lookup) -+ if (!inode->i_op->lookup && !inode->i_op->lookup2) - break; - continue; - /* here ends the main loop */ -@@ -581,9 +606,9 @@ last_component: - if (err < 0) - break; - } -- dentry = cached_lookup(nd->dentry, &this, 0); -+ dentry = cached_lookup(nd->dentry, &this, 0, it); - if (!dentry) { -- dentry = real_lookup(nd->dentry, &this, 0); -+ dentry = real_lookup(nd->dentry, &this, 0, it); - err = PTR_ERR(dentry); - if (IS_ERR(dentry)) - break; -@@ -607,7 +632,8 @@ last_component: - goto no_inode; - if (lookup_flags & LOOKUP_DIRECTORY) { - err = -ENOTDIR; -- if (!inode->i_op || !inode->i_op->lookup) -+ if (!inode->i_op || (!inode->i_op->lookup && -+ !inode->i_op->lookup2)) - break; - } - goto return_base; -@@ -636,12 +662,24 @@ return_err: - return err; - } - -+int link_path_walk(const char * name, struct nameidata *nd) -+{ -+ return link_path_walk_it(name, nd, NULL); -+} -+ -+int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it) -+{ -+ current->total_link_count = 0; -+ return link_path_walk_it(name, nd, it); -+} -+ - int path_walk(const char * name, struct nameidata *nd) - { - current->total_link_count = 0; -- return link_path_walk(name, nd); -+ return link_path_walk_it(name, nd, NULL); - } - -+ - /* SMP-safe */ - /* returns 1 if everything is done */ - static int __emul_lookup_dentry(const char *name, struct nameidata *nd) -@@ -742,7 +780,8 @@ int path_init(const char *name, unsigned - * needs parent already locked. Doesn't follow mounts. - * SMP-safe. - */ --struct dentry * lookup_hash(struct qstr *name, struct dentry * base) -+struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base, -+ struct lookup_intent *it) - { - struct dentry * dentry; - struct inode *inode; -@@ -765,13 +804,16 @@ struct dentry * lookup_hash(struct qstr - goto out; - } - -- dentry = cached_lookup(base, name, 0); -+ dentry = cached_lookup(base, name, 0, it); - if (!dentry) { - struct dentry *new = d_alloc(base, name); - dentry = ERR_PTR(-ENOMEM); - if (!new) - goto out; - lock_kernel(); -+ if (inode->i_op->lookup2) -+ dentry = inode->i_op->lookup2(inode, new, it); -+ else - dentry = inode->i_op->lookup(inode, new); - unlock_kernel(); - if (!dentry) -@@ -783,6 +825,12 @@ out: - return dentry; - } - -+struct dentry * lookup_hash(struct qstr *name, struct dentry * base) -+{ -+ return lookup_hash_it(name, base, NULL); -+} -+ -+ - /* SMP-safe */ - struct dentry * lookup_one_len(const char * name, struct dentry * base, int len) - { -@@ -804,7 +852,7 @@ struct dentry * lookup_one_len(const cha - } - this.hash = end_name_hash(hash); - -- return lookup_hash(&this, base); -+ return lookup_hash_it(&this, base, NULL); - access: - return ERR_PTR(-EACCES); - } -@@ -836,6 +884,22 @@ int __user_walk(const char *name, unsign - return err; - } - -+int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd, struct lookup_intent *it) -+{ -+ char *tmp; -+ int err; -+ -+ tmp = getname(name); -+ err = PTR_ERR(tmp); -+ if (!IS_ERR(tmp)) { -+ err = 0; -+ if (path_init(tmp, flags, nd)) -+ err = path_walk_it(tmp, nd, it); -+ putname(tmp); -+ } -+ return err; -+} -+ - /* - * It's inline, so penalty for filesystems that don't use sticky bit is - * minimal. -@@ -970,7 +1034,8 @@ exit_lock: - * for symlinks (where the permissions are checked later). - * SMP-safe - */ --int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) -+int open_namei_it(const char * pathname, int flag, int mode, struct nameidata *nd, -+ struct lookup_intent *it) - { - int acc_mode, error = 0; - struct inode *inode; -@@ -984,8 +1049,9 @@ int open_namei(const char * pathname, in - * The simplest case - just a plain lookup. - */ - if (!(flag & O_CREAT)) { -+ - if (path_init(pathname, lookup_flags(flag), nd)) -- error = path_walk(pathname, nd); -+ error = path_walk_it(pathname, nd, it); - if (error) - return error; - dentry = nd->dentry; -@@ -995,6 +1061,8 @@ int open_namei(const char * pathname, in - /* - * Create - we need to know the parent. - */ -+ if (it) -+ it->it_op |= IT_CREAT; - if (path_init(pathname, LOOKUP_PARENT, nd)) - error = path_walk(pathname, nd); - if (error) -@@ -1011,7 +1079,7 @@ int open_namei(const char * pathname, in - - dir = nd->dentry; - down(&dir->d_inode->i_sem); -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, it); - - do_last: - error = PTR_ERR(dentry); -@@ -1022,6 +1090,7 @@ do_last: - - /* Negative dentry, just create the file */ - if (!dentry->d_inode) { -+ dentry->d_it = it; - error = vfs_create(dir->d_inode, dentry, - mode & ~current->fs->umask); - up(&dir->d_inode->i_sem); -@@ -1181,13 +1250,20 @@ do_link: - } - dir = nd->dentry; - down(&dir->d_inode->i_sem); -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, NULL); - putname(nd->last.name); - goto do_last; - } - -+int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) -+{ -+ return open_namei_it(pathname, flag, mode, nd, NULL); -+} -+ -+ - /* SMP-safe */ --static struct dentry *lookup_create(struct nameidata *nd, int is_dir) -+static struct dentry *lookup_create(struct nameidata *nd, int is_dir, -+ struct lookup_intent *it) - { - struct dentry *dentry; - -@@ -1195,7 +1271,7 @@ static struct dentry *lookup_create(stru - dentry = ERR_PTR(-EEXIST); - if (nd->last_type != LAST_NORM) - goto fail; -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, it); - if (IS_ERR(dentry)) - goto fail; - if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) -@@ -1241,6 +1317,7 @@ asmlinkage long sys_mknod(const char * f - char * tmp; - struct dentry * dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_CREAT , mode }; - - if (S_ISDIR(mode)) - return -EPERM; -@@ -1252,11 +1329,12 @@ asmlinkage long sys_mknod(const char * f - error = path_walk(tmp, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 0); -+ dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(dentry); - - mode &= ~current->fs->umask; - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - switch (mode & S_IFMT) { - case 0: case S_IFREG: - error = vfs_create(nd.dentry->d_inode,dentry,mode); -@@ -1272,6 +1350,7 @@ asmlinkage long sys_mknod(const char * f - } - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1310,6 +1389,7 @@ asmlinkage long sys_mkdir(const char * p - { - int error = 0; - char * tmp; -+ struct lookup_intent it = { IT_MKDIR, mode }; - - tmp = getname(pathname); - error = PTR_ERR(tmp); -@@ -1321,13 +1401,15 @@ asmlinkage long sys_mkdir(const char * p - error = path_walk(tmp, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 1); -+ dentry = lookup_create(&nd, 1, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_mkdir(nd.dentry->d_inode, dentry, - mode & ~current->fs->umask); - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1407,6 +1489,7 @@ asmlinkage long sys_rmdir(const char * p - char * name; - struct dentry *dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_RMDIR, 0 }; - - name = getname(pathname); - if(IS_ERR(name)) -@@ -1429,10 +1512,12 @@ asmlinkage long sys_rmdir(const char * p - goto exit1; - } - down(&nd.dentry->d_inode->i_sem); -- dentry = lookup_hash(&nd.last, nd.dentry); -+ dentry = lookup_hash_it(&nd.last, nd.dentry, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_rmdir(nd.dentry->d_inode, dentry); -+ intent_release(dentry); - dput(dentry); - } - up(&nd.dentry->d_inode->i_sem); -@@ -1476,6 +1561,7 @@ asmlinkage long sys_unlink(const char * - char * name; - struct dentry *dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_UNLINK, 0 }; - - name = getname(pathname); - if(IS_ERR(name)) -@@ -1489,14 +1575,16 @@ asmlinkage long sys_unlink(const char * - if (nd.last_type != LAST_NORM) - goto exit1; - down(&nd.dentry->d_inode->i_sem); -- dentry = lookup_hash(&nd.last, nd.dentry); -+ dentry = lookup_hash_it(&nd.last, nd.dentry, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - /* Why not before? Because we want correct error value */ - if (nd.last.name[nd.last.len]) - goto slashes; - error = vfs_unlink(nd.dentry->d_inode, dentry); - exit2: -+ intent_release(dentry); - dput(dentry); - } - up(&nd.dentry->d_inode->i_sem); -@@ -1543,6 +1631,7 @@ asmlinkage long sys_symlink(const char * - int error = 0; - char * from; - char * to; -+ struct lookup_intent it = { IT_SYMLINK, 0 }; - - from = getname(oldname); - f(IS_ERR(from)) -@@ -1557,12 +1646,14 @@ asmlinkage long sys_symlink(const char * - error = path_walk(to, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 0); -+ dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_symlink(nd.dentry->d_inode, dentry, from); - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1626,6 +1717,7 @@ asmlinkage long sys_link(const char * ol - int error; - char * from; - char * to; -+ struct lookup_intent it = { IT_LINK, 0 }; - - from = getname(oldname); - if(IS_ERR(from)) -@@ -1648,12 +1740,14 @@ asmlinkage long sys_link(const char * ol - error = -EXDEV; - if (old_nd.mnt != nd.mnt) - goto out_release; -- new_dentry = lookup_create(&nd, 0); -+ new_dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(new_dentry); - if (!IS_ERR(new_dentry)) { -+ new_dentry->d_it = ⁢ - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); - dput(new_dentry); - } -+ intent_release(new_dentry); - up(&nd.dentry->d_inode->i_sem); - out_release: - path_release(&nd); -@@ -1694,7 +1788,8 @@ exit: - * locking]. - */ - int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - struct inode *target; -@@ -1748,12 +1843,14 @@ int vfs_rename_dir(struct inode *old_dir - } else - double_down(&old_dir->i_zombie, - &new_dir->i_zombie); -+ new_dentry->d_it = it; - if (IS_DEADDIR(old_dir)||IS_DEADDIR(new_dir)) - error = -ENOENT; - else if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) - error = -EBUSY; - else - error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); -+ intent_release(new_dentry); - if (target) { - if (!error) - target->i_flags |= S_DEAD; -@@ -1775,7 +1872,8 @@ out_unlock: - } - - int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - -@@ -1802,10 +1900,12 @@ int vfs_rename_other(struct inode *old_d - DQUOT_INIT(old_dir); - DQUOT_INIT(new_dir); - double_down(&old_dir->i_zombie, &new_dir->i_zombie); -+ new_dentry->d_it = it; - if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) - error = -EBUSY; - else - error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); -+ intent_release(new_dentry); - double_up(&old_dir->i_zombie, &new_dir->i_zombie); - if (error) - return error; -@@ -1817,13 +1917,14 @@ int vfs_rename_other(struct inode *old_d - } - - int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - if (S_ISDIR(old_dentry->d_inode->i_mode)) -- error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry); -+ error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry, it); - else -- error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); -+ error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry, it); - if (!error) { - if (old_dir == new_dir) - inode_dir_notify(old_dir, DN_RENAME); -@@ -1841,6 +1942,7 @@ static inline int do_rename(const char * - struct dentry * old_dir, * new_dir; - struct dentry * old_dentry, *new_dentry; - struct nameidata oldnd, newnd; -+ struct lookup_intent it = {IT_RENAME, 0}; - - if (path_init(oldname, LOOKUP_PARENT, &oldnd)) - error = path_walk(oldname, &oldnd); -@@ -1868,7 +1970,9 @@ static inline int do_rename(const char * - - double_lock(new_dir, old_dir); - -- old_dentry = lookup_hash(&oldnd.last, old_dir); -+ it.it_op = IT_RENAME; -+ it.it_mode = 0; -+ old_dentry = lookup_hash_it(&oldnd.last, old_dir, &it); - error = PTR_ERR(old_dentry); - if (IS_ERR(old_dentry)) - goto exit3; -@@ -1884,14 +1988,14 @@ static inline int do_rename(const char * - if (newnd.last.name[newnd.last.len]) - goto exit4; - } -- new_dentry = lookup_hash(&newnd.last, new_dir); -+ new_dentry = lookup_hash_it(&newnd.last, new_dir, &it); - error = PTR_ERR(new_dentry); - if (IS_ERR(new_dentry)) - goto exit4; - - lock_kernel(); - error = vfs_rename(old_dir->d_inode, old_dentry, -- new_dir->d_inode, new_dentry); -+ new_dir->d_inode, new_dentry, &it); - unlock_kernel(); - - dput(new_dentry); ---- tmp/linux/fs/open.c Fri Oct 12 14:48:42 2001 -+++ lum/fs/open.c Thu Jun 6 15:52:38 2002 -@@ -19,6 +19,8 @@ - #include - - #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) -+extern int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it); -+extern void intent_release(struct dentry *de); - - int vfs_statfs(struct super_block *sb, struct statfs *buf) - { -@@ -94,14 +96,19 @@ static inline long do_sys_truncate(const - struct nameidata nd; - struct inode * inode; - int error; -+ struct lookup_intent it; -+ -+ it.it_op = IT_SETATTR; -+ - - error = -EINVAL; - if (length < 0) /* sorry, but loff_t says... */ - goto out; - -- error = user_path_walk(path, &nd); -+ error = user_path_walk_it(path, &nd, &it); - if (error) - goto out; -+ nd.dentry->d_it = ⁢ - inode = nd.dentry->d_inode; - - /* For directories it's -EISDIR, for other non-regulars - -EINVAL */ -@@ -144,6 +151,7 @@ static inline long do_sys_truncate(const - put_write_access(inode); - - dput_and_out: -+ intent_release(nd.dentry); - path_release(&nd); - out: - return error; -@@ -235,10 +243,14 @@ asmlinkage long sys_utime(char * filenam - struct nameidata nd; - struct inode * inode; - struct iattr newattrs; -+ struct lookup_intent it; - -- error = user_path_walk(filename, &nd); -+ it.it_op = IT_SETATTR; -+ -+ error = user_path_walk_it(filename, &nd, &it); - if (error) - goto out; -+ nd.dentry->d_it = ⁢ - inode = nd.dentry->d_inode; - - error = -EROFS; -@@ -262,6 +274,7 @@ asmlinkage long sys_utime(char * filenam - } - error = notify_change(nd.dentry, &newattrs); - dput_and_out: -+ intent_release(nd.dentry); - path_release(&nd); - out: - return error; -@@ -279,11 +292,15 @@ asmlinkage long sys_utimes(char * filena - struct nameidata nd; - struct inode * inode; - struct iattr newattrs; -+ struct lookup_intent it; -+ -+ it.it_op = IT_SETATTR; - -- error = user_path_walk(filename, &nd); -+ error = user_path_walk_it(filename, &nd, &it); - - if (error) - goto out; -+ nd.dentry->d_it = ⁢ - inode = nd.dentry->d_inode; - - error = -EROFS; -@@ -306,6 +323,7 @@ asmlinkage long sys_utimes(char * filena - } - error = notify_change(nd.dentry, &newattrs); - dput_and_out: -+ intent_release(nd.dentry); - path_release(&nd); - out: - return error; -@@ -322,6 +340,9 @@ asmlinkage long sys_access(const char * - int old_fsuid, old_fsgid; - kernel_cap_t old_cap; - int res; -+ struct lookup_intent it; -+ -+ it.it_op = IT_GETATTR; - - if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ - return -EINVAL; -@@ -339,7 +360,7 @@ asmlinkage long sys_access(const char * - else - current->cap_effective = current->cap_permitted; - -- res = user_path_walk(filename, &nd); -+ res = user_path_walk_it(filename, &nd, &it); - if (!res) { - res = permission(nd.dentry->d_inode, mode); - /* SuS v2 requires we report a read only fs too */ -@@ -361,6 +382,9 @@ asmlinkage long sys_chdir(const char * f - int error; - struct nameidata nd; - char *name; -+ struct lookup_intent it; -+ -+ it.it_op = IT_GETATTR; - - name = getname(filename); - error = PTR_ERR(name); -@@ -369,11 +393,12 @@ asmlinkage long sys_chdir(const char * f - - error = 0; - if (path_init(name,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd)) -- error = path_walk(name, &nd); -+ error = path_walk_it(name, &nd, &it); - putname(name); - if (error) - goto out; - -+ nd.dentry->d_it = ⁢ - error = permission(nd.dentry->d_inode,MAY_EXEC); - if (error) - goto dput_and_out; -@@ -381,6 +406,7 @@ asmlinkage long sys_chdir(const char * f - set_fs_pwd(current->fs, nd.mnt, nd.dentry); - - dput_and_out: -+ intent_release(nd.dentry); - path_release(&nd); - out: - return error; -@@ -421,6 +447,9 @@ asmlinkage long sys_chroot(const char * - int error; - struct nameidata nd; - char *name; -+ struct lookup_intent it; -+ -+ it.it_op = IT_GETATTR; - - name = getname(filename); - error = PTR_ERR(name); -@@ -429,11 +458,12 @@ asmlinkage long sys_chroot(const char * - - path_init(name, LOOKUP_POSITIVE | LOOKUP_FOLLOW | - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd); -- error = path_walk(name, &nd); -+ error = path_walk_it(name, &nd, &it); - putname(name); - if (error) - goto out; - -+ nd.dentry->d_it = ⁢ - error = permission(nd.dentry->d_inode,MAY_EXEC); - if (error) - goto dput_and_out; -@@ -446,6 +476,7 @@ asmlinkage long sys_chroot(const char * - set_fs_altroot(); - error = 0; - dput_and_out: -+ intent_release(nd.dentry); - path_release(&nd); - out: - return error; -@@ -490,12 +521,15 @@ asmlinkage long sys_chmod(const char * f - struct inode * inode; - int error; - struct iattr newattrs; -+ struct lookup_intent it; - -- error = user_path_walk(filename, &nd); -+ it.it_op = IT_SETATTR; -+ error = user_path_walk_it(filename, &nd, &it); - if (error) - goto out; - inode = nd.dentry->d_inode; - -+ nd.dentry->d_it = ⁢ - error = -EROFS; - if (IS_RDONLY(inode)) - goto dput_and_out; -@@ -511,6 +545,7 @@ asmlinkage long sys_chmod(const char * f - error = notify_change(nd.dentry, &newattrs); - - dput_and_out: -+ intent_release(nd.dentry); - path_release(&nd); - out: - return error; -@@ -580,10 +615,15 @@ asmlinkage long sys_chown(const char * f - { - struct nameidata nd; - int error; -+ struct lookup_intent it; -+ -+ it.it_op = IT_SETATTR; - -- error = user_path_walk(filename, &nd); -+ error = user_path_walk_it(filename, &nd, &it); - if (!error) { -+ nd.dentry->d_it = ⁢ - error = chown_common(nd.dentry, user, group); -+ intent_release(nd.dentry); - path_release(&nd); - } - return error; -@@ -593,10 +633,15 @@ asmlinkage long sys_lchown(const char * - { - struct nameidata nd; - int error; -+ struct lookup_intent it; - -- error = user_path_walk_link(filename, &nd); -+ it.it_op = IT_SETATTR; -+ -+ error = user_path_walk_link_it(filename, &nd, &it); - if (!error) { -+ nd.dentry->d_it = ⁢ - error = chown_common(nd.dentry, user, group); -+ intent_release(nd.dentry); - path_release(&nd); - } - return error; -@@ -630,10 +675,15 @@ asmlinkage long sys_fchown(unsigned int - * for the internal routines (ie open_namei()/follow_link() etc). 00 is - * used by symlinks. - */ -+extern int open_namei_it(const char *filename, int namei_flags, int mode, -+ struct nameidata *nd, struct lookup_intent *it); -+struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it); -+ - struct file *filp_open(const char * filename, int flags, int mode) - { - int namei_flags, error; - struct nameidata nd; -+ struct lookup_intent it = {IT_OPEN, 0}; - - namei_flags = flags; - if ((namei_flags+1) & O_ACCMODE) -@@ -641,14 +691,14 @@ struct file *filp_open(const char * file - if (namei_flags & O_TRUNC) - namei_flags |= 2; - -- error = open_namei(filename, namei_flags, mode, &nd); -+ error = open_namei_it(filename, namei_flags, mode, &nd, &it); - if (!error) -- return dentry_open(nd.dentry, nd.mnt, flags); -+ return dentry_open_it(nd.dentry, nd.mnt, flags, &it); - - return ERR_PTR(error); - } - --struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) -+struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it) - { - struct file * f; - struct inode *inode; -@@ -690,6 +740,7 @@ struct file *dentry_open(struct dentry * - goto cleanup_all; - } - f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); -+ f->f_intent = it; - - return f; - -@@ -710,6 +761,13 @@ cleanup_dentry: - return ERR_PTR(error); - } - -+struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) -+{ -+ return dentry_open_it(dentry, mnt, flags, NULL); -+ -+} -+ -+ - /* - * Find an empty file descriptor entry, and mark it busy. - */ ---- tmp/linux/fs/stat.c Thu Sep 13 17:04:43 2001 -+++ lum/fs/stat.c Tue Jun 4 12:25:33 2002 -@@ -247,14 +247,16 @@ asmlinkage long sys_readlink(const char - { - struct nameidata nd; - int error; -+ struct lookup_intent it; -+ it.it_op = IT_READLINK; - - if (bufsiz <= 0) - return -EINVAL; - -- error = user_path_walk_link(path, &nd); -+ error = user_path_walk_link_it(path, &nd, &it); - if (!error) { - struct inode * inode = nd.dentry->d_inode; -- -+ nd.dentry->d_it = ⁢ - error = -EINVAL; - if (inode->i_op && inode->i_op->readlink && - !(error = do_revalidate(nd.dentry))) { -@@ -333,9 +335,12 @@ asmlinkage long sys_stat64(char * filena - { - struct nameidata nd; - int error; -+ struct lookup_intent it; -+ it.it_op = IT_GETATTR; - -- error = user_path_walk(filename, &nd); -+ error = user_path_walk_it(filename, &nd, &it); - if (!error) { -+ nd.dentry->d_it = ⁢ - error = do_revalidate(nd.dentry); - if (!error) - error = cp_new_stat64(nd.dentry->d_inode, statbuf); -@@ -348,9 +353,12 @@ asmlinkage long sys_lstat64(char * filen - { - struct nameidata nd; - int error; -+ struct lookup_intent it; -+ it.it_op = IT_GETATTR; - -- error = user_path_walk_link(filename, &nd); -+ error = user_path_walk_link_it(filename, &nd, &it); - if (!error) { -+ nd.dentry->d_it = ⁢ - error = do_revalidate(nd.dentry); - if (!error) - error = cp_new_stat64(nd.dentry->d_inode, statbuf); -@@ -363,11 +371,16 @@ asmlinkage long sys_fstat64(unsigned lon - { - struct file * f; - int err = -EBADF; -+ struct lookup_intent it; -+ -+ memset(&it, 0, sizeof(it)); -+ it.it_op = IT_GETATTR; - - f = fget(fd); - if (f) { - struct dentry * dentry = f->f_dentry; - -+ dentry->d_it = ⁢ - err = do_revalidate(dentry); - if (!err) - err = cp_new_stat64(dentry->d_inode, statbuf); diff --git a/lustre/patches/patch-2.4.18-chaos1 b/lustre/patches/patch-2.4.18-chaos1 deleted file mode 100644 index aa97a84..0000000 --- a/lustre/patches/patch-2.4.18-chaos1 +++ /dev/null @@ -1,1114 +0,0 @@ -diff -ur kernel-2.4.18/drivers/block/blkpg.c kernel-2.4.18.patched/drivers/block/blkpg.c ---- kernel-2.4.18/drivers/block/blkpg.c Tue May 7 17:33:10 2002 -+++ kernel-2.4.18.patched/drivers/block/blkpg.c Thu May 30 13:38:14 2002 -@@ -295,3 +295,38 @@ - } - - EXPORT_SYMBOL(blk_ioctl); -+ -+#define NUM_DEV_NO_WRITE 16 -+static int dev_no_write[NUM_DEV_NO_WRITE]; -+ -+/* -+ * Debug code for turning block devices "read-only" (will discard writes -+ * silently). This is for filesystem crash/recovery testing. -+ */ -+void dev_set_rdonly(kdev_t dev, int no_write) -+{ -+ if (dev) { -+ printk(KERN_WARNING "Turning device %s read-only\n", -+ bdevname(dev)); -+ dev_no_write[no_write] = 0xdead0000 + dev; -+ } -+} -+ -+int dev_check_rdonly(kdev_t dev) { -+ int i; -+ -+ for (i = 0; i < NUM_DEV_NO_WRITE; i++) { -+ if ((dev_no_write[i] & 0xffff0000) == 0xdead0000 && -+ dev == (dev_no_write[i] & 0xffff)) -+ return 1; -+ } -+ return 0; -+} -+ -+void dev_clear_rdonly(int no_write) { -+ dev_no_write[no_write] = 0; -+} -+ -+EXPORT_SYMBOL(dev_set_rdonly); -+EXPORT_SYMBOL(dev_check_rdonly); -+EXPORT_SYMBOL(dev_clear_rdonly); -diff -ur kernel-2.4.18/drivers/block/loop.c kernel-2.4.18.patched/drivers/block/loop.c ---- kernel-2.4.18/drivers/block/loop.c Tue May 7 16:48:59 2002 -+++ kernel-2.4.18.patched/drivers/block/loop.c Thu May 30 13:38:14 2002 -@@ -503,6 +503,11 @@ - spin_unlock_irq(&lo->lo_lock); - - if (rw == WRITE) { -+#ifdef CONFIG_DEV_RDONLY -+ if (dev_check_rdonly(rbh->b_rdev)) -+ goto err; -+#endif -+ - if (lo->lo_flags & LO_FLAGS_READ_ONLY) - goto err; - } else if (rw == READA) { -diff -ur kernel-2.4.18/drivers/ide/ide-disk.c kernel-2.4.18.patched/drivers/ide/ide-disk.c ---- kernel-2.4.18/drivers/ide/ide-disk.c Tue May 7 15:43:35 2002 -+++ kernel-2.4.18.patched/drivers/ide/ide-disk.c Thu May 30 13:38:14 2002 -@@ -557,6 +557,12 @@ - */ - static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block) - { -+#ifdef CONFIG_DEV_RDONLY -+ if (rq->cmd == WRITE && dev_check_rdonly(rq->rq_dev)) { -+ ide_end_request(1, HWGROUP(drive)); -+ return ide_stopped; -+ } -+#endif - if (IDE_CONTROL_REG) - OUT_BYTE(drive->ctl,IDE_CONTROL_REG); - -diff -ur kernel-2.4.18/fs/ext3/Makefile kernel-2.4.18.patched/fs/ext3/Makefile ---- kernel-2.4.18/fs/ext3/Makefile Tue May 7 14:53:46 2002 -+++ kernel-2.4.18.patched/fs/ext3/Makefile Thu May 30 13:38:14 2002 -@@ -9,6 +9,8 @@ - - O_TARGET := ext3.o - -+export-objs := super.o -+ - obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ - ioctl.o namei.o super.o symlink.o - obj-m := $(O_TARGET) -diff -ur kernel-2.4.18/fs/ext3/super.c kernel-2.4.18.patched/fs/ext3/super.c ---- kernel-2.4.18/fs/ext3/super.c Tue May 7 16:43:17 2002 -+++ kernel-2.4.18.patched/fs/ext3/super.c Thu May 30 13:38:14 2002 -@@ -1746,7 +1746,7 @@ - unregister_filesystem(&ext3_fs_type); - } - --EXPORT_NO_SYMBOLS; -+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"); -diff -ur kernel-2.4.18/fs/jbd/commit.c kernel-2.4.18.patched/fs/jbd/commit.c ---- kernel-2.4.18/fs/jbd/commit.c Tue May 7 15:39:35 2002 -+++ kernel-2.4.18.patched/fs/jbd/commit.c Thu May 30 13:38:14 2002 -@@ -482,7 +482,7 @@ - transaction's t_log_list queue, and metadata buffers are on - the t_iobuf_list queue. - -- Wait for the transactions in reverse order. That way we are -+ Wait for the buffers in reverse order. That way we are - less likely to be woken up until all IOs have completed, and - so we incur less scheduling load. - */ -@@ -575,8 +575,10 @@ - - jbd_debug(3, "JBD: commit phase 6\n"); - -- if (is_journal_aborted(journal)) -+ if (is_journal_aborted(journal)) { -+ unlock_journal(journal); - goto skip_commit; -+ } - - /* Done it all: now write the commit record. We should have - * cleaned up our previous buffers by now, so if we are in abort -@@ -586,9 +588,10 @@ - descriptor = journal_get_descriptor_buffer(journal); - if (!descriptor) { - __journal_abort_hard(journal); -+ unlock_journal(journal); - goto skip_commit; - } -- -+ - /* AKPM: buglet - add `i' to tmp! */ - for (i = 0; i < jh2bh(descriptor)->b_size; i += 512) { - journal_header_t *tmp = -@@ -609,7 +612,6 @@ - put_bh(bh); /* One for getblk() */ - journal_unlock_journal_head(descriptor); - } -- lock_journal(journal); - - /* End of a transaction! Finally, we can do checkpoint - processing: any buffers committed as a result of this -@@ -617,6 +619,25 @@ - before. */ - - skip_commit: -+ -+ /* Call any callbacks that had been registered for handles in this -+ * transaction. It is up to the callback to free any allocated -+ * memory. -+ */ -+ if (!list_empty(&commit_transaction->t_jcb)) { -+ struct list_head *p, *n; -+ int error = is_journal_aborted(journal); -+ -+ list_for_each_safe(p, n, &commit_transaction->t_jcb) { -+ struct journal_callback *jcb; -+ -+ jcb = list_entry(p, struct journal_callback, jcb_list); -+ list_del(p); -+ jcb->jcb_func(jcb, error); -+ } -+ } -+ -+ lock_journal(journal); - - jbd_debug(3, "JBD: commit phase 7\n"); - -diff -ur kernel-2.4.18/fs/jbd/journal.c kernel-2.4.18.patched/fs/jbd/journal.c ---- kernel-2.4.18/fs/jbd/journal.c Tue May 7 16:43:17 2002 -+++ kernel-2.4.18.patched/fs/jbd/journal.c Thu May 30 13:38:14 2002 -@@ -58,6 +58,7 @@ - #endif - EXPORT_SYMBOL(journal_flush); - EXPORT_SYMBOL(journal_revoke); -+EXPORT_SYMBOL(journal_callback_set); - - EXPORT_SYMBOL(journal_init_dev); - EXPORT_SYMBOL(journal_init_inode); -diff -ur kernel-2.4.18/fs/jbd/transaction.c kernel-2.4.18.patched/fs/jbd/transaction.c ---- kernel-2.4.18/fs/jbd/transaction.c Tue May 7 16:43:17 2002 -+++ kernel-2.4.18.patched/fs/jbd/transaction.c Thu May 30 13:38:14 2002 -@@ -57,6 +57,7 @@ - transaction->t_state = T_RUNNING; - transaction->t_tid = journal->j_transaction_sequence++; - transaction->t_expires = jiffies + journal->j_commit_interval; -+ INIT_LIST_HEAD(&transaction->t_jcb); - - /* Set up the commit timer for the new transaction. */ - J_ASSERT (!journal->j_commit_timer_active); -@@ -201,6 +202,20 @@ - return 0; - } - -+/* Allocate a new handle. This should probably be in a slab... */ -+static handle_t *get_handle(int nblocks) -+{ -+ handle_t *handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ if (!handle) -+ return NULL; -+ memset(handle, 0, sizeof (handle_t)); -+ handle->h_buffer_credits = nblocks; -+ handle->h_ref = 1; -+ INIT_LIST_HEAD(&handle->h_jcb); -+ -+ return handle; -+} -+ - /* - * Obtain a new handle. - * -@@ -227,14 +242,11 @@ - handle->h_ref++; - return handle; - } -- -- handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ -+ handle = get_handle(nblocks); - if (!handle) - return ERR_PTR(-ENOMEM); -- memset (handle, 0, sizeof (handle_t)); - -- handle->h_buffer_credits = nblocks; -- handle->h_ref = 1; - current->journal_info = handle; - - err = start_this_handle(journal, handle); -@@ -333,14 +345,11 @@ - - if (is_journal_aborted(journal)) - return ERR_PTR(-EIO); -- -- handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ -+ handle = get_handle(nblocks); - if (!handle) - return ERR_PTR(-ENOMEM); -- memset (handle, 0, sizeof (handle_t)); - -- handle->h_buffer_credits = nblocks; -- handle->h_ref = 1; - current->journal_info = handle; - - err = try_start_this_handle(journal, handle); -@@ -1319,6 +1328,29 @@ - #endif - - /* -+ * Register a callback function for this handle. The function will be -+ * called when the transaction that this handle is part of has been -+ * committed to disk with the original callback data struct and the -+ * error status of the journal as parameters. There is no guarantee of -+ * ordering between handles within a single transaction, nor between -+ * callbacks registered on the same handle. -+ * -+ * The caller is responsible for allocating the journal_callback struct. -+ * This is to allow the caller to add as much extra data to the callback -+ * as needed, but reduce the overhead of multiple allocations. The caller -+ * allocated struct must start with a struct journal_callback at offset 0, -+ * and has the caller-specific data afterwards. -+ */ -+void journal_callback_set(handle_t *handle, void (*func)(void *, int), -+ void *cb_data) -+{ -+ struct journal_callback *jcb = cb_data; -+ -+ list_add(&jcb->jcb_list, &handle->h_jcb); -+ jcb->jcb_func = func; -+} -+ -+/* - * All done for a particular handle. - * - * There is not much action needed here. We just return any remaining -@@ -1383,7 +1415,10 @@ - wake_up(&journal->j_wait_transaction_locked); - } - -- /* -+ /* Move callbacks from the handle to the transaction. */ -+ list_splice(&handle->h_jcb, &transaction->t_jcb); -+ -+ /* - * If the handle is marked SYNC, we need to set another commit - * going! We also want to force a commit if the current - * transaction is occupying too much of the log, or if the -diff -ur kernel-2.4.18/include/linux/blkdev.h kernel-2.4.18.patched/include/linux/blkdev.h ---- kernel-2.4.18/include/linux/blkdev.h Tue May 7 15:46:15 2002 -+++ kernel-2.4.18.patched/include/linux/blkdev.h Thu May 30 13:42:25 2002 -@@ -276,4 +276,9 @@ - } - return retval; - } -+ -+#define CONFIG_DEV_RDONLY -+void dev_set_rdonly(kdev_t, int); -+int dev_check_rdonly(kdev_t); -+void dev_clear_rdonly(int); - #endif -diff -ur kernel-2.4.18/include/linux/fs.h kernel-2.4.18.patched/include/linux/fs.h ---- kernel-2.4.18/include/linux/fs.h Tue May 7 16:40:30 2002 -+++ kernel-2.4.18.patched/include/linux/fs.h Thu May 30 13:40:51 2002 -@@ -1034,6 +1034,7 @@ - extern struct vfsmount *kern_mount(struct file_system_type *); - extern int may_umount(struct vfsmount *); - extern long do_mount(char *, char *, char *, unsigned long, void *); -+struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data); - extern void umount_tree(struct vfsmount *); - - #define kern_umount mntput -diff -ur kernel-2.4.18/include/linux/jbd.h kernel-2.4.18.patched/include/linux/jbd.h ---- kernel-2.4.18/include/linux/jbd.h Tue May 7 16:43:17 2002 -+++ kernel-2.4.18.patched/include/linux/jbd.h Thu May 30 13:38:14 2002 -@@ -257,6 +257,13 @@ - return bh->b_private; - } - -+#define HAVE_JOURNAL_CALLBACK_STATUS -+struct journal_callback { -+ struct list_head jcb_list; -+ void (*jcb_func)(void *cb_data, int error); -+ /* user data goes here */ -+}; -+ - struct jbd_revoke_table_s; - - /* The handle_t type represents a single atomic update being performed -@@ -287,6 +294,12 @@ - operations */ - int h_err; - -+ /* List of application registered callbacks for this handle. -+ * The function(s) will be called after the transaction that -+ * this handle is part of has been committed to disk. -+ */ -+ struct list_head h_jcb; -+ - /* Flags */ - unsigned int h_sync: 1; /* sync-on-close */ - unsigned int h_jdata: 1; /* force data journaling */ -@@ -406,6 +419,10 @@ - - /* How many handles used this transaction? */ - int t_handle_count; -+ -+ /* List of registered callback functions for this transaction. -+ * Called when the transaction is committed. */ -+ struct list_head t_jcb; - }; - - -@@ -654,6 +671,8 @@ - extern int journal_try_to_free_buffers(journal_t *, struct page *, int); - extern int journal_stop(handle_t *); - extern int journal_flush (journal_t *); -+extern void journal_callback_set(handle_t *handle, void (*fn)(void *, int), -+ void *cb_data); - - extern void journal_lock_updates (journal_t *); - extern void journal_unlock_updates (journal_t *); -diff -ur kernel-2.4.18/kernel/ksyms.c kernel-2.4.18.patched/kernel/ksyms.c ---- kernel-2.4.18/kernel/ksyms.c Mon May 20 00:15:42 2002 -+++ kernel-2.4.18.patched/kernel/ksyms.c Thu May 30 13:38:14 2002 -@@ -305,6 +305,11 @@ - EXPORT_SYMBOL(lock_may_write); - EXPORT_SYMBOL(dcache_readdir); - -+/* lustre */ -+EXPORT_SYMBOL(pagecache_lock); -+EXPORT_SYMBOL(do_kern_mount); -+ -+ - /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */ - EXPORT_SYMBOL(default_llseek); - EXPORT_SYMBOL(dentry_open); ---- linux/include/linux/fs.h.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/include/linux/fs.h Tue Jun 4 09:24:48 2002 -@@ -314,8 +314,8 @@ - #include - #include - #include --#include - #include -+#include - #include - - /* -@@ -506,8 +506,8 @@ - struct proc_inode_info proc_i; - struct socket socket_i; - struct usbdev_inode_info usbdev_i; -- struct hostfs_inode_info hostfs_i; - struct jffs2_inode_info jffs2_i; -+ struct hostfs_inode_info hostfs_i; - void *generic_ip; - } u; - }; -@@ -536,6 +536,7 @@ - - /* needed for tty driver, and maybe others */ - void *private_data; -+ struct lookup_intent *f_intent; - - /* preallocated helper kiobuf to speedup O_DIRECT */ - struct kiobuf *f_iobuf; -@@ -779,7 +780,9 @@ - extern int vfs_link(struct dentry *, struct inode *, struct dentry *); - extern int vfs_rmdir(struct inode *, struct dentry *); - extern int vfs_unlink(struct inode *, struct dentry *); --extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); -+int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it); - - /* - * File types -@@ -840,6 +843,7 @@ - struct inode_operations { - int (*create) (struct inode *,struct dentry *,int); - struct dentry * (*lookup) (struct inode *,struct dentry *); -+ struct dentry * (*lookup2) (struct inode *,struct dentry *, struct lookup_intent *); - int (*link) (struct dentry *,struct inode *,struct dentry *); - int (*unlink) (struct inode *,struct dentry *); - int (*symlink) (struct inode *,struct dentry *,const char *); -@@ -855,6 +859,10 @@ - int (*revalidate) (struct dentry *); - int (*setattr) (struct dentry *, struct iattr *); - int (*getattr) (struct dentry *, struct iattr *); -+ int (*setxattr) (struct dentry *, const char *, void *, size_t, int); -+ ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); -+ ssize_t (*listxattr) (struct dentry *, char *, size_t); -+ int (*removexattr) (struct dentry *, const char *); - }; - - struct seq_file; -@@ -1307,6 +1315,7 @@ - extern loff_t default_llseek(struct file *file, loff_t offset, int origin); - - extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *)); -+extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it)); - extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *)); - extern int FASTCALL(path_walk(const char *, struct nameidata *)); - extern int FASTCALL(link_path_walk(const char *, struct nameidata *)); -@@ -1317,6 +1326,8 @@ - extern struct dentry * lookup_hash(struct qstr *, struct dentry *); - #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd) - #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd) -+#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it) -+#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it) - - extern void iput(struct inode *); - extern void force_delete(struct inode *); ---- linux/include/linux/dcache.h.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/include/linux/dcache.h Tue Jun 4 09:24:45 2002 -@@ -6,6 +6,28 @@ - #include - #include - -+#define IT_OPEN (1) -+#define IT_CREAT (1<<1) -+#define IT_MKDIR (1<<2) -+#define IT_LINK (1<<3) -+#define IT_SYMLINK (1<<4) -+#define IT_UNLINK (1<<5) -+#define IT_RMDIR (1<<6) -+#define IT_RENAME (1<<7) -+#define IT_READDIR (1<<8) -+#define IT_GETATTR (1<<9) -+#define IT_SETATTR (1<<10) -+#define IT_READLINK (1<<11) -+ -+struct lookup_intent { -+ int it_op; -+ int it_mode; -+ int it_disposition; -+ int it_status; -+ struct iattr *it_iattr; -+ void *it_data; -+}; -+ - /* - * linux/include/linux/dcache.h - * -@@ -79,17 +101,20 @@ - struct dentry_operations *d_op; - struct super_block * d_sb; /* The root of the dentry tree */ - unsigned long d_vfs_flags; -+ struct lookup_intent *d_it; - void * d_fsdata; /* fs-specific data */ - unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */ - }; - - struct dentry_operations { - int (*d_revalidate)(struct dentry *, int); -+ int (*d_revalidate2)(struct dentry *, int, struct lookup_intent *); - int (*d_hash) (struct dentry *, struct qstr *); - int (*d_compare) (struct dentry *, struct qstr *, struct qstr *); - int (*d_delete)(struct dentry *); - void (*d_release)(struct dentry *); - void (*d_iput)(struct dentry *, struct inode *); -+ void (*d_intent_rel)(struct dentry *); - }; - - /* the dentry parameter passed to d_hash and d_compare is the parent ---- linux/fs/namei.c.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/fs/namei.c Mon Jun 3 16:14:56 2002 -@@ -94,6 +94,14 @@ - * XEmacs seems to be relying on it... - */ - -+void intent_release(struct dentry *de) -+{ -+ if (de->d_op && de->d_op->d_intent_rel) -+ de->d_op->d_intent_rel(de); -+ de->d_it = NULL; -+} -+ -+ - /* In order to reduce some races, while at the same time doing additional - * checking and hopefully speeding things up, we copy filenames to the - * kernel data space before using them.. -@@ -260,10 +268,18 @@ - * Internal lookup() using the new generic dcache. - * SMP-safe - */ --static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags) -+static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it) - { - struct dentry * dentry = d_lookup(parent, name); - -+ if (dentry && dentry->d_op && dentry->d_op->d_revalidate2) { -+ if (!dentry->d_op->d_revalidate2(dentry, flags, it) && !d_invalidate(dentry)) { -+ dput(dentry); -+ dentry = NULL; -+ } -+ return dentry; -+ } -+ - if (dentry && dentry->d_op && dentry->d_op->d_revalidate) { - if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) { - dput(dentry); -@@ -281,7 +297,7 @@ - * make sure that nobody added the entry to the dcache in the meantime.. - * SMP-safe - */ --static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags) -+static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it) - { - struct dentry * result; - struct inode *dir = parent->d_inode; -@@ -300,6 +316,9 @@ - result = ERR_PTR(-ENOMEM); - if (dentry) { - lock_kernel(); -+ if (dir->i_op->lookup2) -+ result = dir->i_op->lookup2(dir, dentry, it); -+ else - result = dir->i_op->lookup(dir, dentry); - unlock_kernel(); - if (result) -@@ -322,6 +341,12 @@ - result = ERR_PTR(-ENOENT); - } - } -+ if (result->d_op && result->d_op->d_revalidate2) { -+ if (!result->d_op->d_revalidate2(result, flags, it) && !d_invalidate(result)) { -+ dput(result); -+ result = ERR_PTR(-ENOENT); -+ } -+ } - return result; - } - -@@ -445,7 +470,7 @@ - * - * We expect 'base' to be positive and a directory. - */ --int link_path_walk(const char * name, struct nameidata *nd) -+int link_path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it) - { - struct dentry *dentry; - struct inode *inode; -@@ -518,9 +543,9 @@ - break; - } - /* This does the actual lookups.. */ -- dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE); -+ dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL); - if (!dentry) { -- dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE); -+ dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL); - err = PTR_ERR(dentry); - if (IS_ERR(dentry)) - break; -@@ -554,7 +579,7 @@ - nd->dentry = dentry; - } - err = -ENOTDIR; -- if (!inode->i_op->lookup) -+ if (!inode->i_op->lookup && !inode->i_op->lookup2) - break; - continue; - /* here ends the main loop */ -@@ -581,9 +606,9 @@ - if (err < 0) - break; - } -- dentry = cached_lookup(nd->dentry, &this, 0); -+ dentry = cached_lookup(nd->dentry, &this, 0, it); - if (!dentry) { -- dentry = real_lookup(nd->dentry, &this, 0); -+ dentry = real_lookup(nd->dentry, &this, 0, it); - err = PTR_ERR(dentry); - if (IS_ERR(dentry)) - break; -@@ -607,7 +632,8 @@ - goto no_inode; - if (lookup_flags & LOOKUP_DIRECTORY) { - err = -ENOTDIR; -- if (!inode->i_op || !inode->i_op->lookup) -+ if (!inode->i_op || (!inode->i_op->lookup && -+ !inode->i_op->lookup2)) - break; - } - goto return_base; -@@ -636,12 +662,24 @@ - return err; - } - -+int link_path_walk(const char * name, struct nameidata *nd) -+{ -+ return link_path_walk_it(name, nd, NULL); -+} -+ -+int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it) -+{ -+ current->total_link_count = 0; -+ return link_path_walk_it(name, nd, it); -+} -+ - int path_walk(const char * name, struct nameidata *nd) - { - current->total_link_count = 0; -- return link_path_walk(name, nd); -+ return link_path_walk_it(name, nd, NULL); - } - -+ - /* SMP-safe */ - /* returns 1 if everything is done */ - static int __emul_lookup_dentry(const char *name, struct nameidata *nd) -@@ -742,7 +780,8 @@ - * needs parent already locked. Doesn't follow mounts. - * SMP-safe. - */ --struct dentry * lookup_hash(struct qstr *name, struct dentry * base) -+struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base, -+ struct lookup_intent *it) - { - struct dentry * dentry; - struct inode *inode; -@@ -765,13 +804,16 @@ - goto out; - } - -- dentry = cached_lookup(base, name, 0); -+ dentry = cached_lookup(base, name, 0, it); - if (!dentry) { - struct dentry *new = d_alloc(base, name); - dentry = ERR_PTR(-ENOMEM); - if (!new) - goto out; - lock_kernel(); -+ if (inode->i_op->lookup2) -+ dentry = inode->i_op->lookup2(inode, new, it); -+ else - dentry = inode->i_op->lookup(inode, new); - unlock_kernel(); - if (!dentry) -@@ -783,6 +825,12 @@ - return dentry; - } - -+struct dentry * lookup_hash(struct qstr *name, struct dentry * base) -+{ -+ return lookup_hash_it(name, base, NULL); -+} -+ -+ - /* SMP-safe */ - struct dentry * lookup_one_len(const char * name, struct dentry * base, int len) - { -@@ -804,7 +852,7 @@ - } - this.hash = end_name_hash(hash); - -- return lookup_hash(&this, base); -+ return lookup_hash_it(&this, base, NULL); - access: - return ERR_PTR(-EACCES); - } -@@ -836,6 +884,22 @@ - return err; - } - -+int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd, struct lookup_intent *it) -+{ -+ char *tmp; -+ int err; -+ -+ tmp = getname(name); -+ err = PTR_ERR(tmp); -+ if (!IS_ERR(tmp)) { -+ err = 0; -+ if (path_init(tmp, flags, nd)) -+ err = path_walk_it(tmp, nd, it); -+ putname(tmp); -+ } -+ return err; -+} -+ - /* - * It's inline, so penalty for filesystems that don't use sticky bit is - * minimal. -@@ -970,7 +1034,8 @@ - * for symlinks (where the permissions are checked later). - * SMP-safe - */ --int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) -+int open_namei_it(const char * pathname, int flag, int mode, struct nameidata *nd, -+ struct lookup_intent *it) - { - int acc_mode, error = 0; - struct inode *inode; -@@ -984,8 +1049,9 @@ - * The simplest case - just a plain lookup. - */ - if (!(flag & O_CREAT)) { -+ - if (path_init(pathname, lookup_flags(flag), nd)) -- error = path_walk(pathname, nd); -+ error = path_walk_it(pathname, nd, it); - if (error) - return error; - dentry = nd->dentry; -@@ -995,6 +1061,8 @@ - /* - * Create - we need to know the parent. - */ -+ if (it) -+ it->it_op |= IT_CREAT; - if (path_init(pathname, LOOKUP_PARENT, nd)) - error = path_walk(pathname, nd); - if (error) -@@ -1011,7 +1079,7 @@ - - dir = nd->dentry; - down(&dir->d_inode->i_sem); -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, it); - - do_last: - error = PTR_ERR(dentry); -@@ -1022,6 +1090,7 @@ - - /* Negative dentry, just create the file */ - if (!dentry->d_inode) { -+ dentry->d_it = it; - error = vfs_create(dir->d_inode, dentry, - mode & ~current->fs->umask); - up(&dir->d_inode->i_sem); -@@ -1181,13 +1250,20 @@ - } - dir = nd->dentry; - down(&dir->d_inode->i_sem); -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, NULL); - putname(nd->last.name); - goto do_last; - } - -+int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) -+{ -+ return open_namei_it(pathname, flag, mode, nd, NULL); -+} -+ -+ - /* SMP-safe */ --static struct dentry *lookup_create(struct nameidata *nd, int is_dir) -+static struct dentry *lookup_create(struct nameidata *nd, int is_dir, -+ struct lookup_intent *it) - { - struct dentry *dentry; - -@@ -1195,7 +1271,7 @@ - dentry = ERR_PTR(-EEXIST); - if (nd->last_type != LAST_NORM) - goto fail; -- dentry = lookup_hash(&nd->last, nd->dentry); -+ dentry = lookup_hash_it(&nd->last, nd->dentry, it); - if (IS_ERR(dentry)) - goto fail; - if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) -@@ -1241,6 +1317,7 @@ - char * tmp; - struct dentry * dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_CREAT , mode }; - - if (S_ISDIR(mode)) - return -EPERM; -@@ -1252,11 +1329,12 @@ - error = path_walk(tmp, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 0); -+ dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(dentry); - - mode &= ~current->fs->umask; - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - switch (mode & S_IFMT) { - case 0: case S_IFREG: - error = vfs_create(nd.dentry->d_inode,dentry,mode); -@@ -1272,6 +1350,7 @@ - } - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1310,6 +1389,7 @@ - { - int error = 0; - char * tmp; -+ struct lookup_intent it = { IT_MKDIR, mode }; - - tmp = getname(pathname); - error = PTR_ERR(tmp); -@@ -1321,13 +1401,15 @@ - error = path_walk(tmp, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 1); -+ dentry = lookup_create(&nd, 1, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_mkdir(nd.dentry->d_inode, dentry, - mode & ~current->fs->umask); - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1407,6 +1489,7 @@ - char * name; - struct dentry *dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_RMDIR, 0 }; - - name = getname(pathname); - if(IS_ERR(name)) -@@ -1429,10 +1512,12 @@ - goto exit1; - } - down(&nd.dentry->d_inode->i_sem); -- dentry = lookup_hash(&nd.last, nd.dentry); -+ dentry = lookup_hash_it(&nd.last, nd.dentry, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_rmdir(nd.dentry->d_inode, dentry); -+ intent_release(dentry); - dput(dentry); - } - up(&nd.dentry->d_inode->i_sem); -@@ -1476,6 +1561,7 @@ - char * name; - struct dentry *dentry; - struct nameidata nd; -+ struct lookup_intent it = { IT_UNLINK, 0 }; - - name = getname(pathname); - if(IS_ERR(name)) -@@ -1489,14 +1575,16 @@ - if (nd.last_type != LAST_NORM) - goto exit1; - down(&nd.dentry->d_inode->i_sem); -- dentry = lookup_hash(&nd.last, nd.dentry); -+ dentry = lookup_hash_it(&nd.last, nd.dentry, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - /* Why not before? Because we want correct error value */ - if (nd.last.name[nd.last.len]) - goto slashes; - error = vfs_unlink(nd.dentry->d_inode, dentry); - exit2: -+ intent_release(dentry); - dput(dentry); - } - up(&nd.dentry->d_inode->i_sem); -@@ -1543,6 +1631,7 @@ - int error = 0; - char * from; - char * to; -+ struct lookup_intent it = { IT_SYMLINK, 0 }; - - from = getname(oldname); - if(IS_ERR(from)) -@@ -1557,12 +1646,14 @@ - error = path_walk(to, &nd); - if (error) - goto out; -- dentry = lookup_create(&nd, 0); -+ dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(dentry); - if (!IS_ERR(dentry)) { -+ dentry->d_it = ⁢ - error = vfs_symlink(nd.dentry->d_inode, dentry, from); - dput(dentry); - } -+ intent_release(dentry); - up(&nd.dentry->d_inode->i_sem); - path_release(&nd); - out: -@@ -1626,6 +1717,7 @@ - int error; - char * from; - char * to; -+ struct lookup_intent it = { IT_LINK, 0 }; - - from = getname(oldname); - if(IS_ERR(from)) -@@ -1648,12 +1740,14 @@ - error = -EXDEV; - if (old_nd.mnt != nd.mnt) - goto out_release; -- new_dentry = lookup_create(&nd, 0); -+ new_dentry = lookup_create(&nd, 0, &it); - error = PTR_ERR(new_dentry); - if (!IS_ERR(new_dentry)) { -+ new_dentry->d_it = ⁢ - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); - dput(new_dentry); - } -+ intent_release(new_dentry); - up(&nd.dentry->d_inode->i_sem); - out_release: - path_release(&nd); -@@ -1694,7 +1788,8 @@ - * locking]. - */ - int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - struct inode *target; -@@ -1748,12 +1843,14 @@ - } else - double_down(&old_dir->i_zombie, - &new_dir->i_zombie); -+ new_dentry->d_it = it; - if (IS_DEADDIR(old_dir)||IS_DEADDIR(new_dir)) - error = -ENOENT; - else if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) - error = -EBUSY; - else - error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); -+ intent_release(new_dentry); - if (target) { - if (!error) - target->i_flags |= S_DEAD; -@@ -1775,7 +1872,8 @@ - } - - int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - -@@ -1802,10 +1900,12 @@ - DQUOT_INIT(old_dir); - DQUOT_INIT(new_dir); - double_down(&old_dir->i_zombie, &new_dir->i_zombie); -+ new_dentry->d_it = it; - if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) - error = -EBUSY; - else - error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); -+ intent_release(new_dentry); - double_up(&old_dir->i_zombie, &new_dir->i_zombie); - if (error) - return error; -@@ -1817,13 +1917,14 @@ - } - - int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, -- struct inode *new_dir, struct dentry *new_dentry) -+ struct inode *new_dir, struct dentry *new_dentry, -+ struct lookup_intent *it) - { - int error; - if (S_ISDIR(old_dentry->d_inode->i_mode)) -- error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry); -+ error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry, it); - else -- error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); -+ error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry, it); - if (!error) { - if (old_dir == new_dir) - inode_dir_notify(old_dir, DN_RENAME); -@@ -1841,6 +1942,7 @@ - struct dentry * old_dir, * new_dir; - struct dentry * old_dentry, *new_dentry; - struct nameidata oldnd, newnd; -+ struct lookup_intent it = {IT_RENAME, 0}; - - if (path_init(oldname, LOOKUP_PARENT, &oldnd)) - error = path_walk(oldname, &oldnd); -@@ -1868,7 +1970,9 @@ - - double_lock(new_dir, old_dir); - -- old_dentry = lookup_hash(&oldnd.last, old_dir); -+ it.it_op = IT_RENAME; -+ it.it_mode = 0; -+ old_dentry = lookup_hash_it(&oldnd.last, old_dir, &it); - error = PTR_ERR(old_dentry); - if (IS_ERR(old_dentry)) - goto exit3; -@@ -1884,14 +1988,14 @@ - if (newnd.last.name[newnd.last.len]) - goto exit4; - } -- new_dentry = lookup_hash(&newnd.last, new_dir); -+ new_dentry = lookup_hash_it(&newnd.last, new_dir, &it); - error = PTR_ERR(new_dentry); - if (IS_ERR(new_dentry)) - goto exit4; - - lock_kernel(); - error = vfs_rename(old_dir->d_inode, old_dentry, -- new_dir->d_inode, new_dentry); -+ new_dir->d_inode, new_dentry, &it); - unlock_kernel(); - - dput(new_dentry); ---- linux/fs/open.c.lustre-orig Wed May 22 08:29:48 2002 -+++ linux/fs/open.c Wed May 22 08:29:48 2002 -@@ -630,10 +630,15 @@ - * for the internal routines (ie open_namei()/follow_link() etc). 00 is - * used by symlinks. - */ -+extern int open_namei_it(const char *filename, int namei_flags, int mode, -+ struct nameidata *nd, struct lookup_intent *it); -+struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it); -+ - struct file *filp_open(const char * filename, int flags, int mode) - { - int namei_flags, error; - struct nameidata nd; -+ struct lookup_intent it = {IT_OPEN, 0}; - - namei_flags = flags; - if ((namei_flags+1) & O_ACCMODE) -@@ -641,14 +646,14 @@ - if (namei_flags & O_TRUNC) - namei_flags |= 2; - -- error = open_namei(filename, namei_flags, mode, &nd); -+ error = open_namei_it(filename, namei_flags, mode, &nd, &it); - if (!error) -- return dentry_open(nd.dentry, nd.mnt, flags); -+ return dentry_open_it(nd.dentry, nd.mnt, flags, &it); - - return ERR_PTR(error); - } - --struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) -+struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it) - { - struct file * f; - struct inode *inode; -@@ -690,6 +695,7 @@ - goto cleanup_all; - } - f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); -+ f->f_intent = it; - - return f; - -@@ -710,6 +716,13 @@ - return ERR_PTR(error); - } - -+struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) -+{ -+ return dentry_open_it(dentry, mnt, flags, NULL); -+ -+} -+ -+ - /* - * Find an empty file descriptor entry, and mark it busy. - */ diff --git a/lustre/patches/patch-2.4.3-empty-super b/lustre/patches/patch-2.4.3-empty-super deleted file mode 100644 index 02603fd..0000000 --- a/lustre/patches/patch-2.4.3-empty-super +++ /dev/null @@ -1,31 +0,0 @@ ---- linux/fs/super.c.orig Sat Sep 29 09:40:16 2001 -+++ linux/fs/super.c Sat Sep 29 09:40:42 2001 -@@ -695,7 +695,7 @@ - * the request. - */ - --static struct super_block *get_empty_super(void) -+struct super_block *get_empty_super(void) - { - struct super_block *s; - ---- linux/include/linux/fs.h.orig Sat Sep 29 09:42:14 2001 -+++ linux/include/linux/fs.h Sat Sep 29 09:42:55 2001 -@@ -1360,6 +1360,7 @@ - extern struct file_system_type *get_fs_type(const char *name); - extern struct super_block *get_super(kdev_t); - extern void put_super(kdev_t); -+struct super_block *get_empty_super(void); - unsigned long generate_cluster(kdev_t, int b[], int); - unsigned long generate_cluster_swab32(kdev_t, int b[], int); - extern kdev_t ROOT_DEV; ---- linux/kernel/ksyms.c.orig Sat Sep 29 09:40:56 2001 -+++ linux/kernel/ksyms.c Sat Sep 29 09:41:17 2001 -@@ -142,6 +142,7 @@ - EXPORT_SYMBOL(igrab); - EXPORT_SYMBOL(iunique); - EXPORT_SYMBOL(iget4); -+EXPORT_SYMBOL(get_empty_super); - EXPORT_SYMBOL(iput); - EXPORT_SYMBOL(force_delete); - EXPORT_SYMBOL(follow_up); diff --git a/lustre/patches/patch-2.4.9-ac10 b/lustre/patches/patch-2.4.9-ac10 deleted file mode 100644 index 0ad2377..0000000 --- a/lustre/patches/patch-2.4.9-ac10 +++ /dev/null @@ -1,22 +0,0 @@ -diff -u linux-2.4.9-ac10.orig/include/linux/fs.h linux-2.4.9-ac10/include/linux/fs.h ---- linux-2.4.9-ac10.orig/include/linux/fs.h Mon Sep 24 11:15:51 2001 -+++ linux-2.4.9-ac10/include/linux/fs.h Thu Sep 20 16:55:36 2001 -@@ -1440,6 +1440,7 @@ - extern int dcache_readdir(struct file *, void *, filldir_t); - - extern struct file_system_type *get_fs_type(const char *name); -+struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data); - extern struct super_block *get_super(kdev_t); - extern void drop_super(struct super_block *sb); - static inline int is_mounted(kdev_t dev) -diff -u linux-2.4.9-ac10.orig/kernel/ksyms.c linux-2.4.9-ac10/kernel/ksyms.c ---- linux-2.4.9-ac10.orig/kernel/ksyms.c Mon Sep 24 11:15:52 2001 -+++ linux-2.4.9-ac10/kernel/ksyms.c Thu Sep 20 16:42:30 2001 -@@ -131,6 +131,7 @@ - EXPORT_SYMBOL(def_blk_fops); - EXPORT_SYMBOL(update_atime); - EXPORT_SYMBOL(get_fs_type); -+EXPORT_SYMBOL(do_kern_mount); - EXPORT_SYMBOL(get_super); - EXPORT_SYMBOL(drop_super); - EXPORT_SYMBOL(getname); diff --git a/lustre/patches/patch-2.4.9-chaos14 b/lustre/patches/patch-2.4.9-chaos14 deleted file mode 100644 index 24b5628..0000000 --- a/lustre/patches/patch-2.4.9-chaos14 +++ /dev/null @@ -1,331 +0,0 @@ -diff -ru ../kernel-2.4.9/drivers/block/blkpg.c ../kernel-2.4.9-lustre/drivers/block/blkpg.c ---- ../kernel-2.4.9/drivers/block/blkpg.c Wed Oct 31 17:50:05 2001 -+++ ../kernel-2.4.9-lustre/drivers/block/blkpg.c Mon May 13 14:35:35 2002 -@@ -326,7 +326,43 @@ - - EXPORT_SYMBOL(blk_ioctl); - -- /********************* -+#define NUM_DEV_NO_WRITE 16 -+static int dev_no_write[NUM_DEV_NO_WRITE]; -+ -+/* -+ * Debug code for turning block devices "read-only" (will discard writes -+ * silently). This is for filesystem crash/recovery testing. -+ */ -+void dev_set_rdonly(kdev_t dev, int no_write) -+{ -+ if (dev) { -+ printk(KERN_WARNING "Turning device %s read-only\n", -+ bdevname(dev)); -+ dev_no_write[no_write] = 0xdead0000 + dev; -+ } -+} -+ -+int dev_check_rdonly(kdev_t dev) { -+ int i; -+ -+ for (i = 0; i < NUM_DEV_NO_WRITE; i++) { -+ if ((dev_no_write[i] & 0xffff0000) == 0xdead0000 && -+ dev == (dev_no_write[i] & 0xffff)) -+ return 1; -+ } -+ return 0; -+} -+ -+void dev_clear_rdonly(int no_write) { -+ dev_no_write[no_write] = 0; -+} -+ -+EXPORT_SYMBOL(dev_set_rdonly); -+EXPORT_SYMBOL(dev_check_rdonly); -+EXPORT_SYMBOL(dev_clear_rdonly); -+ -+ -+/********************* - * get_last_sector() - * - * Description: This function will read any inaccessible blocks at the end -diff -ru ../kernel-2.4.9/drivers/block/loop.c ../kernel-2.4.9-lustre/drivers/block/loop.c ---- ../kernel-2.4.9/drivers/block/loop.c Wed Oct 31 17:50:05 2001 -+++ ../kernel-2.4.9-lustre/drivers/block/loop.c Mon May 13 14:23:05 2002 -@@ -482,6 +482,11 @@ - spin_unlock_irq(&lo->lo_lock); - - if (rw == WRITE) { -+#ifdef CONFIG_DEV_RDONLY -+ if (dev_check_rdonly(rbh->b_rdev)) -+ goto err; -+#endif -+ - if (lo->lo_flags & LO_FLAGS_READ_ONLY) - goto err; - } else if (rw == READA) { -diff -ru ../kernel-2.4.9/drivers/ide/ide-disk.c ../kernel-2.4.9-lustre/drivers/ide/ide-disk.c ---- ../kernel-2.4.9/drivers/ide/ide-disk.c Wed Oct 31 17:50:21 2001 -+++ ../kernel-2.4.9-lustre/drivers/ide/ide-disk.c Mon May 13 14:23:05 2002 -@@ -374,6 +374,12 @@ - */ - static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block) - { -+#ifdef CONFIG_DEV_RDONLY -+ if (rq->cmd == WRITE && dev_check_rdonly(rq->rq_dev)) { -+ ide_end_request(1, HWGROUP(drive)); -+ return ide_stopped; -+ } -+#endif - if (IDE_CONTROL_REG) - OUT_BYTE(drive->ctl,IDE_CONTROL_REG); - OUT_BYTE(0x00, IDE_FEATURE_REG); -diff -ru ../kernel-2.4.9/fs/jbd/commit.c ../kernel-2.4.9-lustre/fs/jbd/commit.c ---- ../kernel-2.4.9/fs/jbd/commit.c Wed Oct 31 17:51:37 2001 -+++ ../kernel-2.4.9-lustre/fs/jbd/commit.c Mon May 13 14:23:05 2002 -@@ -462,7 +462,7 @@ - transaction's t_log_list queue, and metadata buffers are on - the t_iobuf_list queue. - -- Wait for the transactions in reverse order. That way we are -+ Wait for the buffers in reverse order. That way we are - less likely to be woken up until all IOs have completed, and - so we incur less scheduling load. - */ -@@ -566,8 +566,10 @@ - - jbd_debug(3, "JBD: commit phase 6\n"); - -- if (is_journal_aborted(journal)) -+ if (is_journal_aborted(journal)) { -+ unlock_journal(journal); - goto skip_commit; -+ } - - /* Done it all: now write the commit record. We should have - * cleaned up our previous buffers by now, so if we are in abort -@@ -577,9 +579,10 @@ - descriptor = journal_get_descriptor_buffer(journal); - if (!descriptor) { - __journal_abort_hard(journal); -+ unlock_journal(journal); - goto skip_commit; - } -- -+ - /* AKPM: buglet - add `i' to tmp! */ - for (i = 0; i < jh2bh(descriptor)->b_size; i += 512) { - journal_header_t *tmp = -@@ -600,7 +603,6 @@ - put_bh(bh); /* One for getblk() */ - journal_unlock_journal_head(descriptor); - } -- lock_journal(journal); - - /* End of a transaction! Finally, we can do checkpoint - processing: any buffers committed as a result of this -@@ -609,6 +611,25 @@ - - skip_commit: - -+ /* Call any callbacks that had been registered for handles in this -+ * transaction. It is up to the callback to free any allocated -+ * memory. -+ */ -+ if (!list_empty(&commit_transaction->t_jcb)) { -+ struct list_head *p, *n; -+ int error = is_journal_aborted(journal); -+ -+ list_for_each_safe(p, n, &commit_transaction->t_jcb) { -+ struct journal_callback *jcb; -+ -+ jcb = list_entry(p, struct journal_callback, jcb_list); -+ list_del(p); -+ jcb->jcb_func(jcb, error); -+ } -+ } -+ -+ lock_journal(journal); -+ - jbd_debug(3, "JBD: commit phase 7\n"); - - J_ASSERT(commit_transaction->t_sync_datalist == NULL); -diff -ru ../kernel-2.4.9/fs/jbd/journal.c ../kernel-2.4.9-lustre/fs/jbd/journal.c ---- ../kernel-2.4.9/fs/jbd/journal.c Wed Oct 31 17:51:37 2001 -+++ ../kernel-2.4.9-lustre/fs/jbd/journal.c Mon May 13 14:23:05 2002 -@@ -56,6 +56,7 @@ - #endif - EXPORT_SYMBOL(journal_flush); - EXPORT_SYMBOL(journal_revoke); -+EXPORT_SYMBOL(journal_callback_set); - - EXPORT_SYMBOL(journal_init_dev); - EXPORT_SYMBOL(journal_init_inode); -diff -ru ../kernel-2.4.9/fs/jbd/transaction.c ../kernel-2.4.9-lustre/fs/jbd/transaction.c ---- ../kernel-2.4.9/fs/jbd/transaction.c Sat Jan 26 01:42:21 2002 -+++ ../kernel-2.4.9-lustre/fs/jbd/transaction.c Mon May 13 14:23:05 2002 -@@ -59,6 +59,7 @@ - transaction->t_state = T_RUNNING; - transaction->t_tid = journal->j_transaction_sequence++; - transaction->t_expires = jiffies + journal->j_commit_interval; -+ INIT_LIST_HEAD(&transaction->t_jcb); - - /* Set up the commit timer for the new transaction. */ - J_ASSERT (!journal->j_commit_timer_active); -@@ -202,6 +203,20 @@ - return 0; - } - -+/* Allocate a new handle. This should probably be in a slab... */ -+static handle_t *get_handle(int nblocks) -+{ -+ handle_t *handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ if (!handle) -+ return NULL; -+ memset(handle, 0, sizeof (handle_t)); -+ handle->h_buffer_credits = nblocks; -+ handle->h_ref = 1; -+ INIT_LIST_HEAD(&handle->h_jcb); -+ -+ return handle; -+} -+ - /* - * Obtain a new handle. - * -@@ -228,14 +243,11 @@ - handle->h_ref++; - return handle; - } -- -- handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ -+ handle = get_handle(nblocks); - if (!handle) - return ERR_PTR(-ENOMEM); -- memset (handle, 0, sizeof (handle_t)); - -- handle->h_buffer_credits = nblocks; -- handle->h_ref = 1; - current->journal_info = handle; - - err = start_this_handle(journal, handle); -@@ -334,14 +346,11 @@ - - if (is_journal_aborted(journal)) - return ERR_PTR(-EIO); -- -- handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS); -+ -+ handle = get_handle(nblocks); - if (!handle) - return ERR_PTR(-ENOMEM); -- memset (handle, 0, sizeof (handle_t)); - -- handle->h_buffer_credits = nblocks; -- handle->h_ref = 1; - current->journal_info = handle; - - err = try_start_this_handle(journal, handle); -@@ -1328,6 +1337,29 @@ - #endif - - /* -+ * Register a callback function for this handle. The function will be -+ * called when the transaction that this handle is part of has been -+ * committed to disk with the original callback data struct and the -+ * error status of the journal as parameters. There is no guarantee of -+ * ordering between handles within a single transaction, nor between -+ * callbacks registered on the same handle. -+ * -+ * The caller is responsible for allocating the journal_callback struct. -+ * This is to allow the caller to add as much extra data to the callback -+ * as needed, but reduce the overhead of multiple allocations. The caller -+ * allocated struct must start with a struct journal_callback at offset 0, -+ * and has the caller-specific data afterwards. -+ */ -+void journal_callback_set(handle_t *handle, void (*func)(void *, int), -+ void *cb_data) -+{ -+ struct journal_callback *jcb = cb_data; -+ -+ list_add(&jcb->jcb_list, &handle->h_jcb); -+ jcb->jcb_func = func; -+} -+ -+/* - * All done for a particular handle. - * - * There is not much action needed here. We just return any remaining -@@ -1409,7 +1439,10 @@ - wake_up(&journal->j_wait_transaction_locked); - } - -- /* -+ /* Move callbacks from the handle to the transaction. */ -+ list_splice(&handle->h_jcb, &transaction->t_jcb); -+ -+ /* - * If the handle is marked SYNC, we need to set another commit - * going! We also want to force a commit if the current - * transaction is occupying too much of the log, or if the -diff -ru ../kernel-2.4.9/include/linux/blkdev.h ../kernel-2.4.9-lustre/include/linux/blkdev.h ---- ../kernel-2.4.9/include/linux/blkdev.h Thu May 9 12:59:13 2002 -+++ ../kernel-2.4.9-lustre/include/linux/blkdev.h Mon May 13 14:23:05 2002 -@@ -257,5 +257,9 @@ - #define blk_started_io(nsects) \ - atomic_add(nsects, &queued_sectors); - -+#define CONFIG_DEV_RDONLY -+void dev_set_rdonly(kdev_t, int); -+int dev_check_rdonly(kdev_t); -+void dev_clear_rdonly(int); - #endif - -diff -ru ../kernel-2.4.9/include/linux/jbd.h ../kernel-2.4.9-lustre/include/linux/jbd.h ---- ../kernel-2.4.9/include/linux/jbd.h Thu May 9 12:59:02 2002 -+++ ../kernel-2.4.9-lustre/include/linux/jbd.h Mon May 13 14:23:05 2002 -@@ -251,6 +251,13 @@ - return bh->b_private; - } - -+#define HAVE_JOURNAL_CALLBACK_STATUS -+struct journal_callback { -+ struct list_head jcb_list; -+ void (*jcb_func)(void *cb_data, int error); -+ /* user data goes here */ -+}; -+ - struct jbd_revoke_table_s; - - /* The handle_t type represents a single atomic update being performed -@@ -281,6 +288,12 @@ - operations */ - int h_err; - -+ /* List of application registered callbacks for this handle. -+ * The function(s) will be called after the transaction that -+ * this handle is part of has been committed to disk. -+ */ -+ struct list_head h_jcb; -+ - /* Flags */ - unsigned int h_sync: 1; /* sync-on-close */ - unsigned int h_jdata: 1; /* force data journaling */ -@@ -400,6 +413,10 @@ - - /* How many handles used this transaction? */ - int t_handle_count; -+ -+ /* List of registered callback functions for this transaction. -+ * Called when the transaction is committed. */ -+ struct list_head t_jcb; - }; - - -@@ -647,6 +664,8 @@ - extern int journal_try_to_free_buffers(journal_t *, struct page *, int); - extern int journal_stop(handle_t *); - extern int journal_flush (journal_t *); -+extern void journal_callback_set(handle_t *handle, void (*func)(void *), -+ void *cb_data); - - extern void journal_lock_updates (journal_t *); - extern void journal_unlock_updates (journal_t *); diff --git a/lustre/patches/patch-2.4.9-rh-ac13-xfs-1 b/lustre/patches/patch-2.4.9-rh-ac13-xfs-1 deleted file mode 100644 index 6211605..0000000 --- a/lustre/patches/patch-2.4.9-rh-ac13-xfs-1 +++ /dev/null @@ -1,110 +0,0 @@ ---- rpm/build/kernel-2.4.9/linux/include/linux/fs.h Mon Nov 5 22:20:00 2001 -+++ linux/include/linux/fs.h Mon Nov 5 22:24:09 2001 -@@ -1049,6 +1049,7 @@ - extern int register_filesystem(struct file_system_type *); - extern int unregister_filesystem(struct file_system_type *); - extern struct vfsmount *kern_mount(struct file_system_type *); -+struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data); - extern int may_umount(struct vfsmount *); - extern long do_mount(char *, char *, char *, unsigned long, void *); - -@@ -1474,6 +1475,7 @@ - extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *); - extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *); - extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t, int); -+ssize_t do_generic_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos, int (*actor)(char *, char *, size_t )); - - extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *); - extern loff_t generic_file_llseek(struct file *, loff_t, int); ---- rpm/build/kernel-2.4.9/linux/kernel/ksyms.c Mon Nov 5 22:20:00 2001 -+++ linux/kernel/ksyms.c Mon Nov 5 22:29:41 2001 -@@ -246,6 +246,7 @@ - EXPORT_SYMBOL(do_generic_file_read); - EXPORT_SYMBOL(flush_inode_pages); - EXPORT_SYMBOL(generic_file_write); -+EXPORT_SYMBOL(do_generic_file_write); - EXPORT_SYMBOL(generic_file_mmap); - EXPORT_SYMBOL(generic_ro_fops); - EXPORT_SYMBOL(generic_buffer_fdatasync); -@@ -286,6 +287,7 @@ - EXPORT_SYMBOL(__pollwait); - EXPORT_SYMBOL(poll_freewait); - EXPORT_SYMBOL(ROOT_DEV); -+//EXPORT_SYMBOL(pagecache_lock); - EXPORT_SYMBOL(__find_get_page); - EXPORT_SYMBOL(__find_lock_page); - EXPORT_SYMBOL(find_get_page_simple); -@@ -371,6 +373,7 @@ - EXPORT_SYMBOL(register_filesystem); - EXPORT_SYMBOL(unregister_filesystem); - EXPORT_SYMBOL(kern_mount); -+EXPORT_SYMBOL(do_kern_mount); - EXPORT_SYMBOL(__mntput); - EXPORT_SYMBOL(may_umount); - ---- rpm/build/kernel-2.4.9/linux/mm/filemap.c Mon Nov 5 22:20:00 2001 -+++ linux/mm/filemap.c Mon Nov 5 22:16:57 2001 -@@ -2672,7 +2672,7 @@ - * okir@monad.swb.de - */ - ssize_t --generic_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos) -+do_generic_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos, int (*actor)(char *, char *, size_t )) - { - struct inode *inode = file->f_dentry->d_inode; - struct address_space *mapping = inode->i_mapping; -@@ -2686,8 +2686,10 @@ - - cached_page = NULL; - -+#if 0 - if (!access_ok(VERIFY_READ, buf, count)) - return -EFAULT; -+#endif - - down(&inode->i_sem); - -@@ -2794,10 +2796,12 @@ - * same page as we're writing to, without it being marked - * up-to-date. - */ -+#if 0 - { volatile unsigned char dummy; - __get_user(dummy, buf); - __get_user(dummy, buf+bytes-1); - } -+#endif - - status = -ENOMEM; /* we'll assign it later anyway */ - page = __grab_cache_page(mapping, index, &cached_page); -@@ -2813,7 +2817,7 @@ - if (status) - goto sync_failure; - kaddr = page_address(page); -- page_fault = __copy_from_user(kaddr+offset, buf, bytes); -+ page_fault = actor(kaddr+offset, buf, bytes); - flush_dcache_page(page); - status = mapping->a_ops->commit_write(file, page, offset, offset+bytes); - if (page_fault) -@@ -2870,6 +2874,21 @@ - vmtruncate(inode, inode->i_size); - goto done; - } -+ -+static inline int actor_from_user(char *dst, char *src, size_t len) -+{ -+ if (!access_ok(VERIFY_READ, src, len)) -+ return -EFAULT; -+ -+ return __copy_from_user(dst, src, len); -+} -+ -+ssize_t -+generic_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos) -+{ -+ return do_generic_file_write(file, buf, count, ppos, &actor_from_user); -+} -+ - - void __init page_cache_init(unsigned long mempages) - { diff --git a/lustre/patches/ubd-io-fail-2.4.18 b/lustre/patches/ubd-io-fail-2.4.18 deleted file mode 100644 index 56c3742..0000000 --- a/lustre/patches/ubd-io-fail-2.4.18 +++ /dev/null @@ -1,34 +0,0 @@ ---- lum/arch/um/drivers/ubd.c.orig Wed Mar 13 14:04:59 2002 -+++ lum/arch/um/drivers/ubd.c Thu Mar 28 23:39:15 2002 -@@ -693,14 +697,23 @@ - spin_unlock(&io_request_lock); - return(1); - } -- if((req->cmd == WRITE) && -- ((dev->openflags & O_ACCMODE) == O_RDONLY)){ -- printk("Write attempted on readonly ubd device %d\n", -- minor(req->rq_dev)); -- spin_lock(&io_request_lock); -- end_request(0); -- spin_unlock(&io_request_lock); -- return(1); -+ if (req->cmd == WRITE) { -+#ifdef CONFIG_DEV_RDONLY -+ if (dev_check_rdonly(req->rq_dev)) { -+ spin_lock(&io_request_lock); -+ end_request(1); -+ spin_unlock(&io_request_lock); -+ return(0); -+ } -+#endif -+ if ((dev->openflags & O_ACCMODE) == O_RDONLY) { -+ printk("Write attempted on readonly ubd device %d\n", -+ minor(req->rq_dev)); -+ spin_lock(&io_request_lock); -+ end_request(0); -+ spin_unlock(&io_request_lock); -+ return(1); -+ } - } - - block = req->sector; diff --git a/lustre/ptlrpc/.cvsignore b/lustre/ptlrpc/.cvsignore deleted file mode 100644 index 067f05c..0000000 --- a/lustre/ptlrpc/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -tags -TAGS diff --git a/lustre/ptlrpc/Makefile.am b/lustre/ptlrpc/Makefile.am deleted file mode 100644 index e98189e..0000000 --- a/lustre/ptlrpc/Makefile.am +++ /dev/null @@ -1,14 +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 - -DEFS:= - -MODULE = ptlrpc -modulefs_DATA = ptlrpc.o -EXTRA_PROGRAMS = ptlrpc - -ptlrpc_SOURCES = connmgr.c recovd.c connection.c rpc.c events.c service.c client.c niobuf.c pack_generic.c - -include $(top_srcdir)/Rules diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c deleted file mode 100644 index 450ade1..0000000 --- a/lustre/ptlrpc/client.c +++ /dev/null @@ -1,576 +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 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_RPC - -#include - -void ptlrpc_init_client(struct recovd_obd *recovd, - int (*recover)(struct ptlrpc_client *recover), - int req_portal, - int rep_portal, struct ptlrpc_client *cl) -{ - memset(cl, 0, sizeof(*cl)); - cl->cli_recovd = recovd; - cl->cli_recover = recover; - if (recovd) - recovd_cli_manage(recovd, cl); - cl->cli_obd = NULL; - cl->cli_request_portal = req_portal; - cl->cli_reply_portal = rep_portal; - INIT_LIST_HEAD(&cl->cli_delayed_head); - INIT_LIST_HEAD(&cl->cli_sending_head); - INIT_LIST_HEAD(&cl->cli_dying_head); - spin_lock_init(&cl->cli_lock); - sema_init(&cl->cli_rpc_sem, 32); -} - -__u8 *ptlrpc_req_to_uuid(struct ptlrpc_request *req) -{ - return req->rq_connection->c_remote_uuid; -} - -struct ptlrpc_connection *ptlrpc_uuid_to_connection(char *uuid) -{ - struct ptlrpc_connection *c; - struct lustre_peer peer; - int err; - - err = kportal_uuid_to_peer(uuid, &peer); - if (err != 0) { - CERROR("cannot find peer %s!\n", uuid); - return NULL; - } - - c = ptlrpc_get_connection(&peer); - if (c) - c->c_epoch++; - - return c; -} - -void ptlrpc_readdress_connection(struct ptlrpc_connection *conn, char *uuid) -{ - struct lustre_peer peer; - int err; - - err = kportal_uuid_to_peer(uuid, &peer); - if (err != 0) { - CERROR("cannot find peer %s!\n", uuid); - return; - } - - memcpy(&conn->c_peer, &peer, sizeof(peer)); - return; -} - -struct ptlrpc_bulk_desc *ptlrpc_prep_bulk(struct ptlrpc_connection *conn) -{ - struct ptlrpc_bulk_desc *bulk; - - OBD_ALLOC(bulk, sizeof(*bulk)); - if (bulk != NULL) { - bulk->b_connection = ptlrpc_connection_addref(conn); - init_waitqueue_head(&bulk->b_waitq); - INIT_LIST_HEAD(&bulk->b_page_list); - } - - return bulk; -} - -struct ptlrpc_bulk_page *ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc) -{ - struct ptlrpc_bulk_page *bulk; - - OBD_ALLOC(bulk, sizeof(*bulk)); - if (bulk != NULL) { - bulk->b_desc = desc; - ptl_set_inv_handle(&bulk->b_md_h); - ptl_set_inv_handle(&bulk->b_me_h); - list_add_tail(&bulk->b_link, &desc->b_page_list); - desc->b_page_count++; - } - return bulk; -} - -void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc) -{ - struct list_head *tmp, *next; - ENTRY; - if (desc == NULL) { - EXIT; - return; - } - - list_for_each_safe(tmp, next, &desc->b_page_list) { - struct ptlrpc_bulk_page *bulk; - bulk = list_entry(tmp, struct ptlrpc_bulk_page, b_link); - ptlrpc_free_bulk_page(bulk); - } - - ptlrpc_put_connection(desc->b_connection); - - OBD_FREE(desc, sizeof(*desc)); - EXIT; -} - -void ptlrpc_free_bulk_page(struct ptlrpc_bulk_page *bulk) -{ - if (!bulk) { - EXIT; - return; - } - - list_del(&bulk->b_link); - bulk->b_desc->b_page_count--; - OBD_FREE(bulk, sizeof(*bulk)); -} - -struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, - struct ptlrpc_connection *conn, - int opcode, int count, int *lengths, - char **bufs) -{ - struct ptlrpc_request *request; - int rc; - ENTRY; - - OBD_ALLOC(request, sizeof(*request)); - if (!request) { - CERROR("request allocation out of memory\n"); - RETURN(NULL); - } - - rc = lustre_pack_msg(count, lengths, bufs, - &request->rq_reqlen, &request->rq_reqmsg); - if (rc) { - OBD_FREE(request, sizeof(*request)); - CERROR("cannot pack request %d\n", rc); - RETURN(NULL); - } - - request->rq_type = PTL_RPC_TYPE_REQUEST; - request->rq_connection = ptlrpc_connection_addref(conn); - - request->rq_reqmsg->conn = (__u64)(unsigned long)conn->c_remote_conn; - request->rq_reqmsg->token = conn->c_remote_token; - request->rq_reqmsg->opc = HTON__u32(opcode); - request->rq_reqmsg->type = HTON__u32(PTL_RPC_MSG_REQUEST); - INIT_LIST_HEAD(&request->rq_list); - - /* this will be dec()d once in req_finished, once in free_committed */ - atomic_set(&request->rq_refcount, 2); - - spin_lock(&conn->c_lock); - request->rq_reqmsg->xid = HTON__u32(++conn->c_xid_out); - request->rq_xid = conn->c_xid_out; - spin_unlock(&conn->c_lock); - - request->rq_client = cl; - - RETURN(request); -} - -void ptlrpc_req_finished(struct ptlrpc_request *request) -{ - if (request == NULL) - return; - - if (request->rq_repmsg != NULL) { - OBD_FREE(request->rq_repmsg, request->rq_replen); - request->rq_repmsg = NULL; - request->rq_reply_md.start = NULL; - } - - if (atomic_dec_and_test(&request->rq_refcount)) - ptlrpc_free_req(request); -} - -void ptlrpc_free_req(struct ptlrpc_request *request) -{ - if (request == NULL) - return; - - if (request->rq_repmsg != NULL) - OBD_FREE(request->rq_repmsg, request->rq_replen); - if (request->rq_reqmsg != NULL) - OBD_FREE(request->rq_reqmsg, request->rq_reqlen); - - if (request->rq_client) { - spin_lock(&request->rq_client->cli_lock); - list_del_init(&request->rq_list); - spin_unlock(&request->rq_client->cli_lock); - } - - ptlrpc_put_connection(request->rq_connection); - - OBD_FREE(request, sizeof(*request)); -} - -static int ptlrpc_check_reply(struct ptlrpc_request *req) -{ - int rc = 0; - - if (req->rq_repmsg != NULL) { - req->rq_transno = NTOH__u64(req->rq_repmsg->transno); - req->rq_flags |= PTL_RPC_FL_REPLIED; - GOTO(out, rc = 1); - } - - if (req->rq_flags & PTL_RPC_FL_RESEND) { - CERROR("-- RESEND --\n"); - GOTO(out, rc = 1); - } - - if (req->rq_flags & PTL_RPC_FL_RECOVERY) { - CERROR("-- RESTART --\n"); - GOTO(out, rc = 1); - } - - - if (CURRENT_TIME - req->rq_time >= req->rq_timeout) { - CERROR("-- REQ TIMEOUT ON CONNID %d XID %Ld --\n", - req->rq_connid, (unsigned long long)req->rq_xid); - /* clear the timeout */ - req->rq_timeout = 0; - req->rq_connection->c_level = LUSTRE_CONN_RECOVD; - req->rq_flags |= PTL_RPC_FL_TIMEOUT; - if (req->rq_client && req->rq_client->cli_recovd) - recovd_cli_fail(req->rq_client); - if (req->rq_level < LUSTRE_CONN_FULL) - rc = 1; - else - rc = 0; - GOTO(out, rc); - } - - if (req->rq_timeout) { - schedule_timeout(req->rq_timeout * HZ); - } - - if (sigismember(&(current->pending.signal), SIGKILL) || - sigismember(&(current->pending.signal), SIGTERM) || - sigismember(&(current->pending.signal), SIGINT)) { - req->rq_flags |= PTL_RPC_FL_INTR; - GOTO(out, rc = 1); - } - - out: - return rc; -} - -int ptlrpc_check_status(struct ptlrpc_request *req, int err) -{ - ENTRY; - - if (err != 0) { - CERROR("err is %d\n", err); - RETURN(err); - } - - if (req == NULL) { - CERROR("req == NULL\n"); - RETURN(-ENOMEM); - } - - if (req->rq_repmsg == NULL) { - CERROR("req->rq_repmsg == NULL\n"); - RETURN(-ENOMEM); - } - - if (req->rq_repmsg->type == NTOH__u32(PTL_RPC_MSG_ERR)) { - CERROR("req->rq_repmsg->type == PTL_RPC_MSG_ERR\n"); - RETURN(-EINVAL); - } - - if (req->rq_repmsg->status != 0) { - CERROR("req->rq_repmsg->status is %d\n", - req->rq_repmsg->status); - /* XXX: translate this error from net to host */ - RETURN(req->rq_repmsg->status); - } - - RETURN(0); -} - -static void ptlrpc_cleanup_request_buf(struct ptlrpc_request *request) -{ - OBD_FREE(request->rq_reqmsg, request->rq_reqlen); - request->rq_reqmsg = NULL; - request->rq_reqlen = 0; -} - -/* Abort this request and cleanup any resources associated with it. */ -static int ptlrpc_abort(struct ptlrpc_request *request) -{ - /* First remove the ME for the reply; in theory, this means - * that we can tear down the buffer safely. */ - PtlMEUnlink(request->rq_reply_me_h); - OBD_FREE(request->rq_reply_md.start, request->rq_replen); - request->rq_repmsg = NULL; - request->rq_replen = 0; - return 0; -} - -/* caller must lock cli */ -void ptlrpc_free_committed(struct ptlrpc_client *cli) -{ - struct list_head *tmp, *saved; - struct ptlrpc_request *req; - - list_for_each_safe(tmp, saved, &cli->cli_sending_head) { - req = list_entry(tmp, struct ptlrpc_request, rq_list); - - if ( (req->rq_flags & PTL_RPC_FL_REPLAY) ) { - CDEBUG(D_INFO, "Retaining request %Ld for replay\n", - req->rq_xid); - continue; - } - - /* not yet committed */ - if (req->rq_transno > cli->cli_last_committed) - break; - - CDEBUG(D_INFO, "Marking request %Ld as committed (" - "transno=%Lu, last_committed=%Lu\n", - req->rq_xid, req->rq_transno, - cli->cli_last_committed); - if (atomic_dec_and_test(&req->rq_refcount)) { - /* we do this to prevent free_req deadlock */ - list_del_init(&req->rq_list); - req->rq_client = NULL; - ptlrpc_free_req(req); - } else { - list_del_init(&req->rq_list); - list_add(&req->rq_list, &cli->cli_dying_head); - } - } - - EXIT; - return; -} - -void ptlrpc_cleanup_client(struct ptlrpc_client *cli) -{ - struct list_head *tmp, *saved; - struct ptlrpc_request *req; - ENTRY; - - spin_lock(&cli->cli_lock); - list_for_each_safe(tmp, saved, &cli->cli_sending_head) { - req = list_entry(tmp, struct ptlrpc_request, rq_list); - CDEBUG(D_INFO, "Cleaning req %p from sending list.\n", req); - list_del_init(&req->rq_list); - req->rq_client = NULL; - ptlrpc_free_req(req); - } - list_for_each_safe(tmp, saved, &cli->cli_dying_head) { - req = list_entry(tmp, struct ptlrpc_request, rq_list); - CERROR("Request %p is on the dying list at cleanup!\n", req); - list_del_init(&req->rq_list); - req->rq_client = NULL; - ptlrpc_free_req(req); - } - spin_unlock(&cli->cli_lock); - - EXIT; - return; -} - -void ptlrpc_continue_req(struct ptlrpc_request *req) -{ - ENTRY; - CDEBUG(D_INODE, "continue delayed request %Ld opc %d\n", - req->rq_xid, req->rq_reqmsg->opc); - wake_up_interruptible(&req->rq_wait_for_rep); - EXIT; -} - -void ptlrpc_resend_req(struct ptlrpc_request *req) -{ - ENTRY; - CDEBUG(D_INODE, "resend request %Ld, opc %d\n", - req->rq_xid, req->rq_reqmsg->opc); - req->rq_status = -EAGAIN; - req->rq_level = LUSTRE_CONN_RECOVD; - req->rq_flags |= PTL_RPC_FL_RESEND; - req->rq_flags &= ~PTL_RPC_FL_TIMEOUT; - wake_up_interruptible(&req->rq_wait_for_rep); - EXIT; -} - -void ptlrpc_restart_req(struct ptlrpc_request *req) -{ - ENTRY; - CDEBUG(D_INODE, "restart completed request %Ld, opc %d\n", - req->rq_xid, req->rq_reqmsg->opc); - req->rq_status = -ERESTARTSYS; - req->rq_flags |= PTL_RPC_FL_RECOVERY; - req->rq_flags &= ~PTL_RPC_FL_TIMEOUT; - wake_up_interruptible(&req->rq_wait_for_rep); - EXIT; -} - -int ptlrpc_queue_wait(struct ptlrpc_request *req) -{ - int rc = 0; - struct ptlrpc_client *cli = req->rq_client; - ENTRY; - - init_waitqueue_head(&req->rq_wait_for_rep); - CDEBUG(D_NET, "subsys: %s req %Ld opc %d level %d, conn level %d\n", - cli->cli_name, req->rq_xid, req->rq_reqmsg->opc, req->rq_level, - req->rq_connection->c_level); - - /* XXX probably both an import and connection level are needed */ - if (req->rq_level > req->rq_connection->c_level) { - CERROR("process %d waiting for recovery\n", current->pid); - spin_lock(&cli->cli_lock); - list_del_init(&req->rq_list); - list_add(&req->rq_list, cli->cli_delayed_head.prev); - spin_unlock(&cli->cli_lock); - wait_event_interruptible - (req->rq_wait_for_rep, - req->rq_level <= req->rq_connection->c_level); - spin_lock(&cli->cli_lock); - list_del_init(&req->rq_list); - spin_unlock(&cli->cli_lock); - CERROR("process %d resumed\n", current->pid); - } - resend: - req->rq_time = CURRENT_TIME; - req->rq_timeout = 30; - rc = ptl_send_rpc(req); - if (rc) { - CERROR("error %d, opcode %d\n", rc, req->rq_reqmsg->opc); - if ( rc > 0 ) - rc = -rc; - ptlrpc_cleanup_request_buf(req); - up(&cli->cli_rpc_sem); - RETURN(-rc); - } - - spin_lock(&cli->cli_lock); - list_del_init(&req->rq_list); - list_add_tail(&req->rq_list, &cli->cli_sending_head); - spin_unlock(&cli->cli_lock); - - CDEBUG(D_OTHER, "-- sleeping\n"); - wait_event_interruptible(req->rq_wait_for_rep, - ptlrpc_check_reply(req)); - CDEBUG(D_OTHER, "-- done\n"); - - if (req->rq_flags & PTL_RPC_FL_RESEND) { - req->rq_flags &= ~PTL_RPC_FL_RESEND; - goto resend; - } - - up(&cli->cli_rpc_sem); - if (req->rq_flags & PTL_RPC_FL_TIMEOUT) - GOTO(out, rc = -ETIMEDOUT); - - if (req->rq_flags & PTL_RPC_FL_INTR) { - /* Clean up the dangling reply buffers */ - ptlrpc_abort(req); - GOTO(out, rc = -EINTR); - } - - if (!(req->rq_flags & PTL_RPC_FL_REPLIED)) - GOTO(out, rc = req->rq_status); - - rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen); - if (rc) { - CERROR("unpack_rep failed: %d\n", rc); - GOTO(out, rc); - } - CDEBUG(D_NET, "got rep %d\n", req->rq_repmsg->xid); - if (req->rq_repmsg->status == 0) - CDEBUG(D_NET, "--> buf %p len %d status %d\n", req->rq_repmsg, - req->rq_replen, req->rq_repmsg->status); - - spin_lock(&cli->cli_lock); - cli->cli_last_rcvd = req->rq_repmsg->last_rcvd; - cli->cli_last_committed = req->rq_repmsg->last_committed; - ptlrpc_free_committed(cli); - spin_unlock(&cli->cli_lock); - - EXIT; - out: - return rc; -} - -int ptlrpc_replay_req(struct ptlrpc_request *req) -{ - int rc = 0; - struct ptlrpc_client *cli = req->rq_client; - ENTRY; - - init_waitqueue_head(&req->rq_wait_for_rep); - CDEBUG(D_NET, "req %Ld opc %d level %d, conn level %d\n", - req->rq_xid, req->rq_reqmsg->opc, req->rq_level, - req->rq_connection->c_level); - - req->rq_time = CURRENT_TIME; - req->rq_timeout = 3; - rc = ptl_send_rpc(req); - if (rc) { - CERROR("error %d, opcode %d\n", rc, req->rq_reqmsg->opc); - ptlrpc_cleanup_request_buf(req); - up(&cli->cli_rpc_sem); - RETURN(-rc); - } - - CDEBUG(D_OTHER, "-- sleeping\n"); - wait_event_interruptible(req->rq_wait_for_rep, - ptlrpc_check_reply(req)); - CDEBUG(D_OTHER, "-- done\n"); - - up(&cli->cli_rpc_sem); - - if (!(req->rq_flags & PTL_RPC_FL_REPLIED)) { - CERROR("Unknown reason for wakeup\n"); - /* XXX Phil - I end up here when I kill obdctl */ - ptlrpc_abort(req); - GOTO(out, rc = -EINTR); - } - - rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen); - if (rc) { - CERROR("unpack_rep failed: %d\n", rc); - GOTO(out, rc); - } - - CDEBUG(D_NET, "got rep %d\n", req->rq_repmsg->xid); - if (req->rq_repmsg->status == 0) - CDEBUG(D_NET, "--> buf %p len %d status %d\n", req->rq_repmsg, - req->rq_replen, req->rq_repmsg->status); - else { - CERROR("recovery failed: "); - CERROR("req %Ld opc %d level %d, conn level %d\n", - req->rq_xid, req->rq_reqmsg->opc, req->rq_level, - req->rq_connection->c_level); - LBUG(); - } - - out: - RETURN(rc); -} diff --git a/lustre/ptlrpc/connection.c b/lustre/ptlrpc/connection.c deleted file mode 100644 index 2723c15..0000000 --- a/lustre/ptlrpc/connection.c +++ /dev/null @@ -1,130 +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 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_RPC - -#include - -static spinlock_t conn_lock; -static struct list_head conn_list; -static struct list_head conn_unused_list; - -struct ptlrpc_connection *ptlrpc_get_connection(struct lustre_peer *peer) -{ - struct list_head *tmp, *pos; - struct ptlrpc_connection *c; - ENTRY; - - spin_lock(&conn_lock); - list_for_each(tmp, &conn_list) { - c = list_entry(tmp, struct ptlrpc_connection, c_link); - if (memcmp(peer, &c->c_peer, sizeof(*peer)) == 0) { - atomic_inc(&c->c_refcount); - GOTO(out, c); - } - } - - list_for_each_safe(tmp, pos, &conn_unused_list) { - c = list_entry(tmp, struct ptlrpc_connection, c_link); - if (memcmp(peer, &c->c_peer, sizeof(*peer)) == 0) { - atomic_inc(&c->c_refcount); - list_del(&c->c_link); - list_add(&c->c_link, &conn_list); - GOTO(out, c); - } - } - - /* FIXME: this should be a slab once we can validate slab addresses - * without OOPSing */ - OBD_ALLOC(c, sizeof(*c)); - if (c == NULL) - GOTO(out, c); - - c->c_level = LUSTRE_CONN_NEW; - c->c_xid_in = 1; - c->c_xid_out = 1; - c->c_generation = 1; - c->c_epoch = 1; - c->c_bootcount = 0; - atomic_set(&c->c_refcount, 1); - spin_lock_init(&c->c_lock); - - memcpy(&c->c_peer, peer, sizeof(c->c_peer)); - list_add(&c->c_link, &conn_list); - - EXIT; - out: - spin_unlock(&conn_lock); - return c; -} - -int ptlrpc_put_connection(struct ptlrpc_connection *c) -{ - int rc = 0; - ENTRY; - - if (atomic_dec_and_test(&c->c_refcount)) { - spin_lock(&conn_lock); - list_del(&c->c_link); - list_add(&c->c_link, &conn_unused_list); - spin_unlock(&conn_lock); - rc = 1; - } - - RETURN(rc); -} - -struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *c) -{ - ENTRY; - atomic_inc(&c->c_refcount); - RETURN(c); -} - -void ptlrpc_init_connection(void) -{ - INIT_LIST_HEAD(&conn_list); - INIT_LIST_HEAD(&conn_unused_list); - conn_lock = SPIN_LOCK_UNLOCKED; -} - -void ptlrpc_cleanup_connection(void) -{ - struct list_head *tmp, *pos; - struct ptlrpc_connection *c; - - spin_lock(&conn_lock); - list_for_each_safe(tmp, pos, &conn_unused_list) { - c = list_entry(tmp, struct ptlrpc_connection, c_link); - list_del(&c->c_link); - OBD_FREE(c, sizeof(*c)); - } - list_for_each_safe(tmp, pos, &conn_list) { - c = list_entry(tmp, struct ptlrpc_connection, c_link); - CERROR("Connection %p has refcount %d at cleanup (nid=%lu)!\n", - c, atomic_read(&c->c_refcount), - (unsigned long)c->c_peer.peer_nid); - list_del(&c->c_link); - OBD_FREE(c, sizeof(*c)); - } - spin_unlock(&conn_lock); -} diff --git a/lustre/ptlrpc/connmgr.c b/lustre/ptlrpc/connmgr.c deleted file mode 100644 index f5941fd..0000000 --- a/lustre/ptlrpc/connmgr.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * obd/rpc/recovd.c - * - * Lustre High Availability Daemon - * - * 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 - * - * by Peter Braam - * - */ - -#define DEBUG_SUBSYSTEM S_RPC - -#include -#include -#include - -static int connmgr_unpack_body(struct ptlrpc_request *req) -{ - struct connmgr_body *b = lustre_msg_buf(req->rq_repmsg, 0); - if (b == NULL) { - LBUG(); - RETURN(-EINVAL); - } - - b->generation = NTOH__u32(b->generation); - - return 0; -} - -int connmgr_connect(struct recovd_obd *recovd, struct ptlrpc_connection *conn) -{ - struct ptlrpc_request *req; - struct ptlrpc_client *cl; - struct connmgr_body *body; - int rc, size = sizeof(*body); - ENTRY; - - if (!recovd) { - CERROR("no manager\n"); - LBUG(); - } - cl = recovd->recovd_client; - - req = ptlrpc_prep_req(cl, conn, CONNMGR_CONNECT, 1, &size, NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0); - body->generation = HTON__u32(conn->c_generation); - body->conn = (__u64)(unsigned long)conn; - body->conn_token = conn->c_token; - strncpy(body->conn_uuid, conn->c_local_uuid, sizeof(body->conn_uuid)); - - req->rq_replen = lustre_msg_size(1, &size); - req->rq_level = LUSTRE_CONN_NEW; - - rc = ptlrpc_queue_wait(req); - rc = ptlrpc_check_status(req, rc); - if (!rc) { - rc = connmgr_unpack_body(req); - if (rc) - GOTO(out_free, rc); - body = lustre_msg_buf(req->rq_repmsg, 0); - CDEBUG(D_NET, "remote generation: %o\n", body->generation); - conn->c_level = LUSTRE_CONN_CON; - conn->c_remote_conn = body->conn; - conn->c_remote_token = body->conn_token; - strncpy(conn->c_remote_uuid, body->conn_uuid, - sizeof(conn->c_remote_uuid)); - } - - EXIT; - out_free: - ptlrpc_free_req(req); - out: - return rc; -} - -static int connmgr_handle_connect(struct ptlrpc_request *req) -{ - struct connmgr_body *body; - int rc, size = sizeof(*body); - ENTRY; - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) { - CERROR("connmgr: out of memory\n"); - req->rq_status = -ENOMEM; - RETURN(0); - } - - body = lustre_msg_buf(req->rq_reqmsg, 0); - connmgr_unpack_body(req); - - req->rq_connection->c_remote_conn = body->conn; - req->rq_connection->c_remote_token = body->conn_token; - strncpy(req->rq_connection->c_remote_uuid, body->conn_uuid, - sizeof(req->rq_connection->c_remote_uuid)); - - CERROR("incoming generation %d\n", body->generation); - body = lustre_msg_buf(req->rq_repmsg, 0); - body->generation = 4711; - body->conn = (__u64)(unsigned long)req->rq_connection; - body->conn_token = req->rq_connection->c_token; - - req->rq_connection->c_level = LUSTRE_CONN_CON; - RETURN(0); -} - -int connmgr_handle(struct obd_device *dev, struct ptlrpc_service *svc, - struct ptlrpc_request *req) -{ - int rc; - ENTRY; - - rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen); - if (rc) { - CERROR("Invalid request\n"); - GOTO(out, rc); - } - - if (req->rq_reqmsg->type != NTOH__u32(PTL_RPC_MSG_REQUEST)) { - CERROR("wrong packet type sent %d\n", - req->rq_reqmsg->type); - GOTO(out, rc = -EINVAL); - } - - switch (req->rq_reqmsg->opc) { - case CONNMGR_CONNECT: - CDEBUG(D_INODE, "connmgr connect\n"); - rc = connmgr_handle_connect(req); - break; - - default: - rc = ptlrpc_error(svc, req); - RETURN(rc); - } - - EXIT; -out: - if (rc) { - ptlrpc_error(svc, req); - } else { - CDEBUG(D_NET, "sending reply\n"); - ptlrpc_reply(svc, req); - } - - return 0; -} diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c deleted file mode 100644 index 19ea660..0000000 --- a/lustre/ptlrpc/events.c +++ /dev/null @@ -1,232 +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 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_RPC - -#include -#include - -ptl_handle_eq_t request_out_eq, reply_in_eq, reply_out_eq, bulk_source_eq, - bulk_sink_eq; -static const ptl_handle_ni_t *socknal_nip = NULL, *qswnal_nip = NULL; - -/* - * Free the packet when it has gone out - */ -static int request_out_callback(ptl_event_t *ev, void *data) -{ - ENTRY; - - if (ev->type != PTL_EVENT_SENT) { - // XXX make sure we understand all events, including ACK's - CERROR("Unknown event %d\n", ev->type); - LBUG(); - } - - RETURN(1); -} - - -/* - * Free the packet when it has gone out - */ -static int reply_out_callback(ptl_event_t *ev, void *data) -{ - ENTRY; - - if (ev->type == PTL_EVENT_SENT) { - OBD_FREE(ev->mem_desc.start, ev->mem_desc.length); - } else { - // XXX make sure we understand all events, including ACK's - CERROR("Unknown event %d\n", ev->type); - LBUG(); - } - - RETURN(1); -} - -/* - * Wake up the thread waiting for the reply once it comes in. - */ -static int reply_in_callback(ptl_event_t *ev, void *data) -{ - struct ptlrpc_request *rpc = ev->mem_desc.user_ptr; - ENTRY; - - if (ev->type == PTL_EVENT_PUT) { - rpc->rq_repmsg = ev->mem_desc.start + ev->offset; - barrier(); - wake_up_interruptible(&rpc->rq_wait_for_rep); - } else { - // XXX make sure we understand all events, including ACK's - CERROR("Unknown event %d\n", ev->type); - LBUG(); - } - - RETURN(1); -} - -int request_in_callback(ptl_event_t *ev, void *data) -{ - struct ptlrpc_service *service = data; - int index; - - if (ev->rlength != ev->mlength) - CERROR("Warning: Possibly truncated rpc (%d/%d)\n", - ev->mlength, ev->rlength); - - spin_lock(&service->srv_lock); - for (index = 0; index < service->srv_ring_length; index++) - if ( service->srv_buf[index] == ev->mem_desc.start) - break; - - if (index == service->srv_ring_length) - LBUG(); - - service->srv_ref_count[index]++; - - if (ptl_is_valid_handle(&ev->unlinked_me)) { - int idx; - - for (idx = 0; idx < service->srv_ring_length; idx++) - if (service->srv_me_h[idx].handle_idx == - ev->unlinked_me.handle_idx) - break; - if (idx == service->srv_ring_length) - LBUG(); - - CDEBUG(D_NET, "unlinked %d\n", idx); - ptl_set_inv_handle(&(service->srv_me_h[idx])); - - if (service->srv_ref_count[idx] == 0) - ptlrpc_link_svc_me(service, idx); - } - - spin_unlock(&service->srv_lock); - if (ev->type == PTL_EVENT_PUT) - wake_up(&service->srv_waitq); - else - CERROR("Unexpected event type: %d\n", ev->type); - - return 0; -} - -static int bulk_source_callback(ptl_event_t *ev, void *data) -{ - struct ptlrpc_bulk_page *bulk = ev->mem_desc.user_ptr; - struct ptlrpc_bulk_desc *desc = bulk->b_desc; - ENTRY; - - if (ev->type == PTL_EVENT_SENT) { - CDEBUG(D_NET, "got SENT event\n"); - } else if (ev->type == PTL_EVENT_ACK) { - CDEBUG(D_NET, "got ACK event\n"); - desc->b_flags |= PTL_BULK_FL_SENT; - wake_up_interruptible(&desc->b_waitq); - } else { - CERROR("Unexpected event type!\n"); - LBUG(); - } - - RETURN(1); -} - -static int bulk_sink_callback(ptl_event_t *ev, void *data) -{ - struct ptlrpc_bulk_page *bulk = ev->mem_desc.user_ptr; - struct ptlrpc_bulk_desc *desc = bulk->b_desc; - ENTRY; - - if (ev->type == PTL_EVENT_PUT) { - if (bulk->b_buf != ev->mem_desc.start + ev->offset) - CERROR("bulkbuf != mem_desc -- why?\n"); - desc->b_finished_count++; - if (bulk->b_cb != NULL) - bulk->b_cb(bulk); - if (desc->b_finished_count == desc->b_page_count) { - desc->b_flags |= PTL_BULK_FL_RCVD; - wake_up_interruptible(&desc->b_waitq); - if (desc->b_cb != NULL) - desc->b_cb(desc); - } - } else { - CERROR("Unexpected event type!\n"); - LBUG(); - } - - RETURN(1); -} - -int ptlrpc_init_portals(void) -{ - int rc; - ptl_handle_ni_t ni; - - socknal_nip = inter_module_get_request("ksocknal_ni", "ksocknal"); - qswnal_nip = inter_module_get_request("kqswnal_ni", "kqswnal"); - if (socknal_nip == NULL && qswnal_nip == NULL) { - CERROR("get_ni failed: is a NAL module loaded?\n"); - return -EIO; - } - - /* Use the qswnal if it's there */ - if (qswnal_nip != NULL) - ni = *qswnal_nip; - else - ni = *socknal_nip; - - rc = PtlEQAlloc(ni, 128, request_out_callback, NULL, &request_out_eq); - if (rc != PTL_OK) - CERROR("PtlEQAlloc failed: %d\n", rc); - - rc = PtlEQAlloc(ni, 128, reply_out_callback, NULL, &reply_out_eq); - if (rc != PTL_OK) - CERROR("PtlEQAlloc failed: %d\n", rc); - - rc = PtlEQAlloc(ni, 128, reply_in_callback, NULL, &reply_in_eq); - if (rc != PTL_OK) - CERROR("PtlEQAlloc failed: %d\n", rc); - - rc = PtlEQAlloc(ni, 128, bulk_source_callback, NULL, &bulk_source_eq); - if (rc != PTL_OK) - CERROR("PtlEQAlloc failed: %d\n", rc); - - rc = PtlEQAlloc(ni, 128, bulk_sink_callback, NULL, &bulk_sink_eq); - if (rc != PTL_OK) - CERROR("PtlEQAlloc failed: %d\n", rc); - - return rc; -} - -void ptlrpc_exit_portals(void) -{ - PtlEQFree(request_out_eq); - PtlEQFree(reply_out_eq); - PtlEQFree(reply_in_eq); - PtlEQFree(bulk_source_eq); - PtlEQFree(bulk_sink_eq); - - if (qswnal_nip != NULL) - inter_module_put("kqswnal_ni"); - if (socknal_nip != NULL) - inter_module_put("ksocknal_ni"); -} diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c deleted file mode 100644 index 584cbf9..0000000 --- a/lustre/ptlrpc/niobuf.c +++ /dev/null @@ -1,400 +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 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_RPC - -#include - -extern ptl_handle_eq_t request_out_eq, reply_in_eq, reply_out_eq, - bulk_source_eq, bulk_sink_eq; -static ptl_process_id_t local_id = {PTL_ID_ANY, PTL_ID_ANY}; - -static int ptlrpc_check_bulk_sent(struct ptlrpc_bulk_desc *bulk) -{ - ENTRY; - - if (bulk->b_flags & PTL_BULK_FL_SENT) - RETURN(1); - - if (sigismember(&(current->pending.signal), SIGKILL) || - sigismember(&(current->pending.signal), SIGINT)) { - bulk->b_flags |= PTL_RPC_FL_INTR; - RETURN(1); - } - - CDEBUG(D_NET, "no event yet\n"); - RETURN(0); -} - -static int ptl_send_buf(struct ptlrpc_request *request, - struct ptlrpc_connection *conn, int portal) -{ - int rc; - ptl_process_id_t remote_id; - ptl_handle_md_t md_h; - ptl_ack_req_t ack; - - request->rq_req_md.user_ptr = request; - - switch (request->rq_type) { - case PTL_RPC_TYPE_REQUEST: - request->rq_req_md.start = request->rq_reqmsg; - request->rq_req_md.length = request->rq_reqlen; - request->rq_req_md.eventq = request_out_eq; - request->rq_req_md.threshold = 1; - ack = PTL_NOACK_REQ; - break; - case PTL_RPC_TYPE_REPLY: - request->rq_req_md.start = request->rq_repmsg; - request->rq_req_md.length = request->rq_replen; - request->rq_req_md.eventq = reply_out_eq; - request->rq_req_md.threshold = 1; - ack = PTL_NOACK_REQ; - break; - default: - LBUG(); - return -1; /* notreached */ - } - request->rq_req_md.options = PTL_MD_OP_PUT; - request->rq_req_md.user_ptr = request; - - rc = PtlMDBind(conn->c_peer.peer_ni, request->rq_req_md, &md_h); - //CERROR("MDBind (outgoing req/rep/bulk): %Lu\n", (__u64)md_h); - if (rc != 0) { - CERROR("PtlMDBind failed: %d\n", rc); - LBUG(); - return rc; - } - - remote_id.nid = conn->c_peer.peer_nid; - remote_id.pid = 0; - - CDEBUG(D_NET, "Sending %d bytes to portal %d, xid %Ld\n", - request->rq_req_md.length, portal, request->rq_xid); - - rc = PtlPut(md_h, ack, remote_id, portal, 0, request->rq_reqmsg->xid, - 0, 0); - if (rc != PTL_OK) { - CERROR("PtlPut(%Lu, %d, %Ld) failed: %d\n", remote_id.nid, - portal, request->rq_xid, rc); - PtlMDUnlink(md_h); - } - - return rc; -} - -int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *desc) -{ - int rc; - struct list_head *tmp, *next; - ptl_process_id_t remote_id; - ENTRY; - - list_for_each_safe(tmp, next, &desc->b_page_list) { - /* only request an ACK for the last page */ - int ack = (next == &desc->b_page_list); - struct ptlrpc_bulk_page *bulk; - bulk = list_entry(tmp, struct ptlrpc_bulk_page, b_link); - - bulk->b_md.start = bulk->b_buf; - bulk->b_md.length = bulk->b_buflen; - bulk->b_md.eventq = bulk_source_eq; - bulk->b_md.threshold = 1 + ack; /* SENT and (if last) ACK */ - bulk->b_md.options = PTL_MD_OP_PUT; - bulk->b_md.user_ptr = bulk; - - rc = PtlMDBind(desc->b_connection->c_peer.peer_ni, bulk->b_md, - &bulk->b_md_h); - if (rc != 0) { - CERROR("PtlMDBind failed: %d\n", rc); - LBUG(); - RETURN(rc); - } - - remote_id.nid = desc->b_connection->c_peer.peer_nid; - remote_id.pid = 0; - - CDEBUG(D_NET, "Sending %d bytes to portal %d, xid %d\n", - bulk->b_md.length, desc->b_portal, bulk->b_xid); - - rc = PtlPut(bulk->b_md_h, (ack ? PTL_ACK_REQ : PTL_NOACK_REQ), - remote_id, desc->b_portal, 0, bulk->b_xid, 0, 0); - if (rc != PTL_OK) { - CERROR("PtlPut(%Lu, %d, %d) failed: %d\n", remote_id.nid, - desc->b_portal, bulk->b_xid, rc); - PtlMDUnlink(bulk->b_md_h); - LBUG(); - RETURN(rc); - } - } - - wait_event_interruptible(desc->b_waitq, ptlrpc_check_bulk_sent(desc)); - - if (desc->b_flags & PTL_RPC_FL_INTR) - RETURN(-EINTR); - - RETURN(0); -} - -int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *desc) -{ - struct list_head *tmp, *next; - int rc; - ENTRY; - - list_for_each_safe(tmp, next, &desc->b_page_list) { - struct ptlrpc_bulk_page *bulk; - bulk = list_entry(tmp, struct ptlrpc_bulk_page, b_link); - - rc = PtlMEAttach(desc->b_connection->c_peer.peer_ni, - desc->b_portal, local_id, bulk->b_xid, 0, - PTL_UNLINK, PTL_INS_AFTER, &bulk->b_me_h); - if (rc != PTL_OK) { - CERROR("PtlMEAttach failed: %d\n", rc); - LBUG(); - GOTO(cleanup, rc); - } - - bulk->b_md.start = bulk->b_buf; - bulk->b_md.length = bulk->b_buflen; - bulk->b_md.threshold = 1; - bulk->b_md.options = PTL_MD_OP_PUT; - bulk->b_md.user_ptr = bulk; - bulk->b_md.eventq = bulk_sink_eq; - - rc = PtlMDAttach(bulk->b_me_h, bulk->b_md, PTL_UNLINK, - &bulk->b_md_h); - if (rc != PTL_OK) { - CERROR("PtlMDAttach failed: %d\n", rc); - LBUG(); - GOTO(cleanup, rc); - } - - CDEBUG(D_NET, "Setup bulk sink buffer: %u bytes, xid %u, " - "portal %u\n", bulk->b_buflen, bulk->b_xid, - desc->b_portal); - } - - RETURN(0); - - cleanup: - ptlrpc_abort_bulk(desc); - - return rc; -} - -int ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc) -{ - struct list_head *tmp, *next; - - list_for_each_safe(tmp, next, &desc->b_page_list) { - struct ptlrpc_bulk_page *bulk; - bulk = list_entry(tmp, struct ptlrpc_bulk_page, b_link); - - /* This should be safe: these handles are initialized to be - * invalid in ptlrpc_prep_bulk_page() */ - PtlMDUnlink(bulk->b_md_h); - PtlMEUnlink(bulk->b_me_h); - } - - return 0; -} - -int ptlrpc_reply(struct ptlrpc_service *svc, struct ptlrpc_request *req) -{ - /* FIXME: we need to increment the count of handled events */ - req->rq_type = PTL_RPC_TYPE_REPLY; - req->rq_repmsg->conn = req->rq_connection->c_remote_conn; - req->rq_repmsg->token = req->rq_connection->c_remote_token; - req->rq_repmsg->xid = HTON__u32(req->rq_reqmsg->xid); - req->rq_repmsg->status = HTON__u32(req->rq_status); - req->rq_reqmsg->type = HTON__u32(req->rq_type); - return ptl_send_buf(req, req->rq_connection, svc->srv_rep_portal); -} - -int ptlrpc_error(struct ptlrpc_service *svc, struct ptlrpc_request *req) -{ - int rc; - ENTRY; - - if (req->rq_repmsg) { - CERROR("req already has repmsg\n"); - LBUG(); - } - - rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - RETURN(rc); - - req->rq_repmsg->type = HTON__u32(PTL_RPC_MSG_ERR); - - rc = ptlrpc_reply(svc, req); - RETURN(rc); -} - - -int ptl_send_rpc(struct ptlrpc_request *request) -{ - ptl_process_id_t local_id; - int rc; - char *repbuf; - - ENTRY; - - if (NTOH__u32(request->rq_reqmsg->type) != PTL_RPC_MSG_REQUEST) { - CERROR("wrong packet type sent %d\n", - NTOH__u32(request->rq_reqmsg->type)); - LBUG(); - RETURN(EINVAL); - } - if (request->rq_replen == 0) { - CERROR("request->rq_replen is 0!\n"); - RETURN(EINVAL); - } - - /* request->rq_repmsg is set only when the reply comes in, in - * client_packet_callback() */ - if (request->rq_reply_md.start) - OBD_FREE(request->rq_reply_md.start, request->rq_replen); - - OBD_ALLOC(repbuf, request->rq_replen); - if (!repbuf) { - LBUG(); - RETURN(ENOMEM); - } - - local_id.nid = PTL_ID_ANY; - local_id.pid = PTL_ID_ANY; - - down(&request->rq_client->cli_rpc_sem); - - rc = PtlMEAttach(request->rq_connection->c_peer.peer_ni, - request->rq_client->cli_reply_portal, - local_id, request->rq_reqmsg->xid, 0, PTL_UNLINK, - PTL_INS_AFTER, &request->rq_reply_me_h); - if (rc != PTL_OK) { - CERROR("PtlMEAttach failed: %d\n", rc); - LBUG(); - GOTO(cleanup, rc); - } - - request->rq_type = PTL_RPC_TYPE_REQUEST; - request->rq_reply_md.start = repbuf; - request->rq_reply_md.length = request->rq_replen; - request->rq_reply_md.threshold = 1; - request->rq_reply_md.options = PTL_MD_OP_PUT; - request->rq_reply_md.user_ptr = request; - request->rq_reply_md.eventq = reply_in_eq; - - rc = PtlMDAttach(request->rq_reply_me_h, request->rq_reply_md, - PTL_UNLINK, &request->rq_reply_md_h); - if (rc != PTL_OK) { - CERROR("PtlMDAttach failed: %d\n", rc); - LBUG(); - GOTO(cleanup2, rc); - } - - CDEBUG(D_NET, "Setup reply buffer: %u bytes, xid %Lu, portal %u\n", - request->rq_replen, request->rq_xid, - request->rq_client->cli_reply_portal); - - rc = ptl_send_buf(request, request->rq_connection, - request->rq_client->cli_request_portal); - RETURN(rc); - - cleanup2: - PtlMEUnlink(request->rq_reply_me_h); - cleanup: - OBD_FREE(repbuf, request->rq_replen); - up(&request->rq_client->cli_rpc_sem); - - return rc; -} - -void ptlrpc_link_svc_me(struct ptlrpc_service *service, int i) -{ - int rc; - ptl_md_t dummy; - ptl_handle_md_t md_h; - - /* Attach the leading ME on which we build the ring */ - rc = PtlMEAttach(service->srv_self.peer_ni, service->srv_req_portal, - local_id, 0, ~0, PTL_RETAIN, PTL_INS_BEFORE, - &(service->srv_me_h[i])); - if (rc != PTL_OK) { - CERROR("PtlMEAttach failed: %d\n", rc); - LBUG(); - } - - if (service->srv_ref_count[i]) - LBUG(); - - dummy.start = service->srv_buf[i]; - dummy.length = service->srv_buf_size; - dummy.max_offset = service->srv_buf_size; - dummy.threshold = PTL_MD_THRESH_INF; - dummy.options = PTL_MD_OP_PUT | PTL_MD_AUTO_UNLINK; - dummy.user_ptr = service; - dummy.eventq = service->srv_eq_h; - dummy.max_offset = service->srv_buf_size; - - rc = PtlMDAttach(service->srv_me_h[i], dummy, PTL_UNLINK, &md_h); - if (rc != PTL_OK) { - /* cleanup */ - CERROR("PtlMDAttach failed: %d\n", rc); - LBUG(); - } -} - -/* ptl_handled_rpc() should be called by the sleeping process once - * it finishes processing an event. This ensures the ref count is - * decremented and that the rpc ring buffer cycles properly. - */ -int ptl_handled_rpc(struct ptlrpc_service *service, void *start) -{ - int index; - - spin_lock(&service->srv_lock); - - for (index = 0; index < service->srv_ring_length; index++) - if (service->srv_buf[index] == start) - break; - - if (index == service->srv_ring_length) - LBUG(); - - CDEBUG(D_INFO, "MD index=%d Ref Count=%d\n", index, - service->srv_ref_count[index]); - service->srv_ref_count[index]--; - - if (service->srv_ref_count[index] < 0) - LBUG(); - - if (service->srv_ref_count[index] == 0 && - !ptl_is_valid_handle(&(service->srv_me_h[index]))) { - CDEBUG(D_NET, "relinking %d\n", index); - ptlrpc_link_svc_me(service, index); - } - - spin_unlock(&service->srv_lock); - return 0; -} diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c deleted file mode 100644 index e932433..0000000 --- a/lustre/ptlrpc/pack_generic.c +++ /dev/null @@ -1,128 +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. - * - * (Un)packing of OST requests - * - */ - -#define DEBUG_SUBSYSTEM S_CLASS - -#include - -int lustre_pack_msg(int count, int *lens, char **bufs, int *len, - struct lustre_msg **msg) -{ - char *ptr; - struct lustre_msg *m; - int size = 0, i; - - for (i = 0; i < count; i++) - size += size_round(lens[i]); - - *len = size_round(sizeof(*m) + count * sizeof(__u32)) + size; - - OBD_ALLOC(*msg, *len); - if (!*msg) - RETURN(-ENOMEM); - - m = *msg; - m->bufcount = HTON__u32(count); - for (i = 0; i < count; i++) - m->buflens[i] = HTON__u32(lens[i]); - - ptr = (char *)m + size_round(sizeof(*m) + count * sizeof(__u32)); - for (i = 0; i < count; i++) { - char *tmp = NULL; - if (bufs) - tmp = bufs[i]; - LOGL(tmp, lens[i], ptr); - } - - return 0; -} - -/* This returns the size of the buffer that is required to hold a lustre_msg - * with the given sub-buffer lengths. */ -int lustre_msg_size(int count, int *lengths) -{ - int size = 0, i; - - for (i = 0; i < count; i++) - size += size_round(lengths[i]); - - size += size_round(sizeof(struct lustre_msg) + count * sizeof(__u32)); - - return size; -} - -int lustre_unpack_msg(struct lustre_msg *m, int len) -{ - int required_len, i; - - required_len = size_round(sizeof(*m)); - if (len < required_len) - RETURN(-EINVAL); - - m->opc = NTOH__u32(m->opc); - m->xid = NTOH__u32(m->xid); - m->status = NTOH__u32(m->status); - m->type = NTOH__u32(m->type); - m->connid = NTOH__u32(m->connid); - m->bufcount = NTOH__u32(m->bufcount); - m->last_rcvd = NTOH__u64(m->last_rcvd); - m->last_committed = NTOH__u64(m->last_committed); - - required_len = size_round(sizeof(*m) + m->bufcount * sizeof(__u32)); - if (len < required_len) - RETURN(-EINVAL); - - for (i = 0; i < m->bufcount; i++) { - m->buflens[i] = NTOH__u32(m->buflens[i]); - required_len += size_round(m->buflens[i]); - } - - if (len < required_len) { - CERROR("len: %d, required_len %d\n", len, required_len); - RETURN(-EINVAL); - } - - RETURN(0); -} - -void *lustre_msg_buf(struct lustre_msg *m, int n) -{ - int i, offset; - - if (n < 0 || n >= m->bufcount) { - CERROR("referencing bad sub buffer!\n"); - LBUG(); - return NULL; - } - - if (m->buflens[n] == 0) - return NULL; - - offset = size_round(sizeof(*m) + m->bufcount * sizeof(__u32)); - - for (i = 0; i < n; i++) - offset += size_round(m->buflens[i]); - - return (char *)m + offset; -} diff --git a/lustre/ptlrpc/recovd.c b/lustre/ptlrpc/recovd.c deleted file mode 100644 index ad1c96c..0000000 --- a/lustre/ptlrpc/recovd.c +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * obd/rpc/recovd.c - * - * Lustre High Availability Daemon - * - * 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 - * - * by Peter Braam - * - */ - -#define DEBUG_SUBSYSTEM S_RPC - -#include -#include -#include - -struct recovd_obd *ptlrpc_connmgr; - -void recovd_cli_manage(struct recovd_obd *recovd, struct ptlrpc_client *cli) -{ - ENTRY; - cli->cli_recovd = recovd; - spin_lock(&recovd->recovd_lock); - list_add(&cli->cli_ha_item, &recovd->recovd_clients_lh); - spin_unlock(&recovd->recovd_lock); - EXIT; -} - -void recovd_cli_fail(struct ptlrpc_client *cli) -{ - ENTRY; - spin_lock(&cli->cli_recovd->recovd_lock); - cli->cli_recovd->recovd_flags |= RECOVD_FAIL; - cli->cli_recovd->recovd_wakeup_flag = 1; - list_del(&cli->cli_ha_item); - list_add(&cli->cli_ha_item, &cli->cli_recovd->recovd_troubled_lh); - spin_unlock(&cli->cli_recovd->recovd_lock); - wake_up(&cli->cli_recovd->recovd_waitq); - EXIT; -} - -/* this function must be called with cli->cli_lock held */ -void recovd_cli_fixed(struct ptlrpc_client *cli) -{ - ENTRY; - list_del(&cli->cli_ha_item); - list_add(&cli->cli_ha_item, &cli->cli_recovd->recovd_clients_lh); - EXIT; -} - - -static int recovd_upcall(void) -{ - char *argv[2]; - char *envp[3]; - - argv[0] = "/usr/src/obd/utils/ha_assist.sh"; - argv[1] = NULL; - - envp [0] = "HOME=/"; - envp [1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; - envp [2] = NULL; - - return call_usermodehelper(argv[0], argv, envp); -} - -static int recovd_check_event(struct recovd_obd *recovd) -{ - int rc = 0; - ENTRY; - - spin_lock(&recovd->recovd_lock); - - recovd->recovd_waketime = CURRENT_TIME; - if (recovd->recovd_timeout) - schedule_timeout(recovd->recovd_timeout); - - if (recovd->recovd_wakeup_flag) { - CERROR("service woken\n"); - GOTO(out, rc = 1); - } - - if (recovd->recovd_timeout && - CURRENT_TIME > recovd->recovd_waketime + recovd->recovd_timeout) { - recovd->recovd_flags |= RECOVD_TIMEOUT; - CERROR("timeout\n"); - GOTO(out, rc = 1); - } - - if (recovd->recovd_flags & RECOVD_STOPPING) { - CERROR("recovd stopping\n"); - rc = 1; - } - - out: - recovd->recovd_wakeup_flag = 0; - spin_unlock(&recovd->recovd_lock); - RETURN(rc); -} - -static int recovd_handle_event(struct recovd_obd *recovd) -{ - ENTRY; - - if (!(recovd->recovd_flags & RECOVD_UPCALL_WAIT) && - recovd->recovd_flags & RECOVD_FAIL) { - - CERROR("client in trouble: flags -> UPCALL_WAITING\n"); - recovd->recovd_flags |= RECOVD_UPCALL_WAIT; - - recovd_upcall(); - recovd->recovd_waketime = CURRENT_TIME; - recovd->recovd_timeout = 10 * HZ; - schedule_timeout(recovd->recovd_timeout); - } - - if (recovd->recovd_flags & RECOVD_TIMEOUT) { - CERROR("timeout - no news from upcall?\n"); - recovd->recovd_flags &= ~RECOVD_TIMEOUT; - } - - if (recovd->recovd_flags & RECOVD_UPCALL_ANSWER) { - CERROR("UPCALL_WAITING: upcall answer\n"); - - while (!list_empty(&recovd->recovd_troubled_lh)) { - struct ptlrpc_client *cli = - list_entry(recovd->recovd_troubled_lh.next, - struct ptlrpc_client, cli_ha_item); - - list_del(&cli->cli_ha_item); - if (cli->cli_recover) { - spin_unlock(&recovd->recovd_lock); - cli->cli_recover(cli); - spin_lock(&recovd->recovd_lock); - } - } - - recovd->recovd_timeout = 0; - recovd->recovd_flags = RECOVD_IDLE; - } - - RETURN(0); -} - -static int recovd_main(void *arg) -{ - struct recovd_obd *recovd = (struct recovd_obd *)arg; - - ENTRY; - - lock_kernel(); - daemonize(); - spin_lock_irq(¤t->sigmask_lock); - sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); - - sprintf(current->comm, "lustre_recovd"); - - /* Record that the thread is running */ - recovd->recovd_thread = current; - recovd->recovd_flags = RECOVD_IDLE; - wake_up(&recovd->recovd_ctl_waitq); - - /* And now, loop forever on requests */ - while (1) { - wait_event_interruptible(recovd->recovd_waitq, - recovd_check_event(recovd)); - - spin_lock(&recovd->recovd_lock); - if (recovd->recovd_flags & RECOVD_STOPPING) { - spin_unlock(&recovd->recovd_lock); - CERROR("lustre_recovd stopping\n"); - EXIT; - break; - } - - recovd_handle_event(recovd); - spin_unlock(&recovd->recovd_lock); - } - - recovd->recovd_thread = NULL; - recovd->recovd_flags = RECOVD_STOPPED; - wake_up(&recovd->recovd_ctl_waitq); - CDEBUG(D_NET, "mgr exiting process %d\n", current->pid); - RETURN(0); -} - -int recovd_setup(struct recovd_obd *recovd) -{ - int rc; - ENTRY; - - INIT_LIST_HEAD(&recovd->recovd_clients_lh); - INIT_LIST_HEAD(&recovd->recovd_troubled_lh); - spin_lock_init(&recovd->recovd_lock); - - init_waitqueue_head(&recovd->recovd_waitq); - init_waitqueue_head(&recovd->recovd_recovery_waitq); - init_waitqueue_head(&recovd->recovd_ctl_waitq); - - rc = kernel_thread(recovd_main, (void *)recovd, - CLONE_VM | CLONE_FS | CLONE_FILES); - if (rc < 0) { - CERROR("cannot start thread\n"); - RETURN(-EINVAL); - } - wait_event(recovd->recovd_ctl_waitq, recovd->recovd_flags & RECOVD_IDLE); - - RETURN(0); -} - -int recovd_cleanup(struct recovd_obd *recovd) -{ - spin_lock(&recovd->recovd_lock); - recovd->recovd_flags = RECOVD_STOPPING; - wake_up(&recovd->recovd_waitq); - spin_unlock(&recovd->recovd_lock); - - wait_event_interruptible(recovd->recovd_ctl_waitq, - (recovd->recovd_flags & RECOVD_STOPPED)); - RETURN(0); -} diff --git a/lustre/ptlrpc/rpc.c b/lustre/ptlrpc/rpc.c deleted file mode 100644 index 861938d..0000000 --- a/lustre/ptlrpc/rpc.c +++ /dev/null @@ -1,210 +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 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 EXPORT_SYMTAB -#define DEBUG_SUBSYSTEM S_RPC - -#include -#include - -extern int ptlrpc_init_portals(void); -extern void ptlrpc_exit_portals(void); - -int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf) -{ - struct recovd_obd *recovd = &obddev->u.recovd; - int err; - ENTRY; - - memset(recovd, 0, sizeof(*recovd)); - - OBD_ALLOC(recovd->recovd_client, sizeof(*recovd->recovd_client)); - if (!recovd) - RETURN(-ENOMEM); - - err = recovd_setup(recovd); - if (err) - GOTO(err_free, err); - - recovd->recovd_service = - ptlrpc_init_svc(128 * 1024,CONNMGR_REQUEST_PORTAL, - CONNMGR_REPLY_PORTAL, "self", connmgr_handle); - if (!recovd->recovd_service) { - CERROR("failed to start service\n"); - GOTO(err_recovd, err = -EINVAL); - } - - ptlrpc_init_client(NULL, NULL, CONNMGR_REQUEST_PORTAL, - CONNMGR_REPLY_PORTAL, recovd->recovd_client); - recovd->recovd_client->cli_name = "connmgr"; - - err = ptlrpc_start_thread(obddev, recovd->recovd_service, "lustre_connmgr"); - if (err) { - CERROR("cannot start thread\n"); - GOTO(err_svc, err); - } - - MOD_INC_USE_COUNT; - ptlrpc_connmgr = recovd; - RETURN(0); - - err_svc: - rpc_unregister_service(recovd->recovd_service); - err_recovd: - recovd_cleanup(recovd); - err_free: - if (recovd->recovd_client) - OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client)); - RETURN(err); -} - -int connmgr_cleanup(struct obd_device *dev) -{ - struct recovd_obd *recovd = &dev->u.recovd; - int err; - - err = recovd_cleanup(recovd); - if (err) - LBUG(); - - ptlrpc_stop_all_threads(recovd->recovd_service); - rpc_unregister_service(recovd->recovd_service); - if (!list_empty(&recovd->recovd_service->srv_reqs)) { - // XXX reply with errors and clean up - CERROR("Request list not empty!\n"); - } - - OBD_FREE(recovd->recovd_service, sizeof(*recovd->recovd_service)); - ptlrpc_cleanup_client(recovd->recovd_client); - OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client)); - MOD_DEC_USE_COUNT; - RETURN(0); -} - - -int connmgr_iocontrol(long cmd, struct obd_conn *conn, int len, void *karg, - void *uarg) -{ - struct recovd_obd *recovd = &conn->oc_dev->u.recovd; - - ENTRY; - if (cmd == OBD_IOC_RECOVD_NEWCONN) { - spin_lock(&recovd->recovd_lock); - recovd->recovd_flags |= RECOVD_UPCALL_ANSWER; - recovd->recovd_wakeup_flag = 1; - wake_up(&recovd->recovd_waitq); - spin_unlock(&recovd->recovd_lock); - EXIT; - } - return 0; -} - - -/* use obd ops to offer management infrastructure */ -static struct obd_ops recovd_obd_ops = { - o_setup: connmgr_setup, - o_cleanup: connmgr_cleanup, - o_iocontrol: connmgr_iocontrol, -}; - -static int __init ptlrpc_init(void) -{ - int rc; - rc = ptlrpc_init_portals(); - if (rc) - RETURN(rc); - ptlrpc_init_connection(); - obd_register_type(&recovd_obd_ops, LUSTRE_HA_NAME); - return 0; -} - -static void __exit ptlrpc_exit(void) -{ - obd_unregister_type(LUSTRE_HA_NAME); - ptlrpc_exit_portals(); - ptlrpc_cleanup_connection(); -} - -/* connmgr.c */ -EXPORT_SYMBOL(ptlrpc_connmgr); -EXPORT_SYMBOL(connmgr_connect); -EXPORT_SYMBOL(connmgr_handle); -EXPORT_SYMBOL(recovd_cli_fail); -EXPORT_SYMBOL(recovd_cli_manage); -EXPORT_SYMBOL(recovd_cli_fixed); -EXPORT_SYMBOL(recovd_setup); -EXPORT_SYMBOL(recovd_cleanup); - -/* connection.c */ -EXPORT_SYMBOL(ptlrpc_readdress_connection); -EXPORT_SYMBOL(ptlrpc_get_connection); -EXPORT_SYMBOL(ptlrpc_put_connection); -EXPORT_SYMBOL(ptlrpc_connection_addref); -EXPORT_SYMBOL(ptlrpc_init_connection); -EXPORT_SYMBOL(ptlrpc_cleanup_connection); - -/* niobuf.c */ -EXPORT_SYMBOL(ptlrpc_send_bulk); -EXPORT_SYMBOL(ptlrpc_register_bulk); -EXPORT_SYMBOL(ptlrpc_abort_bulk); -EXPORT_SYMBOL(ptlrpc_reply); -EXPORT_SYMBOL(ptlrpc_error); -EXPORT_SYMBOL(ptlrpc_resend_req); -EXPORT_SYMBOL(ptl_send_rpc); -EXPORT_SYMBOL(ptlrpc_link_svc_me); - -/* client.c */ -EXPORT_SYMBOL(ptlrpc_init_client); -EXPORT_SYMBOL(ptlrpc_cleanup_client); -EXPORT_SYMBOL(ptlrpc_req_to_uuid); -EXPORT_SYMBOL(ptlrpc_uuid_to_connection); -EXPORT_SYMBOL(ptlrpc_queue_wait); -EXPORT_SYMBOL(ptlrpc_continue_req); -EXPORT_SYMBOL(ptlrpc_replay_req); -EXPORT_SYMBOL(ptlrpc_restart_req); -EXPORT_SYMBOL(ptlrpc_prep_req); -EXPORT_SYMBOL(ptlrpc_free_req); -EXPORT_SYMBOL(ptlrpc_req_finished); -EXPORT_SYMBOL(ptlrpc_prep_bulk); -EXPORT_SYMBOL(ptlrpc_free_bulk); -EXPORT_SYMBOL(ptlrpc_prep_bulk_page); -EXPORT_SYMBOL(ptlrpc_free_bulk_page); -EXPORT_SYMBOL(ptlrpc_check_status); - -/* service.c */ -EXPORT_SYMBOL(ptlrpc_init_svc); -EXPORT_SYMBOL(ptlrpc_stop_all_threads); -EXPORT_SYMBOL(ptlrpc_start_thread); -EXPORT_SYMBOL(rpc_unregister_service); - -/* pack_generic.c */ -EXPORT_SYMBOL(lustre_pack_msg); -EXPORT_SYMBOL(lustre_msg_size); -EXPORT_SYMBOL(lustre_unpack_msg); -EXPORT_SYMBOL(lustre_msg_buf); - -MODULE_AUTHOR("Peter J. Braam "); -MODULE_DESCRIPTION("Lustre Request Processor v1.0"); -MODULE_LICENSE("GPL"); - -module_init(ptlrpc_init); -module_exit(ptlrpc_exit); diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c deleted file mode 100644 index f87c484..0000000 --- a/lustre/ptlrpc/service.c +++ /dev/null @@ -1,345 +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 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_RPC - -#include - -extern int request_in_callback(ptl_event_t *ev, void *data); -extern int ptl_handled_rpc(struct ptlrpc_service *service, void *start); - -static int ptlrpc_check_event(struct ptlrpc_service *svc, - struct ptlrpc_thread *thread, ptl_event_t *event) -{ - int rc = 0; - ENTRY; - - spin_lock(&svc->srv_lock); - if (sigismember(&(current->pending.signal), SIGKILL) || - sigismember(&(current->pending.signal), SIGTERM) || - sigismember(&(current->pending.signal), SIGINT)) { - thread->t_flags |= SVC_KILLED; - GOTO(out, rc = 1); - } - - if (thread->t_flags & SVC_STOPPING) - GOTO(out, rc = 1); - - if (ptl_is_valid_handle(&svc->srv_eq_h)) { - int err; - err = PtlEQGet(svc->srv_eq_h, event); - - if (err == PTL_OK) { - thread->t_flags |= SVC_EVENT; - GOTO(out, rc = 1); - } - - if (err != PTL_EQ_EMPTY) { - CDEBUG(D_NET, "BUG: PtlEQGet returned %d\n", rc); - LBUG(); - } - - GOTO(out, rc = 0); - } - - EXIT; - out: - spin_unlock(&svc->srv_lock); - return rc; -} - -struct ptlrpc_service * -ptlrpc_init_svc(__u32 bufsize, int req_portal, int rep_portal, char *uuid, - svc_handler_t handler) -{ - int err; - int rc, i; - struct ptlrpc_service *service; - ENTRY; - - OBD_ALLOC(service, sizeof(*service)); - if (!service) { - LBUG(); - RETURN(NULL); - } - - spin_lock_init(&service->srv_lock); - INIT_LIST_HEAD(&service->srv_reqs); - INIT_LIST_HEAD(&service->srv_threads); - init_waitqueue_head(&service->srv_waitq); - - service->srv_buf_size = bufsize; - service->srv_rep_portal = rep_portal; - service->srv_req_portal = req_portal; - service->srv_handler = handler; - - err = kportal_uuid_to_peer(uuid, &service->srv_self); - if (err) { - CERROR("cannot get peer for uuid '%s'", uuid); - GOTO(err_free, NULL); - } - - service->srv_ring_length = RPC_RING_LENGTH; - - rc = PtlEQAlloc(service->srv_self.peer_ni, 128, request_in_callback, - service, &(service->srv_eq_h)); - - if (rc != PTL_OK) { - CERROR("PtlEQAlloc failed: %d\n", rc); - LBUG(); - GOTO(err_free, NULL); - } - - for (i = 0; i < service->srv_ring_length; i++) { - OBD_ALLOC(service->srv_buf[i], service->srv_buf_size); - if (service->srv_buf[i] == NULL) { - CERROR("no memory\n"); - LBUG(); - GOTO(err_ring, NULL); - } - service->srv_ref_count[i] = 0; - ptlrpc_link_svc_me(service, i); - } - - CDEBUG(D_NET, "Starting service listening on portal %d\n", - service->srv_req_portal); - - RETURN(service); -err_ring: - service->srv_ring_length = i; - rpc_unregister_service(service); // XXX verify this is right - PtlEQFree(service->srv_eq_h); -err_free: - OBD_FREE(service, sizeof(*service)); - return NULL; -} - -static int handle_incoming_request(struct obd_device *obddev, - struct ptlrpc_service *svc, - ptl_event_t *event) -{ - struct ptlrpc_request request; - struct lustre_peer peer; - void *start; - int rc; - - /* FIXME: If we move to an event-driven model, we should put the request - * on the stack of mds_handle instead. */ - start = event->mem_desc.start; - memset(&request, 0, sizeof(request)); - request.rq_obd = obddev; - request.rq_reqmsg = event->mem_desc.start + event->offset; - request.rq_reqlen = event->mem_desc.length; - - if (request.rq_reqmsg->xid != event->match_bits) - LBUG(); - - CDEBUG(D_NET, "got req %d\n", request.rq_reqmsg->xid); - - peer.peer_nid = event->initiator.nid; - /* FIXME: this NI should be the incoming NI. - * We don't know how to find that from here. */ - peer.peer_ni = svc->srv_self.peer_ni; - - if (request.rq_reqmsg->conn) { - request.rq_connection = - (void *)(unsigned long)request.rq_reqmsg->conn; - if (request.rq_reqmsg->token != - request.rq_connection->c_token) { - struct ptlrpc_connection *tmp; - tmp = ptlrpc_get_connection(&peer); - CERROR("rq_reqmsg->conn: %p\n", request.rq_connection); - CERROR("real connection: %p\n", tmp); - CERROR("rq_reqmsg->token: %Lu\n", - (unsigned long long)request.rq_reqmsg->token); - CERROR("real token : %Lu\n", - (unsigned long long)tmp->c_token); - LBUG(); - } - ptlrpc_connection_addref(request.rq_connection); - } else { - /* - PHIL? should we perhaps only do this when - we get an incoming connmgr_connect request? - */ - request.rq_connection = ptlrpc_get_connection(&peer); - if (!request.rq_connection) - LBUG(); - } - - spin_unlock(&svc->srv_lock); - rc = svc->srv_handler(obddev, svc, &request); - ptlrpc_put_connection(request.rq_connection); - ptl_handled_rpc(svc, start); - return rc; -} - -static int ptlrpc_main(void *arg) -{ - int rc; - struct ptlrpc_svc_data *data = (struct ptlrpc_svc_data *)arg; - struct obd_device *obddev = data->dev; - struct ptlrpc_service *svc = data->svc; - struct ptlrpc_thread *thread = data->thread; - - ENTRY; - - lock_kernel(); - daemonize(); - spin_lock_irq(¤t->sigmask_lock); - sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); - - sprintf(current->comm, data->name); - - /* Record that the thread is running */ - thread->t_flags = SVC_RUNNING; - wake_up(&thread->t_ctl_waitq); - - /* XXX maintain a list of all managed devices: insert here */ - - /* And now, loop forever on requests */ - while (1) { - ptl_event_t event; - - wait_event(svc->srv_waitq, - ptlrpc_check_event(svc, thread, &event)); - - spin_lock(&svc->srv_lock); - if (thread->t_flags & SVC_SIGNAL) { - thread->t_flags &= ~SVC_SIGNAL; - spin_unlock(&svc->srv_lock); - EXIT; - break; - } - - if (thread->t_flags & SVC_STOPPING) { - thread->t_flags &= ~SVC_STOPPING; - spin_unlock(&svc->srv_lock); - EXIT; - break; - } - - if (thread->t_flags & SVC_EVENT) { - thread->t_flags &= ~SVC_EVENT; - rc = handle_incoming_request(obddev, svc, &event); - thread->t_flags &= ~SVC_EVENT; - continue; - } - - CERROR("unknown break in service"); - spin_unlock(&svc->srv_lock); - EXIT; - break; - } - - thread->t_flags = SVC_STOPPED; - wake_up(&thread->t_ctl_waitq); - CDEBUG(D_NET, "service thread exiting, process %d\n", current->pid); - return 0; -} - -static void ptlrpc_stop_thread(struct ptlrpc_service *svc, - struct ptlrpc_thread *thread) -{ - thread->t_flags = SVC_STOPPING; - - wake_up(&svc->srv_waitq); - wait_event_interruptible(thread->t_ctl_waitq, - (thread->t_flags & SVC_STOPPED)); -} - -void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) -{ - spin_lock(&svc->srv_lock); - while (!list_empty(&svc->srv_threads)) { - struct ptlrpc_thread *thread; - thread = list_entry(svc->srv_threads.next, struct ptlrpc_thread, - t_link); - spin_unlock(&svc->srv_lock); - ptlrpc_stop_thread(svc, thread); - spin_lock(&svc->srv_lock); - list_del(&thread->t_link); - OBD_FREE(thread, sizeof(*thread)); - } - spin_unlock(&svc->srv_lock); -} - -int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc, - char *name) -{ - struct ptlrpc_svc_data d; - struct ptlrpc_thread *thread; - int rc; - ENTRY; - - OBD_ALLOC(thread, sizeof(*thread)); - if (thread == NULL) { - LBUG(); - RETURN(-ENOMEM); - } - init_waitqueue_head(&thread->t_ctl_waitq); - - d.dev = dev; - d.svc = svc; - d.name = name; - d.thread = thread; - - spin_lock(&svc->srv_lock); - list_add(&thread->t_link, &svc->srv_threads); - spin_unlock(&svc->srv_lock); - - rc = kernel_thread(ptlrpc_main, (void *) &d, - CLONE_VM | CLONE_FS | CLONE_FILES); - if (rc < 0) { - CERROR("cannot start thread\n"); - RETURN(-EINVAL); - } - wait_event(thread->t_ctl_waitq, thread->t_flags & SVC_RUNNING); - - RETURN(0); -} - -int rpc_unregister_service(struct ptlrpc_service *service) -{ - int rc, i; - - for (i = 0; i < service->srv_ring_length; i++) { - if (ptl_is_valid_handle(&(service->srv_me_h[i]))) { - rc = PtlMEUnlink(service->srv_me_h[i]); - if (rc) - CERROR("PtlMEUnlink failed: %d\n", rc); - ptl_set_inv_handle(&(service->srv_me_h[i])); - } - - if (service->srv_buf[i] != NULL) - OBD_FREE(service->srv_buf[i], service->srv_buf_size); - service->srv_buf[i] = NULL; - } - - rc = PtlEQFree(service->srv_eq_h); - if (rc) - CERROR("PtlEQFree failed: %d\n", rc); - - return 0; -} diff --git a/lustre/scripts/.cvsignore b/lustre/scripts/.cvsignore deleted file mode 100644 index 104ddf7..0000000 --- a/lustre/scripts/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -.Xrefs -lustre.spec -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS diff --git a/lustre/scripts/Makefile.am b/lustre/scripts/Makefile.am deleted file mode 100644 index 5f8bb20..0000000 --- a/lustre/scripts/Makefile.am +++ /dev/null @@ -1,8 +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 - -EXTRA_DIST = license-status maketags.sh mkobddevs obdtrace_demo.scr lustre.spec -include $(top_srcdir)/Rules - diff --git a/lustre/scripts/license-status b/lustre/scripts/license-status deleted file mode 100755 index 5407b91..0000000 --- a/lustre/scripts/license-status +++ /dev/null @@ -1,26 +0,0 @@ -#! /bin/sh -# license-status - Display the status of files in the current directory -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution -# -# Gordon Matzigkeit , 2001-09-27 - -for f in `find . -type f | sort`; do - case "$f" in - *~ | *.orig | *.gz | */config.* | *.o | \ - */CVS/* | */.cvsignore | */.depfiles/* | \ - */COPYING | */ChangeLog) - continue - ;; - esac - - if head -20 "$f" | egrep -e 'GNU' > /dev/null; then - echo "gpled $f" - elif head -20 "$f" | egrep -e '\([Cc]\)' > /dev/null; then - echo "copyrighted $f" - else - echo "bare $f" - fi -done | sort diff --git a/lustre/scripts/lustre.spec.in b/lustre/scripts/lustre.spec.in deleted file mode 100644 index 6919409..0000000 --- a/lustre/scripts/lustre.spec.in +++ /dev/null @@ -1,87 +0,0 @@ -# obd.spec -%define version 0.3.2.0 -%define kversion @RELEASE@ -%define linuxdir @LINUX@ -%define portalsdir @PORTALS@ -Release: 0 - -Summary: Lustre Lite File System -Name: lustre-lite -Version: %{version} -Copyright: GPL -Group: Utilities/System -Requires: lustre-modules, perl-Storable, perl-Term-ReadLine-Gnu -BuildRoot: /var/tmp/obd-%{version}-root -Source: ftp://ftp.lustre.com/pub/lustre/obd-%{version}.tar.gz - -%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} -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 - -%prep -%setup -n obd-%{version} - -%build -rm -rf $RPM_BUILD_ROOT - -# Create the pristine source directory. -mkdir -p $RPM_BUILD_ROOT/usr/src/obd-%{version} -tar -cf - . | (cd $RPM_BUILD_ROOT/usr/src/obd-%{version} && tar -xvBpf -) -mkdir -p $RPM_BUILD_ROOT/tmp -echo :pserver:anonymous@cvs.lustre.sf.net:/cvsroot/lustre > $RPM_BUILD_ROOT/tmp/Root -(cd $RPM_BUILD_ROOT/usr/src/obd-%{version} && find . -name Root -exec cp $RPM_BUILD_ROOT/tmp/Root {} \; ) - -# Set an explicit path to our Linux tree, if we can. -./configure --enable-linuxdir=%{linuxdir} --enable-portalsdir=%{portalsdir} -make - -%install -make install prefix=$RPM_BUILD_ROOT - -%files -%attr(-, root, root) %doc COPYING FDL -%attr(-, root, root) %doc doc/API.txt doc/OBD-HOWTO.sgml doc/obdspec.sgml -%attr(-, root, root) %doc doc/OLVM.txt doc/figs doc/notes.txt -%attr(-, root, root) %doc doc/obdtrace_demo.txt -%attr(-, root, root) /usr/bin/obdctl - -%files -n lustre-modules -%attr(-, root, root) %doc COPYING -%attr(-, root, root) /lib/modules/%{kversion}/fs/llight.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/ptlrpc.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/mds.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/mdc.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/ost.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/osc.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/obdclass.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/obdfilter.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/obdecho.o -%attr(-, root, root) /lib/modules/%{kversion}/fs/obdext2.o - -%files -n lustre-source -%attr(-, root, root) /usr/src/obd-%{version} - -%post -depmod -ae || exit 0 - -%postun -depmod -ae || exit 0 - -%clean -#rm -rf $RPM_BUILD_ROOT - -# end of file diff --git a/lustre/scripts/maketags.sh b/lustre/scripts/maketags.sh deleted file mode 100755 index 9bd9f87..0000000 --- a/lustre/scripts/maketags.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution -set -vx -rm -f TAGS ; find . -name '*.h' -or -name '*.c' | xargs etags -rm -f ctags; find . -name '*.h' -or -name '*.c' | xargs ctags diff --git a/lustre/scripts/mkobddevs b/lustre/scripts/mkobddevs deleted file mode 100755 index a35631d..0000000 --- a/lustre/scripts/mkobddevs +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -x -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -mknod -m 0600 /dev/obd0 c 186 0 -mknod -m 0600 /dev/obd1 c 186 1 -mknod -m 0600 /dev/obd2 c 186 2 -mknod -m 0600 /dev/obd3 c 186 3 -mknod -m 0600 /dev/obd4 c 186 4 -mknod -m 0600 /dev/obd5 c 186 5 -mknod -m 0600 /dev/obd6 c 186 6 -mknod -m 0600 /dev/obd7 c 186 7 diff --git a/lustre/scripts/obdtrace_demo.scr b/lustre/scripts/obdtrace_demo.scr deleted file mode 100644 index 0601235..0000000 --- a/lustre/scripts/obdtrace_demo.scr +++ /dev/null @@ -1,60 +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 -# Print OS version -shell uname -r -# Insert Lustre kernel modules -insmod class/obdclass.o -procsys trace 0 -procsys debug 0 -insmod ext2obd/obdext2.o -insmod obdtrace/obdtrace.o -insmod obdfs/obdfs.o -# Configure direct driver on /dev/obd0 -device /dev/obd0 -attach obdext2 -setup /dev/sda2 -# Configure obdtrace on /dev/obd1 -device /dev/obd1 -attach obdtrace -setup /dev/obd0 -# What's the obd status -status -shell cat /proc/lustre/obd/1/stats -# mount obd file system -shell mkdir -p /mnt/obd -shell mount -t obdfs -odevice=/dev/obd1 none /mnt/obd -shell mount -# Prepare a data set (tar file of current directory) -shell rm -f /tmp/obdtrace_test.tar -shell tar cf /tmp/obdtrace_test.tar . -# make a directory on obd device -shell mkdir -p /mnt/obd/obdtrace_test_dir -# Unpack tarfile to obd device -shell tar -C /mnt/obd/obdtrace_test_dir -xf /tmp/obdtrace_test.tar -shell rm -rf /mnt/obd/obdtrace_test_dir -# Check obdtrace performance stats -status -shell cat /proc/lustre/obd/1/stats -shell echo 0 > /proc/lustre/obd/1/stats -shell cat /proc/lustre/obd/1/stats -# Umount file system -shell umount /mnt/obd -# Cleanup /tmp -shell rm -f /tmp/obdtrace_test.tar -# Dismantle /dev/obd1 -device /dev/obd1 -cleanup -detach -close -# Dismantle /dev/obd0 -device /dev/obd0 -cleanup -detach -close -# Remove all loaded kernel modules -rmmod obdfs -rmmod obdtrace -rmmod obdext2 -rmmod obdclass diff --git a/lustre/tests/.cvsignore b/lustre/tests/.cvsignore deleted file mode 100644 index a171dcd..0000000 --- a/lustre/tests/.cvsignore +++ /dev/null @@ -1,15 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -TAGS -openunlink -testreq -truncate -directio -openme -writeme -fsx diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am deleted file mode 100644 index be14c89..0000000 --- a/lustre/tests/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -DEFS:= -CPPFLAGS := -I. -I$(PORTALS)/include -I$(top_srcdir)/include -D_LARGEFILE64_SOURCE -CFLAGS := -g -Wall -# LDADD = -lldap -# LDADD := -lreadline -ltermcap # -lefence -bin_PROGRAMS = openunlink testreq truncate directio openme writeme fsx #ldaptest - -# ldaptest_SOURCES = ldaptest.c -testreq_SOURCES = testreq.c -truncate_SOURCES = truncate.c -directio_SOURCES = directio.c -openunlink_SOURCES = openunlink.c -openme_SOURCES = openme.c -writeme_SOURCES = writeme.c -fsx_SOURCES = fsx.c - -include $(top_srcdir)/Rules - diff --git a/lustre/tests/README b/lustre/tests/README deleted file mode 100644 index 50fa500..0000000 --- a/lustre/tests/README +++ /dev/null @@ -1,100 +0,0 @@ -A variety of tests can be run or environments set up. - -1. runregression-net - -Usage on server: - llsetup.sh marcus-echo-server.cfg - -with marcus-echo-server.cfg: - - NETWORK=elan - LOCALHOST=4 - SERVER=4 - SETUP_OST=y - OSTTYPE=obdecho - - -Usage on client: -runregression-net marcus-echo-client.cfg - -with marcus-echo-client.cfg: - - NETWORK=elan - LOCALHOST=5 - SERVER=4 - SETUP_OSC=y - -If things are alright it goes through all the tests single threaded, -multithreaded, getattr and brw (both read and write). - -2. How to build .cfg scripts: -The various .cfg scripts in the tests/ directory can be used as building -blocks for full configurations. For example, the above configurations are: - - cat elan-server.cfg obdecho.cfg > marcus-echo-server.cfg - cat elan-client.cfg client-echo.cfg > marcus-echo-client.cfg - -You _could_ specify multiple .cfg files as the parameters to llsetup if -you are doing something uncommon, but it is probably just easer to build -a whole config file in one shot, edit it as needed, and use that file instead. - -For a loopback setup with a mounted filesystem, you could do something like: - - cat net-local.cfg mds.cfg obdext2.cfg client-mount.cfg > uml.cfg - -The order of the specified .cfg files does not matter. - -Since the .cfg script is a shell script, you can add conditional setup in -case you want to avoid changing your configuration if you need to run on -a different host. You could, for example, have marcus-echo-server.cfg: - - NETWORK=elan - HOST=`hostname | sed "s/\..*//"` - case $HOST in - dev*) LOCALHOST=`echo $HOST | sed "s/dev//"` - SERVER=$LOCALHOST - NETWORK=elan ;; - *) LOCALHOST=$HOST - SERVER=$LOCALHOST - NETWORK=tcp ;; - esac - SETUP_OST=y - OSTTYPE=obdecho - -You would, of course, need a marcus-echo-client.cfg to match. - -3. runtests - -The runtests script does a series of simple file-based tests using -a filesystem. You need to use a configuration which includes a real -OST and MDS setup, and an OSC mount. For example, a configuration -marcus-obd-server.cfg: - - SETUP_MDS=y - NETWORK=elan - LOCALHOST=4 - SERVER=4 - MDSFS=ext3 - MDSDEV=/tmp/mds - MDSSIZE=10000 - OSTDEV=/tmp/ost - OSTSIZE=10000 - OSTFS=ext2 - OSTTYPE=obdext2 - SETUP_OST=y - SETUP_LDLM=y - -As with the echo test, you run "sh llsetup.sh marcus-obd-server.cfg" on -the server to configure it. - -For marcus-obd-client.cfg you only need to include the client data: - - NETWORK=elan - LOCALHOST=5 - SERVER=4 - SETUP_OSC=y - OSCMT=/mnt/lustre - SETUP_MOUNT=y - SETUP_LDLM=y - -You run the test via "sh runtests marcus-obd-client.cfg". diff --git a/lustre/tests/client-echo.cfg b/lustre/tests/client-echo.cfg deleted file mode 100644 index 83856ec..0000000 --- a/lustre/tests/client-echo.cfg +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Config file for setting up a client to talk to an echo OST -SETUP_OSC=y diff --git a/lustre/tests/client-mount.cfg b/lustre/tests/client-mount.cfg deleted file mode 100644 index 644ae14..0000000 --- a/lustre/tests/client-mount.cfg +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Config file for mounting a client Lustre filesystem -SETUP_OSC=y -OSCMT=/mnt/lustre -SETUP_MOUNT=y diff --git a/lustre/tests/common.sh b/lustre/tests/common.sh deleted file mode 100644 index f184982..0000000 --- a/lustre/tests/common.sh +++ /dev/null @@ -1,545 +0,0 @@ -#!/bin/sh -export PATH=$PATH:/sbin:/usr/sbin - -[ -d /r ] && R=/r - -PORTALS=$SRCDIR../../portals -LUSTRE=$SRCDIR../../lustre - -PTLCTL=$PORTALS/linux/utils/ptlctl -DBGCTL=$PORTALS/linux/utils/debugctl -ACCEPTOR=$PORTALS/linux/utils/acceptor - -OBDCTL=$LUSTRE/utils/obdctl - -LOOPNUM=0; export LOOPNUM -if [ -b /dev/loop0 ]; then - LOOP=/dev/loop -elif [ -b /dev/loop/0 ]; then - LOOP=/dev/loop/ -else - echo "Cannot find /dev/loop0 or /dev/loop/0" 1>&2 && exit -1 -fi - -do_insmod() { - MODULE=$1 - BASE=`echo $MODULE | sed -e "s^.*/^^" -e "s/\.o$//"` - - [ "$MODULE" ] || fail "usage: $0 " - [ -f $MODULE ] || echo "$0: module '$MODULE' not found" 1>&2 - lsmod | grep -q "\<$BASE\>" && return 0 - insmod $MODULE -} - -# Return the next unused loop device on stdout and in the $LOOPDEV -# environment variable. -next_loop_dev() { - NEXT= - while [ -b ${LOOP}${LOOPNUM} ]; do - LOOPDEV=${LOOP}${LOOPNUM} - losetup ${LOOPDEV} > /dev/null 2>&1 || NEXT=${LOOPDEV} - LOOPNUM=`expr ${LOOPNUM} + 1` - [ "$NEXT" ] && echo ${NEXT} && break - done -} - -# Create a new filesystem. If we are using a loopback device, we check -# for existing "template" filesystems instead of creating a new one, -# because it is _much_ faster to gunzip the empty filesystem instead of -# creating a new one from scratch. Conversely, if we are creating a -# filesystem on a device we use mkfs, because that only writes sparsely -# to the device. The empty filesystems are also highly compressed (1000:1) -# so they don't take too much space. -# -new_fs_usage() { - echo "new_fs {device | file} [size]" 1>&2 - exit -1 -} -new_fs () { - EFILE="$1_$3.gz" - MKFS="mkfs.$1" - MKFSOPT="-b 4096" - - [ "$1" = "ext3" ] && MKFS="mkfs.ext2 -j" - if [ "$1" = "extN" ]; then - MKFS="mkfs.ext2 -j" - EFILE="ext3_$3.gz" - fi - - if [ -b "$2" ]; then - [ $# -lt 2 -o $# -gt 3 ] && new_fs_usage - - PM="/proc/mounts" - [ -r "$PM" ] || PM="/etc/mtab" - - grep "$2 " $PM 1>&2 && echo "$0: $2 is in $PM!" 1>&2 && exit -1 - - $MKFS $MKFSOPT $2 $3 || exit -1 - LOOPDEV=$2 # Not really a loop device - else - [ $# -ne 3 ] && new_fs_usage - - if [ -r "$EFILE" ]; then - echo "using prepared filesystem $EFILE for $2" - zcat "$EFILE" > $2 || exit -1 - sync - else - echo "creating new sparse filesystem on $2" - dd if=/dev/zero of=$2 bs=1k seek=$3 count=1 1>&2 || exit -1 - $MKFS $MKFSOPT -F $2 1>&2 || exit -1 - fi - LOOPDEV=`next_loop_dev` - losetup ${LOOPDEV} $2 1>&2 || exit -1 - fi - - # Enable hash-indexed directories for extN filesystems - [ "$1" = "extN" ] && echo "feature FEATURE_C5" | debugfs -w $2 -} - -# Set up to use an existing filesystem. We take the same parameters as -# new_fs, even though we only use the and parameters, to -# make it easy to convert between new_fs and old_fs in testing scripts. -old_fs () { - [ -e $2 ] || exit -1 - - if [ -b "$2" ]; then - LOOPDEV=$2 # Not really a loop device - else - LOOPDEV=`next_loop_dev` - losetup ${LOOPDEV} $2 1>&2 || exit -1 - fi -} - -list_mods() { - $DBGCTL modules > $R/tmp/ogdb - echo "The GDB module script is in $R/tmp/ogdb" - [ "$DEBUG_WAIT" = "yes" ] && echo -n "Press ENTER to continue" && read -} - -# We need at least one setup file to be given. It can be passed on -# the command-line, or it can be found in the home directory, or it -# can even be sourced into the current shell environment. -setup_opts() { - DEF=$HOME/.lustretestrc - [ -r $DEF ] && . $DEF && SETUP=y - - for CFG in "$@" ; do - case $CFG in - *.cfg) [ -r "$CFG" ] && . $CFG && SETUP=y ;; - *) echo "unknown option '$CFG'" 1>&2 - esac - done - - if [ "$SETUP" != "y" ]; then - echo "error: no config file on command-line and no $DEF" 1>&2 - exit -1 - fi - - [ -z "$MDS_RSH" ] && MDS_RSH="eval" - [ -z "$OST_RSH" ] && OST_RSH="eval" - [ -z "$OSC_RSH" ] && OSC_RSH="eval" -} - -setup_portals() { - if grep -q portals /proc/modules; then - echo "$0: portals already appears to be set up, skipping" - return 0 - fi - - if [ -z "$NETWORK" -o -z "$LOCALHOST" -o -z "$SERVER" ]; then - echo "$0: NETWORK or LOCALHOST or SERVER is not set" 1>&2 - exit -1 - fi - - [ -z "$OSTNODE" ] && OSTNODE=$SERVER - - if [ -z "$DLM" ]; then - if [ "$LOCALHOST" == "$SERVER" ]; then - DLM=localhost - else - DLM=$SERVER - fi - fi - - [ -c /dev/portals ] || mknod /dev/portals c 10 240 - - do_insmod $PORTALS/linux/oslib/portals.o || exit -1 - - case $NETWORK in - elan) [ "$PORT" ] && fail "$0: NETWORK is elan but PORT is set" - do_insmod $PORTALS/linux/qswnal/kqswnal.o || exit -1 - ;; - tcp) [ "$PORT" ] || fail "$0: NETWORK is tcp but PORT is not set" - do_insmod $PORTALS/linux/socknal/ksocknal.o || exit -1 - $ACCEPTOR $PORT - ;; - *) fail "$0: unknown NETWORK '$NETWORK'" ;; - esac - - $PTLCTL <<- EOF - setup $NETWORK - mynid $LOCALHOST - connect $SERVER $PORT - add_uuid self - add_uuid mds - connect $OSTNODE $PORT - add_uuid ost - connect $DLM $PORT - add_uuid ldlm - quit - EOF -} - -setup_lustre() { - [ -c /dev/obd ] || mknod /dev/obd c 10 241 - - do_insmod $LUSTRE/obdclass/obdclass.o || exit -1 - do_insmod $LUSTRE/ptlrpc/ptlrpc.o || exit -1 - do_insmod $LUSTRE/ldlm/ldlm.o || exit -1 - do_insmod $LUSTRE/extN/extN.o || \ - echo "info: can't load extN.o module, not fatal if using ext3" - do_insmod $LUSTRE/mds/mds.o || exit -1 - do_insmod $LUSTRE/mds/mds_ext2.o || exit -1 - do_insmod $LUSTRE/mds/mds_ext3.o || exit -1 - do_insmod $LUSTRE/mds/mds_extN.o || \ - echo "info: can't load mds_extN.o module, needs extN.o" - do_insmod $LUSTRE/obdecho/obdecho.o || exit -1 - do_insmod $LUSTRE/obdext2/obdext2.o || exit -1 - do_insmod $LUSTRE/obdfilter/obdfilter.o || exit -1 - do_insmod $LUSTRE/ost/ost.o || exit -1 - do_insmod $LUSTRE/osc/osc.o || exit -1 - do_insmod $LUSTRE/mdc/mdc.o || exit -1 - do_insmod $LUSTRE/llite/llite.o || exit -1 - - list_mods - - if $OBDCTL name2dev RPCDEV > /dev/null 2>&1; then - echo "$0: RPCDEV is already configured, skipping" - return 0 - fi - - $OBDCTL <<- EOF || return $? - newdev - attach ptlrpc RPCDEV - setup - quit - EOF - - [ -d /mnt/lustre ] || mkdir /mnt/lustre -} - -setup_ldlm() { - [ "$SETUP_LDLM" = "y" ] || return 0 - - [ -c /dev/portals ] || mknod /dev/portals c 10 240 - - $OBDCTL <<- EOF || return $? - newdev - attach ldlm LDLMDEV - setup - quit - EOF - -} - -find_devno() { - if [ -z "$1" ]; then - echo "usage: $0 " 1>&2 - return -1 - fi - - $OBDCTL name2dev $1 -} - -setup_mds() { - [ "$SETUP_MDS" = "y" ] || return 0 - - if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then - echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2 - return -1 - fi - - [ "$1" ] && DO_FS=$1 - if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then - echo "usage: setup_mds {new_fs|old_fs}" 1>&2 - return -1 - fi - - if $OBDCTL name2dev MDSDEV > /dev/null 2>&1; then - echo "$0: MDSDEV is already configured" - return 0 - fi - - $DO_FS ${MDSFS} ${MDSDEV} ${MDSSIZE} - MDS=${LOOPDEV} - - $OBDCTL <<- EOF || return $? - newdev - attach mds MDSDEV - setup ${MDS} ${MDSFS} - quit - EOF -} - -setup_ost() { - [ "$SETUP_OST" = "y" ] || return 0 - - if [ -z "$OSTTYPE" ]; then - echo "error: setup_ost: OSTTYPE unset" 1>&2 - return -1 - fi - - case $OSTTYPE in - obdecho) OBD= - OBDARG= - NEED_FS=n - ;; - obdext2) OBDARG= - NEED_FS=y - ;; - obdfilter) OBDARG=$OSTFS - NEED_FS=y - ;; - *) echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2 - return -1 - ;; - esac - - if $OBDCTL name2dev OBDDEV > /dev/null 2>&1; then - echo "$0: OBDDEV is already configured" - return 0 - fi - - if [ "$NEED_FS" = "y" ]; then - [ "$1" ] && DO_FS=$1 - if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then - echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2 - return -1 - fi - - if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then - echo "usage: setup_ost {new_fs|old_fs}" 1>&2 - return -1 - fi - - $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE} - OBD=${LOOPDEV} - fi - - $OBDCTL <<- EOF || return $? - newdev - attach ${OSTTYPE} OBDDEV - setup ${OBD} ${OBDARG} - quit - EOF - $OBDCTL <<- EOF || return $? - newdev - attach ost OSTDEV - setup \$OBDDEV - quit - EOF -} - -setup_server() { - setup_mds $1 && setup_ost $1 -} - -setup_osc() { - [ "$SETUP_OSC" != "y" ] && return 0 - - if $OBDCTL name2dev OSCDEV > /dev/null 2>&1; then - echo "$0: OSCDEV is already configured" - return 0 - fi - - $OBDCTL <<- EOF || return $? - newdev - attach osc OSCDEV - setup -1 - quit - EOF -} - -setup_mount() { - [ "$SETUP_MOUNT" != "y" ] && return 0 - - [ "$OSCMT" ] || fail "error: $0: OSCMT unset" - - if mount | grep -q $OSCMT; then - echo "$0: $OSCMT is already mounted" - return 0 - fi - - [ ! -d $OSCMT ] && mkdir $OSCMT - echo "$0: mounting \$OSCDEV on $OSCMT" - mount -t lustre_lite -o device=`find_devno OSCDEV` none $OSCMT -} - -setup_client() { - setup_osc && setup_mount -} - -DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug" -DEBUG_OFF="echo 0 > /proc/sys/portals/debug" - -debug_server_off() { - [ "$MDS_RSH" ] && echo "Turn OFF debug on MDS" && $MDS_RSH "$DEBUG_OFF" - [ "$OST_RSH" ] && echo "Turn OFF debug on OST" && $OST_RSH "$DEBUG_OFF" -} - -debug_server_on() { - [ "$MDS_RSH" ] && echo "Turn ON debug on MDS" && $MDS_RSH "$DEBUG_ON" - [ "$OST_RSH" ] && echo "Turn ON debug on OST" && $OST_RSH "$DEBUG_ON" -} - -debug_client_off() { - echo "Turning OFF debug on client" && $OSC_RSH "$DEBUG_OFF" -} - -debug_client_on() { - echo "Turning ON debug on client" && $OSC_RSH "$DEBUG_ON" -} - -cleanup_portals() { - [ -z "$NETWORK" ] && NETWORK=tcp - $PTLCTL <<- EOF - setup $NETWORK - disconnect - del_uuid self - del_uuid mds - del_uuid ost - del_uuid ldlm - quit - EOF - - rmmod kqswnal - rmmod ksocknal - rmmod portals -} - -cleanup_lustre() { - killall acceptor - - losetup -d ${LOOP}0 - losetup -d ${LOOP}1 - losetup -d ${LOOP}2 - - rmmod llite - rmmod mdc - - rmmod mds_extN - rmmod mds_ext3 - rmmod mds_ext2 - rmmod mds - rmmod ost - rmmod osc - rmmod obdecho - rmmod obdfilter - rmmod obdext2 - rmmod extN - - rmmod ldlm - rmmod ptlrpc - rmmod obdclass -} - -cleanup_ldlm() { - [ "$SETUP" -a -z "$SETUP_LDLM" ] && return 0 - - LDLMDEVNO=`find_devno LDLMDEV` - if [ "$LDLMDEVNO" ]; then - $OBDCTL <<- EOF - device $LDLMDEVNO - cleanup - detach - quit - EOF - fi -} - -cleanup_mds() { - [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0 - - MDSDEVNO=`find_devno MDSDEV` - if [ "$MDSDEVNO" ]; then - $OBDCTL <<- EOF - device $MDSDEVNO - cleanup - detach - quit - EOF - fi -} - -cleanup_ost() { - [ "$SETUP" -a -z "$SETUP_OST" ] && return 0 - - OSTDEVNO=`find_devno OSTDEV` - if [ "$OSTDEVNO" ]; then - $OBDCTL <<- EOF - device $OSTDEVNO - cleanup - detach - quit - EOF - fi - - OBDDEVNO=`find_devno OBDDEV` - if [ "$OBDDEVNO" ]; then - $OBDCTL <<- EOF - device $OBDDEVNO - cleanup - detach - quit - EOF - fi -} - -cleanup_server() { - cleanup_ost && cleanup_mds -} - -cleanup_mount() { - [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0 - - [ "$OSCMT" ] || OSCMT=/mnt/lustre - if [ "`mount | grep $OSCMT`" ]; then - umount $OSCMT || fail "unable to unmount $OSCMT" - fi -} - -cleanup_osc() { - [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0 - - OSCDEVNO=`find_devno OSCDEV` - if [ "$OSCDEVNO" ]; then - $OBDCTL <<- EOF - device $OSCDEVNO - cleanup - detach - quit - EOF - fi -} - -cleanup_rpc() { - RPCDEVNO=`find_devno RPCDEV` - if [ "$RPCDEVNO" ]; then - $OBDCTL <<- EOF - device $RPCDEVNO - cleanup - detach - quit - EOF - fi -} - -cleanup_client() { - cleanup_mount && cleanup_osc && cleanup_rpc -} - -fail() { - echo "ERROR: $1" 1>&2 - [ $2 ] && RC=$2 || RC=1 - exit $RC -} diff --git a/lustre/tests/directio.c b/lustre/tests/directio.c deleted file mode 100644 index e495517..0000000 --- a/lustre/tests/directio.c +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -// not correctly in the headers yet!! -#ifndef O_DIRECT -#define O_DIRECT 040000 /* direct disk access hint */ -#endif - -#define BLOCKSIZE 4096 - -int main(int argc, char **argv) -{ - int fd; - char *buf; - int pages; - int rc; - - if (argc != 3) { - printf("Usage: %s file nr_pages\n", argv[0]); - return 1; - } - - pages = strtoul(argv[2], 0, 0); - printf("directio on %s for %d pages \n", argv[1], pages); - - buf = mmap(0, pages * BLOCKSIZE, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANON, 0, 0); - if (!buf) { - printf("No memory %s\n", strerror(errno)); - return 1; - } - - fd = open(argv[1], O_DIRECT | O_RDWR | O_CREAT); - if (fd == -1) { - printf("Cannot open %s: %s\n", argv[1], strerror(errno)); - return 1; - } - - rc = read(fd, buf, pages * BLOCKSIZE); - if (rc != pages * BLOCKSIZE) { - printf("Read error: %s, rc %d\n", strerror(errno), rc); - return 1; - } - - if ( lseek(fd, 0, SEEK_SET) != 0 ) { - printf("Cannot seek %s\n", strerror(errno)); - return 1; - } - - rc = write(fd, buf, pages * BLOCKSIZE); - if (rc != pages * BLOCKSIZE) { - printf("Write error %s\n", strerror(errno)); - return 1; - } - - return 0; -} diff --git a/lustre/tests/elan-client.cfg b/lustre/tests/elan-client.cfg deleted file mode 100644 index 120b605..0000000 --- a/lustre/tests/elan-client.cfg +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Config file for setting up a remote server with a real OST -NETWORK=elan -LOCALHOST=5 -SERVER=4 diff --git a/lustre/tests/elan-server.cfg b/lustre/tests/elan-server.cfg deleted file mode 100644 index 7520840..0000000 --- a/lustre/tests/elan-server.cfg +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Config file for setting up a remote server with a real OST -NETWORK=elan -LOCALHOST=4 -SERVER=4 diff --git a/lustre/tests/ext2_10000.gz b/lustre/tests/ext2_10000.gz deleted file mode 100644 index e700ad021894b9a311eb82fd2870eb3c9cdc906d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10228 zcmb2|=HR%vaG?zob4dxqn;U!eSOO*39vG*qmaT1ZTO6b;6zI8a!R3I6H@qEQIgLS& zm|_}q&DS|UXA|L?8?@PRQEu%d7Dy(_#d2gn%aeCUM^)t?tJ2CuQz1xW+TvI)B z&-`!Zt>1p$@U+NXZkcZxuN`~+^-_UlPCpg7BX?b~x|gx#-ASwSI%RpU?Uq;8<$f#r z_bq8}QRP3Ay*qvuE&Ig4@Zs~U|Ic?$nRxC0e_ur{P6h@Bp1Ie{yFPOEuLrU}wD-Jv zxrnB!AVDZsDko(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7 zfzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@Rz!Cxt x+rK@S01|h&@c;Tg14b-LMukR0U^E0qLtr!nMnhn@gus4=%TYIi864&?007gFqXqx~ diff --git a/lustre/tests/ext2_25000.gz b/lustre/tests/ext2_25000.gz deleted file mode 100644 index 122ed792d8accfd9ecbcf02cec89ffe4acc137c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25136 zcmeI(-%Ha`7{~FWfsRTdkba{uqZ>oUqLirgBB>TMu>!M5Z$vV35xY<_S`BPER*NwN zEtv(eEpXwOl9f&(Rw27c=+|&gyKvyj<=8L7zD@s$ki9<_=kQz{&Us$f&nY&_WV>c< zM{+kbwP}?N%7Y4pLPP>bPrt1x%nMo0)znY4ZrfgcV!*A}-*p?^eHDhfcBfom4o&^`v z)*XMY2OXaaQ(f_9$IP_P4Zrqu0NVj{#aVdl4H9JakGJ9BBT~{iz-H-keKmY**5I_I{ z1Q0*~0R#|0009ILKmY**5I_I{1Q0;re+sxF6L;3`H%nJb>`sCJ0tg_000IagfB*sr zAbs{bQetzbQvk+B(T_)RlZ-)0HfB*srAbh L_r^wH>&*EFvEw*O diff --git a/lustre/tests/ext3_10000.gz b/lustre/tests/ext3_10000.gz deleted file mode 100644 index b372fbdeaf91970c5b33eb16ade22e901894745b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12172 zcmeIzeNYo;8UXNAPQZakJIv`doMjwZJ;#e5r7Krxw2VC{dQl*fzy=bnD6-4PC@$1! zNExs3Ivk?s2W>2Z@|A?_rie>wAYkh$wTQJPyIbPL)N+dK3c|sP1d<%R|8C~~@y{FI z=bv|;d7pXTd4A73^F~*OhE`GM-dPZ|=fi`s;`Qt1L-6=6=DfV8;_CgH>WKVjq4_8N zc6xFCs+3hDFP~VGn0`7be^FD^!p6=-(TH3$QuI>OE?p>V=f(zoz3rD6?4DQys zMYb(C+)A-zlD37mkjSXF2$ylRM*mdj_s0e{X#%glHU31e+xaovCO4lEM$KOX;`s%x zs)gp0!FthKKJ|2n(9j(g(-HXE7!&R)sKjlbl^zv$xQ|G7FPuL(U{0Egm<-sGeFgrA z`TWRN;p=}jzwZ1`_GuvKmztWK*y+!cr_gcFk_G;*1n01C<^Ot0IxJzn`g!7+C$ndR zQHVCUzT9AvqU~N)p-SnTM*Cdm4x$jb>mtfi?=lfwGP!v)Gl9BIZXJa?sWE=Yn=+bq zm{yTxqq14LoF8!YEH(yl_1-LB*J5Hbdnewq*c!ur6K_6F>}G$ACyrYq*`<76eA_nj zDNccHsfAmp5iF@TD~}q)w$&-W&-C}ul+)~ zERL39CGK<^U5FiargS_j*Z~=Ix>oxXl^^d&7pik&GL!b%xJ2Yzu6Kf*v!k0B9BDb z*PJ!Tk0L^EeFgcu$dp8+Ax=?x1N8_>s>)ImZOCI$%ME-2nKRU{uzbR|(b<1wzF&CKURhYDWz7I|vb)zDK4+4L2-nnM|m(N;X7) z2$f4yBkA|}Glnl$m{QP7hOTZ{<~$8$NOK09mwD1aG+SRqZWv5^i7bRR;CroB=C@E@ ze?|%O4piK)@EB*%3iyj9=8w5^dzU>^AkO%Pe zRvIBSc$&uqp*Y;xt>m0`QiZFdoO&{?F#DXdnat8!H(15&EV-vJL&{NWiZA&}*IKJgJKFQA6>(^K+*`Mu= zYw$kyU-paTISM)h!*XN{jbU1MYL6+3Yqno0GAX$ZyJO6lz!CP&G1Fnr#&_DSW7ZJ% zD~<6rBANZ(tCh&BnMgiYlChnMVt@&UcK7dy zWquE#{qlB(L5~~SADXYA=MA=pt;Nnc@?CLe81*&Z4>vBsuOk!i#j}=TDxEwimi5sG z_))l9Zu~Xc1YePxGD4IC&+}t~S|9)ffB+Bx0zd!=00AHX1b_e#00KY&2mk>f00e*l z5C8%|00;m9AOHkj00BQP`NQkK^!f5sfQ$=&0XhaP0s$ZZ1b_e#00J+vz}&)}%Xj4n I-u+zgZ_NV*-2eap diff --git a/lustre/tests/fs.sh b/lustre/tests/fs.sh deleted file mode 100644 index b158c6e..0000000 --- a/lustre/tests/fs.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/bash -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution -#!/bin/sh - -R=/r - -insmod /lib/modules/2.4.17/kernel/drivers/block/loop.o -dd if=/dev/zero of=/tmp/fs bs=1024 count=10000 -mke2fs -b 4096 -F /tmp/fs -losetup /dev/loop/0 /tmp/fs - -insmod $R/usr/src/lustre/obdclass/obdclass.o -insmod $R/usr/src/lustre/obdext2/obdext2.o -mknod /dev/obd c 10 241 - -$R/usr/src/lustre/utils/obdctl < -#include -#if defined(_UWIN) || defined(__linux__) -# include -# include -# include -# include -#endif -#include -#include -#ifndef MAP_FILE -# define MAP_FILE 0 -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */ - -/* - * A log entry is an operation and a bunch of arguments. - */ - -struct log_entry { - int operation; - int args[3]; -}; - -#define LOGSIZE 1000 - -struct log_entry oplog[LOGSIZE]; /* the log */ -int logptr = 0; /* current position in log */ -int logcount = 0; /* total ops */ - -/* - * Define operations - */ - -#define OP_READ 1 -#define OP_WRITE 2 -#define OP_TRUNCATE 3 -#define OP_CLOSEOPEN 4 -#define OP_MAPREAD 5 -#define OP_MAPWRITE 6 -#define OP_SKIPPED 7 - -int page_size; -int page_mask; - -char *original_buf; /* a pointer to the original data */ -char *good_buf; /* a pointer to the correct data */ -char *temp_buf; /* a pointer to the current data */ -char *fname; /* name of our test file */ -int fd; /* fd for our test file */ - -off_t file_size = 0; -off_t biggest = 0; -char state[256]; -unsigned long testcalls = 0; /* calls to function "test" */ - -unsigned long simulatedopcount = 0; /* -b flag */ -int closeprob = 0; /* -c flag */ -int debug = 0; /* -d flag */ -unsigned long debugstart = 0; /* -D flag */ -unsigned long maxfilelen = 256 * 1024; /* -l flag */ -int sizechecks = 1; /* -n flag disables them */ -int maxoplen = 64 * 1024; /* -o flag */ -int quiet = 0; /* -q flag */ -unsigned long progressinterval = 0; /* -p flag */ -int readbdy = 1; /* -r flag */ -int style = 0; /* -s flag */ -int truncbdy = 1; /* -t flag */ -int writebdy = 1; /* -w flag */ -long monitorstart = -1; /* -m flag */ -long monitorend = -1; /* -m flag */ -int lite = 0; /* -L flag */ -long numops = -1; /* -N flag */ -int randomoplen = 1; /* -O flag disables it */ -int seed = 1; /* -S flag */ -int mapped_writes = 1; /* -W flag disables */ -int mapped_reads = 1; /* -R flag disables it */ -int fsxgoodfd = 0; -FILE * fsxlogf = NULL; -int badoff = -1; -int closeopen = 0; - - -void -vwarnc(code, fmt, ap) - int code; - const char *fmt; - va_list ap; -{ - fprintf(stderr, "fsx: "); - if (fmt != NULL) { - vfprintf(stderr, fmt, ap); - fprintf(stderr, ": "); - } - fprintf(stderr, "%s\n", strerror(code)); -} - - -void -warn(const char * fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnc(errno, fmt, ap); - va_end(ap); -} - - -void -prt(char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - vfprintf(stdout, fmt, args); - if (fsxlogf) - vfprintf(fsxlogf, fmt, args); - va_end(args); -} - -void -prterr(char *prefix) -{ - prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno)); -} - - -void -log4(int operation, int arg0, int arg1, int arg2) -{ - struct log_entry *le; - - le = &oplog[logptr]; - le->operation = operation; - if (closeopen) - le->operation = ~ le->operation; - le->args[0] = arg0; - le->args[1] = arg1; - le->args[2] = arg2; - logptr++; - logcount++; - if (logptr >= LOGSIZE) - logptr = 0; -} - - -void -logdump(void) -{ - int i, count, down; - struct log_entry *lp; - - prt("LOG DUMP (%d total operations):\n", logcount); - if (logcount < LOGSIZE) { - i = 0; - count = logcount; - } else { - i = logptr; - count = LOGSIZE; - } - for ( ; count > 0; count--) { - int opnum; - - opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE; - prt("%d(%d mod 256): ", opnum, opnum%256); - lp = &oplog[i]; - if ((closeopen = lp->operation < 0)) - lp->operation = ~ lp->operation; - - switch (lp->operation) { - case OP_MAPREAD: - prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (badoff >= lp->args[0] && badoff < - lp->args[0] + lp->args[1]) - prt("\t***RRRR***"); - break; - case OP_MAPWRITE: - prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (badoff >= lp->args[0] && badoff < - lp->args[0] + lp->args[1]) - prt("\t******WWWW"); - break; - case OP_READ: - prt("READ\t0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (badoff >= lp->args[0] && - badoff < lp->args[0] + lp->args[1]) - prt("\t***RRRR***"); - break; - case OP_WRITE: - prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (lp->args[0] > lp->args[2]) - prt(" HOLE"); - else if (lp->args[0] + lp->args[1] > lp->args[2]) - prt(" EXTEND"); - if ((badoff >= lp->args[0] || badoff >=lp->args[2]) && - badoff < lp->args[0] + lp->args[1]) - prt("\t***WWWW"); - break; - case OP_TRUNCATE: - down = lp->args[0] < lp->args[1]; - prt("TRUNCATE %s\tfrom 0x%x to 0x%x", - down ? "DOWN" : "UP", lp->args[1], lp->args[0]); - if (badoff >= lp->args[!down] && - badoff < lp->args[!!down]) - prt("\t******WWWW"); - break; - case OP_SKIPPED: - prt("SKIPPED (no operation)"); - break; - default: - prt("BOGUS LOG ENTRY (operation code = %d)!", - lp->operation); - } - if (closeopen) - prt("\n\t\tCLOSE/OPEN"); - prt("\n"); - i++; - if (i == LOGSIZE) - i = 0; - } -} - - -void -save_buffer(char *buffer, off_t bufferlength, int fd) -{ - off_t ret; - ssize_t byteswritten; - - if (fd <= 0 || bufferlength == 0) - return; - - if (bufferlength > SSIZE_MAX) { - prt("fsx flaw: overflow in save_buffer\n"); - exit(67); - } - if (lite) { - off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END); - if (size_by_seek == (off_t)-1) - prterr("save_buffer: lseek eof"); - else if (bufferlength > size_by_seek) { - warn("save_buffer: .fsxgood file too short... will -save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek, - (unsigned long long)bufferlength); - bufferlength = size_by_seek; - } - } - - ret = lseek(fd, (off_t)0, SEEK_SET); - if (ret == (off_t)-1) - prterr("save_buffer: lseek 0"); - - byteswritten = write(fd, buffer, (size_t)bufferlength); - if (byteswritten != bufferlength) { - if (byteswritten == -1) - prterr("save_buffer write"); - else - warn("save_buffer: short write, 0x%x bytes instead -of 0x%llx\n", - (unsigned)byteswritten, - (unsigned long long)bufferlength); - } -} - - -void -report_failure(int status) -{ - logdump(); - - if (fsxgoodfd) { - if (good_buf) { - save_buffer(good_buf, file_size, fsxgoodfd); - prt("Correct content saved for comparison\n"); - prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n", - fname, fname); - } - close(fsxgoodfd); - } - exit(status); -} - - -#define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \ - *(((unsigned char *)(cp)) + 1))) - -void -check_buffers(unsigned offset, unsigned size) -{ - unsigned char c, t; - unsigned i = 0; - unsigned n = 0; - unsigned op = 0; - unsigned bad = 0; - - if (memcmp(good_buf + offset, temp_buf, size) != 0) { - prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n", - offset, size); - prt("OFFSET\tGOOD\tBAD\tRANGE\n"); - while (size > 0) { - c = good_buf[offset]; - t = temp_buf[i]; - if (c != t) { - if (n == 0) { - bad = short_at(&temp_buf[i]); - prt("0x%5x\t0x%04x\t0x%04x", offset, - short_at(&good_buf[offset]), bad); - op = temp_buf[offset & 1 ? i+1 : i]; - } - n++; - badoff = offset; - } - offset++; - i++; - size--; - } - if (n) { - prt("\t0x%5x\n", n); - if (bad) - prt("operation# (mod 256) for the bad data -may be %u\n", ((unsigned)op & 0xff)); - else - prt("operation# (mod 256) for the bad data -unknown, check HOLE and EXTEND ops\n"); - } else - prt("????????????????\n"); - report_failure(110); - } -} - - -void -check_size(void) -{ - struct stat statbuf; - off_t size_by_seek; - - if (fstat(fd, &statbuf)) { - prterr("check_size: fstat"); - statbuf.st_size = -1; - } - size_by_seek = lseek(fd, (off_t)0, SEEK_END); - if (file_size != statbuf.st_size || file_size != size_by_seek) { - prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n", - (unsigned long long)file_size, - (unsigned long long)statbuf.st_size, - (unsigned long long)size_by_seek); - report_failure(120); - } -} - - -void -check_trunc_hack(void) -{ - struct stat statbuf; - - ftruncate(fd, (off_t)0); - ftruncate(fd, (off_t)100000); - fstat(fd, &statbuf); - if (statbuf.st_size != (off_t)100000) { - prt("no extend on truncate! not posix!\n"); - exit(130); - } - ftruncate(fd, 0); -} - - -void -doread(unsigned offset, unsigned size) -{ - off_t ret; - unsigned iret; - - offset -= offset % readbdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size read\n"); - log4(OP_SKIPPED, OP_READ, offset, size); - return; - } - if (size + offset > file_size) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping seek/read past end of file\n"); - log4(OP_SKIPPED, OP_READ, offset, size); - return; - } - - log4(OP_READ, offset, size, 0); - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - ret = lseek(fd, (off_t)offset, SEEK_SET); - if (ret == (off_t)-1) { - prterr("doread: lseek"); - report_failure(140); - } - iret = read(fd, temp_buf, size); - if (iret != size) { - if (iret == -1) - prterr("doread: read"); - else - prt("short read: 0x%x bytes instead of 0x%x\n", - iret, size); - report_failure(141); - } - check_buffers(offset, size); -} - - -void -domapread(unsigned offset, unsigned size) -{ - unsigned pg_offset; - unsigned map_size; - char *p; - - offset -= offset % readbdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size read\n"); - log4(OP_SKIPPED, OP_MAPREAD, offset, size); - return; - } - if (size + offset > file_size) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping seek/read past end of file\n"); - log4(OP_SKIPPED, OP_MAPREAD, offset, size); - return; - } - - log4(OP_MAPREAD, offset, size, 0); - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - - pg_offset = offset & page_mask; - map_size = pg_offset + size; - - if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | -MAP_SHARED, fd, - (off_t)(offset - pg_offset))) == (char *)-1) { - prterr("domapread: mmap"); - report_failure(190); - } - memcpy(temp_buf, p + pg_offset, size); - if (munmap(p, map_size) != 0) { - prterr("domapread: munmap"); - report_failure(191); - } - - check_buffers(offset, size); -} - - -void -gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size) -{ - while (size--) { - good_buf[offset] = testcalls % 256; - if (offset % 2) - good_buf[offset] += original_buf[offset]; - offset++; - } -} - - -void -dowrite(unsigned offset, unsigned size) -{ - off_t ret; - unsigned iret; - - offset -= offset % writebdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size write\n"); - log4(OP_SKIPPED, OP_WRITE, offset, size); - return; - } - - log4(OP_WRITE, offset, size, file_size); - - gendata(original_buf, good_buf, offset, size); - if (file_size < offset + size) { - if (file_size < offset) - memset(good_buf + file_size, '\0', offset - file_size); - file_size = offset + size; - if (lite) { - warn("Lite file size bug in fsx!"); - report_failure(149); - } - } - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - ret = lseek(fd, (off_t)offset, SEEK_SET); - if (ret == (off_t)-1) { - prterr("dowrite: lseek"); - report_failure(150); - } - iret = write(fd, good_buf + offset, size); - if (iret != size) { - if (iret == -1) - prterr("dowrite: write"); - else - prt("short write: 0x%x bytes instead of 0x%x\n", - iret, size); - report_failure(151); - } -} - - -void -domapwrite(unsigned offset, unsigned size) -{ - unsigned pg_offset; - unsigned map_size; - off_t cur_filesize; - char *p; - - offset -= offset % writebdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size write\n"); - log4(OP_SKIPPED, OP_MAPWRITE, offset, size); - return; - } - cur_filesize = file_size; - - log4(OP_MAPWRITE, offset, size, 0); - - gendata(original_buf, good_buf, offset, size); - if (file_size < offset + size) { - if (file_size < offset) - memset(good_buf + file_size, '\0', offset - file_size); - file_size = offset + size; - if (lite) { - warn("Lite file size bug in fsx!"); - report_failure(200); - } - } - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - - if (file_size > cur_filesize) { - if (ftruncate(fd, file_size) == -1) { - prterr("domapwrite: ftruncate"); - exit(201); - } - } - pg_offset = offset & page_mask; - map_size = pg_offset + size; - - if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_SHARED, fd, - (off_t)(offset - pg_offset))) == (char *)-1) { - prterr("domapwrite: mmap"); - report_failure(202); - } - memcpy(p + pg_offset, good_buf + offset, size); - if (msync(p, map_size, 0) != 0) { - prterr("domapwrite: msync"); - report_failure(203); - } - if (munmap(p, map_size) != 0) { - prterr("domapwrite: munmap"); - report_failure(204); - } -} - - -void -dotruncate(unsigned size) -{ - int oldsize = file_size; - - size -= size % truncbdy; - if (size > biggest) { - biggest = size; - if (!quiet && testcalls > simulatedopcount) - prt("truncating to largest ever: 0x%x\n", size); - } - - log4(OP_TRUNCATE, size, (unsigned)file_size, 0); - - if (size > file_size) - memset(good_buf + file_size, '\0', size - file_size); - file_size = size; - - if (testcalls <= simulatedopcount) - return; - - if ((progressinterval && testcalls % progressinterval == 0) || - (debug && (monitorstart == -1 || monitorend == -1 || - size <= monitorend))) - prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, -size); - if (ftruncate(fd, (off_t)size) == -1) { - prt("ftruncate1: %x\n", size); - prterr("dotruncate: ftruncate"); - report_failure(160); - } -} - - -void -writefileimage() -{ - ssize_t iret; - - if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) { - prterr("writefileimage: lseek"); - report_failure(171); - } - iret = write(fd, good_buf, file_size); - if ((off_t)iret != file_size) { - if (iret == -1) - prterr("writefileimage: write"); - else - prt("short write: 0x%x bytes instead of 0x%llx\n", - iret, (unsigned long long)file_size); - report_failure(172); - } - if (lite ? 0 : ftruncate(fd, file_size) == -1) { - prt("ftruncate2: %llx\n", (unsigned long long)file_size); - prterr("writefileimage: ftruncate"); - report_failure(173); - } -} - - -void -docloseopen(void) -{ - if (testcalls <= simulatedopcount) - return; - - if (debug) - prt("%lu close/open\n", testcalls); - if (close(fd)) { - prterr("docloseopen: close"); - report_failure(180); - } - fd = open(fname, O_RDWR, 0); - if (fd < 0) { - prterr("docloseopen: open"); - report_failure(181); - } -} - - -void -test(void) -{ - unsigned long offset; - unsigned long size = maxoplen; - unsigned long rv = random(); - unsigned long op = rv % (3 + !lite + mapped_writes); - - /* turn off the map read if necessary */ - - if (op == 2 && !mapped_reads) - op = 0; - - if (simulatedopcount > 0 && testcalls == simulatedopcount) - writefileimage(); - - testcalls++; - - if (closeprob) - closeopen = (rv >> 3) < (1 << 28) / closeprob; - - if (debugstart > 0 && testcalls >= debugstart) - debug = 1; - - if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0) - prt("%lu...\n", testcalls); - - /* - * READ: op = 0 - * WRITE: op = 1 - * MAPREAD: op = 2 - * TRUNCATE: op = 3 - * MAPWRITE: op = 3 or 4 - */ - if (lite ? 0 : op == 3 && (style & 1) == 0) /* vanilla truncate? */ - dotruncate(random() % maxfilelen); - else { - if (randomoplen) - size = random() % (maxoplen+1); - if (lite ? 0 : op == 3) - dotruncate(size); - else { - offset = random(); - if (op == 1 || op == (lite ? 3 : 4)) { - offset %= maxfilelen; - if (offset + size > maxfilelen) - size = maxfilelen - offset; - if (op != 1) - domapwrite(offset, size); - else - dowrite(offset, size); - } else { - if (file_size) - offset %= file_size; - else - offset = 0; - if (offset + size > file_size) - size = file_size - offset; - if (op != 0) - domapread(offset, size); - else - doread(offset, size); - } - } - } - if (sizechecks && testcalls > simulatedopcount) - check_size(); - if (closeopen) - docloseopen(); -} - - -void -cleanup(sig) - int sig; -{ - if (sig) - prt("signal %d\n", sig); - prt("testcalls = %lu\n", testcalls); - exit(sig); -} - - -void -usage(void) -{ - fprintf(stdout, "usage: %s", - "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m -start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t -truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] -fname\n\ - -b opnum: beginning operation number (default 1)\n\ - -c P: 1 in P chance of file close+open at each op (default infinity)\n\ - -d: debug output for all operations\n\ - -l flen: the upper bound on file size (default 262144)\n\ - -m startop:endop: monitor (print debug output) specified byte range -(default 0:infinity)\n\ - -n: no verifications of file size\n\ - -o oplen: the upper bound on operation size (default 65536)\n\ - -p progressinterval: debug output at specified operation interval\n\ - -q: quieter operation\n\ - -r readbdy: 4096 would make reads page aligned (default 1)\n\ - -s style: 1 gives smaller truncates (default 0)\n\ - -t truncbdy: 4096 would make truncates page aligned (default 1)\n\ - -w writebdy: 4096 would make writes page aligned (default 1)\n\ - -D startingop: debug output starting at specified operation\n\ - -L: fsxLite - no file creations & no file size changes\n\ - -N numops: total # operations to do (default infinity)\n\ - -O: use oplen (see -o flag) for every op (default random)\n\ - -P: save .fsxlog and .fsxgood files in dirpath (default ./)\n\ - -S seed: for random # generator (default 1) 0 gets timestamp\n\ - -W: mapped write operations DISabled\n\ - -R: read() system calls only (mapped reads disabled)\n\ - fname: this filename is REQUIRED (no default)\n"); - exit(90); -} - - -int -getnum(char *s, char **e) -{ - int ret = -1; - - *e = (char *) 0; - ret = strtol(s, e, 0); - if (*e) - switch (**e) { - case 'b': - case 'B': - ret *= 512; - *e = *e + 1; - break; - case 'k': - case 'K': - ret *= 1024; - *e = *e + 1; - break; - case 'm': - case 'M': - ret *= 1024*1024; - *e = *e + 1; - break; - case 'w': - case 'W': - ret *= 4; - *e = *e + 1; - break; - } - return (ret); -} - - -int -main(int argc, char **argv) -{ - int i, style, ch; - char *endp; - char goodfile[1024]; - char logfile[1024]; - - goodfile[0] = 0; - logfile[0] = 0; - - page_size = getpagesize(); - page_mask = page_size - 1; - - setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ - - while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:W")) - != EOF) - switch (ch) { - case 'b': - simulatedopcount = getnum(optarg, &endp); - if (!quiet) - fprintf(stdout, "Will begin at operation -%ld\n", - simulatedopcount); - if (simulatedopcount == 0) - usage(); - simulatedopcount -= 1; - break; - case 'c': - closeprob = getnum(optarg, &endp); - if (!quiet) - fprintf(stdout, - "Chance of close/open is 1 in %d\n", - closeprob); - if (closeprob <= 0) - usage(); - break; - case 'd': - debug = 1; - break; - case 'l': - maxfilelen = getnum(optarg, &endp); - if (maxfilelen <= 0) - usage(); - break; - case 'm': - monitorstart = getnum(optarg, &endp); - if (monitorstart < 0) - usage(); - if (!endp || *endp++ != ':') - usage(); - monitorend = getnum(endp, &endp); - if (monitorend < 0) - usage(); - if (monitorend == 0) - monitorend = -1; /* aka infinity */ - debug = 1; - case 'n': - sizechecks = 0; - break; - case 'o': - maxoplen = getnum(optarg, &endp); - if (maxoplen <= 0) - usage(); - break; - case 'p': - progressinterval = getnum(optarg, &endp); - if (progressinterval < 0) - usage(); - break; - case 'q': - quiet = 1; - break; - case 'r': - readbdy = getnum(optarg, &endp); - if (readbdy <= 0) - usage(); - break; - case 's': - style = getnum(optarg, &endp); - if (style < 0 || style > 1) - usage(); - break; - case 't': - truncbdy = getnum(optarg, &endp); - if (truncbdy <= 0) - usage(); - break; - case 'w': - writebdy = getnum(optarg, &endp); - if (writebdy <= 0) - usage(); - break; - case 'D': - debugstart = getnum(optarg, &endp); - if (debugstart < 1) - usage(); - break; - case 'L': - lite = 1; - break; - case 'N': - numops = getnum(optarg, &endp); - if (numops < 0) - usage(); - break; - case 'O': - randomoplen = 0; - break; - case 'P': - strncpy(goodfile, optarg, sizeof(goodfile)); - strcat(goodfile, "/"); - strncpy(logfile, optarg, sizeof(logfile)); - strcat(logfile, "/"); - break; - case 'R': - mapped_reads = 0; - break; - case 'S': - seed = getnum(optarg, &endp); - if (seed == 0) - seed = time(0) % 10000; - if (!quiet) - fprintf(stdout, "Seed set to %d\n", seed); - if (seed < 0) - usage(); - break; - case 'W': - mapped_writes = 0; - if (!quiet) - fprintf(stdout, "mapped writes DISABLED\n"); - break; - - default: - usage(); - /* NOTREACHED */ - } - argc -= optind; - argv += optind; - if (argc != 1) - usage(); - fname = argv[0]; - - signal(SIGHUP, cleanup); - signal(SIGINT, cleanup); - signal(SIGPIPE, cleanup); - signal(SIGALRM, cleanup); - signal(SIGTERM, cleanup); - signal(SIGXCPU, cleanup); - signal(SIGXFSZ, cleanup); - signal(SIGVTALRM, cleanup); - signal(SIGUSR1, cleanup); - signal(SIGUSR2, cleanup); - - initstate(seed, state, 256); - setstate(state); - fd = open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666); - if (fd < 0) { - prterr(fname); - exit(91); - } - strncat(goodfile, fname, 256); - strcat (goodfile, ".fsxgood"); - fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666); - if (fsxgoodfd < 0) { - prterr(goodfile); - exit(92); - } - strncat(logfile, fname, 256); - strcat (logfile, ".fsxlog"); - fsxlogf = fopen(logfile, "w"); - if (fsxlogf == NULL) { - prterr(logfile); - exit(93); - } - if (lite) { - off_t ret; - file_size = maxfilelen = lseek(fd, (off_t)0, SEEK_END); - if (file_size == (off_t)-1) { - prterr(fname); - warn("main: lseek eof"); - exit(94); - } - ret = lseek(fd, (off_t)0, SEEK_SET); - if (ret == (off_t)-1) { - prterr(fname); - warn("main: lseek 0"); - exit(95); - } - } - original_buf = (char *) malloc(maxfilelen); - for (i = 0; i < maxfilelen; i++) - original_buf[i] = random() % 256; - good_buf = (char *) malloc(maxfilelen); - memset(good_buf, '\0', maxfilelen); - temp_buf = (char *) malloc(maxoplen); - memset(temp_buf, '\0', maxoplen); - if (lite) { /* zero entire existing file */ - ssize_t written; - - written = write(fd, good_buf, (size_t)maxfilelen); - if (written != maxfilelen) { - if (written == -1) { - prterr(fname); - warn("main: error on write"); - } else - warn("main: short write, 0x%x bytes instead -of 0x%x\n", - (unsigned)written, maxfilelen); - exit(98); - } - } else - check_trunc_hack(); - - while (numops == -1 || numops--) - test(); - - if (close(fd)) { - prterr("close"); - report_failure(99); - } - prt("All operations completed A-OK!\n"); - - exit(0); - return 0; -} diff --git a/lustre/tests/ldaptest.c b/lustre/tests/ldaptest.c deleted file mode 100644 index c1a7499..0000000 --- a/lustre/tests/ldaptest.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - LDAP *ld; - int err; - - ld = ldap_init("localhost", 389); - if (!ld) { - fprintf(stderr, "ldap_init: %s\n", strerror(errno)); - exit(1); - } - - err = ldap_bind_s(ld, "cn=Manager,dc=lustre,dc=cfs", "secret", - LDAP_AUTH_SIMPLE); - if (err) { - fprintf(stderr, "ldap_bind: %s\n", ldap_err2string(err)); - exit(1); - } - - - - -} diff --git a/lustre/tests/ldlm.cfg b/lustre/tests/ldlm.cfg deleted file mode 100644 index 054f983..0000000 --- a/lustre/tests/ldlm.cfg +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Config file for setting up the lock manager -SETUP_LDLM=y diff --git a/lustre/tests/llcleanup.sh b/lustre/tests/llcleanup.sh deleted file mode 100755 index 5b1f80c..0000000 --- a/lustre/tests/llcleanup.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -SRCDIR="`dirname $0`/" -. $SRCDIR/common.sh - -setup_opts "$@" - -$DBGCTL debug_kernel /tmp/debug.1 -cleanup_client -$DBGCTL debug_kernel /tmp/debug.2 -cleanup_server - -$DBGCTL debug_kernel /tmp/debug.3 -cleanup_ldlm -$DBGCTL debug_kernel /tmp/debug.4 -cleanup_lustre -$DBGCTL debug_kernel /tmp/debug.5 -cleanup_portals diff --git a/lustre/tests/lldlm.sh b/lustre/tests/lldlm.sh deleted file mode 100755 index 6c575e1..0000000 --- a/lustre/tests/lldlm.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -SRCDIR="`dirname $0`/" -. $SRCDIR/common.sh - -export DEBUG_WAIT=yes -. $SRCDIR/llsetup.sh $SRCDIR/net-local.cfg $SRCDIR/ldlm.cfg || exit 2 - -$OBDCTL < /proc/sys/portals/debug - -$OBDCTL < -#include -#include -#include - -int main(int argc, char **argv) -{ - int fd; - - if (argc != 2) { - printf("Usage openme \n"); - exit(1); - } - - fd = open(argv[1], O_RDONLY | O_CREAT, 0600); - if (fd == -1) { - printf("Error opening %s\n", argv[1]); - exit(1); - } - - sleep(10000000); - return 0; -} diff --git a/lustre/tests/openunlink.c b/lustre/tests/openunlink.c deleted file mode 100644 index d0ae419..0000000 --- a/lustre/tests/openunlink.c +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#define T1 "write before unlink\n" -#define T2 "write after unlink\n" -char buf[128]; - -int main(int argc, char **argv) -{ - int fd, rc; - - if (argc != 2) { - fprintf(stderr, "usage: %s filename\n", argv[0]); - exit(1); - } else { - fprintf(stderr, "congratulations - program starting\n"); - } - - fprintf(stderr, "opening\n"); - fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0644); - if (fd == -1) { - fprintf(stderr, "open (before) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "writing\n"); - rc = write(fd, T1, strlen(T1) + 1); - if (rc != strlen(T1) + 1) { - fprintf(stderr, "write (before) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "closing\n"); - rc = close(fd); - if (rc ) { - fprintf(stderr, "close (before) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "opening again\n"); - fd = open(argv[1], O_RDWR ); - if (fd == -1) { - fprintf(stderr, "open (before) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "unlinking\n"); - rc = unlink(argv[1]); - if (rc ) { - fprintf(stderr, "open %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "reading\n"); - rc = read(fd, buf, strlen(T1) + 1); - if (rc != strlen(T1) + 1) { - fprintf(stderr, "read -after %s rc %d\n", strerror(errno), rc); - exit(1); - } - - fprintf(stderr, "comparing data\n"); - if (memcmp(buf, T1, strlen(T1) + 1) ) { - fprintf(stderr, "FAILURE: read wrong data after unlink\n"); - exit(1); - } - - fprintf(stderr, "truncating\n"); - rc = ftruncate(fd, 0); - if (rc ) { - fprintf(stderr, "truncate -after unl %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "seeking\n"); - rc = lseek(fd, 0, SEEK_SET); - if (rc != 0 ) { - fprintf(stderr, "seek (before write) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "writing again\n"); - rc = write(fd, T2, strlen(T2) + 1); - if (rc != strlen(T2) + 1) { - fprintf(stderr, "write (before) %s (rc %d)\n", strerror(errno), rc); - exit(1); - } - - fprintf(stderr, "seeking\n"); - rc = lseek(fd, 0, SEEK_SET); - if (rc != 0 ) { - fprintf(stderr, "seek (before read) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "reading again\n"); - rc = read(fd, buf, strlen(T2) + 1); - if (rc != strlen(T2) + 1) { - fprintf(stderr, "read (after trunc) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "comparing data again\n"); - if (memcmp(buf, T2, strlen(T2) + 1) ) { - fprintf(stderr, "FAILURE: read wrong data after trunc\n"); - exit(1); - } - - fprintf(stderr, "closing again\n"); - rc = close(fd); - if (rc ) { - fprintf(stderr, "close (before) %s\n", strerror(errno)); - exit(1); - } - - fprintf(stderr, "SUCCESS - goto beer\n"); - return 0; -} diff --git a/lustre/tests/ostreq.sh b/lustre/tests/ostreq.sh deleted file mode 100644 index 13e3fbc..0000000 --- a/lustre/tests/ostreq.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -SRCDIR="`dirname $0`/" -. $SRCDIR/common.sh - -SERVER=localhost -PORT=1234 - -$ACCEPTOR $PORT - -$PTLCTL < /proc/sys/portals/debug -cd /mnt/lustre -cp /usr/src/lustre/demos/dbench/client.txt . -/usr/src/lustre/demos/dbench/dbench $1 diff --git a/lustre/tests/runfailure-client-mds-recover.sh b/lustre/tests/runfailure-client-mds-recover.sh deleted file mode 100755 index cc36136..0000000 --- a/lustre/tests/runfailure-client-mds-recover.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -SRCDIR=. - -. common.sh - -reconnect () { - -$OBDCTL < /proc/sys/lustre/fail_loc -mknod /mnt/lustre/dev c 10 240 & -echo "MDS dropped create request -- sleep 4 secs - watch for timeout" -sleep 4 -reconnect -sleep 1 -echo "did things recover? check for file foo, bar, check log for reopen." -ls -l /mnt/lustre -echo "Test 5 done" - -exit - -echo -echo "Test 1 drop request:" `date` "creating /mnt/lustre/foo" -echo -rm -rf /mnt/lustre/* -echo 0x80000107 > /proc/sys/lustre/fail_loc -touch /mnt/lustre/foo & -ps axww | grep touch -echo "MDS dropped create request -- sleep 4 secs - watch for timeout" -sleep 4 -reconnect -sleep 1 -echo "did things recover? check for file foo." -ls -l /mnt/lustre - - -echo -echo "Test 2 test delay queue:" `date` "creating /mnt/lustre/foo" -echo -rm -rf /mnt/lustre/* -mkdir /mnt/lustre/a -echo 0x80000107 > /proc/sys/lustre/fail_loc -touch /mnt/lustre/foo & -ps axww | grep touch -echo "MDS dropped create request -- sleep 4 secs - watch for timeout" -sleep 4 -touch /mnt/lustre/a/f & -reconnect -sleep 1 -echo "did things recover? check for file foo and a/f" -ls -l /mnt/lustre -ls -l /mnt/lustre/a - -echo -echo "Test 4 dropped reply:" `date` "creating /mnt/lustre/foo2" -echo -rm -rf /mnt/lustre/* -echo 0x80000119 > /proc/sys/lustre/fail_loc -touch /mnt/lustre/foo2 & -ps axww | grep touch -echo "MDS dropped create request -- sleep 4 secs - watch for timeout" -sleep 4 -reconnect -echo failure cleared -sleep 1 -echo "did things recover? check for file foo2" -ls -l /mnt/lustre - - - -exit - -echo -echo "Test 3: Multiple failures" -echo -echo 0x0000107 > /proc/sys/lustre/fail_loc -touch /mnt/lustre/bar & -ps axww | grep touch -echo "touch program will have repeated failures sleeping 10" -sleep 10 -echo 0 > /proc/sys/lustre/fail_loc -reconnect -sleep 1 -echo "failure cleared" -echo "did things recover? Check for file bar" -ls -l /mnt/lustre/bar - - diff --git a/lustre/tests/runfailure-mds b/lustre/tests/runfailure-mds deleted file mode 100755 index 0f473ff..0000000 --- a/lustre/tests/runfailure-mds +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh - -SRCDIR="`dirname $0`" -. $SRCDIR/common.sh - -NETWORK=tcp -LOCALHOST=localhost -SERVER=localhost -PORT=1234 - -setup_portals -setup_lustre - -new_fs ext2 /tmp/ost 10000 -OST=$LOOPDEV -MDSFS=ext3 -new_fs ${MDSFS} /tmp/mds 10000 -MDS=$LOOPDEV - -echo 0xffffffff > /proc/sys/portals/debug - -$OBDCTL < /proc/sys/lustre/fail_loc - shift - echo "Running '$*'" - $* - - echo "Cleaning up and restarting MDS" - umount /mnt/lustre || fail "unable to unmount" - $OBDCTL <<- EOF - name2dev MDSDEV - cleanup - detach - quit - EOF - - echo 0 > /proc/sys/lustre/fail_loc - - $OBDCTL <<- EOF - newdev - attach mds MDSDEV - setup ${MDS} ${MDSFS} - quit - EOF - $MNT -} - -#set -vx - -touch /mnt/lustre/foo -chmod a+x /mnt/lustre/foo -sync - -# OBD_FAIL_MDS_REINT_SETATTR_WRITE - MDS will discard data from setattr -test_fail 0x10a chmod 000 /mnt/lustre/foo -ls -l /mnt/lustre/foo -[ ! -x /mnt/lustre/foo ] && fail "/mnt/lustre/foo is not executable!" - -# OBD_FAIL_MDS_REINT_CREATE_WRITE - MDS will not create the file -test_fail 0x10c touch /mnt/lustre/bar -ls /mnt/lustre/bar -[ $? -eq 0 ] && fail "/mnt/lustre/bar was created!" - -# OBD_FAIL_MDS_REINT_UNLINK_WRITE - MDS will discard data from unlink -test_fail 0x10e rm /mnt/lustre/foo -ls /mnt/lustre/foo -[ $? -eq 1 ] && fail "/mnt/lustre/foo has been removed!" - -# OBD_FAIL_MDS_REINT_RENAME_WRITE - MDS will discard data from rename -test_fail 0x112 mv /mnt/lustre/foo /mnt/lustre/bar -ls /mnt/lustre/foo /mnt/lustre/bar -[ ! -f /mnt/lustre/foo -o -f /mnt/lustre/bar ] && \ - fail "/mnt/lustre/foo has been renamed to bar!" - -echo "Done." diff --git a/lustre/tests/runfailure-net b/lustre/tests/runfailure-net deleted file mode 100755 index 078e1a4..0000000 --- a/lustre/tests/runfailure-net +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -set -vx - -SRCDIR="`dirname $0`" -. $SRCDIR/common.sh - -test_fail() { - echo $1 > /proc/sys/lustre/fail_loc - shift - $* & - sleep 1 - kill -9 $! - - echo 0 > /proc/sys/lustre/fail_loc - umount /mnt/lustre || fail "cannot unmount /mnt/lustre" - mount -t lustre_lite -o device=`$OBDCTL name2dev OSCDEV` none /mnt/lustre || fail "cannot remount device '`$OBDCTL name2dev OSCDEV`' on /mnt/lustre" -} - -[ -c /dev/request ] || mknod /dev/request c 10 244 - -[ "`mount | grep /mnt/lustre`" ] || echo | sh llmount.sh || exit -1 - -# GETATTR_NET - ls will hang on the getattr -test_fail 0x102 ls -l /mnt/lustre - -# READPAGE_NET - ls will hang reading in new pages (lost+found is not in cache) -test_fail 0x104 ls /mnt/lustre - -sleep 1 - -# REINT_NET - touch will hang on setattr -test_fail 0x107 touch /mnt/lustre - -# REINT_NET - touch will hang on create -test_fail 0x107 touch /mnt/lustre/tt - -# REINT_NET - mv will hang on rename -touch /mnt/lustre/foo -test_fail 0x107 mv /mnt/lustre/foo /mnt/lustre/bar - -# REINT_NET - rm will hang on unlink -touch /mnt/lustre/salmon -test_fail 0x107 rm /mnt/lustre/salmon - -# OPEN_NET - touch will hang on open -touch /mnt/lustre/foo -test_fail 0x113 cat /mnt/lustre/foo - -# CLOSE_NET - ls will hang on close -test_fail 0x115 ./testreq --close junk_file_handle - -echo 0 > /proc/sys/lustre/fail_loc - -echo "Done." diff --git a/lustre/tests/runiozone b/lustre/tests/runiozone deleted file mode 100755 index d437988..0000000 --- a/lustre/tests/runiozone +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -SIZE=5g -COUNT=0 -[ $1 ] && SIZE=$1 -rm -f endiozone -while date; do - echo "Test #$COUNT" - iozone -i 0 -i 1 -f /mnt/lustre/test.$$ -s $SIZE 2>&1 || exit $? - COUNT=`expr $COUNT + 1` - [ -f endiozone ] && rm endiozone && exit 0 -done | tee /tmp/iozone.log diff --git a/lustre/tests/runregression-net.sh b/lustre/tests/runregression-net.sh deleted file mode 100644 index b724548..0000000 --- a/lustre/tests/runregression-net.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -export PATH=/sbin:/usr/sbin:$PATH - -SRCDIR="`dirname $0`/" -. $SRCDIR/common.sh - -setup_opts $@ - -setup_portals -setup_lustre - -# TODO: obdctl needs to check on the progress of each forked thread -# (IPC SHM, sockets?) to see if it hangs. -for CMD in test_getattr test_brw_read test_brw_write; do - case $CMD in - test_brw_read) CMD=test_brw; RW=r ;; - test_brw_write) CMD=test_brw; RW=w ;; - *) RW= ;; - esac - - setup_server || exit -1 - setup_client || exit -1 - - OSC_DEVNO=`$OBDCTL name2dev OSCDEV` - - # We use '--threads 1 X' instead of '--device X' so that - # obdctl can modnitor the forked thread for progress (TODO). - $OBDCTL --threads 1 v $OSC_DEVNO $CMD 1 $RW v || exit -1 - $OBDCTL --threads 1 v $OSC_DEVNO $CMD 100 $RW v || exit -1 - - #cleanup_client || exit -1 - #cleanup_server || exit -1 - - #setup_server || exit -1 - #setup_client || exit -1 - - debug_server_off - debug_client_off - $OBDCTL --threads 1 v $OSC_DEVNO $CMD 10000 $RW 100 || exit -1 - $OBDCTL --threads 1 v $OSC_DEVNO $CMD 1000000 $RW -10 || exit -1 - - debug_server_on - debug_client_on - $OBDCTL --threads 2 v $OSC_DEVNO $CMD 100 $RW v || exit -1 - - debug_server_off - debug_client_off - $OBDCTL --threads 2 v $OSC_DEVNO $CMD 10000 $RW 100 || exit -1 - $OBDCTL --threads 2 v $OSC_DEVNO $CMD 1000000 $RW -30 || exit -1 - - $OBDCTL --threads 10 v $OSC_DEVNO $CMD 10000 $RW 1000 || exit -1 - $OBDCTL --threads 100 v $OSC_DEVNO $CMD 10000 $RW -30 || exit -1 - - cleanup_client || exit -1 - cleanup_server || exit -1 -done - -cleanup_lustre -cleanup_portals diff --git a/lustre/tests/runtests b/lustre/tests/runtests deleted file mode 100755 index 33ff25f..0000000 --- a/lustre/tests/runtests +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# -# Script which does some basic tests to ensure we haven't regressed. -# Probably a good idea to run this before doing any checkins. -# In the future this can become more fancy, but it's OK for now. - -SRCDIR="`dirname $0`" - -export PATH=/sbin:/usr/sbin:$SRCDIR:$PATH - -. $SRCDIR/common.sh - -ERROR= - -[ "`mount | grep /mnt/lustre`" ] || echo | sh llsetup.sh $@ || exit 1 - -# let's start slowly here... -touch /mnt/lustre || fail "can't touch /mnt/lustre" 2 -echo "copying /etc/hosts to /mnt/lustre/hosts" -cp /etc/hosts /mnt/lustre || fail "can't cp /etc/hosts" 3 -echo "comparing /etc/hosts and /mnt/lustre/hosts" -diff -u /etc/hosts /mnt/lustre/hosts || fail "/etc/hosts copy different" 4 - -# ok, that hopefully worked, so let's do a little more -FILES=`find /etc -type f` -echo "copying files from /etc to /mnt/lustre" -tar cf - $FILES | tar xf - -C /mnt/lustre || fail "copying /etc" 10 - -echo "comparing newly copied files" -for f in $FILES; do - diff -q $f /mnt/lustre/$f || ERROR=11 -done - -[ "$ERROR" ] && fail "old and new files are different" 11 - -sh llcleanup.sh $@ - -echo | sh llrsetup.sh $@ || exit 20 -echo "comparing previously copied files" -diff -u /etc/hosts /mnt/lustre/hosts || fail "/etc/hosts is now different" 21 - -for f in $FILES; do - diff -q $f /mnt/lustre/$f || ERROR=22 -done - -[ "$ERROR" ] && fail "old and new files are different on second diff" 23 - -sh llcleanup.sh $@ -echo | sh llrsetup.sh $@ || exit 24 - -echo "removing files from /mnt/lustre/etc" -rm /mnt/lustre/hosts || fail "can't remove /mnt/lustre/hosts" 25 - -rm -r /mnt/lustre/etc || fail "can't remove /mnt/lustre/etc" 26 - -sh llcleanup.sh $@ diff --git a/lustre/tests/runvmstat b/lustre/tests/runvmstat deleted file mode 100755 index 6bff5ce..0000000 --- a/lustre/tests/runvmstat +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -vmstat 1 | while read LINE ; do echo "`date +%H:%M:%S`: $LINE" ; done diff --git a/lustre/tests/snaprun.sh b/lustre/tests/snaprun.sh deleted file mode 100755 index ea77cfb..0000000 --- a/lustre/tests/snaprun.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Utility script to test several features of a snapshot filesystem -# Assumes that snapshot has already been configured -# -# Copyright (C) 2001 Cluster File Systems, Inc. -# -# This code is issued under the GNU General Public License. -# See the file COPYING in this distribution - -OBDDIR="`dirname $0`/.." -. $OBDDIR/demos/config.sh - -qrun ls $MNTOBD -qrun chown bin.bin $MNTOBD -qrun ls -ld $MNTOBD -qrun ls -ld $MNTSNAP -qrun cp /etc/hosts $MNTOBD -qrun ls $MNTOBD -qrun ls $MNTSNAP - -# More complicated because we can't pass ">>" as an argument easily -echo -n "Run 'echo today >> $MNTOBD/hello' [Y/n]" ; read JUNK -case $JUNK in - n*|N*) echo "not run" ;; - *) plog log "echo today >> $MNTOBD/hello" - echo "today" >> $MNTOBD/hello ;; -esac - -qrun cat $MNTOBD/hello -qrun cat $MNTSNAP/hello -qrun cat $MNTOBD/link -qrun cat $MNTSNAP/link -qrun rm $MNTOBD/goodbye -qrun ls $MNTOBD -qrun ls $MNTSNAP -qrun cat $MNTSNAP/goodbye diff --git a/lustre/tests/test.c b/lustre/tests/test.c deleted file mode 100755 index d4c6bf7..0000000 --- a/lustre/tests/test.c +++ /dev/null @@ -1,101 +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 -#include -#include -#include -#include -#include -#include -#include -#include - -#define LOOP_DEVICE "/dev/loop0" -#define OBD_DEVICE "/dev/obd" - -int main (int argc, char * argv[]) -{ - int fd, rc, err = -1; - struct stat stat_buf; - struct statfs stfs; - - - if (argc < 2) { - printf("syntax: %s command [argument]\n", argv[0]); - printf("Where command is one of \"setup\", \"create\", \"destroy\", or \"sync\".\n"); - exit(1); - } - if (stat(LOOP_DEVICE, &stat_buf)) { - printf("Couldn't stat(" LOOP_DEVICE ").\n"); - exit(1); - } - printf("Device: %u\n", (unsigned int) stat_buf.st_rdev); - - fd = open (OBD_DEVICE, O_RDONLY); - if (fd == -1) { - printf("Couldn't open " OBD_DEVICE ".\n"); - exit(1); - } - - if (!strcmp(argv[1], "setup")) { - rc = ioctl(fd, OBD_IOC_SETUP, &stat_buf.st_rdev); - fprintf(stderr, "rc = %d, errno = %d\n", rc, errno); - } else if (!strcmp(argv[1], "create")) { - int iter, i; - - if (argc < 3) { - printf("create requires a nonzero argument.\n"); - exit(1); - } - - iter = atoi(argv[2]); - if (iter < 1) { - printf("create requires a nonzero argument.\n"); - exit(1); - } - printf("creating %d objects...\n", iter); - - for (i = 0; i < iter; i++) { - if ((rc = ioctl(fd, OBD_IOC_CREATE, &err))) { - fprintf(stderr, "Error; aborting.\n"); - break; - } - if ((rc = ioctl(fd, OBD_IOC_DESTROY, &err))) { - fprintf(stderr, "Error; aborting.\n"); - break; - } - } - fprintf(stderr, "rc = %d, errno = %d, err = %d\n", - rc, errno, err); - } else if (!strcmp(argv[1], "sync")) { - rc = ioctl(fd, OBD_IOC_SYNC, &err); - fprintf(stderr, "rc = %d, errno = %d, err = %d\n", - rc, errno, err); - } else if (!strcmp(argv[1], "destroy")) { - int ino; - - if (argc < 3) { - printf("destroy requires a nonzero inode number.\n"); - exit(1); - } - - ino = atoi(argv[2]); - if (ino < 1) { - printf("destroy requires a nonzero inode number.\n"); - exit(1); - } - - rc = ioctl(fd, OBD_IOC_DESTROY, &ino); - fprintf(stderr, "rc = %d, errno = %d\n", rc, errno); - } else { - printf("Invalid command, run with no arguments for help.\n"); - } - close(fd); - - return 0; -} diff --git a/lustre/tests/test2.c b/lustre/tests/test2.c deleted file mode 100755 index fbbe6bb..0000000 --- a/lustre/tests/test2.c +++ /dev/null @@ -1,60 +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 -#include -#include -#include -#include -#include -#include - -/* Beware when setting FSROOT that I've not made any attempts to avoid buffer - * overruns below--this is a test program, it's a static buffer. */ -#define FSROOT "/mnt" -#define OBD_ITERATIONS 10000 - -int main (int argc, char * argv[]) -{ - int fd, rc, err = -1; - struct stat stat_buf; - - if (argc < 2) { - printf("syntax: %s command\n", argv[0]); - printf("Where command is one of \"setup\" or \"create\".\n"); - exit(1); - } - - if (!strcmp(argv[1], "setup")) { - printf("This is silly.\n"); - } else if (!strcmp(argv[1], "create")) { - int i, iter; - - if (argc < 3) { - printf("create requires a nonzero argument.\n"); - exit(1); - } - - iter = atoi(argv[2]); - - if (iter < 1) { - printf("create requires a nonzero argument.\n"); - exit(1); - } - printf("creating %d files...\n", iter); - - for (i = 0; i < iter; i++) { - fd = creat(FSROOT "/foo123", S_IRWXU); - close(fd); - unlink(FSROOT "/foo123"); - } - } else { - printf("Invalid command, run with no arguments for help.\n"); - } - - return 0; -} diff --git a/lustre/tests/testreq.c b/lustre/tests/testreq.c deleted file mode 100644 index bfcbb5e..0000000 --- a/lustre/tests/testreq.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 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 - -#define _GNU_SOURCE -#include -#undef _GNU_SOURCE - -#include - -static void usage(char *argv0, int status) -{ - printf( -"Usage: %s [OPTION...]\n\ -\n\ ---getattr \n\ ---setattr \n\ ---readpage \n\ ---open \n\ ---close \n\ ---create \n", argv0); - - exit(status); -} - -int main(int argc, char **argv) -{ - int fd, rc, c, cmd = 0; - unsigned long arg; - char *short_opts = "h", *name = argv[0]; - static struct option long_opts[] = { -#define OPT_GETATTR -2 - {"getattr", no_argument, NULL, OPT_GETATTR}, -#define OPT_READPAGE -3 - {"readpage", no_argument, NULL, OPT_READPAGE}, -#define OPT_SETATTR -4 - {"setattr", no_argument, NULL, OPT_SETATTR}, -#define OPT_CREATE -5 - {"create", no_argument, NULL, OPT_CREATE}, -#define OPT_OPEN -6 - {"open", no_argument, NULL, OPT_OPEN}, -#define OPT_CLOSE -7 - {"close", required_argument, NULL, OPT_CLOSE}, -#define OPT_HELP 'h' - {"help", no_argument, NULL, OPT_HELP}, - {0} - }; - - do { - c = getopt_long(argc, argv, short_opts, long_opts, NULL); - - switch (c) { - case OPT_HELP: - usage(argv[0], 0); - break; - case OPT_GETATTR: - cmd = IOC_REQUEST_GETATTR; - name = "getattr"; - arg = 2; - break; - case OPT_SETATTR: - cmd = IOC_REQUEST_SETATTR; - name = "setattr"; - arg = 2; - break; - case OPT_READPAGE: - cmd = IOC_REQUEST_READPAGE; - name = "readpage"; - arg = 2; - break; - case OPT_CREATE: - cmd = IOC_REQUEST_CREATE; - name ="create"; - arg = 2; - break; - case OPT_OPEN: - cmd = IOC_REQUEST_OPEN; - name = "open"; - arg = 2; - break; - case OPT_CLOSE: - cmd = IOC_REQUEST_CLOSE; - name = "close"; - arg = strtoul(optarg, NULL, 0); - break; - case '?': - usage(argv[0], 1); - } - } while (c != -1); - - if (cmd == 0) - usage(argv[0], 1); - - fd = open("/dev/request", O_RDONLY); - if (fd == -1) { - fprintf(stderr, "error opening /dev/request: %s\n", - strerror(errno)); - exit(1); - } - - fprintf(stderr, "Executing %s test (arg=%lu)...\n", name, arg); - if (cmd == IOC_REQUEST_OPEN) { - rc = ioctl(fd, cmd, &arg); - printf("%lu\n", arg); - } else - rc = ioctl(fd, cmd, arg); - fprintf(stderr, "result code: %d\n", rc); - - return 0; -} diff --git a/lustre/tests/truncate.c b/lustre/tests/truncate.c deleted file mode 100644 index 70fbbc7..0000000 --- a/lustre/tests/truncate.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - unsigned long long off; - int err; - - if (argc != 3) { - printf("usage %s file offset (kilobytes)\n", argv[0]); - return 1; - } - - off = strtoul(argv[2], NULL, 0); - off *= 1024; - err = truncate64(argv[1], off); - if ( err ) { - printf("Error truncating %s: %s\n", argv[1], strerror(errno)); - } - return err; -} diff --git a/lustre/tests/writeme.c b/lustre/tests/writeme.c deleted file mode 100644 index ab8692f..0000000 --- a/lustre/tests/writeme.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - int fd, rc; - int i = 0; - char buf[4096]; - - memset(buf, 0, 4096); - - if (argc != 2) { - printf("Usage openme \n"); - exit(1); - } - - fd = open(argv[1], O_RDWR | O_CREAT, 0600); - if (fd == -1) { - printf("Error opening %s\n", argv[1]); - exit(1); - } - - while (1) { - sprintf(buf, "write %d\n", i); - rc = write(fd, buf, sizeof(buf)); - sleep(1); - } - return 0; -} diff --git a/lustre/utils/.cvsignore b/lustre/utils/.cvsignore deleted file mode 100644 index 9aab7fa..0000000 --- a/lustre/utils/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.Xrefs -config.log -config.status -configure -Makefile -Makefile.in -.deps -tags -TAGS -obdctl diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am deleted file mode 100644 index 4b64b74..0000000 --- a/lustre/utils/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -DEFS:= - -EXTRA_DIST = parser.h -CFLAGS:=-g -I. -I/usr/include/glib-1.2 -I$(PORTALS)/include \ --I/usr/lib/glib/include -I$(srcdir)/../include -Wall -KFLAGS:= -CPPFLAGS := -LDADD := -lreadline -ltermcap # -lefence -bin_PROGRAMS = obdctl -obdctl_SOURCES = parser.c obdctl.c - -include $(top_srcdir)/Rules diff --git a/lustre/utils/ha_assist.sh b/lustre/utils/ha_assist.sh deleted file mode 100755 index 0f737f5..0000000 --- a/lustre/utils/ha_assist.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -echo primary `date` >> /tmp/halog - - diff --git a/lustre/utils/ha_assist2.sh b/lustre/utils/ha_assist2.sh deleted file mode 100755 index 4a67434..0000000 --- a/lustre/utils/ha_assist2.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -set -vx -date -echo "ha assist checking for problems" -sleep 3 -if [ ! -e /tmp/halog ]; then - echo "no problems, exiting" - exit -fi - -echo "removing /tmp/halog" -rm /tmp/halog - -echo secondary start `date` -echo "- please supply a new mds" - - -/usr/src/portals/linux/utils/ptlctl < - * 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 -#define printk printf - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define __KERNEL__ -#include -#undef __KERNEL__ - -#include "parser.h" -#include - -int fd = -1; -int connid = -1; -char rawbuf[8192]; -char *buf = rawbuf; -int max = 8192; -int thread; -int rc = 0; - -#define IOCINIT(data) \ -do { \ - memset(&data, 0, sizeof(data)); \ - data.ioc_version = OBD_IOCTL_VERSION; \ - data.ioc_conn1 = connid; \ - data.ioc_len = sizeof(data); \ - if (fd < 0) { \ - fprintf(stderr, "No device open, use device\n"); \ - return 1; \ - } \ -} while (0) - -/* - pack "LL LL LL LL LL LL LL L L L L L L L L L a60 a60 L L L", - $obdo->{id}, 0, - $obdo->{gr}, 0, - $obdo->{atime}, 0, - $obdo->{mtime}, 0 , - $obdo->{ctime}, 0, - $obdo->{size}, 0, - $obdo->{blocks}, 0, - $obdo->{blksize}, - $obdo->{mode}, - $obdo->{uid}, - $obdo->{gid}, - $obdo->{flags}, - $obdo->{obdflags}, - $obdo->{nlink}, - $obdo->{generation}, - $obdo->{valid}, - $obdo->{inline}, - $obdo->{obdmd}, - 0, 0, # struct list_head - 0; # struct obd_ops -} - -*/ - -char * obdo_print(struct obdo *obd) -{ - char buf[1024]; - - sprintf(buf, "id: %Ld\ngrp: %Ld\natime: %Ld\nmtime: %Ld\nctime: %Ld\n" - "size: %Ld\nblocks: %Ld\nblksize: %d\nmode: %o\nuid: %d\n" - "gid: %d\nflags: %x\nobdflags: %x\nnlink: %d,\nvalid %x\n", - obd->o_id, - obd->o_gr, - obd->o_atime, - obd->o_mtime, - obd->o_ctime, - obd->o_size, - obd->o_blocks, - obd->o_blksize, - obd->o_mode, - obd->o_uid, - obd->o_gid, - obd->o_flags, - obd->o_obdflags, - obd->o_nlink, - obd->o_valid); - return strdup(buf); -} - -static char *cmdname(char *func) -{ - static char buf[512]; - - if (thread) { - sprintf(buf, "%s-%d", func, thread); - return buf; - } - - return func; -} - -int getfd(char *func) -{ - if (fd == -1) - fd = open("/dev/obd", O_RDWR); - if (fd == -1) { - fprintf(stderr, "error: %s: opening /dev/obd: %s\n", - cmdname(func), strerror(errno)); - return -1; - } - return 0; -} - -/* -#define difftime(a, b) \ - ((double)(a)->tv_sec - (b)->tv_sec + \ - ((double)((a)->tv_usec - (b)->tv_usec) / 1000000)) -*/ - -#define difftime(a, b) (((a)->tv_sec - (b)->tv_sec) + \ - (((a)->tv_usec - (b)->tv_usec) / 1000000)) - -static int be_verbose(int verbose, struct timeval *next_time, - int num, int *next_num, int num_total) -{ - struct timeval now; - - if (!verbose) - return 0; - - if (next_time != NULL) - gettimeofday(&now, NULL); - - /* A positive verbosity means to print every X iterations */ - if (verbose > 0 && - (next_num == NULL || num >= *next_num || num >= num_total)) { - *next_num += verbose; - if (next_time) { - next_time->tv_sec = now.tv_sec - verbose; - next_time->tv_usec = now.tv_usec; - } - return 1; - } - - /* A negative verbosity means to print at most each X seconds */ - if (verbose < 0 && next_time != NULL && difftime(&now, next_time) >= 0){ - next_time->tv_sec = now.tv_sec - verbose; - next_time->tv_usec = now.tv_usec; - if (next_num) - *next_num = num; - return 1; - } - - return 0; -} - -static int get_verbose(const char *arg) -{ - int verbose; - - if (!arg || arg[0] == 'v') - verbose = 1; - else if (arg[0] == 's' || arg[0] == 'q') - verbose = 0; - else - verbose = (int) strtoul(arg, NULL, 0); - - if (verbose < 0) - printf("Print status every %d seconds\n", -verbose); - else if (verbose == 1) - printf("Print status every operation\n"); - else if (verbose > 1) - printf("Print status every %d operations\n", verbose); - - return verbose; -} - -static int do_disconnect(char *func, int verbose) -{ - struct obd_ioctl_data data; - - if (connid == -1) - return 0; - - IOCINIT(data); - - rc = ioctl(fd, OBD_IOC_DISCONNECT , &data); - if (rc < 0) { - fprintf(stderr, "error: %s: %x %s\n", cmdname(func), - OBD_IOC_DISCONNECT, strerror(errno)); - } else { - if (verbose) - printf("%s: disconnected connid %d\n", cmdname(func), - connid); - connid = -1; - } - - return rc; -} - -extern command_t cmdlist[]; - -static int do_device(char *func, int dev) -{ - struct obd_ioctl_data data; - - memset(&data, 0, sizeof(data)); - - data.ioc_dev = dev; - - if (getfd(func)) - return -1; - - if (obd_ioctl_pack(&data, &buf, max)) { - fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(func)); - return -2; - } - - return ioctl(fd, OBD_IOC_DEVICE , buf); -} - -static int jt_device(int argc, char **argv) -{ - do_disconnect(argv[0], 1); - - if (argc != 2) { - fprintf(stderr, "usage: %s devno\n", cmdname(argv[0])); - return -1; - } - - rc = do_device(argv[0], strtoul(argv[1], NULL, 0)); - - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc = errno)); - - return rc; -} - -static int jt_connect(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - - do_disconnect(argv[0], 1); - - if (argc != 1) { - fprintf(stderr, "usage: %s\n", cmdname(argv[0])); - return -1; - } - - rc = ioctl(fd, OBD_IOC_CONNECT , &data); - if (rc < 0) - fprintf(stderr, "error: %s: %x %s\n", cmdname(argv[0]), - OBD_IOC_CONNECT, strerror(rc = errno)); - else - connid = data.ioc_conn1; - - return rc; -} - -static int jt_disconnect(int argc, char **argv) -{ - if (argc != 1) { - fprintf(stderr, "usage: %s\n", cmdname(argv[0])); - return -1; - } - - return do_disconnect(argv[0], 0); -} - -static int jt__device(int argc, char **argv) -{ - char *arg2[3]; - int ret; - - if (argc < 3) { - fprintf(stderr, "usage: %s devno \n", - cmdname(argv[0])); - return -1; - } - - rc = do_device("device", strtoul(argv[1], NULL, 0)); - - if (!rc) { - arg2[0] = "connect"; - arg2[1] = NULL; - rc = jt_connect(1, arg2); - } - - if (!rc) - rc = Parser_execarg(argc - 2, argv + 2, cmdlist); - - ret = do_disconnect(argv[0], 0); - if (!rc) - rc = ret; - - return rc; -} - -static int jt__threads(int argc, char **argv) -{ - int threads, next_thread; - int verbose; - int i, j; - - if (argc < 5) { - fprintf(stderr, - "usage: %s numthreads verbose devno \n", - argv[0]); - return -1; - } - - threads = strtoul(argv[1], NULL, 0); - - verbose = get_verbose(argv[2]); - - printf("%s: starting %d threads on device %s running %s\n", - argv[0], threads, argv[3], argv[4]); - - for (i = 1, next_thread = verbose; i <= threads; i++) { - rc = fork(); - if (rc < 0) { - fprintf(stderr, "error: %s: #%d - %s\n", argv[0], i, - strerror(rc = errno)); - break; - } else if (rc == 0) { - thread = i; - argv[2] = "--device"; - return jt__device(argc - 2, argv + 2); - } else if (be_verbose(verbose, NULL, i, &next_thread, threads)) - printf("%s: thread #%d (PID %d) started\n", - argv[0], i, rc); - rc = 0; - } - - if (!thread) { /* parent process */ - if (!verbose) - printf("%s: started %d threads\n\n", argv[0], i - 1); - else - printf("\n"); - - for (j = 1; j < i; j++) { - int status; - int ret = wait(&status); - - if (ret < 0) { - fprintf(stderr, "error: %s: wait - %s\n", - argv[0], strerror(errno)); - if (!rc) - rc = errno; - } else { - /* - * This is a hack. We _should_ be able to use - * WIFEXITED(status) to see if there was an - * error, but it appears to be broken and it - * always returns 1 (OK). See wait(2). - */ - int err = WEXITSTATUS(status); - if (err) - fprintf(stderr, - "%s: PID %d had rc=%d\n", - argv[0], ret, err); - if (!rc) - rc = err; - } - } - } - - return rc; -} - -static int jt_detach(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - - if (argc != 1) { - fprintf(stderr, "usage: %s\n", cmdname(argv[0])); - return -1; - } - - if (obd_ioctl_pack(&data, &buf, max)) { - fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0])); - return -2; - } - - rc = ioctl(fd, OBD_IOC_DETACH , buf); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc=errno)); - - return rc; -} - -static int jt_cleanup(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - - if (argc != 1) { - fprintf(stderr, "usage: %s\n", cmdname(argv[0])); - return -1; - } - - rc = ioctl(fd, OBD_IOC_CLEANUP , &data); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc=errno)); - - return rc; -} - -static int jt_newdev(int argc, char **argv) -{ - struct obd_ioctl_data data; - - if (getfd(argv[0])) - return -1; - - IOCINIT(data); - - if (argc != 1) { - fprintf(stderr, "usage: %s\n", cmdname(argv[0])); - return -1; - } - - rc = ioctl(fd, OBD_IOC_NEWDEV , &data); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc=errno)); - else { - printf("Current device set to %d\n", data.ioc_dev); - } - - return rc; -} - -static int jt_attach(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - - if (argc != 2 && argc != 3) { - fprintf(stderr, "usage: %s type [name [uuid]]\n", - cmdname(argv[0])); - return -1; - } - - data.ioc_inllen1 = strlen(argv[1]) + 1; - data.ioc_inlbuf1 = argv[1]; - if (argc == 3) { - data.ioc_inllen2 = strlen(argv[2]) + 1; - data.ioc_inlbuf2 = argv[2]; - } - - if (obd_ioctl_pack(&data, &buf, max)) { - fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0])); - return -2; - } - - rc = ioctl(fd, OBD_IOC_ATTACH , buf); - if (rc < 0) - fprintf(stderr, "error: %s: %x %s\n", cmdname(argv[0]), - OBD_IOC_ATTACH, strerror(rc = errno)); - else if (argc == 3) { - char name[1024]; - if (strlen(argv[2]) > 128) { - printf("Name too long to set environment\n"); - return -EINVAL; - } - snprintf(name, 512, "LUSTRE_DEV_%s", argv[2]); - rc = setenv(name, argv[1], 1); - if (rc) { - printf("error setting env variable %s\n", name); - } - } - - return rc; -} - -#define N2D_OFF 0x100 /* So we can tell between error codes and devices */ - -static int do_name2dev(char *func, char *name) -{ - struct obd_ioctl_data data; - - if (getfd(func)) - return -1; - - IOCINIT(data); - - data.ioc_inllen1 = strlen(name) + 1; - data.ioc_inlbuf1 = name; - - if (obd_ioctl_pack(&data, &buf, max)) { - fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(func)); - return -2; - } - rc = ioctl(fd, OBD_IOC_NAME2DEV , buf); - if (rc < 0) { - fprintf(stderr, "error: %s: %s - %s\n", cmdname(func), - name, strerror(rc = errno)); - return rc; - } - - memcpy((char *)(&data), buf, sizeof(data)); - - return data.ioc_dev + N2D_OFF; -} - -static int jt_name2dev(int argc, char **argv) -{ - if (argc != 2) { - fprintf(stderr, "usage: %s name\n", cmdname(argv[0])); - return -1; - } - - rc = do_name2dev(argv[0], argv[1]); - if (rc >= N2D_OFF) { - int dev = rc - N2D_OFF; - rc = do_device(argv[0], dev); - if (rc == 0) - printf("%d\n", dev); - } - return rc; -} - -static int jt_setup(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - - if ( argc > 3) { - fprintf(stderr, "usage: %s [device] [fstype]\n", - cmdname(argv[0])); - return -1; - } - - data.ioc_dev = -1; - if (argc > 1) { - if (argv[1][0] == '$') { - rc = do_name2dev(argv[0], argv[1] + 1); - if (rc >= N2D_OFF) { - printf("%s is device %d\n", argv[1], - rc - N2D_OFF); - data.ioc_dev = rc - N2D_OFF; - } - } else - data.ioc_dev = strtoul(argv[1], NULL, 0); - data.ioc_inllen1 = strlen(argv[1]) + 1; - data.ioc_inlbuf1 = argv[1]; - } - if ( argc == 3 ) { - data.ioc_inllen2 = strlen(argv[2]) + 1; - data.ioc_inlbuf2 = argv[2]; - } - - if (obd_ioctl_pack(&data, &buf, max)) { - fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0])); - return -2; - } - rc = ioctl(fd, OBD_IOC_SETUP , buf); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc = errno)); - - return rc; -} - - -static int jt_create(int argc, char **argv) -{ - struct obd_ioctl_data data; - struct timeval next_time; - int count = 1, next_count; - int verbose; - int i; - - IOCINIT(data); - if (argc < 2 || argc > 4) { - fprintf(stderr, "usage: %s num [mode] [verbose]\n", - cmdname(argv[0])); - return -1; - } - count = strtoul(argv[1], NULL, 0); - - if (argc > 2) - data.ioc_obdo1.o_mode = strtoul(argv[2], NULL, 0); - else - data.ioc_obdo1.o_mode = 0100644; - data.ioc_obdo1.o_valid = OBD_MD_FLMODE; - - verbose = get_verbose(argv[3]); - - printf("%s: %d obdos\n", cmdname(argv[0]), count); - gettimeofday(&next_time, NULL); - next_time.tv_sec -= verbose; - - for (i = 1, next_count = verbose; i <= count ; i++) { - rc = ioctl(fd, OBD_IOC_CREATE , &data); - if (rc < 0) { - fprintf(stderr, "error: %s: #%d - %s\n", - cmdname(argv[0]), i, strerror(rc = errno)); - break; - } - if (be_verbose(verbose, &next_time, i, &next_count, count)) - printf("%s: #%d is object id %Ld\n", cmdname(argv[0]), - i, data.ioc_obdo1.o_id); - } - return rc; -} - -static int jt_setattr(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - if (argc != 2) { - fprintf(stderr, "usage: %s id mode\n", cmdname(argv[0])); - return -1; - } - - data.ioc_obdo1.o_id = strtoul(argv[1], NULL, 0); - data.ioc_obdo1.o_mode = S_IFREG | strtoul(argv[2], NULL, 0); - data.ioc_obdo1.o_valid = OBD_MD_FLMODE; - - rc = ioctl(fd, OBD_IOC_SETATTR , &data); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc = errno)); - - return rc; -} - -static int jt_destroy(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - if (argc != 2) { - fprintf(stderr, "usage: %s id\n", cmdname(argv[0])); - return -1; - } - - data.ioc_obdo1.o_id = strtoul(argv[1], NULL, 0); - data.ioc_obdo1.o_mode = S_IFREG|0644; - - rc = ioctl(fd, OBD_IOC_DESTROY , &data); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc = errno)); - - return rc; -} - -static int jt_getattr(int argc, char **argv) -{ - struct obd_ioctl_data data; - - if (argc != 2) { - fprintf(stderr, "usage: %s id\n", cmdname(argv[0])); - return -1; - } - - IOCINIT(data); - data.ioc_obdo1.o_id = strtoul(argv[1], NULL, 0); - /* to help obd filter */ - data.ioc_obdo1.o_mode = 0100644; - data.ioc_obdo1.o_valid = 0xffffffff; - printf("%s: object id %Ld\n", cmdname(argv[0]), data.ioc_obdo1.o_id); - - rc = ioctl(fd, OBD_IOC_GETATTR , &data); - if (rc) { - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc=errno)); - } else { - printf("%s: object id %Ld, mode %o\n", cmdname(argv[0]), - data.ioc_obdo1.o_id, data.ioc_obdo1.o_mode); - } - return rc; -} - -static int jt_test_getattr(int argc, char **argv) -{ - struct obd_ioctl_data data; - struct timeval start, next_time; - int i, count, next_count; - int verbose; - - if (argc != 2 && argc != 3) { - fprintf(stderr, "usage: %s count [verbose]\n",cmdname(argv[0])); - return -1; - } - - IOCINIT(data); - count = strtoul(argv[1], NULL, 0); - - if (argc == 3) - verbose = get_verbose(argv[2]); - else - verbose = 1; - - data.ioc_obdo1.o_valid = 0xffffffff; - data.ioc_obdo1.o_id = 2; - gettimeofday(&start, NULL); - next_time.tv_sec = start.tv_sec - verbose; - next_time.tv_usec = start.tv_usec; - printf("%s: getting %d attrs (testing only): %s", cmdname(argv[0]), - count, ctime(&start.tv_sec)); - - for (i = 1, next_count = verbose; i <= count; i++) { - rc = ioctl(fd, OBD_IOC_GETATTR , &data); - if (rc < 0) { - fprintf(stderr, "error: %s: #%d - %s\n", - cmdname(argv[0]), i, strerror(rc = errno)); - break; - } else { - if (be_verbose(verbose, &next_time, i,&next_count,count)) - printf("%s: got attr #%d\n", cmdname(argv[0]), i); - } - } - - if (!rc) { - struct timeval end; - double diff; - - gettimeofday(&end, NULL); - - diff = difftime(&end, &start); - - --i; - printf("%s: %d attrs in %.4gs (%.4g attr/s): %s", - cmdname(argv[0]), i, diff, (double)i / diff, - ctime(&end.tv_sec)); - } - return rc; -} - -static int jt_test_brw(int argc, char **argv) -{ - struct obd_ioctl_data data; - struct timeval start, next_time; - char *bulk, *b; - int pages = 1, obdos = 1, count, next_count; - int verbose = 1, write = 0, rw; - int i, o, p; - int len; - - if (argc < 2 || argc > 6) { - fprintf(stderr, - "usage: %s count [write [verbose [pages [obdos]]]]\n", - cmdname(argv[0])); - return -1; - } - - count = strtoul(argv[1], NULL, 0); - - if (argc >= 3) { - if (argv[2][0] == 'w' || argv[2][0] == '1') - write = 1; - else if (argv[2][0] == 'r' || argv[2][0] == '0') - write = 0; - - verbose = get_verbose(argv[3]); - } - - if (argc >= 5) - pages = strtoul(argv[4], NULL, 0); - if (argc >= 6) - obdos = strtoul(argv[5], NULL, 0); - - if (obdos != 1 && obdos != 2) { - fprintf(stderr, "error: %s: only 1 or 2 obdos supported\n", - cmdname(argv[0])); - return -2; - } - - len = pages * PAGE_SIZE; - - bulk = calloc(obdos, len); - if (!bulk) { - fprintf(stderr, "error: %s: no memory allocating %dx%d pages\n", - cmdname(argv[0]), obdos, pages); - return -2; - } - IOCINIT(data); - data.ioc_conn2 = connid; - data.ioc_obdo1.o_id = 2; - data.ioc_count = len; - data.ioc_offset = 0; - data.ioc_plen1 = len; - data.ioc_pbuf1 = bulk; - if (obdos > 1) { - data.ioc_obdo2.o_id = 3; - data.ioc_plen2 = len; - data.ioc_pbuf2 = bulk + len; - } - - gettimeofday(&start, NULL); - next_time.tv_sec = start.tv_sec - verbose; - next_time.tv_usec = start.tv_usec; - - printf("%s: %s %d (%dx%d pages) (testing only): %s", - cmdname(argv[0]), write ? "writing" : "reading", - count, obdos, pages, ctime(&start.tv_sec)); - - /* - * We will put in the start time (and loop count inside the loop) - * at the beginning of each page so that we will be able to validate - * (at some later time) whether the data actually made it or not. - * - * XXX we do not currently use any of this memory in OBD_IOC_BRW_* - * just to avoid the overhead of the copy_{to,from}_user. It - * can be fixed if we ever need to send real data around. - */ - for (o = 0, b = bulk; o < obdos; o++) - for (p = 0; p < pages; p++, b += PAGE_SIZE) - memcpy(b, &start, sizeof(start)); - - rw = write ? OBD_IOC_BRW_WRITE : OBD_IOC_BRW_READ; - for (i = 1, next_count = verbose; i <= count; i++) { - if (write) { - b = bulk + sizeof(struct timeval); - for (o = 0; o < obdos; o++) - for (p = 0; p < pages; p++, b += PAGE_SIZE) - memcpy(b, &count, sizeof(count)); - } - - rc = ioctl(fd, rw, &data); - if (rc) { - fprintf(stderr, "error: %s: #%d - %s on %s\n", - cmdname(argv[0]), i, strerror(rc = errno), - write ? "write" : "read"); - break; - } else if (be_verbose(verbose, &next_time, i,&next_count,count)) - printf("%s: %s number %d\n", cmdname(argv[0]), - write ? "write" : "read", i); - } - - free(bulk); - - if (!rc) { - struct timeval end; - double diff; - - gettimeofday(&end, NULL); - - diff = difftime(&end, &start); - - --i; - printf("%s: %s %dx%dx%d pages in %.4gs (%.4g pg/s): %s", - cmdname(argv[0]), write ? "wrote" : "read", obdos, - pages, i, diff, (double)obdos * i * pages / diff, - ctime(&end.tv_sec)); - } - return rc; -} - -static int jt_test_ldlm(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - if (argc != 1) { - fprintf(stderr, "usage: %s\n", cmdname(argv[0])); - return 1; - } - - rc = ioctl(fd, IOC_LDLM_TEST, &data); - if (rc) - fprintf(stderr, "error: %s: test failed: %s\n", - cmdname(argv[0]), strerror(rc = errno)); - return rc; -} - -static int jt_newconn(int argc, char **argv) -{ - struct obd_ioctl_data data; - - IOCINIT(data); - if (argc != 1) { - fprintf(stderr, "usage: %s\n", cmdname(argv[0])); - return -1; - } - - rc = ioctl(fd, OBD_IOC_RECOVD_NEWCONN , &data); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc = errno)); - - return rc; -} - -static int jt_quit(int argc, char **argv) -{ - Parser_quit(argc, argv); - - return rc; -} - -command_t cmdlist[] = { - /* Metacommands */ - {"--device", jt__device, 0, "--device "}, - {"--threads", jt__threads, 0, - "--threads "}, - - /* Device configuration commands */ - {"newdev", jt_newdev, 0, "set device to a new unused obd (no args)"}, - {"device", jt_device, 0, "set current device (args device_no name)"}, - {"name2dev", jt_name2dev, 0, "set device by name (args name)"}, - {"attach", jt_attach, 0, "name the type of device (args: type data"}, - {"setup", jt_setup, 0, "setup device (args: [data]"}, - {"detach", jt_detach, 0, "detach the current device (arg: )"}, - {"cleanup", jt_cleanup, 0, "cleanup the current device (arg: )"}, - - /* Session commands */ - {"connect", jt_connect, 0, "connect - get a connection to device"}, - {"disconnect", jt_disconnect, 0, - "disconnect - break connection to device"}, - - /* Session operations */ - {"create", jt_create, 0, "create [count [mode [verbose]]]"}, - {"destroy", jt_destroy, 0, "destroy "}, - {"getattr", jt_getattr, 0, "getattr "}, - {"setattr", jt_setattr, 0, "setattr "}, - {"newconn", jt_newconn, 0, "newconn [newuuid]"}, - {"test_getattr", jt_test_getattr, 0, "test_getattr [verbose]"}, - {"test_brw", jt_test_brw, 0, "test_brw [write [verbose]]"}, - {"test_ldlm", jt_test_ldlm, 0, "test lock manager (no args)"}, - - /* User interface commands */ - {"help", Parser_help, 0, "help"}, - {"exit", jt_quit, 0, "quit"}, - {"quit", jt_quit, 0, "quit"}, - { 0, 0, 0, NULL } -}; - - -static void signal_server(int sig) -{ - if (sig == SIGINT) { - do_disconnect("sigint", 1); - exit(1); - } else { - fprintf(stderr, "%s: got signal %d\n", cmdname("sigint"), sig); - } -} - -int main(int argc, char **argv) -{ - struct sigaction sigact; - - sigact.sa_handler = signal_server; - sigfillset(&sigact.sa_mask); - sigact.sa_flags = SA_RESTART; - sigaction(SIGINT, &sigact, NULL); - - - if (argc > 1) { - rc = Parser_execarg(argc - 1, argv + 1, cmdlist); - } else { - Parser_init("obdctl > ", cmdlist); - rc = Parser_commands(); - } - - do_disconnect(argv[0], 1); - return rc; -} - diff --git a/lustre/utils/parser.c b/lustre/utils/parser.c deleted file mode 100644 index fc22ba7f..0000000 --- a/lustre/utils/parser.c +++ /dev/null @@ -1,590 +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 - -#define READLINE_LIBRARY -#include - -//extern char **completion_matches __P((char *, rl_compentry_func_t *)); -extern void using_history(void); -extern void stifle_history(int); -extern void add_history(char *); - -#include "parser.h" -#define CMD_COMPLETE 0 -#define CMD_INCOMPLETE 1 -#define CMD_NONE 2 -#define CMD_AMBIG 3 - -static command_t * top_level; /* Top level of commands, initialized by - * InitParser */ -static command_t * match_tbl; /* Command completion against this table */ -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 char *command_generator(const char *text, int state); -static char **command_completion(char *text, int start, int end); -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 ) { - return (cmd->pc_func)(argc, argv); - } 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); - } - } -} - -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 the 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)); -} - -/* 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); - break; - } - - return rc; -} - -/* this is the command execution machine */ -int Parser_commands(void) -{ - char *line, *s; - int rc = 0; - - using_history(); - stifle_history(HISTORY); - - rl_attempted_completion_function = (CPPFunction *)command_completion; - rl_completion_entry_function = (void *)command_generator; - - while(!done) { - line = readline(parser_prompt); - - 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; -} - -/************************************************************************* - * 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/lustre/utils/parser.h b/lustre/utils/parser.h deleted file mode 100644 index 036a651..0000000 --- a/lustre/utils/parser.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _PARSER_H_ -#define _PARSER_H_ - -#define HISTORY 100 /* Don't let history grow unbounded */ -#define MAXARGS 100 - -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; - -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_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 -- 1.8.3.1