WO2017185579A1 - 一种数据存储方法及装置 - Google Patents

一种数据存储方法及装置 Download PDF

Info

Publication number
WO2017185579A1
WO2017185579A1 PCT/CN2016/097775 CN2016097775W WO2017185579A1 WO 2017185579 A1 WO2017185579 A1 WO 2017185579A1 CN 2016097775 W CN2016097775 W CN 2016097775W WO 2017185579 A1 WO2017185579 A1 WO 2017185579A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage
data
stored
segment
target
Prior art date
Application number
PCT/CN2016/097775
Other languages
English (en)
French (fr)
Inventor
尹志新
Original Assignee
杭州海康威视数字技术股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 杭州海康威视数字技术股份有限公司 filed Critical 杭州海康威视数字技术股份有限公司
Publication of WO2017185579A1 publication Critical patent/WO2017185579A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0662Virtualisation aspects
    • G06F3/0665Virtualisation aspects at area level, e.g. provisioning of virtual or logical volumes

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a data storage method and apparatus.
  • computers read and write file data in the order of the physical address of the disk.
  • a large number of files are migrated and deleted, which causes the disk storage space to be fragmented.
  • the computer needs to perform data storage again, for example, when storing the target data, it is necessary to sequentially search for the free storage space in the order of the physical address on the disk, and determine whether the free storage space can store the target data, if not, Need to find the free storage space again to find the free storage space that can store the target data, and store the target data.
  • An object of the embodiments of the present application is to provide a data storage method and apparatus to reduce seek time and time.
  • the embodiment of the present application discloses a data storage method, which is applied to a terminal, where the terminal includes at least one disk, and the disk is divided into multiple virtual storage segments according to physical addresses, and corresponding to multiple virtual storage segments.
  • the physical address ranges do not coincide; the methods include:
  • Receiving a storage request for the data to be stored where the storage request includes: an identifier of the target file corresponding to the data to be stored;
  • a target virtual storage segment for storing the to-be-stored data, where the metadata storage segment is identified as a plurality of virtual storage segments.
  • Valued virtual storage segment for storing each virtual storage segment and stored files Correspondence between each other and the storage state of each virtual storage segment;
  • the data to be stored is stored starting from the initial storage location.
  • the determining, according to the identifier of the target file and the information stored in the metadata storage segment, the target virtual storage segment for storing the data to be stored including:
  • the determining, according to the first virtual storage segment, the target virtual storage segment for storing the to-be-stored data includes:
  • a virtual storage segment in which the data belonging to the target file is last stored in the first virtual storage segment is determined as a target virtual storage segment for the data to be stored.
  • the method further includes:
  • the determining, from the virtual storage segment that is closest to the physical address of the first virtual storage segment, the target virtual storage segment for storing the data to be stored including:
  • the storage mode is the first storage mode
  • the virtual storage segment that is closest to the physical address of the first virtual storage segment and does not store data is a target virtual storage segment for storing the data to be stored.
  • the first storage mode is: storing a text in a virtual storage segment Storage method of pieces;
  • the storage mode is the second storage mode
  • obtaining a second virtual storage segment that is closest to the physical address of the first virtual storage segment and the storage mode of the stored file is not the first storage mode
  • the second virtual storage segment is determined as a target virtual storage segment for storing the data to be stored, wherein the second storage manner is: a storage manner in which a plurality of files are stored in one virtual storage segment.
  • the method further includes:
  • the storage mode of the target file is determined as a first storage mode, where the first storage mode is: a storage mode in which one file is stored in one virtual storage segment;
  • the storage mode of the target file is determined to be a second storage mode, where the second storage mode is: a storage manner of storing multiple files in one virtual storage segment;
  • the method further includes:
  • the storage state of the target file is set to the stored state.
  • the method further includes:
  • the file to be created is created, and the storage state of the file to be created is set to an unstored state in the metadata storage segment, and the initial storage location of the data of the file to be created is rejected.
  • the disk includes multiple physical storage areas, where the physical storage area is The smallest physical storage unit of the disk;
  • the storing the data to be stored starting from the initial storage location includes:
  • the data to be stored is divided into data corresponding to each target physical storage area according to the determined available storage capacity of each target physical storage area and the amount of data, where the data to be stored is to be stored across regions. Piece;
  • the divided data blocks are respectively stored in corresponding target physical storage areas.
  • the embodiment of the present application further discloses a data storage device, which is applied to a terminal, where the terminal includes at least one disk, and the disk is divided into multiple virtual storage segments according to physical addresses, and multiple virtual storage segments are corresponding.
  • the physical address ranges do not coincide; the device includes:
  • a storage request receiving module configured to receive a storage request for the data to be stored, where the storage request includes: an identifier of the target file corresponding to the data to be stored;
  • a target virtual storage segment determining module configured to determine, according to the identifier of the target file and the information stored in the metadata storage segment, a target virtual storage segment for storing the to-be-stored data, where the metadata storage segment is A virtual storage segment that is identified as a preset value in the plurality of virtual storage segments, configured to store a correspondence between each virtual storage segment and the stored file and a storage state of each virtual storage segment;
  • a start storage location determining module configured to obtain a last storage location of data stored in the target virtual storage segment, and determine the obtained storage location as a starting storage location of the to-be-stored data
  • a data storage module configured to store the to-be-stored data from the initial storage location.
  • the target virtual storage segment determining module includes:
  • a first storage state determining submodule configured to determine, according to the identifier of the target file, whether the target file is in a stored state
  • a virtual storage segment obtaining submodule configured to determine a submodule determination result in the first storage state In the case of YES, according to the information stored in the metadata storage segment, obtaining a first virtual storage segment storing the target file;
  • a second storage state determining submodule configured to determine whether the first virtual storage segment is in a storable state
  • a first target virtual storage segment determining submodule configured to determine, according to the first virtual storage segment, a target virtuality for storing the to-be-stored data, in a case that the second storage state determining sub-module determining result is yes Storage segment.
  • the first target virtual storage segment determining submodule is specifically configured to determine, in the first virtual storage segment, a virtual storage segment that lastly stores data belonging to the target file, to be used for the waiting The target virtual bucket that stores the data.
  • the target virtual storage segment determining module further includes:
  • a second target virtual storage segment determining submodule configured to determine, from the virtual storage segment closest to the physical address of the first virtual storage segment, that the second storage state determination submodule determination result is negative a target virtual storage segment for storing the data to be stored.
  • the second target virtual storage segment determining submodule includes:
  • a storage mode obtaining unit configured to obtain a storage manner of the target file
  • a first target virtual storage segment determining unit configured to determine, in a case where the storage mode is the first storage mode, a virtual storage segment that is closest to a physical address of the first virtual storage segment and has no data stored for storage
  • the target virtual storage segment of the data to be stored wherein the first storage mode is: a storage manner in which a file is stored in one virtual storage segment;
  • a second target virtual storage segment determining unit configured to obtain, after the storage mode is the second storage mode, a physical address that is closest to the first virtual storage segment and a storage manner of the stored file is not the first a second virtual storage segment of the storage mode; the second virtual storage segment is determined as a target virtual storage segment for storing the data to be stored, wherein the second storage mode is: storing more in one virtual storage segment How files are stored.
  • the target virtual storage segment determining module further includes:
  • a first data amount obtaining submodule configured to determine a submodule judgment result in the first storage state In the case of NO, the amount of data of the data to be stored is obtained;
  • a data amount determining submodule configured to determine whether the obtained data amount is greater than a preset data amount
  • the first storage mode determining sub-module is configured to determine, according to the determination result of the data quantity determining sub-module, that the storage mode of the target file is the first storage mode, where the first storage mode is: A virtual storage segment stores a file storage manner;
  • a second storage mode determining submodule configured to determine, in the case that the data volume determining submodule determination result is negative, that the storage mode of the target file is a second storage mode, wherein the second storage mode is: A storage method in which a plurality of files are stored in one virtual storage segment;
  • a third target virtual storage segment determining submodule configured to determine, according to the determined storage manner, a target virtual storage segment for storing the to-be-stored data
  • the device also includes:
  • a storage status setting module configured to set a storage state of the target file to a stored state.
  • the device further includes:
  • Creating an instruction receiving module configured to receive a file creation instruction for the file to be created
  • a file creation module configured to create the file to be created, and set a storage state of the file to be created to an unstored state in the metadata storage segment, and refuse to determine a starting storage of data of the file to be created position.
  • the disk includes multiple physical storage areas, where the physical storage area is a minimum physical storage unit of the disk;
  • the data storage module includes:
  • a second data amount obtaining submodule configured to obtain the data amount of the data to be stored
  • a storage area determining submodule configured to determine, according to the amount of data, each target physical storage area where the data to be stored is to be stored;
  • a data block dividing sub-module configured to divide the data to be stored into and according to the determined available storage capacity of each target physical storage area and the amount of data, where the data to be stored is to be stored across regions a data block corresponding to each target physical storage area;
  • the data block storage sub-module is configured to store the divided data blocks into corresponding target physical storage areas.
  • an embodiment of the present application further discloses a terminal, the terminal comprising: a housing, a processor, a memory, a circuit board, and a power supply circuit, wherein the circuit board is disposed in the housing Inside the space, the processor and the memory are disposed on the circuit board; the power circuit is configured to supply power to each circuit or device of the terminal; the memory is configured to store executable program code; The processor executes the data storage method described above by running executable program code stored in the memory.
  • an embodiment of the present application further discloses an executable program code for executing the above data storage method at runtime.
  • the embodiment of the present application further discloses a storage medium for storing executable program code, and the executable program code is executed to execute the data storage method described above.
  • the terminal receives the storage request for the data to be stored, and determines, according to the identifier of the target file corresponding to the data to be stored and the information stored in the metadata storage segment, that the storage request is used to store the to-be-stored data. And storing a target virtual storage segment of the data, obtaining a storage location of the end of the data stored in the target virtual storage segment, and determining the obtained storage location as a starting storage location of the data to be stored, and storing the to-be-stored storage location from the initial storage location Storing data.
  • FIG. 1 is a schematic flowchart diagram of a data storage method according to an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of a virtual storage segment according to an embodiment of the present disclosure
  • FIG. 3 is a schematic diagram of metadata arrangement in a metadata storage segment according to an embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart diagram of another data storage method according to an embodiment of the present disclosure.
  • FIG. 5 is a schematic flowchart diagram of another data storage method according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic flowchart of a method for allocating a virtual storage segment according to an implementation of the present application
  • FIG. 7 is a schematic structural diagram of a data storage device according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of another data storage device according to an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of another data storage device according to an embodiment of the present disclosure.
  • FIG. 10 is a schematic structural diagram of a terminal according to an embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a data storage method according to an embodiment of the present disclosure.
  • the terminal is applied to a terminal, where the terminal includes at least one disk, and the disk can be divided into multiple virtual storage segments according to physical addresses, and multiple virtual storages.
  • the physical address ranges corresponding to the segments do not overlap; the method may include the following steps:
  • the storage request includes: an identifier of the target file corresponding to the data to be stored.
  • the storage request may further include information such as the amount of data to be stored, which is not limited in this application.
  • S102 Determine, according to the identifier of the target file corresponding to the data to be stored included in the storage request and the information stored in the metadata storage segment, a target virtual storage segment for storing the data to be stored;
  • the metadata storage segment is a virtual storage segment that is identified as a preset value in the plurality of virtual storage segments, and is used for storing a correspondence between each virtual storage segment and the stored file and a storage state of each virtual storage segment.
  • the storage state of the virtual storage segment includes a storable state and a non-storable state.
  • the above preset values may be 0, 1, 2, etc., and the application does not limit this.
  • the file system before storing any data in the disk, the file system needs to be formatted to determine the type of the disk, thereby determining the size of the physical address segment corresponding to each Vzone (virtual storage segment).
  • the disk is divided into multiple Vzones according to the physical address.
  • the file system uses these Vzones as the minimum storage management unit of the disk, and determines the storage location of the data to be stored according to the Vzone.
  • the size of the physical address segment corresponding to each Vzone is equal to the size of the actual physical storage area.
  • the Host Manage disk or the Host Aware disk is SMR (Shingled Magnetic Recording).
  • SMR Single Magnetic Recording
  • a type of disk, SMR disks are divided into Host Manage, Host Aware and Drive Manage.
  • Host Manage is a disk that is controlled by the host to read and write.
  • Host Aware is A disk that is controlled by the host to read and write, which supports random write operations, but write performance is degraded during random write operations;
  • Drive Manage is a disk that is read and written by disk control, which supports random write operations; the SMR disk The read and write object refers to the actual physical address of the disk;
  • the determined disk type is not Host Manage and Host Aware, you can determine the size of the physical address segment corresponding to each Vzone according to the actual data storage requirements. For example, when a large data file is frequently stored on the disk, the Vzone can be mapped. The size of the physical address segment is set larger. When a file with small data is often stored on the disk, the size of the physical address segment corresponding to the Vzone can be set smaller.
  • the file system divides the physical address of the disk into a plurality of num(X) to num(X+1) segments, as shown in FIG. 2, and FIG. 2 is a A schematic diagram of a virtual storage segment, wherein num(x) and num(x+1) each represent a different physical address, that is, num(x) to num(x+1) are one physical address segment; each physical address The segment corresponds to a Vzone.
  • the physical address segment corresponding to the Vzone0 can be different in size from the physical address segment corresponding to the other Vzones, and can be randomly written; Vzone1-Vzonex
  • the physical address segments are equal in size and can only be written sequentially in this area.
  • the correspondence between the file and the Vzone is: one-to-many, that is, the data of one file can be stored in multiple Vzones.
  • the correspondence between the file and the Vzone can also be: many-to-one, that is, a Vzone can also be stored. Multiple files.
  • Vzone0 stores metadata
  • Vzone1-Vzonex stores file data, which facilitates centralized allocation of metadata and data areas, and avoids fragmentation of data stored on the disk.
  • the metadata storage segment is used to store metadata.
  • the metadata may include: reserved space, super block, super block backup, file index, file index backup, file index bitmap, Vzone bitmap, Vzone bitmap. Backup, Vzone descriptor, Vzone descriptor backup and mapping table; other Vzones are used to store actual file data.
  • FIG. 3 is a schematic diagram of metadata arrangement in a metadata storage segment according to an embodiment of the present disclosure, where
  • Boot block reserved space for storing disk partition information, etc.
  • Super block The information about the file system, including the number of the Vzone to which the current file system is assigned, the total number of Vzones, the total number of idle Vzones, the threshold of multiple files for a single zone, and the file system.
  • the maximum number of files that is, the number of file index inodes), wherein one file index corresponds to one file; in addition, the super block back is a backup of the area;
  • Vzone bitmap Each bit represents a Vzone, 1 means used, 0 means unused; in addition, Vzone bitmap back is the backup of the area;
  • File index bitmap (Inode bitmap) : Each bit represents a file, 1 means used, 0 means unused; when the file is created, it will look up the bitmap, and assign the index number from small to large each time according to the bitmap;
  • File index (Inode): describes the file information, including the starting physical address of the mapping table.
  • the file index also records the corresponding way of the file and Vzone, that is, a Vzone corresponds to multiple files (multi) or a Vzone can only Owned by a file (only); contains the number of the Vzone used by the current file; in addition, the file index backup (Inode back) is a backup of the area;
  • Mapping table (hik map): records the correspondence between the logical address of each file and the physical address of the disk;
  • Vzone description describes the number of users (files) of the current Vzone; describes the location of the current Vzone write pointer; in addition, the Vzone description back is the backup of the zone.
  • the present application is only described by taking the above as an example, and does not limit the order of the above metadata and the size of the occupied space, and only indicates that the metadata is recorded in Vzone0; in addition, the super block stores the idle Vzone.
  • the number of idle Vzones recorded in the Vzone bitmap The number can be quickly obtained for the target Vzone.
  • the target Vzone for storing the data to be stored may be determined according to the foregoing information stored in the metadata storage segment.
  • S103 Obtain a last storage location of data stored in the target virtual storage segment, and determine the obtained storage location as a starting storage location of the data to be stored;
  • the target virtual storage segment is the number of the Vzone to which the current file system is recorded in the superblock
  • the initial storage location of the data to be stored may be determined according to the location of the Vzone write pointer recorded in the Vzone descriptor.
  • the location of the current Vzone write pointer is the end storage location of the data stored in the current Vzone.
  • S104 Store data to be stored starting from a starting storage location.
  • the disk of the terminal may contain multiple physical storage area zones.
  • the zone is the smallest physical storage unit of the disk, and the data storage algorithm of the zone of each disk is different. Therefore, the data to be stored is not allowed to cross. Zone storage.
  • step S104 may include:
  • S02. Determine, according to the amount of data of the data to be stored, each target physical storage area where the data to be stored is to be stored;
  • the target Vzone to be stored is determined, because the Vzone has a corresponding relationship with the zone, and then the target zones for storing the data to be stored are determined.
  • the data volume of the data to be stored a is 100 kB
  • the determined target Vzone is Vzone1.
  • the storage space of the Vzone1 corresponding to the data to be stored corresponds to zone1 and zone2, so that the target physical storage area is zone1 and zone2.
  • the data to be stored is to be stored across the area, the data to be stored is divided into data corresponding to each target physical storage area according to the determined available storage capacity of each target physical storage area and the amount of data to be stored. Piece;
  • step S02 it can be determined that the data to be stored a is to be stored across regions. It is assumed that the available storage capacity of zone1 is 30 kB, and the available storage capacity of zone 2 is 80 kB, and the physical of zone1 corresponds to The address segment is in the front, and the physical address segment corresponding to zone2 is behind. Therefore, the data to be stored a is divided into a data block with a data volume of 30 kB and a data block of 70 kB.
  • the data to be stored may be directly stored from the initial storage location.
  • the plurality mentioned in the present application is at least two.
  • the terminal receives the storage request for the data to be stored, and determines, according to the identifier of the target file corresponding to the to-be-stored data and the information stored in the metadata storage segment, that the storage request is used to store the to-be-stored data. And storing a target virtual storage segment of the data, obtaining a storage location of the end of the data stored in the target virtual storage segment, and determining the obtained storage location as a starting storage location of the data to be stored, and storing the to-be-stored storage location from the initial storage location Storing data.
  • FIG. 4 is a schematic flowchart of another data storage method according to an embodiment of the present disclosure.
  • the terminal is applied to a terminal, where the terminal includes at least one disk, and the disk can be divided into multiple virtual storage segments according to physical addresses, and multiple virtual disks.
  • the physical address ranges corresponding to the storage segments do not overlap.
  • step S102 may include the following steps:
  • the foregoing data storage method may further include:
  • a file for the data needs to be created first.
  • the process of copying a data a is: creating a file A for the data a and storing the data a into the file A.
  • a file index inode for each file is stored in the metadata storage segment, and the Inode includes a correspondence between the file and the Vzone corresponding to the file. If only the file A is created, the data is not stored in the file A. , only need to assign an index number to the file A, and there is no need to allocate a Vzone for the file A, that is, there is no need to allocate a physical address segment for the file A, and thus it is not determined to store the initial storage location of the file A, thereby reducing The file that does not store data occupies storage space and reduces the workload of the terminal.
  • the number of the Vzone corresponding to the file A in the Inode is set to indicate an unassigned value, such as -1.
  • the terminal when the terminal stores the data, if the identifier of the target file corresponding to the data to be stored is not the same as the number of the corresponding Vzone in the inode, it can be considered as being in the stored state and in the stored state.
  • the data a of the file A is preferably stored in the adjacent area of the other data belonging to the file A, so that the terminal can obtain the data of the file A; if the identifier of the target file corresponds to the Vzone number is -1 In the case of the data in the unstorage state, it is only necessary to obtain the area in which the data a can be stored. In order to quickly store the data, the current Vzone can be obtained in the metadata storage section.
  • Vzone corresponding to the number of the Vzone to which the current file system is located in the superblock mentioned in the above step S102
  • Vzone is fine.
  • S1022 Obtain a first virtual storage segment of the storage target file according to the information stored in the metadata storage segment;
  • the number of the first virtual storage segment corresponding to the identifier of the target file may be obtained from the inode stored in the metadata storage segment, thereby determining the first storage target file.
  • Virtual storage segment a mapping between the number of the first virtual storage segment corresponding to the identifier of the target file.
  • the first virtual storage segment may be determined to be in a non-storable state, and otherwise in a storable state.
  • the obtained first virtual storage segment may be one or multiple.
  • S1024 Determine, according to the first virtual storage segment, a target virtual storage segment for storing data to be stored;
  • the determining, by using the first virtual storage segment, the target virtual storage segment for storing data to be stored may include:
  • the virtual storage segment in which the data belonging to the target file is last stored in the first virtual storage segment is determined as the target virtual storage segment for the data to be stored.
  • Vzone2 is the virtual storage segment of the data of the last stored file A. Therefore, it is determined that Vzone2 is used for data to be stored.
  • the target virtual bucket ensures that the data of the same file is stored in the order of physical addresses, which is convenient for the terminal to quickly and accurately obtain the data of the same file.
  • Vzone1 and/or Vzone2 when Vzone1 and/or Vzone2 are in a storable state, the data of file A can be updated, and the data of file A stored in Vzone2 is updated to Vzone1. If Vzone1 is still in a storable state after updating, it indicates that file A is The data is stored in the Vzone1, and the Vzone1 is determined to be the target virtual storage segment for the data to be stored. If the Vzone1 is not in the storage state after the update, and the file A data is also stored in the Vzone2, it can be determined that the Vzone2 is used for The target virtual storage segment of the data to be stored. This ensures that the data of the same file can be stored in adjacent areas, and the fragmentation of data storage in the terminal can be effectively avoided.
  • S1025 Determine, from the virtual storage segment closest to the physical address of the first virtual storage segment, a target virtual storage segment for storing data to be stored.
  • the terminal searches according to the information stored in the metadata storage segment according to the Vzone number from the smallest to the largest, that is, according to the physical address from the front to the back, starting from the number of the first virtual storage segment and searching backward.
  • the target virtual storage segment is determined by storing the number of the virtual storage segment of the data to be stored.
  • the determining, from the virtual storage segment that is closest to the physical address of the first virtual storage segment, the target virtual storage segment for storing the data to be stored may include:
  • the storage manner of each file stored in the metadata storage segment of the terminal is stored. Only when the storage mode of the target file is determined, how to store the data to be stored in the target file, and then determine the data to be stored.
  • Target virtual storage segment includes: the first storage mode is: storing a file in a virtual storage segment; and the second storage mode is: storing a plurality of files in a virtual storage segment.
  • the storage mode is the first storage mode, determine that the virtual storage segment that is closest to the physical address of the first virtual storage segment and does not store data is a target virtual storage segment for storing data to be stored.
  • the Vzone bitmap marked as an unused Vzone in the metadata storage segment If the number of users of the free virtual storage segment A recorded in the Vzone descriptor is 0, the virtual storage segment A may be determined to be The target virtual storage segment; when the number of users in the virtual storage segment A is not 0, continue to look for the idle virtual storage segment B backward.
  • the Vzone bitmap in the metadata storage segment is marked as a used Vzone, and data not in the file is prevented from being written into the Vzone.
  • the data storage of the first storage mode can be divided into two types:
  • the number of the idle virtual storage segment A is the position of the number of the first virtual storage segment in the metadata storage segment, and it can be determined that the virtual storage segment A is the target virtual storage segment.
  • the number of users in the virtual storage segment A is increased by 1. If the number of users in the virtual storage segment A is greater than a threshold, the threshold is determined by a single zone in the superblock corresponding to a threshold of multiple files.
  • the Vzone bitmap of the metadata storage segment is marked as the used Vzone, and the same Vzone is prevented from being written to the data multiple times, resulting in abnormal data of the surrounding Vzone, for example, data of the surrounding Vzone. Being magnetized.
  • the target file is in the stored state, and the first virtual of the storage target file is obtained according to the information stored in the metadata storage segment.
  • the storage segment determines whether the first virtual storage segment is in a storable state, and if in the storable state, determines a target virtual storage segment for storing data to be stored according to the first virtual storage segment, and if it is in a non-storable state, In the virtual storage segment where the physical address of the virtual storage segment is closest, the target virtual storage segment for storing the data to be stored is determined. In this way, the data of the same file is stored in the most recent virtual storage segment that can be stored, which reduces the time required for seeking, and ensures that the terminal can quickly and accurately obtain the data of the same file.
  • FIG. 5 is a schematic flowchart of another data storage method according to an embodiment of the present disclosure.
  • the terminal is applied to a terminal, where the terminal includes at least one disk, and the disk may be divided into multiple virtual storage segments according to physical addresses, and multiple virtual disks.
  • the physical address range corresponding to the storage segment does not overlap; in the case that the target file is not stored, the method may further include the following steps:
  • the data amount of the data to be stored may be obtained according to the data to be stored; of course, the data amount of the data to be stored may be included in the storage request.
  • step S1027 may be directly performed according to the data amount.
  • step S1027 It is determined whether the obtained data amount is greater than the preset data amount, if it is greater than the preset data amount, step S1028 is performed, if it is not greater than the preset data amount, step S1029 is performed;
  • the target file corresponding to the data to be stored may be considered as a big data file.
  • the target file is stored.
  • the mode is determined as the first storage mode, and the big data file is stored in multiple Vzones, which affects the reading of the target file by the terminal.
  • the target file corresponding to the data to be stored may be considered as a small data file.
  • the storage mode of the target file is determined as the second storage mode. Avoid small data files occupying a Vzone, causing waste of storage space.
  • S10210 Determine, according to the determined storage manner, a target virtual storage segment for storing data to be stored.
  • the number of the current virtual storage segment (the number of the Vzone to which the current file system is assigned) is obtained in the metadata storage segment, and the number of the current virtual storage segment is The location starts, and the number of the virtual storage segment A that is idle and the number of users is 0 is searched backwards, and the virtual storage segment A is determined to be the target virtual storage segment.
  • the number of the Vzone1 to which the first storage mode is assigned is obtained in the metadata storage segment, and the number of users in the Vzone1 is 0 or the number of users in the Vzone1 exceeds the threshold.
  • the Vzone2 is the target virtual storage segment.
  • the number of users in Vzone1 is not If the number of users of 0 or Vzone1 does not exceed the threshold, the Vzone1 is directly determined as the target virtual storage segment. In this way, the Vzone with the number of users of 0 is occupied, which affects the data storage of the file in the first storage mode.
  • FIG. 6 is a schematic flowchart of a method for allocating a virtual storage segment according to an implementation of the present application, which may include the following steps:
  • the number of free Vzones is recorded in the super block. If the super block does not contain an idle Vzone, an error is returned.
  • the number of the Vzone to which the file system was last assigned is the number of the current Vzone recorded in the metadata storage segment.
  • the number of free Vzones is reduced by the number of allocated Vzones, and the Vzone number (the current Vzone number) that was last allocated by the file system is updated for use in the next allocation.
  • the method may further include:
  • the corresponding relationship between the identifier of the target file and the number of the Vzone is stored in the inode.
  • the terminal stores the data of the target file again, and the number of the corresponding Vzone is read, it can be determined that the target file is in the stored state.
  • the terminal obtains the data amount of the data to be stored, and determines whether the obtained data amount is greater than the preset data amount. If the data volume is greater than the preset data amount, determining that the storage method of the target file is the first storage mode, if The storage mode of the target file is determined to be the second storage mode, and the target virtual storage segment for storing the data to be stored is determined according to the determined storage manner. In this way, centralized storage of data of big data files is effectively ensured, and the problem that small data file storage wastes storage space is avoided.
  • FIG. 7 is a schematic structural diagram of a data storage device according to an embodiment of the present disclosure, which is applied to a terminal, where the terminal includes at least one disk, and the disk is divided into multiple virtual storage segments according to physical addresses, and multiple virtual storage segments.
  • the corresponding physical address ranges do not coincide; the device may include:
  • the storage request receiving module 701 is configured to receive a storage request for the data to be stored, where the storage request includes: an identifier of the target file corresponding to the data to be stored;
  • the target virtual storage segment determining module 702 is configured to determine, according to the identifier of the target file and the information stored in the metadata storage segment, a target virtual storage segment for storing data to be stored, where the metadata storage segment is a plurality of virtual storage segments.
  • a virtual storage segment that is identified as a preset value, and is used for storing a correspondence between each virtual storage segment and a stored file and a storage state of each virtual storage segment;
  • the initial storage location determining module 703 is configured to obtain a storage location of the end of the data stored in the target virtual storage segment, and determine the obtained storage location as a starting storage location of the data to be stored;
  • the data storage module 704 is configured to store data to be stored starting from a starting storage location.
  • the disk includes multiple physical storage areas, where the physical storage area is the smallest physical storage unit of the disk;
  • the data storage module 704 can include:
  • a second data amount obtaining submodule configured to obtain a data amount of data to be stored
  • a storage area determining submodule configured to determine, according to the amount of data, each target physical storage area where the data to be stored is to be stored;
  • a data block dividing sub-module configured to divide the data to be stored into corresponding physical storage areas of each target according to the determined available storage capacity and data amount of each target physical storage area, where the data to be stored is to be stored across regions Data block
  • the data block storage sub-module is configured to separately store the divided data blocks into corresponding target physical storage areas (not shown in FIG. 7).
  • the terminal receives the storage request for the data to be stored, and determines, according to the identifier of the target file corresponding to the data to be stored and the information stored in the metadata storage segment, that the storage request is used to store the to-be-stored data. And storing a target virtual storage segment of the data, obtaining a storage location of the end of the data stored in the target virtual storage segment, and determining the obtained storage location as a starting storage location of the data to be stored, and storing the to-be-stored storage location from the initial storage location Storing data.
  • FIG. 8 is a schematic structural diagram of another data storage device according to an embodiment of the present application.
  • the device is applied to the terminal, the terminal includes at least one disk, and the disk is divided into multiple virtual storage segments according to the physical address, and the physical address ranges corresponding to the multiple virtual storage segments are not coincident;
  • the target virtual storage segment determining module 702 includes:
  • the first storage state determining sub-module 7021 is configured to determine, according to the identifier of the target file, whether the target file is in a stored state;
  • the virtual storage segment obtaining sub-module 7022 is configured to obtain, according to the information stored in the metadata storage segment, the first virtual storage segment of the storage target file, if the first storage state determination sub-module determines that the result is YES;
  • the second storage state determining sub-module 7023 is configured to determine whether the first virtual storage segment is in a storable state
  • a first target virtual storage segment determining sub-module 7024 configured to determine, according to the first virtual storage segment, a target virtual storage segment for storing data to be stored, if the second storage state determining sub-module determines that the result is YES;
  • the second target virtual storage segment determining sub-module 7025 is configured to determine, from the virtual storage segment closest to the physical address of the first virtual storage segment, that the second storage state determination sub-module determines that the result is negative.
  • the first target virtual storage segment determining sub-module 7024 is specifically configured to determine, in the first virtual storage segment, the virtual storage segment of the data that belongs to the target file for the last time, to be used for storage.
  • the target virtual storage segment of the data is specifically configured to determine, in the first virtual storage segment, the virtual storage segment of the data that belongs to the target file for the last time, to be used for storage.
  • the second target virtual storage segment determining submodule 7025 may include:
  • a storage mode obtaining unit for obtaining a storage method of the target file
  • a first target virtual storage segment determining unit configured to determine, in a storage mode that is the first storage mode, that the virtual storage segment that is closest to the physical address of the first virtual storage segment and that does not store data is used to store data to be stored.
  • a target virtual storage segment wherein the first storage mode is: storing a file in a virtual storage segment;
  • a second target virtual storage segment determining unit configured to be in a storage mode of the second storage mode And obtaining a second virtual storage segment that is closest to the physical address of the first virtual storage segment and the storage manner of the stored file is not the first storage manner; determining the second virtual storage segment as the target virtual storage for storing the data to be stored A segment, wherein the second storage mode is: storing a plurality of files in a virtual storage segment.
  • the data storage device may further include:
  • Creating an instruction receiving module configured to receive a file creation instruction for the file to be created
  • a file creation module configured to create a file to be created, and set a storage state of the file to be created to an unstored state in the metadata storage segment, and reject a starting storage location of the data of the file to be created (not shown in FIG. 8) ).
  • the target file is in the stored state, and the first virtual of the storage target file is obtained according to the information stored in the metadata storage segment.
  • the storage segment determines whether the first virtual storage segment is in a storable state, and if in the storable state, determines a target virtual storage segment for storing data to be stored according to the first virtual storage segment, and if it is in a non-storable state, In the virtual storage segment where the physical address of the virtual storage segment is closest, the target virtual storage segment for storing the data to be stored is determined. In this way, the data of the same file is stored in the most recent virtual storage segment that can be stored, which reduces the time required for seeking, and ensures that the terminal can quickly and accurately obtain the data of the same file.
  • FIG. 9 is a schematic structural diagram of another data storage device according to an embodiment of the present disclosure.
  • the terminal is applied to a terminal, where the terminal includes at least one disk, and the disk is divided into multiple virtual storage segments according to physical addresses, and multiple virtual storages are used.
  • the physical address range corresponding to the segment does not overlap; in the device, the target virtual storage segment determining module 702 may include:
  • a first data amount obtaining sub-module 7026 configured to obtain a data amount of data to be stored if the first storage state determining sub-module determining result is negative;
  • the data amount determining sub-module 7027 is configured to determine whether the obtained data amount is greater than a preset data amount
  • the first storage mode determining sub-module 7028 is configured to determine, according to the determination result of the data quantity determining sub-module, that the storage mode of the target file is the first storage mode, where the first storage mode is: in a virtual storage segment Store how a file is stored;
  • the second storage mode determining sub-module 7029 is configured to determine that the storage mode of the target file is the second storage mode, where the second storage mode is: in a virtual storage segment. Store how multiple files are stored;
  • the third target virtual storage segment determining sub-module 70210 is configured to determine, according to the determined storage manner, a target virtual storage segment for storing data to be stored.
  • the data storage device may further include:
  • a storage status setting module is configured to set a storage state of the target file to a stored state (not shown in FIG. 9).
  • the terminal obtains the data amount of the data to be stored, and determines whether the obtained data amount is greater than the preset data amount. If the data volume is greater than the preset data amount, determining that the target file is stored in the first storage mode.
  • the storage mode of the target file is determined to be the second storage mode, and the target virtual storage segment for storing the data to be stored is determined according to the determined storage manner. In this way, centralized storage of data of big data files is effectively ensured, and the problem that small data file storage wastes storage space is avoided.
  • the embodiment of the present application provides a terminal, where the terminal includes: a housing 1001, a processor 1002, a memory 1003, a circuit board 1004, and a power circuit 1005, wherein the circuit board 1004 is disposed at the Inside the space enclosed by the housing 1001, the processor 1002 and the memory 1003 are disposed on the circuit board 1004; the power circuit 1005 is configured to supply power to each circuit or device of the terminal;
  • the memory 1003 is configured to store executable program code; the processor 1002 performs the following steps by running executable program code stored in the memory 1003:
  • Receiving a storage request for the data to be stored where the storage request includes: an identifier of the target file corresponding to the data to be stored;
  • a target virtual storage segment for storing the to-be-stored data, where the metadata storage segment is identified as a plurality of virtual storage segments.
  • the virtual storage segment of the value is used to store the correspondence between each virtual storage segment and the stored file and the storage state of each virtual storage segment;
  • the data to be stored is stored starting from the initial storage location.
  • the terminal receives the storage request for the data to be stored, and determines, according to the identifier of the target file corresponding to the data to be stored and the information stored in the metadata storage segment, that the storage request is used for storage.
  • the target virtual storage segment of the data to be stored obtains the end storage location of the data stored in the target virtual storage segment, and determines the obtained storage location as the initial storage location of the data to be stored, and stores the storage location from the initial storage location.
  • the data to be stored In this way, it is not necessary to find the free storage space in the order of the physical address of the storage space, and it is not necessary to judge the found free storage space every time to determine whether it can store the target data, only in the metadata storage segment. Find the corresponding target storage segment, which effectively reduces the time spent searching.
  • the terminal exists in many forms, including but not limited to:
  • Mobile communication devices These devices are characterized by mobile communication functions and are mainly aimed at providing voice and data communication.
  • Such terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.
  • Ultra-mobile personal computer equipment This type of equipment belongs to the category of personal computers, has computing and processing functions, and generally has mobile Internet access.
  • Such terminals include: PDAs, MIDs, and UMPC devices, such as the iPad.
  • Portable entertainment devices These devices can display and play multimedia content. Such devices include: audio, video players (such as iPod), handheld game consoles, e-books, and smart toys and portable car navigation devices.
  • the server consists of a processor, a hard disk, a memory, a system bus, etc.
  • the server is similar to a general-purpose computer architecture, but because of the need to provide highly reliable services, processing power and stability High reliability in terms of reliability, security, scalability, and manageability.
  • the embodiment of the present application provides an executable program code, where the executable program code is used to execute the data storage method provided by the embodiment of the present application at a runtime, where the data storage method includes:
  • Receiving a storage request for the data to be stored where the storage request includes: an identifier of the target file corresponding to the data to be stored;
  • a target virtual storage segment for storing the to-be-stored data, where the metadata storage segment is identified as a plurality of virtual storage segments.
  • the virtual storage segment of the value is used to store the correspondence between each virtual storage segment and the stored file and the storage state of each virtual storage segment;
  • the data to be stored is stored starting from the initial storage location.
  • the terminal receives the storage request for the data to be stored, and determines, according to the identifier of the target file corresponding to the data to be stored and the information stored in the metadata storage segment, that the storage request is used to store the data to be stored.
  • the target virtual storage segment obtains the end storage location of the data stored in the target virtual storage segment, and determines the obtained storage location as the initial storage location of the data to be stored, and stores the to-be-stored data from the initial storage location. .
  • the embodiment of the present application provides a storage medium for storing executable program code, the executable program code is executed to execute the data storage method provided by the embodiment of the present application, where the data storage method includes:
  • Receiving a storage request for the data to be stored where the storage request includes: an identifier of the target file corresponding to the data to be stored;
  • a target virtual storage segment for storing the to-be-stored data, where the metadata storage segment is identified as a plurality of virtual storage segments.
  • the virtual storage segment of the value is used to store the correspondence between each virtual storage segment and the stored file and the storage state of each virtual storage segment;
  • the data to be stored is stored starting from the initial storage location.
  • the terminal receives the storage request for the data to be stored, and determines, according to the identifier of the target file corresponding to the data to be stored and the information stored in the metadata storage segment, that the storage request is used to store the data to be stored.
  • the target virtual storage segment obtains the end storage location of the data stored in the target virtual storage segment, and determines the obtained storage location as the initial storage location of the data to be stored, and stores the to-be-stored data from the initial storage location. .
  • the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据存储方法及装置,应用于终端,终端包括至少一个磁盘,磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;该方法包括:接收针对待存储数据的存储请求(S101),根据存储请求中包括的待存储数据对应的目标文件的标识和元数据存储段中存储的信息,确定用于存储待存储数据的目标虚拟存储段(S102),获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为待存储数据的起始存储位置(S103),从起始存储位置开始存储待存储数据(S104)。应用所述方法存储数据,减少了寻道耗时。

Description

一种数据存储方法及装置
本申请要求于2016年4月26日提交中国专利局、申请号为201610269953.7发明名称为“一种数据存储方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,特别涉及一种数据存储方法及装置。
背景技术
目前,计算机按照磁盘的物理地址的顺序读写文件的数据。但是随着磁盘中存储的文件增多,还会伴随着大量文件的迁移和删除,进而导致磁盘的存储空间呈碎片化分布。此时,若计算机需再次进行数据存储,如,存储目标数据时,需要在磁盘中按照物理地址的顺序依次查找空闲存储空间,并判断该空闲存储空间是否可以存储上述目标数据,若不能,则需要再次查找空闲存储空间,以找到能够存储目标数据的空闲存储空间,存储目标数据。
按照上述方式进行数据存储时,不仅需要按照存储空间物理地址的顺序查找空闲存储空间,而且每次都要对查找到的空闲存储空间进行判断,以确定其是否可以存储目标数据,这样增加了寻道耗时。
发明内容
本申请实施例的目的在于提供一种数据存储方法及装置,以减少寻道耗时。
为达到上述目的,本申请实施例公开了一种数据存储方法,应用于终端,所述终端包括至少一个磁盘,所述磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;所述方法包括:
接收针对待存储数据的存储请求,其中,所述存储请求中包括:所述待存储数据对应的目标文件的标识;
根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,其中,所述元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件 之间的对应关系以及各个虚拟存储段的存储状态;
获得所述目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为所述待存储数据的起始存储位置;
从所述起始存储位置开始存储所述待存储数据。
可选的,所述根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,包括:
根据所述目标文件的标识,判断所述目标文件是否处于已存储状态;
若为是,则根据所述元数据存储段中存储的信息,获得存储所述目标文件的第一虚拟存储段;
判断所述第一虚拟存储段是否处于可存储状态;
若处于可存储状态,则根据所述第一虚拟存储段确定用于存储所述待存储数据的目标虚拟存储段。
可选的,所述根据所述第一虚拟存储段确定用于存储所述待存储数据的目标虚拟存储段,包括:
将所述第一虚拟存储段中最后一次存储属于所述目标文件的数据的虚拟存储段,确定为用于所述待存储数据的目标虚拟存储段。
可选的,在判断得知所述第一虚拟存储段处于不可存储状态的情况下,还包括:
从与所述第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储所述待存储数据的目标虚拟存储段。
可选的,所述从与所述第一虚拟存储段物理地址最近的虚拟存储段中,确定用于存储所述待存储数据的目标虚拟存储段,包括:
获得所述目标文件的存储方式;
在所述存储方式为第一存储方式的情况下,确定与所述第一虚拟存储段的物理地址最近且未存储数据的虚拟存储段为用于存储所述待存储数据的目标虚拟存储段,其中,所述第一存储方式为:一个虚拟存储段中存储一个文 件的存储方式;
在所述存储方式为第二存储方式的情况下,获得与所述第一虚拟存储段的物理地址最近且所存储文件的存储方式不是所述第一存储方式的第二虚拟存储段;将所述第二虚拟存储段确定为用于存储所述待存储数据的目标虚拟存储段,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式。
可选的,所述方法还包括:
在所述目标文件处于未存储状态的情况下,获得所述待存储数据的数据量;
判断所获得的数据量是否大于预设数据量;
若大于所述预设数据量,则确定所述目标文件的存储方式为第一存储方式,其中,所述第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
若不大于所述预设数据量,则确定所述目标文件的存储方式为第二存储方式,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式;
根据所确定的存储方式,确定用于存储所述待存储数据的目标虚拟存储段;
所述从所获得的当前数据存储位置开始存储所述待存储数据之后,还包括;
将所述目标文件的存储状态设置为已存储状态。
可选的,所述方法还包括:
接收针对待创建文件的文件创建指令;
创建所述待创建文件,并在所述元数据存储段中将所述待创建文件的存储状态设置为未存储状态,拒绝确定所述待创建文件的数据的起始存储位置。
可选的,所述磁盘中包含多个物理存储区域,所述物理存储区域为所述 磁盘的最小物理存储单元;
所述从所述起始存储位置开始存储所述待存储数据,包括:
获得所述待存储数据的数据量;
根据所述数据量,确定要存储所述待存储数据的各个目标物理存储区域;
在所述待存储数据要跨区域存储的情况下,根据所确定的各个目标物理存储区域的可用存储容量和所述数据量,将所述待存储数据划分为与各个目标物理存储区域对应的数据块;
将划分得到的数据块分别存储至对应的目标物理存储区域中。
为达到上述目的,本申请实施例还公开了一种数据存储装置,应用于终端,所述终端包括至少一个磁盘,所述磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;所述装置包括:
存储请求接收模块,用于接收针对待存储数据的存储请求,其中,所述存储请求中包括:所述待存储数据对应的目标文件的标识;
目标虚拟存储段确定模块,用于根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,其中,所述元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态;
起始存储位置确定模块,用于获得所述目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为所述待存储数据的起始存储位置;
数据存储模块,用于从所述起始存储位置开始存储所述待存储数据。
可选的,所述目标虚拟存储段确定模块,包括:
第一存储状态判断子模块,用于根据所述目标文件的标识,判断所述目标文件是否处于已存储状态;
虚拟存储段获得子模块,用于在所述第一存储状态判断子模块判断结果 为是的情况下,根据所述元数据存储段中存储的信息,获得存储所述目标文件的第一虚拟存储段;
第二存储状态判断子模块,用于判断所述第一虚拟存储段是否处于可存储状态;
第一目标虚拟存储段确定子模块,用于在所述第二存储状态判断子模块判断结果为是的情况下,根据所述第一虚拟存储段确定用于存储所述待存储数据的目标虚拟存储段。
可选的,所述第一目标虚拟存储段确定子模块,具体用于将所述第一虚拟存储段中最后一次存储属于所述目标文件的数据的虚拟存储段,确定为用于所述待存储数据的目标虚拟存储段。
可选的,所述目标虚拟存储段确定模块,还包括:
第二目标虚拟存储段确定子模块,用于在所述第二存储状态判断子模块判断结果为否的情况下,从与所述第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储所述待存储数据的目标虚拟存储段。
可选的,所述第二目标虚拟存储段确定子模块,包括:
存储方式获得单元,用于获得所述目标文件的存储方式;
第一目标虚拟存储段确定单元,用于在所述存储方式为第一存储方式的情况下,确定与所述第一虚拟存储段的物理地址最近且未存储数据的虚拟存储段为用于存储所述待存储数据的目标虚拟存储段,其中,所述第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
第二目标虚拟存储段确定单元,用于在所述存储方式为第二存储方式的情况下,获得与所述第一虚拟存储段的物理地址最近且所存储文件的存储方式不是所述第一存储方式的第二虚拟存储段;将所述第二虚拟存储段确定为用于存储所述待存储数据的目标虚拟存储段,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式。
可选的,所述目标虚拟存储段确定模块,还包括:
第一数据量获得子模块,用于在所述第一存储状态判断子模块判断结果 为否的情况下,获得所述待存储数据的数据量;
数据量判断子模块,用于判断所获得的数据量是否大于预设数据量;
第一存储方式确定子模块,用于在所述数据量判断子模块判断结果为是的情况下,确定所述目标文件的存储方式为第一存储方式,其中,所述第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
第二存储方式确定子模块,用于在所述数据量判断子模块判断结果为否的情况下,确定所述目标文件的存储方式为第二存储方式,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式;
第三目标虚拟存储段确定子模块,用于根据所确定的存储方式,确定用于存储所述待存储数据的目标虚拟存储段;
所述装置还包括:
存储状态设置模块,用于将所述目标文件的存储状态设置为已存储状态。
可选的,所述装置还包括:
创建指令接收模块,用于接收针对待创建文件的文件创建指令;
文件创建模块,用于创建所述待创建文件,并在所述元数据存储段中将所述待创建文件的存储状态设置为未存储状态,拒绝确定所述待创建文件的数据的起始存储位置。
可选的,所述磁盘中包含多个物理存储区域,所述物理存储区域为所述磁盘的最小物理存储单元;
所述数据存储模块,包括:
第二数据量获得子模块,用于获得所述待存储数据的数据量;
存储区域确定子模块,用于根据所述数据量,确定要存储所述待存储数据的各个目标物理存储区域;
数据块划分子模块,用于在所述待存储数据要跨区域存储的情况下,根据所确定的各个目标物理存储区域的可用存储容量和所述数据量,将所述待存储数据划分为与各个目标物理存储区域对应的数据块;
数据块存储子模块,用于将划分得到的数据块分别存储至对应的目标物理存储区域中。
为达到上述目的,本申请实施例还公开了一种终端,所述终端包括:壳体、处理器、存储器、电路板和电源电路,其中,所述电路板安置在所述壳体围成的空间内部,所述处理器和所述存储器设置在所述电路板上;所述电源电路,用于为所述终端的各个电路或器件供电;所述存储器用于存储可执行程序代码;所述处理器通过运行所述存储器中存储的可执行程序代码,以执行上述的数据存储方法。
为达到上述目的,本申请实施例还公开了一种可执行程序代码,所述可执行程序代码用于在运行时执行上述的数据存储方法。
为达到上述目的,本申请实施例还公开了一种存储介质,所述存储介质用于存储可执行程序代码,所述可执行程序代码被运行以执行上述的数据存储方法。
可见,本申请实施例中,终端接收针对待存储数据的存储请求,根据存储请求中包括该待存储数据对应的的目标文件的标识和元数据存储段中存储的信息,确定用于存储该待存储数据的目标虚拟存储段,获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为该待存储数据的起始存储位置,从起始存储位置开始存储该待存储数据。这样,就不需要按照存储空间物理地址的顺序查找空闲存储空间,并且也不需要每次都对查找到的空闲存储空间进行判断,以确定其是否可以存储目标数据,只需要在元数据存储段中查找相应的目标存储段就可以了,有效的减少了寻道耗时。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的一种数据存储方法的流程示意图;
图2为本申请实施例提供的一种虚拟存储段的结构示意图;
图3为本申请实施例提供的一种元数据存储段中元数据排布示意图;
图4为本申请实施例提供的另一种数据存储方法的流程示意图;
图5为本申请实施例提供的另一种数据存储方法的流程示意图;
图6为本申请实施提供的虚拟存储段的分配方法的流程示意图;
图7为本申请实施例提供的一种数据存储装置的结构示意图;
图8为本申请实施例提供的另一种数据存储装置的结构示意图;
图9为本申请实施例提供的另一种数据存储装置的结构示意图;
图10为本申请实施例提供的一种终端的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
下面通过具体实施例,对本申请进行详细说明。
参考图1,图1为本申请实施例提供的一种数据存储方法的流程示意图,应用于终端,该终端包括至少一个磁盘,磁盘按照物理地址可以划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;该方法可以包括如下步骤:
S101:接收针对待存储数据的存储请求;
其中,存储请求中包括:待存储数据对应的目标文件的标识。这里,存储请求中还可以包括待存储数据的数据量等信息,本申请对此不进行限定。
S102:根据存储请求中包括的待存储数据对应的目标文件的标识和元数据存储段中存储的信息,确定用于存储待存储数据的目标虚拟存储段;
其中,元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态。这里,虚拟存储段的存储状态包括可存储状态和不可存储状态。
上述预设值可以为0、1、2等等,本申请并不对此进行限定。
在本申请的一种实现方式中,在未向磁盘中存储任何数据前,需要对文件***进行格式化,确定磁盘的类型,进而确定每个Vzone(虚拟存储段)对应的物理地址段的大小,将磁盘根据物理地址分为多个Vzone,文件***将这些Vzone作为磁盘的最小存储管理单元,根据Vzone确定待存储数据的存储位置。
例如,当确定的磁盘类型为Host Manage或Host Aware时,每个Vzone对应的物理地址段的大小与实际的物理存储区域的大小相等,这里,Host Manage磁盘或Host Aware磁盘为SMR(Shingled Magnetic Recording,叠瓦式磁记录技术)磁盘的一种,SMR磁盘分为Host Manage、Host Aware和Drive Manage,Host Manage为一种由主机端控制读写的磁盘,其不支持随机写操作;Host Aware为一种由主机端控制读写的磁盘,其支持随机写操作,但随机写操作时写性能下降;Drive Manage为一种由磁盘控制读写的磁盘,其支持随机写操作;所述SMR磁盘的读写对象指磁盘实际的物理地址;
当确定的磁盘类型不是Host Manage和Host Aware时,可以根据实际的数据存储需求确定每个Vzone对应的物理地址段的大小,如,当磁盘中经常存储大数据的文件时,可以将Vzone对应的物理地址段的大小设置的大些;当磁盘中经常存储小数据的文件时,可以将Vzone对应的物理地址段的大小设置的小些。
在本申请的一种实现方式中,文件***将磁盘的物理地址划分成多个num(X)至num(X+1)段,如图2所示,图2为本申请实施例提供的一种虚拟存储段的结构示意图,其中,num(x)和num(x+1)各代表不同的物理地址,即num(x)至num(x+1)为一个物理地址段;每个物理地址段对应一个Vzone。假设,第一个Vzone也就是Vzone0为元数据存储段,那么,该Vzone0对应的物理地址段的大小可以与其他Vzone对应的物理地址段的大小不同,且能够作随机写操作;Vzone1-Vzonex的物理地址段的大小相等,并且在该区域只能作顺序的写操作。另外,文件与Vzone的对应关系为:一对多,即:一个文件的数据可以存储在多个Vzone中,当然文件与Vzone的对应关系也可以为:多对一,即:一个Vzone也可以存储多个文件。
另外,Vzone0存储元数据,Vzone1-Vzonex存储文件的数据,利于元数据和数据区的集中分配,避免磁盘中存储数据的碎片化。
实际应用中,元数据存储段用于存储元数据,这里元数据可以包括:预留空间、超级块、超级块备份、文件索引、文件索引备份、文件索引位图、Vzone位图、Vzone位图备份、Vzone描述符、Vzone描述符备份和映射表;其他Vzone用于存放实际的文件数据。可参考图3,图3为本申请实施例提供的一种元数据存储段中元数据排布示意图,其中,
启动块(Boot block):即预留空间,用于存放磁盘分区信息等;
超级块(Super block):即文件***相关信息,包含了当前文件***分配到的Vzone的编号,Vzone的总个数,空闲Vzone的总个数、单个zone对应多文件的阈值、文件***允许的最大文件个数(即文件索引inode个数),其中,一个文件索引对应一个文件;另外,超级块备份(super block back)为该区域的备份;
Vzone位图(Vzone bitmap):每一位代表一个Vzone,1代表已使用,0代表未使用;另外,Vzone位图备份(Vzone bitmap back)为该区域的备份;文件索引位图(Inode bitmap):每一位代表一个文件,1代表已使用,0代表未使用;文件创建时,会查找该位图,每次根据位图,由小到大分配索引号;
文件索引(Inode):描述了文件的信息,包括映射表的起始物理地址;另外,文件索引也记录了文件与Vzone的对应方式,即一个Vzone对应多个文件(multi)还是一个Vzone只能被一个文件所拥有(only);包含当前文件使用的Vzone的编号;另外,文件索引备份(Inode back)为该区域的备份;
映射表(hik map):记录每个文件逻辑地址与磁盘的物理地址的对应关系;
Vzone描述符(Vzone description):描述了当前Vzone的使用者(文件)的个数;描述了当前Vzone写指针的位置;另外,Vzone描述符备份(Vzone description back)为该区域的备份。
需要说明的是,本申请只是以上述为例进行说明,并不对以上元数据的排布顺序和占用空间大小进行限定,仅仅表明Vzone0中记录了这些元数据;另外,超级块存储了空闲的Vzone的个数,结合Vzone位图中记录的空闲Vzone 的编号,可以快速的获得目标Vzone。
这种情况下,当接收到针对待存储数据的存储请求时,就可以根据元数据存储段中存储的上述信息,确定用于存储该待存储数据的目标Vzone。
S103:获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为待存储数据的起始存储位置;
假设,目标虚拟存储段为超级块中记录的当前文件***分配到的Vzone的编号,则可以根据将Vzone描述符中记录的该Vzone写指针的位置,确定待存储数据的起始存储位置。这里,当前Vzone写指针的位置就是该当前Vzone中所存储数据的末尾存储位置。
S104:从起始存储位置开始存储待存储数据。
实际应用中,终端的磁盘中可能包含多个物理存储区域zone,zone为磁盘的最小物理存储单元,而每个磁盘的zone的数据存储算法是有差异的,因此,待存储数据是不允许跨zone存储的。为了保证数据的跨zone存储,步骤S104可以包括:
S01、获得待存储数据的数据量;
S02、根据待存储数据的数据量,确定要存储待存储数据的各个目标物理存储区域;
根据待存储数据的数据量,可以确定出要存储待存储数据的目标Vzone,因为Vzone与zone存在对应关系,进而确定出要存储待存储数据的各个目标zone。如,一待存储数据a的数据量为100kB,确定的目标Vzone为Vzone1,该待存储数据对应的Vzone1的存储空间正好对应zone1和zone2,因此可以确定出目标物理存储区域为zone1和zone2。
S03、在待存储数据要跨区域存储的情况下,根据所确定的各个目标物理存储区域的可用存储容量和待存储数据的数据量,将待存储数据划分为与各个目标物理存储区域对应的数据块;
根据步骤S02中所述,可以确定待存储数据a要跨区域存储,假设,zone1的可用存储容量为30kB,zone2的可用存储容量为80kB,而zone1对应的物理 地址段在前,zone2对应的物理地址段在后,因此,将待存储数据a划分为数据量为30kB的数据块和70kB的数据块。
S04、将划分得到的数据块分别存储至对应的目标物理存储区域中。
这种情况下,有效地避免了将待存储数据作为一整个数据块进行跨区域数据存储时,数据存储不成功的问题。
在本申请的一种实现方式中,若待存储数据不需要跨区域存储,则可以直接从起始存储位置开始存储该待存储数据。
值得一提的是,本申请中所提到的多个为至少两个。
应用图1所示实施例,终端接收针对待存储数据的存储请求,根据存储请求中包括该待存储数据对应的的目标文件的标识和元数据存储段中存储的信息,确定用于存储该待存储数据的目标虚拟存储段,获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为该待存储数据的起始存储位置,从起始存储位置开始存储该待存储数据。这样,就不需要按照存储空间物理地址的顺序查找空闲存储空间,并且也不需要每次都对查找到的空闲存储空间进行判断,以确定其是否可以存储目标数据,只需要在元数据存储段中查找相应的目标存储段就可以了,有效的减少了寻道耗时。
参考图4,图4为本申请实施例提供的另一种数据存储方法的流程示意图,应用于终端,该终端包括至少一个磁盘,磁盘按照物理地址可以划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;该方法中,步骤S102可以包括如下步骤:
S1021:根据存储请求中包括的待存储数据对应的目标文件的标识,判断目标文件是否处于已存储状态,若为是,则执行步骤S1022;
在本申请的一种实现方式中,上述数据存储方法还可以包括:
S11、接收针对待创建文件的文件创建指令;
实际应用中,若要存储一数据,需要先创建针对该数据的文件,如,在复制一个数据a的过程为:创建针对数据a的文件A,将数据a存储至文件A中。
S12、创建待创建文件,并在元数据存储段中将待创建文件的存储状态设 置为未存储状态,拒绝确定待创建文件的数据的起始存储位置。
例如,在元数据存储段中存储有针对每一文件的文件索引Inode,并且Inode包括文件与该文件对应的Vzone的对应关系,若仅创建了文件A,而并未向该文件A中存储数据,则只需要为该文件A分配索引号,无需为该文件A分配Vzone,也就是说,无需为该文件A分配物理地址段,进而不会去确定存储该文件A的起始存储位置,减少了未存储数据的文件占用存储空间的可能,并且减少了终端的工作量。另外,Inode中该文件A对应的Vzone的编号设置为表示未分配的值,如-1。
实际应用中,当终端存储数据时,若读取到的待存储数据对应的目标文件的标识在Inode中对应的Vzone的编号不是-1时,就可以认为处于已存储状态,对于处于已存储状态的文件A的数据a,最好是将数据a存储在属于文件A的其他数据的相邻的区域中,便于终端获得该文件A的数据;若目标文件的标识对应的Vzone的编号是-1时,就可以认为处于未存储状态,对于处于未存储状态的文件的数据,只需要获得能够存储该数据a的区域就可以了,为了快速的存储数据,可以在元数据存储段中获得当前Vzone(如上述步骤S102中提到的超级块中记录的当前文件***分配到的Vzone的编号对应的Vzone),从该当前Vzone中或与该当前Vzone物理地址最近的Vzone中获得能够存储该数据的Vzone就可以了。
S1022:根据元数据存储段中存储的信息,获得存储目标文件的第一虚拟存储段;
一般地,若目标文件处于已存储状态,则可以从元数据存储段中存储的Inode中获得与该目标文件的标识对应存储的第一虚拟存储段的编号,进而确定出存储目标文件的第一虚拟存储段。
S1023:判断第一虚拟存储段是否处于可存储状态,若处于可存储状态,则执行步骤S1024,若处于不可存储状态,则执行步骤S1025;
一般地,当获得的第一虚拟存储段中存储的数据的数据量达到虚拟存储段的存储容量时,可以确定该第一虚拟存储段为处于不可存储状态,否则处于可存储状态。
需要说明的是,获得的第一虚拟存储段可能为一个,也可能为多个。
S1024:根据第一虚拟存储段确定用于存储待存储数据的目标虚拟存储段;
在本申请的一种实现方式中,上述根据第一虚拟存储段确定用于存储待存储数据的目标虚拟存储段,可以包括:
将第一虚拟存储段中最后一次存储属于目标文件的数据的虚拟存储段,确定为用于待存储数据的目标虚拟存储段。
假设,文件A的数据存储在Vzone1和Vzone2中,当Vzone1和/或Vzone2都处于可存储状态时,由于Vzone2为最后存储的文件A的数据的虚拟存储段,因此确定Vzone2为用于待存储数据的目标虚拟存储段。这样保证了同一文件的数据为按照物理地址的顺序存储的,便于终端快速准确的获取到同一文件的数据。
另外,当Vzone1和/或Vzone2都处于可存储状态时,可以更新文件A的数据,将Vzone2中存储的文件A的数据更新至Vzone1中,若更新后Vzone1仍然处于可存储状态,表明文件A的数据都存储在了Vzone1中,则确定Vzone1为用于待存储数据的目标虚拟存储段,若更新后Vzone1处于不存储状态,并且Vzone2中还存储有文件A数据,则可以确定确定Vzone2为用于待存储数据的目标虚拟存储段。这样既保证了同一文件的数据能够存储在相邻的区域中,也能够有效地避免终端中数据存储的碎片化问题。
S1025:从与第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储待存储数据的目标虚拟存储段。
实际应用中,终端根据元数据存储段中存储的信息,按照Vzone的编号从小到大的顺序,也就是按照物理地址从前到后的顺序,从第一虚拟存储段的编号开始向后查找能够用于存储待存储数据的虚拟存储段的编号,确定目标虚拟存储段。
一般地,上述从与第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储待存储数据的目标虚拟存储段,可以包括:
S11、获得目标文件的存储方式;
终端中元数据存储段中存储有已存储的每一文件的存储方式,只有确定了目标文件的存储方式,才能知道如何去存储该目标文件的待存储数据,进而确定存该该待存储数据的目标虚拟存储段。这里,存储方式,包括:第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;第二存储方式为:一个虚拟存储段中存储多个文件的存储方式。
S12、在存储方式为第一存储方式的情况下,确定与第一虚拟存储段的物理地址最近且未存储数据的虚拟存储段为用于存储待存储数据的目标虚拟存储段;
这种情况下,只需要从元数据存储段中第一虚拟存储段的编号的位置开始,向后查找空闲的虚拟存储段A(元数据存储段的Vzone位图中标记为未使用的Vzone)的编号,当该空闲的虚拟存储段A中未存储数据,也就是说,Vzone描述符中记录的该空闲的虚拟存储段A的使用者个数为0时,可以确定该虚拟存储段A为目标虚拟存储段;当该虚拟存储段A中使用者个数不是0时,继续向后查找空闲的虚拟存储段B。另外,在一个虚拟存储段中存储了第一存储方式的文件的数据后,该元数据存储段的Vzone位图中标记为已使用的Vzone,避免非该文件的数据写入该Vzone内。
实际应用中,第一存储方式的数据存储可以分为两种:
一、单文件数据存储。当只有一个文件的数据进行存储时,根据写入的数据量,文件***按照Vzone的编号的大小,从小到大(如图2中,从Vzone1到VzoneX)进行分配,并且只有在前一个Vzone写满的情况下,才会再次为该文件分配空闲的Vzone。
二、多文件数据存储。假设同时存储file1和file2的数据,对file1的数据进行写操作,文件***给file1分配了Vzone1,同时对file2的数据进行写操作,文件***给file2分配了Vzone2,由于file1的数据的存储速率较快,相比于file2,file1很快写满了Vzone1,于是文件***继续分配Vzone3给file1,file1的数据写满Vzone3后,继续分配Vzone4给file1;而file2在文件***分配Vzone4给file1之后,才写满Vzone2,此时,文件***分配给file2的是Vzone5。这样,先到先得,从前向后分配Vzone的方式,保证了多文件的数据同时存储时,各文件写入的物理地址跨度小,从而减少了磁盘的寻道时间。
S13:在存储方式为第二存储方式的情况下,获得与第一虚拟存储段的物理地址最近且所存储文件的存储方式不是第一存储方式的第二虚拟存储段;将第二虚拟存储段确定为用于存储待存储数据的目标虚拟存储段。
这种情况下,只需要从元数据存储段中第一虚拟存储段的编号的位置开始,向后查找空闲的虚拟存储段A的编号,可以确定该虚拟存储段A为目标虚拟存储段。当存储该待存储数据后,该虚拟存储段A中使用者个数加1,若此时虚拟存储段A中使用者个数大于阈值(该阈值由超级块中的单个zone对应多文件的阈值的字段决定)时,将该元数据存储段的Vzone位图中标记为已使用的Vzone,避免同一Vzone被多次写入数据,导致周围的Vzone的数据出现异常,如,周围的Vzone的数据被磁化。
应用图4所示实施例,根据存储请求中包括的待存储数据对应的目标文件的标识,在目标文件处于已存储状态,根据元数据存储段中存储的信息,获得存储目标文件的第一虚拟存储段,判断第一虚拟存储段是否处于可存储状态,若处于可存储状态,根据第一虚拟存储段确定用于存储待存储数据的目标虚拟存储段,若处于不可存储状态,从与第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储待存储数据的目标虚拟存储段。这样,保证同一文件的数据均存储在最近的能够存储的虚拟存储段中,减少了寻道耗时,且保证了终端能够快速准确的获得同一文件的数据。
参考图5,图5为本申请实施例提供的另一种数据存储方法的流程示意图,应用于终端,该终端包括至少一个磁盘,磁盘按照物理地址可以划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;在目标文件处于未存储状态的情况下,该方法中还可以包括如下步骤:
S1026:获得待存储数据的数据量;
在终端获得待存储数据后,可以根据待存储数据获得该待存储数据的数据量;当然在存储请求中可以包括该待存储数据的数据量,此时,可以直接根据该数据量执行步骤S1027。
S1027:判断所获得的数据量是否大于预设数据量,若大于预设数据量,则执行步骤S1028,若不大于预设数据量,执行步骤S1029;
S1028:确定目标文件的存储方式为第一存储方式;
一般地,当所获得的数据量大于预设数据量时,则可以认为该待存储数据对应的目标文件为大数据文件,此时,为提高终端总体的读写性能,将为该目标文件的存储方式确定为第一存储方式,避免大数据文件存储在多个Vzone内,影响终端对该目标文件的读取。
S1029:确定目标文件的存储方式为第二存储方式;
一般地,当所获得的数据量不大于预设数据量时,则可以认为该待存储数据对应的目标文件为小数据文件,此时,将为该目标文件的存储方式确定为第二存储方式,避免小数据文件占用一个Vzone,造成存储空间的浪费的问题。
S10210:根据所确定的存储方式,确定用于存储待存储数据的目标虚拟存储段。
一般地,当目标文件的存储方式为第一存储方式时,在元数据存储段中获得当前虚拟存储段的编号(当前文件***分配到的Vzone的编号),从该当前虚拟存储段的编号的位置开始,向后查找并获得空闲的、使用者个数为0的虚拟存储段A的编号,确定该虚拟存储段A为目标虚拟存储段。
当目标文件的存储方式为第二存储方式时,在元数据存储段中获得第一存储方式分配到的Vzone1的编号,在Vzone1的使用者个数为0或Vzone1的使用者的个数超过阈值时,从Vzone1的编号的位置开始,向后查找并获得空闲的Vzone2,在Vzone2的使用者个数不为0的情况下,确定Vzone2为目标虚拟存储段;在Vzone1的使用者个数不为0或Vzone1的使用者的个数未超过阈值时,直接将该Vzone1确定为目标虚拟存储段。这样就避免了使用者个数为0的Vzone被占用,影响第一存储方式的文件的数据存储。
在本申请的一种实现方式中,查找分配Vzone的方式的整体策略为先到先得,并且顺序由Vzone1往后依次分配,只有在整个磁盘全部被分配完之后,才会从头开始寻找新的空闲Vzone。此过程由元数据存储段的超级块中当前文件***分配到的Vzone编号和Vzone的位图共同完成。如图6所示,图6为本申请实施提供的虚拟存储段的分配方法的流程示意图,可以包括如下步骤:
S21、判断文件***中是否包含空闲的Vzone;
这里,空闲的Vzone的个数记录在超级块中。若超级块中不含有空闲的Vzone,则返回错误。
S22、根据记录在超级块中文件***上次分配到的Vzone的编号,由该编号对应Vzone的位图开始往后查找空闲的Vzone;
这里,文件***上次分配到的Vzone的编号为元数据存储段中记录的当前Vzone的编号。
S23、若查到Vzone位图的末尾仍未找到空闲的Vzone,那么从Vzone位图的头开始查找。
查找成功后,将空闲的Vzone个数减去分配的个数,并更新文件***上次分配的Vzone号(当前Vzone的编号),以便下次分配时使用。
这种情况下,该方法步骤S104之后,还可以包括:
将目标文件的存储状态设置为已存储状态。
在Inode中存储该目标文件的标识与Vzone的编号的对应关系,当终端再次存储该目标文件的数据时,读取到相应的Vzone的编号,则可以确定该目标文件处于已存储状态。
应用图5所示实施例,终端获得待存储数据的数据量,判断所获得的数据量是否大于预设数据量,若大于预设数据量,确定目标文件的存储方式为第一存储方式,若不大于预设数据量,确定目标文件的存储方式为第二存储方式,并根据所确定的存储方式,确定用于存储待存储数据的目标虚拟存储段。这样,有效地保证大数据文件的数据的集中存储,并且避免了小数据文件存储浪费存储空间的问题。
参考图7,图7为本申请实施例提供的一种数据存储装置的结构示意图,应用于终端,该终端包括至少一个磁盘,磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;该装置可以包括:
存储请求接收模块701,用于接收针对待存储数据的存储请求,其中,存储请求中包括:待存储数据对应的目标文件的标识;
目标虚拟存储段确定模块702,用于根据目标文件的标识和元数据存储段中存储的信息,确定用于存储待存储数据的目标虚拟存储段,其中,元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态;
起始存储位置确定模块703,用于获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为待存储数据的起始存储位置;
数据存储模块704,用于从起始存储位置开始存储待存储数据。
在本申请的一种实现方式中,磁盘中包含多个物理存储区域,物理存储区域为磁盘的最小物理存储单元;
这种情况下,数据存储模块704,可以包括:
第二数据量获得子模块,用于获得待存储数据的数据量;
存储区域确定子模块,用于根据数据量,确定要存储待存储数据的各个目标物理存储区域;
数据块划分子模块,用于在待存储数据要跨区域存储的情况下,根据所确定的各个目标物理存储区域的可用存储容量和数据量,将待存储数据划分为与各个目标物理存储区域对应的数据块;
数据块存储子模块,用于将划分得到的数据块分别存储至对应的目标物理存储区域中(图7中未示出)。
应用图7所示实施例,终端接收针对待存储数据的存储请求,根据存储请求中包括该待存储数据对应的的目标文件的标识和元数据存储段中存储的信息,确定用于存储该待存储数据的目标虚拟存储段,获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为该待存储数据的起始存储位置,从起始存储位置开始存储该待存储数据。这样,就不需要按照存储空间物理地址的顺序查找空闲存储空间,并且也不需要每次都对查找到的空闲存储空间进行判断,以确定其是否可以存储目标数据,只需要在元数据存储段中查找相应的目标存储段就可以了,有效的减少了寻道耗时。
参考图8,图8为本申请实施例提供的另一种数据存储装置的结构示意图, 应用于终端,该终端包括至少一个磁盘,磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;该装置中,目标虚拟存储段确定模块702,包括:
第一存储状态判断子模块7021,用于根据目标文件的标识,判断目标文件是否处于已存储状态;
虚拟存储段获得子模块7022,用于在第一存储状态判断子模块判断结果为是的情况下,根据元数据存储段中存储的信息,获得存储目标文件的第一虚拟存储段;
第二存储状态判断子模块7023,用于判断第一虚拟存储段是否处于可存储状态;
第一目标虚拟存储段确定子模块7024,用于在第二存储状态判断子模块判断结果为是的情况下,根据第一虚拟存储段确定用于存储待存储数据的目标虚拟存储段;
第二目标虚拟存储段确定子模块7025,用于在第二存储状态判断子模块判断结果为否的情况下,从与第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储待存储数据的目标虚拟存储段。
在本申请的一种实现方式中,第一目标虚拟存储段确定子模块7024,具体用于将第一虚拟存储段中最后一次存储属于目标文件的数据的虚拟存储段,确定为用于待存储数据的目标虚拟存储段。
在本申请的一种实现方式中,第二目标虚拟存储段确定子模块7025,可以包括:
存储方式获得单元,用于获得目标文件的存储方式;
第一目标虚拟存储段确定单元,用于在存储方式为第一存储方式的情况下,确定与第一虚拟存储段的物理地址最近且未存储数据的虚拟存储段为用于存储待存储数据的目标虚拟存储段,其中,第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
第二目标虚拟存储段确定单元,用于在存储方式为第二存储方式的情况 下,获得与第一虚拟存储段的物理地址最近且所存储文件的存储方式不是第一存储方式的第二虚拟存储段;将第二虚拟存储段确定为用于存储待存储数据的目标虚拟存储段,其中,第二存储方式为:一个虚拟存储段中存储多个文件的存储方式。
在本申请的一种实现方式中,上述数据存储装置还可以包括:
创建指令接收模块,用于接收针对待创建文件的文件创建指令;
文件创建模块,用于创建待创建文件,并在元数据存储段中将待创建文件的存储状态设置为未存储状态,拒绝确定待创建文件的数据的起始存储位置(图8中未示出)。
应用图8所示实施例,根据存储请求中包括的待存储数据对应的目标文件的标识,在目标文件处于已存储状态,根据元数据存储段中存储的信息,获得存储目标文件的第一虚拟存储段,判断第一虚拟存储段是否处于可存储状态,若处于可存储状态,根据第一虚拟存储段确定用于存储待存储数据的目标虚拟存储段,若处于不可存储状态,从与第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储待存储数据的目标虚拟存储段。这样,保证同一文件的数据均存储在最近的能够存储的虚拟存储段中,减少了寻道耗时,且保证了终端能够快速准确的获得同一文件的数据。
参考图9,图9为本申请实施例提供的另一种数据存储装置的结构示意图,应用于终端,该终端包括至少一个磁盘,磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;该装置中,目标虚拟存储段确定模块702,可以包括:
第一数据量获得子模块7026,用于在第一存储状态判断子模块判断结果为否的情况下,获得待存储数据的数据量;
数据量判断子模块7027,用于判断所获得的数据量是否大于预设数据量;
第一存储方式确定子模块7028,用于在数据量判断子模块判断结果为是的情况下,确定目标文件的存储方式为第一存储方式,其中,第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
第二存储方式确定子模块7029,用于在数据量判断子模块判断结果为否的情况下,确定目标文件的存储方式为第二存储方式,其中,第二存储方式为:一个虚拟存储段中存储多个文件的存储方式;
第三目标虚拟存储段确定子模块70210,用于根据所确定的存储方式,确定用于存储待存储数据的目标虚拟存储段。
这种情况下,上述数据存储装置还可以包括:
存储状态设置模块,用于将目标文件的存储状态设置为已存储状态(图9中未示出)。
应用图9所示实施例,终端获得待存储数据的数据量,判断所获得的数据量是否大于预设数据量,若大于预设数据量,确定目标文件的存储方式为第一存储方式,若不大于预设数据量,确定目标文件的存储方式为第二存储方式,并根据所确定的存储方式,确定用于存储待存储数据的目标虚拟存储段。这样,有效地保证大数据文件的数据的集中存储,并且避免了小数据文件存储浪费存储空间的问题。
如图10所示,本申请实施例提供了一种终端,所述终端包括:壳体1001、处理器1002、存储器1003、电路板1004和电源电路1005,其中,所述电路板1004安置在所述壳体1001围成的空间内部,所述处理器1002和所述存储器1003设置在所述电路板1004上;所述电源电路1005,用于为所述终端的各个电路或器件供电;所述存储器1003用于存储可执行程序代码;所述处理器1002通过运行所述存储器1003中存储的可执行程序代码,以执行以下步骤:
接收针对待存储数据的存储请求,其中,所述存储请求中包括:所述待存储数据对应的目标文件的标识;
根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,其中,所述元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态;
获得所述目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为所述待存储数据的起始存储位置;
从所述起始存储位置开始存储所述待存储数据。
处理器1002对上述步骤的具体执行过程以及处理器1002通过运行可执行程序代码来进一步执行的步骤,可以参见本申请图1-9所示实施例的描述,在此不再赘述。
由上可见,本申请实施例中,终端接收针对待存储数据的存储请求,根据存储请求中包括该待存储数据对应的的目标文件的标识和元数据存储段中存储的信息,确定用于存储该待存储数据的目标虚拟存储段,获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为该待存储数据的起始存储位置,从起始存储位置开始存储该待存储数据。这样,就不需要按照存储空间物理地址的顺序查找空闲存储空间,并且也不需要每次都对查找到的空闲存储空间进行判断,以确定其是否可以存储目标数据,只需要在元数据存储段中查找相应的目标存储段就可以了,有效的减少了寻道耗时。
该终端以多种形式存在,包括但不限于:
(1)移动通信设备:这类设备的特点是具备移动通信功能,并且以提供话音、数据通信为主要目标。这类终端包括:智能手机(例如iPhone)、多媒体手机、功能性手机,以及低端手机等。
(2)超移动个人计算机设备:这类设备属于个人计算机的范畴,有计算和处理功能,一般也具备移动上网特性。这类终端包括:PDA、MID和UMPC设备等,例如iPad。
(3)便携式娱乐设备:这类设备可以显示和播放多媒体内容。该类设备包括:音频、视频播放器(例如iPod),掌上游戏机,电子书,以及智能玩具和便携式车载导航设备。
(4)服务器:提供计算服务的设备,服务器的构成包括处理器、硬盘、内存、***总线等,服务器和通用的计算机架构类似,但是由于需要提供高可靠的服务,因此在处理能力、稳定性、可靠性、安全性、可扩展性、可管理性等方面要求较高。
(5)其他具有数据交互功能的电子装置。
本申请实施例提供了一种可执行程序代码,该可执行程序代码用于在运行时执行本申请实施例提供的数据存储方法,其中,数据存储方法,包括:
接收针对待存储数据的存储请求,其中,所述存储请求中包括:所述待存储数据对应的目标文件的标识;
根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,其中,所述元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态;
获得所述目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为所述待存储数据的起始存储位置;
从所述起始存储位置开始存储所述待存储数据。
本申请实施例中,终端接收针对待存储数据的存储请求,根据存储请求中包括该待存储数据对应的的目标文件的标识和元数据存储段中存储的信息,确定用于存储该待存储数据的目标虚拟存储段,获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为该待存储数据的起始存储位置,从起始存储位置开始存储该待存储数据。这样,就不需要按照存储空间物理地址的顺序查找空闲存储空间,并且也不需要每次都对查找到的空闲存储空间进行判断,以确定其是否可以存储目标数据,只需要在元数据存储段中查找相应的目标存储段就可以了,有效的减少了寻道耗时。
本申请实施例提供了一种存储介质,用于存储可执行程序代码,该可执行程序代码被运行以执行本申请实施例提供的数据存储方法,其中,数据存储方法,包括:
接收针对待存储数据的存储请求,其中,所述存储请求中包括:所述待存储数据对应的目标文件的标识;
根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,其中,所述元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态;
获得所述目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为所述待存储数据的起始存储位置;
从所述起始存储位置开始存储所述待存储数据。
本申请实施例中,终端接收针对待存储数据的存储请求,根据存储请求中包括该待存储数据对应的的目标文件的标识和元数据存储段中存储的信息,确定用于存储该待存储数据的目标虚拟存储段,获得目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为该待存储数据的起始存储位置,从起始存储位置开始存储该待存储数据。这样,就不需要按照存储空间物理地址的顺序查找空闲存储空间,并且也不需要每次都对查找到的空闲存储空间进行判断,以确定其是否可以存储目标数据,只需要在元数据存储段中查找相应的目标存储段就可以了,有效的减少了寻道耗时。
对于装置实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本领域普通技术人员可以理解实现上述方法实施方式中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,所述的程序可以存储于计算机可读取存储介质中,这里所称得的存储介质,如:ROM/RAM、磁碟、光盘等。
以上所述仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本申请的保护范围内。

Claims (19)

  1. 一种数据存储方法,应用于终端,其特征在于,所述终端包括至少一个磁盘,所述磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;所述方法包括步骤:
    接收针对待存储数据的存储请求,其中,所述存储请求中包括:所述待存储数据对应的目标文件的标识;
    根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,其中,所述元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态;
    获得所述目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为所述待存储数据的起始存储位置;
    从所述起始存储位置开始存储所述待存储数据。
  2. 根据权利要1所述的方法,其特征在于,所述根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,包括:
    根据所述目标文件的标识,判断所述目标文件是否处于已存储状态;
    若为是,则根据所述元数据存储段中存储的信息,获得存储所述目标文件的第一虚拟存储段;
    判断所述第一虚拟存储段是否处于可存储状态;
    若处于可存储状态,则根据所述第一虚拟存储段确定用于存储所述待存储数据的目标虚拟存储段。
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述第一虚拟存储段确定用于存储所述待存储数据的目标虚拟存储段,包括:
    将所述第一虚拟存储段中最后一次存储属于所述目标文件的数据的虚拟存储段,确定为用于所述待存储数据的目标虚拟存储段。
  4. 根据权利要求2或3所述的方法,其特征在于,在判断得知所述第一虚拟存储段处于不可存储状态的情况下,还包括:
    从与所述第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储所述待存储数据的目标虚拟存储段。
  5. 根据权利要求4所述的方法,其特征在于,所述从与所述第一虚拟存储段物理地址最近的虚拟存储段中,确定用于存储所述待存储数据的目标虚拟存储段,包括:
    获得所述目标文件的存储方式;
    在所述存储方式为第一存储方式的情况下,确定与所述第一虚拟存储段的物理地址最近且未存储数据的虚拟存储段为用于存储所述待存储数据的目标虚拟存储段,其中,所述第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
    在所述存储方式为第二存储方式的情况下,获得与所述第一虚拟存储段的物理地址最近且所存储文件的存储方式不是所述第一存储方式的第二虚拟存储段;将所述第二虚拟存储段确定为用于存储所述待存储数据的目标虚拟存储段,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式。
  6. 根据权利要求2所述的方法,其特征在于,所述方法还包括:
    在所述目标文件处于未存储状态的情况下,获得所述待存储数据的数据量;
    判断所获得的数据量是否大于预设数据量;
    若大于所述预设数据量,则确定所述目标文件的存储方式为第一存储方式,其中,所述第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
    若不大于所述预设数据量,则确定所述目标文件的存储方式为第二存储方式,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式;
    根据所确定的存储方式,确定用于存储所述待存储数据的目标虚拟存储段;
    所述从所获得的当前数据存储位置开始存储所述待存储数据之后,还包括;
    将所述目标文件的存储状态设置为已存储状态。
  7. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    接收针对待创建文件的文件创建指令;
    创建所述待创建文件,并在所述元数据存储段中将所述待创建文件的存储状态设置为未存储状态,拒绝确定所述待创建文件的数据的起始存储位置。
  8. 根据权利要求1所述的方法,其特征在于,所述磁盘中包含多个物理存储区域,所述物理存储区域为所述磁盘的最小物理存储单元;
    所述从所述起始存储位置开始存储所述待存储数据,包括:
    获得所述待存储数据的数据量;
    根据所述数据量,确定要存储所述待存储数据的各个目标物理存储区域;
    在所述待存储数据要跨区域存储的情况下,根据所确定的各个目标物理存储区域的可用存储容量和所述数据量,将所述待存储数据划分为与各个目标物理存储区域对应的数据块;
    将划分得到的数据块分别存储至对应的目标物理存储区域中。
  9. 一种数据存储装置,应用于终端,其特征在于,所述终端包括至少一个磁盘,所述磁盘按照物理地址划分为多个虚拟存储段,多个虚拟存储段对应的物理地址范围不重合;所述装置包括:
    存储请求接收模块,用于接收针对待存储数据的存储请求,其中,所述存储请求中包括:所述待存储数据对应的目标文件的标识;
    目标虚拟存储段确定模块,用于根据所述目标文件的标识和元数据存储段中存储的信息,确定用于存储所述待存储数据的目标虚拟存储段,其中,所述元数据存储段为多个虚拟存储段中标识为预设值的虚拟存储段,用于存 储各个虚拟存储段与已存储文件之间的对应关系以及各个虚拟存储段的存储状态;
    起始存储位置确定模块,用于获得所述目标虚拟存储段中所存储数据的末尾存储位置,并将所获得的存储位置确定为所述待存储数据的起始存储位置;
    数据存储模块,用于从所述起始存储位置开始存储所述待存储数据。
  10. 根据权利要9所述的装置,其特征在于,所述目标虚拟存储段确定模块,包括:
    第一存储状态判断子模块,用于根据所述目标文件的标识,判断所述目标文件是否处于已存储状态;
    虚拟存储段获得子模块,用于在所述第一存储状态判断子模块判断结果为是的情况下,根据所述元数据存储段中存储的信息,获得存储所述目标文件的第一虚拟存储段;
    第二存储状态判断子模块,用于判断所述第一虚拟存储段是否处于可存储状态;
    第一目标虚拟存储段确定子模块,用于在所述第二存储状态判断子模块判断结果为是的情况下,根据所述第一虚拟存储段确定用于存储所述待存储数据的目标虚拟存储段。
  11. 根据权利要求10所述的装置,其特征在于,
    所述第一目标虚拟存储段确定子模块,具体用于将所述第一虚拟存储段中最后一次存储属于所述目标文件的数据的虚拟存储段,确定为用于所述待存储数据的目标虚拟存储段。
  12. 根据权利要求10或11所述的装置,其特征在于,所述目标虚拟存储段确定模块,还包括:
    第二目标虚拟存储段确定子模块,用于在所述第二存储状态判断子模块判断结果为否的情况下,从与所述第一虚拟存储段的物理地址最近的虚拟存储段中,确定用于存储所述待存储数据的目标虚拟存储段。
  13. 根据权利要求12所述的装置,其特征在于,所述第二目标虚拟存储段确定子模块,包括:
    存储方式获得单元,用于获得所述目标文件的存储方式;
    第一目标虚拟存储段确定单元,用于在所述存储方式为第一存储方式的情况下,确定与所述第一虚拟存储段的物理地址最近且未存储数据的虚拟存储段为用于存储所述待存储数据的目标虚拟存储段,其中,所述第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
    第二目标虚拟存储段确定单元,用于在所述存储方式为第二存储方式的情况下,获得与所述第一虚拟存储段的物理地址最近且所存储文件的存储方式不是所述第一存储方式的第二虚拟存储段;将所述第二虚拟存储段确定为用于存储所述待存储数据的目标虚拟存储段,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式。
  14. 根据权利要求10所述的装置,其特征在于,所述目标虚拟存储段确定模块,还包括:
    第一数据量获得子模块,用于在所述第一存储状态判断子模块判断结果为否的情况下,获得所述待存储数据的数据量;
    数据量判断子模块,用于判断所获得的数据量是否大于预设数据量;
    第一存储方式确定子模块,用于在所述数据量判断子模块判断结果为是的情况下,确定所述目标文件的存储方式为第一存储方式,其中,所述第一存储方式为:一个虚拟存储段中存储一个文件的存储方式;
    第二存储方式确定子模块,用于在所述数据量判断子模块判断结果为否的情况下,确定所述目标文件的存储方式为第二存储方式,其中,所述第二存储方式为:一个虚拟存储段中存储多个文件的存储方式;
    第三目标虚拟存储段确定子模块,用于根据所确定的存储方式,确定用于存储所述待存储数据的目标虚拟存储段;
    所述装置还包括:
    存储状态设置模块,用于将所述目标文件的存储状态设置为已存储状态。
  15. 根据权利要求9所述的装置,其特征在于,所述装置还包括:
    创建指令接收模块,用于接收针对待创建文件的文件创建指令;
    文件创建模块,用于创建所述待创建文件,并在所述元数据存储段中将所述待创建文件的存储状态设置为未存储状态,拒绝确定所述待创建文件的数据的起始存储位置。
  16. 根据权利要求9所述的装置,其特征在于,所述磁盘中包含多个物理存储区域,所述物理存储区域为所述磁盘的最小物理存储单元;
    所述数据存储模块,包括:
    第二数据量获得子模块,用于获得所述待存储数据的数据量;
    存储区域确定子模块,用于根据所述数据量,确定要存储所述待存储数据的各个目标物理存储区域;
    数据块划分子模块,用于在所述待存储数据要跨区域存储的情况下,根据所确定的各个目标物理存储区域的可用存储容量和所述数据量,将所述待存储数据划分为与各个目标物理存储区域对应的数据块;
    数据块存储子模块,用于将划分得到的数据块分别存储至对应的目标物理存储区域中。
  17. 一种终端,其特征在于,所述终端包括:壳体、处理器、存储器、电路板和电源电路,其中,所述电路板安置在所述壳体围成的空间内部,所述处理器和所述存储器设置在所述电路板上;所述电源电路,用于为所述终端的各个电路或器件供电;所述存储器用于存储可执行程序代码;所述处理器通过运行所述存储器中存储的可执行程序代码,以执行权利要求1-8任一项所述的数据存储方法。
  18. 一种可执行程序代码,其特征在于,所述可执行程序代码用于在运行时执行权利要求1-8任一项所述的数据存储方法。
  19. 一种存储介质,其特征在于,所述存储介质用于存储可执行程序代码,所述可执行程序代码被运行以执行权利要求1-8任一项所述的数据存储方法。
PCT/CN2016/097775 2016-04-26 2016-09-01 一种数据存储方法及装置 WO2017185579A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610269953.7 2016-04-26
CN201610269953.7A CN107315533A (zh) 2016-04-26 2016-04-26 一种数据存储方法及装置

Publications (1)

Publication Number Publication Date
WO2017185579A1 true WO2017185579A1 (zh) 2017-11-02

Family

ID=60161850

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/097775 WO2017185579A1 (zh) 2016-04-26 2016-09-01 一种数据存储方法及装置

Country Status (2)

Country Link
CN (1) CN107315533A (zh)
WO (1) WO2017185579A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109508143A (zh) * 2018-08-17 2019-03-22 郑州云海信息技术有限公司 一种数据存储方法及装置
CN110188903A (zh) * 2019-04-09 2019-08-30 口碑(上海)信息技术有限公司 预点单信息的处理方法及装置
CN111240843A (zh) * 2020-01-10 2020-06-05 北京猎豹移动科技有限公司 一种数据获取方法、装置、电子设备及存储介质
CN111666330A (zh) * 2019-03-06 2020-09-15 阿里巴巴集团控股有限公司 数据的读写方法和装置
US20230099290A1 (en) * 2017-08-07 2023-03-30 Weka.IO LTD Metadata control in a load-balanced distributed storage system

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108021513B (zh) * 2016-11-02 2021-09-10 杭州海康威视数字技术股份有限公司 一种数据存储方法及装置
CN108255742A (zh) * 2017-11-29 2018-07-06 深圳忆联信息***有限公司 一种大容量固态硬盘映射方法
CN110502184B (zh) * 2018-05-17 2021-01-05 杭州海康威视***技术有限公司 一种存储数据的方法、读取数据的方法、装置及***
CN109683825B (zh) * 2018-12-24 2022-05-24 广东浪潮大数据研究有限公司 一种存储***在线数据压缩方法、装置及设备
CN111506251B (zh) * 2019-01-30 2023-06-02 杭州海康威视***技术有限公司 数据处理方法、装置、smr存储***及存储介质
CN111400322B (zh) * 2020-03-25 2023-10-03 抖音视界有限公司 用于存储数据的方法、装置、电子设备和介质
CN113741796B (zh) * 2020-07-16 2024-04-16 北京沃东天骏信息技术有限公司 一种终端应用的数据持久化方法和装置
CN112214169B (zh) * 2020-09-28 2021-08-10 深圳大学 一种数据存储装置及存储数据的迁移方法
CN112199050A (zh) * 2020-10-22 2021-01-08 Tcl通讯(宁波)有限公司 存储方法、装置、存储介质及终端设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110252070A1 (en) * 2010-04-09 2011-10-13 Dell Products L.P. System and Method for Appending Metadata to Objects
CN102253898A (zh) * 2011-07-22 2011-11-23 杭州海康威视数字技术股份有限公司 一种图像数据的内存管理方法及装置
CN102622350A (zh) * 2011-01-26 2012-08-01 腾讯科技(深圳)有限公司 一种写数据的方法、装置及***
CN103761053A (zh) * 2013-12-30 2014-04-30 华为技术有限公司 一种数据处理方法和装置
CN105446664A (zh) * 2015-12-03 2016-03-30 深圳国微技术有限公司 一种对存储器进行文件存储方法和存储装置
CN105468642A (zh) * 2014-09-09 2016-04-06 杭州海康威视数字技术股份有限公司 数据的存储方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104346357B (zh) * 2013-07-29 2018-02-13 中国科学院声学研究所 一种嵌入式终端的文件存取方法及***
CN103955433A (zh) * 2014-05-09 2014-07-30 华为技术有限公司 盖瓦磁记录硬盘、盖瓦磁记录硬盘写数据的方法及装置
US20160103621A1 (en) * 2014-10-10 2016-04-14 Seagate Technology Llc Multi-Block Data Storage Using Data Compression
CN104461390B (zh) * 2014-12-05 2017-10-24 华为技术有限公司 将数据写入叠瓦状磁记录smr硬盘的方法及装置
CN105094695B (zh) * 2015-06-29 2018-09-04 浪潮(北京)电子信息产业有限公司 一种存储方法和***

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110252070A1 (en) * 2010-04-09 2011-10-13 Dell Products L.P. System and Method for Appending Metadata to Objects
CN102622350A (zh) * 2011-01-26 2012-08-01 腾讯科技(深圳)有限公司 一种写数据的方法、装置及***
CN102253898A (zh) * 2011-07-22 2011-11-23 杭州海康威视数字技术股份有限公司 一种图像数据的内存管理方法及装置
CN103761053A (zh) * 2013-12-30 2014-04-30 华为技术有限公司 一种数据处理方法和装置
CN105468642A (zh) * 2014-09-09 2016-04-06 杭州海康威视数字技术股份有限公司 数据的存储方法及装置
CN105446664A (zh) * 2015-12-03 2016-03-30 深圳国微技术有限公司 一种对存储器进行文件存储方法和存储装置

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230099290A1 (en) * 2017-08-07 2023-03-30 Weka.IO LTD Metadata control in a load-balanced distributed storage system
US11847098B2 (en) * 2017-08-07 2023-12-19 Weka.IO Ltd. Metadata control in a load-balanced distributed storage system
CN109508143A (zh) * 2018-08-17 2019-03-22 郑州云海信息技术有限公司 一种数据存储方法及装置
CN111666330A (zh) * 2019-03-06 2020-09-15 阿里巴巴集团控股有限公司 数据的读写方法和装置
CN111666330B (zh) * 2019-03-06 2023-05-02 阿里巴巴集团控股有限公司 数据的读写方法和装置
CN110188903A (zh) * 2019-04-09 2019-08-30 口碑(上海)信息技术有限公司 预点单信息的处理方法及装置
CN111240843A (zh) * 2020-01-10 2020-06-05 北京猎豹移动科技有限公司 一种数据获取方法、装置、电子设备及存储介质
CN111240843B (zh) * 2020-01-10 2024-05-14 北京聚云立方科技有限公司 一种数据获取方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN107315533A (zh) 2017-11-03

Similar Documents

Publication Publication Date Title
WO2017185579A1 (zh) 一种数据存储方法及装置
US11068455B2 (en) Mapper tree with super leaf nodes
US11461027B2 (en) Deduplication-aware load balancing in distributed storage systems
CN108647151B (zh) 一种全闪***元数据落盘方法、装置、设备及存储介质
US8856440B2 (en) Volatile memory representation of nonvolatile storage device set
WO2017201977A1 (zh) 一种数据写、读方法、装置及分布式对象存储集群
KR102569545B1 (ko) 키-밸류 스토리지 장치 및 상기 키-밸류 스토리지 장치의 동작 방법
EP2863310B1 (en) Data processing method and apparatus, and shared storage device
US9665485B2 (en) Logical and physical block addressing for efficiently storing data to improve access speed in a data deduplication system
US9672144B2 (en) Allocating additional requested storage space for a data set in a first managed space in a second managed space
US9201787B2 (en) Storage device file system and block allocation
US8751547B2 (en) Multiple file system and/or multi-host single instance store techniques
US9430492B1 (en) Efficient scavenging of data and metadata file system blocks
WO2021098267A1 (zh) 一种磁盘处理的方法、***、设备及可读存储介质
CN109240607B (zh) 一种文件读取方法和装置
CN103064639A (zh) 数据存储方法及装置
CN107122130B (zh) 一种数据重删方法及装置
WO2018171296A1 (zh) 一种文件合并方法及控制器
CN109804359A (zh) 用于将数据回写到存储设备的***和方法
CN111506269A (zh) 一种磁盘存储空间分配方法、装置、设备及存储介质
WO2019000949A1 (zh) 分布式存储***中元数据存储方法、***及存储介质
CN103399823A (zh) 业务数据的存储方法、设备和***
US20150088858A1 (en) Data storage device deferred secure delete
WO2020192710A1 (zh) 基于lsm数据库的垃圾处理的方法、固态硬盘以及存储装置
US10482012B1 (en) Storage system and method of operating thereof

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16900088

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 16900088

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 16900088

Country of ref document: EP

Kind code of ref document: A1