file syst ems
play

File Syst ems Last t ime we t alked about disk int ernals 11: - PDF document

File Syst ems Last t ime we t alked about disk int ernals 11: File Syst em Basics Despit e complex int ernals, disks export a simple array of sect ors Last Modif ied: How do we go f rom t hat t o a f ile syst em? 6/ 15/ 2004


  1. File Syst ems � Last t ime we t alked about disk int ernals 11: File Syst em Basics � Despit e complex int ernals, disks export a simple array of sect ors Last Modif ied: � How do we go f rom t hat t o a f ile syst em? 6/ 15/ 2004 12:12:09 PM � What do we exact ly do we expect f rom a f ile syst em? -1 -2 File Syst em Basics Files � FS are probably t he OS abst ract ion t hat � A f ile is a collect ion of dat a wit h syst em maint ained pr oper t ies like average user is most f amiliar wit h � Owner, size, name, last read/ writ e t ime, et c. � Files � Files of t en have “t ypes” which allow user s and � Dir ect or ies applicat ions t o r ecognize t heir int ended use � Access cont r ols (owner s, gr oups, per missions) � Some f ile t ypes ar e under st ood by t he f ile syst em (mount point , symbolic link, dir ect or y) � Some f ile t ypes ar e under st ood by applicat ions and user s (.t xt , .j pg, .ht ml, .doc, … ) � Could t he syst em underst and t hese t ypes and cust omize it s handling? -3 -4 Basic File Operat ions Direct ories Windows � Dir ect or ies pr ovide a way f or user s t o or ganize UNI X t heir f iles *and* a convenient way f or user s t o � Creat eFile (name, CREATE) � cr eat e (name) ident if y and shar e dat a � Creat eFile (name, OPEN) � open (name, mode) � Logically dir ect or ies st or e inf or mat ion like f ile � ReadFile (handle) � r ead (f d) name, size, modif icat ion t ime et c (Not always kept � Wr it eFile (handle) in t he dir ect or y t hough..) � writ e(f d) � FlushFileBuf f er s(handle) � Most f ile syst ems suppor t hier ar chical dir ect or ies � sync(f d) � Set FilePoint er (handle) (/ usr/ local/ bin or C:\ WI NNT) � seek(f d, pos) � CloseHandle(handl ) � P eople like t o organize inf ormat ion hierarchically � close(f d) � Delet eFile(name) � Recall: OS of t en r ecor ds a cur r ent wor king dir ect or y f or each pr ocess � unlink (name) � CopyFile (name) � Can t heref ore ref er t o f iles by absolut e and relat ive � r ename (old, new) � MoveFile(name) names -5 -6 1

  2. Direct ories are special f iles Mult iple parent direct ories? � Dir ect or ies ar e f iles cont aining inf or mat ion t o be � One nat ur al quest ion is “can a f ile be in mor e t han int er pr et ed by t he f ile syst em it self one dir ect or y”? � List of f iles and ot her direct ories cont ained in t his � Sof t links direct ory � Special f ile int erpret ed by t he FS (like direct ories in � Some at t ribut es of each child including where t o f ind it !! t hat sense) � How should t he list of childr en be or ganized? � Tell FS t o look at a dif f erent pat hname f or t his f ile � Flat f ile? � I f f ile delet ed or moved, sof t link will point t o wrong place � B- tree? � Har d links � Many syst ems have no par t icular or der , but t his is � Along wit h ot her f ile inf o maint ain ref erence count ext r emely bad f or lar ge dir ect or ies! � Delet e f ile = decrement ref erence count � Only reclaim st orage when ref erence count does t o 0 -7 -8 P at h Name Translat ion File Buf f er Cache � Cache Dat a Read � To f ind f ile “/ f oo/ bar/ baz” � Exploit t emporal localit y of access by caching pat hname � Find t he special root direct ory f ile (how does FS know t ranslat ion inf ormat ion where t hat is?) � Exploit t emporal localit y of access by leaving recent ly � I n special root direct ory f ile, look f or ent ry f oo and t hat accesses chunks of a f ile in memory in hopes t hat t hey ent ry will t ell you where f oo is will be accessed again (let app give hint if not ?) � Read special direct ory f ile f oo and look f or ent ry bar t o � Exploit spat ial localit y of access by bringing in large t ell you where bar is chunks of a f ile at once � Find special direct ory f ile bar and look f or ent ry baz t o � Dat a wr it t en is also cached t ell you where baz is � For correct ness should be writ e-t hrough t o disk � Finally f ind baz � Normally is writ e- behind � FS can cache common pr ef ixes f or ef f iciency • FS per iodically walks t he buf f er cache and “f lushes” t hings older t han 30 seconds t o disk • Unr eliable! � Usually LRU r eplacement -9 -10 File Buf f er Cache P rot ect ion Syst em � Most FS implement a pr ot ect ion scheme t o � Typically cache is syst em wide (shared by cont rol: all processes) � Who can access a f ile � Shar ed libr ar ies and execut ables and ot her � How t hey can access it (e.g. read/ writ e/ exec/ ..) commonly accessed f iles likely t o be in memor y � Any pr ot ect ion syst em dict at es whet her a given already act ion per f or med by a given subj ect on a given obj ect should be allowed. I n t his case: � Compet es wit h virt ual memory syst em f or physical memory � Obj ect s = f iles � Processes have less memory available t o t hem � P rinciples = users t o st or e code and dat a (addr ess space) � Act ions = operat ions � We’ll t alk mor e about pr ot ect ion syst ems lat er in � Some syst ems have int egr at ed VM/ FS caches t he semest er -11 -12 2

  3. Exercise f or t he Reader ☺ File Syst ems � We t alked a bit about disk int ernals � I f you wer e going t o build your own f ile syst em on t op of a f ixed sized f ile what � Despit e complex int ernals, disks export a would you do? simple array of sect ors � What ot her inf or mat ion would you need t o st or e t her e besides f ile dat a and dir ect or y � How do we go f rom t hat t o a f ile syst em? dat a? � How would you or ganize t hings? -13 -14 Some quest ions File Layout � Would you keep each f ile t oget her � Opt ion 1: All blocks in a f ile must be sequent ially? allocat ed cont iguously � Only need t o list st art and lengt h in direct ory � I f you did, what would you do if a f ile gr ew or � Causes f r agment at ion of f r ee space shrunk? � Also causes copying as f iles gr ow � I f not , how would you keep t r ack of t he � Opt ion 2: Allow f iles t o be broken int o mult iple pieces? pieces � Fixed sized pieces (blocks) or var iable sized pieces (ext ent s)? � I f we ar e going t o allow f iles t o be br oken int o mult iple pieces how will we keep t r ack of t hem ? -15 -16 Blocks or Ext ent s? Finding all P art s of a File � I f f ixed sized block t hen st ore j ust � Opt ion 2A: List all blocks in t he dir ect or y � Direct ories will get pret t y big and also must change t he st ar t ing locat ion f or each one direct ory everyt ime a f ile grows or shrinks � I f variable sized ext ent need t o st ore � Opt ion 2B: Linked st r uct ur e st art ing locat ion and lengt h � Direct ory point s t o f irst piece (block or ext ent ), f irst one point s t o second one � But maybe you can have f ewer ext ent s? � File can expand and cont ract wit hout copying � Blocks = less ext ernal f ragment at ion � Good f or sequent ial access, t errible f or ot her kinds � Ext ent s = less int ernal f ragment at ion � Opt ion 2C: I ndexed st r uct ur e � Direct ory point s t o index block which cont ains point ers t o dat a blocks � Good f or random access as well as sequent ial access -17 -18 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend