Non-volatile memory products for electronic equipments, such as cell phones, digital cameras, computers, etc., are widely used today. When writing a file to the non-volatile memory, data fragments, sequence tables and their associated headers may be written to the non-volatile memory one by one. Here, the data fragments store user data of the file and the sequence tables may comprises sequence table entries to store memory locations of the data fragments. A sequence table entry may comprise a data field for a memory location, and, an entry allocating field and entry valid field to protect the sequence table entry in case of power loss.
The invention described herein is illustrated by way of example and not by way of limitation in the accompanying figures. For simplicity and clarity of illustration, elements illustrated in the figures are not necessarily drawn to scale. For example, the dimensions of some elements may be exaggerated relative to other elements for clarity. Further, where considered appropriate, reference labels have been repeated among the figures to indicate corresponding or analogous elements.
a illustrates a transaction indicator in the file system of
b illustrates a sequence table entry in the file system of
c illustrates a sequence table header in the file system of
d illustrate a data fragment header in the file system of
The following description describes techniques for memory writing method and system. In the following description, numerous specific details such as logic implementations, pseudo-code, means to specify operands, resource partitioning/sharing/duplication implementations, types and interrelationships of system components, and logic partitioning/integration choices are set forth in order to provide a more thorough understanding of the present invention. However, the invention may be practiced without such specific details. In other instances, control structures, gate level circuits and full software instruction sequences have not been shown in detail in order not to obscure the invention. Those of ordinary skill in the art, with the included descriptions, will be able to implement appropriate functionality without undue experimentation.
References in the specification to “one embodiment”, “an embodiment”, “an example embodiment”, etc., indicate that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may not necessarily include the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same embodiment. Further, when a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to effect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described.
Embodiments of the invention may be implemented in hardware, firmware, software, or any combination thereof. Embodiments of the invention may also be implemented as instructions stored on a machine-readable medium, which may be read and executed by one or more processors. A machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computing device). For example, a machine-readable medium may include read only memory (ROM); random access memory (RAM); magnetic disk storage media; optical storage media; flash memory devices; and others.
The processor 101, the non-volatile memory 102 and the volatile memory 103 may be coupled by buses 104-105. In some embodiments, the processor 101, the non-volatile memory 102 and the volatile memory 103 may be included on an integrated circuit board, and the buses 104-105 may be implemented using traces on the circuit board.
According to various embodiments, the processor 101 may perform operations to non-volatile memory 102 and volatile memory 103. In one embodiment, the processor 101 may control writing a partial file or a whole file to the non-volatile memory 102. The file may comprise a plurality of data fragments, at least one sequence table including a plurality of sequence table entries to identify memory locations of the data fragments, and other associated information. Before being written to the non-volatile memory 102, the sequence table entries may be temporarily stored to the volatile memory 103 and then may be transferred from the volatile memory 103 to the non-volatile memory 102 under the control of the processor 101.
Referring now to
According to various embodiments, the file system 200 maintained in the non-volatile memory may hold files written to the non-volatile memory and any associated information about the files. The file system 200 may include a file information structure 210 and a number of storage blocks 220, 250, 260 and 280, etc. For NOR flash memory manufactured by Intel Corporate, Santa Clara, Calif., a storage block may comprise 64 k or 128 k bytes. For NAND flash memory manufactured by SAMSUNG, Korea, a block may comprise 16 k or 32 k bytes. As shown in
Moreover, each sequence table may have a sequence table header (STH) associated therewith, and each data fragment may have a data fragment header (DFH) associated therewith. For example, as shown in
It shall be appreciated that a file in the file system 200 may include any number of storage blocks to hold any number of data fragments and sequence tables. A sequence table may include any number of sequence table entries to point to the data fragments, as long as within its size limitation. The file may further include any other kinds of data structures than those shown in
Detailed structure of the transaction indicator (TI) 215 is shown in
In an embodiment, the transaction begin field and transaction end field of the transaction indicator (TI) 215 may each include 1 bit. In another embodiment, the transaction begin field may have 2 bits while the transaction end field may have 1 bit. Other embodiments may utilize transaction indicators (TI) 215 having a different structure and/or a different number of bits.
The transaction indicator may support a power loss recovery feature to keep data consistency of the file to be written in the non-volatile memory 102. Particularly, when power loss happens after the transaction for writing the file is started, but before the transaction ends, parts of the file which have been written to the non-volatile memory may be deleted automatically by the power loss recovery feature.
Referring now to
Each sequence table has a sequence table header (STH) associated therewith. Detailed data structure of the sequence table header 221′ is shown in
Each data fragment may have a data fragment header (DFH) associated therewith. Detailed data structure of the data fragment header 261′ is shown in
It shall be appreciated that the sequence table header and/or data fragment header may further include other data structures, such as a header invalid field (hdr_invalid field) to represent ‘header invalid’ state. The sequence table header and data fragment header may support a power loss recovery feature for their associated sequence table and data fragment in the non-volatile memory 102. Namely, if power loss happens before validation of a header, its associated sequence table or data fragment may be deleted automatically.
Now referring to
In block 501, the processor 101 may start a transaction for writing a file by changing state of the transaction indicator (TI) 215 in the non-volatile memory 102 to a transaction begin state. For implementation, in an embodiment where the transaction indicator 215 includes a transaction begin field having 2 bits to identify the transaction begin state, the processor 101 may write to the transaction begin field, thereby changing the 2 state bits in the transaction begin field from “11” to “00” to indicate begin of the transaction for writing the file. This change from “11” to “00” may be accomplished using bit twiddling write mode which is a special word programming write mode supported by some non-volatile memory devices. Namely, only two bits of a word are programmed in the bit twiddling mode. However, other embodiments may utilize a different data structure of the transaction indicator and/or a different write mode.
In block 502, the processor 101 may control changing state of a data fragment header (e.g., DFH 261′ in
In block 503, the processor 101 may control writing to the non-volatile memory 102 a data fragment associated with the data fragment header in block 502. For example, as shown in
In block 504, the processor 101 may control writing a sequence table entry to the volatile memory 103. The sequence table entry may comprise a data entry field to identify the memory location of the corresponding data fragment written in block 503. For example, the sequence table entry (STE) 2211 as shown in
In block 505, the processor 101 may determine whether all of the data fragments which carry user data of the file are written to the non-volatile memory. Namely, the processor 101 may determine whether writing the user data of the file to the non-volatile memory is completed. If not, the processor 101 may continue to block 506 where the processor 101 may determine whether the sequence table temporarily stored in the volatile memory 103 (e.g., sequence table 221 in
If the sequence table stored in the volatile memory 103 is determined to be full in block 506, the processor 101 may continue to block 507 to allocate another sequence table header. Namely, the processor 101 in block 507 may change state of a sequence table header to ‘sequence table header allocating’ state in the non-volatile memory 102, indicating that a fragment of a block in the non-volatile memory is allocated to hold a sequence table which may be written to the non-volatile memory. For example, the sequence table 221 temporarily stored in the volatile memory 103 (STH) 221′ in
Then, in block 508, the processor 101 may control writing of the sequence table temporarily stored in the volatile memory 103 to the non-volatile memory 102. For example, the sequence table (ST) 221 in
Then, the processor 101 may return to block 502 to continue writing other parts of the file corresponding to other sequence tables such as, for example, the sequence tables (ST) 252 and 253 as shown in
If, in block 505, the processor 101 determines that writing the user data of the file to the non-volatile memory is completed, the processor may continue to block 509. Namely, the processor 101 may control changing state of a sequence table header in the non-volatile memory 102 to a sequence table header allocating state, which indicates a fragment of a block in the non-volatile memory is allocated to hold a sequence table which may be written to the non-volatile memory. In an embodiment that that may utilize more than one sequence table for the file, the fragment allocated in block 509 may be used to hold the last sequence table of the file. For example, a file may comprise three sequence tables (ST) 221, 252 and 253 as shown in
Then, in block 510, the processor 101 may control writing of the sequence table temporarily stored in the volatile memory 103 to the non-volatile memory 102. In an embodiment, the last sequence table 253 which is temporarily stored in the volatile memory 103 may be written to the non-volatile memory 102 in block 510.
Then, in block 511, the processor 101 may control changing the state of the transaction indicator 215 to a transaction end state. For implementation, in an embodiment where the transaction indicator 215 includes a transaction end field having 2 bits to identify the transaction end state as shown in
This ending of the transaction may be implemented by an embodiment via a bit twiddling write mode. However, other embodiments may utilize a transaction indicator with a different structure, a different number of bits, and/or a different write mode.
Then, in block 512, the processor 101 may change the state of data fragment headers associated with the data fragments of the file which have been written to the non-volatile memory from header allocating state to a header valid state. Completion of block 512 indicates that the fragments of the blocks, which have been allocated in block 502 to hold the data fragments of the file, are validated. This validation may be implemented by an embodiment by writing header valid fields of the data fragment headers associated with the data fragments, which have been written to the non-volatile memory, in bit twiddling write mode.
Then, in block 513, the processor 101 may control changing state of the sequence table header(s) associated with the sequence table(s) of the file from the sequence table header allocating state to the sequence table header valid state. In an embodiment that the file has only one sequence table, its associated sequence table header is validated in block 513. In another embodiment that the file has more than one sequence tables, their associated sequence table headers are validated in block 513. Completion of block 513 indicates that the fragment(s) of storage block(s), which had been allocated in blocks 507 and/or 509 to hold the sequence table(s) of the file, is validated. This validation may be implemented in one embodiment by writing sequence table header valid field(s) of the sequence table header(s) associated with the sequence table(s) in bit twiddling write mode.
It can be seen from the flow chart of
If the power loss occurs when the transaction of writing the file ends, which corresponding to the state of the transaction indicator is changed to the transaction end state, the data fragments and sequence table(s) of the file may be maintained in the non-volatile memory 102 by validating their associated headers. By this way, data consistency for the whole file may be maintained.
However, other embodiments may utilize modifications and variations of the above described power loss recovery feature. For instance, when data consistency is desired on sequence table level but not on file level, the transaction indicator may be omitted. In such case, after each part of a file corresponding to each sequence table is written to the non-volatile memory, including writing data fragments of that part to the non-volatile memory and writing the corresponding sequence table from the volatile memory to the non-volatile memory, each of the associated sequence table header and data fragment headers may be validated.
Pseudo code of power loss recovery initialization in the non-volatile memory according to an embodiment may be:
It shall be well understood by a skilled person in the art that the above-described method may be applied to write a part of a file to the non-volatile memory, but not whole of the file. Then, other parts of the file may be written by using other memory writing methods. In such case, the transaction indicator may indicate begin and end states of a transaction for writing a part of a file to the non-volatile memory. Then, a sequence table of the part of the file may be transferred from the volatile memory to the non-volatile memory if the sequence table is full or all of data fragments of that part of the file have been written to the non-volatile memory.
It can be seen from
Although the present invention has been described in conjunction with certain embodiments, it shall be understood that modifications and variations may be resorted to without departing from the spirit and scope of the invention as those skilled in the art readily understand. Such modifications and variations are considered to be within the scope of the invention and the appended claims.
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/CN2005/000852 | 6/15/2005 | WO | 00 | 9/6/2006 |