This invention relates generally to file systems.
A flash file system is a file system stored on a flash memory. Flash file systems manage downloaded code objects such as Java applets and games. Flash file systems store code objects contiguously in a specific volume. In such case, there is no free or dirty space between valid objects. Herein free or dirty space will be referred to as a hole. Thus, the flash file system assures that all available space of the flash memory is merged into one chunk. Then, the largest possible new object can be written into the available flash memory space.
One problem that arises is that after deleting one object, a hole would be generated between valid objects. All objects after the hole are moved up to coalesce with the last valid object. This moving up may be called a reclamation. The reclamation results are achieved by rewriting the data to the new memory location. Thus, a specific volume may need to be rewritten in total.
This rewriting by a reclamation may happen multiple times to reclaim all of the space after the deleted object. For example, if the first object in the volume needs to be reclaimed, everything in the volume must be rewritten. Not only is this not efficient, but the time needed to do such movement of data may adversely affect the performance of the device. For example, the ability of the device including the flash file system to operate in a seamless fashion may be adversely affected. The user may realize that the system is unable to proceed during such reclamation.
Thus, there is a need for better ways to deal with holes in file systems.
Referring to
A flash memory 518 may also be coupled to the bus 512. The flash memory 518 may include a flash file system 40 and hole management software 30 for managing holes on the file system 40.
The system 500 may be any of a variety of processor-based systems including a personal digital assistant, a cellular telephone, a camera, a camcorder, a game console, a media center, a media player, a laptop computer, and a tablet, to mention a few examples. It may also be a non-mobile computer in some embodiments of the present invention.
In accordance with some embodiments of the present invention, multiple holes may exist between valid code objects in a specific volume. After one object in the volume is deleted, the hole may be left at the original location of the deleted object without being immediately reclaimed. When writing a new object, the volume is scanned to find an appropriate free chunk of memory space within the volume of sufficient size to accommodate the new object. Generally, the suitable free chunk is the first available space with the closest size to that actually needed to store the new object.
If there is no such hole suitably sized to receive the new object, then a defragmentation is performed. The defragmentation coalesces the existing valid objects, reclaims the holes, and merges the available space until an available space of the desired size to accommodate the new object is created.
In many situations, this approach may involve fewer space reclaims than the conventional hole management methods. In this way, multiple holes may be reclaimed at one time and multiple free chunks may be merged during one defragmentation. As a result, in some embodiments, significant improvement in object deletion performance and space defragmentation performance may be achieved.
The hole management software 30 may be stored on the flash memory 518 with the flash file system 40 in one embodiment. As shown in
As indicated on the left in
Then, referring to
Normally, each valid code object 14 has one object header 18 that stores all characteristics of the object, including, for example, the object name, type, size, identifier, and the like. To help manage multiple holes between valid objects (even though there is no actual data for the hole) an object header is still associated with each hole, indicating the hole's size and attributes (free or dirty). As a result, holes, such as hole 20a, are treated and manipulated as a normal object. Thus, normal object operations can be applied to holes and, as a result, holes may be more easily managed in some embodiments. Thus, in the case of
Then, referring to
Then, as shown in
It should be noted that the defragmentation of the dirty chunks 20a and 20b can happen all at one time. Of course, while an illustration is given wherein two dirty chunks or holes 20 are reclaimed at the same time, more or less holes may be reclaimed as needed to achieve an appropriate available space to write the new object.
In the course of defragmentation, holes are reclaimed and coalesced at one time. In some embodiments, this enables more flexible manipulation of any given object. By rewriting and reorganizing the headers, it is easy to write a new object into a hole, to reclaim one dirty chunk to a free chunk, to truncate an object's size, and to expand an object's size.
Then, as shown in
Referring to
To create an object, a check at diamond 36 determines that a new object must be stored. If so, a check determines whether there is an available memory space for the object. If so, the object is simply stored in that available space. If not, a check at diamond 38 determines whether the new object will fit in the space of a hole or so-called invalid object. If so, the invalid object space may be reclaimed as indicated in block 40. This reclamation may reclaim that number of holes which are needed to receive the new object. Then, the new object is written to the space as indicated in block 42. At the same time, the headers for the reclaimed space may be coalesced to create a new header.
If the object will not fit into the space of one single invalid object as determined at diamond 38, all of the blocks after any deleted object or objects may be reclaimed as indicated in block 44. The objects after the deleted object or objects may be moved up, as indicated in block 46, and all of the moved objects may be reallocated as indicated in block 48. Finally, the new objects may be written at the end as indicated in block 50.
While the present invention has been described with respect to a limited number of embodiments, those skilled in the art will appreciate numerous modifications and variations therefrom. It is intended that the appended claims cover all such modifications and variations as fall within the true spirit and scope of this present invention.