[197] in 6.033-lab
a few answers
daemon@ATHENA.MIT.EDU (Benjie Chen)
Fri Apr 7 23:45:20 2000
From: Benjie Chen <benjie@cag.lcs.mit.edu>
Message-Id: <200004080345.XAA20645@amsterdam.lcs.mit.edu>
To: 6.033-lab@MIT.EDU
Date: Fri, 7 Apr 2000 23:45:12 -0400 (EDT)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
1. bread and bwrite use sector numbers, how big are
sectors?
A: 512 bytes, defined in sfsfs/sfsbc.h Sectors can be written
atomically to disk. this just mean that if it failed in the
middle, it will not tell you it succeeded (much like async).
2. do we need to recover files to consistent states?
A: no. only the meta data about the fs need to be in consistent
state. if I have a file, and the fs crashed, the file is allowed
to become garbage, as long as I don't loose any sectors or free
blocks because of the crash.
3. what is the generation number in fh?
a way to specify versions. since files in NFS can be accessed
using this handle, generation number is used to make sure a old
handle gets recognized. here is a section I taken out of a NFS
document:
In the 4.4BSD NFS implementation, the file handle is built from a filesystem
identifier, an inode number, and a generation number. The server creates a
unique filesystem identifier for each of its locally mounted filesystems. A
generation number is assigned to an inode each time that the latter is
allocated to represent a new file. Each generation number is used only once.
Most NFS implementations use a random-number generator to select a new
generation number; the 4.4BSD implementation selects a generation number that
is approximately equal to the creation time of the file. The purpose of the
file handle is to provide the server with enough information to find the file
in future requests. The filesystem identifier and inode provide a unique
identifier for the inode to be accessed. The generation number verifies that
the inode still references the same file that it referenced when the file was
first accessed. The generation number detects when a file has been deleted,
and a new file is later created using the same inode. Although the new file
has the same filesystem identifier and inode number, it is a completely
different file from the one that the previous file handle referenced. Since
the generation number is included in the file handle, the generation number in
a file handle for a previous use of the inode will not match the new
generation number in the same inode. When an old-generation file handle is
presented to the server by a client, the server refuses to accept it, and
instead returns the ``stale file handle'' error message.
--
Benjie Chen
benjie@lcs.mit.edu