요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
===========================
Coda Kernel-Venus Interface
===========================
.. Note::
This is one of the technical documents describing a component of
Coda -- this document describes the client kernel-Venus interface.
For more information:
http://www.coda.cs.cmu.edu
For user level software needed to run Coda:
ftp://ftp.coda.cs.cmu.edu
To run Coda you need to get a user level cache manager for the client,
named Venus, as well as tools to manipulate ACLs, to log in, etc. The
client needs to have the Coda filesystem selected in the kernel
configuration.
The server needs a user level server and at present does not depend on
kernel support.
The Venus kernel interface
Peter J. Braam
v1.0, Nov 9, 1997
This document describes the communication between Venus and kernel
level filesystem code needed for the operation of the Coda file sys-
tem. This document version is meant to describe the current interface
(version 1.0) as well as improvements we envisage.
.. Table of Contents
1. Introduction
2. Servicing Coda filesystem calls
3. The message layer
3.1 Implementation details
4. The interface at the call level
4.1 Data structures shared by the kernel and Venus
4.2 The pioctl interface
4.3 root
4.4 lookup
4.5 getattr
4.6 setattr
4.7 access
4.8 create
4.9 mkdir
4.10 link
4.11 symlink
4.12 remove
4.13 rmdir
4.14 readlink
4.15 open
4.16 close
4.17 ioctl
4.18 rename
4.19 readdir
4.20 vget
4.21 fsync
4.22 inactive
4.23 rdwr
4.24 odymount
4.25 ody_lookup
4.26 ody_expand
4.27 prefetch
4.28 signal
5. The minicache and downcalls
5.1 INVALIDATE
5.2 FLUSH
5.3 PURGEUSER
5.4 ZAPFILE
5.5 ZAPDIR
5.6 ZAPVNODE
5.7 PURGEFID
5.8 REPLACE
6. Initialization and cleanup
6.1 Requirements
1. Introduction
===============
A key component in the Coda Distributed File System is the cache
manager, Venus.
When processes on a Coda enabled system access files in the Coda
filesystem, requests are directed at the filesystem layer in the
operating system. The operating system will communicate with Venus to
service the request for the process. Venus manages a persistent
client cache and makes remote procedure calls to Coda file servers and
related servers (such as authentication servers) to service these
requests it receives from the operating system. When Venus has
serviced a request it replies to the operating system with appropriate
return codes, and other data related to the request. Optionally the
kernel support for Coda may maintain a minicache of recently processed
requests to limit the number of interactions with Venus. Venus
possesses the facility to inform the kernel when elements from its
minicache are no longer valid.
This document describes precisely this communication between the
kernel and Venus. The definitions of so called upcalls and downcalls
will be given with the format of the data they handle. We shall also
describe the semantic invariants resulting from the calls.
Historically Coda was implemented in a BSD file system in Mach 2.6.
The interface between the kernel and Venus is very similar to the BSD
VFS interface. Similar functionality is provided, and the format of
the parameters and returned data is very similar to the BSD VFS. This
leads to an almost natural environment for implementing a kernel-level
filesystem driver for Coda in a BSD system. However, other operating
systems such as Linux and Windows 95 and NT have virtual filesystem
with different interfaces.
To implement Coda on these systems some reverse engineering of the
Venus/Kernel protocol is necessary. Also it came to light that other
systems could profit significantly from certain small optimizations
and modifications to the protocol. To facilitate this work as well as
to make future ports easier, communication between Venus and the
kernel should be documented in great detail. This is the aim of this
document.
2. Servicing Coda filesystem calls
===================================
The service of a request for a Coda file system service originates in
a process P which accessing a Coda file. It makes a system call which
traps to the OS kernel. Examples of such calls trapping to the kernel
are ``read``, ``write``, ``open``, ``close``, ``create``, ``mkdir``,
``rmdir``, ``chmod`` in a Unix context. Similar calls exist in the Win32
environment, and are named ``CreateFile``.
Generally the operating system handles the request in a virtual
filesystem (VFS) layer, which is named I/O Manager in NT and IFS
manager in Windows 95. The VFS is responsible for partial processing
of the request and for locating the specific filesystem(s) which will
service parts of the request. Usually the information in the path
assists in locating the correct FS drivers. Sometimes after extensive
pre-processing, the VFS starts invoking exported routines in the FS
driver. This is the point where the FS specific processing of the
request starts, and here the Coda specific kernel code comes into
play.
The FS layer for Coda must expose and implement several interfaces.
First and foremost the VFS must be able to make all necessary calls to
the Coda FS layer, so the Coda FS driver must expose the VFS interface
as applicable in the operating system. These differ very significantly
among operating systems, but share features such as facilities to
read/write and create and remove objects. The Coda FS layer services
such VFS requests by invoking one or more well defined services
offered by the cache manager Venus. When the replies from Venus have
come back to the FS driver, servicing of the VFS call continues and
finishes with a reply to the kernel's VFS. Finally the VFS layer
returns to the process.
As a result of this design a basic interface exposed by the FS driver
must allow Venus to manage message traffic. In particular Venus must
be able to retrieve and place messages and to be notified of the
arrival of a new message. The notification must be through a mechanism
which does not block Venus since Venus must attend to other tasks even
when no messages are waiting or being processed.
**Interfaces of the Coda FS Driver**
Furthermore the FS layer provides for a special path of communication
between a user process and Venus, called the pioctl interface. The
pioctl interface is used for Coda specific services, such as
requesting detailed information about the persistent cache managed by
Venus. Here the involvement of the kernel is minimal. It identifies
the calling process and passes the information on to Venus. When
Venus replies the response is passed back to the caller in unmodified
form.
Finally Venus allows the kernel FS driver to cache the results from
certain services. This is done to avoid excessive context switches
and results in an efficient system. However, Venus may acquire
information, for example from the network which implies that cached
information must be flushed or replaced. Venus then makes a downcall
to the Coda FS layer to request flushes or updates in the cache. The
kernel FS driver handles such requests synchronously.
Among these interfaces the VFS interface and the facility to place,
receive and be notified of messages are platform specific. We will
not go into the calls exported to the VFS layer but we will state the
requirements of the message exchange mechanism.
3. The message layer
=====================
At the lowest level the communication between Venus and the FS driver
proceeds through messages. The synchronization between processes
requesting Coda file service and Venus relies on blocking and waking
up processes. The Coda FS driver processes VFS- and pioctl-requests
on behalf of a process P, creates messages for Venus, awaits replies
and finally returns to the caller. The implementation of the exchange
of messages is platform specific, but the semantics have (so far)
appeared to be generally applicable. Data buffers are created by the
FS Driver in kernel memory on behalf of P and copied to user memory in
Venus.
The FS Driver while servicing P makes upcalls to Venus. Such an
upcall is dispatched to Venus by creating a message structure. The
structure contains the identification of P, the message sequence
number, the size of the request and a pointer to the data in kernel
memory for the request. Since the data buffer is re-used to hold the
reply from Venus, there is a field for the size of the reply. A flags
field is used in the message to precisely record the status of the
message. Additional platform dependent structures involve pointers to
determine the position of the message on queues and pointers to
synchronization objects. In the upcall routine the message structure
is filled in, flags are set to 0, and it is placed on the *pending*
queue. The routine calling upcall is responsible for allocating the
data buffer; its structure will be described in the next section.
A facility must exist to notify Venus that the message has been
created, and implemented using available synchronization objects in
the OS. This notification is done in the upcall context of the process
P. When the message is on the pending queue, process P cannot proceed
in upcall. The (kernel mode) processing of P in the filesystem
request routine must be suspended until Venus has replied. Therefore
the calling thread in P is blocked in upcall. A pointer in the
message structure will locate the synchronization object on which P is
sleeping.
Venus detects the notification that a message has arrived, and the FS
driver allow Venus to retrieve the message with a getmsg_from_kernel
call. This action finishes in the kernel by putting the message on the
queue of processing messages and setting flags to READ. Venus is
passed the contents of the data buffer. The getmsg_from_kernel call
now returns and Venus processes the request.
At some later point the FS driver receives a message from Venus,
namely when Venus calls sendmsg_to_kernel. At this moment the Coda FS
driver looks at the contents of the message and decides if:
* the message is a reply for a suspended thread P. If so it removes
the message from the processing queue and marks the message as
WRITTEN. Finally, the FS driver unblocks P (still in the kernel
mode context of Venus) and the sendmsg_to_kernel call returns to
Venus. The process P will be scheduled at some point and continues
processing its upcall with the data buffer replaced with the reply
from Venus.
* The message is a ``downcall``. A downcall is a request from Venus to
the FS Driver. The FS driver processes the request immediately
(usually a cache eviction or replacement) and when it finishes
sendmsg_to_kernel returns.
Now P awakes and continues processing upcall. There are some
subtleties to take account of. First P will determine if it was woken
up in upcall by a signal from some other source (for example an
attempt to terminate P) or as is normally the case by Venus in its
sendmsg_to_kernel call. In the normal case, the upcall routine will
deallocate the message structure and return. The FS routine can proceed
with its processing.
**Sleeping and IPC arrangements**
In case P is woken up by a signal and not by Venus, it will first look
at the flags field. If the message is not yet READ, the process P can
handle its signal without notifying Venus. If Venus has READ, and
the request should not be processed, P can send Venus a signal message
to indicate that it should disregard the previous message. Such
signals are put in the queue at the head, and read first by Venus. If
the message is already marked as WRITTEN it is too late to stop the
processing. The VFS routine will now continue. (-- If a VFS request
involves more than one upcall, this can lead to complicated state, an
extra field "handle_signals" could be added in the message structure
to indicate points of no return have been passed.--)
3.1. Implementation details
----------------------------
The Unix implementation of this mechanism has been through the
implementation of a character device associated with Coda. Venus
retrieves messages by doing a read on the device, replies are sent
with a write and notification is through the select system call on the
file descriptor for the device. The process P is kept waiting on an
interruptible wait queue object.
In Windows NT and the DPMI Windows 95 implementation a DeviceIoControl
call is used. The DeviceIoControl call is designed to copy buffers
from user memory to kernel memory with OPCODES. The sendmsg_to_kernel
is issued as a synchronous call, while the getmsg_from_kernel call is
asynchronous. Windows EventObjects are used for notification of
message arrival. The process P is kept waiting on a KernelEvent
object in NT and a semaphore in Windows 95.
4. The interface at the call level
===================================
This section describes the upcalls a Coda FS driver can make to Venus.
Each of these upcalls make use of two structures: inputArgs and
outputArgs. In pseudo BNF form the structures take the following
form::
struct inputArgs {
u_long opcode;
u_long unique; /* Keep multiple outstanding msgs distinct */
u_short pid; /* Common to all */
u_short pgid; /* Common to all */
struct CodaCred cred; /* Common to all */
<union "in" of call dependent parts of inputArgs>
};
struct outputArgs {
u_long opcode;
u_long unique; /* Keep multiple outstanding msgs distinct */
u_long result;
<union "out" of call dependent parts of inputArgs>
};
Before going on let us elucidate the role of the various fields. The
inputArgs start with the opcode which defines the type of service
requested from Venus. There are approximately 30 upcalls at present
which we will discuss. The unique field labels the inputArg with a
unique number which will identify the message uniquely. A process and
process group id are passed. Finally the credentials of the caller
are included.
Before delving into the specific calls we need to discuss a variety of
data structures shared by the kernel and Venus.
4.1. Data structures shared by the kernel and Venus
----------------------------------------------------
The CodaCred structure defines a variety of user and group ids as
they are set for the calling process. The vuid_t and vgid_t are 32 bit
unsigned integers. It also defines group membership in an array. On
Unix the CodaCred has proven sufficient to implement good security
semantics for Coda but the structure may have to undergo modification
for the Windows environment when these mature::
struct CodaCred {
vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, effective, set, fs uid */
vgid_t cr_gid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
vgid_t cr_groups[NGROUPS]; /* Group membership for caller */
};
.. Note::
It is questionable if we need CodaCreds in Venus. Finally Venus
doesn't know about groups, although it does create files with the
default uid/gid. Perhaps the list of group membership is superfluous.
The next item is the fundamental identifier used to identify Coda
files, the ViceFid. A fid of a file uniquely defines a file or
directory in the Coda filesystem within a cell [1]_::
typedef struct ViceFid {
VolumeId Volume;
VnodeId Vnode;
Unique_t Unique;
} ViceFid;
.. [1] A cell is agroup of Coda servers acting under the aegis of a single
system control machine or SCM. See the Coda Administration manual
for a detailed description of the role of the SCM.
Each of the constituent fields: VolumeId, VnodeId and Unique_t are
unsigned 32 bit integers. We envisage that a further field will need
to be prefixed to identify the Coda cell; this will probably take the
form of a Ipv6 size IP address naming the Coda cell through DNS.
The next important structure shared between Venus and the kernel is
the attributes of the file. The following structure is used to
exchange information. It has room for future extensions such as
support for device files (currently not present in Coda)::
struct coda_timespec {
int64_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
struct coda_vattr {
enum coda_vtype va_type; /* vnode type (for create) */
u_short va_mode; /* files access mode and type */
short va_nlink; /* number of references to file */
vuid_t va_uid; /* owner user id */
vgid_t va_gid; /* owner group id */
long va_fsid; /* file system id (dev for now) */
long va_fileid; /* file id */
u_quad_t va_size; /* file size in bytes */
long va_blocksize; /* blocksize preferred for i/o */
struct coda_timespec va_atime; /* time of last access */
struct coda_timespec va_mtime; /* time of last modification */
struct coda_timespec va_ctime; /* time file changed */
u_long va_gen; /* generation number of file */
u_long va_flags; /* flags defined for file */
dev_t va_rdev; /* device special file represents */
u_quad_t va_bytes; /* bytes of disk space held by file */
u_quad_t va_filerev; /* file modification number */
u_int va_vaflags; /* operations flags, see below */
long va_spare; /* remain quad aligned */
};
4.2. The pioctl interface
--------------------------
Coda specific requests can be made by application through the pioctl
interface. The pioctl is implemented as an ordinary ioctl on a
fictitious file /coda/.CONTROL. The pioctl call opens this file, gets
a file handle and makes the ioctl call. Finally it closes the file.
The kernel involvement in this is limited to providing the facility to
open and close and pass the ioctl message and to verify that a path in
the pioctl data buffers is a file in a Coda filesystem.
The kernel is handed a data packet of the form::
struct {
const char *path;
struct ViceIoctl vidata;
int follow;
} data;
where::
struct ViceIoctl {
caddr_t in, out; /* Data to be transferred in, or out */
short in_size; /* Size of input buffer <= 2K */
short out_size; /* Maximum size of output buffer, <= 2K */
};
The path must be a Coda file, otherwise the ioctl upcall will not be
made.
.. Note:: The data structures and code are a mess. We need to clean this up.
**We now proceed to document the individual calls**:
4.3. root
----------
Arguments
in
empty
out::
struct cfs_root_out {
ViceFid VFid;
} cfs_root;
Description
This call is made to Venus during the initialization of
the Coda filesystem. If the result is zero, the cfs_root structure
contains the ViceFid of the root of the Coda filesystem. If a non-zero
result is generated, its value is a platform dependent error code
indicating the difficulty Venus encountered in locating the root of
the Coda filesystem.
4.4. lookup
------------
Summary
Find the ViceFid and type of an object in a directory if it exists.
Arguments
in::
struct cfs_lookup_in {
ViceFid VFid;
char *name; /* Place holder for data. */
} cfs_lookup;
out::
struct cfs_lookup_out {
ViceFid VFid;
int vtype;
} cfs_lookup;
Description
This call is made to determine the ViceFid and filetype of
a directory entry. The directory entry requested carries name 'name'
and Venus will search the directory identified by cfs_lookup_in.VFid.
The result may indicate that the name does not exist, or that
difficulty was encountered in finding it (e.g. due to disconnection).
If the result is zero, the field cfs_lookup_out.VFid contains the
targets ViceFid and cfs_lookup_out.vtype the coda_vtype giving the
type of object the name designates.
The name of the object is an 8 bit character string of maximum length
CFS_MAXNAMLEN, currently set to 256 (including a 0 terminator.)
It is extremely important to realize that Venus bitwise ors the field
cfs_lookup.vtype with CFS_NOCACHE to indicate that the object should
not be put in the kernel name cache.
.. Note::
The type of the vtype is currently wrong. It should be
coda_vtype. Linux does not take note of CFS_NOCACHE. It should.
4.5. getattr
-------------
Summary Get the attributes of a file.
Arguments
in::
struct cfs_getattr_in {
ViceFid VFid;
struct coda_vattr attr; /* XXXXX */
} cfs_getattr;
out::
struct cfs_getattr_out {
struct coda_vattr attr;
} cfs_getattr;
Description
This call returns the attributes of the file identified by fid.
Errors
Errors can occur if the object with fid does not exist, is
unaccessible or if the caller does not have permission to fetch
attributes.
.. Note::
Many kernel FS drivers (Linux, NT and Windows 95) need to acquire
the attributes as well as the Fid for the instantiation of an internal
"inode" or "FileHandle". A significant improvement in performance on
such systems could be made by combining the lookup and getattr calls
both at the Venus/kernel interaction level and at the RPC level.
The vattr structure included in the input arguments is superfluous and
should be removed.
4.6. setattr
-------------
Summary
Set the attributes of a file.
Arguments
in::
struct cfs_setattr_in {
ViceFid VFid;
struct coda_vattr attr;
} cfs_setattr;
out
empty
Description
The structure attr is filled with attributes to be changed
in BSD style. Attributes not to be changed are set to -1, apart from
vtype which is set to VNON. Other are set to the value to be assigned.
The only attributes which the FS driver may request to change are the
mode, owner, groupid, atime, mtime and ctime. The return value
indicates success or failure.
Errors
A variety of errors can occur. The object may not exist, may
be inaccessible, or permission may not be granted by Venus.
4.7. access
------------
Arguments
in::
struct cfs_access_in {
ViceFid VFid;
int flags;
} cfs_access;
out
empty
Description
Verify if access to the object identified by VFid for
operations described by flags is permitted. The result indicates if
access will be granted. It is important to remember that Coda uses
ACLs to enforce protection and that ultimately the servers, not the
clients enforce the security of the system. The result of this call
will depend on whether a token is held by the user.
Errors
The object may not exist, or the ACL describing the protection
may not be accessible.
4.8. create
------------
Summary
Invoked to create a file
Arguments
in::
struct cfs_create_in {
ViceFid VFid;
struct coda_vattr attr;
int excl;
int mode;
char *name; /* Place holder for data. */
} cfs_create;
out::
struct cfs_create_out {
ViceFid VFid;
struct coda_vattr attr;
} cfs_create;
Description
This upcall is invoked to request creation of a file.
The file will be created in the directory identified by VFid, its name
will be name, and the mode will be mode. If excl is set an error will
be returned if the file already exists. If the size field in attr is
set to zero the file will be truncated. The uid and gid of the file
are set by converting the CodaCred to a uid using a macro CRTOUID
(this macro is platform dependent). Upon success the VFid and
attributes of the file are returned. The Coda FS Driver will normally
instantiate a vnode, inode or file handle at kernel level for the new
object.
Errors
A variety of errors can occur. Permissions may be insufficient.
If the object exists and is not a file the error EISDIR is returned
under Unix.
.. Note::
The packing of parameters is very inefficient and appears to
indicate confusion between the system call creat and the VFS operation
create. The VFS operation create is only called to create new objects.
This create call differs from the Unix one in that it is not invoked
to return a file descriptor. The truncate and exclusive options,
together with the mode, could simply be part of the mode as it is
under Unix. There should be no flags argument; this is used in open
(2) to return a file descriptor for READ or WRITE mode.
The attributes of the directory should be returned too, since the size
and mtime changed.
4.9. mkdir
-----------
Summary
Create a new directory.
Arguments
in::
struct cfs_mkdir_in {
ViceFid VFid;
struct coda_vattr attr;
char *name; /* Place holder for data. */
} cfs_mkdir;
out::
struct cfs_mkdir_out {
ViceFid VFid;
struct coda_vattr attr;
} cfs_mkdir;
Description
This call is similar to create but creates a directory.
Only the mode field in the input parameters is used for creation.
Upon successful creation, the attr returned contains the attributes of
the new directory.
Errors
As for create.
.. Note::
The input parameter should be changed to mode instead of
attributes.
The attributes of the parent should be returned since the size and
mtime changes.
4.10. link
-----------
Summary
Create a link to an existing file.
Arguments
in::
struct cfs_link_in {
ViceFid sourceFid; /* cnode to link *to* */
ViceFid destFid; /* Directory in which to place link */
char *tname; /* Place holder for data. */
} cfs_link;
out
empty
Description
This call creates a link to the sourceFid in the directory
identified by destFid with name tname. The source must reside in the
target's parent, i.e. the source must be have parent destFid, i.e. Coda
does not support cross directory hard links. Only the return value is
relevant. It indicates success or the type of failure.
Errors
The usual errors can occur.
4.11. symlink
--------------
Summary
create a symbolic link
Arguments
in::
struct cfs_symlink_in {
ViceFid VFid; /* Directory to put symlink in */
char *srcname;
struct coda_vattr attr;
char *tname;
} cfs_symlink;
out
none
Description
Create a symbolic link. The link is to be placed in the
directory identified by VFid and named tname. It should point to the
pathname srcname. The attributes of the newly created object are to
be set to attr.
.. Note::
The attributes of the target directory should be returned since
its size changed.
4.12. remove
-------------
Summary
Remove a file
Arguments
in::
struct cfs_remove_in {
ViceFid VFid;
char *name; /* Place holder for data. */
} cfs_remove;
out
none
Description
Remove file named cfs_remove_in.name in directory
identified by VFid.
.. Note::
The attributes of the directory should be returned since its
mtime and size may change.
4.13. rmdir
------------
Summary
Remove a directory
Arguments
in::
struct cfs_rmdir_in {
ViceFid VFid;
char *name; /* Place holder for data. */
} cfs_rmdir;
out
none
Description
Remove the directory with name 'name' from the directory
identified by VFid.
.. Note:: The attributes of the parent directory should be returned since
its mtime and size may change.
4.14. readlink
---------------
Summary
Read the value of a symbolic link.
Arguments
in::
struct cfs_readlink_in {
ViceFid VFid;
} cfs_readlink;
out::
struct cfs_readlink_out {
int count;
caddr_t data; /* Place holder for data. */
} cfs_readlink;
Description
This routine reads the contents of symbolic link
identified by VFid into the buffer data. The buffer data must be able
to hold any name up to CFS_MAXNAMLEN (PATH or NAM??).
Errors
No unusual errors.
4.15. open
-----------
Summary
Open a file.
Arguments
in::
struct cfs_open_in {
ViceFid VFid;
int flags;
} cfs_open;
out::
struct cfs_open_out {
dev_t dev;
ino_t inode;
} cfs_open;
Description
This request asks Venus to place the file identified by
VFid in its cache and to note that the calling process wishes to open
it with flags as in open(2). The return value to the kernel differs
for Unix and Windows systems. For Unix systems the Coda FS Driver is
informed of the device and inode number of the container file in the
fields dev and inode. For Windows the path of the container file is
returned to the kernel.
.. Note::
Currently the cfs_open_out structure is not properly adapted to
deal with the Windows case. It might be best to implement two
upcalls, one to open aiming at a container file name, the other at a
container file inode.
4.16. close
------------
Summary
Close a file, update it on the servers.
Arguments
in::
struct cfs_close_in {
ViceFid VFid;
int flags;
} cfs_close;
out
none
Description
Close the file identified by VFid.
.. Note::
The flags argument is bogus and not used. However, Venus' code
has room to deal with an execp input field, probably this field should
be used to inform Venus that the file was closed but is still memory
mapped for execution. There are comments about fetching versus not
fetching the data in Venus vproc_vfscalls. This seems silly. If a
file is being closed, the data in the container file is to be the new
data. Here again the execp flag might be in play to create confusion:
currently Venus might think a file can be flushed from the cache when
it is still memory mapped. This needs to be understood.
4.17. ioctl
------------
Summary
Do an ioctl on a file. This includes the pioctl interface.
Arguments
in::
struct cfs_ioctl_in {
ViceFid VFid;
int cmd;
int len;
int rwflag;
char *data; /* Place holder for data. */
} cfs_ioctl;
out::
struct cfs_ioctl_out {
int len;
caddr_t data; /* Place holder for data. */
} cfs_ioctl;
Description
Do an ioctl operation on a file. The command, len and
data arguments are filled as usual. flags is not used by Venus.
.. Note::
Another bogus parameter. flags is not used. What is the
business about PREFETCHING in the Venus code?
4.18. rename
-------------
Summary
Rename a fid.
Arguments
in::
struct cfs_rename_in {
ViceFid sourceFid;
char *srcname;
ViceFid destFid;
char *destname;
} cfs_rename;
out
none
Description
Rename the object with name srcname in directory
sourceFid to destname in destFid. It is important that the names
srcname and destname are 0 terminated strings. Strings in Unix
kernels are not always null terminated.
4.19. readdir
--------------
Summary
Read directory entries.
Arguments
in::
struct cfs_readdir_in {
ViceFid VFid;
int count;
int offset;
} cfs_readdir;
out::
struct cfs_readdir_out {
int size;
caddr_t data; /* Place holder for data. */
} cfs_readdir;
Description
Read directory entries from VFid starting at offset and
read at most count bytes. Returns the data in data and returns
the size in size.
.. Note::
This call is not used. Readdir operations exploit container
files. We will re-evaluate this during the directory revamp which is
about to take place.
4.20. vget
-----------
Summary
instructs Venus to do an FSDB->Get.
Arguments
in::
struct cfs_vget_in {
ViceFid VFid;
} cfs_vget;
out::
struct cfs_vget_out {
ViceFid VFid;
int vtype;
} cfs_vget;
Description
This upcall asks Venus to do a get operation on an fsobj
labelled by VFid.
.. Note::
This operation is not used. However, it is extremely useful
since it can be used to deal with read/write memory mapped files.
These can be "pinned" in the Venus cache using vget and released with
inactive.
4.21. fsync
------------
Summary
Tell Venus to update the RVM attributes of a file.
Arguments
in::
struct cfs_fsync_in {
ViceFid VFid;
} cfs_fsync;
out
none
Description
Ask Venus to update RVM attributes of object VFid. This
should be called as part of kernel level fsync type calls. The
result indicates if the syncing was successful.
.. Note:: Linux does not implement this call. It should.
4.22. inactive
---------------
Summary
Tell Venus a vnode is no longer in use.
Arguments
in::
struct cfs_inactive_in {
ViceFid VFid;
} cfs_inactive;
out
none
Description
This operation returns EOPNOTSUPP.
.. Note:: This should perhaps be removed.
4.23. rdwr
-----------
Summary
Read or write from a file
Arguments
in::
struct cfs_rdwr_in {
ViceFid VFid;
int rwflag;
int count;
int offset;
int ioflag;
caddr_t data; /* Place holder for data. */
} cfs_rdwr;
out::
struct cfs_rdwr_out {
int rwflag;
int count;
caddr_t data; /* Place holder for data. */
} cfs_rdwr;
Description
This upcall asks Venus to read or write from a file.
.. Note::
It should be removed since it is against the Coda philosophy that
read/write operations never reach Venus. I have been told the
operation does not work. It is not currently used.
4.24. odymount
---------------
Summary
Allows mounting multiple Coda "filesystems" on one Unix mount point.
Arguments
in::
struct ody_mount_in {
char *name; /* Place holder for data. */
} ody_mount;
out::
struct ody_mount_out {
ViceFid VFid;
} ody_mount;
Description
Asks Venus to return the rootfid of a Coda system named
name. The fid is returned in VFid.
.. Note::
This call was used by David for dynamic sets. It should be
removed since it causes a jungle of pointers in the VFS mounting area.
It is not used by Coda proper. Call is not implemented by Venus.
4.25. ody_lookup
-----------------
Summary
Looks up something.
Arguments
in
irrelevant
out
irrelevant
.. Note:: Gut it. Call is not implemented by Venus.
4.26. ody_expand
-----------------
Summary
expands something in a dynamic set.
Arguments
in
irrelevant
out
irrelevant
.. Note:: Gut it. Call is not implemented by Venus.
4.27. prefetch
---------------
Summary
Prefetch a dynamic set.
Arguments
in
Not documented.
out
Not documented.
Description
Venus worker.cc has support for this call, although it is
noted that it doesn't work. Not surprising, since the kernel does not
have support for it. (ODY_PREFETCH is not a defined operation).
.. Note:: Gut it. It isn't working and isn't used by Coda.
4.28. signal
-------------
Summary
Send Venus a signal about an upcall.
Arguments
in
none
out
not applicable.
Description
This is an out-of-band upcall to Venus to inform Venus
that the calling process received a signal after Venus read the
message from the input queue. Venus is supposed to clean up the
operation.
Errors
No reply is given.
.. Note::
We need to better understand what Venus needs to clean up and if
it is doing this correctly. Also we need to handle multiple upcall
per system call situations correctly. It would be important to know
what state changes in Venus take place after an upcall for which the
kernel is responsible for notifying Venus to clean up (e.g. open
definitely is such a state change, but many others are maybe not).
5. The minicache and downcalls
===============================
The Coda FS Driver can cache results of lookup and access upcalls, to
limit the frequency of upcalls. Upcalls carry a price since a process
context switch needs to take place. The counterpart of caching the
information is that Venus will notify the FS Driver that cached
entries must be flushed or renamed.
The kernel code generally has to maintain a structure which links the
internal file handles (called vnodes in BSD, inodes in Linux and
FileHandles in Windows) with the ViceFid's which Venus maintains. The
reason is that frequent translations back and forth are needed in
order to make upcalls and use the results of upcalls. Such linking
objects are called cnodes.
The current minicache implementations have cache entries which record
the following:
1. the name of the file
2. the cnode of the directory containing the object
3. a list of CodaCred's for which the lookup is permitted.
4. the cnode of the object
The lookup call in the Coda FS Driver may request the cnode of the
desired object from the cache, by passing its name, directory and the
CodaCred's of the caller. The cache will return the cnode or indicate
that it cannot be found. The Coda FS Driver must be careful to
invalidate cache entries when it modifies or removes objects.
When Venus obtains information that indicates that cache entries are
no longer valid, it will make a downcall to the kernel. Downcalls are
intercepted by the Coda FS Driver and lead to cache invalidations of
the kind described below. The Coda FS Driver does not return an error
unless the downcall data could not be read into kernel memory.
5.1. INVALIDATE
----------------
No information is available on this call.
5.2. FLUSH
-----------
Arguments
None
Summary
Flush the name cache entirely.
Description
Venus issues this call upon startup and when it dies. This
is to prevent stale cache information being held. Some operating
systems allow the kernel name cache to be switched off dynamically.
When this is done, this downcall is made.
5.3. PURGEUSER
---------------
Arguments
::
struct cfs_purgeuser_out {/* CFS_PURGEUSER is a venus->kernel call */
struct CodaCred cred;
} cfs_purgeuser;
Description
Remove all entries in the cache carrying the Cred. This
call is issued when tokens for a user expire or are flushed.
5.4. ZAPFILE
-------------
Arguments
::
struct cfs_zapfile_out { /* CFS_ZAPFILE is a venus->kernel call */
ViceFid CodaFid;
} cfs_zapfile;
Description
Remove all entries which have the (dir vnode, name) pair.
This is issued as a result of an invalidation of cached attributes of
a vnode.
.. Note::
Call is not named correctly in NetBSD and Mach. The minicache
zapfile routine takes different arguments. Linux does not implement
the invalidation of attributes correctly.
5.5. ZAPDIR
------------
Arguments
::
struct cfs_zapdir_out { /* CFS_ZAPDIR is a venus->kernel call */
ViceFid CodaFid;
} cfs_zapdir;
Description
Remove all entries in the cache lying in a directory
CodaFid, and all children of this directory. This call is issued when
Venus receives a callback on the directory.
5.6. ZAPVNODE
--------------
Arguments
::
struct cfs_zapvnode_out { /* CFS_ZAPVNODE is a venus->kernel call */
struct CodaCred cred;
ViceFid VFid;
} cfs_zapvnode;
Description
Remove all entries in the cache carrying the cred and VFid
as in the arguments. This downcall is probably never issued.
5.7. PURGEFID
--------------
Arguments
::
struct cfs_purgefid_out { /* CFS_PURGEFID is a venus->kernel call */
ViceFid CodaFid;
} cfs_purgefid;
Description
Flush the attribute for the file. If it is a dir (odd
vnode), purge its children from the namecache and remove the file from the
namecache.
5.8. REPLACE
-------------
Summary
Replace the Fid's for a collection of names.
Arguments
::
struct cfs_replace_out { /* cfs_replace is a venus->kernel call */
ViceFid NewFid;
ViceFid OldFid;
} cfs_replace;
Description
This routine replaces a ViceFid in the name cache with
another. It is added to allow Venus during reintegration to replace
locally allocated temp fids while disconnected with global fids even
when the reference counts on those fids are not zero.
6. Initialization and cleanup
==============================
This section gives brief hints as to desirable features for the Coda
FS Driver at startup and upon shutdown or Venus failures. Before
entering the discussion it is useful to repeat that the Coda FS Driver
maintains the following data:
1. message queues
2. cnodes
3. name cache entries
The name cache entries are entirely private to the driver, so they
can easily be manipulated. The message queues will generally have
clear points of initialization and destruction. The cnodes are
much more delicate. User processes hold reference counts in Coda
filesystems and it can be difficult to clean up the cnodes.
It can expect requests through:
1. the message subsystem
2. the VFS layer
3. pioctl interface
Currently the pioctl passes through the VFS for Coda so we can
treat these similarly.
6.1. Requirements
------------------
The following requirements should be accommodated:
1. The message queues should have open and close routines. On Unix
the opening of the character devices are such routines.
- Before opening, no messages can be placed.
- Opening will remove any old messages still pending.
- Close will notify any sleeping processes that their upcall cannot
be completed.
- Close will free all memory allocated by the message queues.
2. At open the namecache shall be initialized to empty state.
3. Before the message queues are open, all VFS operations will fail.
Fortunately this can be achieved by making sure than mounting the
Coda filesystem cannot succeed before opening.
4. After closing of the queues, no VFS operations can succeed. Here
one needs to be careful, since a few operations (lookup,
read/write, readdir) can proceed without upcalls. These must be
explicitly blocked.
5. Upon closing the namecache shall be flushed and disabled.
6. All memory held by cnodes can be freed without relying on upcalls.
7. Unmounting the file system can be done without relying on upcalls.
8. Mounting the Coda filesystem should fail gracefully if Venus cannot
get the rootfid or the attributes of the rootfid. The latter is
best implemented by Venus fetching these objects before attempting
to mount.
.. Note::
NetBSD in particular but also Linux have not implemented the
above requirements fully. For smooth operation this needs to be
corrected.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
문서 범위와 인터페이스 목차
1-94이 기술 문서는 Coda 구성요소 가운데 client kernel과 userspace cache manager Venus 사이의 interface를 설명합니다. 추가 정보는 `http://www.coda.cs.cmu.edu`, Coda 실행에 필요한 user-level software는 `ftp://ftp.coda.cs.cmu.edu`에서 안내합니다.
Coda client를 실행하려면 Venus라는 user-level cache manager와 ACL 조작·login 도구가 필요하고, kernel configuration에서 Coda filesystem을 선택해야 합니다. server는 user-level server가 필요하지만 이 문서 작성 당시에는 kernel support에 의존하지 않습니다.
문서 제목은 Peter J. Braam이 작성한 ‘The Venus kernel interface’이며 version 1.0, 1997년 11월 9일자입니다. 현재 interface와 당시 예상한 개선점을 함께 기록하므로, 뒤의 ‘제거해야 한다’거나 ‘Linux가 구현하지 않았다’는 문장은 protocol 당시 상태에 대한 역사적 주석으로 읽어야 합니다.
목차는 introduction, Coda filesystem call 처리, message layer와 구현 세부, call-level interface, minicache와 Venus→kernel downcall, initialization·cleanup으로 구성됩니다. call-level interface는 shared data structure와 pioctl 뒤에 `root`, `lookup`, `getattr`, `setattr`, `access`, 생성·삭제·link 계열, `open`, `close`, `ioctl`, `rename`, `readdir`, `vget`, `fsync`, `inactive`, `rdwr`, Odyssey 동적 집합 호출, `prefetch`, `signal`을 다룹니다.
minicache downcall은 `INVALIDATE`, `FLUSH`, `PURGEUSER`, `ZAPFILE`, `ZAPDIR`, `ZAPVNODE`, `PURGEFID`, `REPLACE`를 설명합니다. 마지막으로 message queue, cnode, name cache가 Venus 시작·종료·실패에서 지켜야 할 요구사항을 열거합니다.
kernel에서 Venus로 가는 upcall과 반대 방향 downcall을 중심으로 문서 영역을 구분합니다.
.. SPDX-License-Identifier: GPL-2.0
===========================
Coda Kernel-Venus Interface
===========================
.. Note::
This is one of the technical documents describing a component of
Coda -- this document describes the client kernel-Venus interface.
For more information:
http://www.coda.cs.cmu.edu
For user level software needed to run Coda:
ftp://ftp.coda.cs.cmu.edu
To run Coda you need to get a user level cache manager for the client,
named Venus, as well as tools to manipulate ACLs, to log in, etc. The
client needs to have the Coda filesystem selected in the kernel
configuration.
The server needs a user level server and at present does not depend on
kernel support.
The Venus kernel interface
Peter J. Braam
v1.0, Nov 9, 1997
This document describes the communication between Venus and kernel
level filesystem code needed for the operation of the Coda file sys-
tem. This document version is meant to describe the current interface
(version 1.0) as well as improvements we envisage.
.. Table of Contents
1. Introduction
2. Servicing Coda filesystem calls
3. The message layer
3.1 Implementation details
4. The interface at the call level
4.1 Data structures shared by the kernel and Venus
4.2 The pioctl interface
4.3 root
4.4 lookup
4.5 getattr
4.6 setattr
4.7 access
4.8 create
4.9 mkdir
4.10 link
4.11 symlink
4.12 remove
4.13 rmdir
4.14 readlink
4.15 open
4.16 close
4.17 ioctl
4.18 rename
4.19 readdir
4.20 vget
4.21 fsync
4.22 inactive
4.23 rdwr
4.24 odymount
4.25 ody_lookup
4.26 ody_expand
4.27 prefetch
4.28 signal
5. The minicache and downcalls
5.1 INVALIDATE
5.2 FLUSH
5.3 PURGEUSER
5.4 ZAPFILE
5.5 ZAPDIR
5.6 ZAPVNODE
5.7 PURGEFID
5.8 REPLACE
6. Initialization and cleanup
6.1 Requirements
Coda 요청 처리와 세 인터페이스
95-201Coda distributed filesystem의 핵심은 cache manager Venus입니다. Coda를 사용하는 process가 파일에 접근하면 운영체제 filesystem layer가 요청을 받고 Venus와 통신합니다. Venus는 persistent client cache를 관리하고 Coda file server와 authentication server 같은 관련 server에 RPC를 보내 요청을 처리한 뒤 kernel에 return code와 관련 데이터를 돌려줍니다.
kernel의 Coda support는 최근 처리한 요청의 minicache를 선택적으로 유지해 Venus와의 상호작용을 줄일 수 있습니다. Venus는 minicache 항목이 더 이상 유효하지 않을 때 kernel에 알릴 수 있습니다. 이 문서는 이 kernel-Venus 통신, upcall·downcall의 데이터 형식과 호출에서 생기는 semantic invariant를 정의합니다.
Coda는 역사적으로 Mach 2.6의 BSD filesystem에 구현되어 kernel-Venus interface가 BSD VFS와 매우 비슷합니다. 기능과 parameter·return data 형식도 BSD VFS와 유사해 BSD에서는 kernel driver 구현이 자연스럽지만 Linux, Windows 95, Windows NT는 서로 다른 virtual filesystem interface를 사용합니다. 다른 OS로 port하려면 protocol을 세밀히 문서화하고 일부 최적화·수정이 필요했습니다.
요청은 Coda file에 접근하는 process P의 system call에서 시작합니다. Unix의 `read`, `write`, `open`, `close`, `create`, `mkdir`, `rmdir`, `chmod`와 Win32의 `CreateFile`이 예입니다. system call은 kernel로 trap되고, Unix의 VFS, NT의 I/O Manager, Windows 95의 IFS manager가 path를 바탕으로 담당 filesystem driver를 찾아 전처리 뒤 Coda FS driver의 exported routine을 호출합니다.
Coda FS layer는 해당 OS의 VFS interface를 구현해야 합니다. OS마다 형태는 크게 다르지만 object read/write·create·remove 같은 기능은 공통입니다. driver는 VFS 요청을 하나 이상의 Venus service upcall로 처리하고, reply가 오면 VFS 처리를 끝내 process에 결과를 반환합니다.
첫 번째 필수 interface는 Venus가 message traffic을 관리하는 통로입니다. Venus는 message를 가져오고 넣을 수 있어야 하며 새 message 도착을 통지받아야 합니다. 기다리는 message가 없어도 Venus가 다른 task를 수행해야 하므로 notification mechanism이 Venus를 block해서는 안 됩니다.
두 번째는 user process와 Venus 사이의 특수 통신 경로인 pioctl입니다. persistent cache 상세 정보 같은 Coda-specific service에 사용합니다. kernel은 calling process를 식별하고 데이터를 Venus에 전달하며 Venus reply를 수정하지 않고 caller에게 돌려주는 최소한의 역할만 합니다.
세 번째는 lookup·access 같은 Venus service 결과의 kernel cache입니다. context switch를 줄여 효율을 높이지만, Venus가 network에서 새 정보를 얻어 cached information을 flush하거나 replace해야 하면 Coda FS layer에 downcall을 보냅니다. driver는 이 요청을 동기적으로 처리합니다.
VFS interface와 message 송수신·notification은 platform-specific입니다. 이 문서는 VFS에 export하는 개별 OS call 대신 message exchange mechanism의 공통 요구사항을 기술합니다.
process의 VFS 요청이 Venus RPC와 kernel minicache를 거쳐 돌아오는 경로입니다.
1. Introduction
===============
A key component in the Coda Distributed File System is the cache
manager, Venus.
When processes on a Coda enabled system access files in the Coda
filesystem, requests are directed at the filesystem layer in the
operating system. The operating system will communicate with Venus to
service the request for the process. Venus manages a persistent
client cache and makes remote procedure calls to Coda file servers and
related servers (such as authentication servers) to service these
requests it receives from the operating system. When Venus has
serviced a request it replies to the operating system with appropriate
return codes, and other data related to the request. Optionally the
kernel support for Coda may maintain a minicache of recently processed
requests to limit the number of interactions with Venus. Venus
possesses the facility to inform the kernel when elements from its
minicache are no longer valid.
This document describes precisely this communication between the
kernel and Venus. The definitions of so called upcalls and downcalls
will be given with the format of the data they handle. We shall also
describe the semantic invariants resulting from the calls.
Historically Coda was implemented in a BSD file system in Mach 2.6.
The interface between the kernel and Venus is very similar to the BSD
VFS interface. Similar functionality is provided, and the format of
the parameters and returned data is very similar to the BSD VFS. This
leads to an almost natural environment for implementing a kernel-level
filesystem driver for Coda in a BSD system. However, other operating
systems such as Linux and Windows 95 and NT have virtual filesystem
with different interfaces.
To implement Coda on these systems some reverse engineering of the
Venus/Kernel protocol is necessary. Also it came to light that other
systems could profit significantly from certain small optimizations
and modifications to the protocol. To facilitate this work as well as
to make future ports easier, communication between Venus and the
kernel should be documented in great detail. This is the aim of this
document.
2. Servicing Coda filesystem calls
===================================
The service of a request for a Coda file system service originates in
a process P which accessing a Coda file. It makes a system call which
traps to the OS kernel. Examples of such calls trapping to the kernel
are ``read``, ``write``, ``open``, ``close``, ``create``, ``mkdir``,
``rmdir``, ``chmod`` in a Unix context. Similar calls exist in the Win32
environment, and are named ``CreateFile``.
Generally the operating system handles the request in a virtual
filesystem (VFS) layer, which is named I/O Manager in NT and IFS
manager in Windows 95. The VFS is responsible for partial processing
of the request and for locating the specific filesystem(s) which will
service parts of the request. Usually the information in the path
assists in locating the correct FS drivers. Sometimes after extensive
pre-processing, the VFS starts invoking exported routines in the FS
driver. This is the point where the FS specific processing of the
request starts, and here the Coda specific kernel code comes into
play.
The FS layer for Coda must expose and implement several interfaces.
First and foremost the VFS must be able to make all necessary calls to
the Coda FS layer, so the Coda FS driver must expose the VFS interface
as applicable in the operating system. These differ very significantly
among operating systems, but share features such as facilities to
read/write and create and remove objects. The Coda FS layer services
such VFS requests by invoking one or more well defined services
offered by the cache manager Venus. When the replies from Venus have
come back to the FS driver, servicing of the VFS call continues and
finishes with a reply to the kernel's VFS. Finally the VFS layer
returns to the process.
As a result of this design a basic interface exposed by the FS driver
must allow Venus to manage message traffic. In particular Venus must
be able to retrieve and place messages and to be notified of the
arrival of a new message. The notification must be through a mechanism
which does not block Venus since Venus must attend to other tasks even
when no messages are waiting or being processed.
**Interfaces of the Coda FS Driver**
Furthermore the FS layer provides for a special path of communication
between a user process and Venus, called the pioctl interface. The
pioctl interface is used for Coda specific services, such as
requesting detailed information about the persistent cache managed by
Venus. Here the involvement of the kernel is minimal. It identifies
the calling process and passes the information on to Venus. When
Venus replies the response is passed back to the caller in unmodified
form.
Finally Venus allows the kernel FS driver to cache the results from
certain services. This is done to avoid excessive context switches
and results in an efficient system. However, Venus may acquire
information, for example from the network which implies that cached
information must be flushed or replaced. Venus then makes a downcall
to the Coda FS layer to request flushes or updates in the cache. The
kernel FS driver handles such requests synchronously.
Among these interfaces the VFS interface and the facility to place,
receive and be notified of messages are platform specific. We will
not go into the calls exported to the VFS layer but we will state the
requirements of the message exchange mechanism.
Message queue, 동기화와 signal
202-308가장 낮은 계층에서 Venus와 FS driver는 message로 통신합니다. process P를 대신해 driver가 VFS·pioctl 요청을 처리하고 Venus message를 만든 뒤 reply를 기다리므로, 동기화는 process block과 wakeup에 의존합니다. platform별 구현은 달라도 의미는 공통이며, driver는 P를 대신해 kernel memory에 data buffer를 만들고 Venus가 사용할 user memory로 복사합니다.
upcall message structure에는 P의 식별 정보, message sequence number, request size, kernel request buffer pointer, 같은 buffer를 reply에 재사용하기 위한 reply size, 정확한 상태를 기록할 flags가 있습니다. queue 위치와 synchronization object pointer 같은 platform-dependent 필드도 붙습니다. upcall은 flags를 0으로 초기화하고 message를 `pending` queue에 넣습니다. data buffer 할당 책임은 caller에게 있습니다.
OS의 synchronization object로 Venus에 새 message를 알려야 합니다. pending queue에 놓인 뒤 P의 calling thread는 Venus reply가 올 때까지 upcall에서 block되며, message 안의 pointer가 P가 sleep하는 synchronization object를 가리킵니다.
Venus는 notification을 감지하고 `getmsg_from_kernel`로 message를 가져갑니다. kernel은 message를 processing queue로 옮기고 flags를 `READ`로 설정한 뒤 data buffer 내용을 Venus에 넘깁니다.
Venus가 `sendmsg_to_kernel`을 호출하면 driver는 message가 suspended P의 reply인지 downcall인지 구분합니다. reply라면 processing queue에서 제거하고 `WRITTEN`으로 표시한 뒤 P를 unblock합니다. P가 나중에 schedule되면 buffer가 Venus reply로 바뀐 상태에서 upcall을 계속합니다. downcall이면 cache eviction·replacement 같은 요청을 즉시 동기 처리한 후 Venus에 반환합니다.
P가 깨어나면 Venus가 깨운 정상 경우인지 termination 같은 외부 signal인지 확인합니다. 정상 reply면 message structure를 해제하고 filesystem routine을 계속합니다.
외부 signal로 깨어났고 message가 아직 `READ`가 아니면 Venus에 알리지 않고 signal을 처리할 수 있습니다. Venus가 이미 읽었지만 작업을 취소해야 한다면 이전 message를 무시하라는 signal message를 queue 맨 앞에 넣습니다. 이미 `WRITTEN`이면 중단하기 늦었으므로 VFS routine이 계속됩니다. system call 하나가 여러 upcall을 포함하면 point of no return을 추적할 `handle_signals` 같은 필드가 필요할 수 있다는 주석이 있습니다.
Unix 구현은 Coda character device를 사용합니다. Venus는 device `read`로 message를 가져오고 `write`로 reply하며, file descriptor의 `select`로 도착 notification을 받습니다. P는 interruptible wait queue에서 기다립니다.
Windows NT와 DPMI Windows 95는 `DeviceIoControl`로 opcode와 buffer를 user↔kernel memory 사이에 복사합니다. `sendmsg_to_kernel`은 synchronous, `getmsg_from_kernel`은 asynchronous call이며 Windows EventObject로 message arrival을 통지합니다. P는 NT에서 KernelEvent, Windows 95에서 semaphore를 기다립니다.
pending부터 reply 또는 signal 경합까지의 상태 변화를 정리합니다.
3. The message layer
=====================
At the lowest level the communication between Venus and the FS driver
proceeds through messages. The synchronization between processes
requesting Coda file service and Venus relies on blocking and waking
up processes. The Coda FS driver processes VFS- and pioctl-requests
on behalf of a process P, creates messages for Venus, awaits replies
and finally returns to the caller. The implementation of the exchange
of messages is platform specific, but the semantics have (so far)
appeared to be generally applicable. Data buffers are created by the
FS Driver in kernel memory on behalf of P and copied to user memory in
Venus.
The FS Driver while servicing P makes upcalls to Venus. Such an
upcall is dispatched to Venus by creating a message structure. The
structure contains the identification of P, the message sequence
number, the size of the request and a pointer to the data in kernel
memory for the request. Since the data buffer is re-used to hold the
reply from Venus, there is a field for the size of the reply. A flags
field is used in the message to precisely record the status of the
message. Additional platform dependent structures involve pointers to
determine the position of the message on queues and pointers to
synchronization objects. In the upcall routine the message structure
is filled in, flags are set to 0, and it is placed on the *pending*
queue. The routine calling upcall is responsible for allocating the
data buffer; its structure will be described in the next section.
A facility must exist to notify Venus that the message has been
created, and implemented using available synchronization objects in
the OS. This notification is done in the upcall context of the process
P. When the message is on the pending queue, process P cannot proceed
in upcall. The (kernel mode) processing of P in the filesystem
request routine must be suspended until Venus has replied. Therefore
the calling thread in P is blocked in upcall. A pointer in the
message structure will locate the synchronization object on which P is
sleeping.
Venus detects the notification that a message has arrived, and the FS
driver allow Venus to retrieve the message with a getmsg_from_kernel
call. This action finishes in the kernel by putting the message on the
queue of processing messages and setting flags to READ. Venus is
passed the contents of the data buffer. The getmsg_from_kernel call
now returns and Venus processes the request.
At some later point the FS driver receives a message from Venus,
namely when Venus calls sendmsg_to_kernel. At this moment the Coda FS
driver looks at the contents of the message and decides if:
* the message is a reply for a suspended thread P. If so it removes
the message from the processing queue and marks the message as
WRITTEN. Finally, the FS driver unblocks P (still in the kernel
mode context of Venus) and the sendmsg_to_kernel call returns to
Venus. The process P will be scheduled at some point and continues
processing its upcall with the data buffer replaced with the reply
from Venus.
* The message is a ``downcall``. A downcall is a request from Venus to
the FS Driver. The FS driver processes the request immediately
(usually a cache eviction or replacement) and when it finishes
sendmsg_to_kernel returns.
Now P awakes and continues processing upcall. There are some
subtleties to take account of. First P will determine if it was woken
up in upcall by a signal from some other source (for example an
attempt to terminate P) or as is normally the case by Venus in its
sendmsg_to_kernel call. In the normal case, the upcall routine will
deallocate the message structure and return. The FS routine can proceed
with its processing.
**Sleeping and IPC arrangements**
In case P is woken up by a signal and not by Venus, it will first look
at the flags field. If the message is not yet READ, the process P can
handle its signal without notifying Venus. If Venus has READ, and
the request should not be processed, P can send Venus a signal message
to indicate that it should disregard the previous message. Such
signals are put in the queue at the head, and read first by Venus. If
the message is already marked as WRITTEN it is too late to stop the
processing. The VFS routine will now continue. (-- If a VFS request
involves more than one upcall, this can lead to complicated state, an
extra field "handle_signals" could be added in the message structure
to indicate points of no return have been passed.--)
3.1. Implementation details
----------------------------
The Unix implementation of this mechanism has been through the
implementation of a character device associated with Coda. Venus
retrieves messages by doing a read on the device, replies are sent
with a write and notification is through the select system call on the
file descriptor for the device. The process P is kept waiting on an
interruptible wait queue object.
In Windows NT and the DPMI Windows 95 implementation a DeviceIoControl
call is used. The DeviceIoControl call is designed to copy buffers
from user memory to kernel memory with OPCODES. The sendmsg_to_kernel
is issued as a synchronous call, while the getmsg_from_kernel call is
asynchronous. Windows EventObjects are used for notification of
message arrival. The process P is kept waiting on a KernelEvent
object in NT and a semaphore in Windows 95.
root·lookup·getattr·setattr
474-626`root` upcall은 Coda filesystem 초기화 중 호출됩니다. input은 비어 있고 성공하면 `cfs_root_out.VFid`에 filesystem root의 `ViceFid`가 들어갑니다. 실패하면 Venus가 root를 찾지 못한 이유를 나타내는 platform-dependent error code를 반환합니다.
`lookup`은 parent directory의 `VFid`와 `name`을 받아 entry의 `ViceFid`와 `vtype`을 찾습니다. 이름이 없거나 disconnect 등으로 검색할 수 없으면 오류가 되고, 성공하면 target fid와 `coda_vtype`을 반환합니다. name은 terminator를 포함해 최대 `CFS_MAXNAMLEN`, 당시 256자의 8-bit 문자열입니다.
Venus는 `cfs_lookup.vtype`에 `CFS_NOCACHE`를 bitwise OR해 kernel name cache에 넣지 말아야 할 객체를 표시합니다. 원문은 vtype의 선언형이 `coda_vtype`이어야 하며 당시 Linux가 `CFS_NOCACHE`를 반영하지 않는 문제를 지적합니다.
`getattr`은 `VFid`로 식별한 파일의 `coda_vattr`을 반환합니다. 객체가 없거나 접근할 수 없거나 caller에게 attribute 조회 권한이 없으면 오류입니다. 여러 OS driver가 internal inode·FileHandle 생성에 fid와 attribute를 함께 필요로 하므로, Venus/kernel과 RPC 계층에서 `lookup`과 `getattr`을 결합하면 성능을 크게 높일 수 있다는 제안이 있습니다. input의 `attr`은 불필요하므로 제거해야 한다고 적습니다.
`setattr`은 `VFid`와 변경할 `coda_vattr`을 보냅니다. BSD 방식으로 바꾸지 않을 attribute는 `-1`, `vtype`은 `VNON`으로 두고 변경할 값만 설정합니다. FS driver가 변경 요청할 수 있는 것은 mode, owner, groupid, atime, mtime, ctime입니다. 객체 부재·접근 불가·Venus permission 거부가 오류가 될 수 있습니다.
초기화와 pathname 해석에 필요한 네 호출의 입출력을 비교합니다.
4.3. root
----------
Arguments
in
empty
out::
struct cfs_root_out {
ViceFid VFid;
} cfs_root;
Description
This call is made to Venus during the initialization of
the Coda filesystem. If the result is zero, the cfs_root structure
contains the ViceFid of the root of the Coda filesystem. If a non-zero
result is generated, its value is a platform dependent error code
indicating the difficulty Venus encountered in locating the root of
the Coda filesystem.
4.4. lookup
------------
Summary
Find the ViceFid and type of an object in a directory if it exists.
Arguments
in::
struct cfs_lookup_in {
ViceFid VFid;
char *name; /* Place holder for data. */
} cfs_lookup;
out::
struct cfs_lookup_out {
ViceFid VFid;
int vtype;
} cfs_lookup;
Description
This call is made to determine the ViceFid and filetype of
a directory entry. The directory entry requested carries name 'name'
and Venus will search the directory identified by cfs_lookup_in.VFid.
The result may indicate that the name does not exist, or that
difficulty was encountered in finding it (e.g. due to disconnection).
If the result is zero, the field cfs_lookup_out.VFid contains the
targets ViceFid and cfs_lookup_out.vtype the coda_vtype giving the
type of object the name designates.
The name of the object is an 8 bit character string of maximum length
CFS_MAXNAMLEN, currently set to 256 (including a 0 terminator.)
It is extremely important to realize that Venus bitwise ors the field
cfs_lookup.vtype with CFS_NOCACHE to indicate that the object should
not be put in the kernel name cache.
.. Note::
The type of the vtype is currently wrong. It should be
coda_vtype. Linux does not take note of CFS_NOCACHE. It should.
4.5. getattr
-------------
Summary Get the attributes of a file.
Arguments
in::
struct cfs_getattr_in {
ViceFid VFid;
struct coda_vattr attr; /* XXXXX */
} cfs_getattr;
out::
struct cfs_getattr_out {
struct coda_vattr attr;
} cfs_getattr;
Description
This call returns the attributes of the file identified by fid.
Errors
Errors can occur if the object with fid does not exist, is
unaccessible or if the caller does not have permission to fetch
attributes.
.. Note::
Many kernel FS drivers (Linux, NT and Windows 95) need to acquire
the attributes as well as the Fid for the instantiation of an internal
"inode" or "FileHandle". A significant improvement in performance on
such systems could be made by combining the lookup and getattr calls
both at the Venus/kernel interaction level and at the RPC level.
The vattr structure included in the input arguments is superfluous and
should be removed.
4.6. setattr
-------------
Summary
Set the attributes of a file.
Arguments
in::
struct cfs_setattr_in {
ViceFid VFid;
struct coda_vattr attr;
} cfs_setattr;
out
empty
Description
The structure attr is filled with attributes to be changed
in BSD style. Attributes not to be changed are set to -1, apart from
vtype which is set to VNON. Other are set to the value to be assigned.
The only attributes which the FS driver may request to change are the
mode, owner, groupid, atime, mtime and ctime. The return value
indicates success or failure.
Errors
A variety of errors can occur. The object may not exist, may
be inaccessible, or permission may not be granted by Venus.
access·create·mkdir·hard link
627-799`access`는 `VFid` 객체에 `flags`가 나타내는 operation을 허용할지 검증합니다. Coda protection은 ACL을 사용하고 궁극적인 enforcement는 client가 아니라 server가 수행합니다. 결과는 user가 token을 보유했는지에 따라 달라집니다. 객체나 protection ACL에 접근할 수 없으면 오류입니다.
`create`는 parent directory `VFid`, `coda_vattr`, `excl`, `mode`, `name`으로 file 생성을 요청합니다. `excl`이면 기존 파일이 있을 때 오류이고 `attr.size`가 0이면 파일을 truncate합니다. uid와 gid는 platform-dependent `CRTOUID` macro로 `CodaCred`를 변환해 정합니다. 성공하면 새 file의 `ViceFid`와 attributes를 반환해 kernel이 vnode·inode·file handle을 만들 수 있습니다. 권한 부족이나 기존 객체가 directory인 경우 Unix에서 `EISDIR` 등이 발생합니다.
원문은 `create` parameter packing이 비효율적이며 system call `creat`와 VFS `create`가 혼동된 흔적이라고 지적합니다. VFS create는 새 객체만 만들므로 truncate·exclusive·mode를 별도 field로 둘 필요가 없고, file descriptor read/write mode용 flags도 필요 없다고 봅니다. parent directory의 size와 mtime이 바뀌므로 그 attributes도 반환해야 한다는 개선안이 있습니다.
`mkdir`은 create와 비슷하지만 directory를 만듭니다. input attribute 중 mode만 생성에 사용하고 성공하면 새 directory의 fid와 attributes를 반환합니다. input은 전체 attributes 대신 mode만 받아야 하며 parent의 size·mtime 변경도 반환해야 한다는 주석이 있습니다. 오류는 create와 같습니다.
`link`는 `sourceFid` 파일을 `destFid` directory 안에 `tname`으로 hard link합니다. source는 target parent인 `destFid` 안에 있어야 하므로 Coda는 cross-directory hard link를 지원하지 않습니다. output data 없이 result가 성공 또는 실패 종류를 나타냅니다.
ACL 확인에서 새 kernel object 생성과 parent metadata 갱신까지의 단계입니다.
4.7. access
------------
Arguments
in::
struct cfs_access_in {
ViceFid VFid;
int flags;
} cfs_access;
out
empty
Description
Verify if access to the object identified by VFid for
operations described by flags is permitted. The result indicates if
access will be granted. It is important to remember that Coda uses
ACLs to enforce protection and that ultimately the servers, not the
clients enforce the security of the system. The result of this call
will depend on whether a token is held by the user.
Errors
The object may not exist, or the ACL describing the protection
may not be accessible.
4.8. create
------------
Summary
Invoked to create a file
Arguments
in::
struct cfs_create_in {
ViceFid VFid;
struct coda_vattr attr;
int excl;
int mode;
char *name; /* Place holder for data. */
} cfs_create;
out::
struct cfs_create_out {
ViceFid VFid;
struct coda_vattr attr;
} cfs_create;
Description
This upcall is invoked to request creation of a file.
The file will be created in the directory identified by VFid, its name
will be name, and the mode will be mode. If excl is set an error will
be returned if the file already exists. If the size field in attr is
set to zero the file will be truncated. The uid and gid of the file
are set by converting the CodaCred to a uid using a macro CRTOUID
(this macro is platform dependent). Upon success the VFid and
attributes of the file are returned. The Coda FS Driver will normally
instantiate a vnode, inode or file handle at kernel level for the new
object.
Errors
A variety of errors can occur. Permissions may be insufficient.
If the object exists and is not a file the error EISDIR is returned
under Unix.
.. Note::
The packing of parameters is very inefficient and appears to
indicate confusion between the system call creat and the VFS operation
create. The VFS operation create is only called to create new objects.
This create call differs from the Unix one in that it is not invoked
to return a file descriptor. The truncate and exclusive options,
together with the mode, could simply be part of the mode as it is
under Unix. There should be no flags argument; this is used in open
(2) to return a file descriptor for READ or WRITE mode.
The attributes of the directory should be returned too, since the size
and mtime changed.
4.9. mkdir
-----------
Summary
Create a new directory.
Arguments
in::
struct cfs_mkdir_in {
ViceFid VFid;
struct coda_vattr attr;
char *name; /* Place holder for data. */
} cfs_mkdir;
out::
struct cfs_mkdir_out {
ViceFid VFid;
struct coda_vattr attr;
} cfs_mkdir;
Description
This call is similar to create but creates a directory.
Only the mode field in the input parameters is used for creation.
Upon successful creation, the attr returned contains the attributes of
the new directory.
Errors
As for create.
.. Note::
The input parameter should be changed to mode instead of
attributes.
The attributes of the parent should be returned since the size and
mtime changes.
4.10. link
-----------
Summary
Create a link to an existing file.
Arguments
in::
struct cfs_link_in {
ViceFid sourceFid; /* cnode to link *to* */
ViceFid destFid; /* Directory in which to place link */
char *tname; /* Place holder for data. */
} cfs_link;
out
empty
Description
This call creates a link to the sourceFid in the directory
identified by destFid with name tname. The source must reside in the
target's parent, i.e. the source must be have parent destFid, i.e. Coda
does not support cross directory hard links. Only the return value is
relevant. It indicates success or the type of failure.
Errors
The usual errors can occur.
symlink·remove·rmdir·readlink
800-929`symlink`는 `VFid` directory 안에 `tname`이라는 symbolic link를 만들고 그 대상 pathname을 `srcname`으로 설정하며 새 객체 attributes는 `attr`에서 가져옵니다. output은 없습니다. target directory의 size가 변하므로 attributes를 반환해야 한다는 주석이 있습니다.
`remove`는 `VFid` directory에서 `name` 파일을 제거하고 output은 없습니다. directory의 mtime과 size가 변할 수 있으므로 parent attributes를 반환해야 한다고 명세는 제안합니다.
`rmdir`도 같은 모양으로 parent `VFid`에서 `name` directory를 제거하며 output은 없습니다. 역시 parent mtime·size가 변하므로 attributes 반환이 필요하다는 주석이 있습니다.
`readlink`는 symbolic link의 `VFid`를 받아 내용을 output buffer `data`에 읽고 길이를 `count`로 반환합니다. buffer는 최대 `CFS_MAXNAMLEN`의 이름을 담을 수 있어야 합니다. 원문은 이것이 path 한도인지 name 한도인지 `PATH or NAM??`로 미확정 상태를 남겼으며 특별한 오류는 없다고 합니다.
각 호출이 받는 parent·target과 개선 주석을 정리합니다.
4.11. symlink
--------------
Summary
create a symbolic link
Arguments
in::
struct cfs_symlink_in {
ViceFid VFid; /* Directory to put symlink in */
char *srcname;
struct coda_vattr attr;
char *tname;
} cfs_symlink;
out
none
Description
Create a symbolic link. The link is to be placed in the
directory identified by VFid and named tname. It should point to the
pathname srcname. The attributes of the newly created object are to
be set to attr.
.. Note::
The attributes of the target directory should be returned since
its size changed.
4.12. remove
-------------
Summary
Remove a file
Arguments
in::
struct cfs_remove_in {
ViceFid VFid;
char *name; /* Place holder for data. */
} cfs_remove;
out
none
Description
Remove file named cfs_remove_in.name in directory
identified by VFid.
.. Note::
The attributes of the directory should be returned since its
mtime and size may change.
4.13. rmdir
------------
Summary
Remove a directory
Arguments
in::
struct cfs_rmdir_in {
ViceFid VFid;
char *name; /* Place holder for data. */
} cfs_rmdir;
out
none
Description
Remove the directory with name 'name' from the directory
identified by VFid.
.. Note:: The attributes of the parent directory should be returned since
its mtime and size may change.
4.14. readlink
---------------
Summary
Read the value of a symbolic link.
Arguments
in::
struct cfs_readlink_in {
ViceFid VFid;
} cfs_readlink;
out::
struct cfs_readlink_out {
int count;
caddr_t data; /* Place holder for data. */
} cfs_readlink;
Description
This routine reads the contents of symbolic link
identified by VFid into the buffer data. The buffer data must be able
to hold any name up to CFS_MAXNAMLEN (PATH or NAM??).
Errors
No unusual errors.
open·close·ioctl
930-1051`open`은 `VFid`와 `open(2)` 방식의 flags를 전달해 Venus가 해당 file을 persistent cache에 넣고 caller가 열고 있음을 기록하게 합니다. Unix에서는 container file의 device와 inode number를 `dev`, `inode`로 반환하고 Windows에서는 container file path를 반환합니다.
당시 `cfs_open_out`은 Windows case에 맞게 설계되지 않았습니다. container filename을 반환하는 upcall과 container inode를 반환하는 upcall을 분리하는 편이 낫다는 제안이 있습니다.
`close`는 `VFid` 파일을 닫고 server에 갱신합니다. output은 없고 명세상 `flags`는 사용되지 않습니다. Venus code에는 실행용 memory mapping이 남았음을 나타낼 수 있는 `execp` input 공간이 있으며, 이를 활용하지 않으면 아직 mmap된 파일을 cache에서 flush할 수 있다고 잘못 판단할 가능성이 있습니다. close된 container의 data를 새 data로 봐야 하는데 fetch 여부와 exec mapping 상태가 혼재해 있어 재검토가 필요하다고 합니다.
`ioctl`은 file의 ioctl과 pioctl을 포함합니다. `VFid`, `cmd`, `len`, `rwflag`, input data를 보내고 output length와 data를 받습니다. command·length·data는 일반 ioctl처럼 채우며 원문 설명은 Venus가 flags를 사용하지 않는다고 적습니다. 구조에는 `rwflag`가 있는데 주석에서는 ‘flags’가 불필요하다고 부르며 Venus code의 PREFETCHING 처리도 의문으로 남깁니다.
Coda object와 Venus persistent cache의 실제 container를 연결하는 호출입니다.
4.15. open
-----------
Summary
Open a file.
Arguments
in::
struct cfs_open_in {
ViceFid VFid;
int flags;
} cfs_open;
out::
struct cfs_open_out {
dev_t dev;
ino_t inode;
} cfs_open;
Description
This request asks Venus to place the file identified by
VFid in its cache and to note that the calling process wishes to open
it with flags as in open(2). The return value to the kernel differs
for Unix and Windows systems. For Unix systems the Coda FS Driver is
informed of the device and inode number of the container file in the
fields dev and inode. For Windows the path of the container file is
returned to the kernel.
.. Note::
Currently the cfs_open_out structure is not properly adapted to
deal with the Windows case. It might be best to implement two
upcalls, one to open aiming at a container file name, the other at a
container file inode.
4.16. close
------------
Summary
Close a file, update it on the servers.
Arguments
in::
struct cfs_close_in {
ViceFid VFid;
int flags;
} cfs_close;
out
none
Description
Close the file identified by VFid.
.. Note::
The flags argument is bogus and not used. However, Venus' code
has room to deal with an execp input field, probably this field should
be used to inform Venus that the file was closed but is still memory
mapped for execution. There are comments about fetching versus not
fetching the data in Venus vproc_vfscalls. This seems silly. If a
file is being closed, the data in the container file is to be the new
data. Here again the execp flag might be in play to create confusion:
currently Venus might think a file can be flushed from the cache when
it is still memory mapped. This needs to be understood.
4.17. ioctl
------------
Summary
Do an ioctl on a file. This includes the pioctl interface.
Arguments
in::
struct cfs_ioctl_in {
ViceFid VFid;
int cmd;
int len;
int rwflag;
char *data; /* Place holder for data. */
} cfs_ioctl;
out::
struct cfs_ioctl_out {
int len;
caddr_t data; /* Place holder for data. */
} cfs_ioctl;
Description
Do an ioctl operation on a file. The command, len and
data arguments are filled as usual. flags is not used by Venus.
.. Note::
Another bogus parameter. flags is not used. What is the
business about PREFETCHING in the Venus code?
rename·readdir·vget·fsync·inactive
1052-1213`rename`은 `sourceFid` directory의 `srcname` 객체를 `destFid` directory의 `destname`으로 바꿉니다. 두 이름은 반드시 NUL-terminated string이어야 합니다. Unix kernel의 문자열이 언제나 NUL로 끝나는 것은 아니므로 driver가 보장해야 합니다.
`readdir`은 directory `VFid`의 `offset`부터 최대 `count` byte의 entry를 읽고 실제 `size`와 data를 반환하도록 정의되어 있습니다. 하지만 당시에는 이 call을 사용하지 않고 container file로 readdir을 수행했으며, 예정된 directory revamp에서 재평가할 계획이라고 기록합니다.
`vget`은 `VFid`로 Venus에 `FSDB->Get`을 수행하게 하고 fid와 `vtype`을 반환합니다. 당시 사용되지 않았지만 read/write memory-mapped file을 Venus cache에 pin하고 `inactive`로 release하는 데 매우 유용할 수 있다고 평가합니다.
`fsync`은 `VFid` 객체의 RVM attributes를 Venus가 update하도록 요청하며 kernel-level fsync 계열 call의 일부로 사용해야 합니다. result가 동기화 성공 여부를 나타냅니다. 원문은 당시 Linux가 이 call을 구현하지 않았고 구현해야 한다고 적습니다.
`inactive`는 vnode가 더 이상 사용되지 않음을 Venus에 알리도록 이름 붙었지만 이 명세에서는 항상 `EOPNOTSUPP`를 반환하며 제거할 수도 있다고 합니다.
정의는 있지만 사용되지 않거나 구현이 부족했던 호출을 함께 표시합니다.
4.18. rename
-------------
Summary
Rename a fid.
Arguments
in::
struct cfs_rename_in {
ViceFid sourceFid;
char *srcname;
ViceFid destFid;
char *destname;
} cfs_rename;
out
none
Description
Rename the object with name srcname in directory
sourceFid to destname in destFid. It is important that the names
srcname and destname are 0 terminated strings. Strings in Unix
kernels are not always null terminated.
4.19. readdir
--------------
Summary
Read directory entries.
Arguments
in::
struct cfs_readdir_in {
ViceFid VFid;
int count;
int offset;
} cfs_readdir;
out::
struct cfs_readdir_out {
int size;
caddr_t data; /* Place holder for data. */
} cfs_readdir;
Description
Read directory entries from VFid starting at offset and
read at most count bytes. Returns the data in data and returns
the size in size.
.. Note::
This call is not used. Readdir operations exploit container
files. We will re-evaluate this during the directory revamp which is
about to take place.
4.20. vget
-----------
Summary
instructs Venus to do an FSDB->Get.
Arguments
in::
struct cfs_vget_in {
ViceFid VFid;
} cfs_vget;
out::
struct cfs_vget_out {
ViceFid VFid;
int vtype;
} cfs_vget;
Description
This upcall asks Venus to do a get operation on an fsobj
labelled by VFid.
.. Note::
This operation is not used. However, it is extremely useful
since it can be used to deal with read/write memory mapped files.
These can be "pinned" in the Venus cache using vget and released with
inactive.
4.21. fsync
------------
Summary
Tell Venus to update the RVM attributes of a file.
Arguments
in::
struct cfs_fsync_in {
ViceFid VFid;
} cfs_fsync;
out
none
Description
Ask Venus to update RVM attributes of object VFid. This
should be called as part of kernel level fsync type calls. The
result indicates if the syncing was successful.
.. Note:: Linux does not implement this call. It should.
4.22. inactive
---------------
Summary
Tell Venus a vnode is no longer in use.
Arguments
in::
struct cfs_inactive_in {
ViceFid VFid;
} cfs_inactive;
out
none
Description
This operation returns EOPNOTSUPP.
.. Note:: This should perhaps be removed.
rdwr·Odyssey 호출·prefetch·signal
1214-1394`rdwr`은 `VFid`, read/write flag, count, offset, I/O flag와 data로 Venus에 file read 또는 write를 요청하도록 정의되었습니다. 그러나 Coda 철학상 read/write operation은 Venus까지 올라가지 않아야 하고 실제로 동작하지 않으며 사용되지 않았으므로 제거해야 한다는 주석이 붙습니다.
`odymount`는 Unix mount point 하나에 여러 Coda ‘filesystem’을 mount하기 위해 이름을 보내고 해당 system의 root `ViceFid`를 받는 Odyssey dynamic set 호출입니다. VFS mount 영역에 pointer 구조를 복잡하게 만들고 Coda proper에서 사용하지 않으며 Venus도 구현하지 않아 제거 대상으로 기록됩니다.
`ody_lookup`과 `ody_expand`의 input·output은 모두 irrelevant로 적혀 있고 Venus가 구현하지 않으므로 제거하라고 명시합니다. `prefetch`는 dynamic set을 미리 가져오려는 호출이지만 argument가 문서화되지 않았고, Venus `worker.cc`에 support 흔적만 있으며 kernel의 `ODY_PREFETCH` operation도 정의되지 않아 동작하지 않고 사용되지 않습니다.
`signal`은 일반 reply를 기다리지 않는 out-of-band upcall입니다. Venus가 기존 upcall을 input queue에서 읽은 뒤 calling process가 signal을 받았음을 알려 Venus가 operation을 정리하게 합니다. input은 없고 reply도 없습니다.
어떤 Venus state를 정리해야 하는지, 정리가 올바른지, system call 하나에 여러 upcall이 있을 때 어떻게 처리할지 더 이해해야 한다는 주석이 있습니다. `open`은 분명 Venus state를 바꾸지만 다른 upcall도 kernel이 cleanup을 통지해야 하는지는 불명확합니다.
명세에 남았지만 구현·철학·사용 여부 때문에 제거 후보가 된 호출입니다.
4.23. rdwr
-----------
Summary
Read or write from a file
Arguments
in::
struct cfs_rdwr_in {
ViceFid VFid;
int rwflag;
int count;
int offset;
int ioflag;
caddr_t data; /* Place holder for data. */
} cfs_rdwr;
out::
struct cfs_rdwr_out {
int rwflag;
int count;
caddr_t data; /* Place holder for data. */
} cfs_rdwr;
Description
This upcall asks Venus to read or write from a file.
.. Note::
It should be removed since it is against the Coda philosophy that
read/write operations never reach Venus. I have been told the
operation does not work. It is not currently used.
4.24. odymount
---------------
Summary
Allows mounting multiple Coda "filesystems" on one Unix mount point.
Arguments
in::
struct ody_mount_in {
char *name; /* Place holder for data. */
} ody_mount;
out::
struct ody_mount_out {
ViceFid VFid;
} ody_mount;
Description
Asks Venus to return the rootfid of a Coda system named
name. The fid is returned in VFid.
.. Note::
This call was used by David for dynamic sets. It should be
removed since it causes a jungle of pointers in the VFS mounting area.
It is not used by Coda proper. Call is not implemented by Venus.
4.25. ody_lookup
-----------------
Summary
Looks up something.
Arguments
in
irrelevant
out
irrelevant
.. Note:: Gut it. Call is not implemented by Venus.
4.26. ody_expand
-----------------
Summary
expands something in a dynamic set.
Arguments
in
irrelevant
out
irrelevant
.. Note:: Gut it. Call is not implemented by Venus.
4.27. prefetch
---------------
Summary
Prefetch a dynamic set.
Arguments
in
Not documented.
out
Not documented.
Description
Venus worker.cc has support for this call, although it is
noted that it doesn't work. Not surprising, since the kernel does not
have support for it. (ODY_PREFETCH is not a defined operation).
.. Note:: Gut it. It isn't working and isn't used by Coda.
4.28. signal
-------------
Summary
Send Venus a signal about an upcall.
Arguments
in
none
out
not applicable.
Description
This is an out-of-band upcall to Venus to inform Venus
that the calling process received a signal after Venus read the
message from the input queue. Venus is supposed to clean up the
operation.
Errors
No reply is given.
.. Note::
We need to better understand what Venus needs to clean up and if
it is doing this correctly. Also we need to handle multiple upcall
per system call situations correctly. It would be important to know
what state changes in Venus take place after an upcall for which the
kernel is responsible for notifying Venus to clean up (e.g. open
definitely is such a state change, but many others are maybe not).
Minicache와 cnode
1395-1435Coda FS driver는 context switch 비용이 드는 upcall 빈도를 줄이기 위해 `lookup`과 `access` 결과를 cache할 수 있습니다. 대신 Venus는 cached entry가 stale해졌을 때 flush하거나 rename하라는 downcall을 보내야 합니다.
kernel 내부 file handle은 BSD의 vnode, Linux의 inode, Windows의 FileHandle처럼 OS마다 다릅니다. driver는 이 handle과 Venus의 `ViceFid`를 자주 상호 변환해야 하므로 둘을 연결하는 cnode를 유지합니다.
당시 minicache entry는 file name, 객체를 포함한 directory cnode, lookup을 허용한 `CodaCred` 목록, object cnode를 기록합니다. lookup은 caller의 name·directory·credentials로 cache에 cnode를 요청하고 hit 또는 miss를 받습니다.
driver가 object를 수정하거나 제거할 때는 관련 cache entry를 직접 invalidation해야 합니다. Venus가 network 등에서 entry가 더 이상 유효하지 않다는 정보를 얻으면 kernel에 downcall을 보내며 driver가 아래 규칙대로 cache를 지웁니다. downcall data를 kernel memory로 읽지 못한 경우 외에는 driver가 오류를 반환하지 않습니다.
upcall 절감과 Venus callback에 따른 coherence 유지 경로입니다.
5. The minicache and downcalls
===============================
The Coda FS Driver can cache results of lookup and access upcalls, to
limit the frequency of upcalls. Upcalls carry a price since a process
context switch needs to take place. The counterpart of caching the
information is that Venus will notify the FS Driver that cached
entries must be flushed or renamed.
The kernel code generally has to maintain a structure which links the
internal file handles (called vnodes in BSD, inodes in Linux and
FileHandles in Windows) with the ViceFid's which Venus maintains. The
reason is that frequent translations back and forth are needed in
order to make upcalls and use the results of upcalls. Such linking
objects are called cnodes.
The current minicache implementations have cache entries which record
the following:
1. the name of the file
2. the cnode of the directory containing the object
3. a list of CodaCred's for which the lookup is permitted.
4. the cnode of the object
The lookup call in the Coda FS Driver may request the cnode of the
desired object from the cache, by passing its name, directory and the
CodaCred's of the caller. The cache will return the cnode or indicate
that it cannot be found. The Coda FS Driver must be careful to
invalidate cache entries when it modifies or removes objects.
When Venus obtains information that indicates that cache entries are
no longer valid, it will make a downcall to the kernel. Downcalls are
intercepted by the Coda FS Driver and lead to cache invalidations of
the kind described below. The Coda FS Driver does not return an error
unless the downcall data could not be read into kernel memory.
Venus→kernel downcall
1436-1587`INVALIDATE`에 대해서는 이 문서에 이용 가능한 정보가 없습니다.
`FLUSH`는 argument 없이 name cache 전체를 지웁니다. Venus가 시작하거나 종료할 때 stale cache information이 남지 않도록 호출합니다. OS가 kernel name cache를 동적으로 끌 때도 이 downcall을 보냅니다.
`PURGEUSER`는 `CodaCred`를 받아 그 credential을 가진 cache entry를 모두 제거합니다. user token이 만료되거나 flush될 때 호출됩니다.
`ZAPFILE`은 `CodaFid`를 받아 cached vnode attribute의 invalidation 결과로 해당 `(dir vnode, name)` pair의 모든 entry를 제거합니다. 원문은 NetBSD와 Mach의 call name이 정확하지 않고 minicache zapfile routine의 argument가 다르며, 당시 Linux가 attribute invalidation을 올바르게 구현하지 않았다고 적습니다.
`ZAPDIR`은 `CodaFid` directory 안의 모든 cache entry와 그 children을 제거합니다. Venus가 directory에 대한 callback을 받았을 때 보냅니다.
`ZAPVNODE`는 `CodaCred`와 `VFid`가 모두 일치하는 entry를 제거하지만 이 downcall은 아마 발행되지 않는다고 기록합니다.
`PURGEFID`는 file attribute를 flush합니다. 대상이 directory, 즉 odd vnode라면 namecache에서 children을 purge하고 directory 자체도 제거합니다.
`REPLACE`는 `OldFid`를 `NewFid`로 바꿉니다. disconnected 상태에서 Venus가 임시로 할당한 local fid를 reintegration 중 global fid로 바꾸되, 해당 fid의 reference count가 0이 아니어도 name cache 연결을 유지할 수 있게 추가되었습니다.
Venus가 어떤 범위의 cached identity·name·attribute를 무효화하는지 비교합니다.
5.1. INVALIDATE
----------------
No information is available on this call.
5.2. FLUSH
-----------
Arguments
None
Summary
Flush the name cache entirely.
Description
Venus issues this call upon startup and when it dies. This
is to prevent stale cache information being held. Some operating
systems allow the kernel name cache to be switched off dynamically.
When this is done, this downcall is made.
5.3. PURGEUSER
---------------
Arguments
::
struct cfs_purgeuser_out {/* CFS_PURGEUSER is a venus->kernel call */
struct CodaCred cred;
} cfs_purgeuser;
Description
Remove all entries in the cache carrying the Cred. This
call is issued when tokens for a user expire or are flushed.
5.4. ZAPFILE
-------------
Arguments
::
struct cfs_zapfile_out { /* CFS_ZAPFILE is a venus->kernel call */
ViceFid CodaFid;
} cfs_zapfile;
Description
Remove all entries which have the (dir vnode, name) pair.
This is issued as a result of an invalidation of cached attributes of
a vnode.
.. Note::
Call is not named correctly in NetBSD and Mach. The minicache
zapfile routine takes different arguments. Linux does not implement
the invalidation of attributes correctly.
5.5. ZAPDIR
------------
Arguments
::
struct cfs_zapdir_out { /* CFS_ZAPDIR is a venus->kernel call */
ViceFid CodaFid;
} cfs_zapdir;
Description
Remove all entries in the cache lying in a directory
CodaFid, and all children of this directory. This call is issued when
Venus receives a callback on the directory.
5.6. ZAPVNODE
--------------
Arguments
::
struct cfs_zapvnode_out { /* CFS_ZAPVNODE is a venus->kernel call */
struct CodaCred cred;
ViceFid VFid;
} cfs_zapvnode;
Description
Remove all entries in the cache carrying the cred and VFid
as in the arguments. This downcall is probably never issued.
5.7. PURGEFID
--------------
Arguments
::
struct cfs_purgefid_out { /* CFS_PURGEFID is a venus->kernel call */
ViceFid CodaFid;
} cfs_purgefid;
Description
Flush the attribute for the file. If it is a dir (odd
vnode), purge its children from the namecache and remove the file from the
namecache.
5.8. REPLACE
-------------
Summary
Replace the Fid's for a collection of names.
Arguments
::
struct cfs_replace_out { /* cfs_replace is a venus->kernel call */
ViceFid NewFid;
ViceFid OldFid;
} cfs_replace;
Description
This routine replaces a ViceFid in the name cache with
another. It is added to allow Venus during reintegration to replace
locally allocated temp fids while disconnected with global fids even
when the reference counts on those fids are not zero.
초기화와 정리 요구사항
1588-1670Coda FS driver는 message queue, cnode, name cache entry를 유지합니다. name cache는 driver 전용이라 쉽게 조작할 수 있고 message queue도 초기화·파괴 지점이 명확하지만, cnode는 user process가 Coda filesystem object reference를 보유하므로 정리가 더 섬세합니다.
driver가 요청받는 경로는 message subsystem, VFS layer, pioctl interface입니다. 당시 pioctl이 Coda VFS를 통과하므로 VFS 요청과 비슷하게 취급할 수 있습니다.
message queue에는 open·close routine이 있어야 합니다. Unix에서는 character device open이 이에 해당합니다. open 전에는 message를 넣을 수 없어야 하고, open은 남아 있는 오래된 pending message를 제거해야 합니다. close는 sleep 중 process에 upcall을 완료할 수 없음을 알리고 queue가 할당한 memory를 모두 해제해야 합니다.
open 시 namecache를 빈 상태로 초기화해야 합니다. queue가 열리기 전에는 모든 VFS operation이 실패해야 하며, Coda mount가 queue open 전 성공하지 못하게 하면 이를 보장할 수 있습니다.
queue close 뒤에는 어떤 VFS operation도 성공해서는 안 됩니다. `lookup`, read/write, `readdir`는 upcall 없이 진행될 수 있으므로 명시적으로 차단해야 합니다. close 시 namecache를 flush하고 disable해야 합니다.
cnode가 보유한 모든 memory와 filesystem unmount는 upcall에 의존하지 않고 수행할 수 있어야 합니다. Venus가 `rootfid`나 root attributes를 얻지 못하면 mount가 정상적인 오류로 실패해야 하며, Venus가 mount 전에 이 객체들을 fetch하는 방식이 가장 좋습니다.
원문은 특히 NetBSD와 Linux가 이 요구사항을 완전히 구현하지 않았으며 원활한 동작을 위해 수정해야 한다고 결론냅니다.
queue open·close가 Coda VFS의 사용 가능 상태를 결정합니다.
6. Initialization and cleanup
==============================
This section gives brief hints as to desirable features for the Coda
FS Driver at startup and upon shutdown or Venus failures. Before
entering the discussion it is useful to repeat that the Coda FS Driver
maintains the following data:
1. message queues
2. cnodes
3. name cache entries
The name cache entries are entirely private to the driver, so they
can easily be manipulated. The message queues will generally have
clear points of initialization and destruction. The cnodes are
much more delicate. User processes hold reference counts in Coda
filesystems and it can be difficult to clean up the cnodes.
It can expect requests through:
1. the message subsystem
2. the VFS layer
3. pioctl interface
Currently the pioctl passes through the VFS for Coda so we can
treat these similarly.
6.1. Requirements
------------------
The following requirements should be accommodated:
1. The message queues should have open and close routines. On Unix
the opening of the character devices are such routines.
- Before opening, no messages can be placed.
- Opening will remove any old messages still pending.
- Close will notify any sleeping processes that their upcall cannot
be completed.
- Close will free all memory allocated by the message queues.
2. At open the namecache shall be initialized to empty state.
3. Before the message queues are open, all VFS operations will fail.
Fortunately this can be achieved by making sure than mounting the
Coda filesystem cannot succeed before opening.
4. After closing of the queues, no VFS operations can succeed. Here
one needs to be careful, since a few operations (lookup,
read/write, readdir) can proceed without upcalls. These must be
explicitly blocked.
5. Upon closing the namecache shall be flushed and disabled.
6. All memory held by cnodes can be freed without relying on upcalls.
7. Unmounting the file system can be done without relying on upcalls.
8. Mounting the Coda filesystem should fail gracefully if Venus cannot
get the rootfid or the attributes of the rootfid. The latter is
best implemented by Venus fetching these objects before attempting
to mount.
.. Note::
NetBSD in particular but also Linux have not implemented the
above requirements fully. For smooth operation this needs to be
corrected.
요약·해설
coda.rst:1-1670Coda kernel driver는 VFS 요청을 userspace cache manager Venus에 message upcall로 보내고, Venus는 persistent cache와 remote server RPC를 사용해 처리합니다. kernel은 lookup·access minicache와 Coda object를 OS inode에 연결하는 cnode를 유지하며, Venus downcall로 stale name·attribute·fid를 무효화하거나 교체합니다.
이 명세는 1997년 version 1.0 문서라 현재 API를 그대로 대변하기보다 protocol의 설계 의도와 역사적 개선 과제를 함께 담습니다. 특히 READ·WRITTEN message state와 signal race, container file open·close, 미사용 Odyssey 호출, Venus failure 때 queue·namecache·cnode를 upcall 없이 정리하는 요구사항이 구현 검토의 핵심입니다.
VFS call에서 upcall, cache coherence와 shutdown까지의 수명입니다.