Data writing method and device, electronic equipment and storage medium
By distinguishing the data types to be written in the flash memory device and generating tags, the appropriate storage cell is selected for writing, which solves the problem that the storage controller cannot fully utilize parallelism and improves the read rate and system response rate.
Patent Information
- Application Number
- CN202411171861.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2026-03-03
AI Technical Summary
In existing technologies, storage controllers cannot fully utilize the parallelism of flash memory devices, resulting in multiple data entries of the same file being written to the same storage unit, affecting read speed and system response speed, and reducing user experience.
By determining the type of data to be written and generating corresponding tags, the target storage unit is selected based on the tags, and the data to be written is stored in the appropriate storage unit. This distinguishes between data that needs to be replaced and newly added data, thus achieving uniform writing.
It improves data read rate and system response rate, ensures that the data to be written is accurately written to the target storage unit, and enhances the parallelism and efficiency of file reading.
Smart Images

Figure CN121597110A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data storage, and more particularly to a data writing method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the continuous development and advancement of technology, electronic devices have become necessities in daily life. When reading files that need to be run from the storage of electronic devices, the loading speed is crucial. Therefore, flash memory devices in electronic devices today encapsulate multiple storage units (dies) that can operate in parallel. Each storage unit can be tested and verified independently. By storing different parts of the data in the file into different storage units, parallel reading of the file content can be achieved.
[0003] However, with the continued use of flash memory, the storage controller cannot fully utilize the parallelism of storage cells to read data. This results in multiple data entries of the same file being written to the same storage cell, requiring serial reading of the same storage cell, which greatly reduces the read rate. Consequently, it affects the loading rate of file data and the system response rate of electronic devices, impacting the user experience. Summary of the Invention
[0004] To overcome the problems existing in related technologies, this disclosure provides a data writing method, apparatus, electronic device, and storage medium.
[0005] According to a first aspect of the present disclosure, a data writing method is provided, comprising: determining data to be written to a target file; controlling a file system layer to analyze the data to be written to obtain a type of the data to be written, wherein the type of the data to be written indicates whether existing data in a storage unit corresponding to the target file is replaced or new data is added to the storage unit corresponding to the target file; controlling the file system layer to generate a corresponding tag for the data to be written based on the type of the data to be written, wherein the tag is used to identify the type of the data to be written; controlling a storage control layer to determine a target storage unit corresponding to the data to be written based on the tag; and controlling the storage control layer to store the data to be written in the target storage unit to write the data to be written to the target file.
[0006] In one embodiment, the control storage control layer determines the target storage unit corresponding to the data to be written based on the tag, including: in response to the tag being a first tag, the first tag being used to identify the type of the data to be written, representing the replacement of the stored data in the storage unit corresponding to the target file, determining the first storage unit as the target storage unit; the first storage unit is a storage unit in the storage unit corresponding to the target file where there is data that needs to be replaced.
[0007] In one embodiment, the control storage control layer determines the target storage unit corresponding to the data to be written based on the tag, including: in response to the tag being a second tag, the second tag being used to identify the type of the data to be written, representing the addition of data to the storage unit corresponding to the target file, determining the target storage unit based on the second storage unit, wherein the second storage unit is the storage unit in the storage unit corresponding to the target file used for adding data.
[0008] In one embodiment, determining the target storage unit based on the second storage unit includes: if there are multiple second storage units, then determining the storage unit with the smallest amount of target file data among the multiple second storage units as the target storage unit.
[0009] In one embodiment, controlling the storage control layer to store the data to be written to the target storage unit includes: in response to the existence of already stored data in the second storage unit, storing the data to be written to the end of the already stored data in the target storage unit.
[0010] In one embodiment, the method further includes: in response to the first storage unit or the second storage unit corresponding to the data to be written being full, controlling the storage control layer to determine a third storage unit, wherein the third storage unit is a storage unit other than the first storage unit and the second storage unit; and using the third storage unit as the target storage unit.
[0011] According to a second aspect of the present disclosure, a data writing apparatus is provided, comprising: a generation unit, configured to determine data to be written to a target file, control a file system layer to analyze the data to be written to obtain the type of the data to be written, wherein the type of the data to be written indicates whether existing data in a storage unit corresponding to the target file is replaced or new data is added to the storage unit corresponding to the target file, and control the file system layer to generate a corresponding tag for the data to be written based on the type of the data to be written, wherein the tag is used to identify the type of the data to be written; and a processing unit, configured to control a storage control layer to determine a target storage unit corresponding to the data to be written based on the tag, and control the storage control layer to store the data to be written in the target storage unit to write the data to be written to the target file.
[0012] In one embodiment, the processing unit controls the storage control layer to determine the target storage unit corresponding to the data to be written based on the tag in the following manner: in response to the tag being a first tag, the first tag being used to identify the type of the data to be written, indicating that the stored data in the storage unit corresponding to the target file is to be replaced, the first storage unit is determined to be the target storage unit; the first storage unit is the storage unit in the storage unit corresponding to the target file where the data to be replaced exists.
[0013] In one embodiment, the processing unit controls the storage control layer to determine the target storage unit corresponding to the data to be written based on the tag in the following manner: in response to the tag being a second tag, the second tag being used to identify the type of the data to be written, representing the addition of data to the storage unit corresponding to the target file, the target storage unit is determined based on the second storage unit, the second storage unit being the storage unit in the storage unit corresponding to the target file used for adding data.
[0014] In one embodiment, the processing unit determines the target storage unit based on the second storage unit in the following manner: if there are multiple second storage units, the storage unit with the smallest amount of target file data among the stored data in the multiple second storage units is determined as the target storage unit.
[0015] In one embodiment, the processing unit controls the storage control layer to store the data to be written to the target storage unit in the following manner: in response to the existence of already stored data in the second storage unit, the data to be written is stored at the end of the already stored data in the target storage unit.
[0016] In one embodiment, the processing unit is further configured to: in response to the first storage unit or the second storage unit corresponding to the data to be written being full, control the storage control layer to determine a third storage unit, wherein the third storage unit is a storage unit other than the first storage unit and the second storage unit; and use the third storage unit as the target storage unit.
[0017] According to a third aspect of the present disclosure, a data writing apparatus is provided, comprising:
[0018] A processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the data writing method described in the first aspect or any embodiment of the first aspect.
[0019] According to a fourth aspect of the present disclosure, a storage medium is provided, the storage medium storing instructions that, when executed by a processor of a terminal, enable the terminal to perform the method described in the first aspect or any one of the embodiments of the first aspect.
[0020] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: by generating corresponding tags for the data to be written to the target file, determining the target storage unit corresponding to the data to be written based on the tags, and writing the file to be written to the target storage unit, it is possible to distinguish between the data to be written that needs to be replaced and the data to be written that does not need to be replaced, and to write the data to be written that needs to be replaced and the data to be written that does not need to be replaced to the corresponding storage units respectively, thereby planning the write operation of the data to be written, so that the data to be written corresponding to the target file is written to the corresponding storage units respectively, thereby improving the read rate when reading the data of the target file.
[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0022] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0023] Figure 1 This is a flowchart illustrating a data writing method according to an exemplary embodiment.
[0024] Figure 2 This is a flowchart illustrating a method for determining a target storage unit according to an exemplary embodiment.
[0025] Figure 3 This is a flowchart illustrating a method for determining a target storage unit according to an exemplary embodiment.
[0026] Figure 4 This is a schematic diagram illustrating data already present in a storage unit according to an exemplary embodiment.
[0027] Figure 5 This is a schematic diagram illustrating data writing in a related art according to an exemplary embodiment.
[0028] Figure 6 This is a schematic diagram illustrating data writing according to an exemplary embodiment.
[0029] Figure 7 This is a schematic diagram illustrating a UFS device data writing process according to an exemplary embodiment.
[0030] Figure 8 This is a block diagram illustrating a data writing device according to an exemplary embodiment.
[0031] Figure 9 This is a block diagram illustrating an apparatus for writing data according to an exemplary embodiment.
[0032] Figure 10 This is a block diagram illustrating an apparatus for writing data according to an exemplary embodiment. Detailed Implementation
[0033] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure.
[0034] In the accompanying drawings, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The described embodiments are some, but not all, of the embodiments of this disclosure. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure. The embodiments of this disclosure will be described in detail below with reference to the accompanying drawings.
[0035] The data writing method provided in this disclosure is applied to the field of data storage. The data writing method provided in this disclosure is mainly used to determine the tag corresponding to each stored data in the data to be written, determine the storage unit to which each stored data is to be written based on the tag, and write the stored data into the corresponding storage unit, thereby realizing the writing of specific stored data into a characteristic storage unit.
[0036] With the continuous development and advancement of electronic devices and storage technologies, more and more products are using flash memory as the storage medium for data storage. Flash memory consists of many storage dies, each a self-contained, complete microchip unit containing all the circuitry and components necessary to achieve storage functionality. Each die can be tested and verified independently. The data to be written can be the basic unit for data storage, such as a data page. Multiple files within the same file can be written to different storage dies, allowing data to be read in parallel across multiple storage dies.
[0037] In related technologies, data is either randomly written to storage units or multiple data items are written to storage units according to simple writing rules. For example, when writing multiple data items to the same file sequentially, the data can be written to each storage unit according to a simple storage unit arrangement order. However, while random or simple sequential writing can ensure that the data content is evenly written to each storage unit during the initial write, as the number of overwrite and append writes increases, there is a possibility that multiple data items of the same data to be written may be written to the same storage unit. This results in uneven distribution of storage data within the storage units, which in turn affects parallel data reading.
[0038] In view of this, the present disclosure provides a data writing method, which determines the marker corresponding to the data to be written included in the data to be written, determines the storage unit corresponding to the data to be written based on the marker, and writes the data to be written into the corresponding storage unit, thereby realizing the uniform writing of storage data into multiple storage units and improving the reading efficiency of the storage device.
[0039] Figure 1 This is a flowchart illustrating a data writing method according to an exemplary embodiment, such as... Figure 1 As shown, it includes the following steps.
[0040] In step S11, the data to be written to the target file is determined, and the data to be written is analyzed to obtain the type of the data to be written.
[0041] In this embodiment of the disclosure, the type of data to be written indicates whether the data already stored in the storage unit corresponding to the target file is being replaced or whether new data is being added to the storage unit corresponding to the target file.
[0042] In this embodiment of the disclosure, the data to be written can be generated based on the application layer's write request to the target file. The application layer's write request to the target file can be generated when the application layer receives data modified or added to the target file by a user or application. The write request can include at least the target file to be written and the data to be written to the target file, wherein the data to be written represents the data to be written to the target file, and the write request can include one or more data pages to be written. For example, if the data to be written is a data page, the write request can include adding three data pages, Xpage 0, Xpage 1, and Xpage 2, to the target file X.
[0043] In this embodiment of the disclosure, in addition to providing an abstract interface for users and applications to access, manage and modify files and directories, the file system layer can also perform a tag acquisition operation on the data to be written to obtain the tag corresponding to the data to be written.
[0044] In this embodiment of the disclosure, the process of analyzing the data to be written by the file system layer may include comparing the logical address of the data to be written with the logical address of the already stored data in the corresponding storage unit of the target file. For example, if the logical address of the storage unit corresponding to the target file includes 0, 1, 2, 3, and 4, and the logical address of the storage unit corresponding to the already stored data in the target file includes 0, 1, 2, and 3, and the logical address of the data to be written is 0, then the file system layer determines that the type of the data to be written is an overwrite data type. The overwrite data type indicates that the data to be written is used to replace the already stored data in the corresponding storage unit of the target file. If the logical address of the data to be written is 4, then the file system layer determines that the type of the data to be written is an append data type. The append data type indicates that the data to be written indicates that there is no data to be replaced in the already stored data type of the corresponding storage unit of the target file, and the data to be written is used to add data to the corresponding storage unit of the target file.
[0045] In step S12, the control file system layer generates a corresponding tag for the data to be written based on the type of the data to be written.
[0046] In this embodiment of the disclosure, a marker is used to identify the type of data to be written. Different types of data to be written are distinguished by different markers. For example, the marker for data to be written that is an overwrite data type can be set to 1, and the marker for data to be written that is an append write data type can be set to 2. The data to be replaced by the data to be written can also be called the data to be overwritten. That is, the marker is used to identify the existence of the data to be overwritten corresponding to the data to be written. The data to be overwritten represents the existing data in the target file that needs to be replaced, and the existing data represents the stored data included in the target file that has been written to the storage unit. For example, if the target file A includes data A1, A2, and A3, and a write request for the target file A is received, and the write request includes data to be written A1' and A4, then the existing data in the target file A are A1, A2, and A3, and the data to be overwritten is A1'.
[0047] In step S13, the control storage layer determines the target storage unit corresponding to the data to be written based on the tag.
[0048] In this embodiment of the disclosure, the target storage unit includes a first storage unit or a second storage unit. The first storage unit is the storage unit in which the data to be replaced exists in the storage unit corresponding to the target file, and the second storage unit is the storage unit in which the data to be replaced does not exist in the storage unit corresponding to the target file. It should be understood that the first storage unit may or may not exist.
[0049] In this embodiment of the disclosure, the storage unit may contain multiple physical addresses and may store multiple data pages.
[0050] In step S14, the control storage layer stores the data to be written to the target storage unit so as to write the data to the target file.
[0051] In this embodiment of the disclosure, the storage control layer is a key component of the computer storage system, responsible for managing and coordinating the operation of storage devices, and is located between the file system layer of the operating system and the physical storage devices.
[0052] In this embodiment of the disclosure, the target storage unit is the storage unit containing the data to be overwritten corresponding to the data to be written, or the storage unit containing the least amount of existing data. The target storage unit corresponding to the data to be written can be determined based on the tags generated by the file system layer. Different combinations of tags and different data to be written can correspond to different target storage units. For example, if the tag corresponding to the data to be written is tag 1, the corresponding target storage unit is storage unit 1; while if the tag corresponding to the data to be written is tag 2, the corresponding target storage unit can be storage unit 2.
[0053] In this embodiment of the disclosure, by determining the data to be written to the target file and generating a corresponding marker, and based on the marker, determining whether there is a target storage unit in the corresponding storage unit of the target file corresponding to the data to be written, or whether there is a target storage unit that needs to replace the data, and writing the data to be written therein, the data to be written to the target file is accurately written to the corresponding storage unit, so that the file to be written in the target storage unit can meet the reading requirements.
[0054] In this embodiment of the disclosure, if the write method of the data to be written is detected as overwrite, a first tag is generated corresponding to the data to be written. The first tag indicates that the corresponding data to be written is data that replaces existing data in the electronic device.
[0055] Figure 2 This is a flowchart illustrating a method for determining a target storage unit according to an exemplary embodiment, such as... Figure 2 As shown, it includes the following steps.
[0056] Figure 2Step S21 and Figure 1 The steps in step S12 are the same and will not be repeated here. Please refer to the relevant descriptions in the above embodiments. The following only describes the differences.
[0057] In step S22, in response to the first tag being used to identify the type of data to be written, the stored data in the corresponding storage unit of the target file is replaced, and the first storage unit is determined to be the target storage unit.
[0058] In this embodiment of the disclosure, the first storage unit is the storage unit in which the target file contains data that needs to be replaced. If the marker corresponding to the data to be written is detected as the first marker, it indicates that the data to be written is data that needs to be written by the electronic device through an overwrite operation. For example, if the file system analyzes the write request and determines that an overwrite operation is needed to replace the data to be overwritten (A) with the data to be written, then the marker corresponding to the data to be written is set as the first marker.
[0059] It should be understood that, in the embodiments of this disclosure, when an overwrite operation occurs, the logical and physical addresses of the storage data to be replaced are different from the logical and physical addresses of the data to be overwritten. When an overwrite operation occurs, the storage data to be replaced is written to a logical address different from the data to be overwritten, and based on the mapping relationship between logical and physical addresses, the storage data to be replaced is written to the storage medium at the corresponding physical address, and the data to be overwritten is marked as erasable data.
[0060] In this embodiment of the disclosure, by writing the data to be written marked with the first mark to the storage unit where the data to be replaced is located, when an overwrite operation occurs, the overwrite data (corresponding to the data to be written) is written to the same storage unit as the original data (corresponding to the data to be replaced), reducing the writing problem of the data to be written, avoiding the situation where multiple data of the target file are written to the same storage unit due to the overwrite operation, and improving the speed of subsequent reading of the data to be written.
[0061] In this embodiment of the disclosure, if the write method of the data to be written is detected as append write, a second tag is generated corresponding to the data to be written. The second tag indicates that the corresponding data to be written represents data newly added to the target file.
[0062] Figure 3 This is a flowchart illustrating a method for determining a target storage unit according to an exemplary embodiment, such as... Figure 3 As shown, it includes the following steps.
[0063] Figure 3Step S31 and Figure 1 The steps in step S12 are the same and will not be repeated here. Please refer to the relevant descriptions in the above embodiments. The following only describes the differences.
[0064] In step S32, in response to the second marker, which is used to identify the type of data to be written, representing the addition of new data to the storage unit corresponding to the target file, the target storage unit is determined based on the second storage unit.
[0065] In this embodiment of the disclosure, the second storage unit is the storage unit in the target file corresponding to which new data is added. If the marker corresponding to the data to be written is detected to be the second marker, it indicates that the data to be written needs to be written by the electronic device through an append write operation. The append write operation is performed at the end of the file or data structure, and the new data is added after the existing data, rather than overwriting the existing data.
[0066] In this embodiment, if there are multiple second storage units, the storage unit with the least amount of stored data is determined as the target storage unit. The amount of stored data can be the amount of data stored in each storage unit of the target file. For example, for data to be appended to a target file C and marked with a second tag, if the target file C has corresponding second storage units C1, C2, and C3, and the data amounts in the target file C are i, j, and k respectively, where i is less than j and less than k, then the data to be written can be written to second storage unit C1. This achieves uniform data storage.
[0067] In this embodiment of the disclosure, in response to the existence of stored data in the second storage unit, the data to be written is stored at the end of the stored data in the target storage unit, wherein the end of the stored data represents the end of the logical address of the stored data in the target storage unit. When performing an append write operation in the second storage unit where stored data exists, the logical address of the newly written data to be written can be set to immediately follow the end of the logical address of the existing data, or after the logical address of the existing data. For example, the target file X may include three stored data pages: X page 0, X page 1, and X page 2, wherein the logical address of X page 2 is the end of the logical address of the stored data. If additional data page 3 to be written to the X file is to be appended, then X page 3 is written at the end of the stored data, i.e., at the logical address after X page 2.
[0068] In this embodiment of the disclosure, in response to being marked with the second mark, the target storage unit corresponding to the data to be written can also be determined based on the target file in the second storage unit and other storage units. For example, if the storage units in the electronic device include storage unit 0 (die0), storage unit 1 (die1), storage unit 2 (die2), and storage unit 3 (die3), wherein die0 includes the stored data B1 corresponding to the target file B, and die1 contains a logical address whose physical address immediately follows the logical address of the stored data B1, then when responding to the data to be written marked with the second mark, die1 is selected as the second storage unit.
[0069] In this embodiment of the disclosure, the data to be written, marked with the second mark, is written to the second storage unit where the target storage unit does not contain data that needs to be replaced. This avoids the situation where, when using multi-threaded synchronous writing of multiple data to be written, including append writes and overwrite writes, the data to be written for append writes (corresponding to the data to be written marked with the second mark) and the data to be written for overwrite writes (corresponding to the data to be written marked with the first mark) are written to the same storage unit. This achieves uniform writing of the content to be written to the target file and improves the efficiency of subsequent parallel reading of the target file.
[0070] It should be understood that due to the Erase After Write (EW) data management strategy in storage devices, when data needs to be erased or modified, it is considered invalid but not immediately erased. Instead, it is marked as "dirty" or "invalid." Only when all data in the block containing that data is invalid will the block be erased. Therefore, after performing too many overwrite operations on data in a specific storage unit, the storage unit may become full, making it impossible to write the data to the designated target storage unit.
[0071] In this embodiment, in response to the first or second storage unit corresponding to the data to be written being full, the storage control layer determines a third storage unit and uses it as the target storage unit. The third storage unit is a storage unit different from the first and second storage units. It should be understood that, for data to be written marked with a first value, if the first storage unit is full but the second storage unit is not full, the third storage unit can be set to the second storage unit that is not full. Alternatively, a new storage unit other than the storage unit corresponding to the target file in the electronic device can be set as the third storage unit for writing the data to be written to the target file. This avoids situations where the data to be written fails due to insufficient storage space in the target storage unit.
[0072] In one exemplary embodiment, if a storage device includes storage unit 0 (die0), storage unit 1 (die1), storage unit 2 (die2), and storage unit 3 (die3), and contains multiple data corresponding to files A, B, and C, wherein die0 contains stored data A0, B0, and C0, die1 contains stored data A1, B1, and C2, die2 contains stored data A2 and B2, and die3 contains stored data A3 and C0, as follows... Figure 4 As shown, Figure 4 This is a schematic diagram illustrating data already existing in a storage unit according to an exemplary embodiment. Figure 4 In this process, files A, B, C, and D are written sequentially. The storage device firmware will cyclically store them into the dies according to the writing order. At this time, file A is evenly distributed in the four dies, and sequential reading of it can be performed in parallel, with high bandwidth.
[0073] As users continue to use the device, existing files will be overwritten and appended, and new files will be written. Due to the characteristics of flash memory, data can only be updated through out-of-place (OOP) storage, not in-place updates, and existing data pages will be marked as invalid. Figure 5 As shown, Figure 5 This is a schematic diagram illustrating data writing in a related art according to an exemplary embodiment. Figure 5 In order to be in Figure 4 Updating data based on existing data can be done by using an overwrite operation to replace already stored data with the data to be written, or by using an append operation to add new data to the target file. In a data update sequence of B0, B1, A1, C0, followed by a new write of data D0, then updates B2 and A2, and new writes of data C3, B3, and D1, and finally updates A3, all pages of file A are stored in die0. Therefore, the storage controller cannot operate on these pages in parallel, resulting in a read time that is four times longer, significantly reducing read performance.
[0074] In one exemplary embodiment, a schematic diagram of data writing using the data writing method provided in this disclosure is shown in Figure 6. Figure 6This is a schematic diagram illustrating a data writing process according to an exemplary embodiment. When an overwrite occurs, a marker is added during the write operation. When the storage device recognizes this marker, it allocates space on the die of the original page, storing the new data on the original die. For example, if an overwrite occurs on A1, storage space is still allocated on die1 to store the newly overwritten data A1, maintaining maximum parallelism in reading file A. For append writes, in addition to providing the write command, the file system also provides the storage controller with the logical block address information of the file blocks preceding the currently being written block. For example, when writing file B3, the logical address information of B2 is also provided to the storage firmware. The firmware can then obtain the storage location of B2 (die0). When allocating space for writing B3, it will not allocate it sequentially in die0, but rather in die1, maximizing the parallelism of file reading and improving read performance as much as possible.
[0075] In one exemplary embodiment, the data writing method provided in this disclosure is used in a Universal Flash Storage (UFS) system device as follows: Figure 7 As shown, the fast file system can also be called a general-purpose flash storage system. Figure 7 This is a schematic diagram illustrating a UFS device data writing process according to an exemplary embodiment. Figure 7In the process, after the application layer receives a write request for a target file from user input or an application-generated request, the file system analyzes the write request, which includes the data to be written and the corresponding logical block address to be written. By analyzing whether the logical block address corresponding to the data to be written in the write request contains an existing file corresponding to the target file, the type of the data to be written in the write request is determined, thus determining whether the data to be written is an append write type or an overwrite write type. Based on the type of the data to be written, a corresponding tag is generated for the data to be written. If the type of the data to be written is an overwrite write type, an overwrite tag (corresponding to the first tag) is generated for the data to be written; if the type of the data to be written is an overwrite write type, an append write tag (corresponding to the second tag) is generated for the data to be written. If it is detected that the data to be written is an append write type, that is, there is no data to be replaced in the existing data, then when generating the append write tag, the logical block address of the latest data of the target file in the existing data is also generated. The driver layer schedules the write request (including data, corresponding tag and LBA) to the underlying block device. The block device is responsible for managing the storage of data on the physical storage device. In a UFS system, the storage control layer is responsible for constructing the commands sent to the UFS device, including instructions for writing data and the target address, where the target address corresponds to the target storage cell. Upon receiving the command, the UFS device's firmware (FW) parses the parameters in the command and executes the actual data write operation. This involves writing data to the specified target storage cell in the flash memory chip.
[0076] In this embodiment of the disclosure, a marker is generated on the data to be written to the target file to determine whether there is data that needs to be replaced in the file to be written. Based on the marker corresponding to the data to be written, the target storage unit corresponding to the data to be written is determined, so as to realize the accurate writing of the data to be written and ensure that the data contained in the target file can be normally distributed in the storage unit. Furthermore, the reading speed of the target file can be improved when reading the target file.
[0077] Based on the same concept, embodiments of this disclosure also provide a data writing device.
[0078] It is understood that the data writing device provided in this disclosure includes hardware structures and / or software modules corresponding to each function in order to achieve the above-mentioned functions. In conjunction with the units and algorithm steps of the various examples disclosed in this disclosure, this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the technical solutions of this disclosure.
[0079] Figure 8 This is a block diagram illustrating a data writing apparatus 100 according to an exemplary embodiment. (Refer to...) Figure 8 The device includes a generation unit 101 and a processing unit 102.
[0080] The generation unit 101 determines the data to be written to the target file, controls the file system layer to analyze the data to be written, and obtains the type of the data to be written. The type of the data to be written indicates whether the stored data in the corresponding storage unit of the target file is replaced or the data is added to the corresponding storage unit of the target file. Based on the type of the data to be written, the file system layer generates a corresponding tag for the data to be written. The tag is used to identify the type of the data to be written.
[0081] The processing unit 102 is used to control the storage control layer to determine the target storage unit corresponding to the data to be written based on the tag, and to control the storage control layer to store the data to be written into the target storage unit so as to write the data to be written into the target file.
[0082] In one embodiment, the processing unit 102 controls the storage control layer to determine the target storage unit corresponding to the data to be written based on a tag in the following manner: in response to the tag being a first tag, the first tag being used to identify the type of data to be written and to indicate that the stored data in the storage unit corresponding to the target file is to be replaced, the first storage unit is determined to be the target storage unit; the first storage unit is the storage unit in the storage unit corresponding to the target file where the data to be replaced exists.
[0083] In one embodiment, the processing unit 102 controls the storage control layer to determine the target storage unit corresponding to the data to be written based on a tag in the following manner: in response to the tag being a second tag, the second tag being used to identify the type of data to be written, representing the addition of data to the storage unit corresponding to the target file, the target storage unit is determined based on the second storage unit, the second storage unit being the storage unit in the storage unit corresponding to the target file in which the added data exists.
[0084] In one embodiment, the processing unit 102 determines the target storage unit based on the second storage unit in the following manner: if there are multiple second storage units, the storage unit with the smallest amount of target file data among the multiple second storage units is determined as the target storage unit.
[0085] In one embodiment, the processing unit 102 controls the storage control layer to store the data to be written to the target storage unit in the following manner: in response to the existence of stored data in the second storage unit, the data to be written is stored at the end of the stored data in the target storage unit.
[0086] In one embodiment, the processing unit 102 is further configured to: in response to the first storage unit or the second storage unit corresponding to the data to be written being full, control the storage control layer to determine a third storage unit, wherein the third storage unit is a storage unit other than the first storage unit and the second storage unit; and use the third storage unit as the target storage unit.
[0087] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0088] Figure 9 This is a block diagram illustrating an apparatus 200 for writing data according to an exemplary embodiment. For example, apparatus 200 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0089] Reference Figure 9 The device 200 may include one or more of the following components: processing component 202, memory 204, power component 206, multimedia component 208, audio component 210, input / output (I / O) interface 212, sensor component 214, and communication component 216.
[0090] Processing component 202 typically controls the overall operation of device 200, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 202 may include one or more modules to facilitate interaction between processing component 202 and other components. For example, processing component 202 may include a multimedia module to facilitate interaction between multimedia component 208 and processing component 202.
[0091] Memory 204 is configured to store various types of data to support the operation of device 200. Examples of such data include instructions for any application or method operating on device 200, contact data, phonebook data, messages, pictures, videos, etc. Memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0092] The power supply component 206 provides power to the various components of the device 200. The power supply component 206 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device 200.
[0093] Multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 208 includes a front-facing camera and / or a rear-facing camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0094] Audio component 210 is configured to output and / or input audio signals. For example, audio component 210 includes a microphone (MIC) configured to receive external audio signals when device 200 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 204 or transmitted via communication component 216. In some embodiments, audio component 210 also includes a speaker for outputting audio signals.
[0095] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0096] Sensor assembly 214 includes one or more sensors for providing status assessments of various aspects of device 200. For example, sensor assembly 214 may detect the on / off state of device 200, the relative positioning of components such as the display and keypad of device 200, changes in the position of device 200 or a component of device 200, the presence or absence of user contact with device 200, the orientation or acceleration / deceleration of device 200, and temperature changes of device 200. Sensor assembly 214 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 214 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 214 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0097] Communication component 216 is configured to facilitate wired or wireless communication between device 200 and other devices. Device 200 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 216 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 216 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0098] In an exemplary embodiment, the apparatus 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0099] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, which can be executed by a processor 220 of the device 200 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0100] Figure 10 This is a block diagram illustrating an apparatus 300 for writing data according to an exemplary embodiment. For example, apparatus 300 may be provided as a server. (Refer to...) Figure 10The device 300 includes a processing component 322, which further includes one or more processors, and memory resources represented by memory 332 for storing instructions, such as application programs, that can be executed by the processing component 322. The application programs stored in memory 332 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 322 is configured to execute instructions to perform the methods described above.
[0101] Device 300 may also include a power supply component 326 configured to perform power management of device 300, a wired or wireless network interface 350 configured to connect device 300 to a network, and an input / output (I / O) interface 358. Device 300 may operate on an operating system stored in memory 332, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.
[0102] It is understood that in this disclosure, "multiple" refers to two or more, and other quantifiers are similar. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. The singular forms "a," "the," and "the" are also intended to include the plural forms unless the context clearly indicates otherwise.
[0103] It is further understood that the terms "first," "second," etc., are used to describe various types of information, but this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another, and do not indicate a specific order or degree of importance. In fact, the expressions "first," "second," etc., are completely interchangeable. For example, without departing from the scope of this disclosure, first information can also be referred to as second information, and similarly, second information can also be referred to as first information.
[0104] It can be further understood that, unless otherwise specified, "connection" includes both direct connections where no other components exist between the two parties and indirect connections where other components exist between them.
[0105] It is further understood that although operations are described in a specific order in the accompanying drawings in the embodiments of this disclosure, this should not be construed as requiring these operations to be performed in the specific order or serial order shown, or requiring all of the shown operations to be performed to obtain the desired result. In certain environments, multitasking and parallel processing may be advantageous.
[0106] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein.
[0107] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A data writing method, characterized in that, include: The data to be written to the target file is determined, and the file system layer is controlled to analyze the data to be written to obtain the type of the data to be written. The type of the data to be written indicates whether the stored data in the storage unit corresponding to the target file is replaced or new data is added to the storage unit corresponding to the target file. The file system layer is controlled to generate a corresponding tag for the data to be written based on the type of the data to be written, and the tag is used to identify the type of the data to be written. Based on the marker, the storage control layer determines the target storage unit corresponding to the data to be written; The storage control layer is controlled to store the data to be written to the target storage unit, so as to write the data to be written to the target file.
2. The method according to claim 1, characterized in that, The control storage control layer determines the target storage unit corresponding to the data to be written based on the tag, including: In response to the first marker being used to identify the type of data to be written, which indicates that the stored data in the corresponding storage unit of the target file is being replaced, the first storage unit is determined to be the target storage unit. The first storage unit is the storage unit in which the target file contains the data that needs to be replaced.
3. The method according to claim 1, characterized in that, The control storage control layer determines the target storage unit corresponding to the data to be written based on the tag, including: In response to the marker being a second marker, the second marker being used to identify the type of the data to be written, representing the addition of data to the storage unit corresponding to the target file, the target storage unit is determined based on the second storage unit, the second storage unit being the storage unit in the storage unit corresponding to the target file used for adding data.
4. The method according to claim 3, characterized in that, The step of determining the target storage unit based on the second storage unit includes: If there are multiple second storage units, then the storage unit with the smallest amount of target file data among the stored data is determined as the target storage unit.
5. The method according to claim 3 or 4, characterized in that, The process of controlling the storage control layer to store the data to be written to the target storage unit includes: In response to the presence of already stored data in the second storage unit, the data to be written is stored at the end of the already stored data in the target storage unit.
6. The method according to any one of claims 2 to 4, characterized in that, The method further includes: In response to the first or second storage unit corresponding to the data to be written being full, the storage control layer is controlled to determine a third storage unit, which is a storage unit other than the first and second storage units; The third storage unit is used as the target storage unit.
7. A data writing device, characterized in that, include: The generation unit is used to determine the data to be written to the target file, control the file system layer to analyze the data to be written, obtain the type of the data to be written, the type of the data to be written indicates whether the stored data in the storage unit corresponding to the target file is replaced or the data is added to the storage unit corresponding to the target file, and control the file system layer to generate a corresponding tag for the data to be written based on the type of the data to be written, the tag being used to identify the type of the data to be written. The processing unit is configured to control the storage control layer to determine the target storage unit corresponding to the data to be written based on the tag, and to control the storage control layer to store the data to be written in the target storage unit, so as to write the data to be written into the target file.
8. The apparatus according to claim 7, characterized in that, The processing unit controls the storage control layer to determine the target storage unit corresponding to the data to be written based on the tag in the following manner: In response to the first marker being used to identify the type of data to be written, which indicates that the stored data in the corresponding storage unit of the target file is being replaced, the first storage unit is determined to be the target storage unit. The first storage unit is the storage unit in which the target file contains the data that needs to be replaced.
9. The apparatus according to claim 7, characterized in that, The processing unit controls the storage control layer to determine the target storage unit corresponding to the data to be written based on the tag in the following manner: In response to the marker being a second marker, the second marker being used to identify the type of the data to be written, representing the addition of data to the storage unit corresponding to the target file, the target storage unit is determined based on the second storage unit, the second storage unit being the storage unit in the storage unit corresponding to the target file used for adding data.
10. The apparatus according to claim 9, characterized in that, The processing unit determines the target storage unit based on the second storage unit in the following manner: If there are multiple second storage units, then the storage unit with the smallest amount of target file data among the stored data is determined as the target storage unit.
11. The apparatus according to claim 9 or 10, characterized in that, The processing unit controls the storage control layer to store the data to be written to the target storage unit in the following manner: In response to the presence of already stored data in the second storage unit, the data to be written is stored at the end of the already stored data in the target storage unit.
12. The apparatus according to any one of claims 8 to 10, characterized in that, The processing unit is also used for: In response to the first or second storage unit corresponding to the data to be written being full, the storage control layer is controlled to determine a third storage unit, which is a storage unit other than the first and second storage units; The third storage unit is used as the target storage unit.
13. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 6.
14. A storage medium, characterized in that, The storage medium stores instructions that, when executed by the terminal's processor, enable the terminal to perform the method described in any one of claims 1 to 6.