Data management method, device and system based on embedded database

By using the storage location of attribute table storage block data in embedded databases, the problem of low data management efficiency on flash storage media in embedded systems is solved, and efficient real-time data management and fast response are achieved.

CN119782276APending Publication Date: 2025-04-08SAGE MICROELECTRONICS CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411745015.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

In embedded systems, the prior art is difficult to efficiently manage data on flash Flash storage media, and relies on the file system interface of the embedded operating system, limiting data management efficiency.

Method used

By using the storage location of the attribute table storage block data in the embedded database, the query is identified according to the target command in the data management instructions and the target storage location of the data management operation is determined, thereby performing the corresponding data management operation.

Benefits of technology

It realizes efficient real-time management of block data, improves data management efficiency, can quickly respond to and execute instructions, and meets the needs of high-real-time scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782276A_ABST
    Figure CN119782276A_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a data management method, device and system based on an embedded database, which is used to improve the data management efficiency in an embedded system. The scheme includes: receiving a data management instruction, the data management instruction carries a target command identifier; querying a target attribute table to which the target command identifier belongs from the embedded database, wherein any attribute table in the embedded database includes the storage location of the block data corresponding to the command identifier in the flash memory; determining the target storage location of the data management operation to be performed based on the storage location of the block data in the target attribute table; and performing a data management operation matching the target command identifier on the target storage location in the flash memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data storage, and in particular to a data management method, device and system based on an embedded database. Background Art

[0002] In embedded systems, lightweight embedded databases can be used to implement data management, such as SQLite, but its disadvantage is that it relies on the file system interface provided by the embedded operating system. In addition, in-memory relational databases can also achieve fast data management, but their disadvantage is that they cannot manage data on flash storage media.

[0003] How to improve data management efficiency in embedded systems is a technical problem to be solved by this application. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a data management method, device and system based on an embedded database, so as to improve the data management efficiency in an embedded system.

[0005] In a first aspect, a data management method based on an embedded database is provided, comprising: receiving a data management instruction, wherein the data management instruction carries a target command identifier; Querying the target attribute table to which the target command identifier belongs from the embedded database, wherein any attribute table in the embedded database includes the storage location of the block data corresponding to the command identifier in the flash memory; Determining a target storage location of a data management operation to be performed based on the storage location of the block data in the target attribute table; A data management operation matching the target command identifier is performed on a target storage location in the flash memory.

[0006] In a second aspect, a data management device based on an embedded database is provided, comprising: A receiving module receives a data management instruction, wherein the data management instruction carries a target command identifier; A query module, which queries the target attribute table to which the target command identifier belongs from the embedded database, wherein any attribute table in the embedded database includes the storage location of the block data corresponding to the command identifier in the flash memory; A determination module, which determines a target storage location of a data management operation to be performed based on a storage location of the block data in the target attribute table; An execution module executes a data management operation matching the target command identifier on a target storage location in the flash memory.

[0007] In a third aspect, a data management system based on an embedded database is provided, comprising: A SAS expander, used to execute the data management method based on an embedded database as described in any one of claims 1 to 8; A SAS host connected to the SAS expander via a SAS interface, and configured to send a data management instruction to the SAS expander; At least one SAS device is connected to the SAS expander via a SAS interface.

[0008] In a fourth aspect, an electronic device is provided, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method of the first aspect when executed by the processor.

[0009] In a fifth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method of the first aspect are implemented.

[0010] In a sixth aspect, a computer program product is provided, the computer program product comprising a non-transitory computer-readable storage medium storing a computer program, the computer program being operable to cause a computer to execute part or all of the steps of the method of the first aspect.

[0011] In an embodiment of the present application, first, a data management instruction is received, and the data management instruction carries a target command identifier; then, a target attribute table to which the target command identifier belongs is queried from an embedded database, wherein any attribute table in the embedded database includes the storage location of the block data corresponding to the command identifier in the flash memory; then, the target storage location of the data management operation to be performed is determined based on the storage location of the block data in the target attribute table; finally, the data management operation matching the target command identifier is performed on the target storage location in the flash memory. In the scheme provided by the embodiment of the present application, the storage location of the block data corresponding to the command identifier is stored in the embedded database through the attribute table, and the specific storage location of the block data in the flash memory can be determined by querying the embedded database based on the target command identifier carried in the data management instruction. Then, the target storage location to perform the data management operation is determined to perform the data management operation matching the target command identifier. Through the scheme provided by the embodiment of the present application, efficient real-time management of block data can be achieved, which is conducive to the rapid execution of instructions and response instructions. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1a This is one of the flow charts of a data management method based on an embedded database in one embodiment of the present application; Figure 1b It is a schematic diagram of the storage structure of an attribute table and associated block data in a flash memory Flash of a data management method based on an embedded database in an embodiment of the present application; Figure 2 This is a second flow chart of a data management method based on an embedded database in an embodiment of the present application; Figure 3a This is a flowchart of a data management method based on an embedded database according to an embodiment of the present application; Figure 3b This is a fourth flow chart of a data management method based on an embedded database in an embodiment of the present application; Figure 4 This is a flowchart of a data management method based on an embedded database in one embodiment of the present application; Figure 5 This is a sixth flow chart of a data management method based on an embedded database in an embodiment of the present application; Figure 6a This is a flowchart of a data management method based on an embedded database according to an embodiment of the present application; Figure 6b This is a flowchart of a data management method based on an embedded database in an embodiment of the present application. Figure 7 This is a ninth flow chart of a data management method based on an embedded database in an embodiment of the present application; Figure 8 It is a structural diagram of a data management device based on an embedded database in one embodiment of the present application; Fig. 9 It is a structural diagram of a data management system based on an embedded database in one embodiment of the present application. DETAILED DESCRIPTION

[0013] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application. The numbering of the drawings in this application is only used to distinguish the various steps in the scheme, and is not used to limit the execution order of the various steps. The specific execution order is subject to the description in the specification.

[0014] In embedded systems, data management can be achieved through embedded databases such as SQLite. Although the C language implementation is easy to port and is generally applicable to multiple types of data, this implementation method relies on the embedded operating system, especially the embedded operating system providing a file system interface. It can be seen that the relevant technologies for implementing data management are subject to many limitations and have the defect of low data management efficiency.

[0015] Next, we will use an actual application scenario to illustrate the technical problems existing in the data storage field.

[0016] SAS (Serial Attached Small Computer System Interface) Expander is a large-scale System on Chip (SoC), which functions like a router in a network, connecting between a SAS host and a SAS device to exchange data and expand ports. Specifically, SAS Expander is connected to a SAS host and a SAS end device through a SAS interface, and command communication can follow the SAS protocol. The SAS host can manage and configure the Expander through SSP commands and SMP commands defined in the SAS protocol.

[0017] In actual applications, SAS Expander can connect dozens, hundreds or even more hard disks, and manage and maintain a large amount of hard disk status and fault diagnosis data. It usually does not have off-chip memory, but directly stores these data in Flash memory (flash memory). In response to commands from the SAS storage system, SAS Expander can query and manage these data in real time. In this scenario, embedded databases, in-memory relational databases and other methods are subject to technical limitations and are difficult to meet the application requirements of SAS Expander.

[0018] For the above application scenarios involving SAS Expander, the disadvantages and limitations include: (1) If an embedded database such as SQLite is used, it often requires large memory resources and high hardware resource requirements, which is not suitable for embedded systems such as SAS Expander that have small off-chip memory capacity or even no off-chip memory.

[0019] (2) Embedded databases rely on hardware resources for database processing speed and often have the defect of slow processing response, making it difficult to meet the application requirements of high real-time scenarios.

[0020] (3) Embedded databases often rely on embedded operating systems, which limits the choice of operating systems for embedded applications.

[0021] (4) For example, embedded databases such as in-memory databases make it difficult to establish databases on different storage media in embedded systems.

[0022] In order to solve the problems existing in the related art, the embodiment of the present application provides a data management method based on an embedded database, which can be applied to chip devices such as SAS Expander. Figure 1a As shown, the method provided in the embodiment of the present application includes: S11: Receive a data management instruction, where the data management instruction carries a target command identifier.

[0023] In this step, the target command identifier carried in the data management instruction can be determined by parsing the data management instruction. The target command identifier carried by the data management instruction can be used to indicate the type of operation to be performed. In the above application scenario involving SASExpander, the data management instruction can be sent to SASExpander by a SAS host through a SAS interface.

[0024] In actual applications, the target command identifier carried by the data management instruction can be used to instruct the execution of operations such as data query, read, write, and delete.

[0025] S12: Query the target attribute table to which the target command identifier belongs from the embedded database, wherein any attribute table in the embedded database includes the storage location of the block data corresponding to the command identifier in the flash memory.

[0026] In this step, a query is performed on the embedded database based on the target command identifier to determine the target attribute table containing the target command identifier.

[0027] At least one attribute table is stored in the embedded database, and any attribute table includes a command identifier and a storage position of the block data corresponding to the command identifier in the flash memory. The storage position can be stored in a variety of forms. For example, the attribute table can record at least two items of the storage start position of the block data, the size of the block data (the length occupied in the flash memory), and the storage end position of the block data. Based on the embedded database, efficient management of the block data can be achieved, and the required operations can be quickly performed on the block data.

[0028] In one example, the attribute table may include a page code of the block data and a storage location of the block data. The target command identifier carried by the above data management instruction may specifically be a page code for performing management operations. The page pointed to by the page code may have a purpose and function pre-set in the communication protocol, and the actual operation to be performed on the block data may be determined by the page pointed to by the page code.

[0029] For example, the above page codes can be diagnostic page codes, which are a key part of communicating with SCSI Enclosure Services (SES) devices. A series of diagnostic page codes are predefined in the SAS protocol, which can be used for different purposes and functions in actual applications.

[0030] As an example, the structure of the attribute table may be as shown in Table 1 below: Table 1

[0031] In the solution provided by the embodiment of the present application, the minimum data unit processed by the database is defined as block data, and the attribute table may include the starting address of the block data in the Flash memory, the size of the stored block data, the page code of the stored block data, the valid flag of the attribute table, the mutex control word of the data block and other related management and control information. Optionally, the end address of the block data in the Flash can be recorded in addition to the attribute table. Based on the attribute table provided by the embodiment of the present application, the embedded real-time database function based on the Flash memory can be realized.

[0032] In practical applications, the size of the attribute table can be fixed to 16 bytes and stored in the Flash along with the block data. The attribute table and the block data associated with the attribute table can be stored in different locations in the Flash. The association between the attribute table and the block data should be as follows: Figure 1bAs shown. Among them, multiple attribute tables are stored in one area of ​​the flash memory, and block data is stored in another area of ​​the flash memory. When executing a query, the target attribute table to which the target command identifier belongs can be queried in the area where the attribute table is located, and then the specific location of the associated block data in the flash memory is determined according to the storage location recorded in the target attribute table.

[0033] Optionally, when the size of the attribute table is fixed, the solution provided by the embodiment of the present application can enable each attribute table to be stored in a fixed area in the flash memory, which can facilitate efficient query of the target attribute table to which the target command identifier belongs.

[0034] S13: Determine a target storage location of a data management operation to be performed based on the storage location of the block data in the target attribute table.

[0035] Based on the above steps, the storage location of the block data recorded in the target attribute table can be determined. This step further determines the target storage location of the data management operation to be performed based on the storage location recorded in the target attribute table.

[0036] In practical applications, the target storage location may be determined according to the type of data management operation to be performed.

[0037] For example, if the data management operation indicates to perform a read operation, the actual location to be read is the storage location of the block data, that is, the storage location recorded in the target attribute table is determined as the target storage location.

[0038] If the data management operation indicates to perform a write operation, the actual location to be written is a location where no valid block data is stored. In this step, the location to write the new data can be determined based on the storage location of the stored block data, for example, the end of the storage location recorded in the target attribute table is determined as the starting location to write the new data, and the actual occupied target storage location is determined based on the size of the new data.

[0039] S14: Execute a data management operation matching the target command identifier on the target storage location in the flash memory.

[0040] Based on the target storage location determined in the above steps, the data management operation matching the above target command identifier is executed. Through the scheme provided by the embodiment of the present application, an embedded real-time database is implemented in an embedded system with a Flash memory, the block data is organized by the attribute table of the block data, and the page code of the block data is used to retrieve the attribute table, which can efficiently implement operations such as adding, deleting, modifying, and checking the block data. The scheme provided by the embodiment of the present application does not rely on a specific operating system, consumes little hardware resources, has a simple management method, can realize rapid management of data and command response, and meets the real-time requirements of the system.

[0041] Based on the solution provided by the above embodiment, optionally, the data management instruction includes a device diagnostic instruction, the target command identifier is a diagnostic page code, and the block data includes device diagnostic data.

[0042] In practical applications, device diagnostic instructions may include the self-test command SEND DIAGNOSTIC and the diagnostic result acquisition command RECEIVE DIAGNOSTIC RESULTS. The diagnostic data generated by performing diagnostics on the device often requires that the data will not be lost when the power is off and requires a large storage space. Flash is a non-volatile memory with a large capacity, which can effectively meet the application requirements of diagnostic data storage.

[0043] The present solution is further described below with reference to an example. The solution provided in the embodiment of the present application is applied to a SAS Expander, which is connected to a SAS host through a SAS interface, and is connected to at least one SAS device through a SAS interface. The SAS host sends a data management instruction to the SAS Expander, and the SAS Expander performs operations such as device self-test and diagnostic result acquisition according to the data management instruction. The SAS Expander performs diagnosis on the connected SAS device and manages the diagnostic data through the embedded database mentioned in the present solution.

[0044] The target command identifier carried in the data management instruction issued by the above-mentioned SAS host is a diagnostic page code, and SASExpander performs corresponding operations on the device diagnostic data of the SAS device based on the corresponding operations of the diagnostic page code in the SAS protocol.

[0045] Optionally, before managing data through the embedded database, the attribute table can be initialized. In actual applications, there are 16 diagnostic command page codes defined in the SAS protocol, which can be represented as 00h to 0fh, and the manufacturer-defined page codes can be represented as 10h to 1fhe. In actual applications, other page codes can be customized to implement more practical functions without conflicting with the above-defined page codes. When the database is initialized, 32 attribute tables can be defined based on the defined page codes, and 32*16 = 512 bytes of Flash space are used to store these 32 attribute tables. Among them, the starting address of the attribute table can be a preset fixed address in the Flash. The starting address of all block data recorded in the attribute table is initialized to 0, and the block data size is initialized to 0. The page codes recorded in the 32 attribute tables are assigned values ​​in sequence from 00h to 1fh in a predefined order. In actual applications, in order to avoid multi-thread conflicts and data tampering, a block data mutex can be created in advance during the initialization process and set to an unlocked state, and the end address of the block data is initialized to the address of the storage data segment preset in the Flash. After the attribute table is initialized, the content of the attribute table is written to the flash memory.

[0046] Through the solution provided by the embodiment of the present application, the device self-check, diagnostic data acquisition and other operations can be implemented through the device diagnostic instructions carrying the diagnostic page code. Among them, the actual operation to be performed can be efficiently determined based on the diagnostic page code, and the diagnostic data can be efficiently managed through the embedded database, which is conducive to the rapid execution and response of the host command.

[0047] In the solution provided by the embodiment of the present application, the storage location of the block data corresponding to the command identifier is stored in the embedded database through the attribute table, and the specific storage location of the block data in the flash memory can be determined by querying the embedded database based on the target command identifier carried in the data management instruction. Then, the target storage location to perform the data management operation to be performed is determined to perform the data management operation matching the target command identifier. Through the solution provided by the embodiment of the present application, efficient real-time management of block data can be achieved, which is conducive to the rapid execution of instructions and response instructions.

[0048] Based on the solution provided in the above embodiment, optionally, the device diagnosis instruction includes a self-check operation command and the size of the block data to be written, and the target attribute table includes a valid flag bit.

[0049] The device diagnostic instruction includes a self-check operation command, based on which a self-check can be performed on the SAS device connected to the SASExpander, and the size of the block data to be written can be determined according to the size of the diagnostic data.

[0050] In this example, the target attribute table includes a valid flag, which can be, for example, 0 or 1, to indicate whether the block data recorded in the target attribute table is valid. The specific value of the valid flag and the corresponding meaning can be preset. For example, if the valid flag is 0, it means that the data recorded in the attribute table is invalid, and it can be deleted or overwritten with new data. If the valid flag is 1, it means that the data recorded in the attribute table is valid, and when new block data needs to be written, writing can continue from the location of the recorded data.

[0051] like Figure 2 As shown, in the above step S13, determining the target storage location of the data management operation to be performed based on the storage location of the block data in the target attribute table includes: S21: Determine the starting address of the target storage location based on the validity of the block data starting address represented by the valid flag bit.

[0052] In this example, the valid flag bit can specifically indicate whether the block data starting address in the attribute table to which it belongs is valid. Specifically, if the valid flag bit indicates that the block data starting address is valid, it means that data writing can be performed starting from the block data starting address recorded in the attribute table, and then the data stored in the attribute table is overwritten, that is, the new block data is used to overwrite the stored block data.

[0053] If the valid flag indicates that the block data starting address is invalid, that is, data writing cannot be performed starting from the block data starting address recorded in the attribute table, the storage location of the new block data to be written can be determined based on the block data position stored in the attribute table, so that the newly written block data will not overwrite the already stored block data.

[0054] S22: Determine the end address of the target storage location based on the start address of the target storage location and the size of the block data to be written.

[0055] The starting address of the target storage location indicates the starting position for writing the new block data, and the size of the block data to be written indicates the size of the storage space occupied by the block data to be written. In this step, the sum of the starting address and the size of the block data to be written can be determined as the ending address of the target storage location.

[0056] Based on the solution provided in the above embodiment, optionally, Figure 3a As shown, in the above step S21, determining the starting address of the target storage location based on the validity of the block data starting address represented by the valid flag bit includes: S31: If the valid flag bit of the target attribute table indicates that the block data start address is invalid, the end address of the block data recorded in the target attribute table is determined as the start address of the target storage location.

[0057] If the valid flag indicates that the block data start address is invalid, it means that data cannot be written from the block data start address in the attribute table, and it is necessary to continue writing from the end address of the block data recorded in the attribute table. That is, the start address of the new block data that can be written is determined based on the end address, and the start address is the start address of the target storage location.

[0058] S32: If the valid flag bit in the target attribute table indicates that the block data start address is valid, the start address of the block data recorded in the target attribute table is determined as the start address of the target storage location.

[0059] If the valid flag indicates that the block data start address is valid, it means that the new data block can be written starting from this block data start address, and then the block data start address recorded in the attribute table can be determined as the start address of the target storage location.

[0060] Through the solution provided by the embodiment of the present application, the position from which the new block data is written is determined according to the valid flag of the attribute table. The valid flag can effectively improve the management efficiency of data. For invalid written data, the new block data can be used to overwrite the old block data based on the validity indicated by the valid flag, thereby improving the data writing efficiency.

[0061] Next, this solution is further explained with an example. Figure 3b .

[0062] The SEND DIAGNOSTIC command is a command used in the SAS protocol to initiate a diagnostic test or obtain device diagnostic information. This command can be sent to a SAS Expander to perform a self-test or return diagnostic information for the device.

[0063] When SAS Expander receives the SEND DIAGNOSTIC command, it needs to write the data passed by the command into the database. Specifically, the command is parsed first, and after the page code in the command is parsed out, the page code is searched in the attribute table. If the same page code is retrieved and the valid flag of the attribute table is 0, the end address of the block data is used as the starting address of the block data, and the old end address is updated to the starting address of the block data plus the size of the block data. The block data starting address and block data size of the block data attribute table in the memory are updated accordingly, and the valid position of the attribute table is set to 1. The block data will be written to the Flash according to the obtained block data starting address. The above process can realize block data writing, and data information storage can be realized through the embedded database.

[0064] If the valid flag of the attribute table is not 0, the block data start address in the attribute table is considered valid, and new data can be written from the block data start address in the attribute table, and the old data stored in the original address will be erased.

[0065] In addition, if the stored block data needs to be deleted, the valid flag bit in the corresponding attribute table can be set to 0, and the block data in the Flash can be erased. When new block data needs to be written, based on the value of the valid flag bit in the attribute table, the starting position for writing the new block data can be determined to be the starting position of the block data in the attribute table.

[0066] Based on the solution provided in the above embodiment, optionally, Figure 4 As shown, in the above step S14, performing a data management operation matching the target command identifier on the target storage location in the flash memory includes: S41: If the target storage location of the flash memory stores at least a portion of block data that is not recorded in the target attribute table, then update the storage location of at least a portion of the block data to outside the target storage location.

[0067] In the solution provided by the embodiment of the present application, it is also necessary to determine the size relationship between the new data and the old data before executing the write. If the new data size is larger than the old data, the block data entry address of the subsequent attribute table needs to be updated. Assuming that the size of the newly written block data is S1, and the size of the old block data is S2, the entry address of the subsequent block data needs to be shifted backward by at least S1-S2 as a whole. According to the new block data entry address, the subsequent block data is read out and written to the new address to complete the data update. If the new data size is equal to or less than the old data size, the attribute table does not need to be updated, and the data can be directly written to the Flash according to the block data starting address in the attribute table. The above process is the database modification block data flow. The above steps can be used to achieve modification and overwriting of block data.

[0068] S42: Writing the block data to be written into the target storage location of the flash memory.

[0069] The solution provided by the embodiment of the present application can improve the rationality of storage space utilization. In the process of using new block data to overwrite old data blocks, this solution can ensure that the new block data can be written effectively while avoiding overwriting other valid block data that has been stored. The stored block data is moved by address offset, thereby providing sufficient storage space for the newly written block data.

[0070] Based on the solution provided in the above embodiment, optionally, Figure 5 As shown, after the above step S42, that is, after writing the block data to be written into the target storage location of the flash memory, it also includes: S51: adding a mutual exclusion lock to the block data at the target storage location of the flash memory.

[0071] In a multi-threaded system, in order to prevent block data from being rewritten by other threads, the mutex lock of the block data needs to be locked when writing the block data. The mutex lock can ensure the security of the data and prevent it from being tampered with.

[0072] Based on the solution provided in the above embodiment, optionally, the device diagnosis instruction includes a diagnosis result acquisition command.

[0073] The diagnostic result acquisition command can be expressed as RECEIVE DIAGNOSTIC RESULTS, which is a command used in the SAS protocol to request diagnostic information. It allows the application client of the host to obtain diagnostic result data from the SAS device. These data can be based on the most recent SEND DIAGNOSTIC command, or provided by the diagnostic page specified by the PAGE CODE field. When using the RECEIVE DIAGNOSTIC RESULTS command, the PCV (Page Code Valid) bit is usually set to indicate that the PAGE CODE field is valid. In this way, the SAS Expander will return data corresponding to the diagnostic page specified by the PAGE CODE. These data can be used to obtain detailed information about the status of the SAS device, such as hardware status, configuration parameters, error records, etc.

[0074] like Figure 6a As shown, in the above step S13, determining the target storage location of the data management operation to be performed based on the storage location of the block data in the target attribute table includes: S61: Determine the storage location of the block data recorded in the target attribute table as the target storage location.

[0075] Based on the diagnostic result acquisition instruction, the location of the data to be read is determined in this step. The target storage location is determined according to the information recorded in the target attribute table. Optionally, the storage location of the block data recorded in the target attribute table is determined based on the block data starting position and block data size, and then determined as the target storage location.

[0076] Wherein, in the above step S14, performing a data management operation matching the target command identifier on the target storage location in the flash memory includes: S62: Read block data from the target storage location in the flash memory and respond to the data management instruction.

[0077] In this step, block data reading is performed based on the determined target storage location, and the read block data is used to respond to the data management instruction, so that the requesting party can obtain the required block data.

[0078] See also Figure 6b When SAS Expander receives the RECEIVE DIAGNOSTIC RESULTS command to read data from the database, it searches the attribute table by page code. If the corresponding page code is found, it returns the starting address of the block data in the Flash and the size of the block data, and uses the Flash read interface to copy the data to the corresponding buffer (buffer, or buffer register).

[0079] Based on the solution provided in the above embodiment, optionally, Figure 7 As shown, before the above step S12, that is, before querying the target attribute table to which the target command identifier belongs from the embedded database, it also includes: S71: Read the attribute table in the embedded database from the flash memory and store it into the internal memory.

[0080] In this example, the attribute table in the embedded database is read from the flash memory, and the fast response advantage of the memory is utilized to improve the efficiency of information query and update.

[0081] In the above step S12, querying the target attribute table to which the target command identifier belongs from the embedded database includes: S72: Query the target attribute table to which the target command identifier belongs in the attribute table stored in the memory.

[0082] In this step, the query is performed in the memory according to the attribute table read from the flash memory. Compared with the query in the flash memory, the memory can effectively improve the efficiency of the query.

[0083] Wherein, after the above step S14, that is, after performing the data management operation matching the target command identifier on the target storage location in the flash memory, the method further includes: S73: If the block data stored in the flash memory is changed, the attribute table stored in the memory is updated.

[0084] In this example, after the block data is written, modified, deleted, etc., resulting in changes to the block data stored in the flash memory, the attribute table in the memory is updated so that the attribute table in the memory stores the latest data storage information.

[0085] S74: Update the attribute table of the embedded database in the flash memory based on the attribute table stored in the memory.

[0086] Since the flash memory is non-volatile, the latest attribute table is updated to the flash memory for preservation before the memory is powered off. Optionally, the attribute table in the memory is periodically updated with the attribute table of the embedded database in the flash memory based on a preset time. Alternatively, after receiving the power-off instruction, the attribute table in the memory is updated to the embedded database in the flash memory before the power-off is executed, and then the power-off operation is executed.

[0087] The solution provided in the embodiment of the present application can be applied in a SAS Expander system. This solution can effectively meet the management requirements of the SEND DIAGNOSTIC command and the RECEIVE DIAGNOSTIC RESULTS command for diagnostic data. When the SAS Expander receives the SEND DIAGNOSTIC command, the page code and block data size in the command will be parsed, and the block data will be written to the corresponding position in the Flash according to the indexed attribute table. When the SAS Expander receives the RECEIVE DIAGNOSTIC RESULTS command, the attribute table is indexed according to the page code in the command, and the data is read from the Flash according to the block data starting address recorded in the attribute table and returned to the requesting end.

[0088] In embedded applications that support Flash memory, this solution uses a block data attribute table to organize block data and uses the page code of the block data to index the attribute table. An embedded real-time database is designed in embedded applications with small memory capacity, which can effectively realize real-time operations such as adding, deleting, modifying, and checking block data.

[0089] In addition, this solution uses a two-level mechanism to update the attribute table, that is, first updating the attribute table in the memory and then updating the attribute table in the Flash, which further reduces the data processing time and CPU performance consumption.

[0090] Applying this solution to SAS Expander has at least the following advantages: 1. This data processing meets real-time requirements, such as being able to meet real-time management and response of diagnostic data in SAS Expander applications, and timely handle data management of commands such as SEND DIAGNOSTIC and RECEIVE DIAGNOSTIC RESULTS.

[0091] 2. Compared with other embedded databases, the present invention has low hardware resource requirements, consumes only very small CPU performance and very small memory space, and has a wide range of applications.

[0092] 3. Not dependent on embedded operating system, easy to deploy.

[0093] 4. Ability to establish and manage database on Flash storage media, with large database storage capacity.

[0094] In order to solve the problems existing in the related art, the embodiment of the present application also provides a data management device 80 based on an embedded database, such as Figure 8 As shown, including: A receiving module 81 receives a data management instruction, wherein the data management instruction carries a target command identifier; A query module 82 is configured to query a target attribute table to which the target command identifier belongs from an embedded database, wherein any attribute table in the embedded database includes a storage location of block data corresponding to the command identifier in the flash memory; A determination module 83, which determines a target storage location of a data management operation to be performed based on the storage location of the block data in the target attribute table; The execution module 84 executes a data management operation matching the target command identifier on the target storage location in the flash memory.

[0095] The device provided by the embodiment of the present application receives a data management instruction, and the data management instruction carries a target command identifier; then, the target attribute table to which the target command identifier belongs is queried from the embedded database, wherein any attribute table in the embedded database includes the storage position of the block data corresponding to the command identifier in the flash memory; then, the target storage position of the data management operation to be performed is determined based on the storage position of the block data in the target attribute table; finally, the data management operation matching the target command identifier is performed on the target storage position in the flash memory. In the scheme provided by the embodiment of the present application, the storage position of the block data corresponding to the command identifier is stored in the embedded database through the attribute table, and the specific storage position of the block data in the flash memory can be determined by querying the embedded database based on the target command identifier carried in the data management instruction. Then, the target storage position to perform the data management operation is determined to perform the data management operation matching the target command identifier. Through the scheme provided by the embodiment of the present application, efficient real-time management of block data can be achieved, which is conducive to the rapid execution of instructions and response instructions.

[0096] In order to solve the problems existing in the related art, the embodiment of the present application also provides a data management system based on an embedded database, such as Fig. 9 As shown, including: SAS expander 91, used to execute the data management method based on embedded database as described in any of the above embodiments; A SAS host 92 connected to the SAS expander 91 via a SAS interface, and configured to send data management instructions to the SAS expander 91; At least one SAS device 93 is connected to the SAS expander 91 via a SAS interface.

[0097] In the system provided in the embodiment of the present application, the SAS expander can be represented as a SAS Expander, which is respectively connected to the SAS host and at least one SAS device through a SAS interface. The SAS Expander can perform diagnostic detection on the SAS device, execute the instructions of the SAS host and respond quickly through the data management method based on the embedded database provided in the above embodiment.

[0098] Through the system provided by the embodiment of the present application, the storage location of the block data corresponding to the command identifier is stored in the embedded database through the attribute table, and the specific storage location of the block data in the flash memory can be determined through the embedded database query based on the target command identifier carried in the data management instruction. Then, the target storage location to perform the data management operation to be performed is determined to perform the data management operation matching the target command identifier. Through the solution provided by the embodiment of the present application, efficient real-time management of block data can be achieved, which is conducive to the rapid execution of instructions and response instructions.

[0099] Among them, the above modules in the device provided by the embodiment of the present application can also implement the method steps provided by the above method embodiment. Alternatively, the device provided by the embodiment of the present application can also include other modules in addition to the above modules to implement the method steps provided by the above method embodiment. And the device provided by the embodiment of the present application can achieve the technical effects that can be achieved by the above method embodiment.

[0100] Preferably, an embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned data management method embodiment based on the embedded database are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0101] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned data management method embodiment based on an embedded database is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0102] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. The computer program can be operated to enable a computer to execute part or all of the steps of the above-mentioned data management method embodiment based on an embedded database, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0103] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0104] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate a device for implementing the functions specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.

[0105] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0106] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0107] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0108] Memory may include non-permanent storage in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0109] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0110] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0111] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0112] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A data management method based on an embedded database, characterized in that: include: receiving a data management instruction, wherein the data management instruction carries a target command identifier; Querying the target attribute table to which the target command identifier belongs from the embedded database, wherein any attribute table in the embedded database includes the storage location of the block data corresponding to the command identifier in the flash memory; Determining a target storage location of a data management operation to be performed based on the storage location of the block data in the target attribute table; A data management operation matching the target command identifier is performed on a target storage location in the flash memory.

2. The method according to claim 1, characterized in that The data management instruction includes a device diagnostic instruction, the target command identifier is a diagnostic page code, and the block data includes device diagnostic data.

3. The method according to claim 2, characterized in that The device diagnostic instruction includes a self-check operation command and the size of the block data to be written, and the target attribute table includes a valid flag bit; Wherein, determining the target storage location of the data management operation to be performed based on the storage location of the block data in the target attribute table includes: Determining the starting address of the target storage location based on the validity of the block data starting address represented by the valid flag bit; The end address of the target storage location is determined based on the start address of the target storage location and the size of the block data to be written.

4. The method according to claim 3, characterized in that Determining the starting address of the target storage location based on the validity of the block data starting address represented by the valid flag bit includes: If the valid flag bit of the target attribute table indicates that the block data start address is invalid, determining the end address of the block data recorded in the target attribute table as the start address of the target storage location; If the valid flag bit of the target attribute table indicates that the block data start address is valid, the start address of the block data recorded in the target attribute table is determined as the start address of the target storage location.

5. The method according to claim 4, characterized in that Performing a data management operation matching the target command identifier on a target storage location in the flash memory includes: If the target storage location of the flash memory stores at least part of the block data that is not recorded in the target attribute table, updating the storage location of the at least part of the block data to outside the target storage location; The block data to be written is written to the target storage location of the flash memory.

6. The method according to claim 5, characterized in that After writing the block data to be written into the target storage location of the flash memory, the method further includes: A mutual exclusion lock is added to the block data at the target storage location of the flash memory.

7. The method according to claim 2, characterized in that The device diagnosis instruction includes a diagnosis result acquisition command; Wherein, determining the target storage location of the data management operation to be performed based on the storage location of the block data in the target attribute table includes: Determine the storage location of the block data recorded in the target attribute table as the target storage location; The step of performing a data management operation matching the target command identifier on the target storage location in the flash memory includes: The block data is read from the target storage location in the flash memory and responds to the data management instruction.

8. The method according to any one of claims 1 to 7, characterized in that Before querying the target attribute table to which the target command identifier belongs from the embedded database, the method further includes: Reading the attribute table in the embedded database from the flash memory and storing it in the internal memory; The step of querying the target attribute table to which the target command identifier belongs from the embedded database includes: Querying the target attribute table to which the target command identifier belongs in the attribute table stored in the memory; Wherein, after performing the data management operation matching the target command identifier on the target storage location in the flash memory, the method further includes: If the block data stored in the flash memory is changed, updating the attribute table stored in the memory; The attribute table of the embedded database in the flash memory is updated based on the attribute table stored in the memory.

9. A data management device based on an embedded database, characterized in that: include: A receiving module receives a data management instruction, wherein the data management instruction carries a target command identifier; A query module, which queries the target attribute table to which the target command identifier belongs from the embedded database, wherein any attribute table in the embedded database includes the storage location of the block data corresponding to the command identifier in the flash memory; A determination module, which determines a target storage location of a data management operation to be performed based on a storage location of the block data in the target attribute table; An execution module executes a data management operation matching the target command identifier on a target storage location in the flash memory.

10. A data management system based on an embedded database, characterized in that: include: A SAS expander, used to execute the data management method based on an embedded database as described in any one of claims 1 to 8; A SAS host connected to the SAS expander via a SAS interface, and configured to send a data management instruction to the SAS expander; At least one SAS device is connected to the SAS expander via a SAS interface.

11. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 8 when executed by the processor.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

13. A computer program product, characterized in that The computer program product comprises a non-transitory computer-readable storage medium storing a computer program, the computer program being operable to cause a computer to perform the steps of the method according to any one of claims 1 to 8.