1. Field of Invention
The invention relates to a method for updating dirty data of a designated block device, and in particular to a system and method for updating dirty data of a designated raw device that is not based on a file system.
2. Related Art
In order to expedite magnetic disk input/output speed of the upper level application programs processed by Kernel, the Kernel of a Linux system tries its utmost in buffering the disk data accessed during system operation into a memory. When the memory is busy, the Kernel synchronously buffers the stored data into a magnetic disk and releases a part of space of the buffered memory according to a specific rule. Thus, when a user intends to read data from the magnetic disk, and in case that the Kernel checks and finds that the required data is presently stored in the buffer memory, then it reads the required data from the buffer memory immediately; otherwise, it reads the required data from the magnetic disk. Meanwhile, when a user intends to write data into the magnetic disk, the Kernel first stores the data into the buffer memory, as such, the write request of the user can be successfully accomplished immediately.
In the above-mentioned method for delaying writing data into the magnetic disk, a plurality of requests of writing data into adjacent areas of the magnetic disk can be gathered up to be executed in a single write action, hereby reducing frequency of movements of magnetic head and raising the efficiency of writing the data into the magnetic disk. However, this kind of mechanism usually would result in the discrepancy between data buffered in the memory and the data stored in the magnetic disk. Such data in the buffered memory not identical to that stored in the magnetic disk is referred to as dirty data.
In general, Kernel manages the buffer-stored data in a memory page manner, for example, in a block device of the raw device not based on a file system, each of the opened block devices, such as the magnetic disk, partitions, LVN logic volume, etc., all having a fast speed search number used to index all the buffer-stored data pages, wherein the memory page of which data is not identical to that of the magnetic disk is referred to as a dirty page. In case a power outage occurs and there are too many dirty data pages, then part of the buffer-stored data may be lost for being not be able to be written into the magnetic disk in time.
In order to reduce the risk of losing the buffer-stored data mentioned above, in the prior art, the Kernel would search dirty data, that have not been updated for a long time, in the buffer memory of all the opened block devices at regular time intervals or when the memory occupied by the buffer-stored data becomes too large, and then write the searched dirty data into the magnetic disk, thus ensuring that important data would not be lost due to the above-mentioned buffer-storing mechanism.
Though in the prior art, the Kernel would write the dirty data synchronously into the magnetic disk at regular time intervals or when the memory occupied by buffer-stored data is getting too large, yet in order to raise the memory utilization rate to its utmost extent, in practical application, the Kernel would buffer quite a lot of dirty data to be written in the buffer memory. Usually, these dirty data belong respectively to a plurality of opened block devices. In case that the user intends to write the dirty data of a block device which he deems important into the magnetic disk immediately, then this can be achieved by merely closing this block device, or by writing the dirty data of all the block devices synchronously into the magnetic disk through a forced update order. However, this kind of approach not only wastes time, but also delays the crucial moment for user to preserve and save important data. As such, when the percentage of dirty data of user designated block device occupied in the buffer memory is relatively small, the above-mentioned problem would become more evident and pronounced.
USPTO Backgrounds
USPTO Backgrounds