XEROX NSRANDOM 2 4 1 NSRANDOM 1 4 By: Bill van Melle (vanMelle@Xerox.com) INTRODUCTION The module NSRANDOM supplies a replacement implementation of NS FIling that supports random access to files (the Lyric implementation only supports sequential access). With it, you can treat files on an NS file server in the same way as you can on any other random access device. This implementation will be a part of the standard sysout in the next release. REQUIREMENTS & INSTALLATION Your NS file server must be running Services release 10.0 or later. Since this implementation replaces the existing NS Filing implementation, you will want to load the file with ldflg SYSLOAD, and load it from elsewhere than an NS server. Thus, if your LispUsers directory is on an NS server, you must first copy NSRANDOM.LCOM to your local disk or floppy and subsequently load it from there. Furthermore, you must ensure that you have no NS Filing state in your sysout at the time of loading, since the new implementation will incorrectly interpret it. Such state occurs if you have communicated with an NS file server at all since you last booted your machine (returned from LOGOUT, SYSOUT, MAKESYS or SAVEVM). One way of telling whether you have any state is to see if the association list variable \DEVICENAMETODEVICE contains the names of any NS file servers. If so, LOGOUT (so that they clean up), then continue. Once you have satisfied these requirements, then you can execute (IL:LOAD "NSRANDOM.LCOM" 'IL:SYSLOAD) to install the new implementation. EXCEPTIONAL CONDITIONS If you hold a random access stream open over logout, Lisp will reestablish connection to the server the next time you attempt to access the stream after your return from logout. If at this time Lisp determines that the file has been changed in some way since your last access, a debugger window opens to report the condition. The PROCEED command from the debugger gives you a choice of options; currently they are to discard the stream and abort the attempted operation, or proceed by attaching the stream to the now changed file. If the file had been open for output, you should consider carefully before choosing to proceed, lest you overwrite interesting data. For example, this can happen if you have an output stream open over a SAVEVM, continue to write to the stream, then crash and boot your machine back to the state as of the SAVEVM. If a file server crashes while you have a stream open to it, the operation is similar%on your next access to the stream, Lisp attempts to reestablish the connection and checks that the file has not changed in the meantime. As a particular case you may want to be aware of, there is a bug in Services 10.0 (fixed in release 10.3) that occasionally crashes the server when you are extending an old file. The typical sequence of events you will see is a message in the prompt window that the server is not responding, then a notice that the server is not running File Service (i.e., the server has been booted, but has not yet initiated File Service operation), then an entry to the debugger saying that the file has changed since the last access. This occurs because the server had actually written the data Lisp last requested it to write, but had not acknowledged the write before it crashed. In this case, it is safe to tell Lisp to proceed using the newly changed file (the OK command does this)%Lisp will rewrite (redundantly) the data that had not been previously acknowledged, then proceed normally. Sites still running the 10.0 Services release will surely want the server configured to automatically boot itself when it crashes, to minimize the disruption in service. VARIABLE AFFECTING NSRANDOM *NSFILING-SESSION-TIMEOUT* [Variable] To reduce the burden of idle connections to a file service, Lisp does not attempt to maintain an active connection to the server when Lisp has open streams that it is not actively using. If Lisp has made no calls to the server within the period specified by *NSFILING-SESSION-TIMEOUT*, Lisp allows the server to timeout the connection according to its own policy (for Xerox file servers running Services 10.0, that timeout is 10 minutes); otherwise, Lisp attempts to keep the connection alive, even though it is not doing anything interesting with it. In most cases, the timeout has little effect other than to reduce the load on the server (and also to minimize the resources Lisp devotes to keeping the stream open). The next time you access the file, Lisp simply reestablishes the connection, the same as it does after logout or after a server crash (of course, this first access after a long idle period may take a little longer than usual). However, the presence of the timeout means that your normal notion of exclusive access to a file can be violated if you aren't using the file. That is, after the connection times out, it is possible for other users to open for read a file you are writing, or write a file you are reading, or even delete the file (assuming the file's protection allows it, of course). In this case, on your next access to the file, an error will occur (a file busy error, file not found, or a notice that the file has changed). Note that if your workstation runs a non-blocking process for longer than the server's own timeout, or crashes (e.g., in an MP halt) for longer than the server's timeout, your connection is dropped anyway, independent of *NSFILING-SESSION-TIMEOUT*. *NSFILING-SESSION-TIMEOUT* is measured in seconds, and is either a single integer, or a dotted pair of integers; in the latter case, the car denotes the timeout when only input streams are open, the cdr the timeout when at least one output stream is open. A timeout of zero means make no attempt to keep connections alive longer than the server would by default; a timeout of NIL means "infinity". The initial value is (900 . 21600), i.e., 15 minutes and 6 hours, respectively, chosen in the belief that input files are almost never subjected to conflicting access, so are easily reopened, but that a writer of a file tends to expect that nobody will be able to read the file before the writing is finished. *NSFILING-RANDOM-ACCESS* [Variable] If this variable is set to NIL, the implementation reverts to its former practice of only opening files for sequential access. *NSFILING-RANDOM-ACCESS* is initially T. It is not expected that you will need to change it. OTHER USEFUL INFORMATION NSRandom performs directory enumeration more like other devices, in that * is allowed to match arbitrary segments of the "pathname", even though there is a true hierarchical directory structure underneath; i.e., * can match pieces of one or more subdirectory names. However, there is a bug in Services 10.0 server software that causes the value of FILING.ENUMERATION.DEPTH to be ignored%the enumeration is always to infinite depth (the default). The only time FILING.ENUMERATION.DEPTH has an effect is when the only * in the pattern is one that matches the entire root name%i.e., a pattern of the form <directory>subdir>*. This module also has an additional utility you may find useful: (GC-FILING-DIRECTORY DIRNAME CONFIRM?) [Function] This function expunges from the NS filing directory DIRNAME all the empty subdirectories. DIRNAME can specify subdirectories, if you want to clean up only a part of the directory, e.g., "{Frodo:}Lunch>". If CONFIRM? is true, you will be asked to confirm each deletion. Empty subdirectories arise when you create a subdirectory, e.g., by writing files in it or connecting to it, and subsequently delete all the files in it. They don't show up in ordinary directory listings (unless FILING.ENUMERATION.DEPTH is finite), but still take up directory space. (LIST ((PAGE NIL (PAPERSIZE LETTER STARTINGPAGE# 162) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE NIL . LETTER) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE NIL . LETTER) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL)))))(((1 (8( (8D PAGEHEADING RUNNINGHEADTERMINAL MODERN MODERN MODERN MODERNMODERN LOGO  HRULE.GETFNMODERN  HRULE.GETFNMODERN  HRULE.GETFNMODERN   HRULE.GETFNMODERN  HRULE.GETFNMODERN ( ODF@&#PU&)$U@ 8Zz