A data writing method, device, apparatus and storage medium
By establishing a mapping relationship between the target logical address and the old data in the solid-state drive, the problems of dual writes and metadata management in data write requests are solved, improving performance and extending the life of the hard drive, and achieving efficient data recovery and management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JINAN INSPUR DATA TECH CO LTD
- Filing Date
- 2022-10-21
- Publication Date
- 2026-05-08
AI Technical Summary
When using solid-state drives (SSDs), existing distributed storage software requires dual-write operations for data write requests to ensure data security, which leads to performance degradation and shortens disk lifespan. Furthermore, metadata management increases the burden on database operations.
By establishing a mapping relationship between the target logical address and the target old data, the operation of copying metadata to disk is avoided, the steps of dual data writing and metadata management are reduced, and the old data is managed using the target logical address, thereby realizing data recovery and deletion operations.
It improves data write performance, reduces the interaction between the SSD and upper-layer software, extends the lifespan of the hard drive, and enables data recovery in the event of a write failure.
Smart Images

Figure CN115599302B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data management, and in particular to a data writing method, apparatus, device, and storage medium. Background Technology
[0002] Distributed storage software merely uses SSDs (Solid State Disks) as storage units, relying on dual writes to ensure data security for data write requests, without effectively utilizing the internal data management logic of the SSDs. For example... Figure 1 As shown, when a data write request is made, not only is a new copy of the data written to disk, but also a copy of the old data for metadata management is copied. There is a metadata write operation, and metadata management will also increase DB (DataBase) operations. Furthermore, excessive interaction between upper-layer software and SSD solid-state drives will not only reduce performance but also reduce disk lifespan. Summary of the Invention
[0003] In view of this, the purpose of this invention is to provide a data writing method, apparatus, device, and storage medium that can manage old data using a target logical address, avoiding the step of writing copied metadata to disk to manage old data, and reducing dual-write operations. The specific solution is as follows:
[0004] Firstly, this application provides a data writing method applied to a solid-state drive, comprising:
[0005] Obtain a data update request sent by the upper-layer software for the current target data in the new data directory; the data update request includes the new data to be written and the target logical address;
[0006] The current target data is migrated to the old data directory to obtain the first target old data, and a new mapping relationship between the first target old data and the target logical address is created in the local first mapping relationship library;
[0007] A local write operation is performed on the new data to be written. If the write operation fails, the first mapping relationship library is used to find the first target old data corresponding to the target logical address in the old data directory, and the first target old data is migrated back to the new data directory to complete the corresponding data recovery operation.
[0008] Optionally, after performing a local write operation on the new data to be written, the method further includes:
[0009] Send a corresponding write result feedback message to the upper-layer software so that the upper-layer software marks the local target logical address as available when the write result feedback message indicates that the write operation has ended;
[0010] Accordingly, obtaining the data update request sent by the upper-layer software for the current target data in the new data directory includes:
[0011] The data update request for the current target data is initiated by the upper-layer software when the target logical address on the local machine is available.
[0012] Optionally, after performing a local write operation on the new data to be written, the method further includes:
[0013] If the write is successful, the first mapping relationship library is used to find the second target old data corresponding to the target logical address in the old data directory, and the second target old data in the old data directory is marked as recyclable; the second target old data is the previous target data that was migrated from the new data directory to the old data directory in the last data update operation.
[0014] Optionally, the method further includes:
[0015] Obtain the data deletion request containing the target logical address sent by the upper-layer software;
[0016] The first mapping relationship library is used to search for target old data in a recyclable state that corresponds to the target logical address in the data deletion request from the old data directory;
[0017] Perform a deletion operation on the target old data, and delete the mapping relationship between the target old data and the target logical address from the first mapping relationship library.
[0018] Optionally, obtaining the data deletion request containing the target logical address sent by the upper-layer software includes:
[0019] The upper-layer software receives a data deletion request containing the target logical address when the number of current data write requests is less than a preset threshold; the data write request includes an initial data write request and a data update request.
[0020] Optionally, the method further includes:
[0021] Obtain the first data write request sent by the upper-layer software; the first data write request includes the first data to be written and the preset logical address configured by the upper-layer software for the first data to be written;
[0022] Perform a local write operation on the first data to be written to obtain the target data after the first write;
[0023] Create a new mapping relationship between the target data after the first write and the preset logical address in the local second mapping relationship library;
[0024] Accordingly, migrating the current target data to the old data directory to obtain the first target old data includes:
[0025] The second mapping database is used to find the current target data corresponding to the target logical address, and the current target data is migrated to the old data directory to obtain the first target old data.
[0026] Secondly, this application provides a data writing method for use in upper-layer software, including:
[0027] Create a data update request for the current target data in the new data directory on the solid-state drive; the data update request includes the new data to be written and the target logical address;
[0028] The data update request is sent to the solid-state drive (SSD) so that the SSD migrates the current target data to the old data directory to obtain the first target old data, and establishes a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library; performs a local write operation on the new data to be written, and if the write fails, uses the first mapping relationship library to find the first target old data corresponding to the target logical address from the old data directory, and migrates the first target old data back to the new data directory to complete the corresponding data recovery operation.
[0029] Thirdly, the device itself provides a data writing device for solid-state drives, including:
[0030] The request acquisition module is used to acquire data update requests sent by the upper-layer software for the current target data in the new data directory; the data update request includes the new data to be written and the target logical address;
[0031] The relationship creation module is used to migrate the current target data to the old data directory to obtain the first target old data, and to create a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library;
[0032] The data writing module is used to perform local write operations on the new data to be written.
[0033] The data recovery module is used to find the first target old data corresponding to the target logical address from the old data directory when a write failure occurs, using the first mapping relationship library, and to migrate the first target old data back to the new data directory to complete the corresponding data recovery operation.
[0034] Fourthly, the device itself provides a data writing device for use in upper-layer software, including:
[0035] The request creation module is used to create a data update request for the current target data in the new data directory on the solid-state drive; the data update request includes the new data to be written and the target logical address;
[0036] The request sending module is used to send the data update request to the solid-state drive (SSD), so that the SSD migrates the current target data to the old data directory to obtain the first target old data, and establishes a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library; performs a local write operation on the new data to be written, and if the write fails, uses the first mapping relationship library to find the first target old data corresponding to the target logical address from the old data directory, and migrates the first target old data back to the new data directory to complete the corresponding data recovery operation.
[0037] Fifthly, the applicant provides an electronic device, including:
[0038] Memory, used to store computer programs;
[0039] A processor for executing the computer program to implement the aforementioned data writing method.
[0040] Sixthly, the present invention provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the aforementioned data writing method.
[0041] In this application, a data update request for current target data in a new data directory is obtained from the upper-layer software; the data update request includes new data to be written and a target logical address; the current target data is migrated to the old data directory to obtain a first target old data, and a mapping relationship between the first target old data and the target logical address is created in a local first mapping relationship library; a local write operation is performed on the new data to be written, and if the write fails, the first mapping relationship library is used to find the first target old data corresponding to the target logical address in the old data directory, and the first target old data is migrated back to the new data directory to complete the corresponding data recovery operation. Therefore, this application establishes a mapping relationship between the target logical address and the target old data, which allows the target logical address to be used to manage the corresponding target old data. This avoids the steps of copying metadata to disk and then using the metadata to manage the old data. This not only reduces dual data writing and interaction between the SSD and the upper-layer software, but also reduces the database update operations caused by metadata management, thus improving data writing performance. In the event of data writing failure, the corresponding target old data can be found based on the target logical address for data recovery, avoiding the operation of using copied metadata to find the corresponding old data. This avoids using the SSD only as a storage unit and makes reasonable use of the SSD's internal data management logic. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0043] Figure 1 This application discloses a flowchart of a write request operation.
[0044] Figure 2 This is a flowchart of a data writing method disclosed in this application;
[0045] Figure 3 This is an internal logic diagram of a solid-state drive disclosed in this application;
[0046] Figure 4 This is an internal logic diagram of a solid-state drive disclosed in this application;
[0047] Figure 5 This application discloses a flowchart of a write request operation.
[0048] Figure 6 This is a flowchart of a specific data writing method disclosed in this application;
[0049] Figure 7 This is a flowchart of a specific data writing method disclosed in this application;
[0050] Figure 8 This is a flowchart of a data writing method disclosed in this application;
[0051] Figure 9 This is a schematic diagram of the structure of a data writing device disclosed in this application;
[0052] Figure 10 This is a schematic diagram of the structure of a data writing device disclosed in this application;
[0053] Figure 11 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0055] In existing technologies, distributed storage software merely uses SSD hardware disks as storage units. Write requests rely on dual writes to ensure data security, without effectively utilizing the internal data management logic of the SSD hardware disk. Therefore, this application provides a data writing method that establishes a mapping relationship between a target logical address and target old data. This allows the target logical address to manage the corresponding target old data, avoiding the steps of copying metadata to disk and then using that metadata to manage old data. This reduces dual write operations and improves data writing performance.
[0056] See Figure 2 As shown, this embodiment of the invention discloses a data writing method applied to a solid-state drive, comprising:
[0057] Step S11: Obtain the data update request sent by the upper-layer software for the current target data in the new data directory; the data update request includes the new data to be written and the target logical address.
[0058] In this embodiment, as Figure 3 As shown, when a data update request for the current target data in the new data directory is received from the upper-layer software, the solid-state drive currently stores both old and new data. Furthermore, as... Figure 4As shown, the current target data in the new data directory is new data 1. That is, the solid-state drive (SSD) receives a data update request for new data 1 in the new data directory sent by the upper-layer software. The new data to be written in the data update request is new data 2. The target logical address in the data update request is the logical address agreed upon by the SSD and the upper-layer software. The target logical address in the upper-layer software and the target logical address in the SSD can pass the same mapping relationship. That is, both the upper-layer software and the SSD can use this mapping relationship to find the target data corresponding to the target logical address.
[0059] Step S12: Migrate the current target data to the old data directory to obtain the first target old data, and create a new mapping relationship between the first target old data and the target logical address in the local first mapping relationship library.
[0060] In this embodiment, before performing the write operation on the new data to be written, the current target data needs to be migrated to the old data directory to free up space in the new data directory for updating the current target data in the new data directory. Furthermore, by establishing a mapping relationship between the target logical address and the first target old data in the local first mapping relationship library, the first target old data can be managed using the target logical address. The local first mapping relationship library records the mapping relationship between the target logical address and the target old data. Figure 4 As shown, the current target data is new data 1, and the first target old data is old data 2. New data 1 is essentially old data 2; that is, new data 1 in the new data directory is migrated to the old data directory to obtain old data 2. A mapping relationship between old data 2 and the target logical address is then created in the local first mapping database. In this way, the first target old data can be found by utilizing the mapping relationship between the target logical address and the first target old data. This avoids the steps of copying metadata to disk and then using metadata to manage old data. This not only reduces dual data writing and interaction between the SSD and upper-layer software, but also reduces database updates caused by metadata management, thus improving data write performance.
[0061] Step S13: Perform a local write operation on the new data to be written, and if the write fails, use the first mapping relationship library to find the first target old data corresponding to the target logical address in the old data directory, and migrate the first target old data back to the new data directory to complete the corresponding data recovery operation.
[0062] In this embodiment, after performing a local write operation on the new data to be written, it may further include sending a corresponding write result feedback message to the upper-layer software, so that the upper-layer software marks the local target logical address as available when the write result feedback message indicates that the write operation has ended. It is understood that after the write operation on the new data to be written is completed, regardless of whether the write is successful or not, a corresponding write result feedback message needs to be sent to the upper-layer software. After receiving the write result feedback message, the upper-layer software marks the local target logical address as available for use by other data update requests. That is, the solid-state drive obtains the data update request for the current target data in the new data directory initiated by the upper-layer software when the local target logical address is available. Furthermore, when the target logical address in the upper-layer software is marked as unavailable, it indicates that the target logical address is currently occupied, meaning that the write operation on the current new data to be written has not yet been completed. At this time, the upper-layer software will not send a data update request to the solid-state drive. If the upper-layer software sends a data update request to the solid-state drive when the target logical address is marked as unavailable, it will cause data corruption within the solid-state drive, leading to data write failure. In this way, by sending write result feedback messages to the upper-layer software, the upper-layer software can mark the local target logical address as available in a timely manner, avoiding the problem of sending data update requests to the solid-state drive when the target logical address is unavailable, which would lead to data write failure.
[0063] In this embodiment, when writing new data fails, the mapping relationship between the target logical address and the first target old data needs to be used to locate the first target old data in the old data directory. Since the writing of new data failed, the first target old data is currently equivalent to new data. Therefore, the first target old data is moved back to the new data directory to complete the data recovery operation. Simultaneously, the mapping relationship between the target logical address and the first target old data can be deleted from the local first mapping relationship database or not. Furthermore, if the first target old data is not moved back to the new data directory, the new data directory will not contain the first target old data, and the solid-state drive will not be able to obtain the data update request sent by the upper-layer software for the current target data in the new data directory. In this way, when data writing fails, the corresponding target old data can be located based on the target logical address for data recovery, avoiding the operation of using copied metadata to find the corresponding old data for data recovery.
[0064] In this embodiment, after performing a local write operation on the new data to be written, the process may further include, if the write is successful, using the first mapping relationship library to find the second target old data corresponding to the target logical address in the old data directory, and marking the second target old data in the old data directory as recyclable; the second target old data is the previous target data that was migrated from the new data directory to the old data directory in the last data update operation. It can be understood that if the new data to be written is successfully written, the new data is saved to the new data directory, and the second target old data can be released. Thus, the mapping relationship between the target logical address and the second target old data can be used to find the second target old data, mark it as recyclable, and wait for recycling and deletion. Figure 4 As shown, the second target old data is old data 1, and the new data to be written is new data 2. If new data 2 is successfully written, the local first mapping relationship library is used to find the old data 1 corresponding to the target logical address in the old data directory, and the old data 1 in the old data directory is marked as recyclable, waiting for recycling and deletion. In this way, by marking the second target old data as recyclable, the target old data marked as recyclable is deleted when the SSD receives fewer requests. This avoids the operation of keeping the new data and deleting the old data every time data is successfully written, reducing the interaction between the SSD and the upper-layer software, and improving the lifespan of the SSD.
[0065] like Figure 5As shown, the overwritten old data is the current target data in the new data directory, which is also the first target old data in the old data directory. The system retrieves data update requests sent by the upper-layer software for the current target data in the new data directory. These requests include the new data to be written and the target logical address. The new data to be written includes metadata and data. A mapping relationship is established in the local first mapping database between the target logical address and the overwritten old data in the old data directory. This same mapping relationship is then passed to the upper-layer software so that both the upper-layer software and the solid-state drive can use this mapping relationship to find the overwritten old data corresponding to the target logical address. After performing the data write operation on the new data to be written, a write result feedback message indicating that the write operation has been completed is sent to the upper-layer software. This allows the upper-layer software to mark the local target logical address as available for use by other data update requests. When data writing fails, the system uses the local first mapping database to find the overwritten old data corresponding to the target logical address in the old data directory and moves the overwritten old data back to the new data directory to complete the data recovery operation. This avoids the steps of copying metadata to disk and then using metadata to manage old data, and also avoids the operations of retaining new data and deleting old data every time data is successfully written or retaining old data and deleting new data every time data is written, thus reducing the interaction between the solid-state drive and the upper-layer software.
[0066] Therefore, this application establishes a mapping relationship between the target logical address and the target old data, which allows the target logical address to be used to manage the corresponding target old data. This avoids the steps of copying metadata to disk and then using the metadata to manage the old data. This not only reduces dual data writing and interaction between the SSD and the upper-layer software, but also reduces the database update operations caused by metadata management, improving data writing performance. In the event of data writing failure, the corresponding target old data can be found based on the target logical address for data recovery, avoiding the operation of finding the corresponding old data using copied metadata. This avoids using the SSD only as a storage unit and makes reasonable use of the SSD's internal data management logic.
[0067] As described in the previous embodiment, this application details the establishment of the mapping relationship between the target logical address and the target old data, and how to manage the old data using the target logical address. Therefore, this application further details how to perform a deletion operation on the target old data based on the target logical address. See [link to relevant documentation]. Figure 6 As shown, this embodiment of the invention discloses a data deletion process applied to a solid-state drive, including:
[0068] Step S21: Obtain the data deletion request containing the target logical address sent by the upper-layer software.
[0069] In this embodiment, obtaining the data deletion request containing the target logical address sent by the upper-layer software can include obtaining the data deletion request containing the target logical address sent by the upper-layer software when the number of current data write requests is less than a preset threshold. The data write request includes the first data write request and the data update request. It is understood that when the number of current write requests on the solid-state drive is low, the data deletion request containing the target logical address sent by the upper-layer software is obtained. The preset threshold is set by the user based on their actual deletion needs. For example, when the number of current data write requests is 5 and the preset threshold is 10, the data deletion request containing the target logical address sent by the upper-layer software is obtained. This avoids the data channel congestion or data deletion failure caused by deleting old target data in a recyclable state corresponding to the target logical address in the data deletion request when the number of current data write requests exceeds the preset threshold. It also avoids the operation of retaining new data and deleting old data each time a data write is successful, or retaining old data and deleting new data each time a data write fails, reducing the interaction between the solid-state drive and the upper-layer software and improving the lifespan of the solid-state drive.
[0070] Step S22: Use the first mapping relationship library to search for target old data in a recyclable state that corresponds to the target logical address in the data deletion request from the old data directory.
[0071] Step S23: Perform a deletion operation on the target old data and delete the mapping relationship between the target old data and the target logical address from the first mapping relationship library.
[0072] In this embodiment, the target logical address in the data deletion request is used to find the corresponding target old data marked as recyclable in the old data directory, and the target old data is deleted. At the same time, the mapping relationship between the target logical address and the target old data is deleted from the local first mapping relationship library to reduce unnecessary resource consumption.
[0073] Therefore, this application avoids the data channel congestion or data deletion failure caused by deleting target old data marked as recyclable corresponding to the target logical address in the data deletion request when the number of current data write requests exceeds the preset threshold. It also avoids the operation of retaining new data and deleting old data each time a data write is successful, or retaining old data and deleting new data each time a data write fails. This reduces the interaction between the solid-state drive and the upper-layer software, and improves the lifespan of the solid-state drive.
[0074] Based on the previous embodiment, this application has described in detail the establishment of the mapping relationship between the target logical address and the target old data, and how to use the target logical address to manage the old data. Therefore, this application will now describe in detail how to perform the data writing operation on the first data to be written, see [link to relevant documentation]. Figure 7 As shown, this embodiment of the invention discloses a writing process for the first data to be written, applied to a solid-state drive, including:
[0075] Step S31: Obtain the first data write request sent by the upper layer software; the first data write request includes the first data to be written and the preset logical address configured by the upper layer software for the first data to be written.
[0076] In this embodiment, when the first data write request sent by the upper-layer software is received, since there is no current target data in the new data directory, the preset logical address in the first data write request is configured for the first data to be written, and the preset logical address is the logical address agreed upon by the upper-layer software and the solid-state drive.
[0077] Step S32: Perform a local write operation on the first data to be written to obtain the target data after the first write.
[0078] Step S33: Create a new mapping relationship between the target data after the first write and the preset logical address in the local second mapping relationship library.
[0079] In this embodiment, after the initial write operation of the data to be written is completed, a mapping relationship between a preset logical address and the target data after the initial write needs to be established in the local second mapping relationship library. This local second mapping relationship library records the mapping relationship between the target logical address and the new data, so that the target data after the initial write corresponding to the target logical address can be found using the local second mapping relationship library. Furthermore, after receiving a data update request from the upper-layer software for the target data after the initial write in the new data directory, the second mapping relationship library is used to find the current target data corresponding to the target logical address in the data update request, and the current target data is migrated to the old data directory to obtain the first target old data, thereby achieving the backup of the old data.
[0080] As can be seen, this application obtains the first write request sent by the upper layer software, and after performing the write operation on the first data to be written, it creates a mapping relationship between the target data after the first write and the preset logical address in the local second mapping relationship library, so that the target data after the first write corresponding to the target logical address can be found using the local second mapping relationship library.
[0081] See Figure 8 As shown, this embodiment of the invention discloses a data writing method applied to upper-layer software, including:
[0082] Step S41: Create a data update request for the current target data in the new data directory on the solid-state drive; the data update request includes the new data to be written and the target logical address.
[0083] Step S42: Send the data update request to the solid-state drive (SSD) so that the SSD migrates the current target data to the old data directory to obtain the first target old data, and creates a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library; perform a local write operation on the new data to be written, and if the write fails, use the first mapping relationship library to find the first target old data corresponding to the target logical address from the old data directory, and migrate the first target old data back to the new data directory to complete the corresponding data recovery operation.
[0084] In this embodiment, when the target logical address is available, a data update request is created for the current target data in the new data directory, where the new data directory is located on a solid-state drive (SSD). The data update request is then sent to the SSD so that the SSD migrates the current target data in the new data directory to the old data directory to obtain the first target old data. A mapping relationship is established between the target logical address in the data update request and the first target old data in the old data directory to achieve backup of the first target old data. In the event of a data write failure, the local first mapping relationship library is used to find the first target old data corresponding to the target logical address from the old data to complete the data recovery operation.
[0085] Therefore, this application sends a data update request containing the new data to be written and the target logical address to the solid-state drive (SSD), so that the SSD can establish a mapping relationship between the target logical address and the target old data. The target logical address is used to manage the target old data, avoiding the steps of writing the copied metadata to disk and then using metadata to manage the target old data. This not only reduces the number of data writes and the interaction between the SSD and the upper-layer software, but also reduces the database update operations caused by metadata management, thus improving the performance of data writing.
[0086] See Figure 9 As shown, an embodiment of the present invention discloses a data writing device applied to a solid-state drive, comprising:
[0087] Request acquisition module 11 is used to acquire data update requests sent by upper-layer software for the current target data in the new data directory; the data update request includes the new data to be written and the target logical address;
[0088] The relationship creation module 12 is used to migrate the current target data to the old data directory to obtain the first target old data, and to create a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library;
[0089] Data writing module 13 is used to perform local write operations on the new data to be written;
[0090] The data recovery module 14 is used to search for the first target old data corresponding to the target logical address from the old data directory using the first mapping relationship library when a write failure occurs, and to migrate the first target old data back to the new data directory to complete the corresponding data recovery operation.
[0091] Therefore, this application establishes a mapping relationship between the target logical address and the target old data, which allows the target logical address to be used to manage the corresponding target old data. This avoids the steps of copying metadata to disk and then using the metadata to manage the old data. This not only reduces dual data writing and interaction between the SSD and the upper-layer software, but also reduces the database update operations caused by metadata management, improving data writing performance. In the event of data writing failure, the corresponding target old data can be found based on the target logical address for data recovery, avoiding the operation of finding the corresponding old data using copied metadata. This avoids using the SSD only as a storage unit and makes reasonable use of the SSD's internal data management logic.
[0092] In some specific embodiments, after the data writing module 13, the system may further include:
[0093] The message sending unit is used to send a corresponding write result feedback message to the upper-layer software, so that the upper-layer software marks the local target logical address as available when the write result feedback message indicates that the write operation has ended;
[0094] Accordingly, the request acquisition module 11 can be specifically used to acquire the data update request for the current target data initiated by the upper-layer software when the target logical address on the local machine is in an available state.
[0095] In some specific embodiments, after the data writing module 13, the system may further include:
[0096] The first data lookup unit is used, upon successful writing, to use the first mapping relationship library to search for the second target old data corresponding to the target logical address from the old data directory.
[0097] A data marking unit is used to mark the second target old data in the old data directory as recyclable; the second target old data is the previous target data that was migrated from the new data directory to the old data directory in the last data update operation.
[0098] In some specific embodiments, the data writing device may further include:
[0099] The deletion request acquisition submodule is used to acquire the data deletion request containing the target logical address sent by the upper layer software;
[0100] The second data search unit is used to use the first mapping relationship library to search for target old data in a recyclable state that corresponds to the target logical address in the data deletion request from the old data directory;
[0101] The data deletion unit is used to perform a deletion operation on the target old data;
[0102] The relationship deletion unit is used to delete the mapping relationship between the target old data and the target logical address from the first mapping relationship library.
[0103] In some specific embodiments, the deletion request acquisition submodule may specifically include:
[0104] The deletion request acquisition unit is used to acquire data deletion requests containing the target logical address sent by the upper-layer software when the number of current data write requests is less than a preset threshold; the data write requests include initial data write requests and data update requests.
[0105] In some specific embodiments, the data writing device may further include:
[0106] The initial request acquisition unit is used to acquire the initial data write request sent by the upper-layer software; the initial data write request includes the initial data to be written and the preset logical address configured by the upper-layer software for the initial data to be written;
[0107] The initial data writing unit is used to perform a local write operation on the initial data to be written to obtain the target data after the initial write.
[0108] The relationship establishment unit is used to establish a mapping relationship between the target data after the first write and the preset logical address in the local second mapping relationship library;
[0109] Correspondingly, the relationship creation module 12 can be used to use the second mapping relationship library to find the current target data corresponding to the target logical address, and migrate the current target data to the old data directory to obtain the first target old data.
[0110] See Figure 10 As shown, an embodiment of the present invention discloses a data writing device, applied to upper-layer software, comprising:
[0111] The request creation module 21 is used to create a data update request for the current target data in the new data directory on the solid-state drive; the data update request includes the new data to be written and the target logical address;
[0112] The request sending module 22 is used to send the data update request to the solid-state drive (SSD) so that the SSD migrates the current target data to the old data directory to obtain the first target old data, and establishes a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library; performs a local write operation on the new data to be written, and if the write fails, uses the first mapping relationship library to find the first target old data corresponding to the target logical address from the old data directory, and migrates the first target old data back to the new data directory to complete the corresponding data recovery operation.
[0113] For more detailed information on the working process of each of the above modules, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0114] Therefore, this application sends a data update request containing the new data to be written and the target logical address to the solid-state drive (SSD), so that the SSD can establish a mapping relationship between the target logical address and the target old data. The target logical address is used to manage the target old data, avoiding the steps of writing the copied metadata to disk and then using metadata to manage the target old data. This not only reduces the number of data writes and the interaction between the SSD and the upper-layer software, but also reduces the database update operations caused by metadata management, thus improving the performance of data writing.
[0115] Furthermore, embodiments of this application also disclose an electronic device, Figure 11 This is a structural diagram of an electronic device 30 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0116] Figure 11 This is a schematic diagram of the structure of an electronic device 30 provided in an embodiment of this application. Specifically, the electronic device 30 may include: at least one processor 31, at least one memory 32, a power supply 33, a communication interface 34, an input / output interface 35, and a communication bus 36. The memory 32 stores a computer program, which is loaded and executed by the processor 31 to implement the relevant steps in the data writing method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 30 in this embodiment may specifically be an electronic computer.
[0117] In this embodiment, the power supply 33 is used to provide operating voltage for each hardware device on the electronic device 30; the communication interface 34 can create a data transmission channel between the electronic device 30 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 35 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0118] In addition, the memory 32, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 321, computer program 322, etc., and the storage method can be temporary storage or permanent storage.
[0119] The operating system 321 is used to manage and control the various hardware devices on the electronic device 30 and the computer program 322, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the data writing method executed by the electronic device 30 as disclosed in any of the foregoing embodiments, the computer program 322 may further include a computer program capable of performing other specific tasks.
[0120] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed data writing method. The specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0121] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0122] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software 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 this application.
[0123] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0124] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0125] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A data writing method, characterized in that, Applications in solid-state drives include: Obtain a data update request sent by the upper-layer software for the current target data in the new data directory; the data update request includes the new data to be written and the target logical address; The current target data is migrated to the old data directory to obtain the first target old data, and a new mapping relationship between the first target old data and the target logical address is created in the local first mapping relationship library; Perform a local write operation on the new data to be written, and if the write fails, use the first mapping relationship library to find the first target old data corresponding to the target logical address from the old data directory, and migrate the first target old data back to the new data directory to complete the corresponding data recovery operation; The data writing method further includes: Obtain the first data write request sent by the upper-layer software; the first data write request includes the first data to be written and the preset logical address configured by the upper-layer software for the first data to be written; perform a local write operation on the first data to be written to obtain the target data after the first write; create a mapping relationship between the target data after the first write and the preset logical address in the local second mapping relationship library; The step of migrating the current target data to the old data directory to obtain the first target old data includes: The second mapping database is used to find the current target data corresponding to the target logical address, and the current target data is migrated to the old data directory to obtain the first target old data.
2. The data writing method according to claim 1, characterized in that, After performing a local write operation on the new data to be written, the method further includes: Send a corresponding write result feedback message to the upper-layer software so that the upper-layer software marks the local target logical address as available when the write result feedback message indicates that the write operation has ended; Accordingly, obtaining the data update request sent by the upper-layer software for the current target data in the new data directory includes: The data update request for the current target data is initiated by the upper-layer software when the target logical address on the local machine is available.
3. The data writing method according to claim 1, characterized in that, After performing a local write operation on the new data to be written, the method further includes: If the write is successful, the first mapping relationship library is used to find the second target old data corresponding to the target logical address in the old data directory, and the second target old data in the old data directory is marked as recyclable; the second target old data is the previous target data that was migrated from the new data directory to the old data directory in the last data update operation.
4. The data writing method according to claim 3, characterized in that, Also includes: Obtain the data deletion request containing the target logical address sent by the upper-layer software; The first mapping relationship library is used to search for target old data in a recyclable state that corresponds to the target logical address in the data deletion request from the old data directory; Perform a deletion operation on the target old data, and delete the mapping relationship between the target old data and the target logical address from the first mapping relationship library.
5. The data writing method according to claim 4, characterized in that, The step of obtaining the data deletion request containing the target logical address sent by the upper-layer software includes: The upper-layer software receives a data deletion request containing the target logical address when the number of current data write requests is less than a preset threshold; the data write request includes an initial data write request and a data update request.
6. A data writing method, characterized in that, Applied to upper-layer software, including: Create a data update request for the current target data in the new data directory on the solid-state drive; the data update request includes the new data to be written and the target logical address; The data update request is sent to the solid-state drive (SSD) so that the SSD migrates the current target data to the old data directory to obtain the first target old data, and establishes a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library; performs a local write operation on the new data to be written, and if the write fails, uses the first mapping relationship library to find the first target old data corresponding to the target logical address from the old data directory, and migrates the first target old data back to the new data directory to complete the corresponding data recovery operation; The data writing method further includes: The first data write request is sent to the solid-state drive (SSD) so that the SSD can perform a local write operation on the first data to be written to obtain the target data after the first write. A mapping relationship between the target data after the first write and a preset logical address is created in the local second mapping relationship library. The first data write request includes the first data to be written and the preset logical address configured by the upper-layer software for the first data to be written. The step of migrating the current target data to the old data directory to obtain the first target old data includes: The second mapping database is used to find the current target data corresponding to the target logical address, and the current target data is migrated to the old data directory to obtain the first target old data.
7. A data writing device, characterized in that, Applications in solid-state drives include: The request acquisition module is used to acquire data update requests sent by the upper-layer software for the current target data in the new data directory; the data update request includes the new data to be written and the target logical address; The relationship creation module is used to migrate the current target data to the old data directory to obtain the first target old data, and to create a mapping relationship between the first target old data and the target logical address in the local first mapping relationship library; The data writing module is used to perform local write operations on the new data to be written. The data recovery module is used to find the first target old data corresponding to the target logical address from the old data directory using the first mapping relationship library when a write failure occurs, and to migrate the first target old data back to the new data directory to complete the corresponding data recovery operation. The data writing device is specifically used for: Obtain the first data write request sent by the upper-layer software; the first data write request includes the first data to be written and the preset logical address configured by the upper-layer software for the first data to be written; perform a local write operation on the first data to be written to obtain the target data after the first write; create a mapping relationship between the target data after the first write and the preset logical address in the local second mapping relationship library; The relationship creation module is specifically used for: The second mapping database is used to find the current target data corresponding to the target logical address, and the current target data is migrated to the old data directory to obtain the first target old data.
8. A data writing device, characterized in that, Applied to upper-layer software, including: The request creation module is used to create a data update request for the current target data in the new data directory on the solid-state drive; the data update request includes the new data to be written and the target logical address; The request sending module is used to send the data update request to the solid-state drive (SSD), so that the SSD migrates the current target data to the old data directory to obtain the first target old data, and establishes a mapping relationship between the first target old data and the target logical address in a local first mapping relationship library; performs a local write operation on the new data to be written, and if the write fails, uses the first mapping relationship library to find the first target old data corresponding to the target logical address from the old data directory, and migrates the first target old data back to the new data directory to complete the corresponding data recovery operation; The data writing device is specifically used for: The first data write request is sent to the solid-state drive (SSD) so that the SSD can perform a local write operation on the first data to be written to obtain the target data after the first write. A mapping relationship between the target data after the first write and a preset logical address is created in the local second mapping relationship library. The first data write request includes the first data to be written and the preset logical address configured by the upper-layer software for the first data to be written. The request sending module is specifically used for: The second mapping database is used to find the current target data corresponding to the target logical address, and the current target data is migrated to the old data directory to obtain the first target old data.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the data writing method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the data writing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Data storage method and system and computer readable storage medium
CN114756178A
Log-structured storage device format
US20150058291A1