Abstract:
Techniques for storing and reading data on/from a hard disk are disclosed. According to one aspect of the present invention, a hard disk is provided with a parameter storage block for storing a number of parameters. One of the parameters is a last physical address the hard disk was accessed. The last physical address is used as a reference to read data segments onto the hard disk. Each of the data segments is a compressed version of a portion of data to be stored in the hard disk. A portion of the data is allocated in accordance with a predefined time period. Accordingly, the compressed data portion also includes a header including information about the compressed data portion. The information includes at least a compression scheme used as well as the time about the data portion. Based on how the data is stored, a corresponding reading method is also provided.

Description:
BACKGROUND OF THE INVENTION  
       [0001]     1. Field of the Invention  
         [0002]     The present invention relates to the area of data storage and data reading, and more particularly to method and apparatus for storing and reading data on/from a hard disk.  
         [0003]     2. Description of Related Art  
         [0004]     Currently, the popular file systems are FAT12, FAT16, FAT32, NTFS, EXT2, EXT3, etc. These file systems are all composed of a file directory indexed list and a cluster list. A file in these file system may occupy a lot of discontinuous clusters. When the hard disk is required to be read and written, a magnetic head provided in a hard disk will jump and reposition according to the discontinuous clusters of the file. As shown in  FIG. 1 , it is a flow diagram for reading a file in a hard disk that adapts the conventional file system. It includes operations as follows: obtaining a file directory indexed list; reading out a first cluster assigned to an objected file from the file directory indexed list; reading out a content from the cluster assigned to the file; determining if the file is completely read out; if so, ending the operation; if not, obtaining a next cluster assigned to the file and repeating the corresponding operations mentioned above. Due to discontinuous clusters of the file, the magnetic head provided on the hard disk will frequently jump and reposition to a cluster a few clusters away. This jumping and reposition process is the major reason for the hard disk depreciation. For writing disk fragmentation and making the hard disk involve in more repositioning operations.  
         [0005]     In some applications which require to process a large amount of data, such as monitoring industry which needs to store the video data on the hard disk every day, so a large quantity of writing operations are needed on the hard disk. In this special application, if adopting conventional file system to manage and store the data on the hard disk, the service life of the hard disk may be significantly affected and the cost for the operation increases.  
         [0006]     Thus there is a need for techniques for storing and reading data on/from hard disk with minimum affect on the service life thereof.  
       SUMMARY OF THE INVENTION  
       [0007]     This section is for the purpose of summarizing some aspects of the present invention and to briefly introduce some preferred embodiments. Simplifications or omissions in this section as well as in the abstract or the title of this description may be made to avoid obscuring the purpose of this section, the abstract and the title. Such simplifications or omissions are not intended to limit the scope of the present invention.  
         [0008]     Techniques for storing and reading data on/from a hard disk are disclosed. According to one aspect of the present invention, a hard disk is provided with a parameter storage block for storing a number of parameters. One of the parameters is a last physical address the hard disk was accessed. The last physical address is used as a reference to read data segments onto the hard disk. Each of the data segments is a compressed version of a portion of data to be stored in the hard disk. A portion of the data is allocated in accordance with a predefined time period. Accordingly, the compressed data portion also includes a header including information about the compressed data portion. The information includes at least a compression scheme used as well as the time about the data portion. Based on how the data is stored, a corresponding reading method is also provided.  
         [0009]     The present invention may be implemented in hardware and software as a system, an apparatus or a method. According to one embodiment, the present invention is a data storage method for a hard disk, the hard disk provided with a parameter storage block for storing a last physical address accessed, the method comprises reading the last physical address; positioning a magnetic header of the hard disk at a next physical address adjacent to the last physical address; and writing data into continuous storage spaces on the hard disk according to a magnetic track sequence.  
         [0010]     According to another embodiment, the present invention is a method for reading data in a hard disk, the method comprises calculating a minimum offset address of a data package in the hard disk according to a compression scheme, wherein the data package includes a portion or all of the data; reading an identifier of the data package according to the minimum offset address; and determining if the identifier of the data package corresponding to an identification of the data. If the determining operation is not confirmed, reading an identification of a next data package according to a sequence, and continuing the determining operation is confirmed; and if the determining operation is confirmed, reading the data package.  
         [0011]     According to yet another embodiment, the present invention is a data storage method for a hard disk, the hard disk provided with a parameter storage block for storing a last physical address accessed, the method comprises allocating a storage block for storing a plurality of status parameters; segmenting data into a plurality of segments, each corresponding to a predefined time period; compressing each of the segments into a data package, wherein the data package includes a header having a compression time and compression information of how the data package is compressed; reading a first physical address according to the status parameters; storing the compressed segments into continuous storage spaces with reference to the first physical address till all compressed segments are stored; and resetting the first physical address to a second physical address.  
         [0012]     One of the objects, features, and advantages of the present invention is to provide an efficient accessing mechanism of a hard disk.  
         [0013]     Other objects, features, and advantages of the present invention will become apparent upon examining the following detailed description of an embodiment thereof, taken in conjunction with the attached drawings. 
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0014]     These and other features, aspects, and advantages of the present invention will become better understood with regard to the following description, appended claims, and accompanying drawings where:  
         [0015]      FIG. 1  is a flowchart for reading a file in a hard disk according to a conventional file system;  
         [0016]      FIG. 2  is a diagram showing a data storage architecture for a hard disk according to one embodiment of the present invention.  
         [0017]      FIG. 3  is a process or flow diagram of an exemplary data storage method according to one embodiment of the present invention;  
         [0018]      FIG. 4  is a first process or flow diagram of a data reading method in the present invention;  
         [0019]      FIG. 5  is a second process or flow diagram of the data reading method in the present invention; and  
         [0020]      FIG. 6  is a third process or flow diagram of the data reading method in the present invention. 
     
    
     DETAILED DESCRIPTION OF THE INVENTION  
       [0021]     The detailed description of the present invention is presented largely in terms of procedures, steps, logic blocks, processing, or other symbolic representations that directly or indirectly resemble the operations of devices or systems contemplated in the present invention. These descriptions and representations are typically used by those skilled in the art to most effectively convey the substance of their work to others skilled in the art.  
         [0022]     Reference herein to “one embodiment” or “an embodiment” means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the invention. The appearances of the phrase “in one embodiment” in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Further, the order of blocks in process flowcharts or diagrams or the use of sequence numbers representing one or more embodiments of the invention do not inherently indicate any particular order nor imply any limitations in the invention.  
         [0023]     According to one embodiment of the present invention, a hard disk is provided with a storage block for storing a plurality of status parameters thereof. The status parameters comprise use identification information which identifies if the hard disk is in use or not, and a last physical address that was accessed. In one embodiment, the status parameters are stored as a block at 0-th address of the hard disk. When a hard disk is used for the first time, namely it is a new hard disk, the identification information of the status parameters and the last physical address shall be set at 0. When all data are completely deleted from the hard disk, the identification information of the status parameter and the last physical address shall be refreshed to 0 as well, thus demonstrating that no data is stored in the hard disk.  
         [0024]     According to one embodiment, a data storage method comprises the following operations: reading a last physical address of the disk that was accessed, positioning a magnetic header provided in the hard disk at a next physical address adjacent to the last physical address; writing data into a continuous storage space on the hard disk according to a magnetic track sequence. When receiving a stopping order about data storage on the hard disk, the current physical address being accessed will be updated as the last store physical address in the status parameters.  
         [0025]     In order to conveniently search the stored data and make full use of the hard disk resources, before storing the data into the hard disk, the data shall be compressed into a data package according a predefined time length (e.g., one minute), and a corresponding data package header containing a compression time and compression information of the corresponding data package shall be generated and added in the front of the corresponding data package. The data package header and its corresponding data package will be stored into the hard disk according to the magnetic track sequence.  
         [0026]     As shown in  FIG. 2 , provided that a set of image data needed to be stored into a hard disk. It is assumed that each image frame is about 40 KB in size, and 20 frames can be compressed within one second, the one-minute image data needed to be stored into the hard disk is 48M in size. The image data in one minute shall be compressed into a data package, and a data package header shall be added in the front of corresponding data package. This data package header records the compression time and compressibility information of this data package as well as other information defined by the user.  
         [0027]     In order to conveniently search the stored data at any time, the hard disk is partitioned into a number of storage areas. For example, the hard disk can be partitioned into several storage areas, each volume thereof is 4 G in size. If the above example of compressing one minute image data into a data package continues, for the purpose of aligning each data package header with corresponding data package in each storage area, before storing a new one-minute image data package, the following operations shown in the  FIG. 3  shall be conducted.  
         [0028]     At S 1 , calculating a required storage space for storing the one-minute image data according to a compression scheme. Referring to the above-mentioned example, the one minute image data is 48M in size; At S 2 , determining if a remaining storage space of the current partition in the hard disk is (1+a) times larger than the required storage space, where “a” represents a ratio of an exceeding part of the maximum file generated under the compression scheme (assuming all are compressed per the compression scheme) against a target size, generally it is a number that is less than one. If the determining is confirmed, the operations is taken to S 3 , if not, the S 4  is carried out.  
         [0029]     At S 3 , writing the one-minute data package and the data package header into the current partition in the hard disk according to the magnetic track sequence. At S 4 , positioning the hard disk magnetic header at a first address in a next immediate partition, and writing the one-minute data package and the corresponding data package header.  
         [0030]     According to another embodiment, a corresponding data read method is provided in the present invention. Supposing that a user wants to search the image data that has been written into the hard disk at a certain time (e.g., data starting at 5 minutes from the beginning), if the hard disk is not partitioned,  FIG. 4  shows a flowchart or process according to the embodiment. At  11 , according to the compression that is used to compress the data, calculating a minimum offset address of the data package at a designated time in relation to the first data package of the hard disk and reading the data package and the corresponding header at this offset address. At  12 , determining if the compression time in the data package header is the same as the designated time or within a time range between the recorded compression times of this and next data package headers, if so, the process goes to  14 , if not, the process go to  13 .  
         [0031]     At  13 , reading the next data package and corresponding header according to sequence and returning to  12 . At  14 , reading the data from this data package until the user sends the command to stop the reading operation.  
         [0032]     On the other hand, if the hard disk is partitioned, when a user needs to read the data stored at a designated time, at first, the system needs to locate the storage partition where the image data at the designated time is stored.  FIG. 5  shows a flowchart or process according to one embodiment of the present invention.  
         [0033]     At  21 , according to the compression in the data storage method and a start time of the hard disk data storage, calculating an approximate storage partition (n) where the objected data is stored. At  22 , reading the first data package header of the approximate storage partition (n) and determining if the recorded compression time in the first data package header is less than the designated time. If so, the process goes to  23 ; if not, the process goes to  25 .  
         [0034]     At  23 , reading a first data package header in the next storage partition (n+1) and determining if the recorded compression time in the first data package header is more than the designated time. If so, the process goes to  27 ; if not, the process goes to  24 . At  24 : increasing n by one, the process then goes to  23 . At  25 , reading a first data package header and determining if the recorded compression time in the data package header is less than the designated time. If so, the process goes to  28 ; if not, the process goes to  26 ;  
         [0035]     At  26 , decreasing n by one and switching to  25 . At  27 , determining the storage partition storing the image data of the desingaed time is the storage partition No. n. At  28 , determining the storage partition storing the data of the desingaed time is the storage partition No. n-1.  
         [0036]     After the storage partition storing the image data of the designated time is determined, the exact storage address location in this storage partition storing the data of the designaed tiem shall be further determined.  FIG. 6  shows a flowchart or process according to one embodiment of the present invention.  
         [0037]     At  31 , according to the compression in the data storage method, calculating a minimum offset address of the data package at the designated time in relation to the first data package of the current storage partition and reading the data package and the corresponding head at this offset address. At  32 , if the compression time in the data package head is same as the designated time or within a time range between the recorded compression times of this and next data package headers. If so, the process goes to  34 ; if not, the process goes to  33 .  
         [0038]     At  33 , reading the next data package and the corresponding header according to the sequence and returning to  32 . At  34 , reading the data from this data package until the user sends the command to stop the reading process.  
         [0039]     The present invention has been described in sufficient details with a certain degree of particularity. It is understood to those skilled in the art that the present disclosure of embodiments has been made by way of examples only and that numerous changes in the arrangement and combination of parts may be resorted without departing from the spirit and scope of the invention as claimed. Accordingly, the scope of the present invention is defined by the appended claims rather than the foregoing description of embodiments.