Professional Documents
Culture Documents
networked
Caching as an essential design technique
2
Introduction
3
Introduction
A Case for DS
Server A
I need to
I want to store store my
my thesis on analysis
the server!
and reports
I need to have I need safely…
my book always storage for My boss
available..
my reports
wants…
4
Introduction
A Case for DS
Server A
Same here…
Server B
I don’t
remember..
5
Introduction
A Case for DS
Server B
Server A
Server C
6
Storage Systems and Their Properties
Other features:
mountable file stores
more? ...
8
What is a File System?
filedes = open(name, mode)
Opens an existing file with the given name
.
filedes = creat(name, mode)
Creates a new file with the given name
.
Both operations deliver a file descriptor referencing the open
file. The mode is read, write or both.
status = close(filedes)
Closes the open file filedes.
count = read(filedes, buffer, n)
Transfers n bytes from the file referenced by filedes to buffer
.
count = write(filedes, buffer, n)
Transfers n bytes to the file referenced by filedes from buffer.
Both operations deliver the number of bytes actually transferred
and advance the read-write pointer.
pos = lseek(filedes, offset,
Moves the read-write pointer to offset (relative or absolute,
whence)
depending on whence).
status = unlink(name)
Removes the file name from the directory structure. If the file
has no other names, it is deleted.
status = link(name1, name2)
Adds a new name (name2) for a file (name1
).
status = stat(name, buffer)
Gets the file attributes for file name into buffer.
9
What is a File System?
10
File Service Architecture
Client module
Read
Write
Create
Delete
GetAttributes
SetAttributes
12
Responsibilities of Various Modules
Flat file Service
Concerned with the implementation of operations on the contents of file. Unique
File Identifiers (UFIDs) are used to refer to files in all requests for flat file service
operations. UFIDs are long sequences of bits chosen so that each file has a
unique ID among all of the files in a distributed system.
Directory Service
Provides mapping between text names for the files and their UFIDs. Clients may
obtain the UFID of a file by quoting its text name to directory service. Directory
service supports functions needed to generate directories and to add new files
to directories.
Client Module
It runs on each computer and provides integrated service (flat file and directory)
as a single API to application programs. For example, in UNIX hosts, a client
module emulates the full set of UNIX file operations.
It holds information about the network locations of flat-file and directory server
processes; and achieve better performance through implementation of a cache
of recently used file blocks at the client.
13
Server operations/interfaces for the model
file service
Flat file service
position of first byte
Directory service
14
File Group
files
15
Case Study: Sun (Oracle) NFS
An industry standard for file sharing on local networks since the 1980s
An open standard with clear and simple interfaces
Supports many of the design requirements already mentioned:
transparency
heterogeneity
efficiency
fault tolerance
Limited achievement of:
concurrency
replication
consistency
security
16
NFS Architecture
Client computer
remote files
UNIX
NFS
UNIX
NFS
NFS
Client
file
file
Other
client
server
system
system
NFS
protocol
(remote operations)
17
NFS Architecture
18
NFS Server Operations
• read(fh, offset, count) -> attr, data
fh = fileModel flat file service
handle:
• write(fh, offset, count, data) -> attr
Read(FileId, i, n) -> Data
Filesystem identifier
i-node number
i-node generation
•
create(dirfh, name, attr) -> newfh, attr
Write(FileId, i, Data)
• remove(dirfh, name) status
Create() -> FileId
• getattr(fh) -> attr
Delete(FileId)
• setattr(fh, attr) -> attr
GetAttributes(FileId) -> Attr
• lookup(dirfh, name) -> fh, attr
SetAttributes(FileId, Attr)
• rename(dirfh, name, todirfh, toname)
Model directory service
• link(newdirfh, newname, dirfh, name)
Lookup(Dir, Name) -> FileId
• readdir(dirfh, cookie, count) -> entries
AddName(Dir, Name, File)
• symlink(newdirfh, newname, string) -> UnName(Dir, Name)
status
GetNames(Dir, Pattern)
• readlink(fh) -> string
->NameSeq
• mkdir(dirfh, name, attr) -> newfh, attr
• rmdir(dirfh, name) -> status
• statfs(fh) -> fsstats
19
NFS Access Control and Authentication
20
Architecture Components
(UNIX / Linux)
Server:
nfsd: NFS server daemon that services requests from
clients.
mountd: NFS mount daemon that carries out the mount
daemon.
/etc/exports: configuration file that defines which portion
Mount operation:
mount(remotehost, remotedirectory,
localdirectory)
Server maintains a table of clients who have
mounted filesystems at that server
Each client maintains a table of mounted file
systems holding:
< IP address, port number, file handle>
22
Local and Remote File Systems Accessible on an
NFS Client
Remote Remote
people students x staff users
mount mount
23
Automounter
25
NFS Optimization - Client Caching
NFS client module caches the results of read, write, getattr, lookup and readdir
operations
synchronization of file contents (one-copy semantics) is not guaranteed when
two or more clients are sharing the same file.
Timestamp-based validity check
reduces inconsistency, but doesn't eliminate it
validity condition for cache entries at the client:
t freshness guarantee
Tc time when cache entry was
(T - Tc < t) v (Tmclient = Tmserver)
last validated
t is configurable (per file) but is typically set to Tm time when block was last
3 seconds for files and 30 secs. for directories
updated
it remains difficult to write distributed
T current time
applications that share files with NFS
26
Summary
27