Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

File system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Chapter IV File system

A file is an information logical unit created by a process.

Directories are system files that manage the structure of the file system

In Unix, the parts of a path are separated by "/". In Windows, the delimiter is "\", and in Multics it is ">".

Regardless of the delimiter, if the first character of the path name is the delimiter, the path is absolute

Most operating systems that support hierarchical directory structures have two special directory entries in each directory. And "..", often pronounced as "dot" and "dotdot", "dot" refers to the current directory, "dotdot" refers to the parent directory (except in the root directory, where it points to itself.

When deleting a directory, only an empty directory can be called to delete the directory

Implementation of file system

File system layout: sector 0 of the disk is called the Master Boot record (MBR), which is used to boot the computer. At the end of the MBR, the partition table gives the starting address of each partition. A partition in the table is marked as the active partition. When the computer is booted, the BIOS reads and executes the MBR. The first thing MBR does is to identify the active partition, read in a piece of it, called the boot block, and execute it. In addition, there is a super block that contains all the key parameters of the file system and is read into memory when the computer starts or when the file system is first used. Typical information in super blocks includes the magic used to determine the type of file system, the number of blocks in the file system, and other important management information.

File implementation:

1. Continuous allocation, advantages: simple implementation, good read operation performance; disadvantages: easy to produce disk fragments

two。 Linked list allocation: the first word of each block serves as a pointer to the next block. Although this method is very convenient to read sequentially, random access is quite slow, and because the pointer takes up extra space, each disk block is no longer an integer power of 2. this strange size greatly reduces the performance of the system (many programs read disks to the power of 2.

3. Use linked list allocation in memory: take out the pointer of the disk block in 2 and put it in a table in memory. This table is called the file allocation table (FAT). The disadvantage is that the whole table is put in memory.

4. I node: the record file belongs to those disk blocks, listing the file attributes and the disk address of the file block. Given I node, the I node of the file will only exist in memory when the file is opened. The last disk block address points not to the data block but to the address of a block that contains the disk block address.

Directory implementation

1. A better solution is that the file entry contains an address pointing to the file name and an attribute of the file. For long directories, the linear search method is too slow, and one way to speed up the search is to use a hash table.

Share a file

1. Link: the connection between a specific directory and a shared file is called a connection.

two。 The file system itself is an acyclic graph, not a tree

3. In order to solve the problem of writing data to a single file in a shared file, contrary to the purpose of sharing the file, Unix adopts the I node, that is, the disk block is not included in the directory but in a small data structure (I node) related to the file itself; another option is symbolic linking: that is, the system creates a new file that points to the shared file (a shortcut in the windows system).

Log structure file system

1. The basic idea is to structure the entire disk into a log.

two。 Every once in a while, or when there is a special need, all outstanding writes buffered in memory are placed in a separate segment and written to disk as an adjacent segment at the end of the log

3. The log file system has a cleanup thread that periodically scans logs for disk compression.

4. The entire disk becomes a large circular buffer, and the writer thread writes the new segment in front, while the cleanup process removes the old segment from behind.

Virtual file system

1. Idea: abstract the parts that all file systems have in common, and put this part of the code into a separate layer, which calls the underlying actual file system to manage data concretely

two。 All file-related system calls point to the virtual file system in the initial processing

3. Virtual files have two different interfaces: the interface of the upper user process and the interface of the lower layer to the actual file system.

File system management and optimization

1. Almost all file systems divide files into fixed block sizes for storage, and the blocks are not necessarily adjacent to each other.

two。 If the allocated unit is too large, it wastes space (even a small file will occupy the entire cylinder), and if it is too small, it wastes time (the file spans multiple blocks, multiple seek and rotation delay)

3. Record free blocks, scheme 1: use disk block linked list, scheme 2: use bitmap

4. Disk quota: the maximum number of files and blocks that administrators assign to each user, and the operating system ensures that each user does not exceed the quota assigned to them.

5. File system backup: handles two issues: 1), recover from an unexpected disaster; 2) recover from an incorrect operation, (Recycle Bin in windos)

6. Incremental dump: do a full dump periodically, while backing up only the data that changed on the same day every day. It is slightly better to back up only files that have changed since the most recent dump.

7. There are two options for dumping: physical dump, logical dump; physical dump: starting from block 0 of the disk, all blocks are sequentially output to tape until the last one is copied; logical dump: starting from one or more specified directories, all files and directories that have changed since a given benchmark date (for example, the date of the last incremental dump or full dump).

8. File system consistency: many computers come with a user program to check file consistency. In Unix, it is scandisk in fsck,windos.

9. Performance of the file system:

1) caching

In Unix, there is a system call sync, which forcibly writes all modified blocks back to disk immediately. When the system starts, it runs a program, usually called update, in the background, which continuously executes sync calls in an infinite loop. The dormancy between every two calls is 30 seconds.

There is a FlushFileBuffers in windos that writes each modified block to disk as soon as it is written into the tell buffer. Writing all modified blocks in the buffer back to disk immediately is called a write-through cache. Write-through buffering requires more disk IO than non-write buffering

2) read blocks in advance

3) reduce the movement of the disk arm

Put the blocks that may be sequentially accessed together, of course, preferably on the same cylinder, so as to reduce the number of moves of the disk arm

Disk defragmentation: mobile culture makes them adjacent and places all (or at least most) of the free space in one or more large contiguous areas. Windos has a program defrag that does this work.

File system example:

1.CD-ROM, designed for disposable write media

An extension is made based on the Unix,ISO 9660 file system standard, Rock Ridge extension, and one extension made by Microsoft is Joliet extension.

The 2.MS_DOS file system, together with FAT-32, has been widely used by many cut-in systems, such as digital cameras.

3.UnixV7 file system, I node uses 3-level indirect blocks.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report