File System Implementation
Transcript
<v Tony Gurney>Oh man, I've just noticed the last 159 minutes and 59 seconds. That's going to hurt 8 minutes.</v> <v Tony Gurney>OK, so the recording started again, so move on to the second part.</v> <v Tony Gurney>So we're looking back now to Chapter 11, which is implementing file systems.</v> <v Tony Gurney>Then we started talking about filesystems last week.</v> <v Tony Gurney>And what I wanted to do was do the mass storage stuff first.</v> <v Tony Gurney>To give you an idea of how we might store things on a device and that mate then impact about how we decide on the failed system that we choose.</v> <v Tony Gurney>And how we do it?</v> <v Tony Gurney>OK, so we'll look at different ways of doing it as.</v> <v Tony Gurney>We normally do.</v> <v Tony Gurney>Uhm, to train figure. The best way of setting up these failed systems that we talked about before.</v> <v Tony Gurney>As we go through it and.</v> <v Tony Gurney>I I'm under no illusions that.</v> <v Tony Gurney>These sorts of stuff that will be talking about.</v> <v Tony Gurney>Are</v> <v Tony Gurney>understandable on the first time through much over as, but some of it you need to call back and grab yourselves about paper and just try and work your way through. So when we talk about multi level indexes for.</v> <v Tony Gurney>Fails to rejoin I failed system.</v> <v Tony Gurney>You'll probably want to go Buik, sketch it out and try and understand.</v> <v Tony Gurney>How it all fits together?</v> <v Tony Gurney>'cause if you can understand it first time through.</v> <v Tony Gurney>Well done.</v> <v Tony Gurney>You cruise the old module.</v> <v Tony Gurney>I'm not one of them. It takes me or you, but we've got time to get into my head.</v> <v Tony Gurney>OK, so we want to talk about implementing this file structure. That's going to be on our mass storage unit.</v> <v Tony Gurney>So let's talk about.</v> <v Tony Gurney>The definitions when we're going through just so we have a.</v> <v Tony Gurney>Uh, set language that we can talk about things for, and usually when I get through this I'll start talking about disks 'cause of most often hard disks. But of course it can be anything they don't have to be hard disks.</v> <v Tony Gurney>So we'll have failed systems on these desks, not necessarily a disk, could be anything.</v> <v Tony Gurney>And those failed systems need to allow both the user to get access to things.</v> <v Tony Gurney>And allow the disks to store all the data in a way that's easily accessible and rememberable. He says, making up the water rememberable.</v> <v Tony Gurney>Ah.</v> <v Tony Gurney>There will be a direct link between the failed system and the hard disk, probably.</v> <v Tony Gurney>Because.</v> <v Tony Gurney>The amount of data that we'll be storing things and will probably be a multiple of the size of the block on the disk now.</v> <v Tony Gurney>It's not a one to one because you have different devices.</v> <v Tony Gurney>That would be kinda silly to have, ah.</v> <v Tony Gurney>A sector of 333 bytes that doesn't fit into anything. So most of these they end up being powers of two that fit into one another.</v> <v Tony Gurney>So we have.</v> <v Tony Gurney>Blocks of sectors.</v> <v Tony Gurney>So we take the stuff that's on the disk, bitter, enter chunk, create block.</v> <v Tony Gurney>We will also have information about where the files are, and that's not fail control block.</v> <v Tony Gurney>We need to have information about the device itself, so they'll be device drivers.</v> <v Tony Gurney>So we've got all of these different levels users and how they fail. System thinks of itself and how. That's then organize and how that then goes onto a disc and how that disk is then accessed, which means you'll get a whole pile of layers.</v> <v Tony Gurney>That we get through before we get some data. And you might think that that's.</v> <v Tony Gurney>Overly complicated.</v> <v Tony Gurney>And in fact, some operating systems.</v> <v Tony Gurney>Well, strap out loads of these things depending on.</v> <v Tony Gurney>What they're being used for.</v> <v Tony Gurney>But for a general operating system, when it's used for different things, this is really the only way that we can do it. Of course we have.</v> <v Tony Gurney>Different devices.</v> <v Tony Gurney>Look at the machine that you're looking at just now.</v> <v Tony Gurney>Even if you're watching this new phone, you probably have two different storage devices. You probably get your internal memory and a micro SD card, for example.</v> <v Tony Gurney>So you probably get 2 storage devices.</v> <v Tony Gurney>At least.</v> <v Tony Gurney>So they of course need different biocontrol. 'cause of physically different.</v> <v Tony Gurney>But we don't want to know about it, so we need some sort of.</v> <v Tony Gurney>File system that they will both use and the fails on that need to be organized.</v> <v Tony Gurney>And we need to have a.</v> <v Tony Gurney>We of how we think about it. No matter what the device and one that makes sense to US users rather than people who understand about.</v> <v Tony Gurney>The internals of an operating system like you guys.</v> <v Tony Gurney>Because that's how we, through application programs will see it.</v> <v Tony Gurney>So the file system gets through all these layers in order to access things.</v> <v Tony Gurney>And that means that it makes it easy to add on. For example, our USB drive, because that you guys be driver will live there.</v> <v Tony Gurney>It will have a slightly different biocontrol, but everything else up here.</v> <v Tony Gurney>Will all work in the same way and we won't have to care.</v> <v Tony Gurney>We don't care that it's physically different. We don't care that we're accessing a USB drive or a network or a DVD ROM.</v> <v Tony Gurney>It makes no difference to us.</v> <v Tony Gurney>We just keep give us it.</v> <v Tony Gurney>But what we're most often talking about as the hard disk, or just looked at, let's set up in the way that we've just discussed.</v> <v Tony Gurney>OK, so the device drivers will actually physically do the access of disk that we've been talking about. The one where you go to a specific cylinder on the disk, which is specific sector and read that in go to drive one cylinder seven to two track two sector 10.</v> <v Tony Gurney>And during the data it's India into memory allocation 1060 may be the sort of command that you give to the device driver.</v> <v Tony Gurney>So coaster device grausam data put in memory done.</v> <v Tony Gurney>Basic file system will grab the.</v> <v Tony Gurney>Logical block.</v> <v Tony Gurney>And remember that logical block make the made up of multiple sectors, so you may have to give.</v> <v Tony Gurney>Four of these commands to get a block.</v> <v Tony Gurney>And that data is inhaled.</v> <v Tony Gurney>Somewhere.</v> <v Tony Gurney>So pointed out point we're looking at the internals of a hard disk that there's a controller. One of the things I wanna can show that will probably be a buffer, some memory. So the data that you read from the disk.</v> <v Tony Gurney>Can be held in memory until it's ready to go.</v> <v Tony Gurney>Two wherever requested it.</v> <v Tony Gurney>When you think about it, you have to have that. Otherwise what you'd have to do is synchronize the whole system. Being ready for some data to be put to a particular piece of memory.</v> <v Tony Gurney>When the disk was ready.</v> <v Tony Gurney>So the whole system has to stop while the district dates and the head moves in and out in the data is red and drawing.</v> <v Tony Gurney>No.</v> <v Tony Gurney>Put some memory on their color buffer and have it ready when the computer comes back.</v> <v Tony Gurney>I will be calling device comes back.</v> <v Tony Gurney>So we've got this idea that we've got different things. We've got. The physical setup will get the logical set up, and we need to have something in between.</v> <v Tony Gurney>Name?</v> <v Tony Gurney>Translates between.</v> <v Tony Gurney>So the logical fail system thinks about fails we. We think about them.</v> <v Tony Gurney>With any man, uh.</v> <v Tony Gurney>Creation date tonight. Size and whatever happens to be.</v> <v Tony Gurney>And that's great, because, UM.</v> <v Tony Gurney>Different devices may have different logical failed systems.</v> <v Tony Gurney>We can't employees whatever.</v> <v Tony Gurney>Operating system would like or in a device, so we might be able to, for example, set up our hard disk to have all the different things we saw a week or two ago that there Mac operating system can have labels. It can put colors against the file.</v> <v Tony Gurney>Well, we can't mandate that. For example, our seed desk.</v> <v Tony Gurney>Has a place on the file to store that label, so it might have a slightly different.</v> <v Tony Gurney>Failed system with slightly different.</v> <v Tony Gurney>Meta data.</v> <v Tony Gurney>Some things are fairly universal. A file name for example.</v> <v Tony Gurney>My favorite color no.</v> <v Tony Gurney>So we have different file systems for different reasons, perhaps because it's a different device like the CD or DVD.</v> <v Tony Gurney>Perhaps because you want to do different things to it because you're trying to set up a file system to be fairer or to have better access from different types of data. And we talked about that before when we talked about file systems in general.</v> <v Tony Gurney>That's why we don't just have one.</v> <v Tony Gurney>If we could say yes, here's the file system.</v> <v Tony Gurney>And it works great for everything. Well, be fantastic. We could take all of our data everywhere we go when everything could read it.</v> <v Tony Gurney>But it doesn't work for everything and it can't work for everything.</v> <v Tony Gurney>In fact.</v> <v Tony Gurney>There's barely a month goes by without somebody saying oh, by the way I've come up with this new idea.</v> <v Tony Gurney>So let's get a file system to implement it.</v> <v Tony Gurney>I've got two network filesystems on my disk. I've got one drive and Google Drive.</v> <v Tony Gurney>They use different file systems. They use different device drivers. You use different accesses so we get new things all the time.</v> <v Tony Gurney>So how do we start up?</v> <v Tony Gurney>Setting these things up with some things that we will need on our devices.</v> <v Tony Gurney>Again, we looked at media. We talked about having a boot to control block.</v> <v Tony Gurney>Something that allows us to.</v> <v Tony Gurney>Start up and operating system from that device.</v> <v Tony Gurney>We'll have details on the different volumes, so if we are split up our device into different volumes will need to remember that.</v> <v Tony Gurney>How many blocks there are?</v> <v Tony Gurney>We have the start. We have the end, what's been used, what's free so that we can save things onto it.</v> <v Tony Gurney>You're talking of saving things. We probably just don't want just one big pool of files. We probably want to have some sort of structure on them, some sort of directory structure, so that will need to be stored.</v> <v Tony Gurney>And of course, within that you will have and again, well spoken about this before.</v> <v Tony Gurney>Some data about the file itself, the file control block storing all the different information about the file that we have.</v> <v Tony Gurney>Now it's all on the desk and has to stay on the disk.</v> <v Tony Gurney>Because.</v> <v Tony Gurney>Eventually will turn off your computer.</v> <v Tony Gurney>So it has to be on the desk.</v> <v Tony Gurney>To remember it the next time you turn on, but we've probably to speed up things. Also want to have some of that in memory.</v> <v Tony Gurney>We want to have things in memory so that we know where fails are so we can go and get them.</v> <v Tony Gurney>'cause otherwise every time we wanted to fail we would have to go to the directory structure.</v> <v Tony Gurney>That's stored on the disk. Find out where that file is, and then do another access.</v> <v Tony Gurney>So at minimum, we're doubling.</v> <v Tony Gurney>File access times because we have to go back to the device twice.</v> <v Tony Gurney>So what we would tend to do?</v> <v Tony Gurney>In the diagram is better than this slide here.</v> <v Tony Gurney>What will tend to do is bring see the directory structure into memory so when we open a file we already have the directory structure will know Perez and that allows us to go to our disk and grab the data.</v> <v Tony Gurney>Whether we are reading it or rating to.</v> <v Tony Gurney>Sorry, one other, opening it or reading from it.</v> <v Tony Gurney>So once we open the family name.</v> <v Tony Gurney>So we say open thread dot TXT.</v> <v Tony Gurney>We have a directory structure and memory and it goes and says OK about files that they are.</v> <v Tony Gurney>Well, no, not that fails. They had let's remember that too.</v> <v Tony Gurney>So that the fail control block can also be brought into memory. So as we're working our way through that, Flynn reading different bits.</v> <v Tony Gurney>We can then going get up from our secondary storage.</v> <v Tony Gurney>So we'll get different ways of accessing it, and to speed up we bring them in.</v> <v Tony Gurney>That's great if we have the memory.</v> <v Tony Gurney>Because depending on the size of your desk, depending on the number of disks depending number of storage devices.</v> <v Tony Gurney>Not might be a lot of directory structures or maybe a lot of fail access to tables.</v> <v Tony Gurney>That's going to be a lot of memory.</v> <v Tony Gurney>We also have.</v> <v Tony Gurney>The idea of partitions where we split up our devices and to multiple logical sections, and they need to be connected to the system somewhere. That connection is called mounting and again we spoke about this last week this idea.</v> <v Tony Gurney>That sometimes we don't even notice it. We stick in a USB drive and it stuck to users drive G.</v> <v Tony Gurney>Well lucky hose.</v> <v Tony Gurney>The only time it actually gets upset is when we take it out without telling the operating system we're going to remove it because all of these pieces of data that we are saving failed control blocks, directory structures, even the data itself.</v> <v Tony Gurney>They have to be updated.</v> <v Tony Gurney>'cause if we've read them into memory and change things, we have to write them back out at some point.</v> <v Tony Gurney>And if we remove all devices without doing that, all of those structures will be out of date and we might lose data.</v> <v Tony Gurney>Either because we haven't saved it to the structure or because we haven't saved the pointers through the data.</v> <v Tony Gurney>And the directory structure or the failed control block.</v>
<v Tony Gurney>So we'll get pointers to these partitions, will get pointers about where they live. Unix for example might have one disk for programs, and that's.</v> <v Tony Gurney>Mounted at a place in the file system called Slash and Ben for Binary for program files, and it may have another disk that stores user data and had might be.</v> <v Tony Gurney>Mounted at Slash USR for user.</v> <v Tony Gurney>Windows uses Plato's Max usernames, it just depends on the operating system.</v> <v Tony Gurney>Most devices all will have a root partition, the main one where your operating system is stored.</v> <v Tony Gurney>When you start up the computer and you've probably seen this on your own machine, it says checking file system, so it's going checking what devices are there, but more than that it's also checking that the device is consistent.</v> <v Tony Gurney>Are all the files in the directory structure pointing to other there?</v> <v Tony Gurney>On the pointing to the right, but.</v> <v Tony Gurney>Is everything OK and if not you can have an issue.</v> <v Tony Gurney>And some of you may have seen these issues when you start it up your machine.</v> <v Tony Gurney>'cause if it fails that chick.</v> <v Tony Gurney>You can have all sorts of problems where it will go away and it will start to go through not just as superficial. Check that really detailed to check to make sure that all your data is set up properly.</v> <v Tony Gurney>All OK so far.</v> <v Paraskevas Chronopoulos>OK with that.</v> <v Tony Gurney>OK, thank you.</v> <v Tony Gurney>So we talked about having multiple fails. We talked about organizing them into directories. So how are we going to implement that?</v> <v Tony Gurney>We could just have a list.</v> <v Tony Gurney>Let's directories on .2.</v> <v Tony Gurney>The directory.</v> <v Tony Gurney>Per exists on disk.</v> <v Tony Gurney>Problem with a linear list. Anybody that's done in a programming will tell you that searching through a linear list is slow.</v> <v Tony Gurney>And it's the sort of thing we were talking about earlier. Purse give us we are sometimes will lucky and it's it's start. Some things were really unlucky and it's at the end.</v> <v Tony Gurney>But on average it will take.</v> <v Tony Gurney>Exactly half the time to find something, uh, West, as the list is long.</v> <v Tony Gurney>So dead simple to implement, but.</v> <v Tony Gurney>On average, half the length to access it.</v> <v Tony Gurney>So some systems use something called a hash table.</v> <v Tony Gurney>I don't know if you've come across hash tables before.</v> <v Tony Gurney>And that is a question I don't know if we need to spend time explaining hashes.</v> <v Tony Gurney>Yes no.</v> <v Tony Gurney>It's something the chart of copper hand. If you've heard of a hash.</v> <v Tony Gurney>Table.</v> <v Paraskevas Chronopoulos>Yes, and I think we.</v> <v Tony Gurney>Yeah.</v> <v Paraskevas Chronopoulos>Came up with a list term last year, but.</v> <v Tony Gurney>Happy New year.</v> <v Paraskevas Chronopoulos>Like a map.</v> <v Tony Gurney>Like in March.</v> <v Paraskevas Chronopoulos>I think.</v> <v Tony Gurney>Yeah, Kendall.</v> <v Tony Gurney>OK so so not enough people have come across it, so a hash table.</v> <v Tony Gurney>Is in essence a mathematical function, so your point some data at this function and it gives you back end number.</v> <v Tony Gurney>The idea is that that number is unique.</v> <v Tony Gurney>So that if you point in the same data at it will always give you that same number.</v> <v Tony Gurney>But conversely, if you give it the number, it can give you the data.</v> <v Tony Gurney>So it's a very quick way.</v> <v Tony Gurney>Of pointing to.</v> <v Tony Gurney>Some data because you can, rather than searching through.</v> <v Tony Gurney>The list.</v> <v Tony Gurney>You can point the data to create the hash.</v> <v Tony Gurney>And not points to a particular place.</v> <v Tony Gurney>The track comes in that function that gives you the hash.</v> <v Tony Gurney>Because what you want is a set of results that are unique.</v> <v Tony Gurney>You don't want to point the same data to it and it comes up with the same number. Sometimes it happens. It's called a collision.</v> <v Tony Gurney>Uh, and that can cause an issue, but it does speed up getting access to directories.</v> <v Tony Gurney>Uh, I'll remember and put a link to an explanation of hash tables.</v> <v Tony Gurney>And the module materials if you want to read more about them. If no, it just takes a lot for it. That that's how it works.</v> <v Tony Gurney>Next thing we have to think about is how we allocate data on the device.</v> <v Tony Gurney>Do we see right? Everything is contiguous.</v> <v Tony Gurney>Everything has to stay together on the disk one block after the other.</v> <v Tony Gurney>That's fantastic for performance, 'cause if you want to read a file in that file has ten blocks.</v> <v Tony Gurney>Think about how hard disk setup.</v> <v Tony Gurney>You can just read block 10/11/12, thirteen 1415.</v> <v Tony Gurney>And it's all going, so you just read it as it's going. That's great.</v> <v Tony Gurney>For the problem becomes what happens if that fails size changes. Do you leave extra space for it?</v> <v Tony Gurney>If no, if they fail, gets bigger, and it's bumped up against something else, do you have to move it to enough space on the disk?</v> <v Tony Gurney>And do you have another space on the disk is big enough?</v> <v Tony Gurney>And what do you do with that space that's left? What do you put in there? So it's the same kind of arguments that we had five or six weeks ago when we were talking about fragmentation. Your disk can fragment.</v> <v Tony Gurney>And you can have spaces where you can't use things and you can have lots of space on the disk, but none of them are big enough to actually store what you need.</v> <v Tony Gurney>On the other hand, it's really simple to program.</v> <v Tony Gurney>World is a failed start. How big is that goal?</v> <v Tony Gurney>Oddly, that's one of the reasons why you might want different partitions in different file systems.</v> <v Tony Gurney>Or if you do partition that, hide.</v> <v Tony Gurney>The operating system itself.</v> <v Tony Gurney>That's not going to change much.</v> <v Tony Gurney>The files are going to be there. You're not going to make them bigger or smaller, they'll just exist.</v> <v Tony Gurney>So why not have a really simple really fast contiguous allocation failed system for the?</v> <v Tony Gurney>Operating system but have a different file system for your data.</v> <v Tony Gurney>That allows the data to grow, so there's one reason why you might want to partition a disk and use different file systems or not.</v> <v Tony Gurney>So for contiguous allocation, for.</v> <v Tony Gurney>Fragmentation you might have to bring it together and that's called compaction.</v> <v Tony Gurney>But it's really simple.</v> <v Tony Gurney>We have a logical file system.</v> <v Tony Gurney>With one entry and that points to a physical fail system with another entry.</v> <v Tony Gurney>This is one of the things I was talking about by the way, where you might have to go back and look at it.</v> <v Tony Gurney>This I'm I'm. I'm not convinced with these cakes or diagram.</v> <v Tony Gurney>But they make more sense when you're reading a book.</v> <v Tony Gurney>So I'm not going to spend too much time on them in this lecture.</v> <v Tony Gurney>Well, we need to do is go back to them later on.</v> <v Tony Gurney>And that will help when you're thinking about.</v> <v Tony Gurney>Where things are on the desk, so for this very simple one it's saying we're looking for a particular block.</v> <v Tony Gurney>So particular part of the file, so we go to possession Q which is a start of the fail and then and offset are.</v> <v Tony Gurney>So it's basically saying go to the start of the Flynn, then go this amount into the failed to get the better data that we need.</v> <v Tony Gurney>And for our purposes in this case.</v> <v Tony Gurney>Each of these blocks is 512 bytes long.</v> <v Tony Gurney>OK, so that's the general idea with these diagrams. As I say, we've got a few more coming up. I'm not going to spend the GS on them.</v> <v Tony Gurney>Because I do think you have to go through.</v> <v Tony Gurney>In quite detailed.</v> <v Tony Gurney>Quite a detailed fashion to try and understand what wondering, so that's the idea of spent some time on this one. I won't be spending time on. The later ones are more interested in diagrams like this, 'cause I think they are.</v> <v Tony Gurney>Easier to see.</v> <v Tony Gurney>So what we've got here is how we're thinking about our file. You get a file called count.</v> <v Tony Gurney>And we can store that in our directory. Seeing count starts at 0 and it is too long.</v> <v Tony Gurney>And if we go to a physical device, we can see that starting at 0.</v> <v Tony Gurney>And for two blocks we have a failed count.</v> <v Tony Gurney>TR stops at 14 in his three, so we go to 14. Oh look, there's T yarn. It takes 1/2.</v> <v Tony Gurney>Three books.</v> <v Tony Gurney>Meal starts at 19 and a 6123456 good. It's all working as we expect.</v> <v Tony Gurney>Lists the same if it's the same.</v> <v Tony Gurney>OK, so it's contiguous. It starts at particular place and goes on for a certain number of blocks.</v> <v Tony Gurney>So great for unchanging data or less great for files that change, so some systems use.</v> <v Tony Gurney>Still contiguous?</v> <v Tony Gurney>But he used something called an extent.</v> <v Tony Gurney>The extend the contiguous file.</v> <v Tony Gurney>Uhm?</v> <v Tony Gurney>Queen, you ask for a certain when you ask to create a file.</v> <v Tony Gurney>It allocates you an extent, a certain number of blocks.</v> <v Tony Gurney>And you can use those blocks.</v> <v Tony Gurney>And you're allowed to keep those blocks. And if you use them, that's great. And if you don't, well, that's your problem.</v> <v Tony Gurney>Use quite often in systems so so you think about our Begg IBM mainframe, where you've got lots of different data on it.</v> <v Tony Gurney>It makes you think very closely about how much data you're going to have, because you can ask for an extension. You can ask for whatever size that is that because you are allocating that amount.</v> <v Tony Gurney>You're also charged for that might be an internal or an external thing, but your child, if you want a certain amount of data.</v> <v Tony Gurney>So you're very careful to say, well, this is what I actually need, rather than just saying, Oh yes, give me lots and lots of data.</v> <v Tony Gurney>I want to store hundreds and hundreds of things.</v> <v Tony Gurney>So it's.</v> <v Tony Gurney>It's quite useful, and those kinds of things where you have.</v> <v Tony Gurney>A big system where you want the speed of access, 'cause if you're channeling through a huge database, you want to just go.</v> <v Tony Gurney>And run through it. You don't want to be all over the disk.</v> <v Tony Gurney>But never mind, you won't have an idea how big your data is, so you don't take resources from other places.</v> <v Tony Gurney>So you allocate an extent I contiguous block and that's €10.</v> <v Tony Gurney>But the fail can get bigger, so you can actually ask for another extent.</v> <v Tony Gurney>And get another block of disks is another another block set of blocks is another contiguous set. So now you're fails in two contiguous sets of books.</v> <v Tony Gurney>Which poses a problem.</v> <v Tony Gurney>Because how do you know that those two extents belong to the same failure? Going to have to connect them somehow.</v> <v Tony Gurney>So we're going to have to start linking things.</v> <v Tony Gurney>So the end of the extent might point to the next extent, or you may have a file somewhere else. I zone or this file is this extent and this extent you know one of the ways that we've looked at before.</v> <v Tony Gurney>But it suggests something else as well, but we can allocate contiguous set of blocks and then another contiguous set of blocks. Now another contiguous set of blocks.</v> <v Tony Gurney>And link them all together.</v> <v Tony Gurney>Why not just allocate one block and then link that?</v> <v Tony Gurney>So rather than saying I need 50 megabytes, see I need a file.</v> <v Tony Gurney>And as you have failed, grows and changes, you get you get.</v> <v Tony Gurney>Allocated extra resources.</v> <v Tony Gurney>To cope with the size of that fail.</v> <v Tony Gurney>That's really helpful for resources because you're not using, for example, in an extent where you ask for that 50 megabytes, but to start off with your failures 2 megabytes so you're wasting 4 to 8 megabytes of all that space and side it's not used.</v> <v Tony Gurney>Uhm?</v> <v Tony Gurney>You have no fragmentation, so you have no or where we've deleted this file, and there's now a spare set of blocks. Can we fit anything in there? Because everything just points to the next one, so you're like 8/1 at a time because no spaces, no problem.</v> <v Tony Gurney>We do have to manage the space 'cause we might still delete files and have blocks become available. So we have to remember where that spear space is.</v> <v Tony Gurney>And because we're only getting one at a time because they're not contiguous, we're back to our problem that we had.</v> <v Tony Gurney>When we're accessing the desk, their heads all over the place.</v> <v Tony Gurney>Not just for different files, but sometimes for the same file.</v> <v Tony Gurney>And abide Lee.</v> <v Tony Gurney>Fragmented fail can take a long time to access.</v> <v Tony Gurney>Some of you may have come across that. Some of you may have run a defragmentation utility on your own hard disk, and what that does is, in essence, even though you're running a linked system.</v> <v Tony Gurney>It grabs all the different.</v> <v Tony Gurney>Blocks that are linked and sticks all together in one big contiguous block.</v> <v Tony Gurney>So when you're accessing it, things called much more quickly.</v> <v Tony Gurney>So swings around abouts.</v> <v Tony Gurney>Things might become fragmented.</v> <v Tony Gurney>But we don't have to take pills of data.</v> <v Tony Gurney>At once.</v> <v Tony Gurney>On the other hand, every block is connected to next blocks or something happens in the middle of that block, your suddenly lost and you don't know where to go next, so reliability can be a problem.</v> <v Tony Gurney>But it's a fairly.</v> <v Tony Gurney>Robust system unless you.</v> <v Tony Gurney>And.</v> <v Tony Gurney>Stop the system. So if you just turn it off while doing eject it and that's why it complains when you just pull out a USB drive. 'cause most USB drives use this kind of system and it's called a file allocation table.</v> <v Tony Gurney>It's been around for.</v> <v Tony Gurney>40 years.</v> <v Tony Gurney>And not Begg helpdesk that I bought used it.</v> <v Tony Gurney>It certainly has an allocation table.</v> <v Tony Gurney>Table where it says.</v> <v Tony Gurney>This is a fail, and here's the first block.</v> <v Tony Gurney>So you go to get that block and at the end of that block it says, oh, by the way, here's the next block. So you go to get the next block and that linked list just continues on until you get to the end.</v> <v Tony Gurney>They're all different.</v> <v Tony Gurney>I am variations on that, so you might want to have the whole list to begin with so you don't have to read the blocking again, get the next one.</v> <v Tony Gurney>Ah.</v> <v Tony Gurney>You might have.</v> <v Tony Gurney>Numbers of blocks at your store, so you may not store everything, even mate. Store the first few so we can get access to them. It just depends.</v> <v Tony Gurney>You may also decide to store the point or not at the end, but at the beginning so that the first thing you do is the pointer to the next block, so you can be ready to go and get it.</v> <v Tony Gurney>Something like that.</v> <v Tony Gurney>So you get the block and it gets a pointer to your next list. It next item in the list.</v> <v Tony Gurney>So we have something like this a fail.</v> <v Tony Gurney>This says it starts at 9.</v> <v Tony Gurney>So we go to 9.</v> <v Tony Gurney>And we read it and it's a pool diagram that's not supposed to see one in the US supposed to see 16.</v> <v Tony Gurney>So that goes to 16 and 16 points to one.</v> <v Tony Gurney>And one points to 10 and 10 points to 25 and 25.</v> <v Tony Gurney>Sales minus one.</v> <v Tony Gurney>Which is under tension for seeing.</v> <v Tony Gurney>Well done.</v> <v Tony Gurney>And the other thing was stored in this directory as the end block. So if we get through this it's worked its way through. We've got to 25. N said it's ending that matches up then that gives us some comfort. We know that we've got the whole file.</v> <v Tony Gurney>Fail allocation table.</v> <v Tony Gurney>Doesn't bother with the end block, it just has this start block.</v> <v Tony Gurney>Same idea it says go to 217 counts of first one and that's got linked to 618, which is all linked to 339.</v> <v Tony Gurney>And then it stops, but there's no link bike, so will fail allocation table.</v> <v Tony Gurney>Method can't tell if you haven't got the whole file.</v> <v Tony Gurney>OK everyone, happy without bidding for we move on to more complicated methods.</v> <v Tony Gurney>OK, well one of the issues that we have here is speed, so we point to 217.</v> <v Tony Gurney>And we have to read 217 to know that we need to go to 618. So we put that in and say, can we get 618 please? And again we have to then read 618 to know that we also need 329. So I put that into asset coming get Theo name please. And then we go and get that.</v> <v Tony Gurney>And it can take everywhere.</v> <v Tony Gurney>And the same.</v> <v Tony Gurney>Issues that we had when we were looking at how we get.</v> <v Tony Gurney>I am different blocks when we have a block you.</v> <v Tony Gurney>We could be miles away from it.</v> <v Tony Gurney>By the time we, we know that we need to go and get this next block from the desk. So maybe instead of pointing to from each individual block, we store all the blocks, we have an index that says, not just.</v> <v Tony Gurney>We'll defrost blockers, but we are all the blocks are.</v> <v Tony Gurney>So next time the same file.</v> <v Tony Gurney>Doesn't point to the first block in the data.</v> <v Tony Gurney>It points to an end. Explore cannot index. Block says OK. Well this file.</v> <v Tony Gurney>Use these blocks nine, sixteen, 110 and 25.</v> <v Tony Gurney>So you can take those and see. Please go and give us.</v> <v Tony Gurney>All of these blocks at once, and that gets the whole failing.</v> <v Tony Gurney>Clearly, because you're using a whole block, you may not use all the.</v> <v Tony Gurney>Space you have for the index block.</v> <v Tony Gurney>So all these minus ones or just showing you well, actually we could store a lot more in here. In a sense it's wasting space, but.</v> <v Tony Gurney>Probably worth it for the speed.</v> <v Tony Gurney>But it gives us to get to request all of these blocks at once.</v> <v Tony Gurney>So it's an indexed.</v> <v Tony Gurney>Uh, we have doing it.</v> <v Tony Gurney>So.</v> <v Tony Gurney>We have an overhead 'cause we're going index block.</v> <v Tony Gurney>And also.</v> <v Tony Gurney>Brings up a different question. What happens if you?</v> <v Tony Gurney>Use up all of these.</v> <v Tony Gurney>Well, there's no reason if we have one index blocks, we can't have another index block, so this last one, for example, might point to another block.</v> <v Tony Gurney>There's a second index block to give us the rest of the file.</v> <v Tony Gurney>Or the next chunk of the failover happens to be so we can start to.</v> <v Tony Gurney>Split up the file into all these blocks.</v> <v Tony Gurney>So we can move from single.</v> <v Tony Gurney>Index tables to multiple index tables.</v> <v Tony Gurney>So we start pointing at one thing.</v> <v Tony Gurney>Which points to more than one thing which points to all the different chunks of the file.</v> <v Tony Gurney>So we can have single things we can have.</v> <v Tony Gurney>Multiple things where we point at multiple blocks at once.</v> <v Tony Gurney>We can have multiple multiple things where the blocks that we point to themselves point to more blocks.</v> <v Tony Gurney>So depending on the data that we're storing dependent, how complicated for want to make this? Depending how big of files are depending depending behind it pending.</v> <v Tony Gurney>Everything about this stuff depends.</v> <v Tony Gurney>We can implement them, and in fact there's nothing that says we only have to do one. Unix NFS will do all of these all at one time, so let's have some things are direct blocks, so you just point to the data.</v> <v Tony Gurney>Some will have single indirect, so you've got an index. It points to the data and some have double or triple and directs where you point to the data, which points to more indices, which finally point to the data.</v> <v Tony Gurney>There's nothing stopping you have any combination that you want.</v> <v Tony Gurney>Well, it will come down to is what's best for your data and what runs the most quickly.</v> <v Tony Gurney>Because depending on the access pale access tape you choose depending on the file system you use.</v> <v Tony Gurney>They all have different consequences for the performance. If you've just got one contiguous, fail, great, you read it really quickly. Fantastic.</v> <v Tony Gurney>You've got to read an index file first. That will be a hit.</v> <v Tony Gurney>And you can mitigate that by bringing the index into memory and using that instead, so there's all of these.</v> <v Tony Gurney>Pure wasn't coins that half to be weighed by whoever's decide designing the operating system.</v> <v Tony Gurney>And in general.</v> <v Tony Gurney>Run an extra.</v> <v Tony Gurney>Instruction on the CPU rather than doing an extra access to disk, 'cause as well said all along.</v> <v Tony Gurney>Access to desk is far, far slower than just doing an extra instruction.</v> <v Tony Gurney>So finally we want to talk about.</v> <v Tony Gurney>How we remember not just where things are, but where things are not.</v> <v Tony Gurney>How do we know that we can store a new file?</v> <v Tony Gurney>How do we know where we can start?</v> <v Tony Gurney>Well, we need to have some free space.</v> <v Tony Gurney>We have free space where there's no fails. We need to remember where that is.</v> <v Tony Gurney>They remember how this is set up. We've got logical blocks or in the desk so we could just say there's something in there or there isn't, so we could have a bitmap.</v> <v Tony Gurney>One bet for every block.</v> <v Tony Gurney>If it's one, then you can use it, and if it's zero then you can't.</v> <v Tony Gurney>And.</v> <v Tony Gurney>This kind of.</v> <v Tony Gurney>This thing down the bottom here. CPUs have instructions to return offset within. Wonder first one bit.</v> <v Tony Gurney>I know that doesn't seem to make sense particular if you haven't looked to CPU instruction sets.</v> <v Tony Gurney>I knew you've looked at little man computer, but that has a very restricted instruction set. What it really means is you can throw a piece of data or what?</v> <v Tony Gurney>This instruction and it will come back and see the first one. End this 16 bits is at location for.</v> <v Tony Gurney>Which is fantastic if that one says.</v> <v Tony Gurney>Alright, well that means that a frost free space isn't location for.</v> <v Tony Gurney>So it's this idea about using a CPU instruction rather than a disk access.</v> <v Tony Gurney>Yeah, sorry, I'm going to leave it and.</v> <v Tony Gurney>Are we about long? I've only got 5 slides to go, but I understand.</v> <v Tony Gurney>If anyone needs to go, I'll finish the lecture. If you can, stay great. If you have to go absolutely understand that the video will be uploaded if he come back to it later.</v> <v Tony Gurney>As I've heard, there's a downside. If you've got a bitmap with every.</v> <v Tony Gurney>And.</v> <v Tony Gurney>Block on the desk and one bit for back. Then you need some extra memory and you can work it out 'cause you can work out. Given the size of the block and the size of the disk, how many bits you'll need in there for how much memory you'll need. Innocent example on there.</v> <v Tony Gurney>A one terabyte deskmate takes 64 megabytes of memory.</v> <v Tony Gurney>That's quite a chunk of your working memory.</v> <v Tony Gurney>Sorry.</v> <v Tony Gurney>Maybe?</v> <v Tony Gurney>You, rather than storing everything, have a linked list so the same way as we link the.</v> <v Tony Gurney>Uh, fails and point to the next one. Maybe we.</v> <v Tony Gurney>Simply how the linked list of free.</v> <v Tony Gurney>Blocks as well. All we need to store as a first free block.</v> <v Tony Gurney>And how many free blocks that are?</v> <v Tony Gurney>And if we want some space, we can just go to that frost free block and say Yep will have that one and that will tell us where the next one is. And if we have the next one is where the next one is, and so on.</v> <v Tony Gurney>I know we then have to update if that one took three blocks. For example. Oh, we would have to do is update the.</v> <v Tony Gurney>Free Space List hate, which wouldn't be too. It would be 5.</v> <v Tony Gurney>On the amount of free space behalf, which would be reduced by three blocks.</v> <v Tony Gurney>Maybe we could do something else.</v> <v Tony Gurney>Maybe we could start to group these things.</v> <v Tony Gurney>'cause again will have the same issue. We have to go to.</v> <v Tony Gurney>Block to to find out that the next one is blocked, the to find out the next one block forward. So one maybe instead of just storing the next one. What we could see is well.</v> <v Tony Gurney>I'm blocked too.</v> <v Tony Gurney>And.</v> <v Tony Gurney>I have 4 free blocks.</v> <v Tony Gurney>So we can group them and say, yeah, I've got four blocks here, all contiguous on disk.</v> <v Tony Gurney>And the next one is at 8.</v> <v Tony Gurney>And that says, yeah, I've got 6 three blocks.</v> <v Tony Gurney>And the next one is at 17, which says I've got two, and so on and so on.</v> <v Tony Gurney>So maybe we could group.</v> <v Tony Gurney>I will.</v> <v Tony Gurney>Pointers.</v> <v Tony Gurney>To understand not just where the free spaces but.</v> <v Tony Gurney>How large are as in one contiguous?</v> <v Tony Gurney>And.</v> <v Tony Gurney>Block</v> <v Tony Gurney>and we could probably extend that to say, well, I've got a fail.</v> <v Tony Gurney>And rather than using.</v> <v Tony Gurney>A block of four.</v> <v Tony Gurney>And they in the Forst.</v> <v Tony Gurney>Block by block of sex. Maybe we just use.</v> <v Tony Gurney>That's one and we get the file to be contiguous, and because it's five blocks, we have all sorts of options that we can implement, and we've got that choice.</v> <v Tony Gurney>Again, to try and speed up and fail access system and to speed up everything that we are doing.</v> <v Tony Gurney>Once you start to get to really large storage systems, that becomes very difficult.</v> <v Tony Gurney>And I'm talking about hundreds of terabytes here.</v> <v Tony Gurney>We certainly can't store anything in memory we have going in half this store it on disk.</v> <v Tony Gurney>Uhm?</v> <v Tony Gurney>That may be what we can do is divide the space into.</v> <v Tony Gurney>In this particular case, they have called it meta slabs.</v> <v Tony Gurney>Same kind of idea, user space map, but you have lots of them instead of one for the whole system.</v> <v Tony Gurney>And Zephys said file system uses us.</v> <v Tony Gurney>Whatever we do, we can work out what's more efficient, what gives us the best performance by figuring out how long it takes us to access directories and files and access things on disk and all that kind of stuff.</v> <v Tony Gurney>And all of this stuff that we have looked her up to now.</v> <v Tony Gurney>How we allocate fails on the desk. How we figure out. We are free. Space is how we then allocate that and change that.</v> <v Tony Gurney>All of those things will go into improving the performance.</v> <v Tony Gurney>As books, all of the things that we've touched on things like having a buffer.</v> <v Tony Gurney>We can use the same sort of stuff.</v> <v Tony Gurney>That we do with memory.</v> <v Tony Gurney>We've talked before about saying, well, if we access memory allocation to, why don't we just get memory allocation 3/4 and five?</v> <v Tony Gurney>Because the chances are that's what we'll be getting next anyway.</v> <v Tony Gurney>Why do we do this? Same with.</v> <v Tony Gurney>A file systems.</v> <v Tony Gurney>I'll take a look if we have contiguous filesystems. If we were asked to get blocked in well, chances are we're probably need to get blocks 11-12, thirteen, 1415, sixteen, 17, and 18 as well.</v> <v Tony Gurney>And if we have get enough space and.</v> <v Tony Gurney>The buffer on her dress instead of just saying get 10 get eight blocks.</v> <v Tony Gurney>So have a cache.</v> <v Tony Gurney>So the next time it comes back and go at heart, I'm ahead of you. That's already in my cache.</v> <v Tony Gurney>There's a cost involved 'cause you need memory chips on your device.</v> <v Tony Gurney>But that might be worth it to speed up your access.</v> <v Tony Gurney>You can do all of these kind of things.</v> <v Tony Gurney>You can.</v> <v Tony Gurney>Try and get.</v> <v Tony Gurney>Uh.</v> <v Tony Gurney>Ahead of yourself to try and get stuff in. When it's happened. You can delay rating out to files.</v> <v Tony Gurney>While still doing lots of roots.</v> <v Tony Gurney>So that you're not slowing down other things, and then when all the roads are finished, you do all your rights all at once.</v> <v Tony Gurney>All bunched together.</v> <v Tony Gurney>That can be an issue if you Tom things off of who USB stick out. You can do all of these things to try and increase your efficiency.</v> <v Tony Gurney>So Amir, 11 minutes late.</v> <v Tony Gurney>That's that one finished.</v> <v Tony Gurney>Anyone have any questions?</v> <v Tony Gurney>OK, I'll stop the recording then.</v>

Ask anything
We've read this whole study set, so questions about it get the best answers.