0% found this document useful (0 votes)
4 views25 pages

File System

The document discusses the organization and management of the XV6 file system, emphasizing the importance of data persistence, synchronization, and the use of a tree data structure. It explains disk emulation in QEMU, detailing how virtual disks are created and managed within a virtual machine. Additionally, it covers the structure and functionality of inodes, including their role in file management and memory caching within the system.

Uploaded by

mashhood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views25 pages

File System

The document discusses the organization and management of the XV6 file system, emphasizing the importance of data persistence, synchronization, and the use of a tree data structure. It explains disk emulation in QEMU, detailing how virtual disks are created and managed within a virtual machine. Additionally, it covers the structure and functionality of inodes, including their role in file management and memory caching within the system.

Uploaded by

mashhood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

If data is another disk, it must be shared.

Data must be sent to disk.


Persistence; Fetch, work on data and store it back to file system.
Kind of data structure for management or maintenance of file system is that of a tree.

Data structure on disk may become inconsistent because of crash of file from going to DISK.

Locking is required; synchronization is required.


Organization of XV6 file system?

Disk layer:
QEMU: virtual emulator in RISC V.

Not physical/mechanical disk but virtual.

Disk emulation in QEMU (Quick Emulator) refers to the ability of


QEMU to simulate or emulate different types of disk drives and storage
devices within a virtual machine (VM).

Here's an explanation of the concept of disk emulation in QEMU:

1. Virtualization and Emulation:


 QEMU provides a virtualization environment where it emulates
the hardware components of a computer, allowing you to run
an entire operating system (OS) inside a virtual machine.
 Emulation, in this context, means that QEMU simulates the
behavior of physical hardware components, such as CPU,
memory, and disk drives.
2. Disk Emulation:
 QEMU allows you to emulate different types of disk drives that
can be used by the virtual machines.
 Emulating a disk involves creating a virtual representation of a
storage device within the virtual machine. This virtual disk can
be used to install and run an operating system, store data,
and perform various disk-related operations.

R-X: read and execute.


Trampoline, kernel text,.
j

Block size is integral multiple of sector size.


Above disk layer, lot of communication between external hard disk and buffer cache.

Fixed number of buffers to hold disk block.: 30 in XV6


These blocks when they will be arriving in the memory(RAM), residing in buffer.
What is the nature of buffer cache?

Data BSIZE: 1024 bytes.


block size in the disk and in the memory or buffer is also same; 1024 bytes.

Refcnt: if the buffer is being used now?

Dev: 2 HDD, so some files are there, the arriving block is coming from which HDD?

BlockNO: Bock X(1), block Y(2).

Valid:
data/garbage: valid data block hence 0.(empty)

Disk: want to write back to disk/block?

Fetch a block> update it> write back to HDD?


make this 1 else 0.
NBUF: number of buffers.

Declare head node of doubly linked nost: looking for specific data block or making space for new
data.

Whole data structure is known as bcache:


++++

We have several buffers and individual buffers so connect them with doubly linked list.
Booststrap: initilizate all the necceasary functions needed.

BINIT(): it is initilizaed here.

bootstrap is responsible for forbinit and not other processor.

Virtio_disk_init: qemu virtual hard disk.


Bread(uint dev, uint, blockno)
unit dev:which HDD?

Uint block no: which block no?

Bget: is this block already in memory? If not then search in HDD.

Virtio_disk_rw(b,0): argument: 0, because we want to read from the disk>


Argument: 1, we are writing on the disk.
if not found in LinkedList, then going to end and making space, instead use hash table.

And when you don’t have block (create empty space, buffer) use heap.
Logging:
Header:

Block X to HDD, so destination address needs to be known.


2 blocks.
# of filled block:2

Block y address.

Block x address.

Header block:

Log header is first saved in memory and then in disk.

Header block is filled only AFTER write.

Readimg something is not included.


Read/write were pseudo function so in actual begin_op
it waits for previous transaction already running to commit.

If log slots are limited for current system call.

Two process are sending to disk, so counter =2.


Like these two are pcoess

Already did
Pin means just right to the header it will bring the block.

Record block sector: means write 103; 103 is the address.

Reserving the slot in log on disk

Increment n
Log.outstanding: decemreneted, means counter so system call made 0, if yes then commit.
INODE:

It might refer to the ondisk data structure containing a file’s size and list of data block numbers.

‘‘inode’’ might refer to an in-memory inode, which contains a copy of the on-disk inode as well as
extra information needed within the kernel.

The on-disk inodes are packed into a contiguous area of disk called the inode blocks

The on-disk inode is defined by a struct dinode (4078).

The type field distinguishes between files, directories, and special files (devices). A type of zero
indicates that an on-disk inode is free.

The nlink field counts the number of directory entries that refer to this inode, to recognize when the
on-disk inode and blocks should be freed.

The size field records the number of bytes of content in the file.

The addrs array records the block numbers of the disk blocks holding the file’s content.

The kernel keeps the set of active inodes in memory; struct inode (4162) is the in-memory copy of
a struct dinode on disk. The kernel stores an inode in memory only if there are C pointers referring
to that inode. The ref field counts the number of C pointers referring to the in-memory inode, and
the kernel discards the inode from memory if the reference count drops to zero. T
A: extra blocks required when more than 12 blocks are required.

B: copy of the same Inode and C is the extra information needed by the kernal.
4 indodes under 1 block.

Each can have 4 inodes, so 20 inodes data structures are in file system.

Each block refers to one inode structure.

1 character = 1 byte in C.

You might also like