CN113467698A - Writing method and device based on file system, computer equipment and storage medium - Google Patents
Writing method and device based on file system, computer equipment and storage medium Download PDFInfo
- Publication number
- CN113467698A CN113467698A CN202010237085.0A CN202010237085A CN113467698A CN 113467698 A CN113467698 A CN 113467698A CN 202010237085 A CN202010237085 A CN 202010237085A CN 113467698 A CN113467698 A CN 113467698A
- Authority
- CN
- China
- Prior art keywords
- file system
- data
- storage medium
- writing
- system metadata
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 77
- 238000012216 screening Methods 0.000 claims abstract description 13
- 238000004590 computer program Methods 0.000 claims description 29
- 230000001360 synchronised effect Effects 0.000 claims description 19
- 238000012545 processing Methods 0.000 claims description 14
- 230000000903 blocking effect Effects 0.000 abstract description 4
- 238000007726 management method Methods 0.000 description 19
- 238000004891 communication Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 208000003028 Stuttering Diseases 0.000 description 2
- 241000700605 Viruses Species 0.000 description 2
- 230000001788 irregular Effects 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- ZXQYGBMAQZUVMI-GCMPRSNUSA-N gamma-cyhalothrin Chemical compound CC1(C)[C@@H](\C=C(/Cl)C(F)(F)F)[C@H]1C(=O)O[C@H](C#N)C1=CC=CC(OC=2C=CC=CC=2)=C1 ZXQYGBMAQZUVMI-GCMPRSNUSA-N 0.000 description 1
- 230000017525 heat dissipation Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
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
- 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]
Abstract
The application provides a data writing method and device based on a file system, computer equipment and a storage medium. The method comprises the following steps: when a write-in instruction of file data to be written is determined to be received, acquiring file system metadata from a memory; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data; screening the file system metadata to determine a target available storage space; and writing the file data to be written into the target available storage space. By adopting the method, the situations of blocking or frame loss of video and the like caused by the fact that the file system writes data under the condition that the resources of the embedded equipment are limited can be avoided, and therefore the writing performance of the file system is effectively improved.
Description
Technical Field
The present application relates to the field of embedded system technologies, and in particular, to a data writing method and apparatus based on a file system, a computer device, and a storage medium.
Background
At present, a file system is widely applied to embedded devices such as a motion camera or a driving recording instrument, and for the embedded devices with rich resources, such as the embedded devices with a large enough memory and a good enough performance of a storage medium, the file system in the embedded system can be well operated and obtain good performance.
However, for an embedded device with extremely limited resources, the embedded device may more frequently recover file data and file system metadata (including a storage medium usage distribution table in a memory), which may cause a decrease in writing performance of a file system, and may easily cause situations such as stuttering and frame loss due to video recording.
Obviously, the existing method increases the writing times and reading times of writing data into the storage medium from the memory, reduces the writing speed and reading speed of the storage medium, and increases the storage burden, thereby causing the problems of blockage or video frame loss and the like when the file system in the embedded system writes data.
Disclosure of Invention
Based on this, for an embedded system with a short resource, it is necessary to provide a data writing method, an apparatus, a computer device and a storage medium based on a file system, for the problems that a batch of file data is written into a storage medium when the batch of file data is written into a memory, and metadata (including a current usage distribution table) of the memory is acquired when the file data is written into the storage medium by the memory once, resulting in a stuck or a video frame loss when the file system writes data.
In a first aspect, an embodiment of the present application provides a data writing method based on a file system, including:
when a write-in instruction of file data to be written is determined to be received, acquiring file system metadata from a memory; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
screening the file system metadata to determine a target available storage space;
and writing the file data to be written into the target available storage space.
In one embodiment, when a power down instruction or a restart instruction is received, the current file system metadata in the memory is written to the non-volatile storage medium.
In one embodiment, the writing, when a power-down instruction or a restart instruction is received, current file system metadata in a memory into a non-volatile storage medium includes:
when a power failure instruction or a restart instruction is received, obtaining updated file system metadata according to the file data to be written and the file system metadata received in a memory, and determining the updated file system metadata as the current file system metadata;
acquiring a preset alignment writing rule in a nonvolatile storage medium; the preset alignment writing rule represents an alignment mode of the current file system metadata and a storage physical unit in a nonvolatile storage medium;
and writing the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset alignment writing rule.
In one embodiment, the obtaining updated file system metadata according to the file data to be written and the file system metadata received in the memory includes:
acquiring a storage position of a target available storage space in a nonvolatile storage medium according to the target available storage space corresponding to the file data to be written received in a memory;
and updating the available attribute of the target available storage space in the file system metadata into an unavailable attribute according to the storage position to obtain updated file system metadata.
In one embodiment, the writing the current file system metadata into a non-volatile storage medium according to the preset aligned writing rule includes:
acquiring the maximum write-in length of the nonvolatile storage medium at one time;
determining the writing times corresponding to the total data volume according to the maximum writing length and the total data volume of the metadata of the current file system;
and according to the preset alignment writing rule, gradually writing the total data volume into a nonvolatile storage medium according to the writing times.
In one embodiment, after the step of writing the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset aligned writing rule, the method further includes:
when the current file system metadata are determined to be written into a nonvolatile storage medium in an aligned mode, executing synchronous operation aiming at the aligned file system metadata to obtain synchronous file metadata; the aligned file system metadata comprises current file system metadata which is aligned and written in a nonvolatile storage medium, and the synchronous file metadata is used for representing the fluency and the continuity of the current file system metadata.
In one embodiment, before the step of obtaining the current state information when it is determined that the write instruction of the file data to be written is received, the method further includes:
acquiring historical record data of a nonvolatile storage medium, and judging whether the nonvolatile storage medium meets a preset formatting condition according to the historical record data;
when the nonvolatile storage medium is determined to meet the preset formatting condition according to the historical record data, performing formatting operation on the nonvolatile storage medium;
when the fact that the nonvolatile storage medium does not accord with the preset formatting condition is determined according to the historical record data, outputting prompt information; wherein the prompt message is used for prompting that the current storage space of the nonvolatile storage medium is enough and the formatting operation is not required to be executed.
In a second aspect, an embodiment of the present application provides a data writing apparatus based on a file system, where the apparatus includes:
the first acquisition module is used for acquiring the metadata of the file system from the memory when determining that a write-in instruction of the file data to be written is received; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
the first processing module is used for screening the file system metadata to determine a target available storage space;
and the first data writing module is used for writing the file data to be written into the target available storage space.
The data writing device based on the file system further comprises a second data writing module, wherein the second data writing module is used for writing the current file system metadata in the memory into the nonvolatile storage medium when a power failure instruction or a restart instruction is received.
The second data writing module specifically includes:
the updating unit is used for obtaining updated file system metadata according to the file data to be written and the file system metadata received in the memory when a power failure instruction or a restart instruction is received, and determining the updated file system metadata as the current file system metadata;
the device comprises an acquisition unit, a storage unit and a control unit, wherein the acquisition unit is used for acquiring a preset alignment writing rule in a nonvolatile storage medium; the preset alignment writing rule represents an alignment mode of the current file system metadata and a storage physical unit in a nonvolatile storage medium;
and the data writing unit is used for writing the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset alignment writing rule.
The updating unit specifically includes:
the first obtaining subunit is configured to obtain, according to a target available storage space corresponding to the to-be-written file data received in the memory, a storage location of the target available storage space in a nonvolatile storage medium;
and the updating subunit is configured to update the available attribute of the target available storage space in the file system metadata to an unavailable attribute according to the storage location, so as to obtain updated file system metadata.
The data writing unit specifically includes:
a second obtaining subunit, configured to obtain a maximum write-once length of the nonvolatile storage medium;
the determining subunit is configured to determine, according to the maximum writing length and a total data size of the current file system metadata, a writing number corresponding to the total data size;
and the data writing subunit is configured to write the total data size into the nonvolatile storage medium successively according to the writing times according to the preset alignment writing rule.
The data writing unit further specifically includes an execution subunit, where the execution subunit is configured to, when it is determined that the current file system metadata is written in the nonvolatile storage medium in an aligned manner, execute a synchronization operation for the aligned file system metadata to obtain synchronized file metadata; the aligned file system metadata comprises current file system metadata which is aligned and written in a nonvolatile storage medium, and the synchronous file metadata is used for representing the fluency and the continuity of the current file system metadata.
The data writing device based on the file system further comprises:
the second acquisition module is used for acquiring historical record data of the nonvolatile storage medium and judging whether the nonvolatile storage medium meets a preset formatting condition or not according to the historical record data;
the processing module is used for executing formatting operation aiming at the nonvolatile storage medium when the nonvolatile storage medium is determined to accord with the preset formatting condition according to the historical record data;
the output module is used for outputting prompt information when the fact that the nonvolatile storage medium does not accord with the preset formatting condition is determined according to the historical record data; wherein the prompt message is used for prompting that the current storage space of the nonvolatile storage medium is enough and the formatting operation is not required to be executed.
In a third aspect, a computer device provided in an embodiment of the present application includes a memory and a processor, where the memory stores a computer program, and the processor implements the following steps when executing the computer program:
when a write-in instruction of file data to be written is determined to be received, acquiring file system metadata from a memory; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
screening the file system metadata to determine a target available storage space;
and writing the file data to be written into the target available storage space.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the following steps:
when a write-in instruction of file data to be written is determined to be received, acquiring file system metadata from a memory; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
screening the file system metadata to determine a target available storage space;
and writing the file data to be written into the target available storage space.
The application provides a data writing method, a data writing device, computer equipment and a storage medium based on a file system, wherein the method comprises the steps of firstly, acquiring file system metadata from a memory when a writing instruction of file data to be written is received; because the file system metadata comprises storage space distribution data of the current available storage space and the unavailable storage space of the nonvolatile storage medium and size information of the stored file data, the computer equipment can mark the storage space distribution data of the current available storage space and the unavailable storage space of the nonvolatile storage medium as unrecoverable memory data after reading the storage space distribution data into the memory once and does not write data into the nonvolatile true storage medium before shutdown or restart, so that the aim that the storage space distribution data of the current available storage space and the unavailable storage space of the nonvolatile storage medium are not recycled by the memory subsystem is fulfilled, and the problems that when a batch of file data is written into the memory, the batch of file data and the file system metadata are written into the nonvolatile storage medium and when the memory writes one time of file data into the nonvolatile storage medium, the nonvolatile storage medium acquires one time are avoided The problems of blocking or video frame loss and the like caused by using the distribution condition table in the prior art are solved, so that the reading times of the nonvolatile storage medium are reduced, the writing times of the memory to the nonvolatile storage medium are reduced, and the writing data performance of the memory and the nonvolatile storage medium is improved; further, a target available storage space is determined by screening the file system metadata, so that the file data to be written is written into the target available storage space. Therefore, the purpose of improving the writing performance of the file system under the condition of limited resources of the computer equipment is achieved, and the writing data speed of the computer equipment is improved.
Drawings
FIG. 1 is a flowchart illustrating a method for writing data based on a file system according to an embodiment;
FIG. 2 is a flowchart illustrating a method for writing data based on a file system according to another embodiment;
FIG. 3 is a flowchart illustrating a method for writing data based on a file system according to another embodiment;
FIG. 4 is a flowchart illustrating a method for writing data based on a file system according to another embodiment;
FIG. 5 is a flowchart illustrating a method for writing data based on a file system according to another embodiment;
FIG. 6 is a diagram of a file system based data writing apparatus, according to an embodiment;
FIG. 7 is an internal block diagram of a computer device, provided in one embodiment.
Detailed Description
At present, a built-in file system of an embedded device is usually designed based on linux, and for an embedded device with very limited resources, the embedded device is usually forced to write a batch of file data into a non-volatile storage medium due to limited resources, and the embedded device acquires file system metadata (including a current usage distribution table of the non-volatile storage medium) once when the memory writes the file data into the non-volatile storage medium, so that the number of times of reading and writing from the memory into the non-volatile storage medium is greatly increased, the writing speed of the non-volatile storage medium is reduced, the storage burden is increased, and the problems of blocking or frame loss due to video recording and the like are caused when the file system in the embedded system writes data.
The embodiment of the application provides a data writing method, a data writing device, a computer device and a storage medium based on a file system, when determining to receive the writing instruction of the file data to be written, acquiring the file system metadata from the memory, a specific process of screening the file system metadata to determine a target available storage space so as to write the file data to be written into the target available storage space, and the file system metadata is not written to the non-volatile storage medium when the file data to be written is written to the memory, is not written to the non-volatile storage medium once until a power down command or a restart command is received, the file system metadata of the nonvolatile storage medium is not required to be acquired from the nonvolatile storage medium when the writing instruction of the file data to be written is determined to be received, and the data writing speed of the file system is improved.
It should be noted that, in the data writing method based on the file system provided in the embodiment of the present application, the execution main body may be a data writing apparatus based on the file system, and the data writing apparatus based on the file system may be implemented as part or all of a computer device by software, hardware, or a combination of software and hardware. Optionally, the Computer device may be an electronic device with a data processing function, such as a Personal Computer (PC), a portable device, a server, and the like, or may also be an embedded device, an intelligent device, a Digital Video (DV) or a driving recorder, and the like, and the specific form of the Computer device is not limited in this embodiment. The execution subjects of the method embodiments described below are described taking a computer device as an example.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Fig. 1 is a schematic flow chart of a data writing method based on a file system according to an embodiment, where the embodiment relates to a specific process of how a computer device writes data when determining that a write instruction of file data to be written is received. As shown in fig. 1, the method includes:
step S11, when determining that the write-in instruction of the file data to be written is received, acquiring the file system metadata from the memory; wherein the file system metadata includes storage space distribution data of currently available storage space and unavailable storage space of the non-volatile storage medium and size information of the stored file data.
Specifically, when the computer device receives a write-in instruction of file data to be written in a starting state, the file system metadata can be directly read from the memory, and the file system metadata does not need to be acquired by traversing the nonvolatile storage medium; when the computer device is a Digital Video camera (DV), the file data to be written may be Video frame data; the File System may be a Fourth-generation extended File System (ext 4), a File Allocation Table (fat) File System, a Flash Friendly File System (f 2fs), and the like, and the nonvolatile storage medium may be a Memory module based on nand Flash technology, for example, the nonvolatile storage medium may be a Secure Digital Memory Card (SD Card).
In the actual processing process, when computer equipment receives file data to be written, the storage position of the file data to be written can be determined according to the size of the file to be written and the size of an available storage space in file system metadata; the file system metadata may include storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium, size information of the stored file data, and may also include important information such as authority, capacity size, modification time, creation time, file name, date, and storage location of the stored file data.
When the computer device determines to receive the file data to be written for the first time in the starting state, the available storage space and the unavailable storage space of the nonvolatile storage medium can be traversed to obtain the file system metadata; if the computer device receives the file data to be written for the first time (for example, the second time), the file system metadata can be obtained without traversing all the storage spaces of the nonvolatile storage medium again, and only the file system metadata obtained through the last traversal (for example, the first time) needs to be obtained, so that the target available storage space is determined according to the available storage space in the file system metadata obtained through the last traversal. Therefore, when the computer equipment is in the starting state, the file system metadata can be directly obtained from the memory, and the clearing operation aiming at the file system metadata in the memory cannot be executed, so that the file system metadata stored in the memory is still stored in the memory when the computer is in the starting state.
Wherein the storage space distribution data can represent the distribution of available storage space and unavailable storage space of the nonvolatile storage medium; for example, the storage space distribution data may be displayed in a pie chart, the available storage space is filled with a green color and the identifier corresponds to the percentage, the unavailable storage space is filled with a red color and the identifier corresponds to the percentage, and the total percentage of the available storage space to the unavailable storage space is 100%.
And step S12, screening the file system metadata to determine a target available storage space.
Specifically, the computer device may traverse storage space distribution data in the file system metadata according to the capacity of the file data to be written, specifically, screen available storage spaces in the storage space distribution data to obtain sub-available storage spaces sufficient for storing the file data to be written, and determine the sub-available storage spaces as target available storage spaces; the sub-available storage space may be a partial storage space of the available storage space, or may be the available storage space.
And step S13, writing the file data to be written into the target available storage space.
Specifically, when determining a target available storage space according to the capacity of the file data to be written, the computer device may write the file data to be written into the target available storage space, so as to complete the data writing operation.
In this embodiment, the computer device first determines that file system metadata is obtained from the memory when a write instruction of file data to be written is received; because the file system metadata comprises storage space distribution data of the current available storage space and the unavailable storage space of the nonvolatile storage medium and size information of the stored file data, the computer equipment can mark the storage space distribution data of the current available storage space and the unavailable storage space of the nonvolatile storage medium as unrecoverable memory data after reading the storage space distribution data into the memory once and does not write data into the nonvolatile memory before shutdown or restart, so that the aim that the storage space distribution data of the current available storage space and the unavailable storage space of the nonvolatile storage medium are not recycled by the memory subsystem is fulfilled, and the problems that when a batch of file data is written into the memory, the batch of file data and the file system metadata are written into the nonvolatile storage medium, and when the file data is written into the nonvolatile storage medium once by the memory, the current use of the nonvolatile storage medium is acquired once so that the batch of file data and the file system metadata are not recycled by the memory subsystem are avoided The problems of blocking or video frame loss and the like caused by the distribution condition table during the data writing of the file system not only reduce the reading times of the nonvolatile storage medium, but also reduce the times of writing data into the nonvolatile storage medium by the memory, and improve the data writing performance of the memory and the nonvolatile storage medium; further, a target available storage space is determined by screening the file system metadata, so that the file data to be written is written into the target available storage space. Therefore, the purpose of improving the writing performance of the file system under the condition of limited resources of the computer equipment is achieved, and the writing data speed of the computer equipment is improved.
The above embodiments disclose specific processes of how a computer device writes data when determining that a write instruction of file data to be written is received, and the following embodiments describe specific processes of how data is written when the computer device receives a power-down instruction or a restart instruction. It should be noted that the following method is only used for explaining the present application and is not used for limiting the present application.
As an optional implementation manner of the foregoing embodiment, this embodiment relates to a specific process of how to write data when the computer device receives a power-down instruction or a restart instruction. On the basis of the foregoing embodiment, optionally, the method further includes:
and step S21, when a power failure instruction or a restart instruction is received, writing the current file system metadata in the memory into the nonvolatile storage medium.
Specifically, when the computer device receives a power-down instruction, a restart instruction, or a stop operation instruction such as stop recording, the current file system metadata in the memory may be written into the nonvolatile storage medium, so that when the computer device is powered on again or started, the current file system metadata of the nonvolatile storage medium may be directly obtained by reading from the nonvolatile storage medium, and the current file system metadata may be file system metadata obtained by updating the file system metadata according to currently received file data to be written in the memory.
In the actual processing process, when the computer device does not receive a power-down instruction, a restart instruction or a stop operation instruction such as stopping video recording, the data writing operation of the file data to be written can be continuously performed in the memory, even if the file data to be written is the file data to be written aiming at a plurality of batches, the memory can write the data to be written of the plurality of batches into the memory according to the sequence of the batches, only when the computer equipment receives a power-down instruction or a restart instruction, or when the computer device stops recording or other specific scenes of stopping writing, the computer device writes the metadata of the current file system in the memory into the nonvolatile storage medium, the specific scenes are insensitive to the time consumption of writing and can tolerate long-time writing, so that the writing performance of the file system can be improved in the writing process of the file data to be written.
And writing the current system metadata in the memory into the nonvolatile storage medium in the specific scene, so that the current file system metadata for the nonvolatile storage medium can be directly acquired when the subsequent computer device is restarted or restarted. Therefore, when the computer device is used for a long time and is not plugged or is rarely plugged and is provided with a battery for power supply, for example, in a scene of continuous motion DV video recording and the like, the received file data to be written can be stored in the memory without being written into the nonvolatile storage medium, and the risk of data loss is not increased.
In this embodiment, when receiving a power-down instruction, a restart instruction, or a stop operation instruction such as stop recording, the computer device writes the current file system metadata in the memory into the nonvolatile storage medium, and does not need to write data into the nonvolatile storage medium every time a write instruction of file data to be written is received, so that the number of times of writing data from the memory into the nonvolatile storage medium is reduced, and the rapidity and reliability of writing data by the computer device are improved.
Fig. 2 is a schematic flow chart of a data writing method based on a file system according to another embodiment, where this embodiment relates to a specific process of how to write current file system metadata in a memory into a nonvolatile storage medium when a computer device receives a power-down instruction or a restart instruction. On the basis of the above embodiment, optionally, step S21 may be implemented by the following process:
step S211, when a power-down command or a restart command is received, obtaining updated file system metadata according to the file data to be written and the file system metadata received in the memory, and determining the updated file system metadata as the current file system metadata.
Specifically, when the computer device receives a power-down instruction, a restart instruction, or a stop instruction corresponding to other stop operations such as stopping video recording, the file system metadata may be updated according to the file data to be written received in the current memory, so as to obtain updated file system metadata.
In the actual processing process, in order to solve the problem that the file system metadata in the memory and the user data in the memory are both removed when the computer device performs memory recovery, the existing method acquires the file system metadata once when storing a batch of video data, updates the file system metadata, and stores the file system metadata into the storage medium once the file system metadata is updated, and when the update times of the file system are more and more, the write-in times of the memory into the storage medium are more and more increased, so that the storage performance is more and more poor.
Step S212, acquiring a preset alignment writing rule in the nonvolatile storage medium; and the preset alignment writing rule represents an alignment mode of the current file system metadata and a storage physical unit in the nonvolatile storage medium.
Specifically, the preset alignment write rule may be an alignment rule in a non-volatile storage medium protocol, for example, when the non-volatile storage medium is an sd card, the preset write rule may be an RU size 32K alignment rule of the sd card protocol, the sd card may include a plurality of storage physical units, each storage physical unit may be sequentially written with a plurality of bits of data having a length of 32K, the lengths of the storage physical units may be the same or different, and this is not limited herein.
In actual processing, when the memory resource of the computer device is limited, the memory cannot buffer more data, so that the written data is scattered and irregular, and the writing operation is equivalent to random writing for a nonvolatile storage medium based on flash, which greatly reduces the writing data performance of the nonvolatile storage medium, thereby causing a stuck state. Based on this, when the computer device in this embodiment receives a power-down instruction, a restart instruction, or a stop operation instruction such as stop video recording, an alignment rule in the non-volatile storage medium protocol may be used for the current file system metadata to be written in the non-volatile storage medium, and the current file system metadata and the file data to be written in the non-volatile storage medium are aligned with multiple storage physical units of the non-volatile storage medium, so that the data writing performance of the non-volatile storage medium is improved, and therefore, the jam is avoided.
Step S213, writing the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset alignment writing rule.
Specifically, the computer device may divide the current file system metadata and the to-be-written file data in the memory into n 32KByte data, and sequentially number the 1 st 32KByte data, the 2 nd 32KByte data, … …, and the nth 32KByte data according to the writing order, where the 1 st 32KByte data, the 2 nd 32KByte data, … …, and the nth 32KByte data are sequentially determined according to the sequence in which the to-be-written file data and the stored file data corresponding to the current file system metadata are written in the memory; or non-sequentially writing according to a preset rule of the file system, for example, pointing the first position of the 1 st 32KByte data to the next writable position in the form of a pointer, and writing the 2 nd 32KByte data at the next writable position, … …, until the nth 32KByte data is written; wherein the next writable location is not contiguous with the first location.
Then, the 1 st 32KByte data, the 2 nd 32KByte data, … … and the mth 32KByte data can be sequentially written in the 1 st storage physical unit, the m +1 st 32KByte data, the m +2 nd 32KByte data … … and the jth 32KByte data can be sequentially written in the 2 nd storage physical unit, the j +1 st 32KByte data, the j +2 nd 32KByte data … … and the f 32KByte data can be sequentially written in the 3 rd storage physical unit, … … and so on until all the n 32KByte data are written in the nonvolatile storage medium; wherein n, m, j and f are positive integers respectively, and n is more than or equal to f and j is more than or equal to m.
In this embodiment, when the computer device receives a power-down instruction or a restart instruction, the current file system metadata in the memory and the file data to be written are written into the nonvolatile storage medium according to the preset alignment write-in rule after the preset alignment write-in rule in the nonvolatile storage medium is acquired, so that the problem of stuttering and irregular data written from the memory to the nonvolatile storage medium under the condition that the memory of the computer device cannot cache more data is avoided, and the reliability and wide applicability of the computer device are improved.
Fig. 3 is a schematic flow chart of a data writing method based on a file system according to another embodiment, where this embodiment relates to a specific process of how computer equipment obtains updated file system metadata according to the file data to be written and the file system metadata received in a memory. On the basis of the above embodiment, optionally, step S211 may be implemented by the following sub-steps:
step S2111, obtaining a storage location of the target available storage space in the nonvolatile storage medium according to the target available storage space corresponding to the file data to be written received in the memory.
Specifically, when receiving a power-down instruction, a restart instruction, or a stop instruction corresponding to other stop operations such as stopping video recording, the computer device may obtain a target available storage space corresponding to currently received to-be-written file data in the memory, may obtain one target available storage space corresponding to the to-be-written file data when receiving one batch of to-be-written file data, and may obtain a plurality of target available storage spaces corresponding to a plurality of batches of to-be-written file data when receiving a plurality of batches of to-be-written file data, where the computer may obtain, according to the one target available storage space or the plurality of target available storage spaces, a storage location of the one target available storage space in the nonvolatile storage medium or a storage location of the plurality of target available storage spaces in the nonvolatile storage medium, where the storage location corresponds to the to-be-written file data in the nonvolatile storage medium.
Step S2112, according to the storage position, the available attribute of the target available storage space in the file system metadata is updated to the unavailable attribute, and the updated file system metadata is obtained.
Specifically, after acquiring the storage location of one target available storage space in the nonvolatile storage medium or the storage locations of a plurality of target available storage spaces in the nonvolatile storage medium, the computer device may update the available attribute of the target available storage space in the storage space distribution data of the file system metadata to the unavailable attribute; for example, the computer device may preset that the storage space distribution data of the file system metadata includes M management units, and the available storage space in the storage space distribution data includes a first management unit, a second management unit, … …, and an mth management unit1The management unit comprises a first management unit and a second management unit… …, M2Management unit, M1+M2The size of each management unit may be the same or different.
Moreover, the available attribute or the unavailable attribute of each memory management unit can be described by corresponding color identifiers, for example, the memory management unit corresponding to the available attribute is a green identifier, and the memory management unit corresponding to the unavailable attribute is a red identifier, so that when the computer device acquires the second management unit of the available storage space of the target available storage space in the storage space distribution data, the green identifier of the second management unit can be updated to the red identifier, and the updated storage space distribution data includes the first management unit, … …, and mth management unit at this time1-1 management unit, the unavailable storage space in the storage space distribution data comprising a first management unit, … …, Mth2+1 management unit.
In this embodiment, the computer device obtains a storage location of the target available storage space in the memory through the target available storage space corresponding to the to-be-written file data received in the memory, and updates an available attribute of the target available storage space in the file system metadata to an unavailable attribute according to the storage location, so as to achieve a purpose of updating the file system metadata in the memory according to the to-be-written file data written in the memory, which not only can improve fluency and continuity of the to-be-written file data written in the memory, but also can improve reliability and accuracy of writing data by the computer device.
Fig. 4 is a flowchart illustrating a data writing method based on a file system according to yet another embodiment, where this embodiment relates to a specific process of how a computer device writes the current file system metadata into a non-volatile storage medium according to the preset aligned writing rule. On the basis of the above embodiment, optionally, step S212 may be implemented by the following process:
step S2121, obtaining the maximum write-once length of the nonvolatile storage medium.
Specifically, the maximum write-once length may represent a maximum data amount allowed by the nonvolatile storage medium to be writable each time, for example, when the nonvolatile storage medium is an sd card and the preset alignment write rule is an RU size 32K alignment rule of an sd card protocol, the maximum write-once length of the nonvolatile storage medium may be set to be p times of 32Kbyte data; wherein p is a natural number other than 0.
Step S2122, determining the writing times corresponding to the total data volume according to the maximum writing length and the total data volume of the metadata of the current file system.
Specifically, the computer device may determine, according to a maximum write length of a nonvolatile storage medium at one time and a total data size of the current file system metadata, a number of times of writing corresponding to the total data size, that is, a maximum number of times of writing corresponding to the current file system metadata; for example, when the maximum write length of the nonvolatile storage medium at one time may be 32Kbyte × p, and the total data amount of the current file system metadata is 32Kbyte × n, the computer device may determine that the number of writes corresponding to the total data amount is n/p; wherein n > p.
And step S2123, writing the total data volume into a nonvolatile storage medium successively according to the writing times according to the preset alignment writing rule.
Specifically, the computer device may write the current file system metadata in the memory into the non-volatile storage medium according to the writing times according to the preset aligned writing rule, for example, when the total data amount of the current file system metadata in the memory is 32KByte × n, if the data length that each storage physical unit is allowed to write is 32KByte × p (that is, the data storage amount of each storage physical unit is the same as the maximum write length of the non-volatile storage medium at one time) and n/p is a positive integer, the n/p times of data corresponding to the 32KByte × n may be 32KByte × p, 32KByte × 2p, … …, and 32KByte × n/p in sequence, where the computer device may write the 1 st 32KByte × p data in the 32KByte × n into the 1 st storage physical unit, and write the 2 nd 32KByte × 2p data into the 2 nd storage physical unit, … …, until the n/p-th 32KByte × n data is written into the n/p-th storage physical unit.
The total data volume 32KByte × n of the current file system metadata in the memory may be sequentially numbered as 1 st 32KByte data, 2 nd 32KByte data, … …, and nth 32KByte data according to a writing sequence, and the 1 st 32KByte data, the 2 nd 32KByte data, … …, and the nth 32KByte data may be sequentially determined according to a sequence in which the current file system metadata is written in the memory; or non-sequentially writing according to a preset rule of the file system, for example, pointing the first position of the 1 st 32KByte data to the next writable position in the form of a pointer, and writing the 2 nd 32KByte data at the next writable position, … …, until the nth 32KByte data is written; wherein the next writable location is not contiguous with the first location.
In this embodiment, the computer device determines the write-in times corresponding to the total data size of the current file system metadata in the memory by obtaining the maximum write-in length of the nonvolatile storage medium once, and then sequentially writes the current file system metadata in the storage medium according to a preset aligned write-in rule and the write-in times, so as to improve the storage performance of the nonvolatile storage medium and reduce the maintenance cost of the data stored in the nonvolatile storage medium.
As an optional implementation manner of the foregoing embodiment, this embodiment relates to a specific process of how to ensure fluency and continuity of the current file system metadata when the computer device writes the current file system metadata and the file data to be written into the nonvolatile storage medium. On the basis of the foregoing embodiment, optionally, the method further includes:
when the current file system metadata are determined to be written into a nonvolatile storage medium in an aligned mode, executing synchronous operation aiming at the aligned file system metadata to obtain synchronous file metadata; the aligned file system metadata comprises current file system metadata which is aligned and written in a nonvolatile storage medium, and the synchronous file metadata is used for representing the fluency and the continuity of the current file system metadata.
Specifically, when receiving a power-down instruction, a restart instruction, or a stop instruction for stopping other stop operations such as video recording, the computer device may first align and write the current file system metadata and the file data to be written in the memory into the nonvolatile storage medium, and when determining that the write operation of aligning and writing the current file system metadata in the memory into the nonvolatile storage medium is completed, may perform a synchronization operation on the aligned file system metadata to ensure overall fluency and continuity of all file system metadata received by the nonvolatile storage medium, and then perform the power-down operation, the restart operation, or the stop other stop operations such as video recording.
For example, when the computer device is in poor heat dissipation, virus trojan damage, poor contact of a power socket, and the like, a user is required to execute a shutdown operation, the computer device may generate a shutdown instruction according to the shutdown operation, the memory may first align and write the current file system metadata and the file data to be written into the nonvolatile storage medium based on the shutdown instruction, and when the computer device determines that the write operation of writing the current file system metadata in the memory into the nonvolatile storage medium in alignment is completed, a synchronization operation may be executed for the aligned file system metadata, so that the computer device may read smooth and continuous file system metadata from the nonvolatile storage medium after being powered on next time.
Similarly, when the computer device crashes or is blue-screened under abnormal conditions such as system file damage and virus entry, a user is required to execute a restart operation at this time, the computer device can generate a restart instruction according to the restart operation, the memory can firstly align and write the current file system metadata and the file data to be written into the nonvolatile storage medium based on the restart instruction, and when the computer device determines that the write operation of aligning and writing the current file system metadata in the memory into the nonvolatile storage medium is finished, the memory can execute a synchronization operation for the aligned file system metadata, so that the computer device can read smooth and continuous file system metadata from the nonvolatile storage medium after being started again.
In the actual processing process, if the file data to be written is video data recorded for a certain specific scene, when the computer device writes the file data to be written into the target available storage space, there may be a problem that the capacity of the video data is increasingly large so that the capacity of the target available storage space is insufficient, and here, the computer device may detect whether a video file for the specific scene is stored in the stored file data, and if it is detected that the video file is stored in the stored file data, the video file and file system metadata corresponding to the video file may be deleted; on the contrary, if it is detected that the stored file data does not store the video file, the file data that is not used for a long time, which may be one year or two years, may be deleted, which is not limited herein. Therefore, in this embodiment, when the file data to be written is file data to be written with an ever-increasing storage capacity, the computer device writes all the current file system metadata and the file data to be written in the memory into the nonvolatile storage medium only in a stop operation scenario such as power failure, restart, or video stop, and also executes a synchronization operation on the aligned file system metadata only when it is determined in the nonvolatile storage medium that the write operation of writing the current file system metadata in the memory into the nonvolatile storage medium in alignment is completed, thereby ensuring the smoothness and continuity of the file system metadata received in the nonvolatile storage medium.
In this embodiment, when receiving a power-down instruction or a restart instruction, the computer device performs a synchronization operation on the current file system metadata and the file data to be written in the memory written in the nonvolatile storage medium and the file system metadata written in the aligned manner, and then performs a power-down operation or a restart operation, so as to avoid the problems of frame loss, stuck and the like caused when the current file system metadata in the memory is written in the nonvolatile storage medium, and thus ensure the overall fluency and continuity of the current file system metadata received by the nonvolatile storage medium.
Fig. 5 is a flowchart illustrating a data writing method based on a file system according to another embodiment, where this embodiment relates to a specific process of how a computer device performs a formatting operation according to a usage of a non-volatile storage medium. On the basis of the foregoing embodiment, optionally, the method further includes:
and step S31, acquiring historical record data of the nonvolatile storage medium, and judging whether the nonvolatile storage medium meets the preset formatting condition according to the historical record data.
The preset formatting condition may include that the current storage space of the non-volatile storage medium is occupied by a preset percentage and the storage space is insufficient. Alternatively, the preset percentage may be 70%.
Specifically, when the computer device is powered on and operated, the history data of the nonvolatile storage medium may be obtained first, and the history data may represent the currently occupied storage space of the nonvolatile storage medium. Therefore, the computer device determines whether the non-volatile storage medium meets the preset formatting condition according to the history data, which may be that the computer device determines whether the currently occupied storage space of the non-volatile storage medium reaches a preset percentage, and if it is determined that the currently occupied storage space of the non-volatile storage medium reaches the preset percentage (for example, greater than or equal to 70%), it may determine that the non-volatile storage medium meets the preset formatting condition, and then the process proceeds to step S32; on the contrary, if it is determined that the currently occupied storage space of the non-volatile storage medium does not reach the preset percentage (for example, less than 70%), at this time, the non-volatile storage medium may be considered not to satisfy the preset formatting condition, and the process proceeds to step S33.
And step S32, when the nonvolatile storage medium is determined to accord with the preset formatting condition according to the historical record data, performing formatting operation on the nonvolatile storage medium.
Specifically, when the computer device determines that the nonvolatile storage medium meets the preset formatting condition according to the history data, it may be considered that the current storage space of the nonvolatile storage medium is insufficient at this time, and in order to avoid performance slowing of the nonvolatile storage medium due to too long use, a formatting operation may be performed on the nonvolatile storage medium to restore the nonvolatile storage medium to a state close to a new nonvolatile storage medium, so as to improve the data reading performance and the data writing performance of the nonvolatile storage medium.
Step S33, when the non-volatile storage medium is determined not to accord with the preset formatting condition according to the historical record data, outputting prompt information; wherein the prompt message is used for prompting that the current storage space of the nonvolatile storage medium is enough and the formatting operation is not required to be executed.
Specifically, when the computer device determines that the nonvolatile storage medium does not meet the preset formatting condition according to the history data, it may be considered that the current storage space of the nonvolatile storage medium is sufficient at this time, and it is not necessary to perform the formatting operation with respect to the nonvolatile storage medium.
In the actual processing process, if the computer device only includes the data of the nonvolatile storage medium carried by the computer device when the computer device leaves the factory according to the history data, the nonvolatile storage medium can be considered to be used for the first time, and at this time, a formatting operation is executed for the nonvolatile storage medium, so that the data reading performance and the data writing performance of the nonvolatile storage medium are improved.
In this embodiment, the computer device acquires history data of the nonvolatile storage medium. Whether the nonvolatile storage medium meets the preset formatting condition or not is judged according to the historical record data, and whether the formatting operation needs to be executed for the nonvolatile storage medium or not is determined, so that the maintenance cost of the nonvolatile storage medium is reduced, the reading and writing data performances of the nonvolatile storage medium are improved, and the writing data performance of the computer equipment can be improved.
It should be understood that although the various steps in the flow charts of fig. 1-5 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1-5 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in FIG. 6, a file system based data writing apparatus is provided. As shown in fig. 6, the apparatus may specifically include: the device comprises a first acquisition module 11, a second acquisition module 12, a first processing module 13 and a first data writing module 14.
Specifically, the first obtaining module 11 may be configured to obtain the file system metadata from the memory when determining that a write instruction of file data to be written is received; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
the first processing module 12 may be configured to filter the file system metadata to determine a target available storage space;
the first data writing module 13 may be configured to write the file data to be written into the target available storage space.
The data writing device based on the file system may further include: the second data writing module 21.
Specifically, the second data writing module 21 may be configured to write the current file system metadata in the memory into the nonvolatile storage medium when a power failure instruction or a restart instruction is received.
The second data writing module 21 may specifically include: an update unit 211, an acquisition unit 212, and a data write unit 213.
Specifically, the updating unit 211 may be configured to, when a power-down instruction or a restart instruction is received, obtain updated file system metadata according to the file data to be written and the file system metadata received in the memory, and determine the updated file system metadata as the current file system metadata;
an obtaining unit 212, configured to obtain a preset alignment writing rule in a nonvolatile storage medium; the preset alignment writing rule represents an alignment mode of the current file system metadata and a storage physical unit in a nonvolatile storage medium;
the data writing unit 213 may be configured to write the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset alignment writing rule.
The updating unit 211 may specifically include: a first acquisition subunit 2111 and an update subunit 2112.
Specifically, the first obtaining subunit 2111 is configured to obtain, according to a target available storage space corresponding to the to-be-written file data received in the memory, a storage location of the target available storage space in the nonvolatile storage medium;
the updating subunit 2112, configured to update the available attribute of the target available storage space in the file system metadata to an unavailable attribute according to the storage location, so as to obtain updated file system metadata.
The data writing unit 213 may specifically include: a second acquisition subunit 2131, a determination subunit 2131, and a data writing subunit 2133.
Specifically, the second obtaining subunit 2131 may be configured to obtain a maximum write-once length of the nonvolatile storage medium.
Determining subunit 2131, which may determine, according to the maximum writing length and a total data size of the current file system metadata, a writing number corresponding to the total data size;
the data writing subunit 2133 may be configured to write the total data size into the nonvolatile storage medium sequentially according to the writing times according to the preset alignment writing rule.
The data writing unit 213 may further specifically include an execution subunit 2134, which is configured to, when it is determined that the current file system metadata is written in the nonvolatile storage medium in an aligned manner, perform a synchronization operation for the aligned file system metadata to obtain synchronized file metadata; the aligned file system metadata comprises current file system metadata which is aligned and written in a nonvolatile storage medium, and the synchronous file metadata is used for representing the fluency and the continuity of the current file system metadata.
The data writing device based on the file system may further include: a second acquisition module 31, a processing module 32 and an output module 33.
Specifically, the second obtaining module 31 may be configured to obtain history data of the nonvolatile storage medium, and determine whether the nonvolatile storage medium meets a preset formatting condition according to the history data.
The processing module 32 may be configured to perform a formatting operation on the non-volatile storage medium when it is determined that the non-volatile storage medium meets a preset formatting condition according to the history data.
The output module 33 may be configured to output a prompt message when it is determined that the nonvolatile storage medium does not meet the preset formatting condition according to the history data; wherein the prompt message is used for prompting that the current storage space of the nonvolatile storage medium is enough and the formatting operation is not required to be executed.
For specific limitations of the file system based data writing apparatus, reference may be made to the above limitations of the file system based data writing method, which are not described herein again. The respective modules in the above-described file system-based data writing apparatus may be wholly or partially implemented by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 7. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a file system based data writing method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
when a write-in instruction of file data to be written is determined to be received, acquiring file system metadata from a memory; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
screening the file system metadata to determine a target available storage space;
and writing the file data to be written into the target available storage space.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and when a power-down instruction or a restarting instruction is received, writing the current file system metadata in the memory into a nonvolatile storage medium.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
when a power failure instruction or a restart instruction is received, obtaining updated file system metadata according to the file data to be written and the file system metadata received in a memory, and determining the updated file system metadata as the current file system metadata;
acquiring a preset alignment writing rule in a nonvolatile storage medium; the preset alignment writing rule represents an alignment mode of the current file system metadata and a storage physical unit in a nonvolatile storage medium;
and writing the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset alignment writing rule.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring a storage position of a target available storage space in a nonvolatile storage medium according to the target available storage space corresponding to the file data to be written received in a memory;
and updating the available attribute of the target available storage space in the file system metadata into an unavailable attribute according to the storage position to obtain updated file system metadata.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring the maximum write-in length of the nonvolatile storage medium at one time;
determining the writing times corresponding to the total data volume according to the maximum writing length and the total data volume of the metadata of the current file system;
and according to the preset alignment writing rule, gradually writing the total data volume into a nonvolatile storage medium according to the writing times.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
when the current file system metadata are determined to be written into a nonvolatile storage medium in an aligned mode, executing synchronous operation aiming at the aligned file system metadata to obtain synchronous file metadata; the aligned file system metadata comprises current file system metadata which is aligned and written in a nonvolatile storage medium, and the synchronous file metadata is used for representing the fluency and the continuity of the current file system metadata.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring historical record data of a nonvolatile storage medium, and judging whether the nonvolatile storage medium meets a preset formatting condition according to the historical record data;
when the nonvolatile storage medium is determined to meet the preset formatting condition according to the historical record data, performing formatting operation on the nonvolatile storage medium;
when the fact that the nonvolatile storage medium does not accord with the preset formatting condition is determined according to the historical record data, outputting prompt information; wherein the prompt message is used for prompting that the current storage space of the nonvolatile storage medium is enough and the formatting operation is not required to be executed.
It should be clear that, in the embodiments of the present application, the process of executing the computer program by the processor is consistent with the process of executing the steps in the above method, and specific reference may be made to the description above.
In one embodiment, there is also provided a computer readable storage medium having a computer program stored thereon, the computer program when executed by a processor implementing the steps of:
when a write-in instruction of file data to be written is determined to be received, acquiring file system metadata from a memory; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
screening the file system metadata to determine a target available storage space;
and writing the file data to be written into the target available storage space.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and when a power-down instruction or a restarting instruction is received, writing the current file system metadata in the memory into a nonvolatile storage medium.
In one embodiment, the computer program when executed by the processor further performs the steps of:
when a power failure instruction or a restart instruction is received, obtaining updated file system metadata according to the file data to be written and the file system metadata received in a memory, and determining the updated file system metadata as the current file system metadata;
acquiring a preset alignment writing rule in a nonvolatile storage medium; the preset alignment writing rule represents an alignment mode of the current file system metadata and a storage physical unit in a nonvolatile storage medium;
and writing the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset alignment writing rule.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring a storage position of a target available storage space in a nonvolatile storage medium according to the target available storage space corresponding to the file data to be written received in a memory;
and updating the available attribute of the target available storage space in the file system metadata into an unavailable attribute according to the storage position to obtain updated file system metadata.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring the maximum write-in length of the nonvolatile storage medium at one time;
determining the writing times corresponding to the total data volume according to the maximum writing length and the total data volume of the metadata of the current file system;
and according to the preset alignment writing rule, gradually writing the total data volume into a nonvolatile storage medium according to the writing times.
In one embodiment, the computer program when executed by the processor further performs the steps of:
when the current file system metadata are determined to be written into a nonvolatile storage medium in an aligned mode, executing synchronous operation aiming at the aligned file system metadata to obtain synchronous file metadata; the aligned file system metadata comprises current file system metadata which is aligned and written in a nonvolatile storage medium, and the synchronous file metadata is used for representing the fluency and the continuity of the current file system metadata.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring historical record data of a nonvolatile storage medium, and judging whether the nonvolatile storage medium meets a preset formatting condition according to the historical record data;
when the nonvolatile storage medium is determined to meet the preset formatting condition according to the historical record data, performing formatting operation on the nonvolatile storage medium;
when the fact that the nonvolatile storage medium does not accord with the preset formatting condition is determined according to the historical record data, outputting prompt information; wherein the prompt message is used for prompting that the current storage space of the nonvolatile storage medium is enough and the formatting operation is not required to be executed.
It should be clear that, in the embodiments of the present application, the process of executing the computer program by the processor is consistent with the process of executing the steps in the above method, and specific reference may be made to the description above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. A method for writing data based on a file system, the method comprising:
when a write-in instruction of file data to be written is determined to be received, acquiring file system metadata from a memory; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
screening the file system metadata to determine a target available storage space;
and writing the file data to be written into the target available storage space.
2. The method as recited in claim 1, the method further comprising:
and when a power-down instruction or a restarting instruction is received, writing the current file system metadata in the memory into a nonvolatile storage medium.
3. The method of claim 2, wherein writing the current file system metadata in the memory to the non-volatile storage medium when the power down command or the reboot command is received comprises:
when a power failure instruction or a restart instruction is received, obtaining updated file system metadata according to the file data to be written and the file system metadata received in a memory, and determining the updated file system metadata as the current file system metadata;
acquiring a preset alignment writing rule in a nonvolatile storage medium; the preset alignment writing rule represents an alignment mode of the current file system metadata and a storage physical unit in a nonvolatile storage medium;
and writing the current file system metadata and the file data to be written into a nonvolatile storage medium according to the preset alignment writing rule.
4. The method according to claim 3, wherein obtaining updated file system metadata according to the file data to be written and the file system metadata received in the memory comprises:
acquiring a storage position of a target available storage space in a nonvolatile storage medium according to the target available storage space corresponding to the file data to be written received in a memory;
and updating the available attribute of the target available storage space in the file system metadata into an unavailable attribute according to the storage position to obtain updated file system metadata.
5. The method of claim 3, wherein writing the current file system metadata to a non-volatile storage medium according to the preset aligned write rule comprises:
acquiring the maximum write-in length of the nonvolatile storage medium at one time;
determining the writing times corresponding to the total data volume according to the maximum writing length and the total data volume of the metadata of the current file system;
and according to the preset alignment writing rule, gradually writing the total data volume into a nonvolatile storage medium according to the writing times.
6. The method of claim 3, wherein after the step of writing the current file system metadata and the file data to be written to a non-volatile storage medium according to the preset aligned write rule, the method further comprises:
when the current file system metadata are determined to be written into a nonvolatile storage medium in an aligned mode, executing synchronous operation aiming at the aligned file system metadata to obtain synchronous file metadata; the aligned file system metadata comprises current file system metadata which is aligned and written in a nonvolatile storage medium, and the synchronous file metadata is used for representing the fluency and the continuity of the current file system metadata.
7. The method according to claim 1, wherein before the step of obtaining the current state information when it is determined that the write command for the file data to be written is received, the method further comprises:
acquiring historical record data of a nonvolatile storage medium, and judging whether the nonvolatile storage medium meets a preset formatting condition according to the historical record data;
when the nonvolatile storage medium is determined to meet the preset formatting condition according to the historical record data, performing formatting operation on the nonvolatile storage medium;
when the fact that the nonvolatile storage medium does not accord with the preset formatting condition is determined according to the historical record data, outputting prompt information; wherein the prompt message is used for prompting that the current storage space of the nonvolatile storage medium is enough and the formatting operation is not required to be executed.
8. A data writing apparatus based on a file system, the apparatus comprising:
the first acquisition module is used for acquiring the metadata of the file system from the memory when determining that a write-in instruction of the file data to be written is received; wherein the file system metadata comprises storage space distribution data of currently available storage space and unavailable storage space of the nonvolatile storage medium and size information of stored file data;
the first processing module is used for screening the file system metadata to determine a target available storage space;
and the first data writing module is used for writing the file data to be written into the target available storage space.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor is adapted to carry out the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010237085.0A CN113467698A (en) | 2020-03-30 | 2020-03-30 | Writing method and device based on file system, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010237085.0A CN113467698A (en) | 2020-03-30 | 2020-03-30 | Writing method and device based on file system, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113467698A true CN113467698A (en) | 2021-10-01 |
Family
ID=77865018
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010237085.0A Pending CN113467698A (en) | 2020-03-30 | 2020-03-30 | Writing method and device based on file system, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113467698A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116700840A (en) * | 2023-08-03 | 2023-09-05 | 北京中电华大电子设计有限责任公司 | File execution method, device, electronic equipment and readable storage medium |
Citations (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101840380A (en) * | 2009-03-12 | 2010-09-22 | 马维尔国际贸易有限公司 | The protection metadata is avoided the apparatus and method of accident power-off influence |
CN102063380A (en) * | 2010-12-31 | 2011-05-18 | 北京握奇数据系统有限公司 | Method and device for writing data in non-volatile memory |
CN103106161A (en) * | 2012-12-22 | 2013-05-15 | 中国船舶重工集团公司第七0九研究所 | Display card basic input output system (BIOS) updating method based on input/output (IO) access mode |
WO2013091244A1 (en) * | 2011-12-23 | 2013-06-27 | 华为技术有限公司 | File system data storage method and access method and device therefor |
CN103744961A (en) * | 2014-01-06 | 2014-04-23 | 清华大学 | Method for prolonging service life of nonvolatile storage with reconfigurable file system directory tree |
US20140250155A1 (en) * | 2011-11-17 | 2014-09-04 | Huawei Technologies Co., Ltd. | Metadata storage and management method for cluster file system |
CN104238962A (en) * | 2014-09-16 | 2014-12-24 | 华为技术有限公司 | Method and device for writing data into cache |
US9020987B1 (en) * | 2011-06-29 | 2015-04-28 | Emc Corporation | Managing updating of metadata of file systems |
CN104820575A (en) * | 2015-04-27 | 2015-08-05 | 西北工业大学 | Method for realizing thin provisioning of storage system |
CN105302747A (en) * | 2014-07-11 | 2016-02-03 | 深圳市腾讯计算机系统有限公司 | Storage startup control method and storage startup control apparatus |
CN105353988A (en) * | 2015-11-13 | 2016-02-24 | 曙光信息产业(北京)有限公司 | Metadata reading and writing method and device |
CN105703945A (en) * | 2016-01-08 | 2016-06-22 | 烽火通信科技股份有限公司 | Optical network unit (ONU) upgrading method |
CN106126439A (en) * | 2007-07-25 | 2016-11-16 | 技佳科技有限公司 | Variable partition in mixing storage subsystem |
CN106873908A (en) * | 2017-01-17 | 2017-06-20 | 北京联想核芯科技有限公司 | Date storage method and device |
KR20170130180A (en) * | 2016-05-18 | 2017-11-28 | 에스케이텔레콤 주식회사 | Method and Apparatus for Processing Data Using Non-Volatile Memory |
US9880762B1 (en) * | 2015-12-30 | 2018-01-30 | EMC IP Holding Company LLC | Compressing metadata blocks prior to writing the metadata blocks out to secondary storage |
CN109213772A (en) * | 2018-09-12 | 2019-01-15 | 华东师范大学 | Date storage method and NVMe storage system |
CN109325373A (en) * | 2018-09-20 | 2019-02-12 | 郑州云海信息技术有限公司 | A kind of store method of metadata, device, equipment and readable storage medium storing program for executing |
US20190265899A1 (en) * | 2018-02-28 | 2019-08-29 | Micron Technology, Inc. | Meta data processing during startup of storage devices |
CN110187837A (en) * | 2019-05-30 | 2019-08-30 | 苏州浪潮智能科技有限公司 | A kind of file access method, device and file system |
CN110209341A (en) * | 2018-03-23 | 2019-09-06 | 腾讯科技(深圳)有限公司 | A kind of method for writing data, device and storage equipment |
CN110286853A (en) * | 2019-06-06 | 2019-09-27 | 大唐微电子技术有限公司 | A kind of method for writing data and device, computer readable storage medium |
CN110377436A (en) * | 2019-07-12 | 2019-10-25 | 清华大学 | Data storage access method, equipment and the device of persistence memory |
US20190377647A1 (en) * | 2018-06-11 | 2019-12-12 | Dell Products, Lp | Method and Apparatus for Ensuring Data Integrity in a Storage Cluster With the Use of NVDIMM |
US20200097367A1 (en) * | 2018-09-20 | 2020-03-26 | Samsung Electronics Co., Ltd. | Storage device and operating method of storage device |
-
2020
- 2020-03-30 CN CN202010237085.0A patent/CN113467698A/en active Pending
Patent Citations (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106126439A (en) * | 2007-07-25 | 2016-11-16 | 技佳科技有限公司 | Variable partition in mixing storage subsystem |
CN101840380A (en) * | 2009-03-12 | 2010-09-22 | 马维尔国际贸易有限公司 | The protection metadata is avoided the apparatus and method of accident power-off influence |
CN102063380A (en) * | 2010-12-31 | 2011-05-18 | 北京握奇数据系统有限公司 | Method and device for writing data in non-volatile memory |
US9020987B1 (en) * | 2011-06-29 | 2015-04-28 | Emc Corporation | Managing updating of metadata of file systems |
US20140250155A1 (en) * | 2011-11-17 | 2014-09-04 | Huawei Technologies Co., Ltd. | Metadata storage and management method for cluster file system |
WO2013091244A1 (en) * | 2011-12-23 | 2013-06-27 | 华为技术有限公司 | File system data storage method and access method and device therefor |
CN103106161A (en) * | 2012-12-22 | 2013-05-15 | 中国船舶重工集团公司第七0九研究所 | Display card basic input output system (BIOS) updating method based on input/output (IO) access mode |
CN103744961A (en) * | 2014-01-06 | 2014-04-23 | 清华大学 | Method for prolonging service life of nonvolatile storage with reconfigurable file system directory tree |
CN105302747A (en) * | 2014-07-11 | 2016-02-03 | 深圳市腾讯计算机系统有限公司 | Storage startup control method and storage startup control apparatus |
CN104238962A (en) * | 2014-09-16 | 2014-12-24 | 华为技术有限公司 | Method and device for writing data into cache |
CN104820575A (en) * | 2015-04-27 | 2015-08-05 | 西北工业大学 | Method for realizing thin provisioning of storage system |
CN105353988A (en) * | 2015-11-13 | 2016-02-24 | 曙光信息产业(北京)有限公司 | Metadata reading and writing method and device |
US9880762B1 (en) * | 2015-12-30 | 2018-01-30 | EMC IP Holding Company LLC | Compressing metadata blocks prior to writing the metadata blocks out to secondary storage |
CN105703945A (en) * | 2016-01-08 | 2016-06-22 | 烽火通信科技股份有限公司 | Optical network unit (ONU) upgrading method |
KR20170130180A (en) * | 2016-05-18 | 2017-11-28 | 에스케이텔레콤 주식회사 | Method and Apparatus for Processing Data Using Non-Volatile Memory |
CN106873908A (en) * | 2017-01-17 | 2017-06-20 | 北京联想核芯科技有限公司 | Date storage method and device |
US20190265899A1 (en) * | 2018-02-28 | 2019-08-29 | Micron Technology, Inc. | Meta data processing during startup of storage devices |
CN110209341A (en) * | 2018-03-23 | 2019-09-06 | 腾讯科技(深圳)有限公司 | A kind of method for writing data, device and storage equipment |
US20190377647A1 (en) * | 2018-06-11 | 2019-12-12 | Dell Products, Lp | Method and Apparatus for Ensuring Data Integrity in a Storage Cluster With the Use of NVDIMM |
CN109213772A (en) * | 2018-09-12 | 2019-01-15 | 华东师范大学 | Date storage method and NVMe storage system |
CN109325373A (en) * | 2018-09-20 | 2019-02-12 | 郑州云海信息技术有限公司 | A kind of store method of metadata, device, equipment and readable storage medium storing program for executing |
US20200097367A1 (en) * | 2018-09-20 | 2020-03-26 | Samsung Electronics Co., Ltd. | Storage device and operating method of storage device |
CN110187837A (en) * | 2019-05-30 | 2019-08-30 | 苏州浪潮智能科技有限公司 | A kind of file access method, device and file system |
CN110286853A (en) * | 2019-06-06 | 2019-09-27 | 大唐微电子技术有限公司 | A kind of method for writing data and device, computer readable storage medium |
CN110377436A (en) * | 2019-07-12 | 2019-10-25 | 清华大学 | Data storage access method, equipment and the device of persistence memory |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116700840A (en) * | 2023-08-03 | 2023-09-05 | 北京中电华大电子设计有限责任公司 | File execution method, device, electronic equipment and readable storage medium |
CN116700840B (en) * | 2023-08-03 | 2023-09-26 | 北京中电华大电子设计有限责任公司 | File execution method, device, electronic equipment and readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9501231B2 (en) | Storage system and storage control method | |
CN102521289B (en) | File synchronization method, device and system | |
JP2017079053A (en) | Methods and systems for improving storage journaling | |
CN109902034B (en) | Snapshot creating method and device, electronic equipment and machine-readable storage medium | |
CN109496292B (en) | Disk management method, disk management device and electronic equipment | |
CN109614055B (en) | Snapshot creating method and device, electronic equipment and machine-readable storage medium | |
CN106357703B (en) | Cluster switching method and device | |
CN113568582B (en) | Data management method, device and storage equipment | |
US20170083419A1 (en) | Data management method, node, and system for database cluster | |
EP1826663A2 (en) | Apparatus, method and computer program for processing information | |
CN115639971A (en) | Data writing method, data writing device, electronic device, storage medium, and program product | |
CN104866388B (en) | Data processing method and device | |
CN109683983B (en) | Method and equipment for generating and loading mirror image file | |
CN110147296B (en) | Data processing method, device, equipment and readable storage medium | |
US11487428B2 (en) | Storage control apparatus and storage control method | |
CN113467698A (en) | Writing method and device based on file system, computer equipment and storage medium | |
CN107148612A (en) | A kind of method and apparatus of extending user subregion | |
CN117131014A (en) | Database migration method, device, equipment and storage medium | |
CN115407943A (en) | Memory dump file generation method, device and equipment and readable storage medium | |
CN113849494A (en) | Data updating method and device | |
WO2022083190A1 (en) | Data downloading method and apparatus, computer device, and storage medium | |
CN115061858A (en) | Data persistence method and device, computer equipment and storage medium | |
CN114020308A (en) | Camera equipment upgrading method, device, equipment and medium | |
CN113934362A (en) | Data storage method and device, computer equipment and storage medium | |
US8935488B2 (en) | Storage system and storage control method |
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 |