<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F_Lecture_16</id>
	<title>Operating Systems 2019F Lecture 16 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F_Lecture_16"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_16&amp;action=history"/>
	<updated>2026-05-18T20:02:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_16&amp;diff=22538&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;Note that this lecture was given on Monday rather than Wednesday.  Please don&#039;t come to class for lecture on Wednesday, Nov. 6, instead watch the video below!  ==Video==  The...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_16&amp;diff=22538&amp;oldid=prev"/>
		<updated>2020-03-20T02:08:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Note that this lecture was given on Monday rather than Wednesday.  Please don&amp;#039;t come to class for lecture on Wednesday, Nov. 6, instead watch the video below!  ==Video==  The...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Note that this lecture was given on Monday rather than Wednesday.  Please don&amp;#039;t come to class for lecture on Wednesday, Nov. 6, instead watch the video below!&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
The video from the lecture given on November 4th, 2019 (special time) [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec16-20191104.m4v is now available].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 16&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
Filesystem implementation&lt;br /&gt;
&lt;br /&gt;
* worth looking at the textbook&lt;br /&gt;
&lt;br /&gt;
One view of filesystems is as an implementation of open, read, write, close, etc&lt;br /&gt;
&lt;br /&gt;
But also, with persistent storage, a filesystem is a data structure (on persistent media of some kind)&lt;br /&gt;
&lt;br /&gt;
With standard in volatile memory data structures (ones in process memory), corrupted data structures aren&amp;#039;t a big deal&lt;br /&gt;
 - restart the process&lt;br /&gt;
&lt;br /&gt;
Persistent data structures have to maintain integrity for a long time&lt;br /&gt;
 - much more likely to see corruption&lt;br /&gt;
 - can&amp;#039;t &amp;quot;restart&amp;quot; - that would result in lost data&lt;br /&gt;
   (a restart is a reformat)&lt;br /&gt;
&lt;br /&gt;
Key design constraints for filesystems&lt;br /&gt;
 - store it in blocks (not bytes)&lt;br /&gt;
   - address storage with block numbers and offsets, not addresses&lt;br /&gt;
 - robust in the face of (accidental) corruption&lt;br /&gt;
 - random access is high latency (not true for SSDs)&lt;br /&gt;
 - sequential access is much lower latency&lt;br /&gt;
&lt;br /&gt;
UNIX filesystems have inodes&lt;br /&gt;
 - to allow multiple hard links, so filenames refer to inodes, and inodes refer to data&lt;br /&gt;
&lt;br /&gt;
Many, many UNIX filesystem implementations&lt;br /&gt;
 - ext4 is most common on Linux systems, but xfs is also used&lt;br /&gt;
 - bsd systems traditionally used ufs&lt;br /&gt;
 - btrfs, zfs are also important as next-generation filesystems&lt;br /&gt;
&lt;br /&gt;
Basic organization of UNIX-like filesystems:&lt;br /&gt;
 * data blocks&lt;br /&gt;
 * inode blocks&lt;br /&gt;
   - metadata (timestamps, length, owner, perms, etc)&lt;br /&gt;
   - data or references to data blocks&lt;br /&gt;
 * directory blocks (may be a type of inode block)&lt;br /&gt;
 * superblock(s) &amp;lt;---&lt;br /&gt;
Normally divisions between block types is defined at filesystem creation/formatting (e.g. by mkfs).&lt;br /&gt;
&lt;br /&gt;
Just like files have metadata, so do filesystems&lt;br /&gt;
The superblock stores metadata on the filesystem&lt;br /&gt;
 - needed for when it is mounted&lt;br /&gt;
 - says how big it is, what type, other filesystem-specific parameters&lt;br /&gt;
&lt;br /&gt;
Normally the superblock is cached in RAM&lt;br /&gt;
 - will be updated periodically as filesystem state changes (e.g., number&lt;br /&gt;
   of free inodes)&lt;br /&gt;
 - will be written to disk periodically&lt;br /&gt;
 - most data is static&lt;br /&gt;
&lt;br /&gt;
Superblock is normally the first block of a filesystem&lt;br /&gt;
 - convenient!&lt;br /&gt;
 - but...what if it gets corrupted?  You can&amp;#039;t access the filesystem&lt;br /&gt;
 - but fortunately we have backups as part of the filesystem, at well-known&lt;br /&gt;
   offsets (which can vary by filesystem)&lt;br /&gt;
&lt;br /&gt;
When a filesystem gets corrupted, what do you do?  you check it!&lt;br /&gt;
 - use fsck (file system check)&lt;br /&gt;
&lt;br /&gt;
If fsck has to repair the filesystem because of errors, it could make things worse.&lt;br /&gt;
  - error recovery procedures may cause loss of data&lt;br /&gt;
&lt;br /&gt;
If you really care about the data and don&amp;#039;t have a current backup, do a low level (block level) copy of the filesystem *before* you run fsck.&lt;br /&gt;
&lt;br /&gt;
You really want backups of your openstack instances!&lt;br /&gt;
&lt;br /&gt;
The people who really understand filesystem structure are forensic analysts&lt;br /&gt;
 - helps them find deleted data&lt;br /&gt;
&lt;br /&gt;
On most UNIX filesystems, delete is just unlink&lt;br /&gt;
 - so inodes are reclaimed when there are no hard links to it&lt;br /&gt;
 - but being reclaimed does not mean it is erased, it is just added to the pool of inodes that can be overwritten&lt;br /&gt;
 - same for data blocks&lt;br /&gt;
&lt;br /&gt;
fsck on large disks&lt;br /&gt;
-------------------&lt;br /&gt;
 * fsck involves walking the filesystem data structure looking for inconsistencies&lt;br /&gt;
   - data blocks referred to by multiple inodes&lt;br /&gt;
   - deleted inodes that still have names&lt;br /&gt;
   - etc.&lt;br /&gt;
 * fsck thus involves a lot of random disk access&lt;br /&gt;
&lt;br /&gt;
Older systems would tell you not to just turn off the computer...why?&lt;br /&gt;
 - late 1990s&lt;br /&gt;
 - because filesystem state was cached in RAM and would be lost&lt;br /&gt;
   - write caching&lt;br /&gt;
 - so filesystem on disk would be left in an inconsistent state,&lt;br /&gt;
   would need to run fsck to potentially repair&lt;br /&gt;
 - fsck times got longer and longer (10+ minutes), hours for RAID arrays&lt;br /&gt;
&lt;br /&gt;
RAID = redundant array of inexpensive disks originally, ways to combine&lt;br /&gt;
       multiple disks into one logical disk with higher performance (raid-0,&lt;br /&gt;
       striping), better reliability (raid-1, mirroring), or a mix of the two&lt;br /&gt;
       (raid 5 and higher)&lt;br /&gt;
&lt;br /&gt;
So, how do you avoid long fsck times?&lt;br /&gt;
 - write everything twice&lt;br /&gt;
 - write first to a journal: sequential record of activity, changes to fs&lt;br /&gt;
 - write later to main filesystem data structures (random access)&lt;br /&gt;
&lt;br /&gt;
With a journal, on fsck you just have to check the journal&lt;br /&gt;
 - any inconsistencies will be there&lt;br /&gt;
 - doesn&amp;#039;t handle inconsistencies in &amp;quot;old&amp;quot; data&lt;br /&gt;
&lt;br /&gt;
next-generation filesystems have integrity protection for all data and metadata&lt;br /&gt;
 - zfs &amp;amp; btrfs&lt;br /&gt;
 - will catch silent corruption&lt;br /&gt;
&lt;br /&gt;
log-structured filesystems&lt;br /&gt;
 - writing twice seems silly, especially if you are writing a lot&lt;br /&gt;
 - idea - why not make the journal the entire filesystem?&lt;br /&gt;
 - log will fill up, so you periodically clean things (write out new entries for up to date data and mark old ones as deleted)&lt;br /&gt;
 - originally developed for systems with high write load, such as online databases&lt;br /&gt;
 - but for today, we used them in solid-state disks&lt;br /&gt;
&lt;br /&gt;
Log-structured &amp;quot;filesystems&amp;quot; aren&amp;#039;t directly accessible in an SSD&lt;br /&gt;
 - they are below the block interface level&lt;br /&gt;
 - needed because writes to same portion of SSD will destroy it&lt;br /&gt;
 - log structure is for wear leveling&lt;br /&gt;
&lt;br /&gt;
Holes in files in UNIX&lt;br /&gt;
 - if a file is all zeros, why allocate data blocks for those zeros?&lt;br /&gt;
 - if you just write a block of zeros, it will be allocated&lt;br /&gt;
 - but if you lseek past the end of a file and then write, the potions you skipped over will be filled in with virtual zeros (zero data that isn&amp;#039;t stored)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>