CN107341049B - Transaction optimization processing method and device - Google Patents

Transaction optimization processing method and device Download PDF

Info

Publication number
CN107341049B
CN107341049B CN201710534000.3A CN201710534000A CN107341049B CN 107341049 B CN107341049 B CN 107341049B CN 201710534000 A CN201710534000 A CN 201710534000A CN 107341049 B CN107341049 B CN 107341049B
Authority
CN
China
Prior art keywords
data
module
storage area
object data
modified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710534000.3A
Other languages
Chinese (zh)
Other versions
CN107341049A (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201710534000.3A priority Critical patent/CN107341049B/en
Publication of CN107341049A publication Critical patent/CN107341049A/en
Application granted granted Critical
Publication of CN107341049B publication Critical patent/CN107341049B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • G06F9/467Transactional memory

Abstract

The invention discloses a transaction optimization processing method and device, and belongs to the field of memories. The method comprises the following steps: the virtual machine executes the application instruction, and when the application instruction is executed to the first application interface, the transaction state is initialized to be a starting transaction; when object data is created, generating index information according to the object data, adding the index information and the object data in a nonvolatile storage area, and updating the position information of the index information and the position information of the object data in a random access storage area; when the object data is modified, the object data is modified after the position of the object data needing to be modified is determined according to the unique identifier; when executing to the second application program interface, the modified data is written directly into the non-volatile storage area. The technical scheme of the invention improves the processing efficiency of transactions by utilizing the random access storage area, greatly improves the performance of reading and writing data, and prolongs the service life of products by reducing the writing operation on the nonvolatile storage area.

Description

Transaction optimization processing method and device
Technical Field
The present invention relates to the field of memories, and in particular, to a method and an apparatus for optimizing transaction processing.
Background
The COS is called Chip operating system (operating system on Chip) and mainly controls the information exchange between the virtual machine and the outside world, manages the memory in the smart card and completes the processing of various commands inside the card. In many large, critical applications, the virtual machine is performing a large number of tasks every second, combining them to fulfill a business requirement, called a transaction. Transactions are critical in COS, during which COS operations such as marking, backing up data, changing data of the nonvolatile memory area, recovering data, etc. need to be set continuously, and since each write operation on the nonvolatile memory area is rather time-consuming compared to a read operation, most of the application time is consumed on the write operation of the nonvolatile memory area.
A large amount of application programs, data and files are stored in the nonvolatile storage area, and the stored information cannot be lost after the power failure; the random access storage area is used for storing data information processed by the virtual machine, the content in the random access storage area can be refreshed at any time, the access speed is high, and the stored information can be lost after power failure.
In the existing transaction processing mechanism, when the processing data is more or scattered and distributed in a plurality of pages, especially in the downloading and personalization processes of applications, the nonvolatile storage area is low in efficiency and not flexible enough, more time and space are wasted, and the number of write operations on the nonvolatile storage is too many, so that the service life of a product is greatly reduced.
Disclosure of Invention
The invention aims to solve the problems in the prior art and provides a transaction processing optimization method and device.
The technical scheme adopted by the invention is as follows:
in one aspect, a method for optimizing transaction processing includes:
step S1: the virtual machine executes the application instruction, and when the application instruction is executed to the first application interface, the transaction state is initialized to be a starting transaction; when creating the object data, step S2 is executed; when the object data is modified, step S3 is performed; when executing to the second application program interface, executing step S4;
step S2: the virtual machine judges whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and the index information, if the space is insufficient, an error is reported, the step S1 is returned, if the space is sufficient, the index information is generated according to the object data, the index information and the object data are added to the nonvolatile storage area, after the position information of the index information and the position information of the object data are updated in the random access storage area, whether the transaction state is a starting transaction is judged, if not, the position information of the index information and the position information of the object data are stored in the nonvolatile storage area, and if the position information of the index information and the position information of the object data are updated, the step S1 is returned;
step S3: after determining the position information of the object data needing to be modified according to the received unique identifier, the virtual machine judges whether the transaction state is a starting transaction, if not, the virtual machine modifies the object data needing to be modified in the nonvolatile storage area according to the position information of the object data needing to be modified; if yes, updating the modification record of the object needing modification in the random access storage area, and returning to the step S1;
step S4: the virtual machine judges whether the transaction state is a starting transaction, and if not, an error is reported; if yes, traversing the modification records of the nonvolatile storage area and the random access storage area, counting the number of modification pages, directly writing the modification data into the nonvolatile storage area, updating the transaction state into an end transaction, and returning to the step S1;
in step S2, the adding the index information and the object data to the nonvolatile storage area specifically includes:
adding the index information to an object index area of the nonvolatile storage area, and adding the object data to an object data area of the nonvolatile storage area;
the adding the index information to the object index area of the nonvolatile storage area specifically includes:
step X1: acquiring an offset address of a current object index area from a data global information area of the nonvolatile storage area, and finding a page where the last piece of index information is located according to the offset address;
step X2: taking the page where the last index information in the current object index area is located as a current page, and loading all information of the current page into a random access memory area;
step X3: judging whether the current page can store an index message or not, if so, storing the newly created index message into the random access memory area, otherwise, executing the step X4;
step X4: taking the next page of the current page as the current page, loading all information of the current page into the random access memory area, and storing the newly created index information into the random access memory area;
step X5: and writing all the information of the current page back to the object index area.
In another aspect, an apparatus for optimizing transaction processing includes:
the execution module is used for executing the application instruction; the second judging module is used for executing the application instruction when the transaction state is judged to be the starting transaction; the second updating module is used for executing the application instruction after updating the modification record of the object needing to be modified in the storage access storage area; the third updating module is also used for executing the application instruction after the transaction state is updated to the end transaction by the third updating module;
the first initialization module is used for initializing the transaction state as a starting transaction when the execution module executes to the first application interface;
the first judging module is used for judging whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and the index information when the execution module executes the creation of the object data;
the error reporting module is used for reporting an error when the first judging module judges that the residual space of the nonvolatile storage area is not enough to store the received newly-created object data and the index information; the second judging module is also used for reporting an error when the second judging module judges that the transaction state is not the beginning transaction;
the generating module is used for generating index information according to the object data when the first judging module judges that the residual space of the nonvolatile storage area is enough to store the received newly-created object data and the index information;
the first adding module is used for storing the index information and the object data generated by the generating module in the nonvolatile storage area;
a first updating module for updating the position information of the index information and the position information of the object data in the random access memory area;
the second judging module is used for judging whether the transaction state is a starting transaction or not after the first updating module updates the position information of the index information and the position information of the object data in the random access memory area; the first positioning module is used for judging whether the transaction state is a starting transaction or not after determining the position information of the object data needing to be modified; the execution module is also used for judging whether the transaction state is a starting transaction when the execution module executes to the second application program interface;
a storage module, configured to store, in the nonvolatile storage area, location information of the index information and location information of the object data when the second determination module determines that the transaction state is not a start transaction;
the first positioning module is used for determining the position information of the object data to be modified according to the received unique identifier after the execution module executes the instruction for modifying the object data;
the modification module is used for modifying the object data to be modified in the nonvolatile storage area according to the position information of the object data to be modified when the second judgment module judges that the transaction state is not the beginning transaction;
the second updating module is used for updating the modification record of the object to be modified in the random access memory area when the execution module executes the instruction for modifying the object data and the second judgment module judges that the transaction state is the starting transaction;
the first traversal module is used for traversing the modification records of the nonvolatile storage area and the random access storage area when the execution module executes the second application program interface and the second judgment module judges that the transaction state is the starting transaction;
the counting module is used for counting the number of modified pages after the first traversal module traverses the modification records of the nonvolatile storage area and the random access storage area;
the first data writing module is used for directly writing the modified data into the nonvolatile storage area;
the third updating module is used for updating the transaction state into an end transaction after the first data writing module directly writes the modified data into the nonvolatile storage area;
the first adding module specifically comprises: a first adding submodule and a second adding submodule;
the first adding submodule is used for adding the index information in an object index area of the nonvolatile storage area;
the second adding submodule is used for adding the object data in an object data area of the nonvolatile storage area;
the first adding submodule specifically includes: the device comprises a searching unit, a first acting unit, a first judging unit, a storage unit, a second acting unit, a second storage unit and a first data writing unit;
the searching unit is used for acquiring the offset address of the current object index area from the data global information area of the nonvolatile storage area and finding the page where the last piece of index information is located according to the offset address;
the first serving unit is configured to take a page where the last piece of index information in the current object index area is located as a current page, and load all information of the current page into a random access memory area;
the first judging unit is used for judging whether the current page can store one piece of index information or not;
the first storage unit is used for storing the newly created index information into the random access storage area when the first judging unit judges that the current page can also store one piece of index information;
the second acting unit is used for taking the next page of the current page as the current page when the first judging unit judges that the current page can not store one piece of index information;
the second storage unit is used for loading all the information of the current page into the random access memory area and storing the newly created index information into the random access memory area;
the first data writing unit is used for writing the information of the current page back to the object index area.
The beneficial effects obtained by the invention are as follows:
by adopting the technical scheme of the invention, when more data are processed or the data distribution is scattered, the processing efficiency of the transaction is improved by utilizing the random access storage area, the performance of reading and writing the data is greatly improved, and the service life of the product is prolonged by reducing the writing operation on the nonvolatile storage area.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of a transaction optimization processing method provided in a first embodiment of the present invention;
fig. 2 is a flowchart illustrating an operation after a first application program interface is called in the method for optimizing transaction processing according to the second embodiment of the present invention;
fig. 3 is a flowchart illustrating an operation after a first function is called in the method for optimizing transaction processing according to the second embodiment of the present invention;
fig. 4 is a flowchart illustrating an operation after a second function is called in the method for optimizing transaction processing according to the second embodiment of the present invention;
fig. 5 is a flowchart illustrating an operation after a third function is called in the method for optimizing transaction processing according to the second embodiment of the present invention;
fig. 6 is a flowchart of a transaction processing optimization method provided in the second embodiment of the present invention
An operational flow diagram after the second application program interface is called;
fig. 7 is a flowchart of an operation performed after a third application program interface is called in the method for optimizing transaction processing according to the second embodiment of the present invention;
fig. 8 is an operation flowchart of powering back on the virtual machine after powering down in the transaction optimization processing method according to the second embodiment of the present invention;
fig. 9 is a device for optimizing transaction processing according to the fourth embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the following embodiments, a virtual machine, a first storage area, and a second storage area are included, the first storage area of the virtual machine including: an object data storage area, a data global information area and a data backup area. The object data storage area includes: an object index area, a blank area, and an object data area. The first storage area is a nonvolatile memory such as an EEPROM, and the second storage area is a volatile memory such as a RAM.
Example one
The embodiment of the invention provides an optimized processing method of transaction processing, which comprises the processes of starting transaction, executing transaction, submitting transaction, canceling transaction and power failure protection, wherein the executing transaction comprises the operation of creating data, the operation of modifying data and the operation of reading data.
As shown in fig. 1, includes:
step 101: electrifying the virtual machine, judging whether an incomplete transaction exists when the virtual machine is powered off last time, if so, starting power-down protection, otherwise, executing the step 102;
step 102: initializing transaction processing by the virtual machine;
specifically, in this embodiment, the transaction initialization specifically includes: clearing the data in the second memory area and setting the transaction mark as invalid.
Step 103: the virtual machine executes the application instructions, executes step 105 when executing to the first application program interface, executes step 106 when executing to the first function, executes step 107 when executing to the second function, executes step 108 when executing to the third function, executes step 109 when executing to the second application program interface, executes step 110 when executing to the third application program interface, and executes step 111 when executing to the other command;
step 105: calling a first application program interface to start a transaction, and returning to the step 103;
the starting transaction specifically includes:
checking the transaction flag bit, reporting an error when the transaction flag bit is valid, and returning to execute step 103; when the transaction flag bit is invalid, the transaction flag bit is valid, and the step 103 is returned to;
step 106: calling a first function to create data, and returning to execute the step 103;
the creating data specifically includes:
generating newly created index information according to the newly created object data, judging whether the size of the newly created index information plus the size of the newly created object data is smaller than or equal to the size of a blank area of the first storage area, if so, adding the newly created index information and the newly created object data in the first storage area, otherwise, reporting an error, and returning to execute the step 103; when the transaction flag bit is valid, returning to execute step 103; when the transaction flag bit is invalid, storing the position information of the object index area and the position information of the object data area into a data global information area of the first storage area;
step 107: calling a second function to modify data, and returning to execute the step 103;
the modifying data specifically includes:
determining the position of the object data to be modified according to the unique identifier, and storing the position information of the object data to be modified and the modified data as a modified record in a second storage area; when the transaction flag bit is invalid, directly modifying the object data in the first storage area; when the transaction flag bit is valid, determining whether all current modification records are contained in the second storage area, if so, updating the data information to be modified in the second storage area, otherwise, when the remaining space of the second storage area is insufficient and the space of the data backup area of the first storage area is not full, submitting the data in the second storage area to the data backup area and emptying the modification records in the second storage area, continuing to add the modification records which are not contained in the second storage area, and returning to execute step 103;
step 108: calling a third function to read data, and returning to execute the step 103;
the read transaction specifically includes:
determining the position of the object data to be read according to the unique identifier, reading the data in the corresponding address of the object data area of the first storage area as the target data, searching and reading the data intersected with the read address range in the data backup area of the first storage area when the transaction processing flag bit is valid, merging the data with the target data, searching the data intersected with the read address range in the second storage area, merging the data with the merged target data again to obtain the data to be read, and returning to the step 103;
step 109: calling a second application program interface to submit the transaction, and returning to execute the step 103;
the committing transaction specifically includes:
when the transaction flag bit is valid and the second storage area has data, traversing the modification records in the second storage area and the data backup area of the first storage area, judging whether the modification records only have data modification of one page, if so, directly writing the modification data into the object data area of the first storage area, otherwise, submitting the modification records in the second storage area to the data backup area, traversing and reading the modification records in the data backup area, writing the modification data into the object data area, and returning to the step 103;
step 110: calling a third application program interface to cancel the transaction, and returning to execute the step 103;
the canceling transaction specifically includes:
and when the transaction flag bit is valid, judging whether the data backup area has modification records, if not, clearing the modification records and clearing the transaction flag bit of the second storage area, otherwise, clearing the modification records and clearing the transaction flag bit of the cache area after clearing the modification records of the data backup area.
Step 111: and performing corresponding operation according to the execution command, and returning to the step 103.
In the embodiment, the first storage area is an EEPROM, the second storage area is an RAM, and the read-write speed of the second storage is higher than that of the first storage.
Example two
In this embodiment, the first storage area includes: an object data storage area, a data global information area and a data backup area. The object data storage area includes: an object index area, a blank area, and an object data area. It is worth mentioning that the first storage area and the second storage area are divided into a plurality of pages according to the size of the first storage area and the second storage area and fixed byte number.
Referring to fig. 2, in the transaction processing mechanism, when a first application program interface is called, a transaction is started, and the specific steps are as follows:
step 201: when the first application program interface of the virtual machine is called, judging whether the value of the transaction processing flag bit is true, if so, reporting an error, otherwise, executing the step 202;
preferably, in this embodiment, the first application program interface is specifically a begin transaction (beginning) interface.
Step 202: the value of the transaction flag bit is set to true.
Referring to fig. 3, the create data operation is performed when the first function is called in the transaction mechanism:
in this embodiment, a piece of index information is stored in the object index area, the index information records position and size information of object data corresponding to the index information one by one, and the object data area stores the object data corresponding to the index information one by one. Note that when the index information is stored in the object index area, the index information is stored in an incremental manner from a lower address to an upper address, and when the object data is stored in the object data area, the index information is stored in a decreasing manner from the upper address to the lower address. The data global information area is used for storing the initial position information and the offset of the object index area and the object data area.
Step 301: when the first function is called, judging whether the size of the newly created index information plus the size of the newly created object data is smaller than or equal to the size of a blank area of the first storage area, if so, executing a step 303, otherwise, executing a step 302;
preferably, in this embodiment, the first function is specifically a create transaction function.
In this embodiment, the size of each piece of index information is determined, so the number of pieces of index information that can be stored in one page of the object index area is also determined. In order to avoid the situation of cross-page storage when index information is stored in the object index area, the size of the index information is set to be a certain divisor of the page size. The size of the newly created object data does not have a fixed size.
For example, in this embodiment, the page size is 256 bytes, and the size of the index information is 4 bytes, where the index information mainly includes: the position of the object data corresponding to the index information and the size of the object data each occupy 2 bytes.
Step 302: judging whether the value of the transaction processing flag bit is true, if so, canceling the transaction, reporting an error, and returning to the step 103; otherwise, error is reported, and the step 103 is returned to;
step 303: adding index information of newly created object data in the object index area;
in this embodiment, the steps specifically include:
step A1: acquiring an offset address of an object index area from a data global information area, and finding a page where the last piece of index information is located according to a last address;
step A2: taking the page where the last piece of index information in the current object index area is located as a current page, and loading all information of the current page into a memory;
step A3: judging whether the current page can store one piece of index information, if so, storing the newly created index information into a memory, otherwise, executing the step A4;
step A4: taking the next page of the current page as the current page, loading all information of the current page into a memory, and storing newly created index information into the memory;
specifically, in the present embodiment, the address information and the object data size of the newly created object data are recorded in the object index area as index information.
Step A5: and writing the information of the current page back to the object index area, wherein the index number is + 1.
Step 304: adding newly created object data in the object data area;
in this embodiment, the steps specifically include:
step B1: obtaining the offset address and the size of the newly created object data from the object index area;
step B2: taking the page where the last byte of the last piece of object data in the current object index area is located as a current page, and loading all information of the current page into a memory;
step B3: judging whether the current page can store newly created object data, if so, storing the newly created object data into a memory, and writing the data of the current page back to an object data area; otherwise, after the current page is full, writing the data of the current page back to the object data area, and executing step B4;
step B4: taking the next page of the current page as the current page, storing the newly created object data into the memory, judging whether the newly created data is stored completely, if so, writing the data of the current page back to the object data area, and if not, continuing to execute the step B4;
step 305: updating the position information of the object index area and the position information of the object data area in the second storage area;
specifically, in this embodiment, the position information of the object index area is updated, specifically, the position information is the offset of the tail position of the index information newly created in the object index area; the position information of the update target data area is, specifically, an offset of an end position of newly created target data in the update target data area. Note that the offset here is an offset of the start position with respect to the low address (0).
Step 306: judging whether the value of the transaction processing flag bit is true, if so, returning to the step 103, otherwise, executing the step 307;
step 307: storing the position information of the object index area and the position information of the object data area into a data global information area of the first storage area, and returning to execute the step 103;
referring to fig. 4, the modify data operation is performed when the second function is called in the transaction mechanism:
step 401: searching index information corresponding to the object data to be modified in the object index area through the index sequence number;
preferably, in this embodiment, the second function is specifically a modification function.
Specifically, in this embodiment, the virtual machine analyzes the data transmitted from the upper layer, obtains the index number of the index information corresponding to the data to be modified after the analysis, and searches the index information corresponding to the object data to be modified in the object index area according to the index number.
Step 402: searching the position of the object data needing to be modified in the object data area through the index information;
specifically, the location of the modified object data is found in the object data area by reading the location information about the object data in the index information, that is, the page number and the offset address in the page where the object data is located are determined by the offset address of the object data, specifically:
by the calculation formula: (offset address + page size-1)/page size, and obtaining the page number of the data to be modified by taking down an integer from the obtained final result; by the calculation formula: and the offset address is% of the page size, so that the in-page offset address of the page where the data to be modified is located is obtained.
Step 403: judging whether the value of the transaction processing flag bit is true, if so, executing step 405, otherwise, executing step 404;
step 404: directly modifying the data in the corresponding address of the first storage area, and returning to execute the step 103;
step 405: searching whether a modification record block containing the existing modification data exists in the second storage area, if so, executing a step 406, otherwise, executing a step 407;
in this embodiment, an offset address of object data to be modified, a length of modification, and data to be updated are recorded in a modification record block in the second storage area. Here, the offset address is the first address of the modified data.
It should be noted that, in this embodiment, when data needs to be modified, data of only one page of the object data area may be modified one or more times, or data of multiple pages of the object data area may be modified.
Step 406: updating the data information needing to be modified in the second storage area, and returning to execute the step 103;
specifically, in this embodiment, there may be modification performed on one data multiple times, and when it is determined that there is existing modified data in the second storage area, in order to ensure that the data to be updated in the modification recording block of the second storage area is up-to-date, the updated data needs to be updated again.
Step 407: judging whether the residual space of the second storage area is smaller than the size of the modified recording block, if so, executing step 408, otherwise, executing step 410;
specifically, when it is determined that the second storage area does not contain the existing modified area, the non-contained modified record needs to be stored in the modified record block in the second storage area, if the modified record is not stored in the second storage area at this time, step 409 is executed, otherwise step 410 is executed.
Step 408: judging whether the data backup area is full, if so, canceling the transaction, reporting an error, returning to the step 103, otherwise, executing the step 409;
step 409: adding the data in the second storage area to the data backup area, clearing the data in the second storage area, and executing step 410;
step 410: adding modification record blocks of modification data not contained in the second storage area, and returning to execute the step 103;
referring to fig. 5, the transaction mechanism performs a read data operation when a third function is called:
preferably, in this embodiment, the third function is specifically a read transaction function.
Step 501: searching index information corresponding to the object data to be read in the object index area through the index sequence number;
step 502: searching the position of the object data to be modified in the object data area according to the index information;
step 503: reading data in a corresponding address of the first storage area as target data;
step 504: judging whether the value of the transaction processing flag bit is true, if so, executing step 505, otherwise, returning to execute step 103;
specifically, in this embodiment, if the value of the transaction flag bit is true, the data to be read may be partially contained in the backup area and the cache area, so that the original data is read first, and then the data in the backup area and the cache are read and merged.
Step 505: traversing the recording blocks of the first storage area, in which the data backup area intersects with the read address range, reading out the data of the relevant recording blocks and merging the data with the target data;
step 506: traversing the record blocks intersected with the read address range in the second storage area, reading out the data of the relevant record blocks, merging the data with the target data, and returning to execute the step 103;
specifically, in the present embodiment, in traversing the recording block intersecting with the read address range in the second storage area, the data obtained by merging the data of the relevant recording block with the target data is read out as the finally read data.
Referring to fig. 6, in the transaction processing mechanism, when the second application program interface is called, a transaction is committed, and the specific steps are as follows:
step 601: judging whether the value of the transaction processing flag bit of the transaction processing flag is true, if so, executing step 602, otherwise, reporting an error, and returning to execute step 103;
preferably, in this embodiment, the second application program interface is specifically a commit transaction (commit transaction) interface.
Step 602: judging whether the second storage area has data, if so, executing the step 603, otherwise, setting the flag bit of the transaction flag to false, and returning to execute the step 103;
step 603: judging whether only one page data modification exists in the data backup area in the second storage area and the first storage area, if so, executing step 604, otherwise, executing step 605;
in this embodiment, the determination is made by modifying the offset address and the modified length of the target data to be modified in the record block. The offset address refers to the first address of the modified data, the initial address of the data needing to be modified is found according to the sequence from the low address to the high address of the modified length, and the data is obtained according to the calculation formula: (offset address + page size-1)/page size, and taking down an integer from the obtained final result to obtain the page number of the data needing to be modified; (initial address + page size-1)/page size, and obtaining the page number of the data needing to be modified by taking down an integer from the obtained final result;
it should be noted that, if a new object is created in the transaction, the end position information of the object index area and the object data area may be changed, and this change first exists in the second storage area, and only when the transaction is committed, the change is actually stored in the data global information area of the first storage area. Therefore, after step 603 is executed, it is further determined that the position information of the object index region and the position information of the data region are not changed, that is, the temporary global information of the second storage region and the global information of the first storage region are compared, if yes, step 604 is executed, otherwise, step 605 is executed.
Step 604: writing the modified data into the corresponding object data area, setting the transaction flag bit to false, and returning to execute step 103;
specifically, in this embodiment, according to the data recorded in the modification record block in the second storage area, the data to be modified in the object data area is read into the memory and modified, then the modified data is written back to the corresponding page of the object data area, then the data in the second storage area is cleared, and the commit transaction is completed.
Step 605: submitting the modified record blocks in the second storage area to a data backup area;
specifically, in this embodiment, if the data of the multiple pages in the target data area is modified, even if the second storage area is not full, the data in the second storage area needs to be submitted to the data backup area, so as to prevent that, after the virtual machine is powered down in the submitting process, the data in the second storage area is completely lost, and when the virtual machine is powered up next time, the second storage area reads the previously stored data from the data backup area, and the modification continues.
It should be noted that, when the data in the second storage area is committed to the data backup area, the method further includes: and submitting the identification of the start of the transaction submitting identification to the data backup area.
Step 606: writing the position information of the object index area, the position information of the data area and the transaction mark value in the second storage area into the data global information area in the first storage area;
step 607: traversing and reading the modification recording blocks in all the data backup areas, and writing the modified data into the corresponding object data areas;
specifically, in this embodiment, the modified record blocks in all the data backup areas are read in a traversal manner, the data to be modified in the object data area is read into the memory and modified according to the records in the modified record blocks, and then the modified data is written back to the corresponding page of the object data area.
Furthermore, after all the modified record blocks in the data backup area are read in a traversing manner, the transaction commit completion flag is committed to the data backup area.
Step 608: setting the transaction flag value to false, and writing the transaction flag value into the data global information area;
step 609: clearing all data in the second storage area, clearing the data in the data backup area, and returning to execute step 103.
Referring to fig. 7, in the transaction processing mechanism, when the third application program interface is called, a transaction is cancelled, which includes the following specific steps:
step 701: judging whether the value of the transaction processing flag bit is true, if so, executing the step 702, otherwise, returning to execute the step 103;
preferably, in this embodiment, the third application program interface is specifically an abort transaction (aborttransition) interface.
Step 702: judging whether data exist in the data backup area, if so, executing the step 703 after clearing the data in the data backup area, otherwise, directly executing the step 703;
step 703: and setting the transaction flag bit to false, clearing the data in the cache region, and returning to the step 103.
Referring to fig. 8, an embodiment of the present invention provides a method for power down protection in an optimization processing method of transaction processing, which includes the following specific steps:
step 801: acquiring a transaction processing flag bit from a data global information area;
step 802: judging whether the value of the transaction processing flag bit is true, if so, executing the step 803, otherwise, returning to execute the step 103;
step 803: acquiring a first modification recording block of a data backup area as a current modification recording block;
preferably, starting from the high address of the data backup area, the data of the modified record blocks are sequentially acquired from the low address until all the modified record blocks of the data backup area are traversed.
Step 804: judging whether the current modification record block has modification data, if so, executing step 805, otherwise, executing step 807;
step 805: acquiring data of object data to be modified from the current modification record block, and writing the modified data into a corresponding object data area;
specifically, in this embodiment, after obtaining the data of the object data to be modified from the current modification record block, the data to be modified in the object data area is read into the memory according to the record in the modification record block and is modified, and then the modified data is written back to the corresponding page in the object data area.
Step 806: acquiring a next modified record block of the current modified record block, and returning to the step 804;
step 807: and setting the transaction flag value to false, clearing the data in the data backup area, and returning to execute the step 103.
EXAMPLE III
The embodiment provides an optimization processing method for virtual machine transaction processing, which specifically includes:
step S1: the virtual machine executes the application instruction, and when the application instruction is executed to the first application interface, the transaction state is initialized to be a starting transaction; when creating the object data, step S2 is executed; when the object data is modified, step S3 is performed; when executing to the second application program interface, executing step S4;
step S2: the virtual machine judges whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and the index information, if the space is insufficient, an error is reported, the step S1 is returned, if the space is sufficient, the index information is generated according to the object data, the index information and the object data are added to the nonvolatile storage area, after the position information of the index information and the position information of the object data are updated in the random access storage area, whether the transaction state is a starting transaction is judged, if not, the position information of the index information and the position information of the object data are stored in the nonvolatile storage area, and if the position information of the index information and the position information of the object data are updated, the step S1 is returned;
step S3: the virtual machine determines the position information of the object data to be modified according to the received unique identifier, judges whether the transaction state is a starting transaction, and modifies the object data in a nonvolatile storage area according to the position information if the transaction state is not the starting transaction state; if yes, updating the modification record of the object needing modification in the storage access storage area, and returning to the step S1;
step S4: the virtual machine judges whether the transaction state is a starting transaction, and if not, an error is reported; if yes, the modification records of the nonvolatile storage area and the random access storage area are traversed, the number of modified pages is counted, the modified data is directly written into the nonvolatile storage area, the transaction state is updated to be the end transaction, and the operation returns to the step S1.
Specifically, in step S2, adding index information and object data to the nonvolatile storage area, specifically:
index information is added to an object index area of the nonvolatile storage area, and object data is added to an object data area of the nonvolatile storage area.
In this embodiment, adding index information to the object index area of the nonvolatile storage area specifically includes:
step X1: acquiring an offset address of a current object index area from a data global information area of a nonvolatile storage area, and finding a page where the last piece of index information is located according to the offset address;
step X2: taking the page where the last piece of index information in the current object index area is as the current page, and loading all information of the current page into a random access memory area;
step X3: judging whether the current page can store an index message or not, if so, storing the index message into a random access storage area, otherwise, executing the step X4;
step X4: taking the next page of the current page as the current page, loading all information of the current page into a random access memory area, and storing index information into the random access memory area;
step X5: writing all information of the current page back to the object index area;
adding object data in an object data area of the nonvolatile storage area, specifically:
step Y1: obtaining the offset address and the size of the received newly created object data from the index information;
step Y2: taking the page where the last byte of the last piece of object data in the current object index area is located as a current page, and loading all information of the current page into a random access memory area;
step Y3: judging whether the current page can store newly created object data, if so, storing the newly created object data into a random access storage area, and writing the data of the current page back to an object data area; otherwise, after the current page is full, the data of the current page is written back to the object data area, and step Y4 is executed;
step Y4: and taking the next page of the current page as the current page, storing the received newly created object data into the random access memory area, judging whether the newly created data is stored completely, if so, writing the data of the current page back into the object data area, and if not, continuing to execute the step Y4.
Preferably, in step S2, the updating the index information and the location information of the object data in the random access memory area specifically includes: updating the location information of the object index area and the location information of the object data area in the random access memory area;
storing the index information and the position information of the object data in the nonvolatile storage area specifically comprises: storing the position information of the index area and the position information of the object data area in a nonvolatile storage area;
judging whether the remaining space of the nonvolatile storage area is enough to store the received newly created object data and the index information, specifically: after determining the size of the residual space of the nonvolatile storage area according to the position information of the object index area and the object data area in the random access storage area, judging whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and index information.
Specifically, in step S2, it is determined whether the remaining space of the nonvolatile storage area is sufficient to store the received newly created object data and the index information, specifically: after determining the size of the remaining space of the nonvolatile memory area according to the position information of the object index area and the object data area in the random access memory area, judging whether the size of the index information plus the size of the received newly created object data is smaller than or equal to the size of the blank area of the nonvolatile memory area.
Preferably, in step S3, the determining, according to the received unique identifier, the location information of the object data that needs to be modified includes:
and determining the index information of the object data to be modified according to the received unique identifier, and determining the position information of the object data to be modified in the nonvolatile storage area according to the index information.
In this embodiment, the determining, according to the index information, the location information of the object data that needs to be modified in the nonvolatile storage area specifically includes:
and determining the page number and the offset address in the page of the object data to be modified in the nonvolatile storage area by reading the offset address of the object data in the index information.
In this embodiment, determining the page number and the offset address in the page where the object data to be modified is located in the nonvolatile memory area specifically includes:
adding the difference value obtained by subtracting 1 from the page size and the offset address, dividing the obtained sum by the page size, and taking an integer downwards from the obtained final result to obtain the page number of the data needing to be modified; and (4) the offset address is used for carrying out remainder on the page size, and the obtained final result is the in-page offset address of the page where the data needing to be modified is located.
Preferably, in step S3, before updating the modification record of the object to be modified in the storage access storage area, the method further includes: the virtual machine judges whether the random access memory area has the modification record containing the position information, if so, the modification data in the modification record is updated to be the received modification data, and the step S1 is returned; if not, a modification record containing the location information, size, and received modification data of the object data that needs to be modified is added to the random access memory area, returning to step S1.
Specifically, before adding a modification record containing the location information, the size, and the received modification data of the object data to be modified in the random access memory area, the method further includes:
step C1: judging whether the residual space of the random access storage area is enough to store the modification record containing the position information, the size and the modification data of the object data needing to be modified, if the space is insufficient, executing the step C2, and if the space is enough, executing the step C4;
step C2: judging whether the data backup area in the nonvolatile storage area is full, if so, canceling the transaction, reporting an error, returning to the step S1, otherwise, executing the step C3;
step C3: submitting the modification record in the random access storage area to the data backup area, emptying the modification record in the random access storage area, and executing step C4;
step C4: a modification record containing the location information, size and received modification data of the object data to be modified is added to the random access memory area.
More specifically, step C1 specifically includes: judging whether the remaining space of the random access memory area is enough to store the modification recording block containing the position information, the size and the modification data of the object data to be modified, if the space is not enough, executing the step C2, and if the space is enough, executing the step C4;
step C3 specifically includes: submitting the modified record blocks in the random access storage area to the data backup area, emptying the modified record blocks in the random access storage area, and executing the step C4;
step C4 specifically includes: a modification record block containing the location information, size and received modification data of the object data to be modified is added to the random access memory area.
Further, in step S4, traversing the modification records in the nonvolatile storage area and the random access storage area specifically includes: and traversing the modification record blocks of the data backup area and the random access storage area, reading the modification records of the modification record blocks, and obtaining the position information and the size of the object data to be modified in each modification record.
Preferably, in step S4, before traversing the modification record of the nonvolatile memory area and the random access memory area, the method further includes: and judging whether the random access storage area has a modification record, if not, updating the transaction state to be the end transaction, returning to the step S1, and if so, executing the modification record traversing the nonvolatile storage area and the random access storage area.
In this embodiment, in step S4, the number of modified pages is counted, specifically: and after the virtual machine traverses the modification records of the nonvolatile storage area and the random access storage area to obtain the position information and the size of the object data to be modified in each modification record, the virtual machine counts the number of modification pages according to the position information and the size of the object data to be modified in each modification record.
Preferably, before the step S4, the method further includes, before writing the modified data directly into the nonvolatile storage area: the virtual machine judges whether the number of the modified pages is larger than a preset value, if the virtual machine judges that the number of the modified pages is larger than the preset value, the virtual machine submits the modified records in the random access storage area to the nonvolatile storage area, reads the modified records in the nonvolatile storage area in a traversing manner, writes the received modified data into the nonvolatile storage area, updates the transaction state into an end transaction, and returns to the step S1; if the virtual machine judges that the number of modified pages is less than or equal to the predetermined value, the modified data is directly written into the nonvolatile storage area, the transaction status is updated to the end transaction, and the process returns to step S1.
In this embodiment, step S1 further includes:
when the object data is read, step S5 is executed; when the third application interface is executed, step S6 is executed; when other instructions are executed, corresponding operations are carried out according to the execution instructions;
step S5: the virtual machine determines the position information of the object data needing to be read according to the received unique identifier, reads the object data in the position information of the nonvolatile storage area as the target data, judges whether the transaction state is a starting transaction, if not, reports an error, returns to the step S1, if yes, searches and reads the object data which are the same as the position information in the nonvolatile storage area and the random access storage area, combines the object data with the target data to obtain the data needing to be read, updates the transaction state into an end transaction, and returns to the step S1;
step S6: the virtual machine judges whether the transaction state is a start transaction, if not, an error is reported, the step is returned to S1, if yes, whether the modification record exists in the data backup area is judged, if yes, the modification record in the data backup area is cleared first, then the transaction state is updated to be an end transaction, then the modification record in the random access storage area is cleared, and the step is returned to S1; if not, the transaction status is updated to the end transaction, and after the modified record of the random access memory area is cleared, the process returns to step S1.
In this embodiment, in step S5, the determining, according to the received unique identifier, the location information of the object data that needs to be read includes:
and determining the index information of the object data to be read according to the received unique identifier, and determining the position information of the object data to be read in the nonvolatile storage area according to the index information.
In this embodiment, in step S5, the searching and reading the object data with the same location in the nonvolatile storage area and the random access storage area specifically includes: and traversing the data backup area and the random access storage area in the nonvolatile storage area to search for a modified record block containing the position, reading modified data of the modified record block and combining the modified data with the target data.
Preferably, step S1 is preceded by:
step F1: judging whether power-down protection is started, if so, starting the power-down protection, and executing the step S1, otherwise, executing the step F2;
step F2: the virtual machine performs transaction initialization, and step S1 is executed.
Specifically, starting the power down protection specifically includes:
judging whether the transaction state is a beginning transaction, if not, reporting an error, returning to the step S1, if so, acquiring a first modification record of the data backup area as a current modification record, judging whether the current modification record contains modification data, if not, updating the transaction state to be an ending transaction, clearing data in the data backup area, returning to the step S1, if so, acquiring the modification data from the current modification record, writing the modification data into a nonvolatile storage area according to the position information in the modification record, acquiring a next modification record of the current modification record as the current modification record, and continuously judging whether the current modification record contains the modification data.
In this embodiment, in step S2, it is determined whether the transaction status is a beginning transaction, specifically: judging whether the value of the transaction flag bit is valid, if so, returning to the step S1, otherwise, storing the position information of the index information and the position information of the object data in the nonvolatile storage area;
in step S3, it is determined whether the transaction status is a beginning transaction, which specifically includes: judging whether the value of the transaction flag bit is valid, if so, updating a modification record of the object to be modified in the storage access storage area, returning to the step S1, otherwise, modifying the object data in the nonvolatile storage area according to the position information;
in step S4, it is determined whether the transaction status is a beginning transaction, which specifically includes: judging whether the value of the transaction flag bit is valid, if so, traversing the modification records of the nonvolatile storage area and the random access storage area and counting the number of modified pages, otherwise, reporting an error;
updating the transaction state into an end transaction, specifically: the value of the transaction flag bit is set to invalid.
Specifically, before the step S4 of directly writing the modified data into the nonvolatile storage area, the method further includes: writing the value of the transaction flag bit to the non-volatile storage area;
after the power down protection is started in step F1, the method further includes: the value of the transaction flag bit is obtained from the non-volatile storage area.
In this embodiment, step F2 specifically includes: all data in the random access memory area is cleared, and the value of the transaction flag bit is set to invalid.
Example four
The present embodiment provides an optimization processing apparatus for virtual machine transaction processing, referring to fig. 9, the apparatus specifically includes:
an execution module 401, configured to execute the application instruction; for executing the application instruction when the second determining module 408 determines that the transaction status is a start transaction; the second updating module 412 is used for executing the application instruction after updating the modification record of the object needing to be modified in the storage access storage area; and is further configured to execute the application instruction after the third update module 416 updates the transaction status to end the transaction;
a first initialization module 402, configured to initialize a transaction state as a start transaction when the execution module 401 executes to the first application interface;
a first judgment module 403, configured to judge whether the remaining space of the nonvolatile storage area is sufficient to store the received newly created object data and the index information when the execution module 401 executes creating the object data;
an error reporting module 404, configured to report an error when the first determining module 403 determines that the remaining space of the nonvolatile storage area is not enough to store the received newly created object data and the index information; and is further configured to report an error when the second determining module 408 determines that the transaction status is not the beginning transaction;
a generating module 405, configured to generate index information according to the object data when the first determining module 403 determines that the remaining space of the nonvolatile storage area is sufficient to store the received newly created object data and the index information;
a first adding module 406, configured to store the index information and the object data generated by the generating module 405 in the nonvolatile storage area;
a first updating module 407 for updating the location information of the index information and the location information of the object data in the random access memory area;
a second judging module 408, configured to judge whether the transaction state is a start transaction after the first updating module 407 updates the location information of the index information and the location information of the object data in the random access memory area; the first positioning module 410 is used for determining whether the transaction state is a beginning transaction after determining the position information of the object data needing to be modified; the system is further configured to determine whether the transaction status is a start transaction when the execution module 401 accesses the second application program interface;
a storage module 409, configured to store the location information of the index information and the location information of the object data in the nonvolatile storage area when the second determination module 408 determines that the transaction status is not the start transaction;
a first positioning module 410, configured to determine, according to the received unique identifier, location information of the object data that needs to be modified after the execution module 401 executes the instruction for modifying the object data;
a modifying module 411, configured to modify the object data in the nonvolatile storage area according to the location information when the second determining module 408 determines that the transaction status is not the start transaction;
a second updating module 412, configured to update, when the execution module 401 executes the instruction to modify the object data and when the second determination module 408 determines that the transaction status is the start transaction, a modification record of the object to be modified in the storage access memory area;
a first traversal module 413 configured to traverse the modification records of the nonvolatile storage area and the random access storage area when the execution module 401 executes to the second application program interface and when the second determination module 408 determines that the transaction status is the start transaction;
a counting module 414, configured to count the number of modified pages after the first traversal module 413 traverses the modification records in the nonvolatile memory area and the random access memory area;
a first write data module 415 for writing the modified data directly into the non-volatile storage area;
and a third updating module 416, configured to update the transaction status to an end transaction after the first data writing module 415 writes the modified data directly to the nonvolatile storage area.
In this embodiment, the first adding module 406 specifically includes: a first adding submodule and a second adding submodule;
the first adding submodule is used for adding index information in an object index area of the nonvolatile storage area;
and the second adding submodule is used for adding the object data in the object data area of the nonvolatile storage area.
Specifically, the first adding sub-module specifically includes: the device comprises a searching unit, a first acting unit, a first judging unit, a storage unit, a second acting unit, a second storage unit and a first data writing unit; the second adding submodule specifically includes: the device comprises a receiving unit, a third acting unit, a second judging unit, a second data writing unit, a third data writing unit, a fourth acting unit, a third judging unit and a fourth data writing unit;
the searching unit is used for acquiring the offset address of the current object index area from the data global information area of the nonvolatile storage area and finding the page where the last piece of index information is located according to the offset address;
the first serving unit is used for taking the page where the last index information in the current object index area is located as a current page and loading all information of the current page into a random access memory area;
the first judging unit is used for judging whether the current page can store one piece of index information;
the first storage unit is used for storing the index information into the random access storage area when the first judging unit judges that the current page can also store one piece of index information;
the second serving unit is used for serving a next page of the current page as the current page when the first judging unit judges that the current page can not store one piece of index information;
the second storage unit is used for loading all the information of the current page into the random access storage area and storing the index information into the random access storage area;
the first data writing unit is used for writing the information of the current page back to the object index area;
a receiving unit configured to obtain an offset address and a size of the received newly created object data from the index information;
a third acting unit, configured to load all information of the current page into the random access memory area, where a page where a last byte of last object data in the current object index area is located is taken as the current page;
the second judging unit is used for judging whether the current page can store newly created object data or not;
the second data writing unit is used for storing the newly created object data into the random access storage area and writing the data of the current page back to the object data area when the second judging unit judges that the current page can store the newly created object data;
the third data writing unit is used for writing the data of the current page back to the object data area after the current page is fully stored when the second judging unit judges that the current page can not store the newly created object data;
a fourth as unit for storing the received newly created object data into the random access memory area with a next page of the current page as the current page; the second judging unit is used for judging whether the newly created data is stored completely or not according to the first judging unit, and storing the received newly created object data into the random access memory area when the second judging unit judges that the newly created data is not stored completely;
a third judging unit configured to judge whether or not the newly created data is stored completely after the fourth as unit stores the received newly created object data in the random access memory area;
and the fourth data writing unit is used for writing the data of the current page back to the object data area when the third judging unit judges that the newly created data is stored completely.
Preferably, the first updating module 407 is specifically configured to: updating the location information of the object index area and the location information of the object data area in the random access memory area;
the storage module 409 is specifically configured to: storing the position information of the index area and the position information of the object data area in a nonvolatile storage area;
the first determining module 403 is specifically configured to: after determining the size of the residual space of the nonvolatile storage area according to the position information of the object index area and the object data area in the random access storage area, judging whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and index information.
In this embodiment, the first determining module 403 includes: a determination unit and a fourth judgment unit;
a determining unit for determining the size of the remaining space of the nonvolatile memory area according to the location information of the object index area and the object data area in the random access memory area;
a fourth judgment unit operable to judge whether or not the size of the index information plus the size of the received newly created object data is smaller than or equal to the size of the free area of the nonvolatile storage area.
In this embodiment, the first positioning module 410 specifically includes: a first determination submodule and a second determination submodule;
the first determining submodule is used for determining the index information of the object data needing to be modified according to the received unique identifier;
and the second determining submodule is used for determining the position information of the object data needing to be modified in the nonvolatile storage area according to the index information determined by the first determining submodule.
Preferably, the second determination submodule includes: a reading unit and a determining unit;
a reading unit, configured to read an offset address of object data in the index information;
and the determining unit is used for determining the read offset address according to the reading unit and determining the page number and the offset address in the page of the object data needing to be modified in the nonvolatile storage area.
Preferably, the determination unit is specifically configured to: adding the difference value obtained by subtracting 1 from the page size and the offset address, dividing the obtained sum by the page size, and taking an integer downwards from the obtained final result to obtain the page number of the data needing to be modified; and (4) the offset address is used for carrying out remainder on the page size, and the obtained final result is the in-page offset address of the page where the data needing to be modified is located.
In this embodiment, the apparatus further comprises: the device comprises a third judgment module, a fourth updating module and a second adding module; (ii) a
And the third judging module is used for judging whether the modification record containing the position information exists in the random access storage area.
The fourth updating module is used for updating the modified data in the modified record to be the received modified data when the third judging module judges that the modified record containing the position information exists in the random access storage area;
the execution module 401 is configured to execute the application instruction after the fourth update module updates the modified data in the modified record to the received modified data; the second adding module is also used for executing the application instruction after adding the modification record containing the position information and the size of the object data to be modified and the received modification data in the random access memory area;
and a second adding module, configured to add, when the third determining module determines that the modification record including the location information does not exist in the random access memory area, a modification record including the location information and the size of the object data to be modified and the received modification data in the random access memory area.
Specifically, the apparatus further comprises: the device comprises a fourth judging module, a fifth judging module, a first submitting module and an adding module;
the fourth judging module is used for judging whether the residual space of the random access storage area is enough to store the modification record containing the position information, the size and the modification data of the object data to be modified;
the fifth judging module is used for judging whether the data backup area in the nonvolatile storage area is full or not when the fourth judging module judges that the space is insufficient;
the first submitting module is used for submitting the modification records in the random access storage area to the data backup area and emptying the modification records in the random access storage area when the fifth judging module judges that the data backup area in the nonvolatile storage area is not full;
the adding module is used for adding modification records containing the position information and the size of the object data to be modified and the received modification data in the random access storage area when the fourth judging module judges that the space is enough; and the first submitting module is further used for adding a modification record containing the position information and the size of the object data to be modified and the received modification data in the random access storage area after the first submitting module empties the modification record in the random access storage area.
In this embodiment, the fourth determining module is specifically configured to: judging whether the residual space of the random access storage area is enough to store a modification record block containing the position information, the size and the modification data of the object data to be modified;
the first submission module is specifically configured to: when the fifth judging module judges that the data backup area in the nonvolatile storage area is not full, the modification recording block in the random access storage area is submitted to the data backup area, and the modification recording block in the random access storage area is emptied;
an adding module, specifically configured to: a modification record block containing the position information, size and received modification data of the object data to be modified is added to the random access memory area.
Specifically, the first traversal module 413 is specifically configured to: and traversing the modification record blocks of the data backup area and the random access storage area, reading the modification records of the modification record blocks, and obtaining the position information and the size of the object data to be modified in each modification record.
In this embodiment, the apparatus further comprises: a sixth judging module;
the sixth judging module is specifically configured to: judging whether the random access storage area has a modification record or not;
the first traversal module 413 is specifically configured to traverse the modification records of the nonvolatile storage area and the random access storage area when the sixth determination module determines that the modification record exists in the random access storage area;
a third updating module 416, configured to update the transaction status to an end transaction when the sixth determining module determines that the modification record does not exist in the random access memory area;
the execution module 401 is configured to execute the application instruction after the third update module 416 updates the transaction status to the end transaction.
In this embodiment, the statistical module 414 specifically includes: a traversing unit and a counting unit;
a traversal unit, configured to traverse modification records in the nonvolatile storage area and the random access storage area after the first traversal module 413 traverses the nonvolatile storage area and the random access storage area, to obtain location information and size of object data to be modified in each modification record;
and the counting unit is used for counting the number of the modification pages according to the position information and the size of the object data needing to be modified in each modification record obtained by the traversing unit.
Specifically, the apparatus further comprises: the system comprises a seventh judging module, a second submitting module, a second traversing module and a third data writing module;
and the seventh judging module is used for judging whether the number of the modified pages is larger than a preset value.
The second submitting module is used for submitting the modification records in the random access storage area to the nonvolatile storage area when the seventh judging module judges that the number of the modification pages is greater than the preset value;
the second traversal module is used for traversing and reading the modified records in the nonvolatile storage area after the modified records in the random access storage area are submitted to the nonvolatile storage area by the second submission module;
the third data writing module is used for writing the received modified data into the nonvolatile storage area; the seventh judging module is used for directly writing the modified data into the nonvolatile storage area when judging that the number of the modified pages is less than or equal to the preset value;
the third updating module 416 is further configured to update the transaction status to an end transaction after the third data writing module writes the received modified data into the nonvolatile storage area;
the execution module 401 is configured to execute the application instruction after the third update module 416 updates the transaction status to the end transaction.
Specifically, the apparatus further comprises: the device comprises a second positioning module, a reading module, a serving module, a searching module, a merging module, an eighth judging module and a clearing module;
a second positioning module, configured to determine, when the execution module 401 executes an instruction to read object data, location information of the object data that needs to be read according to the received unique identifier;
the reading module is used for reading the object data in the position information of the nonvolatile storage area;
a module for reading the object data in the nonvolatile storage area position information as target data;
a searching module, configured to search and read object data that is the same as the location information in the nonvolatile storage area and the random access storage area when the second determining module 408 determines that the transaction state is a start transaction;
the merging module is used for merging the object data which are searched and read by the searching module and are the same as the position information with the target data to obtain the data to be read;
a third updating module 416, configured to update the transaction status to an end transaction; the eighth judging module is further configured to update the transaction status to an end transaction when the eighth judging module judges that the data backup area has no modified record;
the execution module 401 is configured to execute the application instruction after the third update module 416 updates the transaction status to the end transaction; for executing the application instruction after the error reporting module 404 reports an error; the system comprises a clearing module, a storage module and a control module, wherein the clearing module is used for clearing the modification record of the random access storage area and then executing an application instruction;
an error reporting module 404, configured to report an error when the second determining module 408 determines that the transaction status is not the transaction start status;
an eighth determining module, configured to determine whether the data backup area has a modification record when the second determining module 408 determines that the transaction status is a transaction start status;
the clearing module is used for clearing the modification record of the data backup area when the eighth judging module judges that the modification record exists in the data backup area; the update record for clearing the random access memory area is cleared when the third update module 416 updates the transaction status to the end transaction.
Specifically, the second positioning includes: a first positioning unit and a second positioning unit;
a first positioning unit, configured to determine, when the execution module 401 executes an instruction to read object data, index information of the object data to be read according to the received unique identifier;
and the second positioning unit is used for determining the position information of the object data to be read in the nonvolatile storage area according to the index information determined by the first positioning unit.
In this embodiment, the searching module includes: a first traversal unit and a first reading unit;
the first traversal unit is used for traversing the data backup area and the random access storage area in the nonvolatile storage area to search for a modification record block containing the position;
and the first reading unit is used for reading out the modified data of the modified recording block searched by the first traversal unit and merging the modified data with the target data.
Specifically, the apparatus further comprises: the ninth judging module, the starting module and the second initializing module;
a ninth judging module, configured to judge whether to start power down protection;
the starting module is used for starting the power-down protection when the ninth judging module judges that the power-down protection is started;
and the second initialization module is used for initializing transaction processing when the ninth judgment module judges that the power failure protection is started.
Preferably, the starting module specifically includes: the device comprises an acquisition unit, a fifth acting unit, a fifth judgment unit, a first clearing unit, a first acquisition unit, a writing unit, a second acquisition unit and a sixth acting unit;
a second judging module 408, configured to judge whether the transaction status is a starting transaction;
an obtaining unit, configured to obtain a first modification record of the data backup area when the second determining module 408 determines that the object state is the start state;
a fifth acting unit, configured to use the first modified record of the data backup area obtained by the obtaining unit as the current modified record;
a fifth judging unit, configured to judge whether the current modification record has modification data;
a third updating module 416, configured to update the transaction status to an end transaction when the fifth determining module determines that the current modification record does not contain modification data;
a first clearing unit, configured to clear data in the data backup area after the third updating module 416 updates the transaction status to the end transaction;
the first obtaining unit is used for obtaining the modified data from the current modified record when the fifth judging unit judges that the modified data exist in the current modified record;
a writing unit for writing the modification data into the nonvolatile storage area according to the position information in the modification record;
the second acquisition unit is used for acquiring the next modification record of the current modification record;
and the sixth acting unit is used for taking the next modified record acquired by the second acquiring unit as the current modified record and triggering the fifth judging unit.
Specifically, the second determining module 408 is specifically configured to determine whether a value of the transaction flag is valid;
the third updating module 416 is specifically configured to set the value of the transaction flag to invalid.
Further, the apparatus further comprises: a writing module and an obtaining module;
the write-in module is used for writing the value of the transaction processing flag bit into the nonvolatile storage area;
an obtaining module to obtain a value of a transaction flag bit from a non-volatile storage area.
Still further, the second initialization module comprises: a second purge unit;
a second erasing unit configured to erase all data in the random access memory area;
the third updating module 416 is specifically configured to set the value of the transaction flag to invalid.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all such changes or substitutions should be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (42)

1. An optimization processing method for virtual machine transaction processing is characterized by specifically comprising the following steps:
step S1: the virtual machine executes the application instruction, and when the application instruction is executed to the first application interface, the transaction state is initialized to be a starting transaction; when creating the object data, step S2 is executed; when the object data is modified, step S3 is performed; when executing to the second application program interface, executing step S4;
step S2: the virtual machine judges whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and the index information, if the space is insufficient, an error is reported, the step S1 is returned, if the space is sufficient, the index information is generated according to the object data, the index information and the object data are added to the nonvolatile storage area, the position information of the index information and the position information of the object data are updated in the random access storage area, whether the transaction state is a starting transaction is judged, if not, the position information of the index information and the position information of the object data are stored in the nonvolatile storage area, and if yes, the step S1 is returned;
step S3: the virtual machine determines the position information of the object data needing to be modified according to the received unique identifier, judges whether the transaction state is a starting transaction, and modifies the object data needing to be modified in a nonvolatile storage area according to the position information of the object data needing to be modified if the transaction state is not the starting transaction state; if yes, updating the modification record of the object data needing to be modified in the random access storage area, and returning to the step S1;
step S4: the virtual machine judges whether the transaction state is a starting transaction, and if not, an error is reported; if yes, traversing the modification records of the nonvolatile storage area and the random access storage area, counting the number of modified pages, directly writing modified data into the nonvolatile storage area, updating the transaction state into an end transaction, and returning to the step S1;
in step S2, the adding the index information and the object data to the nonvolatile storage area specifically includes:
adding the index information to an object index area of the nonvolatile storage area, and adding the object data to an object data area of the nonvolatile storage area;
the adding the index information to the object index area of the nonvolatile storage area specifically includes:
step X1: acquiring an offset address of a current object index area from a data global information area of the nonvolatile storage area, and finding a page where the last piece of index information is located according to the offset address;
step X2: taking the page where the last index information in the current object index area is located as a current page, and loading all information of the current page into a random access memory area;
step X3: judging whether the current page can store an index message or not, if so, storing the newly created index message into the random access memory area, otherwise, executing the step X4;
step X4: taking the next page of the current page as the current page, loading all information of the current page into the random access memory area, and storing the newly created index information into the random access memory area;
step X5: writing all information of the current page back to the object index area;
adding the object data in the object data area of the nonvolatile storage area specifically includes:
step Y1: obtaining an offset address and a size of the received newly created object data from the index information;
step Y2: taking a page where the last byte of the last piece of object data in the current object index area is located as a current page, and loading all information of the current page into a random access memory area;
step Y3: judging whether the current page can store newly created object data, if so, storing the newly created object data into a random access memory area, and writing the data of the current page back to an object data area; otherwise, after the current page is full, writing the data of the current page back to the object data area, and executing step Y4;
step Y4: and taking the next page of the current page as the current page, storing the received newly created object data into a random access memory area, judging whether the newly created object data is stored completely, if so, writing the data of the current page back into an object data area, and if not, continuing to execute the step Y4.
2. The method according to claim 1, wherein in step S2, the updating the location information of the index information and the location information of the object data in the random access memory area specifically comprises: updating the location information of the object index area and the location information of the object data area in a random access memory area;
the storing the position information of the index information and the position information of the object data in the nonvolatile storage area specifically includes: storing location information of the object index area and location information of the object data area in the nonvolatile storage area;
the determining whether the remaining space of the nonvolatile storage area is sufficient to store the received newly created object data and the index information specifically includes: after determining the size of the residual space of the nonvolatile storage area according to the position information of the object index area and the object data area in the random access storage area, judging whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and index information.
3. The method according to claim 1, wherein in step S2, the determining whether the remaining space of the nonvolatile storage area is sufficient to store the received newly created object data and the index information includes: after determining the size of the remaining space of the nonvolatile storage area according to the position information of the object index area and the object data area in the random access storage area, judging whether the size of the index information plus the size of the received newly created object data is smaller than or equal to the size of a blank area of the nonvolatile storage area.
4. The method according to claim 1, wherein in step S3, the determining the location information of the object data that needs to be modified according to the received unique identifier includes:
and determining the index information of the object data to be modified according to the received unique identifier, and determining the position information of the object data to be modified in the nonvolatile storage area according to the index information of the object data to be modified.
5. The method according to claim 4, wherein the determining the location information of the object data to be modified in the nonvolatile storage area according to the index information of the object data to be modified specifically includes:
and determining the page number and the offset address in the page of the object data to be modified in the nonvolatile storage area by reading the offset address of the object data in the index information of the object data to be modified.
6. The method according to claim 5, wherein the determining of the page number and the offset address in the page where the object data to be modified is located in the nonvolatile storage area specifically includes:
adding the difference value obtained by subtracting 1 from the page size and the offset address, dividing the obtained sum by the page size, and taking an integer downwards from the obtained final result to obtain the page number of the data needing to be modified; and (4) the offset address is used for carrying out remainder on the page size, and the obtained final result is the in-page offset address of the page where the data needing to be modified is located.
7. The method according to claim 1, wherein in step S3, before the updating the modification record of the object data needing to be modified in the random access memory area, the method further comprises: the virtual machine judges whether a modification record containing the position information of the object data needing to be modified exists in the random access storage area, if so, the modification data in the modification record is updated to be received modification data, and the step S1 is returned; if not, a modification record containing the location information and the size of the object data to be modified and the received modification data is added to the random access memory area, and the process returns to step S1.
8. The method according to claim 7, wherein before adding a modification record containing the location information, the size, and the received modification data of the object data to be modified in the random access memory area, the method further comprises:
step C1: judging whether the remaining space of the random access memory area is enough to store the modification record containing the position information and the size of the object data to be modified and the received modification data, if the space is not enough, executing the step C2, and if the space is enough, executing the step C4;
step C2: judging whether the data backup area in the nonvolatile storage area is full, if so, canceling the transaction, reporting an error, returning to the step S1, otherwise, executing the step C3;
step C3: submitting the modification record in the random access storage area to the data backup area, emptying the modification record in the random access storage area, and executing step C4;
step C4: and adding a modification record containing the position information and the size of the object data needing to be modified and the received modification data in the random access memory area.
9. The method according to claim 8, wherein the step C1 is specifically: judging whether the remaining space of the random access memory area is enough to store the modification record block containing the position information and the size of the object data to be modified and the received modification data, if the space is insufficient, executing the step C2, and if the space is enough, executing the step C4;
the step C3 specifically includes: submitting the modified record blocks in the random access storage area to the data backup area, emptying the modified record blocks in the random access storage area, and executing step C4;
the step C4 specifically includes: and adding a modification record block containing the position information and the size of the object data needing to be modified and the received modification data in the random access memory area.
10. The method according to claim 1, wherein in step S4, the modified records traversing the nonvolatile storage area and the random access storage area are specifically: and traversing the modification record blocks of the data backup area and the random access storage area, reading the modification records of the modification record blocks, and obtaining the position information and the size of the object data to be modified in each modification record.
11. The method according to claim 1, wherein in step S4, before the step of traversing the modified records of the nonvolatile memory area and the random access memory area, the method further comprises: and judging whether a modification record exists in the random access storage area, if the modification record does not exist, updating the transaction state to be an end transaction, returning to the step S1, and if the modification record exists, executing the modification record traversing the nonvolatile storage area and the random access storage area.
12. The method according to claim 1, wherein in the step S4, the statistical number of modified pages is specifically: and after the virtual machine traverses the modification records of the nonvolatile storage area and the random access storage area to obtain the position information and the size of the object data to be modified in each modification record, the virtual machine counts the number of modification pages according to the position information and the size of the object data to be modified in each modification record.
13. The method according to claim 12, wherein before the step S4, the step of writing the modified data directly into the nonvolatile storage area further comprises: the virtual machine judges whether the number of the modified pages is greater than a preset value, if the virtual machine judges that the number of the modified pages is greater than the preset value, the virtual machine submits the modified records in the random access storage area to the nonvolatile storage area, then, the modified records in the nonvolatile storage area are read in a traversing manner, the received modified data are written into the nonvolatile storage area, the transaction state is updated to be an end transaction, and the operation returns to the step S1; if the virtual machine judges that the number of modified pages is less than or equal to the predetermined value, the received modified data is directly written into the nonvolatile storage area, the transaction status is updated to the end transaction, and the process returns to step S1.
14. The method according to claim 1, wherein the step S1 further comprises:
when the object data is read, step S5 is executed; when the third application interface is executed, step S6 is executed;
step S5: the virtual machine determines the position information of the object data needing to be read according to the received unique identifier, reads the object data in the position information of the object data needing to be read in the nonvolatile storage area as the target data, judges whether the transaction state is a start transaction, if not, reports an error, returns to the step S1, if yes, searches and reads the object data which is the same as the position information of the object data needing to be read in the nonvolatile storage area and the random access storage area, combines the object data with the target data to obtain the data needing to be read, updates the transaction state to be an end transaction, and returns to the step S1;
step S6: the virtual machine judges whether the transaction state is a beginning transaction, if not, an error is reported, the process returns to the step S1, if yes, whether a modification record exists in the data backup area is judged, if yes, the transaction state is updated to be an ending transaction after the modification record in the data backup area is cleared, then the modification record in the random access storage area is cleared, and the process returns to the step S1; if not, the transaction status is updated to the end transaction, and after the modified record of the random access memory area is cleared, the process returns to step S1.
15. The method according to claim 14, wherein in step S5, the determining the location information of the object data to be read according to the received unique identifier includes:
and determining the index information of the object data to be read according to the received unique identifier, and determining the position information of the object data to be read in the nonvolatile storage area according to the index information of the object data to be read.
16. The method according to claim 15, wherein in step S5, the finding and reading the object data in the nonvolatile storage area and the random access storage area, which is the same as the location information of the object data to be read, specifically comprises: traversing the data backup area and the random access storage area in the nonvolatile storage area to search for a modified record block containing the position information of the object data to be read, reading out the modified data of the modified record block and merging the modified data with the target data.
17. The method according to claim 1, wherein the step S1 is preceded by:
step F1: judging whether power-down protection is started, if so, starting the power-down protection, and executing the step S1, otherwise, executing the step F2;
step F2: the virtual machine performs transaction initialization, and step S1 is executed.
18. The method according to claim 17, wherein the initiating power down protection specifically comprises:
judging whether the transaction state is a beginning transaction, if not, reporting an error, returning to the step S1, if so, acquiring a first modification record of a data backup area as a current modification record, judging whether the current modification record contains modification data, if not, updating the transaction state to be an end transaction, clearing data of the data backup area, returning to the step S1, if so, acquiring the modification data from the current modification record, writing the modification data into a nonvolatile storage area according to the position information in the modification record, acquiring a next modification record of the current modification record as the current modification record, and continuously judging whether the current modification record contains the modification data.
19. The method according to claim 18, wherein the step S2 of determining whether the transaction status is a start transaction specifically includes: judging whether the value of the transaction flag bit is valid, if so, returning to the step S1, otherwise, storing the position information of the index information and the position information of the object data in the nonvolatile storage area;
in the step S3, the determining whether the transaction state is a start transaction specifically includes: judging whether the value of the transaction flag bit is valid, if so, updating the modification record of the object data to be modified in the random access storage area, returning to the step S1, otherwise, modifying the object data to be modified in the nonvolatile storage area according to the position information of the object data to be modified;
in the step S4, the determining whether the transaction state is a start transaction specifically includes: judging whether the value of the transaction flag bit is valid, if so, traversing the modification records of the nonvolatile storage area and the random access storage area and counting the number of modified pages, otherwise, reporting an error;
the updating the transaction state to be an end transaction specifically includes: and setting the value of the transaction processing flag bit to be invalid.
20. The method according to claim 19, wherein before said writing the modified data directly to the nonvolatile storage area in step S4, further comprising: writing the value of the transaction flag bit to a non-volatile storage area;
after the power down protection is started in step F1, the method further includes: the value of the transaction flag bit is obtained from the non-volatile storage area.
21. The method according to claim 20, wherein step F2 specifically comprises: clearing all data in the random access memory area and setting the value of the transaction flag bit to be invalid.
22. An optimization processing device for virtual machine transaction processing, the device specifically includes:
the execution module is used for executing the application instruction; the second judging module is used for executing the application instruction when the transaction state is judged to be the starting transaction; the second updating module is used for executing the application instruction after updating the modification record of the object data needing to be modified in the random access memory area; the third updating module is also used for executing the application instruction after the transaction state is updated to the end transaction by the third updating module;
the first initialization module is used for initializing the transaction state as a starting transaction when the execution module executes to the first application interface;
the first judging module is used for judging whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and the index information when the executing module executes the creation of the object data;
the error reporting module is used for reporting an error when the first judging module judges that the residual space of the nonvolatile storage area is not enough to store the received newly-created object data and the index information; the second judging module is further used for reporting an error when the second judging module judges that the transaction state is not the beginning transaction;
the generating module is used for generating the index information according to the object data when the first judging module judges that the residual space of the nonvolatile storage area is enough to store the received newly-created object data and the index information;
a first adding module, configured to store, in the nonvolatile storage area, the index information and the object data generated by the generating module;
a first updating module for updating the position information of the index information and the position information of the object data in a random access memory area;
a second judging module, configured to judge whether the transaction state is a start transaction after the first updating module updates the location information of the index information and the location information of the object data in the random access memory area; the first positioning module is used for judging whether the transaction state is a starting transaction or not after determining the position information of the object data needing to be modified; the execution module is further used for judging whether the transaction state is a starting transaction or not when the execution module executes to a second application program interface;
a storage module, configured to store, in the nonvolatile storage area, location information of the index information and location information of the object data when the second determination module determines that the transaction state is not a start transaction;
the first positioning module is used for determining the position information of the object data to be modified according to the received unique identifier after the execution module executes the instruction for modifying the object data;
a modification module, configured to modify, when the second determination module determines that the transaction state is not a start transaction, the object data to be modified in a nonvolatile storage area according to the location information of the object data to be modified;
a second updating module, configured to update, when the execution module executes the instruction for modifying the object data and when the second determination module determines that the transaction status is a transaction start status, a modification record of the object data that needs to be modified in the random access memory area;
the first traversal module is used for traversing the modification records of the nonvolatile storage area and the random access storage area when the execution module executes the second application program interface and the second judgment module judges that the transaction state is the starting transaction;
the counting module is used for counting the number of modified pages after the first traversal module traverses the modification records of the nonvolatile storage area and the random access storage area;
the first data writing module is used for directly writing the modified data into the nonvolatile storage area;
the third updating module is used for updating the transaction state into an end transaction after the first data writing module directly writes the modified data into the nonvolatile storage area;
the first adding module specifically comprises: a first adding submodule and a second adding submodule;
the first adding submodule is used for adding the index information in an object index area of the nonvolatile storage area;
the second adding submodule is used for adding the object data in an object data area of the nonvolatile storage area;
the first adding submodule specifically includes: the device comprises a searching unit, a first acting unit, a first judging unit, a first storage unit, a second acting unit, a second storage unit and a first data writing unit;
the searching unit is used for acquiring the offset address of the current object index area from the data global information area of the nonvolatile storage area and finding the page where the last piece of index information is located according to the offset address;
the first serving unit is configured to take a page where the last piece of index information in the current object index area is located as a current page, and load all information of the current page into a random access memory area;
the first judging unit is used for judging whether the current page can store one piece of index information or not;
the first storage unit is used for storing newly created index information into the random access storage area when the first judging unit judges that the current page can also store one piece of index information;
the second acting unit is used for taking the next page of the current page as the current page when the first judging unit judges that the current page can not store one piece of index information;
the second storage unit is used for loading all information of the current page into the random access memory area and storing newly created index information into the random access memory area;
the first data writing unit is used for writing the information of the current page back to the object index area;
the second adding sub-module specifically comprises: the device comprises a receiving unit, a third acting unit, a second judging unit, a second data writing unit, a third data writing unit, a fourth acting unit, a third judging unit and a fourth data writing unit;
the receiving unit is used for obtaining the offset address and the size of the received newly created object data from the index information;
the third acting unit is used for taking the page where the last byte of the last piece of object data in the current object index area is located as the current page and loading all information of the current page into the random access memory area;
the second judging unit is configured to judge whether the current page can store newly created object data;
the second write data unit is configured to, when the second determination unit determines that the current page is capable of storing the newly created object data, store the newly created object data in a random access memory area, and write back the data of the current page to an object data area;
the third data writing unit is configured to write back the data of the current page to the object data area after the current page is full when the second determining unit determines that the current page cannot store the newly created object data;
the fourth serving unit is configured to take a next page of the current page as the current page, and store the received newly created object data in a random access memory area; the third judging unit is further configured to, when the third judging unit judges that the newly created object data is not stored completely, take a next page of the current page as a current page, and store the received newly created object data in a random access memory area;
the third judging unit is configured to judge whether the newly created data is stored up after the fourth unit stores the received newly created object data in a random access memory area;
and the fourth data writing unit is configured to write back the data of the current page to the object data area when the third determining unit determines that the newly created data is stored completely.
23. The apparatus of claim 22, wherein the first update module is specifically configured to: updating the location information of the object index area and the location information of the object data area in a random access memory area;
the storage module is specifically configured to: storing location information of the object index area and location information of the object data area in the nonvolatile storage area;
the first judging module is specifically configured to: after determining the size of the residual space of the nonvolatile storage area according to the position information of the object index area and the object data area in the random access storage area, judging whether the residual space of the nonvolatile storage area is enough to store the received newly created object data and index information.
24. The apparatus of claim 22, wherein the first determining module comprises: a determination unit and a fourth judgment unit;
the determining unit is used for determining the size of the residual space of the nonvolatile storage area according to the position information of the object index area and the object data area in the random access storage area;
the fourth judging unit is configured to judge whether or not the size of the index information plus the size of the received newly created object data is smaller than or equal to the size of the free area of the nonvolatile storage area.
25. The apparatus according to claim 22, wherein the first positioning module specifically comprises: a first determination submodule and a second determination submodule;
the first determining submodule is used for determining index information of the object data needing to be modified according to the received unique identifier;
and the second determining submodule is used for determining the position information of the object data needing to be modified in the nonvolatile storage area according to the index information determined by the first determining submodule.
26. The apparatus of claim 25, wherein the second determining submodule comprises: a reading unit and a determining unit;
the reading unit is used for reading the offset address of the object data in the index information of the object data to be modified;
the determining unit is used for determining the page number and the offset address in the page of the object data needing to be modified in the nonvolatile storage area according to the offset address read by the reading unit.
27. The apparatus according to claim 26, wherein the determining unit is specifically configured to: adding the difference value obtained by subtracting 1 from the page size and the offset address, dividing the obtained sum by the page size, and taking an integer downwards from the obtained final result to obtain the page number of the data needing to be modified; and (4) the offset address is used for carrying out remainder on the page size, and the obtained final result is the in-page offset address of the page where the data needing to be modified is located.
28. The apparatus of claim 22, further comprising: the device comprises a third judgment module, a fourth updating module and a second adding module;
the third judging module is used for judging whether a modification record containing the position information of the object data needing to be modified exists in the random access storage area;
the fourth updating module is configured to update the modified data in the modified record to the received modified data when the third determining module determines that the modified record including the location information of the object data to be modified exists in the random access memory area;
the execution module is configured to execute the application instruction after the fourth updating module updates the modified data in the modified record to the received modified data; the second adding module is further configured to execute an application instruction after adding a modification record containing the location information and the size of the object data to be modified and the received modification data in the random access memory area;
the second adding module is configured to add, when the third determining module determines that no modification record including the location information of the object data that needs to be modified exists in the random access memory area, a modification record including the location information and size of the object data that needs to be modified and the received modification data in the random access memory area.
29. The apparatus of claim 28, further comprising: the device comprises a fourth judging module, a fifth judging module, a first submitting module and an adding module;
the fourth judging module is configured to judge whether the remaining space of the random access storage area is sufficient to store a modification record that includes the location information and the size of the object data that needs to be modified and the received modification data;
the fifth judging module is used for judging whether the data backup area in the nonvolatile storage area is full or not when the fourth judging module judges that the space is insufficient;
the first submitting module is configured to submit the modification record in the random access storage area to the data backup area and empty the modification record in the random access storage area when the fifth determining module determines that the data backup area in the nonvolatile storage area is not full;
the adding module is configured to add, when the fourth determining module determines that the space is sufficient, a modification record including the location information and the size of the object data to be modified and the received modification data in the random access memory area; and the first committing module is further configured to add a modification record containing the location information and the size of the object data to be modified and the received modification data to the random access memory area after the first committing module clears the modification record in the random access memory area.
30. The apparatus according to claim 29, wherein the fourth determining module is specifically configured to: judging whether the residual space of the random access memory area is enough to store a modification record block containing the position information and the size of the object data to be modified and the received modification data;
the first submission module is specifically configured to: when the fifth judging module judges that the data backup area in the nonvolatile storage area is not full, submitting the modification record block in the random access storage area to the data backup area, and emptying the modification record block in the random access storage area;
the adding module is specifically configured to: adding a modification record block containing the location information, the size and the received modification data of the object data to be modified in the random access memory area.
31. The apparatus of claim 22, wherein the first traversal module is specifically configured to: and traversing the modification record blocks of the data backup area and the random access storage area, reading the modification records of the modification record blocks, and obtaining the position information and the size of the object data to be modified in each modification record.
32. The apparatus of claim 22, further comprising: a sixth judging module;
the sixth determining module is specifically configured to: judging whether the random access storage area has a modification record or not;
the first traversal module is specifically configured to traverse modification records of the nonvolatile storage area and the random access storage area when the sixth determination module determines that the modification record exists in the random access storage area;
the third updating module is configured to update the transaction state to an end transaction when the sixth determining module determines that no modification record exists in the random access memory area;
and the execution module is used for executing the application instruction after the third updating module updates the transaction state into the end transaction.
33. The apparatus according to claim 22, wherein the statistics module specifically includes: a traversing unit and a counting unit;
the traversal unit is used for traversing the modification records of the nonvolatile storage area and the random access storage area after the first traversal module traverses the nonvolatile storage area and the random access storage area to obtain the position information and the size of the object data to be modified in each modification record;
and the counting unit is used for counting the number of the modification pages according to the position information and the size of the object data needing to be modified in each modification record obtained by the traversing unit.
34. The apparatus of claim 33, further comprising: the system comprises a seventh judging module, a second submitting module, a second traversing module and a third data writing module;
the seventh judging module is configured to judge whether the number of the modified pages is greater than a predetermined value;
the second submitting module is configured to submit the modification record in the random access storage area to the nonvolatile storage area when the seventh determining module determines that the number of the modification pages is greater than the predetermined value;
the second traversal module is configured to, after the second submission module submits the modified record in the random access storage area to the nonvolatile storage area, traverse and read the modified record in the nonvolatile storage area;
the third data writing module is used for writing the received modified data into the nonvolatile storage area; the seventh judging module is further configured to directly write the received modified data into the nonvolatile storage area when judging that the number of modified pages is less than or equal to a predetermined value;
the third updating module is further configured to update the transaction state to an end transaction after the third data writing module writes the received modification data into the nonvolatile storage area;
and the execution module is used for executing the application instruction after the third updating module updates the transaction state into the end transaction.
35. The apparatus of claim 22, further comprising: the device comprises a second positioning module, a reading module, a serving module, a searching module, a merging module, an eighth judging module and a clearing module;
the second positioning module is used for determining the position information of the object data to be read according to the received unique identifier when the execution module executes the instruction for reading the object data;
the reading module is used for reading the object data in the position information of the object data needing to be read in the nonvolatile storage area;
the acting module is used for reading the object data in the position information of the object data needing to be read in the nonvolatile storage area as target data;
the searching module is configured to search and read object data that is the same as the location information of the object data to be read in the nonvolatile storage area and the random access storage area when the second determining module determines that the transaction state is a transaction start state;
the merging module is used for merging the object data which are searched and read by the searching module and have the same position information with the object data to be read with the target data to obtain the data to be read;
the third updating module is used for updating the transaction state into an end transaction; the eighth judging module is further configured to update the transaction status to an end transaction when the eighth judging module judges that the data backup area has no modified record;
the execution module is configured to execute the application instruction after the third updating module updates the transaction status to the end transaction; the application instruction is executed after the error reporting module reports errors; the system comprises a clearing module, a storage module and a control module, wherein the clearing module is used for executing an application instruction after clearing a modification record of a random access storage area;
the error reporting module is configured to report an error when the second determining module determines that the transaction status is not the transaction start status;
the eighth determining module is configured to determine whether the data backup area has a modification record when the second determining module determines that the transaction status is a transaction start status;
the clearing module is configured to clear the modification record in the data backup area when the eighth determining module determines that the data backup area has the modification record; and the modification record of the random access memory area is cleared when the third updating module updates the transaction state to the end transaction.
36. The apparatus of claim 35, wherein the second positioning module comprises: a first positioning unit and a second positioning unit;
the first positioning unit is used for determining the index information of the object data to be read according to the received unique identifier when the execution module executes the instruction for reading the object data;
the second positioning unit is used for determining the position information of the object data to be read in the nonvolatile storage area according to the index information of the object data to be read determined by the first positioning unit.
37. The apparatus of claim 36, wherein the lookup module comprises: a first traversal unit and a first reading unit;
the first traversal unit is used for traversing the data backup area and the random access storage area in the nonvolatile storage area to search for a modification record block containing the position information of the object data to be read;
and the first reading unit is used for reading out the modified data of the modified recording block searched by the first traversal unit and merging the modified data with the target data.
38. The apparatus of claim 22, further comprising: the ninth judging module, the starting module and the second initializing module;
the ninth judging module is used for judging whether to start power-down protection;
the starting module is used for starting the power-down protection when the ninth judging module judges that the power-down protection is started;
and the second initialization module is used for initializing transaction processing when the ninth judgment module judges that the power failure protection is started.
39. The apparatus according to claim 38, wherein the starting module specifically comprises: the device comprises an acquisition unit, a fifth acting unit, a fifth judgment unit, a first clearing unit, a first acquisition unit, a writing unit, a second acquisition unit and a sixth acting unit;
the second judging module is used for judging whether the transaction state is a starting transaction;
the obtaining unit is configured to obtain a first modification record of the data backup area when the second determining module determines that the transaction state is the starting state;
the fifth acting unit is configured to use the first modified record of the data backup area acquired by the acquiring unit as the current modified record;
the fifth judging unit is configured to judge whether the current modification record has modification data;
the third updating module is configured to update the transaction status to an end transaction when the fifth determining module determines that the current modification record does not have modification data;
the first clearing unit is configured to clear the data in the data backup area after the third updating module updates the transaction status to the end transaction;
the first obtaining unit is configured to obtain modified data from the current modified record when the fifth determining unit determines that the modified data exists in the current modified record;
the writing unit is used for writing the modified data into the nonvolatile storage area according to the position information in the modified record;
the second obtaining unit is configured to obtain a next modified record of the current modified record;
and the sixth acting unit is configured to use the next modified record obtained by the second obtaining unit as the current modified record, and trigger the fifth judging unit.
40. The apparatus according to claim 22, wherein the second determining module is specifically configured to determine whether a value of a transaction flag bit is valid;
the third updating module is specifically configured to set the value of the transaction flag to be invalid.
41. The apparatus of claim 40, further comprising: a writing module and an obtaining module;
the writing module is used for writing the value of the transaction processing flag bit into a nonvolatile storage area;
the obtaining module is configured to obtain a value of a transaction flag from the nonvolatile storage area.
42. The apparatus of claim 41, wherein the second initialization module comprises: a second purge unit;
the second clearing unit is used for clearing all data in the random access memory area;
the third updating module is specifically configured to set the value of the transaction flag to be invalid.
CN201710534000.3A 2017-07-03 2017-07-03 Transaction optimization processing method and device Active CN107341049B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710534000.3A CN107341049B (en) 2017-07-03 2017-07-03 Transaction optimization processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710534000.3A CN107341049B (en) 2017-07-03 2017-07-03 Transaction optimization processing method and device

Publications (2)

Publication Number Publication Date
CN107341049A CN107341049A (en) 2017-11-10
CN107341049B true CN107341049B (en) 2020-02-11

Family

ID=60218232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710534000.3A Active CN107341049B (en) 2017-07-03 2017-07-03 Transaction optimization processing method and device

Country Status (1)

Country Link
CN (1) CN107341049B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109002401A (en) * 2018-05-04 2018-12-14 广东睿江云计算股份有限公司 Magnetic disk of virtual machine reproduction process read method and device based on dynamic buffering
CN112882867B (en) * 2021-02-25 2024-03-05 杭州海康威视系统技术有限公司 Index information storage method and device and storage equipment
CN114791832B (en) * 2022-04-24 2024-02-27 深圳软牛科技集团股份有限公司 IOS system repairing method and device when equipment space is insufficient and related components

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102495754A (en) * 2011-10-27 2012-06-13 飞天诚信科技股份有限公司 Cache-based java card transaction processing method
CN103955395A (en) * 2014-04-28 2014-07-30 飞天诚信科技股份有限公司 Method and device for efficient object management

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100410557B1 (en) * 2001-11-19 2003-12-18 주식회사 하이닉스반도체 Microcontroller with program patching capability and method for operating the same

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102495754A (en) * 2011-10-27 2012-06-13 飞天诚信科技股份有限公司 Cache-based java card transaction processing method
CN103955395A (en) * 2014-04-28 2014-07-30 飞天诚信科技股份有限公司 Method and device for efficient object management

Also Published As

Publication number Publication date
CN107341049A (en) 2017-11-10

Similar Documents

Publication Publication Date Title
JP5032172B2 (en) Integrated memory management apparatus and method, and data processing system
CN105009094B (en) The method, apparatus and system of two ranks power-up mapping are rebuild using space free count in solid state drive
CN109871333B (en) Method for accessing flash memory module, related flash memory controller and electronic device
US20180275887A1 (en) Data Storage Device and Operating Method of Data Storage Device
CN101650972B (en) Method for updating data of nonvolatile memory of intelligent card
CN103164342B (en) Coordinate during the carry of availability of data
TW201833777A (en) Data storage device and operating method therefor
CN109582599A (en) Data memory device and non-volatile formula memory operating method
CN100501868C (en) Method for realizing memory file system based on NAND Flash
US8825946B2 (en) Memory system and data writing method
JPH07105691A (en) Method of writing/erasing and controlling storage
JP2006235960A (en) Method for increasing speed of garbage collection
CN107341049B (en) Transaction optimization processing method and device
CN113785275B (en) Flash data power-down protection method and device
CN109783396A (en) The method of access flash memory module and relevant flash controller and electronic device
JP4909963B2 (en) Integrated memory management device
CN109669889B (en) Light Nor Flash control method and device
JP2010287049A (en) Memory system and memory system management method
CN104021089A (en) Flash memory control chip, storage device and flash memory control method
CN104978154A (en) Cache operation-based flash rapid read-write method and system
JP2009205689A (en) Flash disk device
CN100456263C (en) Method for treating broken block when using flash memory in tax-controlled cashing machine
US20220171540A1 (en) Reducing wear on zoned storage devices for storing digital data
CN102169464A (en) Caching method and device used for non-volatile memory, and intelligent card
JP2000285001A (en) Semiconductor flash memory device and its control method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant