Outline: Access Control Lists (ACL) : Keep Lists of Access For Each Domain With
Outline: Access Control Lists (ACL) : Keep Lists of Access For Each Domain With
1
Unix lookup: /a/b/c Unix file system is slow!
“.” Name space Physical organization
a disk
n What are the problems?
“..” 2
b 3 Inode table
“.” 4
5 How many disk I/O’s to n How can we fix them?
... access first byte of c?
<a,3>
c File system for BSD 4.2 (Fast File System or FFS)
Blocks are 512 bytes n
<c, 14> n Kirk McKusick, Bill Joy, Samuel Leffler, Robert Fabry
n Just big blocks? n Why don’t we have 1MB block sizes and 1KB fragment
n Most files are small sizes?
n Experiments: 4K block size resulted in 50% waste
n Good bandwidth for large files, pretty good disk utilization for small
files
2
Near and Far File System Consistency
n Keep a directory’s contents within a cylinder group n File systems have lots of data structures
n Spread out sub-directories n Bitmap for free blocks
n Try to allocate file blocks in the same cylinder groups n Directory
n Spread out “medium” to “big” files n File header
n First 50K within the same cylinder group n Indirect blocks
n And switch cylinder groups every 1MB n Data blocks
Problem: slow! Have to wait for write to complete n Add file to new directory
before you go on
n Create new file
n Allocate space on disk for header, data
Write-back: delay writing modified data back to disk (for
example, until replaced) n Write new header to disk
3
User data consistency Transaction concept
n For user data, Unix uses “write back” --- forced to disk every 30 n Transactions: group actions together so that they are
seconds (or user can call “sync” to force to disk immediately). n Atomic: either happens or it does not (no partial operations)
n Serializable: transactions appear to happen one after the other
No guarantee blocks are written to disk in any order. n Durable: once it happens, stays happened
Sometimes meta-data consistency is good enough
Critical sections are atomic and serializable, but not durable
How should vi save changes to a file to disk ?
Need two more items:
Write new version in temp file
Commit --- when transaction is done (durable)
Move old version to other temp file
Rollback --- if failure during a transaction (means it didn’t happen at all)
Move new version into real file
Unlink old version
n Do a set of operations tentatively. If you get to commit, ok. Otherwise,
roll back the operations as if the transaction never happened.
If crash, look at temp area; if any files out there, send email to user that
there might be a problem.
Transaction implementation
Transaction implementation (cont’d)
n Key idea: fix problem of how you make multiple updates to disk, by Disk
turning multiple updates into a single disk write! Memory cache
4
Transactions under multiple
threads Two-phase locking
n What if two threads run same transaction at same time? use locks! n Don’t allow “unlock” before commit.
Begin transaction
Lock x, y
x=x+1
n First phase: only allowed to acquire locks (this avoids
y=y–1 deadlock concerns).
Unlock x, y
Commit
n Second phase: all unlocks happen at commit
n Problematic scenario:
n Thread A grabs locks, modifies x, y, writes to the log, unlocks
n Before A commits, thread B grabs lock, writes x, y, unlocks, and does n Thread B can’t see any of A’s changes, until A commits and
commit. releases locks. This provides serializability.
n Before A commits, it crashes!
This eliminates any need for file system check (fsck) after crash
If crash, read log:
n If log is not complete, no change!