Duke CPS 110 - Outline for Today’s Lecture

Unformatted text preview:

1Outline for Today’s LectureAdministrative:– TAs expect to be in Teer tonight– Demo signupsObjective: – File system naming issues continued– Distributed file systems (naming)– Down a level – files themselvesSoft vs. Hard LinksWhat’s the difference in behavior?TerryLynnJamie/Unix File Naming (Hard Links)0rain: 32hail: 480wind: 18sleet: 48inode48inodelink count = 2directory A directory BA Unix file may have multiple names.linksystem calllink (existing name, new name)create a new name for an existing fileincrementinodelink countunlinksystem call (“remove”)unlink(name)destroy directory entrydecrementinodelink countif count = 0 and file is not in active usefree blocks (recursively) and on-disk inodeEach directory entry naming thefile is called a hard link.Each inodecontains a reference countshowing how many hard links name it.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.0rain: 32hail: 48inode48inodelink count = 1directory A0wind: 18sleet: 67directory B../A/hail/0inode67symlinksystem callsymlink(existing name, new name)allocate a new file (inode) with typesymlinkinitialize file contents with existing namecreate directory entry for new file with new nameThe target of the link may beremoved at any time, leavinga dangling reference.How should the kernel handle recursive soft links?Convenience, but not performance!2Soft vs. Hard LinksWhat’s the difference in behavior?TerryLynnJamie/XSoft vs. Hard LinksWhat’s the difference in behavior?TerryLynnJamie/XDistributed File Systems• Naming– Location transparency/ independence• Caching– Consistency• Replication– Availability and updatesservernetworkserverclientclientclientNaming• \\His\d\pictures\castle.jpg– Not location transparent - both machine and drive embedded in name.• NFS mounting– Remote directory mounted over local directory in local naming hierarching.– /usr/m_pt/A– No global viewHer local directory treeusrm_ptHis localdir treefor_exportA Busrm_ptA BHer localtree after mountA Busrm_ptHis aftermounton B3Global Name SpaceExample: Andrew File System/afstmp bin liblocal filesshared files -looks identical toall clientsVFS: the FilesystemSwitchsyscall layer (file, uio, etc.)user spaceVirtual File System (VFS)networkprotocolstack(TCP/IP) NFS FFS LFS etc.*FS etc.device driversSun Microsystems introduced the virtual file systemframework in 1985 to accommodate the Network File System cleanly.• VFS allows diverse specific file systems to coexist in a file tree, isolating all FS-dependencies inpluggable filesystem modules.VFS was an internal kernel restructuringwith no effect on thesyscall interface.Incorporates object-oriented concepts:a generic procedural interface withmultiple implementations.Other abstract interfaces in the kernel: device drivers,file objects, executable files, memory objects.VnodesIn the VFS framework, every file or directory in active use is represented by a vnode object in kernel memory.syscall layerNFS UFSfreevnodesActivevnodes are reference-counted by the structures thathold pointers to them, e.g.,the system open file table.Each vnodehas a standardfile attributesstruct.Vnodeoperations aremacros that vector tofilesystem-specificprocedures. Genericvnodepoints atfilesystem-specificstruct(e.g.,inode,rnode), seenonly by thefilesystem. Each specific file system maintains a hash of its residentvnodes.Example:Network File System (NFS)syscall layerUFSNFSserverVFSVFSNFSclientUFSsyscall layerclientuser programsnetworkserver4Vnode Operations and Attributesdirectories onlyvop_lookup (OUT vpp, name)vop_create (OUTvpp, name, vattr)vop_remove (vp, name)vop_link (vp, name)vop_rename (vp, name, tdvp, tvp, name)vop_mkdir (OUT vpp, name, vattr)vop_rmdir (vp, name)vop_readdir (uio, cookie)vop_symlink (OUT vpp, name, vattr, contents)vop_readlink (uio)files onlyvop_getpages (page**, count, offset)vop_putpages (page**, count, sync, offset)vop_fsync()vnode/file attributes (vattr orfattr)type (VREG, VDIR, VLNK, etc.)mode (9+ bits of permissions)nlink (hard link count)owner user IDowner group IDfilesystemIDunique file IDfile size (bytes and blocks)access timemodify timegeneration numbergeneric operationsvop_getattr (vattr)vop_setattr (vattr )vhold()vholdrele()Pathname Traversal• When a pathname is passed as an argument to a system call, the syscall layer must “convert it to avnode”.• Pathname traversal is a sequence of vop_lookup calls to descend the tree to the named file or directory.open(“/tmp/zot”)vp = getvnode for / (rootdir)vp->vop_lookup(&cvp, “tmp”);vp = cvp;vp->vop_lookup(&cvp, “zot”);Issues:1. crossing mount points2. obtaining rootvnode(or current dir)3. finding resident vnodes in memory4. caching name->vnodetranslations5. symbolic (soft) links6. disk implementation of directories7. locking/referencing to handle raceswith name create and delete operationsHints• A valuable distributed systems design technique that can be illustrated in naming.• Definition: information that is not guaranteed to be correct. If it is, it can improve performance. If not, things will still work OK. Must be able to validate information.• Example: Sprite prefix tablesPrefix Tablesm_pt1usrm_pt2A//A/m_pt1/usr/m_pt2 −> pink/A/m_pt1 −> blue/A/m_pt1/usr/B −> pinkB/A/m_pt1/usr/m_pt2/stuff.below5Performance Issue re:NamingWhat to do about long paths?• Make long lookups cheaper − cluster inodesand data on disk to make each component resolution step somewhat cheaper– Immediate files − meta-data and first block of data co-located• Collapse prefixes of paths − hash table– Prefix table• “Cache it” − in this case, directory infoMeta-Data• File size• File type• Protection - access control information• History: creation time, last modification,last access.• Location of file -which device• Location of individual blocks of the file on disk.• Owner of file• Group(s) of users associated with fileAccess Control for Files• Access control lists - detailed list attached to file of users allowed (denied) access, including kind of access allowed/denied.• UNIX RWX - owner, group, everyoneUNIX access control• Each file carries its access control with it.rwx rwx rwx setuidOwnerUIDGroupGIDEverybody else When bit set, itallows processexecuting objectto assume UID ofowner temporarily -enter owner domain(rights amplification)• Owner has chmod, chgrp


View Full Document

Duke CPS 110 - Outline for Today’s Lecture

Download Outline for Today’s Lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Outline for Today’s Lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Outline for Today’s Lecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?