In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article, "what are the knowledge points of Linux's Iamp O subsystem?", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can gain something after reading this article. Let's take a look at this article "what are the knowledge points of Linux's Iamp O subsystem?"
I/O write
I/O read:
The processing of read system calls is divided into two parts: user space and kernel space processing. Among them, user space processing is only trapped in the kernel through 0x80 interrupts, and then its interrupt service routine, namely sys_read, is called to enter the kernel processing flow.
The processing of read system calls in the kernel, as described in the figure above, goes through VFS, specific file systems, such as ext2, page cache layer, general block layer, IO scheduling layer, device driver layer, and device layer. Among them, VFS is mainly used to shield the differences in the operation of the lower-level specific file system, and provides a unified interface to the upper layer. It is precisely because of this level that the device can be abstracted into files. The specific file system defines its own block size, set of operations, and so on. The purpose of introducing cache layer is to improve the efficiency of IO. It caches part of the data on the disk, and when the request arrives, if the data exists in the cache and is up-to-date, it is passed directly to the user program, eliminating the operation on the underlying disk. The main job of the general block layer is to receive disk requests from the upper layer and finally issue IO requests (BIO). The IO scheduling layer attempts to merge and sort the bio requests of the general block layer according to the set scheduling algorithm, and call back the request handling function provided by the driver layer to deal with the specific IO requests. The driver of the driver layer corresponds to a specific physical device, which takes out the IO request from the upper layer, and according to the information specified in the IO request, manipulates the device to transmit data by sending commands to the device controller of the specific block device. The device layer is specific physical devices.
VFS layer:
The kernel function sys_read is the entry point for read system calls at this layer.
According to the index specified by the file fd, it fetches the corresponding file object from the current process descriptor and calls vfs_read to perform the file read operation.
Vfs_read will call the read function related to the specific file to perform the read operation, file- > f_op.read.
VFS then gives control to the ext2 file system. (ext2 is here as an example for parsing)
Processing of Ext2 file system layer
Through the ext2_file_operations structure, we know that the above function will eventually be called to the do_sync_read function, which is a common read function of the system. So do_sync_read is the real entrance to the ext2 layer.
The entry function do_sync_read of this layer calls the function generic_file_aio_read, which determines the access method of this read request. If it is directly io (filp- > f_flags is set with the O_DIRECT flag, that is, it does not pass through cache), the generic_file_direct_IO function is called; if it is the page cache method, the do_generic_file_read function is called. It determines whether the page is cached on the page, and if so, copies the data directly to user space. If not, the page_cache_sync_readahead function is called to perform a pre-read (check to see if it can be read ahead), which calls mpage_readpages. If it still fails (pre-reading or other reasons may not be allowed), jump directly to readpage, execute mpage_readpage, and read data from disk.
In mpage_readpages (reading multiple pages at a time), it puts contiguous blocks into the same BIO and delays the commit of the BIO until discontiguous blocks appear, then directly commit the BIO, and then continue processing to construct another BIO.
Page cache structure of the file
Figure 5 shows the page cache structure of a file. The file is divided into blocks of page size, and these blocks (pages) are organized into a multi-tree (called radix tree). All leaf nodes in the tree are page frame structures (struct page) that represent each page used to cache the file. The first page at the leftmost end of the leaf layer holds the first 4096 bytes of the file (if the page size is 4096 bytes), the next page holds the second 4096 bytes of the file, and so on. All intermediate nodes in the tree are organizational nodes that indicate the page on which the data at an address is located. This tree can be hierarchical from 0 to 6 layers, and the supported file size ranges from 0 bytes to 16 T bytes. The root node pointer of the tree can be obtained from the address_space object associated with the file, which is saved in the inode object associated with the file.
The mpage processing mechanism is the problem that the page cache layer has to deal with.
Universal block layer
At the end of the cache layer processing, the generic_make_request function is called after the mpage_submit_bio is executed. This is the entry function of the general block layer.
It passes the bio to the IO scheduling layer for processing.
IO dispatching layer
Merge and sort the bio to improve the efficiency of IO. Then, call the callback function of the device driver layer, request_fn, and go to the device driver layer for processing.
Device driver layer
The request function processes each bio in the request queue separately and sends commands to the disk controller according to the information in the bio. When the processing is complete, the completion function end_bio is called to notify the upper layer that it is complete.
Block device driver
The above is the content of this article on "what are the knowledge points of Linux's Igamot O subsystem". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.