24 Pages

disk-fs

Course: CPS 110, Fall 2009
School: Duke
Rating:
 
 
 
 
 

Word Count: 1687

Document Preview

Systems File and Disk Layout I/O: The Big Picture Processor interrupts Cache Memory Bus I/O Bridge Main Memory Disk Controller I/O Bus Graphics Controller Graphics Network Interface Disk Disk Network Rotational Media Track Arm Cylinder Head Platter Sector Access time = seek time + rotational delay + transfer time seek time = 5-15 milliseconds to move the disk arm and settle on a cylinder rotational...

Register Now

Unformatted Document Excerpt

Coursehero >> North Carolina >> Duke >> CPS 110

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Systems File and Disk Layout I/O: The Big Picture Processor interrupts Cache Memory Bus I/O Bridge Main Memory Disk Controller I/O Bus Graphics Controller Graphics Network Interface Disk Disk Network Rotational Media Track Arm Cylinder Head Platter Sector Access time = seek time + rotational delay + transfer time seek time = 5-15 milliseconds to move the disk arm and settle on a cylinder rotational delay = 8 milliseconds for full rotation at 7200 RPM: average delay = 4 ms transfer time = 1 millisecond for an 8KB block at 8 MB/s Bandwidth utilization is less than 50% for any noncontiguous access at a block grain. Disks and Drivers Disk hardware and driver software provide basic facilities for nonvolatile secondary storage (block devices). 1. OS views the block devices as a collection of volumes. A logical volume may be a partition of a single disk or a concatenation of multiple physical disks (e.g., RAID). 2. OS accesses each volume as an array of fixed-size sectors. Identify sector (or block) by unique (volumeID, sector ID). Read/write operations DMA data to/from physical memory. 3. Device interrupts OS on I/O completion. Using Disk Storage Typical operating systems use disks in three different ways: 1. System calls allow user programs to access a "raw" disk. Unix: special device file identifies volume directly. Any process that can open the device file can read or write any specific sector in the disk volume. 2. OS uses disk as backing storage for virtual memory. OS manages volume transparently as an "overflow area" for VM contents that do not "fit" in physical memory. 3. OS provides syscalls to create/access files residing on disk. OS file system modules virtualize physical disk storage as a collection of logical files. Unix File Syscalls int fd; /* file descriptor */ fd = open("/bin/sh", O_RDONLY, 0); fd = creat("/tmp/zot", 0777); unlink("/tmp/zot"); char data[bufsize]; bytes = read(fd, data, count); bytes = write(fd, data, count); lseek(fd, 50, SEEK_SET); mkdir("/tmp/dir", 0777); rmdir("/tmp/dir"); bin / etc tmp process file descriptor table system open file table Nachos File Syscalls/Operations Create("zot"); OpenFileId fd; fd = Open("zot"); Close(fd); char data[bufsize]; Write(data, count, fd); Read(data, count, fd); FileSystem class internal methods: Create(name, size) OpenFile = Open(name) Remove(name) List() FileSystem BitMap Directory Bitmap indicates whether each disk block is in-use or free. Limitations: 1. small, fixed-size files and directories 2. single disk with a single directory 3. stream files only: no seek syscall 4. file size is specified at creation time 5. no access control, etc. A single 10-entry directory stores names and disk locations for all currently existing files. FileSystem data structures reside on-disk, but file system code always operates on a cached copy in memory (read/modify/write). Preview of Issues for File Systems 1. Buffering disk data for access from the processor. block I/O (DMA) must use aligned, physically resident buffers block update is a read-modify-write 2. Creating/representing/destroying independent files. disk block allocation, file block map structures directories and symbolic naming 3. Masking the high seek/rotational latency of disk access. smart block allocation on disk block caching, read-ahead (prefetching), and writebehind Representing a File On-Disk in Nachos An OpenFile represents a file in active use, with a seek pointer and read/write primitives for arbitrary byte ranges. logical block 0 logical block 1 OpenFile OpenFile(sector) Seek(offset) Read(char* data, bytes) Write(char* data, bytes) once upo n a time /nin a l and far far away ,/nlived t he wise and sage wizard. FileHdr bytes sectors A file header describes an on-disk file as an ordered sequence of sectors with a length, mapped by a logical-to-physical block map. logical block 2 OpenFile* ofd = filesys->Open("tale"); ofd->Read(data, 10) gives `once upon ` ofd->Read(data, 10) gives `a time/nin ` Allocate(...,filesize) length = FileLength() sector = ByteToSector(offset) File Metadata On disk, each file is represented by a FileHdr structure. The FileHdr object is an in-memory copy of this structure. file attributes: may include owner, access control, time of create/modify/access, etc. The FileHdr is a file system "bookeeping" structure that supplements the file data itself: these kinds of structures are called filesystem metadata. bytes sectors etc. A Nachos FileHdr occupies exactly one disk sector. To operate on the file (e.g., to open it), the FileHdr must be read into memory. Any changes to the attributes or block map must be written back to the disk to make them permanent. logical-physical block map (like a translation table) physical block pointers in the block map are sector IDs FileHdr* hdr = new FileHdr(); hdr->FetchFrom(sector) hdr->WriteBack(sector) Representing Large Files The Nachos FileHdr occupies exactly one disk sector, limiting the maximum file size. sector size = 128 bytes 120 bytes of block map = 30 entries each entry maps a 128-byte sector max file size = 3840 bytes inode direct block map (12 entries) In Unix, the FileHdr (called an indexnode or inode) represents large files using a hierarchical block map. Each file system block is a clump of sectors (4KB, 8KB, 16KB). Inodes are 128 bytes, packed into blocks. Each inode has 68 bytes of attributes and 15 block map entries. suppose block size 8KB = 12 direct block map entries in the inode can map 96KB of data. One indirect block (referenced by the inode) can map 16MB of data. One double indirect block pointer in inode maps 2K indirect blocks. maximum file size is 96KB + 16MB + (2K*16MB) + ... indirect block double indirect block Representing Small Files CPS 210 Internal fragmentation in the file system blocks can waste significant space for small files. E.g., 1KB files waste 87% of disk space (and bandwidth) in a naive file system with an 8KB block size. Most files are small: one study [Irlam93] shows a median of 22KB. FFS solution: optimize small files for space efficiency. Subdivide blocks into 2/4/8 fragments (or just frags). Free block maps contain one bit for each fragment. To determine if a block is free, examine bits for all its fragments. The last block of a small file is stored on fragment(s). Basics of Directories A directory is a set of file names, supporting lookup by symbolic name. In Nachos, each directory is a file containing a set of mappings from name->FileHdr. Directory(entries) sector = Find(name) Add(name, sector) Remove(name) directory fileHdr 0 wind: 18 0 snow: 62 rain: 32 hail: 48 Each directory entry is a fixed-size slot with space for a FileNameMaxLen byte name. Entries or slots are found by a linear scan. A directory entry may hold a pointer to another directory, forming a hierarchical name space. sector 32 A Nachos Filesystem On Disk An allocation bitmap file maintains free/allocated state of each physical block; its FileHdr is always stored in sector 0. A directory maintains the name->FileHdr mappings for all existing files; its FileHdr is always stored in sector 1. sector 0 allocation bitmap file sector 1 11100010 00101101 10111101 once upo n a time /n in a l directory file 0 rain: 32 hail: 48 wind: 18 0 snow: 62 10011010 00110001 00010101 00101110 00011001 01000100 and far far away , lived th Every box in this diagram represents a disk sector. Unix File Naming (Hard Links) directory A directory B wind: 18 0 sleet: 48 A Unix file may have multiple names. Each directory entry naming the file is called a hard link. Each inode contains a reference count showing how many hard links name it. 0 rain: 32 hail: 48 inode link count = 2 inode 48 link system call link (existing name, new name) create a new name for an existing file increment inode link count unlink system call ("remove") unlink(name) destroy directory entry decrement inode link count if count = 0 and file is not in active use free blocks (recursively) and on-disk inode Unix Symbolic (Soft) Links Unix files may also be named by symbolic (soft) links. A soft link is a file containing a pathname of some other file. symlink system call symlink (existing name, new name) allocate a new file (inode) with type symlink initialize file contents with existing name create directory entry for new file with new name The target of the link may be removed at any time, leaving a dangling reference. How should the kernel handle recursive soft links? directory A 0 rain: 32 hail: 48 directory B wind: 18 0 sleet: 67 inode link count = 1 inode 48 inode 67 ../A/hail/0 The Problem of Disk Layout The level of indirection in the file block maps allows flexibility in file layout. "File system design is 99% block allocation.&q...

Textbooks related to the document above:
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Duke - CPS - 100
zygotezucchinizoundszoomzoologyzoozonezombiezodiacalzodiaczlotyzirconiumzirconzippyzipzingzinczilchzigzaggingzigzagziggingzigzetazestyzestzerothzeroeszerozenithzebrazealouszealotzealzazenzapzaggingzagz'szyuleyu
Duke - CPS - 108
SCANDIR(3) Linux Programmer's Manual SCANDIR(3)NAME scandir, alphasort - scan a directory for matching entriesSYNOPSIS #include <dirent.h> int scandir(const char *dir, struct dirent *namelist,
Duke - CPS - 108
Standard C Library Functions regcmp(3C)NAME regcmp, regex - compile and execute regular expressionSYNOPSIS #include <libgen.h> char *regcmp(const char *string1, /* char *string2 */ ., int /*(c
Duke - CPS - 001
S A M P L E CPS 1 (Ramm)Spring 2001 13 April 2001 Quiz #11Name _ Honor Code_ Section _A. True/False?(1) Light travels about one foot in a nano-second.(2) Having no moving parts, vacuum tubes are more reliable than transi
Duke - CPS - 006
FRONT 1 15 14 2 16 13 3 12 17 18 19 20 11
Duke - CPS - 124
You can submit your homework 1 online either from your acpub or CSaccounts. The syntax is:submit_cps124 hw1 <filename1> <filename2> .The submit binaries are available at /usr/local/bin/submit_cps124 on CS machines and/afs/acpub/project/cps/bin
Duke - CPS - 124
Planet Semi Major axis(a) in AU Mercury 0.38709893 Venus 0.72333199 Earth 1.00000011 Mars 1.52366231 Jupiter 5.20336301 Saturn 9.53707032 Uranus 19.19126393 Neptune 30.06896348 Pluto
Duke - CPS - 100
A Short History of Computing05/16/09 1Courtesy of IPRE GaTech, 2008Jacques de Vaucanson 1709-1782 Gifted French artist and inventor Son of a glove-maker, aspired to be a clockmaker 1727-1743 Created a series of mechanical automations that simu
Duke - CPS - 100
Java Basics ArraysShould be a very familiar ideaExample: method to count number of A grades public static int getAs(int[] grades) { int aCount = 0; for (int k = 0; k < grades.length; k+){ if (grades[k] >= 90) aCount+; } return aCount;P
Duke - CPS - 100
.Or Forever Hold Your Peace (2000)/Ahrens, Melinda/Beeler, David/Bowden, Scott/Carlson, Pepper/Christian, Peter/Coogan, Keith/Coyne, Chris/Criss, Nancy/Forrest, Andy/Kagen, Michael/Keith-Porter, Linda/Kirk, Bonnie J./Lang, Joy/McCullough, James E./Mi
Duke - CPS - 100
Your id number was mailed to you.finex is final exam Grades as of May 7, 10pmid lab5 lab6 lab7 lab8 lab9 quz15 10 10 10 10 0 0 =11 8.75 10.00 5.75 0.00 0.00 7.00 12 7.50 10.00
Duke - CPS - 100
Pack That Class Up (To the tune of Juvenile's Back that Ass Up)I was working on a program, Had some hashin'and I thought I might need to clear my cache, andSet up an array for some organizin'But when I ran the main, I found a problemSegmentat
Duke - CPS - 100
Data Structures revisitedqLinked lists and arrays and ArrayLists and . Linear structures, operations include insert, delete, traverse, . Advantages and tradeoffs include . We want to move toward structures that support very efficient insertion
Duke - CPS - 100
COMPSCI 100, Spring 2009 Owen Astrachanhttp:/www.cs.duke.edu/courses/cps100/spring09 http:/www.cs.duke.edu/~olaCPS 100, Spring 20091.1Data into Information and KnowledgeCPS 100, Spring 20091.2What is Computer Science?What is it that di
Duke - CPS - 100
Conventions in Compsci 100 projectsqWe want you to concentrate on algorithms and data structures Not on rendering fonts, interacting with users This is important! But not what this course is about We try to build GUIs or views that facilitate pr
Duke - CPS - 100
Let me - let me express - let me express my thanks to the historicslate of candidates who accompanied me on this journey, and especiallythe one who traveled the farthest, a champion for working Americans andan inspiration to my daughters and to yo
Duke - CPS - 100
And I thank you, Sen. McCain and Mrs. McCain, for the confidence thatyou have placed in me. Senator, I am honored to be chosen as yourrunning mate. I will be honored to serve next to the next president ofthe United States.I know that when Sen. M
Duke - CPS - 100
Thank you all so much for being here tonight.You know, last week, I congratulated Senator Obama when he finishedfirst and I finished second in Iowa. One race down. Tonight, Icongratulate Senator Clinton and Senator Obama, two racesdown. Forty-ei
Duke - CPS - 100
Thank you all very much. National Commander Marty Conatser, thank youfor the kind introduction. National Adjutant Bob Spanogle, AuxiliaryPresident Jan Pulvermacher-Ryan, Auxiliary Secretary Pam Gilley: thankyou all. If I may speak for the gang at
Duke - CPS - 100
From sets, toward maps, via big-OhqConsider the MemberCheck weekly problem Find elements in common to two vectors Alphabetize/sort resulting vector, no duplicates Write/code an algorithm, use vectors/algorithms, but no sets Goal: easy to write
Duke - CPS - 100
"Code it baby, one more time"Oh Buggy buggy, you weren't supposed to throwIO Exception errorsYou dummy dummy, your disk is too full and nowyour program wont work right, yeahcode this how you want it to betell me binky cuz I need know now (oh
Duke - CPS - 100
Big-O Controlby The Artist Formerly Known as Special KSung to "&%#@ control" by The Artist Formerly Known as PrinceNuestra presentacion especial comenzara en brevePero antes un mensaje de nuestros auspiciadoresUh, yeah, UhGood mornin ladies
Duke - CPS - 100
COMPUTERS (take-off on "Tequila")[music]Computers![music]Computers!ok the real song:What is an array? (take off on "Take my Breath Away")Watching every motion as I code this little game,On this program stuck, I finally ask for help in sham
Duke - CPS - 100
String City Music: Charles Manson's "Sick City"String City, yeahstresses studentsString City melts their brains downto make Forbes look prettywhat should I do I'm just a failurethe extra credit I always seem to takeyou just sit and press com
Duke - CPS - 100
One Week Based on Barenaked Ladies' "One Week"(Capital letters in lines denote emphasis sincethis song is a bugger to sing)It's been One week since dorQue was dueI really should have made my Magic word foo.Five days since a bus errorDisr
Duke - CPS - 100
Summer Girls - LFOMy Revised Lyrics:I like it when ola stops by.in the cluster.Chorus:New Kids on the Block had a bunch of hitsParse errors make me sick.And I think its fly when ola stops by in the clusterI like code that joins DNA really
Duke - CPS - 100
Original Group: Green DayOriginal Song Title: Good Riddance (Time of Your Life)Original Lyrics: Another turning point, a fork stuck in the road. Time grabs you by the wrist, directs you where to go. So make the best of this test, and don't as
Duke - CPS - 100
tune: Brown-eyed Girl, Van MorrisonMy Tree PointerHey where'd my info go?The node I just created.Goin' down my search treeorder n in the worst caseOrder logn-ing away heyas seen on average.Until it finds a null pointernow its address is xz
Duke - CPS - 100
Blink 182 - All the Small ThingsAll the coding, no sleep, foo things.Late nights, in Teerno girls, no beer.I'll use, linked lists,more bugs, I'm pissed.Watching, waiting.hope program's compiling.Chorus:Say it ain't so, what's my
Duke - CPS - 100
sung to "You Drive Me Crazy" by Britney Spearsthe CD versionola, oh how i need youTo explain recursions, so I know what to do.ola, I just cannot seeThose little clones you claim are there to help me.Everytime I trace the codeMy head starts sp
Duke - CPS - 100
We Didn't Write the Program(to the tune of Billy Joel's We Didn't Start the Fire)Rsg, huffman tree, wordtrack, nothing's backLink-a-list, pop a stack, make a vector, push it back,Bus error, index out, seg fault, wanna shout.For loop, While loo
Duke - CPS - 100
TREESWe are the world,We are ROOTS children.We are the NODES that make up all the TREES so lets start building.There are many types of TREES,BST and HUFFMAN,Us and our parents make up the best ADT's.We are the world,We are ROOTS childre
Duke - CPS - 100
Lyrics to the song "So Happy Together", by the TurtlesImagine programming, I do,I think about it day and night, it's only right,To think about this course we love,or say we might, so stressed out together.We call it CPS, at level one-hundred,
Duke - CPS - 100
"Man! I Feel Like Recursion" (to the tune of Shania Twain's "Man! IFeel Like a Woman")(Let's program)C'mon.I'm sitting here tonight, this program's gotta writeall the nodes in a treeeeee.I don't want no loops, I only want to choosethe call
Duke - CPS - 100
"There's Your Trouble" to the tune of "There's Your Trouble" by the Dixie ChicksIt should have compiled, but It wasn't friendly, was itSame old storyParse error and no luckShould have worked like a charmShould have run like the wind, Like a
Duke - CPS - 100
Astrachan Pie(sung to "American Pie" by Don McLean)A long, long time ago,I can still remember,When he taught me Computer Science Six.He taught me how to cout <coot> and cin <sin>,I got my libraries from his bin,And then we played with MadLi
Duke - CPS - 100
/Sing to the tune of "Pinball Wizard" by The Who (see below)CPS NerdEver since I was a freshman,I've Programmed c+;From Anagram to DorqueI even programmed Huff,But I ain't seen nothing like himIn the lab at Teer-This CPS nerdSure doesn't l
Duke - CPS - 100
sung to the tune of sisqo's "thong song"intro: cps right here, lettin all the people know what programmerstalk about, you know, makin it run.verse 1: ooh recursion, so ingenious and you know another major can't handle this compiling like it
Duke - CPS - 100
extra credit songI don't know if this makes sense. It uses a lot of cps100 termsthough, and can be fit into the actual meter of the song.Sung to the tune of Piano Man, by Billy JoelIt's 2 am on a saturday,My program, it's time to begin.Ther
Duke - CPS - 100
Sung to Blink 182's - What's My Age Again?I booted up, it was a Monday nightI had four hours to get my program rightIt started to compile, and I began to smileBut then it exited abnormallyAnd that's about the time the system crashed on meIt a
Duke - CPS - 100
tune: Sweet Home AlabamaSweet Home Gay Love Auditorium(God I Love Computer Science)Oh DAMN my program won't compile!did I initialize the right thing? O looky here, there's no declaration!and i forgot to sharp include string!(that shouldnt h
Duke - CPS - 100
To the tune of (SITTIN' ON) THE DOCK OF THE BAY by Otis ReddingCoding in the morning sunI'll be coding when the evening comesWasting time all dayTrying to fix the bugs, yeahI'm(refrain)Sitting on my buttox all dayCoding my life awayI'm
Duke - CPS - 100
MUST SING THIS SONG TO THE INSTRUMENTAL OF GANGSTA'S PARADISE BY COOLIO OR TO THE BEATS OF WEIRD AL'S AMISH PARADISE.As I walk from the bus stop to that dreaded building Teer,I look at myself and realize I've become my worst fear.Cause I've been
Duke - CPS - 100
Song title: T.E.E.R.(to the tune of YMCA, by the Village People)Program, there's no need to crash downI said, PROGRAM, on the keyboard you poundI said, PROGRAM, cause the bug will be foundThere's no need to be unhappyProgram, there's a pla
Duke - CPS - 100
Britney Spears' "Hit Me Baby One More Time"Oh QuickSort QuickSortOh QuickSort QuickSortOh Quicksort QuicksortHow were you supposed to knowThat I'd be Order n squaredOh Quicksort QuicksortYou shouldn't have let me runCuz now I'm slow as hell
Duke - CPS - 100
tune: Micheal Jackson's ThrillerVectorBackground: Do do dum do do dum cha Do do dum do do dum cha Do do dum do do dum chaIt's close to midnight, and you need to store this informationYou want a data structure, that's
Duke - CPS - 100
(Bug)You Really Got MeOriginal Van Halen song Written by: Ray Davies. Jay Boy Music Corp. BMI.All Rights Reserved.-Bug, you really got me now You got me so I don't know what I'm codin' Bug, you really got me now You got me so I can't sle
Duke - CPS - 100
*MY VERSION, OH HOW I HAVE DEBAUCHED THE BACKSTREET BOYS' MEANINGFUL LYRICS*"Code, Please Compile Today" - XXX and the Back(tracking) BoysI hate my compiler,My one desire,Believe when I pray:Please, god, compile today!But the TA is so far a
Duke - CPS - 100
Tune: Blessed Union of Soul - Hey Leonardo (She likes me for me)It don't matter what you are, a vector, pointer, or a stringYou'll never be as good as a computer's best friend,And if you were it wouldn't mean nothin'She's a balanced sear
Duke - CPS - 100
CPS Song Parody of Green Day's "Good Riddance (Time of Your Life)"another parse errorshowin' up in your codesoon as you clear that upyou get another craploadso make the best of this test and don't ask whyeven if it takes 20 hoursand you t
Duke - CPS - 100
Not Done YetWritten to the tune of Allstar, by SmashmouthSomebody once told meIf you need a sorting algorithmBubble ain't the sharpest tool in the shedYou might prefer to mergeOr perhaps even a quicksortBut you got to make the choice in y
Duke - CPS - 100
Title: SORT METree: Hi ya Node!Node: Hi Tree!Tree: Wanna get sorted?Node: Sure Tree!Tree: Let's start!Node:I'm just a lost node, in a big big treeSo confusing, so distractedYou can play with me, put me where you wantStupid pointers, tha
Duke - CPS - 124
*cube example*8#VRML V2.0 utf8 DEF cube0_grp Group { children [DEF NgcRoot Group { children [ DEF cube0 Shape { appearance DEF cube0_material Appearance { material Material { diffuseColor 1
Duke - CPS - 124
Vertex & Pixel ShadersCPS124 Computer GraphicsFerdinand SchoberShader History I 1995/1996: 3dfx Voodoo 1first mass market GPU, hw accelerated rasterization GLIDE API, 16bit buffers, texturing & shading Quake using OpenGL! 1998: 3dfx Voodoo
Duke - CPS - 124
Cutting Edge Computer GamesCPS124 Computer GraphicsFerdinand SchoberComputer Game Milestones I First Age 80's:Pong, Pacman, M.U.L.E., Nethack Bard's Tale, Ultima, Wizardry Civilization, Populous, Maniac Mansion Second Age 90's:Doom, Ulti
Duke - CPS - 124
Statistics for Project3 Mean 94.93 Standard Deviation 9.74 Low 80 Median 100 High 107 Column Maximum 100 30 valid out of 30 possible data points
Duke - CPS - 124
Statistics for Project2 Mean 78.03 Standard Deviation 20.40 Low 0 Median 85 High 104 Column Maximum 100 37 valid out of 38 possible data points
Duke - CPS - 108
> The following statement is a comment by a colleague:> > "Object Oriented Programming is just a structuring method for> procedural programming, rather than a new paradigm"> > I disagreed quite strongly, but found it hard to convince him.> > W
Duke - CPS - 108
From C+ to JavaqJava history: Oak, toasterovens, internet language, panacea Not really a standard language like C+ Arguably proprietary (and arguably not) Precursor to C# ? What it is OO language, not a hybrid (like C+) compiled to bytecode,
Duke - CPS - 108
Maintenance Commands du(1M)NAME du - summarize disk usageSYNOPSIS /usr/bin/du [ -adkr ] [ -s | -o ] [ file. ] /usr/xpg4/bin/du [ -a | -s ] [ -krx ] [ file. ]DESCRIPTION The du utili
Duke - TEAM - 108
<apptday="wednesday"time="1, 26"subject = "fuck"/><apptday ="monday"time="11,9"subject = "fuck"/><appt day="monday" time="9,12" subject="sleep"/><appt day="tuESDay" time="9,10" subject="CPS 110"/><appt day = "thursday" time = "9