0% found this document useful (0 votes)
23 views32 pages

SIT102 Lecture 8.2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views32 pages

SIT102 Lecture 8.2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

File Operations

O File is an abstract data type


O Create
O Write – at write pointer location
O Read – at read pointer
location O Reposition within file -
seek
O Delete
O Truncate
O Open(Fi) – search the directory structure on
disk for entry Fi, and move the content of
entry to memory
O Close (Fi) – move the content of entry Fi in
memory to directory structure on disk
Open Files
O Several pieces of data are needed
to manage open files:
O Open-file table: tracks open files
O File pointer: pointer to last read/write
location, per process that has the file open
O File-open count: counter of number of times
a file is open – to allow removal of data
from open-file table when last processes
closes it
O Disk location of the file: cache of data
access information
O Access rights: per-process access mode
information
Open File Locking
O Provided by some operating systems and
file systems
O Similar to reader-writer locks
O Shared lock similar to reader lock –
several processes can acquire
concurrently
O Exclusive lock similar to writer lock
O Mediates access to a file
O Mandatory or advisory:
O Mandatory – access is denied depending on
locks held and requested
O Advisory – processes can find status of locks
and decide what to do
File Types – Name, Extension
Directory Structure
O A collection of nodes
containing information about all
files
Disk Structure
O Disk can be subdivided into partitions
O Disks or partitions can be RAID protected
against failure
O Disk or partition can be used raw – without a
file system, or formatted with a file system
O Partitions also known as minidisks, slices
O Entity containing file system known as a
volume
O Each volume containing file system also tracks that
file system’s info in device directory or volume
table of contents
O As well as general-purpose file systems
there are many special-purpose file
systems, frequently all within the same
operating system or computer
A Typical File-system
Organization
Types of File Systems
O We mostly talk of general-purpose file systems
O But systems frequently have may file systems,
some general- and some special- purpose
O Consider Solaris has
O tmpfs – memory-based volatile FS for fast,
temporary I/O
O objfs – interface into kernel memory to get
kernel symbols for debugging
O ctfs – contract file system for managing
daemons
O lofs – loopback file system allows one FS to be
accessed in place of another
O procfs – kernel interface to process structures
O ufs, zfs – general purpose file systems
Operations Performed on
Directory
O Search for a file

O Create a file

O Delete a file

O List a directory

O Rename a file

O Traverse the file


system
Directory Organization
The directory is organized logically to obtain

O Efficiency – locating a file quickly


O Naming – convenient to users
O Two users can have same name for
different files
O The same file can have several different
names
OGrouping – logical grouping of files by
properties, (e.g., all Java programs, all games,
…)
Single-Level Directory
O A single directory for all
users

O Naming problem
O Grouping problem
Two-Level Directory
O Separate directory for each
user

■ Path name
■ Can have the same file name for different user
■ Efficient searching
■ No grouping capability
Tree-Structured Directories
Tree-Structured Directories
(Cont.)
O Efficient searching

O Grouping Capability

O Current directory (working directory)


O cd /spell/mail/prog
O type list
Tree-Structured Directories
(Cont)
O Absolute or relative path name
O Creating a new file is done in current directory
O Delete a file
rm <file-name>
O Creating a new subdirectory is done in
current directory
mkdir <dir-name>
Example: if in current directory
/mail mkdir count

Deleting “mail”  deleting the entire


subtree rooted by “mail”
Acyclic-Graph Directories
O Have shared subdirectories and
files
Acyclic-Graph Directories
(Cont.)
O Two different names (aliasing)
O If dict deletes list  dangling
pointer
O Solutions:
O Backpointers, so we can delete all
pointers Variable size records a problem
O Backpointers using a daisy chain
organization
O Entry-hold-count solution
O New directory entry type
O Link – another name (pointer) to an existing
file
O Resolve the link – follow pointer to locate
the file
General Graph Directory
General Graph
Directory (Cont.)
O How do we guarantee no cycles?
O Allow only links to file not subdirectories
O Garbage collection
O Every time a new link is added use a cycle
detection algorithm to determine whether
it is OK
File System Mounting
O A file system must be mounted before it can
be accessed
O A unmounted file system (i.e., Fig. 11-11(b)) is
mounted at a mount point
File Sharing
O Sharing of files on multi-user systems is desirable
O Sharing may be done through a protection
scheme
O On distributed systems, files may be shared across
a network
O Network File System (NFS) is a common
distributed file-sharing method
O If multi-user system
O User IDs identify users, allowing permissions
and protections to be per-user
Group IDs allow users to be in groups, permitting group
access rights
O Owner of a file / directory
O Group of a file / directory
File Sharing – Remote
File Systems
O Uses networking to allow file system access between systems
O Manually via programs like FTP
O Automatically, seamlessly using distributed file systems
O Semi automatically via the world wide web
O Client-server model allows clients to mount remote file systems
from servers
O Server can serve multiple clients
O Client and user-on-client identification is insecure or
complicated
O NFS is standard UNIX client-server file sharing protocol
O CIFS is standard Windows protocol
O Standard operating system file calls are translated into remote
calls
O Distributed Information Systems (distributed naming services) such
as LDAP, DNS, NIS, Active Directory implement unified access to
information needed for remote computing
File Sharing – Failure Modes
O All file systems have failure modes
O For example corruption of directory structures
or other non-user data, called metadata
O Remote file systems add new failure
modes, due to network failure, server
failure
O Recovery from failure can involve state
information about status of each
remote request
O Stateless protocols such as NFS v3 include
all information in each request, allowing
easy recovery but less security
File Sharing – Consistency
Semantics
O Specify how multiple users are to access a shared
file simultaneously
O Similar to Ch 5 process synchronization algorithms
O Tend to be less complex due to disk I/O and network
latency (for remote file systems
O Andrew File System (AFS) implemented complex
remote file sharing semantics
O Unix file system (UFS) implements:
O Writes to an open file visible immediately to other users
of the same open file
O Sharing file pointer to allow multiple users to read
and write concurrently
O AFS has session semantics
O Writes only visible to sessions starting after the file is
closed
Protection
O File owner/creator should be able to
control:
O what can be done
O by whom
O Types of access
O Read
O Write
O Execute
O Append
O Delete
O List
Access Lists and
Groups
O
O
Mode of access: read, write, execute
Three classes of users on Unix / Linux
RWX
a) owner access 7  1
11 RWX

b) group access 6  1 RWX


10
O Ask manager to create a group (unique name), say G, and add
c) public access
some users 1
to the group.  0
01
O For a particular file (say game) or subdirectory, define an
appropriate access.

Attach a group to a file chgrp G game


Windows 10 Access-
Control List Management
A Sample UNIX Directory
Listing
Solid-State Drive (SSD)
O Nonvolatile memory
O This gives the device the “solid-state” name
O Most common media: NAND Flash memory (Floating-
gate transistors)
O
SSD: 2013 - 2015
O Intel 520 Cherryville (2013) O Samsung 850
O Capacity: 240 GB (2015)
O Compare to HD: TB
O Capacity: 1TB
O Sequential R/W: 550/520
MB/s O Sequential R/W: 540/520
O Compare to HD: 122 MB/s
MB/s
O Latency
O Latency
O Read: 0.04 ms O N/A
O Write: 0.2 ms O $0.5/GB ($0.2/GB
O Compare to HD: tens today)
of ms
O $1/GB
O Compare to HD: 0.06/GB
Limitations of SSD
O Random write performance
O For write, need to first erase a large of
pages (32-64 pages), and reprogram
O Burnout
O Each cell has limited erase/program
cycles
O Range from 1,000 – 100,000 writes

© 2016-2017 DING YUAN ALL RIGHTS RESERVED


How do SSD’s characteristics
impact FS design?
O Characteristics of SSD
O No mechanical components ---
data location won’t make
difference
• Optimizations on data location are no
longer useful

O Random write performance is BAD


• Avoid random writes!
O Limited “write” cycles for each cell
• Spread the writes across the entire
SSD
© 2016-2017 DING YUAN ALL RIGHTS RESERVED

You might also like