coda.rst 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===========================
  3. Coda Kernel-Venus Interface
  4. ===========================
  5. .. Note::
  6. This is one of the technical documents describing a component of
  7. Coda -- this document describes the client kernel-Venus interface.
  8. For more information:
  9. http://www.coda.cs.cmu.edu
  10. For user level software needed to run Coda:
  11. ftp://ftp.coda.cs.cmu.edu
  12. To run Coda you need to get a user level cache manager for the client,
  13. named Venus, as well as tools to manipulate ACLs, to log in, etc. The
  14. client needs to have the Coda filesystem selected in the kernel
  15. configuration.
  16. The server needs a user level server and at present does not depend on
  17. kernel support.
  18. The Venus kernel interface
  19. Peter J. Braam
  20. v1.0, Nov 9, 1997
  21. This document describes the communication between Venus and kernel
  22. level filesystem code needed for the operation of the Coda file sys-
  23. tem. This document version is meant to describe the current interface
  24. (version 1.0) as well as improvements we envisage.
  25. .. Table of Contents
  26. 1. Introduction
  27. 2. Servicing Coda filesystem calls
  28. 3. The message layer
  29. 3.1 Implementation details
  30. 4. The interface at the call level
  31. 4.1 Data structures shared by the kernel and Venus
  32. 4.2 The pioctl interface
  33. 4.3 root
  34. 4.4 lookup
  35. 4.5 getattr
  36. 4.6 setattr
  37. 4.7 access
  38. 4.8 create
  39. 4.9 mkdir
  40. 4.10 link
  41. 4.11 symlink
  42. 4.12 remove
  43. 4.13 rmdir
  44. 4.14 readlink
  45. 4.15 open
  46. 4.16 close
  47. 4.17 ioctl
  48. 4.18 rename
  49. 4.19 readdir
  50. 4.20 vget
  51. 4.21 fsync
  52. 4.22 inactive
  53. 4.23 rdwr
  54. 4.24 odymount
  55. 4.25 ody_lookup
  56. 4.26 ody_expand
  57. 4.27 prefetch
  58. 4.28 signal
  59. 5. The minicache and downcalls
  60. 5.1 INVALIDATE
  61. 5.2 FLUSH
  62. 5.3 PURGEUSER
  63. 5.4 ZAPFILE
  64. 5.5 ZAPDIR
  65. 5.6 ZAPVNODE
  66. 5.7 PURGEFID
  67. 5.8 REPLACE
  68. 6. Initialization and cleanup
  69. 6.1 Requirements
  70. 1. Introduction
  71. ===============
  72. A key component in the Coda Distributed File System is the cache
  73. manager, Venus.
  74. When processes on a Coda enabled system access files in the Coda
  75. filesystem, requests are directed at the filesystem layer in the
  76. operating system. The operating system will communicate with Venus to
  77. service the request for the process. Venus manages a persistent
  78. client cache and makes remote procedure calls to Coda file servers and
  79. related servers (such as authentication servers) to service these
  80. requests it receives from the operating system. When Venus has
  81. serviced a request it replies to the operating system with appropriate
  82. return codes, and other data related to the request. Optionally the
  83. kernel support for Coda may maintain a minicache of recently processed
  84. requests to limit the number of interactions with Venus. Venus
  85. possesses the facility to inform the kernel when elements from its
  86. minicache are no longer valid.
  87. This document describes precisely this communication between the
  88. kernel and Venus. The definitions of so called upcalls and downcalls
  89. will be given with the format of the data they handle. We shall also
  90. describe the semantic invariants resulting from the calls.
  91. Historically Coda was implemented in a BSD file system in Mach 2.6.
  92. The interface between the kernel and Venus is very similar to the BSD
  93. VFS interface. Similar functionality is provided, and the format of
  94. the parameters and returned data is very similar to the BSD VFS. This
  95. leads to an almost natural environment for implementing a kernel-level
  96. filesystem driver for Coda in a BSD system. However, other operating
  97. systems such as Linux and Windows 95 and NT have virtual filesystem
  98. with different interfaces.
  99. To implement Coda on these systems some reverse engineering of the
  100. Venus/Kernel protocol is necessary. Also it came to light that other
  101. systems could profit significantly from certain small optimizations
  102. and modifications to the protocol. To facilitate this work as well as
  103. to make future ports easier, communication between Venus and the
  104. kernel should be documented in great detail. This is the aim of this
  105. document.
  106. 2. Servicing Coda filesystem calls
  107. ===================================
  108. The service of a request for a Coda file system service originates in
  109. a process P which accessing a Coda file. It makes a system call which
  110. traps to the OS kernel. Examples of such calls trapping to the kernel
  111. are ``read``, ``write``, ``open``, ``close``, ``create``, ``mkdir``,
  112. ``rmdir``, ``chmod`` in a Unix ontext. Similar calls exist in the Win32
  113. environment, and are named ``CreateFile``.
  114. Generally the operating system handles the request in a virtual
  115. filesystem (VFS) layer, which is named I/O Manager in NT and IFS
  116. manager in Windows 95. The VFS is responsible for partial processing
  117. of the request and for locating the specific filesystem(s) which will
  118. service parts of the request. Usually the information in the path
  119. assists in locating the correct FS drivers. Sometimes after extensive
  120. pre-processing, the VFS starts invoking exported routines in the FS
  121. driver. This is the point where the FS specific processing of the
  122. request starts, and here the Coda specific kernel code comes into
  123. play.
  124. The FS layer for Coda must expose and implement several interfaces.
  125. First and foremost the VFS must be able to make all necessary calls to
  126. the Coda FS layer, so the Coda FS driver must expose the VFS interface
  127. as applicable in the operating system. These differ very significantly
  128. among operating systems, but share features such as facilities to
  129. read/write and create and remove objects. The Coda FS layer services
  130. such VFS requests by invoking one or more well defined services
  131. offered by the cache manager Venus. When the replies from Venus have
  132. come back to the FS driver, servicing of the VFS call continues and
  133. finishes with a reply to the kernel's VFS. Finally the VFS layer
  134. returns to the process.
  135. As a result of this design a basic interface exposed by the FS driver
  136. must allow Venus to manage message traffic. In particular Venus must
  137. be able to retrieve and place messages and to be notified of the
  138. arrival of a new message. The notification must be through a mechanism
  139. which does not block Venus since Venus must attend to other tasks even
  140. when no messages are waiting or being processed.
  141. **Interfaces of the Coda FS Driver**
  142. Furthermore the FS layer provides for a special path of communication
  143. between a user process and Venus, called the pioctl interface. The
  144. pioctl interface is used for Coda specific services, such as
  145. requesting detailed information about the persistent cache managed by
  146. Venus. Here the involvement of the kernel is minimal. It identifies
  147. the calling process and passes the information on to Venus. When
  148. Venus replies the response is passed back to the caller in unmodified
  149. form.
  150. Finally Venus allows the kernel FS driver to cache the results from
  151. certain services. This is done to avoid excessive context switches
  152. and results in an efficient system. However, Venus may acquire
  153. information, for example from the network which implies that cached
  154. information must be flushed or replaced. Venus then makes a downcall
  155. to the Coda FS layer to request flushes or updates in the cache. The
  156. kernel FS driver handles such requests synchronously.
  157. Among these interfaces the VFS interface and the facility to place,
  158. receive and be notified of messages are platform specific. We will
  159. not go into the calls exported to the VFS layer but we will state the
  160. requirements of the message exchange mechanism.
  161. 3. The message layer
  162. =====================
  163. At the lowest level the communication between Venus and the FS driver
  164. proceeds through messages. The synchronization between processes
  165. requesting Coda file service and Venus relies on blocking and waking
  166. up processes. The Coda FS driver processes VFS- and pioctl-requests
  167. on behalf of a process P, creates messages for Venus, awaits replies
  168. and finally returns to the caller. The implementation of the exchange
  169. of messages is platform specific, but the semantics have (so far)
  170. appeared to be generally applicable. Data buffers are created by the
  171. FS Driver in kernel memory on behalf of P and copied to user memory in
  172. Venus.
  173. The FS Driver while servicing P makes upcalls to Venus. Such an
  174. upcall is dispatched to Venus by creating a message structure. The
  175. structure contains the identification of P, the message sequence
  176. number, the size of the request and a pointer to the data in kernel
  177. memory for the request. Since the data buffer is re-used to hold the
  178. reply from Venus, there is a field for the size of the reply. A flags
  179. field is used in the message to precisely record the status of the
  180. message. Additional platform dependent structures involve pointers to
  181. determine the position of the message on queues and pointers to
  182. synchronization objects. In the upcall routine the message structure
  183. is filled in, flags are set to 0, and it is placed on the *pending*
  184. queue. The routine calling upcall is responsible for allocating the
  185. data buffer; its structure will be described in the next section.
  186. A facility must exist to notify Venus that the message has been
  187. created, and implemented using available synchronization objects in
  188. the OS. This notification is done in the upcall context of the process
  189. P. When the message is on the pending queue, process P cannot proceed
  190. in upcall. The (kernel mode) processing of P in the filesystem
  191. request routine must be suspended until Venus has replied. Therefore
  192. the calling thread in P is blocked in upcall. A pointer in the
  193. message structure will locate the synchronization object on which P is
  194. sleeping.
  195. Venus detects the notification that a message has arrived, and the FS
  196. driver allow Venus to retrieve the message with a getmsg_from_kernel
  197. call. This action finishes in the kernel by putting the message on the
  198. queue of processing messages and setting flags to READ. Venus is
  199. passed the contents of the data buffer. The getmsg_from_kernel call
  200. now returns and Venus processes the request.
  201. At some later point the FS driver receives a message from Venus,
  202. namely when Venus calls sendmsg_to_kernel. At this moment the Coda FS
  203. driver looks at the contents of the message and decides if:
  204. * the message is a reply for a suspended thread P. If so it removes
  205. the message from the processing queue and marks the message as
  206. WRITTEN. Finally, the FS driver unblocks P (still in the kernel
  207. mode context of Venus) and the sendmsg_to_kernel call returns to
  208. Venus. The process P will be scheduled at some point and continues
  209. processing its upcall with the data buffer replaced with the reply
  210. from Venus.
  211. * The message is a ``downcall``. A downcall is a request from Venus to
  212. the FS Driver. The FS driver processes the request immediately
  213. (usually a cache eviction or replacement) and when it finishes
  214. sendmsg_to_kernel returns.
  215. Now P awakes and continues processing upcall. There are some
  216. subtleties to take account of. First P will determine if it was woken
  217. up in upcall by a signal from some other source (for example an
  218. attempt to terminate P) or as is normally the case by Venus in its
  219. sendmsg_to_kernel call. In the normal case, the upcall routine will
  220. deallocate the message structure and return. The FS routine can proceed
  221. with its processing.
  222. **Sleeping and IPC arrangements**
  223. In case P is woken up by a signal and not by Venus, it will first look
  224. at the flags field. If the message is not yet READ, the process P can
  225. handle its signal without notifying Venus. If Venus has READ, and
  226. the request should not be processed, P can send Venus a signal message
  227. to indicate that it should disregard the previous message. Such
  228. signals are put in the queue at the head, and read first by Venus. If
  229. the message is already marked as WRITTEN it is too late to stop the
  230. processing. The VFS routine will now continue. (-- If a VFS request
  231. involves more than one upcall, this can lead to complicated state, an
  232. extra field "handle_signals" could be added in the message structure
  233. to indicate points of no return have been passed.--)
  234. 3.1. Implementation details
  235. ----------------------------
  236. The Unix implementation of this mechanism has been through the
  237. implementation of a character device associated with Coda. Venus
  238. retrieves messages by doing a read on the device, replies are sent
  239. with a write and notification is through the select system call on the
  240. file descriptor for the device. The process P is kept waiting on an
  241. interruptible wait queue object.
  242. In Windows NT and the DPMI Windows 95 implementation a DeviceIoControl
  243. call is used. The DeviceIoControl call is designed to copy buffers
  244. from user memory to kernel memory with OPCODES. The sendmsg_to_kernel
  245. is issued as a synchronous call, while the getmsg_from_kernel call is
  246. asynchronous. Windows EventObjects are used for notification of
  247. message arrival. The process P is kept waiting on a KernelEvent
  248. object in NT and a semaphore in Windows 95.
  249. 4. The interface at the call level
  250. ===================================
  251. This section describes the upcalls a Coda FS driver can make to Venus.
  252. Each of these upcalls make use of two structures: inputArgs and
  253. outputArgs. In pseudo BNF form the structures take the following
  254. form::
  255. struct inputArgs {
  256. u_long opcode;
  257. u_long unique; /* Keep multiple outstanding msgs distinct */
  258. u_short pid; /* Common to all */
  259. u_short pgid; /* Common to all */
  260. struct CodaCred cred; /* Common to all */
  261. <union "in" of call dependent parts of inputArgs>
  262. };
  263. struct outputArgs {
  264. u_long opcode;
  265. u_long unique; /* Keep multiple outstanding msgs distinct */
  266. u_long result;
  267. <union "out" of call dependent parts of inputArgs>
  268. };
  269. Before going on let us elucidate the role of the various fields. The
  270. inputArgs start with the opcode which defines the type of service
  271. requested from Venus. There are approximately 30 upcalls at present
  272. which we will discuss. The unique field labels the inputArg with a
  273. unique number which will identify the message uniquely. A process and
  274. process group id are passed. Finally the credentials of the caller
  275. are included.
  276. Before delving into the specific calls we need to discuss a variety of
  277. data structures shared by the kernel and Venus.
  278. 4.1. Data structures shared by the kernel and Venus
  279. ----------------------------------------------------
  280. The CodaCred structure defines a variety of user and group ids as
  281. they are set for the calling process. The vuid_t and vgid_t are 32 bit
  282. unsigned integers. It also defines group membership in an array. On
  283. Unix the CodaCred has proven sufficient to implement good security
  284. semantics for Coda but the structure may have to undergo modification
  285. for the Windows environment when these mature::
  286. struct CodaCred {
  287. vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, effective, set, fs uid */
  288. vgid_t cr_gid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
  289. vgid_t cr_groups[NGROUPS]; /* Group membership for caller */
  290. };
  291. .. Note::
  292. It is questionable if we need CodaCreds in Venus. Finally Venus
  293. doesn't know about groups, although it does create files with the
  294. default uid/gid. Perhaps the list of group membership is superfluous.
  295. The next item is the fundamental identifier used to identify Coda
  296. files, the ViceFid. A fid of a file uniquely defines a file or
  297. directory in the Coda filesystem within a cell [1]_::
  298. typedef struct ViceFid {
  299. VolumeId Volume;
  300. VnodeId Vnode;
  301. Unique_t Unique;
  302. } ViceFid;
  303. .. [1] A cell is agroup of Coda servers acting under the aegis of a single
  304. system control machine or SCM. See the Coda Administration manual
  305. for a detailed description of the role of the SCM.
  306. Each of the constituent fields: VolumeId, VnodeId and Unique_t are
  307. unsigned 32 bit integers. We envisage that a further field will need
  308. to be prefixed to identify the Coda cell; this will probably take the
  309. form of a Ipv6 size IP address naming the Coda cell through DNS.
  310. The next important structure shared between Venus and the kernel is
  311. the attributes of the file. The following structure is used to
  312. exchange information. It has room for future extensions such as
  313. support for device files (currently not present in Coda)::
  314. struct coda_timespec {
  315. int64_t tv_sec; /* seconds */
  316. long tv_nsec; /* nanoseconds */
  317. };
  318. struct coda_vattr {
  319. enum coda_vtype va_type; /* vnode type (for create) */
  320. u_short va_mode; /* files access mode and type */
  321. short va_nlink; /* number of references to file */
  322. vuid_t va_uid; /* owner user id */
  323. vgid_t va_gid; /* owner group id */
  324. long va_fsid; /* file system id (dev for now) */
  325. long va_fileid; /* file id */
  326. u_quad_t va_size; /* file size in bytes */
  327. long va_blocksize; /* blocksize preferred for i/o */
  328. struct coda_timespec va_atime; /* time of last access */
  329. struct coda_timespec va_mtime; /* time of last modification */
  330. struct coda_timespec va_ctime; /* time file changed */
  331. u_long va_gen; /* generation number of file */
  332. u_long va_flags; /* flags defined for file */
  333. dev_t va_rdev; /* device special file represents */
  334. u_quad_t va_bytes; /* bytes of disk space held by file */
  335. u_quad_t va_filerev; /* file modification number */
  336. u_int va_vaflags; /* operations flags, see below */
  337. long va_spare; /* remain quad aligned */
  338. };
  339. 4.2. The pioctl interface
  340. --------------------------
  341. Coda specific requests can be made by application through the pioctl
  342. interface. The pioctl is implemented as an ordinary ioctl on a
  343. fictitious file /coda/.CONTROL. The pioctl call opens this file, gets
  344. a file handle and makes the ioctl call. Finally it closes the file.
  345. The kernel involvement in this is limited to providing the facility to
  346. open and close and pass the ioctl message and to verify that a path in
  347. the pioctl data buffers is a file in a Coda filesystem.
  348. The kernel is handed a data packet of the form::
  349. struct {
  350. const char *path;
  351. struct ViceIoctl vidata;
  352. int follow;
  353. } data;
  354. where::
  355. struct ViceIoctl {
  356. caddr_t in, out; /* Data to be transferred in, or out */
  357. short in_size; /* Size of input buffer <= 2K */
  358. short out_size; /* Maximum size of output buffer, <= 2K */
  359. };
  360. The path must be a Coda file, otherwise the ioctl upcall will not be
  361. made.
  362. .. Note:: The data structures and code are a mess. We need to clean this up.
  363. **We now proceed to document the individual calls**:
  364. 4.3. root
  365. ----------
  366. Arguments
  367. in
  368. empty
  369. out::
  370. struct cfs_root_out {
  371. ViceFid VFid;
  372. } cfs_root;
  373. Description
  374. This call is made to Venus during the initialization of
  375. the Coda filesystem. If the result is zero, the cfs_root structure
  376. contains the ViceFid of the root of the Coda filesystem. If a non-zero
  377. result is generated, its value is a platform dependent error code
  378. indicating the difficulty Venus encountered in locating the root of
  379. the Coda filesystem.
  380. 4.4. lookup
  381. ------------
  382. Summary
  383. Find the ViceFid and type of an object in a directory if it exists.
  384. Arguments
  385. in::
  386. struct cfs_lookup_in {
  387. ViceFid VFid;
  388. char *name; /* Place holder for data. */
  389. } cfs_lookup;
  390. out::
  391. struct cfs_lookup_out {
  392. ViceFid VFid;
  393. int vtype;
  394. } cfs_lookup;
  395. Description
  396. This call is made to determine the ViceFid and filetype of
  397. a directory entry. The directory entry requested carries name 'name'
  398. and Venus will search the directory identified by cfs_lookup_in.VFid.
  399. The result may indicate that the name does not exist, or that
  400. difficulty was encountered in finding it (e.g. due to disconnection).
  401. If the result is zero, the field cfs_lookup_out.VFid contains the
  402. targets ViceFid and cfs_lookup_out.vtype the coda_vtype giving the
  403. type of object the name designates.
  404. The name of the object is an 8 bit character string of maximum length
  405. CFS_MAXNAMLEN, currently set to 256 (including a 0 terminator.)
  406. It is extremely important to realize that Venus bitwise ors the field
  407. cfs_lookup.vtype with CFS_NOCACHE to indicate that the object should
  408. not be put in the kernel name cache.
  409. .. Note::
  410. The type of the vtype is currently wrong. It should be
  411. coda_vtype. Linux does not take note of CFS_NOCACHE. It should.
  412. 4.5. getattr
  413. -------------
  414. Summary Get the attributes of a file.
  415. Arguments
  416. in::
  417. struct cfs_getattr_in {
  418. ViceFid VFid;
  419. struct coda_vattr attr; /* XXXXX */
  420. } cfs_getattr;
  421. out::
  422. struct cfs_getattr_out {
  423. struct coda_vattr attr;
  424. } cfs_getattr;
  425. Description
  426. This call returns the attributes of the file identified by fid.
  427. Errors
  428. Errors can occur if the object with fid does not exist, is
  429. unaccessible or if the caller does not have permission to fetch
  430. attributes.
  431. .. Note::
  432. Many kernel FS drivers (Linux, NT and Windows 95) need to acquire
  433. the attributes as well as the Fid for the instantiation of an internal
  434. "inode" or "FileHandle". A significant improvement in performance on
  435. such systems could be made by combining the lookup and getattr calls
  436. both at the Venus/kernel interaction level and at the RPC level.
  437. The vattr structure included in the input arguments is superfluous and
  438. should be removed.
  439. 4.6. setattr
  440. -------------
  441. Summary
  442. Set the attributes of a file.
  443. Arguments
  444. in::
  445. struct cfs_setattr_in {
  446. ViceFid VFid;
  447. struct coda_vattr attr;
  448. } cfs_setattr;
  449. out
  450. empty
  451. Description
  452. The structure attr is filled with attributes to be changed
  453. in BSD style. Attributes not to be changed are set to -1, apart from
  454. vtype which is set to VNON. Other are set to the value to be assigned.
  455. The only attributes which the FS driver may request to change are the
  456. mode, owner, groupid, atime, mtime and ctime. The return value
  457. indicates success or failure.
  458. Errors
  459. A variety of errors can occur. The object may not exist, may
  460. be inaccessible, or permission may not be granted by Venus.
  461. 4.7. access
  462. ------------
  463. Arguments
  464. in::
  465. struct cfs_access_in {
  466. ViceFid VFid;
  467. int flags;
  468. } cfs_access;
  469. out
  470. empty
  471. Description
  472. Verify if access to the object identified by VFid for
  473. operations described by flags is permitted. The result indicates if
  474. access will be granted. It is important to remember that Coda uses
  475. ACLs to enforce protection and that ultimately the servers, not the
  476. clients enforce the security of the system. The result of this call
  477. will depend on whether a token is held by the user.
  478. Errors
  479. The object may not exist, or the ACL describing the protection
  480. may not be accessible.
  481. 4.8. create
  482. ------------
  483. Summary
  484. Invoked to create a file
  485. Arguments
  486. in::
  487. struct cfs_create_in {
  488. ViceFid VFid;
  489. struct coda_vattr attr;
  490. int excl;
  491. int mode;
  492. char *name; /* Place holder for data. */
  493. } cfs_create;
  494. out::
  495. struct cfs_create_out {
  496. ViceFid VFid;
  497. struct coda_vattr attr;
  498. } cfs_create;
  499. Description
  500. This upcall is invoked to request creation of a file.
  501. The file will be created in the directory identified by VFid, its name
  502. will be name, and the mode will be mode. If excl is set an error will
  503. be returned if the file already exists. If the size field in attr is
  504. set to zero the file will be truncated. The uid and gid of the file
  505. are set by converting the CodaCred to a uid using a macro CRTOUID
  506. (this macro is platform dependent). Upon success the VFid and
  507. attributes of the file are returned. The Coda FS Driver will normally
  508. instantiate a vnode, inode or file handle at kernel level for the new
  509. object.
  510. Errors
  511. A variety of errors can occur. Permissions may be insufficient.
  512. If the object exists and is not a file the error EISDIR is returned
  513. under Unix.
  514. .. Note::
  515. The packing of parameters is very inefficient and appears to
  516. indicate confusion between the system call creat and the VFS operation
  517. create. The VFS operation create is only called to create new objects.
  518. This create call differs from the Unix one in that it is not invoked
  519. to return a file descriptor. The truncate and exclusive options,
  520. together with the mode, could simply be part of the mode as it is
  521. under Unix. There should be no flags argument; this is used in open
  522. (2) to return a file descriptor for READ or WRITE mode.
  523. The attributes of the directory should be returned too, since the size
  524. and mtime changed.
  525. 4.9. mkdir
  526. -----------
  527. Summary
  528. Create a new directory.
  529. Arguments
  530. in::
  531. struct cfs_mkdir_in {
  532. ViceFid VFid;
  533. struct coda_vattr attr;
  534. char *name; /* Place holder for data. */
  535. } cfs_mkdir;
  536. out::
  537. struct cfs_mkdir_out {
  538. ViceFid VFid;
  539. struct coda_vattr attr;
  540. } cfs_mkdir;
  541. Description
  542. This call is similar to create but creates a directory.
  543. Only the mode field in the input parameters is used for creation.
  544. Upon successful creation, the attr returned contains the attributes of
  545. the new directory.
  546. Errors
  547. As for create.
  548. .. Note::
  549. The input parameter should be changed to mode instead of
  550. attributes.
  551. The attributes of the parent should be returned since the size and
  552. mtime changes.
  553. 4.10. link
  554. -----------
  555. Summary
  556. Create a link to an existing file.
  557. Arguments
  558. in::
  559. struct cfs_link_in {
  560. ViceFid sourceFid; /* cnode to link *to* */
  561. ViceFid destFid; /* Directory in which to place link */
  562. char *tname; /* Place holder for data. */
  563. } cfs_link;
  564. out
  565. empty
  566. Description
  567. This call creates a link to the sourceFid in the directory
  568. identified by destFid with name tname. The source must reside in the
  569. target's parent, i.e. the source must be have parent destFid, i.e. Coda
  570. does not support cross directory hard links. Only the return value is
  571. relevant. It indicates success or the type of failure.
  572. Errors
  573. The usual errors can occur.
  574. 4.11. symlink
  575. --------------
  576. Summary
  577. create a symbolic link
  578. Arguments
  579. in::
  580. struct cfs_symlink_in {
  581. ViceFid VFid; /* Directory to put symlink in */
  582. char *srcname;
  583. struct coda_vattr attr;
  584. char *tname;
  585. } cfs_symlink;
  586. out
  587. none
  588. Description
  589. Create a symbolic link. The link is to be placed in the
  590. directory identified by VFid and named tname. It should point to the
  591. pathname srcname. The attributes of the newly created object are to
  592. be set to attr.
  593. .. Note::
  594. The attributes of the target directory should be returned since
  595. its size changed.
  596. 4.12. remove
  597. -------------
  598. Summary
  599. Remove a file
  600. Arguments
  601. in::
  602. struct cfs_remove_in {
  603. ViceFid VFid;
  604. char *name; /* Place holder for data. */
  605. } cfs_remove;
  606. out
  607. none
  608. Description
  609. Remove file named cfs_remove_in.name in directory
  610. identified by VFid.
  611. .. Note::
  612. The attributes of the directory should be returned since its
  613. mtime and size may change.
  614. 4.13. rmdir
  615. ------------
  616. Summary
  617. Remove a directory
  618. Arguments
  619. in::
  620. struct cfs_rmdir_in {
  621. ViceFid VFid;
  622. char *name; /* Place holder for data. */
  623. } cfs_rmdir;
  624. out
  625. none
  626. Description
  627. Remove the directory with name 'name' from the directory
  628. identified by VFid.
  629. .. Note:: The attributes of the parent directory should be returned since
  630. its mtime and size may change.
  631. 4.14. readlink
  632. ---------------
  633. Summary
  634. Read the value of a symbolic link.
  635. Arguments
  636. in::
  637. struct cfs_readlink_in {
  638. ViceFid VFid;
  639. } cfs_readlink;
  640. out::
  641. struct cfs_readlink_out {
  642. int count;
  643. caddr_t data; /* Place holder for data. */
  644. } cfs_readlink;
  645. Description
  646. This routine reads the contents of symbolic link
  647. identified by VFid into the buffer data. The buffer data must be able
  648. to hold any name up to CFS_MAXNAMLEN (PATH or NAM??).
  649. Errors
  650. No unusual errors.
  651. 4.15. open
  652. -----------
  653. Summary
  654. Open a file.
  655. Arguments
  656. in::
  657. struct cfs_open_in {
  658. ViceFid VFid;
  659. int flags;
  660. } cfs_open;
  661. out::
  662. struct cfs_open_out {
  663. dev_t dev;
  664. ino_t inode;
  665. } cfs_open;
  666. Description
  667. This request asks Venus to place the file identified by
  668. VFid in its cache and to note that the calling process wishes to open
  669. it with flags as in open(2). The return value to the kernel differs
  670. for Unix and Windows systems. For Unix systems the Coda FS Driver is
  671. informed of the device and inode number of the container file in the
  672. fields dev and inode. For Windows the path of the container file is
  673. returned to the kernel.
  674. .. Note::
  675. Currently the cfs_open_out structure is not properly adapted to
  676. deal with the Windows case. It might be best to implement two
  677. upcalls, one to open aiming at a container file name, the other at a
  678. container file inode.
  679. 4.16. close
  680. ------------
  681. Summary
  682. Close a file, update it on the servers.
  683. Arguments
  684. in::
  685. struct cfs_close_in {
  686. ViceFid VFid;
  687. int flags;
  688. } cfs_close;
  689. out
  690. none
  691. Description
  692. Close the file identified by VFid.
  693. .. Note::
  694. The flags argument is bogus and not used. However, Venus' code
  695. has room to deal with an execp input field, probably this field should
  696. be used to inform Venus that the file was closed but is still memory
  697. mapped for execution. There are comments about fetching versus not
  698. fetching the data in Venus vproc_vfscalls. This seems silly. If a
  699. file is being closed, the data in the container file is to be the new
  700. data. Here again the execp flag might be in play to create confusion:
  701. currently Venus might think a file can be flushed from the cache when
  702. it is still memory mapped. This needs to be understood.
  703. 4.17. ioctl
  704. ------------
  705. Summary
  706. Do an ioctl on a file. This includes the pioctl interface.
  707. Arguments
  708. in::
  709. struct cfs_ioctl_in {
  710. ViceFid VFid;
  711. int cmd;
  712. int len;
  713. int rwflag;
  714. char *data; /* Place holder for data. */
  715. } cfs_ioctl;
  716. out::
  717. struct cfs_ioctl_out {
  718. int len;
  719. caddr_t data; /* Place holder for data. */
  720. } cfs_ioctl;
  721. Description
  722. Do an ioctl operation on a file. The command, len and
  723. data arguments are filled as usual. flags is not used by Venus.
  724. .. Note::
  725. Another bogus parameter. flags is not used. What is the
  726. business about PREFETCHING in the Venus code?
  727. 4.18. rename
  728. -------------
  729. Summary
  730. Rename a fid.
  731. Arguments
  732. in::
  733. struct cfs_rename_in {
  734. ViceFid sourceFid;
  735. char *srcname;
  736. ViceFid destFid;
  737. char *destname;
  738. } cfs_rename;
  739. out
  740. none
  741. Description
  742. Rename the object with name srcname in directory
  743. sourceFid to destname in destFid. It is important that the names
  744. srcname and destname are 0 terminated strings. Strings in Unix
  745. kernels are not always null terminated.
  746. 4.19. readdir
  747. --------------
  748. Summary
  749. Read directory entries.
  750. Arguments
  751. in::
  752. struct cfs_readdir_in {
  753. ViceFid VFid;
  754. int count;
  755. int offset;
  756. } cfs_readdir;
  757. out::
  758. struct cfs_readdir_out {
  759. int size;
  760. caddr_t data; /* Place holder for data. */
  761. } cfs_readdir;
  762. Description
  763. Read directory entries from VFid starting at offset and
  764. read at most count bytes. Returns the data in data and returns
  765. the size in size.
  766. .. Note::
  767. This call is not used. Readdir operations exploit container
  768. files. We will re-evaluate this during the directory revamp which is
  769. about to take place.
  770. 4.20. vget
  771. -----------
  772. Summary
  773. instructs Venus to do an FSDB->Get.
  774. Arguments
  775. in::
  776. struct cfs_vget_in {
  777. ViceFid VFid;
  778. } cfs_vget;
  779. out::
  780. struct cfs_vget_out {
  781. ViceFid VFid;
  782. int vtype;
  783. } cfs_vget;
  784. Description
  785. This upcall asks Venus to do a get operation on an fsobj
  786. labelled by VFid.
  787. .. Note::
  788. This operation is not used. However, it is extremely useful
  789. since it can be used to deal with read/write memory mapped files.
  790. These can be "pinned" in the Venus cache using vget and released with
  791. inactive.
  792. 4.21. fsync
  793. ------------
  794. Summary
  795. Tell Venus to update the RVM attributes of a file.
  796. Arguments
  797. in::
  798. struct cfs_fsync_in {
  799. ViceFid VFid;
  800. } cfs_fsync;
  801. out
  802. none
  803. Description
  804. Ask Venus to update RVM attributes of object VFid. This
  805. should be called as part of kernel level fsync type calls. The
  806. result indicates if the syncing was successful.
  807. .. Note:: Linux does not implement this call. It should.
  808. 4.22. inactive
  809. ---------------
  810. Summary
  811. Tell Venus a vnode is no longer in use.
  812. Arguments
  813. in::
  814. struct cfs_inactive_in {
  815. ViceFid VFid;
  816. } cfs_inactive;
  817. out
  818. none
  819. Description
  820. This operation returns EOPNOTSUPP.
  821. .. Note:: This should perhaps be removed.
  822. 4.23. rdwr
  823. -----------
  824. Summary
  825. Read or write from a file
  826. Arguments
  827. in::
  828. struct cfs_rdwr_in {
  829. ViceFid VFid;
  830. int rwflag;
  831. int count;
  832. int offset;
  833. int ioflag;
  834. caddr_t data; /* Place holder for data. */
  835. } cfs_rdwr;
  836. out::
  837. struct cfs_rdwr_out {
  838. int rwflag;
  839. int count;
  840. caddr_t data; /* Place holder for data. */
  841. } cfs_rdwr;
  842. Description
  843. This upcall asks Venus to read or write from a file.
  844. .. Note::
  845. It should be removed since it is against the Coda philosophy that
  846. read/write operations never reach Venus. I have been told the
  847. operation does not work. It is not currently used.
  848. 4.24. odymount
  849. ---------------
  850. Summary
  851. Allows mounting multiple Coda "filesystems" on one Unix mount point.
  852. Arguments
  853. in::
  854. struct ody_mount_in {
  855. char *name; /* Place holder for data. */
  856. } ody_mount;
  857. out::
  858. struct ody_mount_out {
  859. ViceFid VFid;
  860. } ody_mount;
  861. Description
  862. Asks Venus to return the rootfid of a Coda system named
  863. name. The fid is returned in VFid.
  864. .. Note::
  865. This call was used by David for dynamic sets. It should be
  866. removed since it causes a jungle of pointers in the VFS mounting area.
  867. It is not used by Coda proper. Call is not implemented by Venus.
  868. 4.25. ody_lookup
  869. -----------------
  870. Summary
  871. Looks up something.
  872. Arguments
  873. in
  874. irrelevant
  875. out
  876. irrelevant
  877. .. Note:: Gut it. Call is not implemented by Venus.
  878. 4.26. ody_expand
  879. -----------------
  880. Summary
  881. expands something in a dynamic set.
  882. Arguments
  883. in
  884. irrelevant
  885. out
  886. irrelevant
  887. .. Note:: Gut it. Call is not implemented by Venus.
  888. 4.27. prefetch
  889. ---------------
  890. Summary
  891. Prefetch a dynamic set.
  892. Arguments
  893. in
  894. Not documented.
  895. out
  896. Not documented.
  897. Description
  898. Venus worker.cc has support for this call, although it is
  899. noted that it doesn't work. Not surprising, since the kernel does not
  900. have support for it. (ODY_PREFETCH is not a defined operation).
  901. .. Note:: Gut it. It isn't working and isn't used by Coda.
  902. 4.28. signal
  903. -------------
  904. Summary
  905. Send Venus a signal about an upcall.
  906. Arguments
  907. in
  908. none
  909. out
  910. not applicable.
  911. Description
  912. This is an out-of-band upcall to Venus to inform Venus
  913. that the calling process received a signal after Venus read the
  914. message from the input queue. Venus is supposed to clean up the
  915. operation.
  916. Errors
  917. No reply is given.
  918. .. Note::
  919. We need to better understand what Venus needs to clean up and if
  920. it is doing this correctly. Also we need to handle multiple upcall
  921. per system call situations correctly. It would be important to know
  922. what state changes in Venus take place after an upcall for which the
  923. kernel is responsible for notifying Venus to clean up (e.g. open
  924. definitely is such a state change, but many others are maybe not).
  925. 5. The minicache and downcalls
  926. ===============================
  927. The Coda FS Driver can cache results of lookup and access upcalls, to
  928. limit the frequency of upcalls. Upcalls carry a price since a process
  929. context switch needs to take place. The counterpart of caching the
  930. information is that Venus will notify the FS Driver that cached
  931. entries must be flushed or renamed.
  932. The kernel code generally has to maintain a structure which links the
  933. internal file handles (called vnodes in BSD, inodes in Linux and
  934. FileHandles in Windows) with the ViceFid's which Venus maintains. The
  935. reason is that frequent translations back and forth are needed in
  936. order to make upcalls and use the results of upcalls. Such linking
  937. objects are called cnodes.
  938. The current minicache implementations have cache entries which record
  939. the following:
  940. 1. the name of the file
  941. 2. the cnode of the directory containing the object
  942. 3. a list of CodaCred's for which the lookup is permitted.
  943. 4. the cnode of the object
  944. The lookup call in the Coda FS Driver may request the cnode of the
  945. desired object from the cache, by passing its name, directory and the
  946. CodaCred's of the caller. The cache will return the cnode or indicate
  947. that it cannot be found. The Coda FS Driver must be careful to
  948. invalidate cache entries when it modifies or removes objects.
  949. When Venus obtains information that indicates that cache entries are
  950. no longer valid, it will make a downcall to the kernel. Downcalls are
  951. intercepted by the Coda FS Driver and lead to cache invalidations of
  952. the kind described below. The Coda FS Driver does not return an error
  953. unless the downcall data could not be read into kernel memory.
  954. 5.1. INVALIDATE
  955. ----------------
  956. No information is available on this call.
  957. 5.2. FLUSH
  958. -----------
  959. Arguments
  960. None
  961. Summary
  962. Flush the name cache entirely.
  963. Description
  964. Venus issues this call upon startup and when it dies. This
  965. is to prevent stale cache information being held. Some operating
  966. systems allow the kernel name cache to be switched off dynamically.
  967. When this is done, this downcall is made.
  968. 5.3. PURGEUSER
  969. ---------------
  970. Arguments
  971. ::
  972. struct cfs_purgeuser_out {/* CFS_PURGEUSER is a venus->kernel call */
  973. struct CodaCred cred;
  974. } cfs_purgeuser;
  975. Description
  976. Remove all entries in the cache carrying the Cred. This
  977. call is issued when tokens for a user expire or are flushed.
  978. 5.4. ZAPFILE
  979. -------------
  980. Arguments
  981. ::
  982. struct cfs_zapfile_out { /* CFS_ZAPFILE is a venus->kernel call */
  983. ViceFid CodaFid;
  984. } cfs_zapfile;
  985. Description
  986. Remove all entries which have the (dir vnode, name) pair.
  987. This is issued as a result of an invalidation of cached attributes of
  988. a vnode.
  989. .. Note::
  990. Call is not named correctly in NetBSD and Mach. The minicache
  991. zapfile routine takes different arguments. Linux does not implement
  992. the invalidation of attributes correctly.
  993. 5.5. ZAPDIR
  994. ------------
  995. Arguments
  996. ::
  997. struct cfs_zapdir_out { /* CFS_ZAPDIR is a venus->kernel call */
  998. ViceFid CodaFid;
  999. } cfs_zapdir;
  1000. Description
  1001. Remove all entries in the cache lying in a directory
  1002. CodaFid, and all children of this directory. This call is issued when
  1003. Venus receives a callback on the directory.
  1004. 5.6. ZAPVNODE
  1005. --------------
  1006. Arguments
  1007. ::
  1008. struct cfs_zapvnode_out { /* CFS_ZAPVNODE is a venus->kernel call */
  1009. struct CodaCred cred;
  1010. ViceFid VFid;
  1011. } cfs_zapvnode;
  1012. Description
  1013. Remove all entries in the cache carrying the cred and VFid
  1014. as in the arguments. This downcall is probably never issued.
  1015. 5.7. PURGEFID
  1016. --------------
  1017. Arguments
  1018. ::
  1019. struct cfs_purgefid_out { /* CFS_PURGEFID is a venus->kernel call */
  1020. ViceFid CodaFid;
  1021. } cfs_purgefid;
  1022. Description
  1023. Flush the attribute for the file. If it is a dir (odd
  1024. vnode), purge its children from the namecache and remove the file from the
  1025. namecache.
  1026. 5.8. REPLACE
  1027. -------------
  1028. Summary
  1029. Replace the Fid's for a collection of names.
  1030. Arguments
  1031. ::
  1032. struct cfs_replace_out { /* cfs_replace is a venus->kernel call */
  1033. ViceFid NewFid;
  1034. ViceFid OldFid;
  1035. } cfs_replace;
  1036. Description
  1037. This routine replaces a ViceFid in the name cache with
  1038. another. It is added to allow Venus during reintegration to replace
  1039. locally allocated temp fids while disconnected with global fids even
  1040. when the reference counts on those fids are not zero.
  1041. 6. Initialization and cleanup
  1042. ==============================
  1043. This section gives brief hints as to desirable features for the Coda
  1044. FS Driver at startup and upon shutdown or Venus failures. Before
  1045. entering the discussion it is useful to repeat that the Coda FS Driver
  1046. maintains the following data:
  1047. 1. message queues
  1048. 2. cnodes
  1049. 3. name cache entries
  1050. The name cache entries are entirely private to the driver, so they
  1051. can easily be manipulated. The message queues will generally have
  1052. clear points of initialization and destruction. The cnodes are
  1053. much more delicate. User processes hold reference counts in Coda
  1054. filesystems and it can be difficult to clean up the cnodes.
  1055. It can expect requests through:
  1056. 1. the message subsystem
  1057. 2. the VFS layer
  1058. 3. pioctl interface
  1059. Currently the pioctl passes through the VFS for Coda so we can
  1060. treat these similarly.
  1061. 6.1. Requirements
  1062. ------------------
  1063. The following requirements should be accommodated:
  1064. 1. The message queues should have open and close routines. On Unix
  1065. the opening of the character devices are such routines.
  1066. - Before opening, no messages can be placed.
  1067. - Opening will remove any old messages still pending.
  1068. - Close will notify any sleeping processes that their upcall cannot
  1069. be completed.
  1070. - Close will free all memory allocated by the message queues.
  1071. 2. At open the namecache shall be initialized to empty state.
  1072. 3. Before the message queues are open, all VFS operations will fail.
  1073. Fortunately this can be achieved by making sure than mounting the
  1074. Coda filesystem cannot succeed before opening.
  1075. 4. After closing of the queues, no VFS operations can succeed. Here
  1076. one needs to be careful, since a few operations (lookup,
  1077. read/write, readdir) can proceed without upcalls. These must be
  1078. explicitly blocked.
  1079. 5. Upon closing the namecache shall be flushed and disabled.
  1080. 6. All memory held by cnodes can be freed without relying on upcalls.
  1081. 7. Unmounting the file system can be done without relying on upcalls.
  1082. 8. Mounting the Coda filesystem should fail gracefully if Venus cannot
  1083. get the rootfid or the attributes of the rootfid. The latter is
  1084. best implemented by Venus fetching these objects before attempting
  1085. to mount.
  1086. .. Note::
  1087. NetBSD in particular but also Linux have not implemented the
  1088. above requirements fully. For smooth operation this needs to be
  1089. corrected.