CN109669623B - File management method, file management device, electronic equipment and storage medium - Google Patents
File management method, file management device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN109669623B CN109669623B CN201710951379.8A CN201710951379A CN109669623B CN 109669623 B CN109669623 B CN 109669623B CN 201710951379 A CN201710951379 A CN 201710951379A CN 109669623 B CN109669623 B CN 109669623B
- Authority
- CN
- China
- Prior art keywords
- file
- block
- information
- ssd
- written
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
- G06F3/0611—Improving I/O performance in relation to response time
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0629—Configuration or reconfiguration of storage systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention provides a file management method, a file management device, electronic equipment and a storage medium, wherein the method comprises the following steps: obtaining a file to be written in the SSD; generating an identifier of a file to be written, and determining a block for storing the file to be written as a first block through an SSD file system; and storing the file to be written into the block data area of the first block, acquiring file storage information of the file to be written, and storing the acquired file storage information into the block index area of the first block. When the scheme provided by the embodiment of the invention is applied to storing the file, the file to be written does not need to be written based on the storage path, so that the writing speed of the file to be written is improved.
Description
Technical Field
The present invention relates to the field of data storage technologies, and in particular, to a file management method, a file management apparatus, an electronic device, and a storage medium.
Background
A Solid State Drive (SSD) is a storage device for storing data, and compared with a conventional hard disk, the SSD has characteristics of fast read/write speed, low power consumption, high reliability, and the like, and is gradually used by more and more electronic devices. When the SSD is mounted on the electronic device, the file management system of the operating system of the electronic device usually manages the SSD, for example, the file management system of the windows operating system or linux operating system of the electronic device manages the SSD.
In the process of file management on an SSD, for example, writing a file in the SSD, a file management system of an existing operating system needs to determine a storage path of the file to be written in the SSD, and then write the file to be written in the determined storage path. The storage path is the storage location information of the file determined by the file management system of the existing operating system.
Although the file management system of the operating system itself can perform file management on the SSD mounted on the electronic device by using the file management method based on the storage path, when the file management method is applied to a scene requiring frequent file operations, for example, a scene requiring real-time writing operations of a large number of files, such as massive picture recognition, the file management system of the operating system itself needs to determine the storage paths of a plurality of files at the same time, and then performs the writing operations on the files based on the determined storage paths, which often takes a long time and causes a decrease in the writing speed of the files.
Disclosure of Invention
Embodiments of the present invention provide a file management method, a file management apparatus, an electronic device, and a storage medium, so as to achieve the purpose of increasing the writing speed of a file in an SSD. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a file management method, which is applied to an electronic device, where the electronic device is mounted with a solid state disk SSD, and the SSD has an SSD file system, and the SSD file system includes: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of a block for recording file storage information of a file stored in the block data area of the block, and a block data area, the file management method comprising:
obtaining a file to be written in the SSD;
generating an identifier of the file to be written, and determining a block for storing the file to be written as a first block through the SSD file system;
and storing the file to be written into the block data area of the first block, acquiring file storage information of the file to be written, and storing the acquired file storage information into the block index area of the first block.
Optionally, the file management method further includes:
and generating file storage position information of the file to be written according to the file storage information of the file to be written, the block information of the first block and SSD information of the SSD to which the first block belongs.
Optionally, the data area information includes: the usage status of each block;
after the storing the file to be written to the block data area of the first block, the file management method further includes:
judging whether the current use state of the first block is a full write state;
if so, updating the use state of the first block recorded in the data area information to a full write state;
if not, updating the use state of the first block recorded in the data area information to a written state when the pre-writing state is an unwritten state, wherein the pre-writing state is: and storing the file to be written to the use state of the first block before the file to be written is stored in the block data area of the first block.
Optionally, the system index area includes: a system main index area and a system standby index area;
the system main index area is used for storing SSD information and data area information;
and the system standby index area is used for storing the backup information of the system main index area.
Optionally, the block index area of one block includes: a block main index area of the block and a block standby index area of the block;
a block main index area of a block for recording file storage information of a file stored in the block data area of the block;
and the block spare index area of one block is used for storing backup information of the block main index area of the block.
Optionally, the file management method further includes:
obtaining file storage position information of a file to be read from an SSD;
positioning a block used for storing the file to be read in the SSD according to the SSD information and the block information recorded in the obtained file storage position information;
and reading the file to be read from the positioned block according to the file storage information recorded in the obtained file storage position information.
Optionally, when more than one block is located, the reading the file to be read from the located block according to the file storage information recorded in the obtained file storage location information includes:
according to file storage information recorded in the obtained file storage position information, reading data belonging to the file to be read from each positioned block respectively;
and merging the read data to obtain the file to be read.
In a second aspect, an embodiment of the present invention provides a file management apparatus, which is applied to an electronic device, where the electronic device is mounted with a solid state disk SSD, and the SSD has an SSD file system, and the SSD file system includes: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of one block for recording file storage information of a file stored in the block data area of the block, and a block data area, the file management apparatus comprising:
the acquisition module is used for acquiring a file to be written in the SSD;
the determining module is used for generating an identifier of the file to be written, and determining a block for storing the file to be written as a first block through the SSD file system;
and the storage module is used for storing the file to be written into the block data area of the first block, acquiring file storage information of the file to be written and storing the acquired file storage information into the block index area of the first block.
Optionally, the file management apparatus further includes:
and the generating module is used for generating the file storage position information of the file to be written according to the file storage information of the file to be written, the block information of the first block and the SSD information of the SSD to which the first block belongs.
Optionally, the data area information includes: the usage status of each block;
the file management apparatus further includes:
the judging module is used for judging whether the current use state of the first block is a full-written state;
the judging module comprises:
the first updating submodule is used for updating the use state of the first block recorded in the data area information into a full-written state when the judgment module judges that the first block is in the full-written state;
a second updating sub-module, configured to update the usage status of the first block recorded in the data area information to a written status when the pre-write status is an unwritten status when the determination module determines that the usage status of the first block is not the unwritten status, where the pre-write status is: and storing the file to be written to the use state of the first block before the file to be written is stored in the block data area of the first block.
Optionally, the system index area includes: a system main index area and a system standby index area;
the system main index area is used for storing SSD information and data area information;
and the system standby index area is used for storing the backup information of the system main index area.
Optionally, the block index area of one block includes: a block main index area of the block and a block standby index area of the block;
a block main index area of a block for recording file storage information of a file stored in the block data area of the block;
and the block spare index area of one block is used for storing backup information of the block main index area of the block.
Optionally, the file management apparatus further includes:
the reading module is used for obtaining file storage position information of a file to be read, which is to be read from the SSD; positioning a block used for storing the file to be read in the SSD according to the SSD information and the block information recorded in the obtained file storage position information; and reading the file to be read from the positioned block according to the file storage information recorded in the obtained file storage position information.
Optionally, when more than one block is located, the reading module is specifically configured to:
according to file storage information recorded in the obtained file storage position information, reading data belonging to the file to be read from each positioned block respectively;
and merging the read data to obtain the file to be read.
In a third aspect, an embodiment of the present invention provides an electronic device, where the electronic device is mounted with a solid state disk SSD, and the SSD has an SSD file system, and the SSD file system includes: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of a block for recording file storage information of a file stored in the block data area of the block, and a block data area, the electronic device further comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
the memory is used for storing a computer program;
the processor is used for executing the program stored in the memory and executing the following steps:
obtaining a file to be written in the SSD;
generating an identifier of the file to be written, and determining a block for storing the file to be written as a first block through the SSD file system;
and storing the file to be written into the block data area of the first block, acquiring file storage information of the file to be written, and storing the acquired file storage information into the block index area of the first block.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium is a storage medium in an electronic device, and the electronic device is mounted with a solid state disk SSD, and the SSD has an SSD file system, and the SSD file system includes: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of a block for recording file storage information of a file stored in the block data area of the block, and a block data area, a computer program being stored in the computer-readable storage medium, the computer program being executed by a processor to:
obtaining a file to be written in the SSD;
generating an identifier of the file to be written, and determining a block for storing the file to be written as a first block through the SSD file system;
and storing the file to be written into the block data area of the first block, acquiring file storage information of the file to be written, and storing the acquired file storage information into the block index area of the first block.
In the file management method, the file management apparatus, the electronic device and the storage medium provided by the embodiment of the invention, when the electronic equipment is hung with the SSD, the SSD has an SSD file system different from an operating system own file system, after the electronic equipment acquires the file to be written, generating the identifier of the file, determining the block for storing the file to be written through the SSD file system, directly storing the file to be written into the determined block, compared with the prior art, when the scheme provided by the embodiment of the invention is applied to realize file storage, the storage position of the file is determined by the file system of the SSD, and the determined storage position is a block contained in a block data area in the SSD file system, the storage path of the file to be written does not need to be determined, namely the file to be written does not need to be written based on the storage path, and therefore the writing speed of the file to be written is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic diagram of the area division of an SSD according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a file management method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of another area division of an SSD according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a file management apparatus according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a file management apparatus according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a determining module in the file management apparatus according to the embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a file management method, which is applied to electronic equipment, wherein the electronic equipment can be a server or other types of electronic equipment.
The electronic device is mounted with the SSD, specifically, only one SSD may be mounted, or more than one SSD may be mounted, and each SSD mounted with the electronic device has an SSD file system. Wherein the SSD file system comprises: a system Index area and a data area, referring to fig. 1, wherein the system main Index area and the system standby Index area constitute a system Index area, Index is used to represent the system main Index area, and binder is used to represent the system standby Index area; block 1, block 2 … … block n constitute a data area.
The system index area is used for storing SSD information and data area information; the data area is divided into blocks of the same size, each block including: a block index area and a block data area, referring to fig. 1, where i1 and i2 … … in are block index areas of corresponding block 1 and block 2 … … block n; d1 and D2 … … Dn are block data areas of the corresponding block 1 and block 2 … … block n.
The block index area of a block is used for recording the file storage information of the file stored in the block data area of the block.
Specifically, the file storage information may include information such as a file ID (identity) of the stored file, a file size, a file position offset, and a file storage time. The file position offset may be understood as: the offset of the starting storage location of the file in the block relative to the starting address of the block. For example, if block 1 stores file a, the block index area of block 1 may include the file ID, the file size, the file location offset, and the file storage time of file a; if the block 2 stores the file B, the block index area of the block 2 may include the file ID, the file size, the file position offset, and the file storage time of the file B; block 3 stores file C, the block index area of block 3 may contain the file ID, file size, file location offset, and file storage time of file C.
The SSD information may include information such as an ID, a total storage capacity, and an available space of the SSD.
The data area information may include information such as the size of each block in the data area, the number of blocks, and usage status information for each block. The use state information of the block may be understood as: information indicating a current usage state of the block, which can be divided into, from the viewpoint of data storage: an unwritten state, a written state, and a fully written state.
The unwritten state can be understood as: the status of no files yet stored;
the fully written state can be understood as: a state where a file has been stored and there is no free storage space;
the written state can be understood as: there is a state where a file has been stored but there is still free storage space.
As can be seen from the above description, the information such as the ID of the SSD in the SSD information, the total storage capacity, and the block size and the number of blocks in the data area information is not changed while the SSD stores the file, and the available space in the SSD information and the usage status of each block in the data area information may change with the storage of the file, so that the SSD information and the data area information may be set during formatting the SSD, where the available space in the SSD information and the usage status of each block in the data area information set during the formatting process are only initial values.
Specifically, in the process of formatting the SSD having the SSD file system, besides the SSD needs to be formatted in the conventional sense, a system index area, a data area, and a block index area and a block data area of each block in the data area in the SSD file system need to be determined, and SSD information and data area information stored in the system index area need to be set.
The size of the system index area, the size of each block in the data area and the size of the block index area in each block can be preset;
the initial value of the available space in the SSD information may be set to the total storage capacity of the SSD;
since no file is stored in each block of the data area during formatting, the initial value of the use state of each block may be set as: an unwritten state;
the number of blocks in the data area information may be calculated in the following manner:
subtracting the size of the system index area from the total storage space to obtain a difference value;
and dividing the obtained difference value by the size of each block in the preset data area, and taking the quotient obtained after the division as the number of the blocks in the data area.
As shown in fig. 2, the file management method provided in the embodiment of the present invention includes the following steps:
s101, obtaining a file to be written in the SSD.
In this embodiment of the present invention, the file to be written is a file to be written in the SSD, and the file may include: a picture format file, a text format file, an audio format file, a video format file, and the like. It is easy to understand that there are many ways to obtain the file to be written, for example, the file to be written may be obtained through a file writing request sent by an application program, and the file to be written stored in the cloud database may also be actively searched.
S102, generating an identifier of a file to be written, and determining a block for storing the file to be written as a first block through the SSD file system.
And after the file to be written is obtained, the electronic equipment generates a unique identifier of the file so as to distinguish the file from other files. As can be seen from the foregoing, the data area of an SSD can be divided into a plurality of blocks having the same size, so that one block for storing a file to be written can be determined by the SSD file system, and the determined block is taken as the first block. Specifically, the SSD file system may allocate a block in a data area for a file to be written to store the file to be written.
As an optional implementation manner, when one electronic device mounts a plurality of SSDs, the electronic device may select one of the SSDs to store a file to be written according to SSD information stored in each SSD system index area, such as an ID of the SSD. Illustratively, when one electronic device mounts 3 SSDs, the IDs of the 3 SSDs are 001A, 002B, and 003C, respectively, the electronic device may randomly select the SSD with the ID of 002B as the SSD storing the file to be written, and allocate a block in one data area to store the file to be written through the file management system of the SSD; or one SSD can be selected as the SSD for storing the file to be written based on the format of the current file to be written.
Since the obtained files may have different sizes, the first block allocated by the SSD file system may be one or a plurality of blocks. That is, when the size of a file is larger than the size of a block in the data area, a plurality of blocks may be allocated for the file for storing the file. For example, a file having a size of 80MB and a block having a size of 64MB, the file management system may allocate 2 blocks for storing the file.
S103, storing the file to be written into the block data area of the first block, obtaining the file storage information of the file to be written, and storing the obtained file storage information into the block index area of the first block.
In the embodiment of the invention, after the first block is allocated to the file to be written, the file can be stored in the block data area of the first block when the preparation for storing the file to be written is indicated. After the file to be written is stored, file storage information of the file, such as a file ID, a file size, a file location offset, a file storage time, and the like, may be acquired and stored in the block index area of the first block. By storing the storage information of the file in the block index area, the index information of the file can be established in the block for storing the file, so that the storage condition of the file can be conveniently checked later, and the use convenience of the file management method provided by the embodiment of the invention is improved.
Optionally, a plurality of files to be written, which are allocated to the first block, can be sequentially stored in the block data area of the first block, so that the sequential writing performance advantage of the SSD can be utilized, the storage speed of the plurality of files can be increased, and the file storage efficiency can be improved.
As an optional implementation manner of the embodiment of the present invention, after obtaining the file storage information of the stored file to be written, the embodiment of the present invention may further generate file storage location information corresponding to the file. The file storage location information generally includes file storage information of the file, block information of the first block, and SSD information of the SSD to which the first block belongs. The block information of the first block may contain various attribute information of the first block, such as a current use state of the first block, a block number of the first block in the data area, and the like. The file storage location information may include: the file ID of the file, the size of the file, the position offset of the file, the ID of the SSD where the file is located, the block number of the first block, and the like.
Moreover, on the basis of the above embodiment, after the file to be written is stored in the SSD, the information of the file storage location may be fed back to the application program that sends the file write request, so that a user of the application program can know that the file to be written is stored in the SSD, and can also know information such as the file storage location and the file ID, which is convenient for the user to search the file in the future. Illustratively, the file storage location information may be fed back to the application sending the file write request in the form of a URL (Uniform Resource Locator), and the URL address may contain information such as an ID of the SSD, information of a block where the file is located (e.g., a block number of the first block), a file location offset, a file size, a file ID, and the like.
As an optional implementation manner of the embodiment of the present invention, the data area information may further include a use status of each block. The use state of a block may be an unwritten state, a written state, and a fully written state. The unwritten state indicates that the data in the block is empty, and the data can be written; the written state indicates that the block stores data and the data can still be written again; the write full status indicates that the data stored in the block is full and that no more data can be written. After the file to be written is stored in the first block, the state of the first block may change, and therefore, the use state of the first block needs to be updated in combination with the use states of the first block before and after the file to be written is stored, so that it is ensured that the use state of the first block is correctly stored.
After a file to be written is stored in a first block, two conditions may exist, wherein in the first condition, the first block is in a full-written state; in case two, the first block is in an unfilled state. According to the two situations, whether the use state of the first block is the full-written state or not can be judged, and then the use state of the first block is updated in different modes according to the judgment result.
Alternatively, the specific updating process may be that, if the current usage state of the first block is a write-full state, the usage state of the first block recorded in the data area information may be updated to the write-full state; if the current use state of the first block is the non-full-written state and the pre-write state is the non-written state, indicating that the use state of the first block is not yet storing data before the file to be written is stored in the block data area of the first block, the use state of the first block recorded in the data area information may be updated to the written state.
In addition, when the current use state of the first block is an incomplete write state and the pre-write state is a written state, which indicates that a file to be written is stored in the block data area of the first block before the file to be written is stored, the first block has a stored file, the use state of the first block is a written state, and after the file to be written is stored, the first block still has a free space.
As an alternative implementation of the embodiment of the present invention, as shown in fig. 3, the system index area may be only partially formed. That is, the SSD information and the data area information are directly stored in the system index area, and the system index area may be the system main index area in fig. 1.
Corresponding to the above embodiment, as another optional implementation manner of the embodiment of the present invention, as shown in fig. 1, the system index area may be composed of two parts, that is, the system index area may be divided into: a system main index area and a system standby index area. The system comprises a system main index area, a data area and a data area, wherein the system main index area is used for storing SSD information and data area information; the system spare index area is used for storing backup information of the system main index area, namely, the system spare index area is used as a backup of the system main index area and is also used for storing SSD information and data area information. The system standby index area of the embodiment of the invention stores the backup information of the system main index area, so that when the system main index area fails, the data in the system main index area can be recovered through the backup information in the system standby index area, thereby improving the data security of the SSD.
As an alternative implementation manner of the embodiment of the present invention, the block index area of one block may be only composed of a part. That is, the file storage information of the file stored in the block data area of a block is directly recorded in the block index area of the block, and the block index area at this time may be the block main index area in fig. 1.
Corresponding to the above embodiment, as another optional embodiment of the present invention, the block index area of one block may be composed of two parts, that is, the block index area may be divided into: a block primary index region of the block and a block secondary index region of the block. The block main index area is used for recording file storage information of a file stored in the block data area of the block; and a block spare index area for storing backup information of the block main index area of the block, that is, the block spare index area is used as a backup of the block main index area and is also used for recording file storage information of files stored in the data area of the block, referring to fig. 1, where Bi1 and Bi2 … … Bin are block spare index areas of corresponding block 1 and block 2 … … block n. In the block backup index area of the embodiment of the invention, because the backup information of the block main index area of the block is stored, when the block main index area is damaged, the data in the block main index area can be recovered through the backup information of the block backup index area, thereby improving the data security of the SSD.
As an optional implementation manner of the embodiment of the present invention, after the file to be written is written in the SSD managed by the file system of the embodiment of the present invention, file data in the SSD may also be read, and the file may be referred to as a file to be read.
Alternatively, the file to be read in the SSD may be read using the generated file storage location information.
As described above, after a file to be written is written into the SSD, file storage location information corresponding to the file is generated, where the file storage location information includes corresponding SSD information and block information, and specifically, information such as an ID of the SSD where the file is located, a block number of the first block, and the like may be recorded. Through the information, the block for storing the file to be read can be positioned in the SSD. As described above, the file storage location information may further include file storage information, where information such as a file ID of the file, a size of the file, and a location offset of the file may be recorded in the file storage information, and therefore, the file to be read may be read from the located block through the file storage information recorded in the file storage location information.
Specifically, the SSD where the file to be read is located may be determined first by the ID of the SSD in the file storage location information, and then the block where the file to be read is located in the SSD by the block number of the first block where the file is located; and reading the file to be read in the block data area of the positioned block according to the size of the file and the position offset of the file in the file position storage information.
When the file in the SSD is read, the embodiment of the invention can directly locate the block of the file to be read through the SSD information and the block information in the file storage position information corresponding to the file, and then read the file to be read from the located block through the file storage information recorded in the file storage position information without reading the file based on the file storage path, thereby improving the reading speed of the file.
In the foregoing embodiment, when the size of a file is larger than the size of a block in the data area, a plurality of blocks may be allocated for the file for storing the file. Accordingly, there may also be situations where more than one block is located when reading the file.
As an optional implementation manner of the embodiment of the present invention, when more than one block is located, in the embodiment of the present invention, when the file to be read is read, data belonging to the file to be read may be read from each located block according to file storage information recorded in the obtained file storage location information, and the read data may be subjected to merging processing to obtain the file to be read.
In the file management method provided by the embodiment of the invention, when the electronic device is mounted with the SSD, the SSD itself has an SSD file system different from a file system of an operating system itself, and after the electronic device obtains the file to be written, the identifier of the file is generated, and the block for storing the file to be written is determined by the SSD file system, and the file to be written is directly stored in the determined block.
Corresponding to the above method embodiment, the embodiment of the present invention also provides a corresponding device embodiment.
As shown in fig. 4, an embodiment of the present invention provides a file management apparatus, where the apparatus is mounted with a solid state disk SSD, and the SSD has an SSD file system, where the SSD file system includes: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of a block for recording file storage information of a file stored in the block data area of the block, and the block data area, the apparatus comprising:
the obtaining module 201 is configured to obtain a file to be written into the SSD.
A determining module 202, configured to generate an identifier of the file to be written, and determine, as a first block, a block for storing the file to be written through the SSD file system.
The storage module 203 is configured to store the file to be written in the block data area of the first block, obtain file storage information of the file to be written, and store the obtained file storage information in the block index area of the first block.
In the file management device provided by the embodiment of the invention, when the electronic device is mounted with the SSD, the SSD itself has an SSD file system different from a file system of an operating system itself, and after the electronic device obtains the file to be written, the identifier of the file is generated, and the block for storing the file to be written is determined by the SSD file system, and the file to be written is directly stored in the determined block.
As shown in fig. 5, as an optional implementation manner of the embodiment of the present invention, on the basis of the above apparatus embodiment, the file management apparatus according to the embodiment of the present invention may further include:
the generating module 204 is configured to generate file storage location information of the file to be written according to the file storage information of the file to be written, the block information of the first block, and SSD information of the SSD to which the first block belongs.
Alternatively, the data area information may include: the usage status of each block;
the file management device of the embodiment of the invention further comprises:
the determining module 205 is configured to determine whether the current usage status of the first block is a full status.
Optionally, the system index area includes: a system main index area and a system standby index area;
the system main index area is used for storing SSD information and data area information;
and the system standby index area is used for storing the backup information of the system main index area.
Optionally, the block index area of one block includes: a block main index area of the block and a block standby index area of the block; a block main index area of a block for recording file storage information of a file stored in the block data area of the block; and the block spare index area of one block is used for storing backup information of the block main index area of the block.
Optionally, the file management apparatus according to the embodiment of the present invention further includes:
a reading module 206, configured to obtain file storage location information of a file to be read from an SSD; positioning a block used for storing a file to be read in the SSD according to the SSD information and the block information recorded in the obtained file storage position information; and reading the file to be read from the positioned block according to the file storage information recorded in the obtained file storage position information.
Optionally, when more than one block is located, the reading module 206 may specifically be configured to:
according to the file storage information recorded in the obtained file storage position information, reading data belonging to the file to be read from each positioned block respectively; merging the read data to obtain the file to be read:
optionally, as shown in fig. 6, the determining module 205 further includes:
the first updating sub-module 2051 is configured to update the usage status of the first block recorded in the data area information to a full status when the determining module 205 determines yes.
A second updating sub-module 2052, configured to, when the determination module 205 determines that the status before writing is not written, update the usage status of the first block recorded in the data area information to a written status, where the status before writing is: and storing the file to be written into the use state of the first block before the block data area of the first block.
According to the file management device provided by the embodiment of the invention, the generation module 204 can generate the file storage position information, so that a user can conveniently search the file in the future; through the system standby index area, when the system main index area is damaged, data in the system main index area can be recovered through backup information in the system standby index area, so that the data security of the SSD is guaranteed; through the block backup index area, when the block main index area is damaged, data in the block main index area can be recovered through backup information of the block backup index area, and therefore data safety of the SSD is guaranteed.
An embodiment of the present invention further provides an electronic device, as shown in fig. 7, the electronic device includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, where the processor 301, the communication interface 302, and the memory 303 complete mutual communication through the communication bus 304,
a memory 303 for storing a computer program;
the processor 301, when executing the program stored in the memory 303, is configured to implement the following steps of the file management method according to the embodiment of fig. 2 and the other embodiments of the method described above:
obtaining a file to be written in the SSD;
generating an identifier of a file to be written, and determining a block for storing the file to be written as a first block through an SSD file system;
and storing the file to be written into the block data area of the first block, acquiring file storage information of the file to be written, and storing the acquired file storage information into the block index area of the first block.
According to the electronic device provided by the embodiment of the invention, when the electronic device is mounted with the SSD, the SSD has the SSD file system different from the self-contained file system of the operating system, after the electronic device obtains the file to be written, the identifier of the file is generated, the SSD file system determines the block for storing the file to be written, and the file to be written is directly stored in the determined block.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, so as to implement the following steps of the file management method according to the embodiment of fig. 2 and the other embodiments of the method described above:
obtaining a file to be written in the SSD;
generating an identifier of a file to be written, and determining a block for storing the file to be written as a first block through an SSD file system;
and storing the file to be written into the block data area of the first block, acquiring file storage information of the file to be written, and storing the acquired file storage information into the block index area of the first block.
In the computer-readable storage medium provided by the embodiment of the invention, when the electronic device is mounted with the SSD, the SSD itself has an SSD file system different from a file system of an operating system itself, and after the electronic device obtains the file to be written, the identifier of the file is generated, and the block for storing the file to be written is determined by the SSD file system, and the file to be written is directly stored in the determined block.
For the apparatus/electronic device/storage medium embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to part of the description of the method embodiment.
It should be noted that the device, the electronic device, and the storage medium according to the embodiments of the present invention are respectively a device, an electronic device, and a storage medium to which the dynamic contention window adjustment method based on the random game theory is applied, and all embodiments of the dynamic contention window adjustment method based on the random game theory are applicable to the device, the electronic device, and the storage medium, and can achieve the same or similar beneficial effects.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.
Claims (14)
1. The file management method is applied to electronic equipment, wherein the electronic equipment is mounted with a Solid State Disk (SSD), the SSD has an SSD file system, and the SSD file system comprises: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of a block for recording file storage information of a file stored in the block data area of the block, and a block data area, the method comprising:
obtaining a file to be written in the SSD through a file writing request sent by an application program; the file to be written comprises a picture format file, a text format file, an audio format file or a video format file;
when the electronic equipment is hung with a plurality of SSDs, the electronic equipment selects one SSD as the SSD for storing the file to be written based on the format of the file to be written;
generating an identifier of the file to be written, and determining a block for storing the file to be written as a first block through the SSD file system;
storing the file to be written into a block data area of the first block in a sequential storage manner, obtaining file storage information of the file to be written, and storing the obtained file storage information into a block index area of the first block, wherein the file storage information comprises a file position offset of the file to be written, and the file position offset is used for indicating an offset of a starting storage position of the file to be written in the first block relative to a starting address of the first block;
and generating file storage position information of the file to be written according to the file storage information of the file to be written, the block information of the first block and SSD information of the SSD to which the first block belongs, and feeding back the file storage position information to the application program after the file to be written is stored in the SSD.
2. The file management method according to claim 1, wherein said data area information includes: the usage status of each block;
after the storing the file to be written to the block data area of the first block, the method further comprises:
judging whether the current use state of the first block is a full write state;
if so, updating the use state of the first block recorded in the data area information to a full write state;
if not, updating the use state of the first block recorded in the data area information to a written state when the pre-writing state is an unwritten state, wherein the pre-writing state is: and storing the file to be written to the use state of the first block before the file to be written is stored in the block data area of the first block.
3. The file management method according to any one of claims 1-2, wherein the system index area includes: a system main index area and a system standby index area;
the system main index area is used for storing SSD information and data area information;
and the system standby index area is used for storing the backup information of the system main index area.
4. The file management method according to any one of claims 1-2, wherein the block index area of one block includes: a block main index area of the block and a block standby index area of the block;
a block main index area of a block for recording file storage information of a file stored in the block data area of the block;
and the block spare index area of one block is used for storing backup information of the block main index area of the block.
5. The file management method according to claim 1, characterized in that the method further comprises:
obtaining file storage position information of a file to be read from an SSD;
positioning a block used for storing the file to be read in the SSD according to the SSD information and the block information recorded in the obtained file storage position information;
and reading the file to be read from the positioned block according to the file storage information recorded in the obtained file storage position information.
6. The file management method according to claim 5, wherein, when more than one block is located, said reading the file to be read from the located block according to the file storage information recorded in the obtained file storage location information comprises:
according to file storage information recorded in the obtained file storage position information, reading data belonging to the file to be read from each positioned block respectively;
and merging the read data to obtain the file to be read.
7. The file management device is applied to an electronic device, wherein the electronic device is mounted with a Solid State Disk (SSD), and the SSD has an SSD file system, and the SSD file system includes: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of a block for recording file storage information of a file stored in the block data area of the block, and a block data area, the apparatus comprising:
the acquisition module is used for acquiring a file to be written in the SSD through a file writing request sent by an application program; the file to be written comprises a picture format file, a text format file, an audio format file or a video format file;
the determining module is used for selecting one SSD as the SSD for storing the file to be written by the electronic equipment based on the format of the file to be written when the electronic equipment is hung with a plurality of SSDs; generating an identifier of the file to be written, and determining a block for storing the file to be written as a first block through the SSD file system;
a storage module, configured to store the file to be written in a block data area of the first block in a sequential storage manner, obtain file storage information of the file to be written, and store the obtained file storage information in a block index area of the first block, where the file storage information includes a file position offset of the file to be written, and the file position offset is used to indicate an offset of a starting storage position of the file to be written in the first block relative to a starting address of the first block;
and the feedback module is used for generating file storage position information of the file to be written according to the file storage information of the file to be written, the block information of the first block and SSD information of the SSD to which the first block belongs, and feeding back the file storage position information to the application program after the file to be written is stored in the SSD.
8. The file management apparatus according to claim 7, wherein said data area information includes: the usage status of each block;
the device further comprises:
the judging module is used for judging whether the current use state of the first block is a full-written state;
the judging module comprises:
the first updating submodule is used for updating the use state of the first block recorded in the data area information into a full-written state when the judgment module judges that the first block is in the full-written state;
a second updating sub-module, configured to update the usage status of the first block recorded in the data area information to a written status when the pre-write status is an unwritten status when the determination module determines that the usage status of the first block is not the unwritten status, where the pre-write status is: and storing the file to be written to the use state of the first block before the file to be written is stored in the block data area of the first block.
9. The file management apparatus according to any one of claims 7 to 8, wherein the system index area includes: a system main index area and a system standby index area;
the system main index area is used for storing SSD information and data area information;
and the system standby index area is used for storing the backup information of the system main index area.
10. The file management apparatus according to any of claims 7 to 8, wherein the block index area of one block comprises: a block main index area of the block and a block standby index area of the block;
a block main index area of a block for recording file storage information of a file stored in the block data area of the block;
and the block spare index area of one block is used for storing backup information of the block main index area of the block.
11. The file management apparatus according to claim 7, wherein said apparatus further comprises:
the reading module is used for obtaining file storage position information of a file to be read, which is to be read from the SSD; positioning a block used for storing the file to be read in the SSD according to the SSD information and the block information recorded in the obtained file storage position information; and reading the file to be read from the positioned block according to the file storage information recorded in the obtained file storage position information.
12. The file management apparatus according to claim 11, wherein when more than one block is located, the reading module is specifically configured to:
according to file storage information recorded in the obtained file storage position information, reading data belonging to the file to be read from each positioned block respectively;
and merging the read data to obtain the file to be read.
13. An electronic device, wherein the electronic device is mounted with a Solid State Disk (SSD), the SSD having an SSD file system, the SSD file system comprising: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area of a block for recording file storage information of a file stored in the block data area of the block, and a block data area, the electronic device further comprising: a processor and a memory, wherein the memory is configured to store a computer program;
the processor, when executing the program stored in the memory, is adapted to carry out the method steps of any of claims 1-6.
14. A computer-readable storage medium, wherein the computer-readable storage medium is a storage medium in an electronic device, and the electronic device is mounted with a Solid State Disk (SSD), and the SSD has an SSD file system, and the SSD file system includes: the system comprises a system index area and a data area, wherein the system index area is used for storing SSD information and data area information, the data area is divided into blocks with the same size, and each block comprises: a block index area and a block data area, the block index area of a block being used to record file storage information of a file stored in the block data area of the block, the computer readable storage medium having stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-6.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710951379.8A CN109669623B (en) | 2017-10-13 | 2017-10-13 | File management method, file management device, electronic equipment and storage medium |
PCT/CN2018/107594 WO2019072088A1 (en) | 2017-10-13 | 2018-09-26 | File management method, file management device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710951379.8A CN109669623B (en) | 2017-10-13 | 2017-10-13 | File management method, file management device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109669623A CN109669623A (en) | 2019-04-23 |
CN109669623B true CN109669623B (en) | 2021-09-03 |
Family
ID=66100386
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710951379.8A Active CN109669623B (en) | 2017-10-13 | 2017-10-13 | File management method, file management device, electronic equipment and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN109669623B (en) |
WO (1) | WO2019072088A1 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111382122B (en) * | 2020-03-11 | 2024-01-30 | 杭州涂鸦信息技术有限公司 | File management system and method for multi-path network camera sub-equipment |
CN113190507B (en) * | 2021-05-14 | 2022-06-03 | 杭州海康威视数字技术股份有限公司 | Index information synchronization method and device and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1619533A (en) * | 2003-11-17 | 2005-05-25 | 鸿富锦精密工业(深圳)有限公司 | Flash memory document management system and method |
CN101178693A (en) * | 2007-12-14 | 2008-05-14 | 沈阳东软软件股份有限公司 | Data cache method and system |
CN106021268A (en) * | 2015-03-26 | 2016-10-12 | 国际商业机器公司 | File system block-level tiering and co-allocation |
CN107203532A (en) * | 2016-03-16 | 2017-09-26 | 阿里巴巴集团控股有限公司 | Construction method, the implementation method of search and the device of directory system |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103514260B (en) * | 2013-08-13 | 2016-12-28 | 中国科学技术大学苏州研究院 | Internal storage log file system and its implementation |
US9665287B2 (en) * | 2015-09-18 | 2017-05-30 | Alibaba Group Holding Limited | Data deduplication using a solid state drive controller |
-
2017
- 2017-10-13 CN CN201710951379.8A patent/CN109669623B/en active Active
-
2018
- 2018-09-26 WO PCT/CN2018/107594 patent/WO2019072088A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1619533A (en) * | 2003-11-17 | 2005-05-25 | 鸿富锦精密工业(深圳)有限公司 | Flash memory document management system and method |
CN101178693A (en) * | 2007-12-14 | 2008-05-14 | 沈阳东软软件股份有限公司 | Data cache method and system |
CN106021268A (en) * | 2015-03-26 | 2016-10-12 | 国际商业机器公司 | File system block-level tiering and co-allocation |
CN107203532A (en) * | 2016-03-16 | 2017-09-26 | 阿里巴巴集团控股有限公司 | Construction method, the implementation method of search and the device of directory system |
Also Published As
Publication number | Publication date |
---|---|
WO2019072088A1 (en) | 2019-04-18 |
CN109669623A (en) | 2019-04-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109669622B (en) | File management method, file management device, electronic equipment and storage medium | |
US11799959B2 (en) | Data processing method, apparatus, and system | |
CN104537076B (en) | A kind of file read/write method and device | |
CN105069048A (en) | Small file storage method, query method and device | |
CN108614837B (en) | File storage and retrieval method and device | |
CN109669621B (en) | File management method, file management system, electronic device and storage medium | |
CN110888837B (en) | Object storage small file merging method and device | |
US11494403B2 (en) | Method and apparatus for storing off-chain data | |
CN107959695B (en) | Data transmission method and device | |
CN103324533A (en) | distributed data processing method, device and system | |
CN110019048A (en) | Document handling method, device, system and server based on MongoDB | |
CN111638853A (en) | Data storage method and device, storage cluster, gateway equipment and main equipment | |
CN111221475A (en) | Storage space management method, device, equipment and readable medium | |
CN109669623B (en) | File management method, file management device, electronic equipment and storage medium | |
CN105141685A (en) | File read-write system and meta data memory thereof as well as method and device for reading and writing files | |
CN113157600A (en) | Space allocation method of shingled hard disk, file storage system and server | |
EP3822763B1 (en) | Data reading method, device, system, and distributed system | |
CN105260266B (en) | A kind of snapped volume write method and dependent snapshot system | |
CN115756955A (en) | Data backup and data recovery method and device and computer equipment | |
CN110795031A (en) | Data deduplication method, device and system based on full flash storage | |
CN109271097B (en) | Data processing method, data processing device and server | |
CN110688065A (en) | Storage space management method, system, electronic equipment and storage medium | |
CN107704208B (en) | Method, device and medium for repairing metadata | |
CN109144403B (en) | Method and equipment for switching cloud disk modes | |
CN107148612A (en) | A kind of method and apparatus of extending user subregion |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |