WO2022242419A1 - 分区创建方法、装置、存储介质及计算机设备 - Google Patents

分区创建方法、装置、存储介质及计算机设备 Download PDF

Info

Publication number
WO2022242419A1
WO2022242419A1 PCT/CN2022/088499 CN2022088499W WO2022242419A1 WO 2022242419 A1 WO2022242419 A1 WO 2022242419A1 CN 2022088499 W CN2022088499 W CN 2022088499W WO 2022242419 A1 WO2022242419 A1 WO 2022242419A1
Authority
WO
WIPO (PCT)
Prior art keywords
partition
sector
memory
capacity
storage capacity
Prior art date
Application number
PCT/CN2022/088499
Other languages
English (en)
French (fr)
Inventor
赵创
Original Assignee
RealMe重庆移动通信有限公司
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 RealMe重庆移动通信有限公司 filed Critical RealMe重庆移动通信有限公司
Publication of WO2022242419A1 publication Critical patent/WO2022242419A1/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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • 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/062Securing storage systems
    • G06F3/0622Securing storage systems in relation to access
    • 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/0629Configuration or reconfiguration of storage systems
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of computer application technology, and in particular to a partition creation method, device, storage medium and computer equipment.
  • the partitioning of the memory is to use the partition editor to divide several logical parts on the memory, and each logical part represents a partition. After the storage is divided into several partitions (Partition), different types of directories and files can be stored in different partitions.
  • a dynamic partition method is proposed, that is, by recording and detecting the state of blocks in each partition, and reserving different numbers of blocks for each partition according to the detected state as the number of bad blocks, which solves the problem of In order to avoid the problem of waste of resources caused by reserving more blocks for partitions in order to avoid bad blocks in the memory, there is a problem of reduced read and write performance of the memory caused by fragmentation of the storage space.
  • the embodiment of the present application provides a partition creation method, device, storage medium, and computer equipment, which can determine the unused first storage capacity between existing partitions by calculating the aligned sector position, and use the first storage capacity to create a target Partitioning ensures read and write performance while improving storage space utilization.
  • the embodiment of the present application provides a partition creation method, the method comprising:
  • each of the adjacent partitions includes the current partition and the next partition
  • a target partition is created based on a first storage capacity between each aligned sector position and a next partition in each of the adjacent partitions and a preset partition capacity.
  • an embodiment of the present application provides a partition creation device, and the partition creation device includes:
  • an aligned sector determination module configured to determine the aligned sector positions between adjacent partitions that already exist in the memory
  • a first capacity determining module configured to determine a first storage capacity between the aligned sector position and the next partition in each of the adjacent partitions, each of the adjacent partitions includes the current partition and the next partition;
  • a partition establishment module configured to create a target partition based on the first storage capacity between each of the aligned sector positions and the next partition in each of the adjacent partitions and a preset partition capacity.
  • an embodiment of the present application provides a storage medium, where a plurality of instructions are stored in the storage medium, and the instructions are adapted to be loaded by a processor and execute the above method steps.
  • an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded by the processor and execute the above-mentioned method steps .
  • the alignment sector position between the existing adjacent partitions in the memory is firstly determined, and then the alignment sector position to the next partition in each of the adjacent partitions is determined. Finally, according to the partition capacity of the target partition to be created, the target partition is created by using the unused first storage capacity between the adjacent partitions of the existing partition, which reduces the waste of resources, and based on The first storage capacity determined by aligning the sector positions also ensures the read/write performance of the memory. By adopting the embodiment of the present application, a good balance between memory space and performance can be achieved.
  • Fig. 1 provides a schematic flow diagram of a partition creation method according to an embodiment of the present application
  • FIG. 2 provides a schematic flowchart of a partition creation method according to an embodiment of the present application
  • FIG. 3 provides a schematic diagram of an example of partition coverage according to an embodiment of the present application.
  • Figure 4 provides an example schematic diagram of a partition not covered by the embodiment of the present application
  • FIG. 5 provides an exemplary schematic diagram of calculating the sector number of an aligned sector according to an embodiment of the present application
  • FIG. 6 provides a schematic diagram of an example of determining a partition gap in an embodiment of the present application.
  • FIG. 7 provides an exemplary schematic diagram of creating a target partition for an embodiment of the present application.
  • FIG. 8 provides a schematic structural diagram of a partition creation device according to an embodiment of the present application.
  • FIG. 9 provides a schematic structural diagram of a location determination module 15 according to an embodiment of the present application.
  • FIG. 10 provides a schematic structural diagram of a gap determination module 16 according to an embodiment of the present application.
  • FIG. 11 provides a schematic structural diagram of a partition establishment module 17 according to an embodiment of the present application.
  • FIG. 12 provides a schematic structural diagram of a computer device according to an embodiment of the present application.
  • FIG. 13 provides a schematic structural diagram of an operating system and user space according to an embodiment of the present application.
  • Fig. 14 is the architecture diagram of the Android operating system in Fig. 12;
  • FIG. 15 is a structural diagram of the IOS operating system in FIG. 12 .
  • plural means two or more.
  • “And/or” describes the association relationship of associated objects, indicating that there may be three types of relationships, for example, A and/or B may indicate: A exists alone, A and B exist simultaneously, and B exists independently.
  • the character “/” generally indicates that the contextual objects are an "or” relationship.
  • This solution is applied to computer equipment, and the computer equipment includes memory, and the memory includes but not limited to storage devices such as mechanical hard disk, solid state hard disk, internal memory, and flash memory.
  • the partition of the memory is to divide the overall storage space of the memory into multiple independent areas for the convenience, ease, and speed of file storage and management, which are used for the storage of different types of data such as operating systems, applications, and data files.
  • the traditional partition creation method is based on the capacity of the new partition to be created, on the basis of the original partition, a new section of space is allocated in the unused partition to create a new partition, and so on.
  • the block refers to the smallest unit for accessing data.
  • a block includes at least several sectors, and a sector is the smallest unit of value storage.
  • a sector The capacity of the zone is 512 bytes.
  • the storage medium has the characteristics of random distribution of bad blocks, that is, sectors that cannot be accessed are randomly distributed in the storage medium. Therefore, not only the capacity of the new partition needs to be considered when creating a new partition, but for To avoid the problem of randomly distributed bad blocks in the storage medium, it is necessary to reserve some sectors, but the number of reserved sectors is not reasonably allocated in the traditional partition creation method.
  • a dynamic partition method is proposed, that is, by recording and detecting the state of blocks in each partition, and reserving different numbers of blocks for each partition according to the detected state as the number of bad blocks, which solves the problem of In order to avoid the problem of resource waste caused by reserving more sectors for the partition in order to avoid randomly distributed bad blocks in the memory, it does not deal with the partition gap and does not consider the read and write performance of the memory.
  • the partition creation method proposed in this application determines the unused first storage capacity between the adjacent partitions of the existing partitions, and uses the first partition capacity to create a new target partition, which is the rational use of the unused first storage capacity , the resource utilization rate is improved, and the first storage capacity between adjacent partitions determined based on the aligned sectors ensures the read and write performance of the memory, and realizes the balanced use of the memory in terms of space and performance.
  • FIG. 1 provides a schematic flowchart of a method for creating a partition according to an embodiment of the present application.
  • the execution subject of the embodiment of the present application is a computer device, and the computer device includes a memory.
  • the partition creation method may include the following steps S101-S103.
  • a sector is the basic unit for reading and writing data in a memory, but since the sector capacity is relatively small and there are a large number of sectors in a memory, it is difficult to address when reading and writing data, so multiple sectors are usually Combined together to form a block, first address the block, and then address the sector, for example: the 101st sector to the 300th sector is the first block, then the 301st sector to the 500th sector is the second block, wherein the first sector of each block is defined as an aligned sector, for example, the 101st sector and the 301st sector.
  • the basic unit for reading and writing data in the memory is a sector, and each sector has a storage space of 512B.
  • the aligned sector with the smallest sector number is determined from the unused sectors between adjacent partitions, and the sector number of the aligned sector indicates that the aligned sector location in memory.
  • the adjacent partitions mean that there are no other partitions between the two partitions.
  • the sector area divided by partition 1 includes the 101st sector to the 3000th sector, while the sector area divided by partition 2 is the 4000th sector From the 6400th sector to the 6400th sector, if the 3001st to 3999th sector is not used by the partition, then the partition 1 and the partition 2 are considered as adjacent partitions.
  • the aligned sector position is located between the current partition and the next partition, and an unused storage space between the aligned sector position and the next partition is used as the first storage capacity.
  • the preset partition capacity and the capacity of the first partition capacity between the adjacent partitions use the first partition capacity to create the target partition, if the total storage capacity of the first partition capacity is greater than Or equal to the preset partition capacity, then only the gaps between the partitions can be used to create the target partition, if the total storage capacity of the first partition capacity is less than the preset partition capacity, then the capacity of each first partition is used as the Part of the target partition, and then create the remaining part of the target partition where there is no partition after the last partition.
  • the capacity of the partition gap can be calculated based on the number of sectors included in each partition gap.
  • the unit of the partition capacity is byte (B), and byte is the smallest unit representing the meaning of information in a computer.
  • the unit representing storage capacity also includes KB, MB, GB, T, etc., wherein 1KB is equal to 1024B , 1MB is equal to 1024KB, 1GB is equal to 1024MB, and 1T is equal to 1024GB.
  • the partition creation method proposed in this application determines the unused first storage capacity between the adjacent partitions of the existing partitions, and uses the first partition capacity to create a new target partition, which is the rational use of the unused first storage capacity , the resource utilization rate is improved, and the first storage capacity between adjacent partitions determined based on the aligned sectors ensures the read and write performance of the memory, and realizes the balanced use of the memory in terms of space and performance.
  • FIG. 2 provides a schematic flowchart of a method for creating a partition according to the embodiment of the present application.
  • the execution subject of the embodiment of the present application is a computer device, and the computer device includes a memory.
  • the method for creating a partition may include the following steps S201-S212.
  • the second storage capacity between the last sector positions is used as the remaining storage capacity of the memory.
  • the target partition of the preset partition capacity cannot be established; if the remaining storage capacity is greater than or equal to the preset partition capacity, it indicates that the memory has enough remaining storage space to create a new partition, then It is judged whether the existing partitions in the storage include the target partition to be created. For example, if there is already a King of Glory partition in the storage, and now the King of Glory partition is undergoing a major update, a partition needs to be created for storage. In this case, the target partition to be created already exists in the memory.
  • the target partition to be created already exists in the existing partitions in the memory
  • the target partition is extended from the last sector of the target partition based on the preset partition capacity.
  • the end sector of the target partition changes, and the position of the end sector of the target partition cannot exceed the start sector of the next partition of the target partition position, if the end sector position of the target partition exceeds the start sector position of the next partition of the target partition, it is considered that the extended target partition covers the next partition of the target partition, otherwise, if the If the end sector position of the target partition does not exceed the start sector position of the next partition of the target partition, it is considered that the extended target partition does not cover the next partition of the target partition.
  • FIG. 3 provides an exemplary schematic diagram of partition coverage according to the embodiment of the present application.
  • the existing partition 1 includes sectors 201 to 1556, and the existing partition 2 includes sectors 2701 to 4158. If partition 1 is expanded according to the preset partition capacity, the expanded partition is as follows: The dotted line in the figure includes sector 1557 to sector 3358. It is obvious that sector 2701 to sector 3358 of the storage area has been used by partition 2, that is, the extended target partition covers the next partition of the target partition.
  • FIG. 4 provides an exemplary schematic diagram of non-coverage of partitions according to the embodiment of the present application.
  • the existing partition 1 includes sectors 201 to 1556, and the existing partition 2 includes sectors 2701 to 4158. If partition 1 is expanded according to the preset partition capacity, the expanded partition is as follows: The dotted line in the figure includes sector 1557 to sector 2594. Obviously, the extended part of partition 1 does not cover any partition, 2594 ⁇ 2701, that is, the extended target partition does not cover the next partition of the target partition, and the sector 201 to The storage area of sector 2594 is used as the target partition.
  • traversing the existing partitions in the memory based on the sector number and sector capacity of the last sector in the current partition, and the alignment parameters of the memory, calculate the location to which the last sector in the current partition belongs.
  • Alignment area based on the alignment area to which the last sector in the current partition belongs, the alignment parameter of the memory, the alignment offset, and the sector capacity, calculate the alignment sector between the current partition and the next partition District location.
  • the alignment parameter of the memory is a single block capacity
  • the alignment area is a block
  • the calculation of the alignment area to which the last sector in the current partition belongs is to calculate the block of the block to which the last sector in the current partition belongs Numbering.
  • the current partition refers to one of the existing partitions. Using this method to traverse all the existing partitions in the memory, the block number of the block to which the last sector of each partition belongs can be obtained.
  • the alignment offset means that the first aligned sector of the memory is not the sector whose sector number is 1, and the storage between the sector whose sector number is 1 and the first aligned sector
  • the capacity is the alignment offset. For example, if the sector number of the first aligned sector is 61, the alignment offset is 60 sectors.
  • the alignment area is the block number of the block to which it belongs, multiplying the block number by the alignment parameter of the memory, and adding the obtained result to the alignment offset to obtain:
  • the storage capacity between the sector whose sector number is 1 and the last sector of the alignment area is divided by the storage capacity between the sector whose sector number is 1 and the last sector of the alignment area
  • the capacity of a single sector is the number of sectors from the sector with the sector number 1 to the last sector in the alignment area, and adding 1 to the number of sectors obtained is the sector number of the aligned sector .
  • FIG. 5 provides an exemplary schematic diagram of calculating the sector number of the aligned sector according to the embodiment of the present application.
  • partition 1 and partition 2 there are two existing partitions, partition 1 and partition 2, where partition 1 includes the 201st sector to the 1556th sector, and partition 2 includes the 2701st sector to the 5000th sector , the alignment offset includes sector 1 to sector 101, a total of 100 sectors are offset, and the capacity of each alignment area is 204800B.
  • the first alignment area is from the 101st sector to the 500th sector. And so on.
  • the alignment area can also be called a block.
  • the sector number of the last sector of partition 1 is multiplied by the capacity of a single sector and then divided by the capacity of a single alignment area.
  • the alignment area to which the last sector of partition 1 belongs is the fourth alignment area, and then use the alignment area to which the last sector belongs
  • S209. Determine the first storage capacity between the aligned sector position and the next partition in each of the adjacent partitions, where each of the adjacent partitions includes the current partition and the next partition;
  • determine the starting position of the first sector of the next partition if the aligned sector position between the current partition and the next partition is smaller than the starting position of the first sector of the next partition start position, determine the first storage capacity between the aligned sector position and the start position of the first sector of the next partition, if the aligned sector position between the current partition and the next partition is greater than or equal to the starting position of the first sector of the next partition, and it is determined that there is no first storage capacity between the current partition and the next partition.
  • the starting position of the first sector is the sector number of the first sector
  • the current partition refers to the previous partition of each adjacent partition
  • the next partition refers to the previous partition of each adjacent partition.
  • partition 1 and partition 2 are adjacent partitions
  • the sector area divided by partition 1 includes the 101st sector to the 3000th sector
  • the sector area divided by partition 2 is the 4000th sector to
  • partition 1 is the current partition
  • partition 2 is the next partition
  • the sector number of the first sector of the next partition is 4000.
  • the current partition and the next partition are adjacent partitions, there is a certain number of unused sectors between the current partition and the next partition, and the judgment is based on the aligned sectors calculated by the current partition Whether it belongs to an unused sector between the current partition and the next partition.
  • the aligned sector position between the current partition and the next partition is transferred to the next partition
  • the gap between the starting positions of the first sector is the first storage capacity between the current partition and the next partition.
  • the sector number of the aligned sector is greater than or equal to the sector number of the first sector of the next partition, it is determined that the first storage capacity does not exist between the current partition and the next partition.
  • the memory reads and writes data based on block reading and writing. If a string of data is stored in one block, the memory only needs to read one block; if a string of data is stored in two In a block, a part is stored in a block, and if the memory wants to read this string of data, it needs to read two blocks, which will waste more time than storing this string of data in one block for reading. Therefore, the first storage capacity is determined from the aligned sector to the first sector of the next partition, so that each first storage capacity is used from the first sector of a block when storing data , which can improve the reading efficiency.
  • FIG. 6 provides an exemplary schematic diagram of determining the first storage capacity for the embodiment of the present application.
  • partition 1 and partition 2 are adjacent partitions
  • partition 2 and partition 3 are adjacent partitions
  • partition 1 includes the first 201st sector to 1556th sector
  • partition 2 includes 2701st sector to 4158th sector
  • partition 3 includes 4276th sector to 5875th sector, calculated based on the last sector of partition 1 It is obtained that the aligned sector between partition 1 and partition 2 is sector 1701, and the first sector of partition 2 is sector 2701, then sector 1701 does not exceed sector 2701, and the first storage capacity exists as sector 1701 to sector 2701; and according to the last sector of partition 2, the aligned sector between partition 2 and partition 3 is sector 4501, the first sector of partition 3 in the figure is sector 4276, sector 4501 exceeds sector 4276, and the sector number of the aligned sector is greater than the sector number of the first sector of partition 3, then there is no first storage capacity between partition 2 and partition 3.
  • the total storage capacity is obtained by adding the first storage capacities calculated between adjacent partitions.
  • each of the first storage capacities is regarded as a part of the target partition, and then each of the existing partitions in the memory is determined.
  • the last partition of the partition and obtain the sector number of the last sector of the last partition, and then determine the sector number of the first aligned sector after the last partition in the manner described in step S208,
  • the sector number of the aligned sector represents the position of the aligned sector, starting from the aligned sector position, using the difference between the preset partition capacity and the total storage capacity as the storage capacity, creating a sub-partition, and finally Each of the first storage capacity and the sub-partition is used as the target partition.
  • the target partition is not created using the first partition capacity, and the last partition of each partition existing in the memory is directly determined. partition, and obtain the sector number of the last sector of the last partition, and then determine the sector number of the first aligned sector after the last partition in the manner described in step S208, the aligned sector
  • the sector number of the zone represents the aligned sector position, and the target partition is created with the aligned sector position as the starting point and the preset partition capacity as the storage capacity.
  • each first storage capacity between adjacent partitions is equal to the preset partition capacity
  • directly use each of the first storage capacities to create a target partition If the total storage capacity of a storage capacity is greater than the preset partition capacity, the first storage capacities are superimposed according to the order of the first storage capacities, and when the superimposed storage capacity is equal to the preset partition capacity, the The superimposed capacity of the first partition is used as the target partition.
  • the order of the first storage capacity can be sorted according to the sector numbers of the sectors in the first storage capacity, and the smaller the sector number of the sector, the higher the front.
  • the superposition of each first storage capacity refers to the The first storage capacity is superimposed one by one in order and compared with the preset partition capacity during the superposition process, and then when the superimposed storage capacity is equal to the preset partition capacity, each first storage capacity to be superimposed is taken as the target Let’s take an example to illustrate the partitions.
  • the storage has five first storage capacities, namely the first storage capacity 1, the first storage capacity 2, the first storage capacity 3, the first storage capacity 4, and the first storage capacity A storage capacity 5, first compare the first storage capacity 1 and the preset partition capacity, if the preset partition capacity is greater than the first storage capacity 1, then superimpose the first storage capacity 1 and the first storage capacity 2, and then compare The storage capacity after the first storage capacity 1 and the first storage capacity 2 are superimposed and the preset partition capacity, and so on, until the first storage capacity 1, the first storage capacity 2, the first storage capacity 3 and the first storage capacity 4 If the superimposed storage capacity of the four first storage capacities is greater than the preset partition capacity, the four first storage capacities of first storage capacity 1, first storage capacity 2, first storage capacity 3, and first storage capacity 4 storage capacity as the target partition.
  • the storage capacities of the first three first storage capacities may also be superimposed, and the first three first storage capacities may be used as part of the target partition, Then determine the sector number of the first sector of the 4th first storage capacity, starting from the first sector of the 4th first storage capacity, taking the preset partition capacity and the first three The difference between the superimposed storage capacity of the first storage capacity is the storage capacity, a sub-partition is created, and finally the first three first storage capacities and the sub-partition are used as the target partition.
  • steps S211 to S212 provides an exemplary schematic diagram of creating a target partition for the embodiment of the present application.
  • the gap capacity of the first storage capacity 1 is 256000, a total of 500 sectors, and the gap capacity of the first storage capacity 2 is 204800, There are 400 sectors in total, the gap capacity of the first storage capacity 3 is 307200, a total of 600 sectors, and the gap capacity of the first storage capacity 4 is 358400, a total of 700 sectors.
  • the total storage capacity of the first storage capacity is less than the preset partition capacity
  • the total storage capacity of the first storage capacity is equal to the preset partition capacity
  • the total storage capacity of the first storage capacity is greater than the preset partition capacity.
  • the target partition should include the first storage capacity 1, the second A storage capacity 2, a first storage capacity 3, a first storage capacity 4 and a sub-partition created after the last partition whose capacity is equal to the preset partition capacity minus the total storage capacity of the 4 first storage capacities , the first sector of the sub-partition is the first aligned sector after the last partition, and the aligned sector is calculated based on the sector number of the last sector in the last partition.
  • the target partition should include the first storage capacity 1, the first Storage capacity 2, first storage capacity 3, first storage capacity 4.
  • the target partition should include the first storage capacity 1, the first storage capacity 2, and the first storage capacity 3 at this time.
  • the step of obtaining the remaining storage capacity of the memory, comparing the remaining storage capacity with the preset storage capacity, and the step of judging whether the target partition to be created already exists in the memory may be performed in parallel All of them can be executed independently, and there is no restrictive logical sequence.
  • the target partition with the preset partition capacity cannot be established, if the remaining storage capacity greater than or equal to the preset partition capacity, then the target partition of the preset partition capacity can be established, which ensures the feasibility of partition creation; then judge whether the target partition to be created already exists in the memory, and determine whether the creation of the target partition is new
  • the creation of a partition is also an extension of an existing partition. If the target partition to be created already exists in the memory and the expanded target partition does not cover the next partition of the target partition, then the expanded target partition is used as the target partition.
  • the created target partition is convenient for the expansion of the existing partition; if there is no target partition to be created in the storage, calculate the first storage capacity among the existing partitions, and use the first storage capacity and the remaining storage capacity to create the target partition , the unused first storage capacity is reasonably used, which improves resource utilization, and the first storage capacity between adjacent partitions determined based on the aligned sector positions ensures the read and write performance of the memory, realizing Balanced use of memory space and performance.
  • the partition creation apparatus 1 can be implemented as all or part of a terminal device through software, hardware or a combination of the two.
  • the partition creation device 1 includes a remaining capacity acquisition module 11, a partition judgment module 12, a partition extension module 13, a coverage judgment module 14, a position determination module 15, a gap determination module 16, and a partition establishment module 17, specifically including :
  • a remaining capacity acquiring module 11 configured to acquire the remaining storage capacity of the memory
  • a partition judging module 12 configured to judge whether the target partition to be created already exists in the memory
  • a partition extension module 13 configured to extend the target partition after the last sector of the target partition if the target partition to be created already exists in the memory
  • Coverage judging module 14 for judging whether the expanded target partition covers the next partition of the target partition
  • a position determining module 15 configured to determine the aligned sector positions between adjacent partitions existing in the memory
  • a gap determination module 16 configured to determine a first storage capacity between the aligned sector position and the next partition in each of the adjacent partitions, each of the adjacent partitions includes the current partition and the next partition;
  • the partition establishment module 17 is configured to create a target partition based on the first storage capacity between each of the aligned sector positions and the next partition in each of the adjacent partitions and a preset partition capacity.
  • the remaining capacity acquisition module is specifically used for:
  • the second storage capacity between the target aligned sector position after the last partition and the last sector position of the memory is used as the remaining storage capacity of the memory.
  • the position determination module is further configured to perform the determination of the aligned sector positions between adjacent partitions that already exist in the memory if the remaining storage capacity is greater than or equal to the preset partition capacity A step of.
  • the location determination module is further configured to perform the determining the alignment sector between adjacent partitions existing in the memory if the extended target partition covers the next partition of the target partition. Steps for district location.
  • the position determining module is further configured to perform the determining the alignment sector positions between adjacent partitions that already exist in the memory if the target partition to be created does not exist in the memory A step of;
  • the partition extension module is further configured to use the extended target partition as the created target partition if the extended target partition does not cover the next partition of the target partition.
  • FIG. 9 a schematic structural diagram of a position determination module 15 is provided for this embodiment of the present application.
  • the position determining module 15 includes:
  • the area calculation unit 151 is configured to traverse the existing partitions in the memory, and calculate the last sector in the current partition based on the sector number, sector capacity and alignment parameters of the memory in the current partition.
  • a location calculation unit 152 configured to calculate the distance between the current partition and the next partition based on the alignment area to which the last sector in the current partition belongs, the alignment parameter of the memory, the alignment offset, and the sector capacity. The alignment sector position between.
  • FIG. 10 a schematic structural diagram of a gap determination module 16 is provided for the embodiment of the present application.
  • the gap determination module 16 includes:
  • a start sector determination unit 161, configured to determine the start position of the first sector of the next partition
  • the first gap determination unit 162 is configured to determine that the aligned sector position between the current partition and the next partition is smaller than the starting position of the first sector of the next partition a first storage capacity between the start of the first sector of the next partition;
  • the second gap determination unit 163 is configured to determine that the current partition is to There is no first storage capacity between the next partitions.
  • FIG. 11 a schematic structural diagram of a partition establishment module 17 is provided for the embodiment of the present application.
  • the partition building module 17 includes:
  • a total capacity acquisition unit 171, configured to calculate the sum of the first storage capacities between the adjacent partitions to obtain the total storage capacity
  • the first partition creation unit 172 is configured to, if the total storage capacity is less than the preset partition capacity, start from the target aligned sector position after the last partition existing in the memory, and use the preset partition The difference between the capacity and the total storage capacity is the storage capacity, and the target partition is created;
  • the second partition creation unit 173 is configured to select a preset partition capacity from the total storage capacity to create a target partition if the total storage capacity is greater than or equal to the preset partition capacity.
  • the partition creation device when the partition creation device provided in the above embodiment executes the partition creation method, it only uses the division of the above-mentioned functional modules as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional modules according to needs. , which divides the internal structure of the device into different functional modules to complete all or part of the functions described above.
  • the device for creating a partition provided by the above embodiment is based on the same idea as the method for creating a partition, and its implementation process can be found in the method embodiment for details, and will not be repeated here.
  • the target partition with the preset partition capacity cannot be established, if the remaining storage capacity greater than or equal to the preset partition capacity, then the target partition of the preset partition capacity can be established, which ensures the feasibility of partition creation; then judge whether the target partition to be created already exists in the memory, and determine whether the creation of the target partition is new
  • the creation of a partition is also an extension of an existing partition. If the target partition to be created already exists in the memory and the expanded target partition does not cover the next partition of the target partition, then the expanded target partition is used as the target partition.
  • the created target partition is convenient for the expansion of the existing partition; if there is no target partition to be created in the storage, calculate the first storage capacity among the existing partitions, and use the first storage capacity and the remaining storage capacity to create the target partition , the unused first storage capacity is reasonably used, which improves resource utilization, and the first storage capacity between adjacent partitions determined based on the aligned sector positions ensures the read and write performance of the memory, realizing Balanced use of memory space and performance.
  • the embodiment of the present application also provides a computer storage medium, and the computer storage medium can store a plurality of instructions, and the instructions are suitable for being loaded and executed by a processor as described in the above-mentioned embodiments shown in FIGS. 1 to 7 .
  • the specific execution process can refer to the specific description of the embodiments shown in FIG. 1 to FIG. 7 , and details are not repeated here.
  • the present application also provides a computer program product, the computer program product stores at least one instruction, the at least one instruction is loaded by the processor and executes the partition creation in the embodiment shown in the above-mentioned Fig. 1 to Fig. 7
  • the method for the specific execution process, refer to the specific description of the embodiments shown in FIG. 1 to FIG. 7 , and details are not repeated here.
  • FIG. 12 shows a structural block diagram of a computer device provided by an exemplary embodiment of the present application.
  • a computer device in this application may include one or more of the following components: a processor 110 , a memory 120 , an input device 130 , an output device 140 and a bus 150 .
  • the processor 110 , the memory 120 , the input device 130 and the output device 140 may be connected through a bus 150 .
  • Processor 110 may include one or more processing cores.
  • the processor 110 uses various interfaces and lines to connect various parts of the entire computer equipment, and executes the computer by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120.
  • Various functions and processing data of the device 100 may use at least one of digital signal processing (digital signal processing, DSP), field-programmable gate array (field-programmable gate array, FPGA), programmable logic array (programmable logic array, PLA) implemented in the form of hardware.
  • the processor 110 may integrate one or a combination of a central processing unit (central processing unit, CPU), an image processor (graphics processing unit, GPU), a modem, and the like.
  • the CPU mainly handles the operating system, user interface and application programs, etc.; the GPU is used to render and draw the displayed content; the modem is used to handle wireless communication. It can be understood that, the above-mentioned modem may not be integrated into the processor 110, but may be realized by a communication chip alone.
  • the memory 120 may include a random access memory (random Access Memory, RAM), and may also include a read-only memory (read-only memory, ROM).
  • RAM random Access Memory
  • ROM read-only memory
  • the memory 120 includes a non-transitory computer-readable storage medium.
  • the memory 120 may be used to store instructions, programs, codes, sets of codes, or sets of instructions.
  • the memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system and instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.) , instructions for implementing the following various method embodiments, etc.
  • the operating system can be an Android system, including a system based on the deep development of the Android system, an IOS system developed by Apple, including a system based on the deep development of the IOS system or other systems.
  • the storage data area can also store data created by the computer device during use, such as phonebook, audio and video data, chat record data, and the like.
  • the memory 120 can be divided into an operating system space and a user space.
  • the operating system runs in the operating system space, and native and third-party applications run in the user space.
  • the operating system allocates corresponding system resources for different third-party application programs.
  • different application scenarios in the same third-party application have different requirements for system resources. For example, in the local resource loading scenario, the third-party application has higher requirements for disk reading speed; in the animation rendering scenario, the second Three-party applications have higher requirements on GPU performance.
  • the operating system and third-party applications are independent of each other, and the operating system often cannot perceive the current application scenarios of the third-party applications in a timely manner, resulting in the inability of the operating system to perform targeted system resource adaptation according to the specific application scenarios of the third-party applications.
  • the memory 120 can store a Linux kernel layer 320, a system runtime library layer 340, an application framework layer 360 and an application layer 380, Among them, the Linux kernel layer 320 , the system runtime layer 340 and the application framework layer 360 belong to the operating system space, and the application layer 380 belongs to the user space.
  • the Linux kernel layer 320 provides underlying drivers for various hardware of computer equipment, such as display drivers, audio drivers, camera drivers, Bluetooth drivers, Wi-Fi drivers, power management, and the like.
  • the system runtime layer 340 provides main feature support for the Android system through some C/C++ libraries.
  • the SQLite library provides database support
  • the OpenGL/ES library provides 3D drawing support
  • the Webkit library provides browser kernel support.
  • An Android runtime (Android runtime) is also provided in the system runtime library layer 340, which mainly provides some core libraries and can allow developers to use the Java language to write Android applications.
  • the application framework layer 360 provides various APIs that may be used when building applications. Developers can also use these APIs to build their own applications, such as activity management, window management, view management, notification management, content providers, Package management, call management, resource management, location management.
  • the IOS system includes: a core operating system layer 420 (Core OS layer), a core service layer 440 (Core Services layer), a media layer 460 (Media layer), touchable layer 480 (Cocoa Touch Layer).
  • the core operating system layer 420 includes an operating system kernel, drivers, and underlying program frameworks. These underlying program frameworks provide functions closer to hardware for use by the program frameworks located in the core service layer 440 .
  • the core service layer 440 provides system services and/or program frameworks required by applications, such as foundation framework, account framework, advertisement framework, data storage framework, network connection framework, geographic location framework, exercise framework and so on.
  • the media layer 460 provides audio-visual interfaces for applications, such as interfaces related to graphics and images, interfaces related to audio technology, interfaces related to video technology, and wireless playback (AirPlay) interfaces of audio and video transmission technologies.
  • the touchable layer 480 provides various commonly used interface-related frameworks for application development, and the touchable layer 480 is responsible for the user's touch interaction on the computer device. Such as local notification service, remote push service, advertising framework, game tool framework, message user interface interface (User Interface, UI) framework, user interface UIKit framework, map framework and so on.
  • frameworks related to most applications include but are not limited to: the basic framework in the core service layer 440 and the UIKit framework in the touchable layer 480 .
  • the basic framework provides many basic object classes and data types, and provides the most basic system services for all applications, regardless of UI.
  • the class provided by the UIKit framework is a basic UI class library for creating a touch-based user interface. iOS applications can provide UI based on the UIKit framework, so it provides the infrastructure of the application for building user interfaces, drawing , Handle and user interaction events, respond to gestures, and more.
  • the method and principle of implementing the data communication between the third-party application program and the operating system in the IOS system can refer to the Android system, and this application will not repeat them here.
  • the input device 130 is used for receiving input instructions or data, and the input device 130 includes but not limited to a keyboard, a mouse, a camera, a microphone or a touch device.
  • the output device 140 is used to output instructions or data, and the output device 140 includes but not limited to a display device and a speaker.
  • the input device 130 and the output device 140 can be set together, and the input device 130 and the output device 140 are touch screens, and the touch screen is used to receive any suitable object such as a finger, a touch pen, etc. Nearby touch operation, and display the user interface of each application.
  • the touch display screen is usually arranged on the front panel of the computer equipment. Touch screens can be designed as full screens, curved screens or special-shaped screens. The touch display screen can also be designed as a combination of a full screen and a curved screen, or a combination of a special-shaped screen and a curved screen, which is not limited in this embodiment of the present application.
  • the structure of the computer equipment shown in the above drawings does not constitute a limitation on the computer equipment, and the computer equipment may include more or less components than those shown in the illustration, or combine certain some components, or a different arrangement of components.
  • the computer device also includes components such as a radio frequency circuit, an input unit, a sensor, an audio circuit, a wireless fidelity (WiFi) module, a power supply, and a Bluetooth module, which will not be repeated here.
  • WiFi wireless fidelity
  • each step may be the computer device introduced above.
  • each step is executed by an operating system of a computer device.
  • the operating system may be an Android system, an IOS system, or other operating systems, which is not limited in this embodiment of the present application.
  • the computer equipment of the embodiment of the present application can also be equipped with a display device on it, and the display device can be various devices that can realize display functions, such as: a cathode ray tube display (cathode ray tube display, CR for short), a light emitting diode display (light -emitting diode display, referred to as LED), electronic ink screen, liquid crystal display (liquid crystal display, referred to as LCD), plasma display panel (plasma display panel, referred to as PDP), etc. Users can use the display device on the computer device 101 to view information such as displayed text, images, and videos.
  • a cathode ray tube display cathode ray tube display, CR for short
  • a light emitting diode display light -emitting diode display, referred to as LED
  • electronic ink screen liquid crystal display (liquid crystal display, referred to as LCD), plasma display panel (plasma display panel, referred to as PDP), etc.
  • LCD liquid crystal display
  • PDP plasma display
  • the computer device may be a smart phone, a tablet computer, a game device, an AR (Augmented Reality, augmented reality) device, a car, a data storage device, an audio playback device, a video playback device, a notebook, a desktop computing device, a wearable device such as an electronic Watches, electronic glasses, electronic helmets, electronic bracelets, electronic necklaces, electronic clothing and other equipment.
  • a wearable device such as an electronic Watches, electronic glasses, electronic helmets, electronic bracelets, electronic necklaces, electronic clothing and other equipment.
  • the processor 110 can be used to call the partition creation program stored in the memory 120, and specifically perform the following operations:
  • each of the adjacent partitions includes the current partition and the next partition
  • a target partition is created based on a first storage capacity between each aligned sector position and a next partition in each of the adjacent partitions and a preset partition capacity.
  • the target partition to be created does not exist in the memory, performing the step of determining the alignment sector positions between adjacent partitions that already exist in the memory;
  • the step of determining the alignment sector positions between the existing adjacent partitions in the memory is performed.
  • the remaining storage capacity is greater than or equal to the preset partition capacity, then determine the aligned sector positions between adjacent partitions existing in the memory.
  • the processor 110 specifically performs the following operations when performing the acquiring the remaining storage capacity of the memory:
  • the second storage capacity between the target aligned sector position after the last partition and the last sector position of the memory is used as the remaining storage capacity of the memory.
  • the processor 110 specifically performs the following operations when performing the determination of the aligned sector positions between the existing adjacent partitions in the memory:
  • the processor 110 executes the determining the first storage capacity between the aligned sector position and the next partition in each of the adjacent partitions, specifically perform the following operations:
  • aligned sector position between the current partition and the next partition is smaller than the start position of the first sector of the next partition, determine the aligned sector position to the first sector of the next partition a first storage capacity between start locations of sectors;
  • the processor 110 creates a target based on the first storage capacity between each of the aligned sector positions and the next partition in each of the adjacent partitions and the preset partition capacity when performing the When partitioning, specifically perform the following operations:
  • the preset partition capacity If the total storage capacity is less than the preset partition capacity, start from the target aligned sector position after the last partition existing in the memory, and use the difference between the preset partition capacity and the total storage capacity The value is the storage capacity, create the target partition;
  • the preset partition capacity is selected from the total storage capacity to create a target partition.
  • the target partition with the preset partition capacity cannot be established, if the remaining storage capacity greater than or equal to the preset partition capacity, then the target partition of the preset partition capacity can be established, which ensures the feasibility of partition creation; then judge whether the target partition to be created already exists in the memory, and determine whether the creation of the target partition is new
  • the creation of a partition is also an extension of an existing partition. If the target partition to be created already exists in the memory and the expanded target partition does not cover the next partition of the target partition, then the expanded target partition is used as the target partition.
  • the created target partition is convenient for the expansion of the existing partition; if there is no target partition to be created in the storage, calculate the first storage capacity among the existing partitions, and use the first storage capacity and the remaining storage capacity to create the target partition , the unused first storage capacity is reasonably used, which improves resource utilization, and the first storage capacity between adjacent partitions determined based on the aligned sector positions ensures the read and write performance of the memory, realizing Balanced use of memory space and performance.
  • the disclosed device can be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be combined or can be Integrate into another system, or some features may be ignored, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some service interfaces, and the indirect coupling or communication connection of devices or units may be in electrical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable memory.
  • the technical solution of the present application is essentially or part of the contribution to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory.
  • a computer device which may be a personal computer, server or network device, etc.
  • the aforementioned memory includes: U disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
  • the program can be stored in a computer-readable memory, and the memory can include: flash memory disk, read-only memory (Read-Only Memory, ROM), random access device (Random Access Memory, RAM), magnetic disk or optical disk, etc.

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)
  • Devices For Executing Special Programs (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Memory System (AREA)

Abstract

本申请实施例公开了一种分区创建方法、装置、存储介质及计算机设备,所述方法包括:确定所述存储器中已存在的各相邻分区之间的对齐扇区位置,然后确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。采用本申请实施例,可以利用已存在的各相邻分区之间未使用的第一分区容量建立新的目标分区,减少了资源的浪费,且基于存储器的对齐扇区位置确定的第一存储容量又保证了存储器的读写性能。

Description

分区创建方法、装置、存储介质及计算机设备
相关申请的交叉引用
本申请要求于2021年05月20日提交的申请号为202110553721.5的中国新申请的优先权,其在此出于所有目的通过引用将其全部内容并入本文。
技术领域
本申请涉及计算机应用技术领域,尤其涉及一种分区创建方法、装置、存储介质及计算机设备。
背景技术
存储器的分区是使用分区编辑器(partition editor)在存储器上划分几个逻辑部分,每个逻辑部分代表一个分区。存储器被划分成数个分区(Partition)后,不同类的目录与文件可以在不同的分区内进行存储。
常规技术中,若要新增分区,一般在未使用的分区中划出一个新的分区,而每个新的分区中都会预留一部分块以应对存储器中存在坏块的问题,导致资源浪费。而后为解决资源浪费的问题提出了一种动态分区的方法,即通过记录检测各分区的块的状态,依据检测到的状态为坏块的数量为每个分区预留不同数量的块,解决了为规避存储器中坏块而为分区预留较多的块引起的资源浪费问题,但是存在存储空间碎片化导致的存储器的读写性能降低问题。
发明内容
本申请实施例提供了一种分区创建方法、装置、存储介质及计算机设备,可以通过计算出对齐扇区位置来确定已存在分区之间未使用的第一存储容量,利用第一存储容量创建目标分区,在提高存储器的空间利用率的同时保证读写性能。
所述技术方案如下:
第一方面,本申请实施例提供了一种分区创建方法,所述方法包括:
确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。
第二方面,本申请实施例提供了一种分区创建装置,所述分区创建装置包括:
对齐扇区确定模块,用于确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
第一容量确定模块,用于确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
分区建立模块,用于基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。
第三方面,本申请实施例提供一种存储介质,所述存储介质存储有多条指令,所述指令适于由处理器加载并执行上述的方法步骤。
第四方面,本申请实施例提供一种计算机设备,可包括:处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器加载并执行上述的方法步骤。
本申请一些实施例提供的技术方案带来的有益效果至少包括:
在本申请实施例中,首先确定所述存储器中已存在的各相邻分区之间的对齐扇区位置,接着确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,最后根据待创建的目标分区的分区容量,利用已存在的分区各相邻分区之间未被使用的所述第一存储容量创建目标分区,减少了资源的浪费,且基于对齐扇区位置所确定的第一存储容量又保证了存储器的读写性能,采用本申请实施例,可以很好的达到存储器空间和性能上的均衡。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供了一种分区创建方法的流程示意图;
图2为本申请实施例提供了一种分区创建方法的流程示意图;
图3为本申请实施例提供了一种分区覆盖的举例示意图;
图4为本申请实施例提供了一种分区未覆盖的举例示意图
图5为本申请实施例提供了一种计算对齐扇区的扇区编号的举例示意图;
图6本申请实施例提供了一种确定分区间隙的举例示意图;
图7为本申请实施例提供了一种创建目标分区的举例示意图;
图8为本申请实施例提供了一种分区创建装置的结构示意图;
图9为本申请实施例提供了一种位置确定模块15的结构示意图;
图10为本申请实施例提供了一种间隙确定模块16的结构示意图;
图11为本申请实施例提供了一种分区建立模块17的结构示意图;
图12为本申请实施例提供了一种计算机设备的结构示意图;
图13为本申请实施例提供了一种操作系统和用户空间的结构示意图;
图14是图12中安卓操作系统的架构图;
图15是图12中IOS操作系统的架构图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
在本申请的描述中,需要理解的是,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性。在本申请的描述中,需要说明的是,除非另有明确的规定和限定,“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其他步骤或单元。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本申请中的具体含义。此外,在本申请的描述中,除非另有说明,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。
为了更清楚的描述本发明实施例的技术方案,在描述之前,对本发明中的一些概念进行详细描述以便更好的理解本方案。本方案应用于计算机设备,所述计算机设备包含存储器,所述存储器包括但不限于机械硬盘、固态硬盘、内存、闪存等存储设备。存储器的分区就是从文件存放和管理的方便、容易、快捷性出发将存储器的整体存储空间划分成多个独立的区域,分别用于操作系统、应用程序以及数据文件等不同类型的数据的存放。传统的分区创建方法是依据待创建的新分区的容量,在原有分区的基础上,在未使用的分区中新划分出一段空间创建新分区,以此类推。值得说明的是,由于存储介质存在坏块随机分布的特性,所述块是指存取数据的最小单位,一个块至少包括几个扇区,而扇区是值存储器的最小单位,一般一个扇区的容量大小为512字节,所述存储介质存在坏块随机分布的特性即存储介质中的随机分布着不能进行存取操作的扇区,因此创建新分区不仅需要考虑新分区的容量,为规避存储介质中存在随机分布的坏块的问题还需要预留一部分扇区,而在传统的分区创建方法中并未对预留扇区的数量进行合理分配,此外分区创建的位置随机分布造成相邻分区建存在无法使用的分区间隙,造成严重的资源浪费问题,且位置随机分布的分区严重影响存储器的读写性能。而后为解决资源浪费的问题提出了一种动态分区的方法,即通过记录检测各分区的块的状态,依据检测到的状态为坏块的数量为每个分区预留不同数量的块,解决了为规避存储器中随机分布的坏块而为分区预留较多的扇区引起的资源浪费问题,但是并未对分区间隙进行处理且没有考虑存储器的读写性能。
本申请提出的分区创建方法通过确定已存在分区的各相邻分区之间未被使用的第一存储容量,利用第一分区容量创建新的目标分区,既合理使用的未使用的第一存储容量,提高了资源的利用率,且基于对齐扇区确定的各相邻分区之间的第一存储容量又保证了存储器的读写性能,实现了存储器在空间和性能上的均衡使用。
下面结合具体的实施例进行详细说明。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。附图中所示的流程图仅是示例性说明,不是必须按照所示步骤执行。例如,有的步骤是并列的,在逻辑上并没有严格的先后关系,因此实际执行顺序是可变的。
请参见图1,为本申请实施例提供了一种分区创建方法的流程示意图。本申请实施例的执行主体为计算机设备,所述计算机设备中包括存储器。如图1所示,所述分区创建方法可以包括以下步骤S101~S103。
S101,确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
扇区为存储器进行数据读写的基本单位,但由于扇区容量比较小且在一个存储器中扇区的数量众多,在进行读写数据时存在寻址困难的问题,所以通常将多个扇区组合在一起,形成一个块,首先对块进行寻址,然后再对扇区寻址,例如:第101扇区到第300扇区为第一个块,则第301扇区到第500扇区为第二个块,其中,将每个块的第一个扇区定义为对齐扇区,例如第101扇区与第301扇区。存储器读写数据时的基本单位为扇区,每个扇区有512B的存储空间。
具体的,存储器的已存在若干分区,从各相邻分区之间未被使用的扇区中确定扇区编号最小的对齐扇区,所述对齐扇区的扇区编号即表明所述对齐扇区在存储器中的位置。
所述相邻分区即两个分区之间再无其他分区,例如,分区1所划分的扇区区域包括第101扇区到第3000扇区,而分区2所划分的扇区区域为第4000扇区到第6400扇区,其中第3001扇区到第3999扇区没有被分区使用,则认为分区1和分区2为相邻分区。
S102,确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
具体的,所述对齐扇区位置位于所述当前分区和下一个分区之间,将所述对齐扇区位置到所述下一个分区之间未被使用的存储空间作为所述第一存储容量。
S103,基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。
具体的,根据预设分区容量以及各所述相邻分区之间的第一分区容量的容量大小,利用所述第一分区容量创建目标分区,若所述各第一分区容量的总存储容量大于或者等于所述预设分区容量,则可以只利用各分区间隙创建目标分区,若所述各第一分区容量的总存储容量小于所述预设分区容量,则将各第一分区容量作为所述目标分区的一部分,然后再在最后一个分区后面没有进行分区的位置创建剩余部分的目标分区。
不难理解,所述分区间隙的容量可以基于每个分区间隙之间包含多少个扇区计算得到。
所述分区容量的单位是字节(B),字节是计算机中表示信息含义的最小单位,除字节外,表示存储容量的单位还有KB、MB、GB、T等,其中1KB等于1024B、1MB等于1024KB、1GB等于1024MB、1T等于1024GB。
本申请提出的分区创建方法通过确定已存在分区的各相邻分区之间未被使用的第一存储容量,利用第一分区容量创建新的目标分区,既合理使用的未使用的第一存储容量,提高了资源的利用率,且基于对齐扇区确定的各相邻分区之间的第一存储容量又保证了存储器的读写性能,实现了存储器在空间和性能上的均衡使用。
请参见图2,为本申请实施例提供了一种分区创建方法的流程示意图。本申请实施例的执行主体为计算机设备,所述计算机设备中包括存储器。如图2所示,所述分区创建方法可以包括以下步骤S201~S212。
S201,获取所述存储器的剩余存储容量;
具体的,确定所述存储器中已存在的最后一个分区之后的目标对齐扇区位置以及所述存储器的最后一个扇区位置,将所述最后一个分区之后的目标对齐扇区位置到所述存储器的最后一个扇区位置之间的第二存储容量作为所述存储器的剩余存储容量。
S202,若所述剩余存储容量大于或者等于预设分区容量,则判断待创建的目标分区在所述存储器中是否已经存在;
具体的,若剩余存储容量小于预设分区容量,则不能建立预设分区容量的目标分区,若所述剩余存储容量大于或者等于预设分区容量,表明存储器有足够剩余存储空间创建新分区,则判断存储器中已存在的分区中是否包括待创建的目标分区。举个例子说明,存储器中已存在王者荣耀分区,现在王者荣耀分区迎来重大更新,需要建立分区来存储,此种情况即为存储器中已经存在待创建的目标分区。
进一步的,若所述剩余存储容量小于预设分区容量,则直接返回,不能创建新分区。
S203,若待创建的目标分区在所述存储器中不存在,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤;
S204,若待创建的目标分区在所述存储器中已经存在,则在所述目标分区的最后一个扇区之后扩 展所述目标分区;
具体的,若存储器中已存在的分区中已存在待创建的目标分区,则基于预设分区容量从所述目标分区的最后一个扇区之后对所述目标分区进行扩展。
S205,判断扩展后的目标分区是否覆盖所述目标分区的下一个分区;
具体的,基于步骤S203对所述目标分区进行扩展之后,所述目标分区的终止扇区发生变化,所述目标分区的终止扇区位置不能超出所述目标分区的下一个分区的起始扇区位置,若所述目标分区的终止扇区位置超出所述目标分区的下一个分区的起始扇区位置,则认为扩展后的目标分区覆盖了所述目标分区的下一个分区,反之,若所述目标分区的终止扇区位置没有超出所述目标分区的下一个分区的起始扇区位置,则认为扩展后的目标分区未覆盖所述目标分区的下一个分区。
S206,若扩展后的目标分区覆盖所述目标分区的下一个分区,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤;
请参见图3,为本申请实施例提供了一种分区覆盖的举例示意图。
如图3所示,已存在分区1包括扇区201到扇区1556,已存在分区2包括扇区2701到扇区4158,若对依据预设分区容量对分区1进行拓展,拓展后的分区如图虚线包括扇区1557到扇区3358,很显然存储区域扇区2701到扇区3358已被分区2使用,即为扩展后的目标分区覆盖所述目标分区的下一个分区。
S207,若扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目标分区;
请参见图4,为本申请实施例提供了一种分区未覆盖的举例示意图。
如图4所示,已存在分区1包括扇区201到扇区1556,已存在分区2包括扇区2701到扇区4158,若对依据预设分区容量对分区1进行拓展,拓展后的分区如图虚线包括扇区1557到扇区2594,显然分区1的拓展部分不覆盖任何一个分区,2594<2701,即扩展后的目标分区未覆盖所述目标分区的下一个分区,直接将扇区201到扇区2594的存储区域作为目标分区。
S208,确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
具体的,遍历所述存储器中已存在的各分区,基于当前分区中最后一个扇区的扇区编号、扇区容量以及所述存储器的对齐参数,计算所述当前分区中最后一个扇区所属的对齐区域,基于所述当前分区中最后一个扇区所属的对齐区域、所述存储器的对齐参数、对齐偏移量以及所述扇区容量,计算所述当前分区与下一个分区之间的对齐扇区位置。
所述存储器的对齐参数即单个的块容量,所述对齐区域即块,所述计算所述当前分区中最后一个扇区所属的对齐区域即计算所述当前分区中最后一个扇区所属块的块编号。
首先,计算第一个扇区到当前分区的最后一个扇区的总容量,即用当前分区的最后一个扇区的扇区编号乘以单个扇区的容量,得到第一个扇区到当前分区的最后一个扇区的总容量,再使用第一个扇区到当前分区的最后一个扇区的总容量除以单个块的容量,最后将结果向上取整数,所得结果即为当前分区的最后一个扇区所属块的块编号。所述当前分区是指已存在的各分区其中之一,利用此方法遍历所述存储器中已存在的所有分区,即可得到每一个分区的最后一个扇区所属块的块编号。
所述基于所述当前分区中最后一个扇区所属的对齐区域、所述存储器的对齐参数、对齐偏移量以及所述扇区容量,计算所述当前分区与下一个分区之间的对齐扇区位置。其中,所述对齐偏移量是指所述存储器的第一个对齐扇区不是扇区编号为1的扇区,从扇区编号为1的扇区到第一个对齐扇区之间的存储容量即对齐偏移量,例如:第一个对齐扇区的扇区编号为61,则对齐偏移量即为60个扇区。
具体的,利用所述当前分区中最后一个扇区所属的对齐区域,所述对齐区域即所属块的块编号,利用块编号乘以存储器的对齐参数,所得结果再加上对齐偏移量得到从扇区编号为1的扇区到所述对齐区域的最后一个扇区之间的存储容量,将从扇区编号为1的扇区到所述对齐区域的最后一个扇区之间的存储容量除以单个扇区的容量即为从扇区编号为1的扇区到所述对齐区域的最后一个扇区之间的扇区数,将所得扇区数加1即为对齐扇区的扇区编号。
请一并参见图5,为本申请实施例提供了一种计算对齐扇区的扇区编号的举例示意图。
如图5所示,包括2个已存在的分区,分区1和分区2,其中分区1包括第201个扇区到第1556个扇区,分区2包括第2701个扇区到第5000个扇区,对齐偏移量包括扇区1到扇区101,一共偏移100个扇区,每个对齐区域的容量为204800B,第一个对齐区域为第101个扇区到第500个扇区,以此类推。首先计算分区1最后一个扇区所属的对齐区域,所述对齐区域也可称作块,利用分区1最后一个扇区的扇区编号乘以单个扇区的容量再除以单个对齐区域的容量,即如图(1556*512)/204800=3.89,再将3.89向上取整数等于4,即所述分区1最后一个扇区所属的对齐区域为第4个对 齐区域,再用最后一个扇区所属的对齐区域的编号乘以单个对齐区域的容量再加上对齐偏移量乘以单个扇区容量,得到4个对齐区域加上对齐偏移量的总容量,再将总容量除以单个扇区容量得到,所述分区1最后一个扇区所属的对齐区域的最后一个扇区的扇区编号,最后将结果加1即为对齐扇区的扇区编号,如图所示(4*204800+100*512)/512+1=1701。
S209,确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
具体的,确定所述下一个分区的第一个扇区的起始位置,若所述当前分区与下一个分区之间的对齐扇区位置小于所述下一个分区的第一个扇区的起始位置,确定所述对齐扇区位置到所述下一个分区的第一个扇区的起始位置之间的第一存储容量,若所述当前分区与下一个分区之间的对齐扇区位置大于或者等于所述下一个分区的第一个扇区的起始位置,确定所述当前分区到下一个分区之间不存在第一存储容量。
所述第一个扇区的起始位置即所述第一个扇区的扇区编号,所述当前分区是指各相邻分区的前一个分区,所述下一个分区即各相邻分区的后一个分区,例如,分区1和分区2为相邻分区,分区1所划分的扇区区域包括第101扇区到第3000扇区,而分区2所划分的扇区区域为第4000扇区到第6400扇区,则分区1为所述当前分区,分区2为所述下一个分区,则所述下一个分区的第一个扇区的扇区编号为4000。
所述当前分区与所述下一个分区为相邻分区,所述当前分区与所述下一个分区之间存在一定数量的未被使用的扇区,判断基于所述当前分区计算出的对齐扇区是否属于所述当前分区与所述下一个分区之间的未被使用的扇区。
若所述对齐扇区的扇区编号小于所述下一个分区的第一个扇区的扇区编号,则将所述当前分区与下一个分区之间的对齐扇区位置到所述下一个分区的第一个扇区的起始位置之间的间隙为所述当前分区到下一个分区之间的第一存储容量。
若所述对齐扇区的扇区编号大于或者等于所述下一个分区的第一个扇区的扇区编号,则确定所述当前分区到下一个分区之间不存在所述第一存储容量。
不难理解,因为存储器进行数据的读写是基于块进行读取和写入,若一串数据存放在一个块里面,则存储器只需要对一个块进行读取;若一串数据存放在两个块中,一个块里面存放一部分,则存储器若要读取这一串数据就需要对两个块进行读取,就会相比较将这一串数据存放在一个块里面进行读取时浪费更多的时间,因此按照从对齐扇区到下一个分区的第一个扇区确定第一存储容量的方式,使得每个第一存储容量保存数据时都是从一个块的第一个扇区进行使用,可以提高读取效率。
请一并参见图6,为本申请实施例提供了一种确定第一存储容量的举例示意图。
如图6所示,有在三个已存在的分区,包括分区1、分区2以及分区3,其中分区1和分区2为相邻分区,分区2和分区3为相邻分区,分区1包括第201个扇区到第1556个扇区,分区2包括第2701个扇区到第4158个扇区,分区3包括第4276个扇区到第5875个扇区,根据分区1的最后一个扇区计算得到分区1和分区2之间的对齐扇区为扇区1701,而分区2的第一个扇区为扇区2701,则扇区1701不超过扇区2701,则存在第一存储容量为扇区1701到扇区2701;而根据分区2的最后一个扇区计算得到分区2和分区3之间的对齐扇区为扇区4501,图中分区3的第一个扇区为扇区4276,扇区4501超过了扇区4276,对齐扇区的扇区编号大于分区3的第一个扇区的扇区编号,则分区2和分区3之间不存在第一存储容量。
S210,计算各所述相邻分区之间的第一存储容量的和,得到总存储容量;
具体的,将从各相邻分区之间计算的第一存储容量相加得到总存储容量。
S211,若所述总存储容量小于所述预设分区容量,则以所述存储器中已存在的最后一个分区之后的目标对齐扇区位置为起点,以预设的分区容量与所述总存储容量的差值为存储容量,创建目标分区;
具体的,若各相邻分区之间的分区间隙的总存储容量小于预设分区容量,则将各所述第一存储容量作为所述目标分区的一部分,然后确定所述存储器中已存在的各分区的最后一个分区,并获取所述最后一个分区的最后一个扇区的扇区编号,然后按照步骤S208所描述的方式确定所述最后一个分区后面的第一个对齐扇区的扇区编号,所述对齐扇区的扇区编号表征对齐扇区位置,以所述对齐扇区位置为起点,以所述预设分区容量与所述总存储容量的差值为存储容量,创建子分区,最终将各所述第一存储容量和所述子分区作为所述目标分区。
可选的,若各相邻分区之间的分区间隙的总存储容量小于预设分区容量,不使用第一分区容量创建所述目标分区,直接确定所述存储器中已存在的各分区的最后一个分区,并获取所述最后一个分区的最后一个扇区的扇区编号,然后按照步骤S208所描述的方式确定所述最后一个分区后面的第一个 对齐扇区的扇区编号,所述对齐扇区的扇区编号表征对齐扇区位置,以所述对齐扇区位置为起点,以所述预设分区容量为存储容量,创建目标分区。
S212,若所述总存储容量大于或者等于所述预设分区容量,则在所述总存储容量中选取预设分区容量创建目标分区。
具体的,若各相邻分区之间的各第一存储容量的总存储容量等于预设分区容量,则直接使用各所述第一存储容量创建目标分区,若各相邻分区之间的各第一存储容量的总存储容量大于预设分区容量,则按照各第一存储容量的先后顺序,对各第一存储容量进行叠加,当叠加后的存储容量等于所述预设分区容量时,将所叠加的第一分区容量作为所述目标分区。
所述第一存储容量的先后顺序可以按照第一存储容量中扇区的扇区编号排序,拥有扇区的扇区编号越小越靠前,所述对各第一存储容量进行叠加是指将第一存储容量按照顺序逐一叠加并在叠加过程中与预设分区容量进行比较,然后当叠加后的存储容量等于所述预设分区容量时,将进行叠加的各第一存储容量作为所述目标分区,举个例子来说明一下,例如:所述存储器一共有五个第一存储容量,分别是第一存储容量1、第一存储容量2、第一存储容量3、第一存储容量4以及第一存储容量5,首先比较第一存储容量1与预设分区容量,若所述预设分区容量大于所述第一存储容量1,则叠加第一存储容量1与第一存储容量2,然后比较第一存储容量1与第一存储容量2叠加后的存储容量与预设分区容量,以此类推,若直到第一存储容量1、第一存储容量2、第一存储容量3与第一存储容量4这4个第一存储容量的叠加后的存储容量大于预设分区容量,则将第一存储容量1、第一存储容量2、第一存储容量3与第一存储容量4这4个第一存储容量作为目标分区。
可选的,若叠加4个第一存储容量的存储容量大于预设分区容量,还可以叠加前三个第一存储容量的存储容量,并将前三个第一存储容量作为目标分区的一部分,然后确定第4个第一存储容量的第一个扇区的扇区编号,以第4个第一存储容量的第一个扇区为起点,以所述预设分区容量与所述前三个第一存储容量所叠加存储容量的差值为存储容量,创建子分区,最终将前三个第一存储容量和所述子分区作为所述目标分区。
步骤S211到步骤S212请一并参见图7,为本申请实施例提供了一种创建目标分区的举例示意图。
如图7所示,各相邻分区之间共存在4个第一存储容量,其中第一存储容量1的间隙容量为256000,共500个扇区,第一存储容量2的间隙容量为204800,共400个扇区,第一存储容量3的间隙容量为307200,共600个扇区,第一存储容量4的间隙容量为358400,共700个扇区。
接下来参见图7分别对第一存储容量的总存储容量小于预设分区容量、第一存储容量的总存储容量等于预设分区容量、第一存储容量的总存储容量大于预设分区容量这三种情况逐一进行举例描述。
第一种情况,若目标分区的分区容量为1500000,则共需要2930个扇区,即第一存储容量的总存储容量小于预设分区容量,此时目标分区应该包括第一存储容量1、第一存储容量2、第一存储容量3、第一存储容量4以及在最后一个分区后创建的子分区,所述子分区的容量等于预设分区容量减去4个第一存储容量的总存储容量,所述子分区的第一个扇区是最后一个分区之后的第一个对齐扇区,所述对齐扇区是基于最后一个分区中最后一个扇区的扇区编号计算的。
第二种情况,若预设分区容量为1126400,则共需要2200个扇区,此时第一存储容量的总存储容量等于预设分区容量,则目标分区应该包括第一存储容量1、第一存储容量2、第一存储容量3、第一存储容量4。
第三种情况,若预设分区容量为660000,则共需要1290个扇区,即第一存储容量的总存储容量大于预设分区容量,因为第一存储容量1、第一存储容量2、第一存储容量3这3个第一存储容量叠加后的存储容量已经大于所述预设分区容量,则此时目标分区应该包括第一存储容量1、第一存储容量2、第一存储容量3。
需要说明的是,在本申请实施例中,获取存储器的剩余存储容量,比较剩余存储容量和预设存储容量的步骤与判断待创建的目标分区在所述存储器中是否已经存在的步骤可以是并列的,都是可以单独执行的,并没有限定性的逻辑上的先后顺序。
在本申请实施例中,首先获取存储器的剩余存储容量,比较剩余存储容量和预设分区容量,若剩余存储容量小于预设分区容量,则不能建立预设分区容量的目标分区,若剩余存储容量大于或者等于预设分区容量,则可以建立预设分区容量的目标分区,保证了分区创建的可行性;然后判断待创建的目标分区在所述存储器中是否已经存在,确定目标分区的创建是新分区的创建还是对已存在分区的扩展,若待创建的目标分区在所述存储器中已经存在且扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目标分区,方便对于已存在分区的扩展;若存储器中不存在待创建的目标分区,则计算已存在各分区之间的第一存储容量,利用第一存储容量和剩余存储容量 创建目标分区,合理的使用了的未使用的第一存储容量,提高了资源的利用率,且基于对齐扇区位置确定的各相邻分区之间的第一存储容量又保证了存储器的读写性能,实现了存储器在空间和性能上的均衡使用。
请参见图8,为本申请实施例提供了一种分区创建装置的结构示意图。如图8所示,该分区创建装置1可以通过软件、硬件或者两者的结合实现成为终端设备的全部或一部分。根据一些实施例,该分区创建装置1包括,剩余容量获取模块11,分区判断模块12,分区扩展模块13,覆盖判断模块14,位置确定模块15、间隙确定模块16、分区建立模块17,具体包括:
剩余容量获取模块11,用于获取所述存储器的剩余存储容量;
分区判断模块12,用于判断待创建的目标分区在所述存储器中是否已经存在;
分区扩展模块13,用于若待创建的目标分区在所述存储器中已经存在,则在所述目标分区的最后一个扇区之后扩展所述目标分区;
覆盖判断模块14,用于判断扩展后的目标分区是否覆盖所述目标分区的下一个分区;
位置确定模块15,用于确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
间隙确定模块16,用于确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
分区建立模块17,用于基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。
可选的,所述剩余容量获取模块,具体用于:
确定所述存储器中已存在的最后一个分区之后的目标对齐扇区位置以及所述存储器的最后一个扇区位置;
将所述最后一个分区之后的目标对齐扇区位置到所述存储器的最后一个扇区位置之间的第二存储容量作为所述存储器的剩余存储容量。
可选的,所述位置确定模块,还用于若所述剩余存储容量大于或者等于预设分区容量,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤。
可选的,所述位置确定模块,还用于若扩展后的目标分区覆盖所述目标分区的下一个分区,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤。
可选的,所述位置确定模块,还用于若待创建的目标分区在所述存储器中不存在,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤;
可选的,所述分区扩展模块,还用于若扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目标分区。
可选的,如图9所示,为本申请实施例提供了一种位置确定模块15的结构示意图。
所述位置确定模块15,包括:
区域计算单元151,用于遍历所述存储器中已存在的各分区,基于当前分区中最后一个扇区的扇区编号、扇区容量以及所述存储器的对齐参数,计算所述当前分区中最后一个扇区所属的对齐区域;
位置计算单元152,用于基于所述当前分区中最后一个扇区所属的对齐区域、所述存储器的对齐参数、对齐偏移量以及所述扇区容量,计算所述当前分区与下一个分区之间的对齐扇区位置。
可选的,如图10所示,为本申请实施例提供了一种间隙确定模块16的结构示意图。
所述间隙确定模块16,包括:
起始扇区确定单元161,用于确定所述下一个分区的第一个扇区的起始位置;
第一间隙确定单元162,用于若所述当前分区与下一个分区之间的对齐扇区位置小于所述下一个分区的第一个扇区的起始位置,确定所述对齐扇区位置到所述下一个分区的第一个扇区的起始位置之间的第一存储容量;
第二间隙确定单元163,用于若所述当前分区与下一个分区之间的对齐扇区位置大于或者等于所述下一个分区的第一个扇区的起始位置,确定所述当前分区到下一个分区之间不存在第一存储容量。
可选的,如图11所示,为本申请实施例提供了一种分区建立模块17的结构示意图。
所述分区建立模块17,包括:
总容量获取单元171,用于计算各所述相邻分区之间的第一存储容量的和,得到总存储容量;
第一分区创建单元172,用于若所述总存储容量小于所述预设分区容量,则以所述存储器中已存在的最后一个分区之后的目标对齐扇区位置为起点,以预设的分区容量与所述总存储容量的差值为存储容量,创建目标分区;
第二分区创建单元173,用于若所述总存储容量大于或者等于所述预设分区容量,则在所述总存储容量中选取预设分区容量创建目标分区。
需要说明的是,上述实施例提供的分区创建装置在执行分区创建方法时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的分区创建装置与分区创建方法实施例属于同一构思,其体现实现过程详见方法实施例,这里不再赘述。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
在本申请实施例中,首先获取存储器的剩余存储容量,比较剩余存储容量和预设分区容量,若剩余存储容量小于预设分区容量,则不能建立预设分区容量的目标分区,若剩余存储容量大于或者等于预设分区容量,则可以建立预设分区容量的目标分区,保证了分区创建的可行性;然后判断待创建的目标分区在所述存储器中是否已经存在,确定目标分区的创建是新分区的创建还是对已存在分区的扩展,若待创建的目标分区在所述存储器中已经存在且扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目标分区,方便对于已存在分区的扩展;若存储器中不存在待创建的目标分区,则计算已存在各分区之间的第一存储容量,利用第一存储容量和剩余存储容量创建目标分区,合理的使用了的未使用的第一存储容量,提高了资源的利用率,且基于对齐扇区位置确定的各相邻分区之间的第一存储容量又保证了存储器的读写性能,实现了存储器在空间和性能上的均衡使用。
本申请实施例还提供了一种计算机存储介质,所述计算机存储介质可以存储有多条指令,所述指令适于由处理器加载并执行如上述图1~图7所示实施例的所述分区创建方法,具体执行过程可以参见图1~图7所示实施例的具体说明,在此不进行赘述。
本申请还提供了一种计算机程序产品,该计算机程序产品存储有至少一条指令,所述至少一条指令由所述处理器加载并执行如上述图1~图7所示实施例的所述分区创建方法,具体执行过程可以参见图1~图7所示实施例的具体说明,在此不进行赘述。
请参考图12,其示出了本申请一个示例性实施例提供的计算机设备的结构方框图。本申请中的计算机设备可以包括一个或多个如下部件:处理器110、存储器120、输入装置130、输出装置140和总线150。处理器110、存储器120、输入装置130和输出装置140之间可以通过总线150连接。
处理器110可以包括一个或者多个处理核心。处理器110利用各种接口和线路连接整个计算机设备内的各个部分,通过运行或执行存储在存储器120内的指令、程序、代码集或指令集,以及调用存储在存储器120内的数据,执行计算机设备100的各种功能和处理数据。可选地,处理器110可以采用数字信号处理(digital signal processing,DSP)、现场可编程门阵列(field-programmable gate array,FPGA)、可编程逻辑阵列(programmable logic Array,PLA)中的至少一种硬件形式来实现。处理器110可集成中央处理器(central processing unit,CPU)、图像处理器(graphics processing unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器110中,单独通过一块通信芯片进行实现。
存储器120可以包括随机存储器(random Access Memory,RAM),也可以包括只读存储器(read-only memory,ROM)。可选地,该存储器120包括非瞬时性计算机可读介质(non-transitory computer-readable storage medium)。存储器120可用于存储指令、程序、代码、代码集或指令集。存储器120可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等,该操作系统可以是安卓(Android)系统,包括基于Android系统深度开发的系统、苹果公司开发的IOS系统,包括基于IOS系统深度开发的系统或其它系统。存储数据区还可以存储计算机设备在使用中所创建的数据比如电话本、音视频数据、聊天记录数据等。
参见图13所示,存储器120可分为操作系统空间和用户空间,操作系统即运行于操作系统空间,原生及第三方应用程序即运行于用户空间。为了保证不同第三方应用程序均能够达到较好的运行效果,操作系统针对不同第三方应用程序为其分配相应的系统资源。然而,同一第三方应用程序中不同应用场景对系统资源的需求也存在差异,比如,在本地资源加载场景下,第三方应用程序对磁盘读取速度 的要求较高;在动画渲染场景下,第三方应用程序则对GPU性能的要求较高。而操作系统与第三方应用程序之间相互独立,操作系统往往不能及时感知第三方应用程序当前的应用场景,导致操作系统无法根据第三方应用程序的具体应用场景进行针对性的系统资源适配。
为了使操作系统能够区分第三方应用程序的具体应用场景,需要打通第三方应用程序与操作系统之间的数据通信,使得操作系统能够随时获取第三方应用程序当前的场景信息,进而基于当前场景进行针对性的系统资源适配。
以操作系统为Android系统为例,存储器120中存储的程序和数据如图14所示,存储器120中可存储有Linux内核层320、系统运行时库层340、应用框架层360和应用层380,其中,Linux内核层320、系统运行库层340和应用框架层360属于操作系统空间,应用层380属于用户空间。Linux内核层320为计算机设备的各种硬件提供了底层的驱动,如显示驱动、音频驱动、摄像头驱动、蓝牙驱动、Wi-Fi驱动、电源管理等。系统运行库层340通过一些C/C++库来为Android系统提供了主要的特性支持。如SQLite库提供了数据库的支持,OpenGL/ES库提供了3D绘图的支持,Webkit库提供了浏览器内核的支持等。在系统运行时库层340中还提供有安卓运行时库(Android runtime),它主要提供了一些核心库,能够允许开发者使用Java语言来编写Android应用。应用框架层360提供了构建应用程序时可能用到的各种API,开发者也可以通过使用这些API来构建自己的应用程序,比如活动管理、窗口管理、视图管理、通知管理、内容提供者、包管理、通话管理、资源管理、定位管理。应用层380中运行有至少一个应用程序,这些应用程序可以是操作系统自带的原生应用程序,比如联系人程序、短信程序、时钟程序、相机应用等;也可以是第三方开发者所开发的第三方应用程序,比如游戏类应用程序、即时通信程序、相片美化程序、分区创建程序等。
以操作系统为IOS系统为例,存储器120中存储的程序和数据如图15所示,IOS系统包括:核心操作系统层420(Core OS layer)、核心服务层440(Core Services layer)、媒体层460(Media layer)、可触摸层480(Cocoa Touch Layer)。核心操作系统层420包括了操作系统内核、驱动程序以及底层程序框架,这些底层程序框架提供更接近硬件的功能,以供位于核心服务层440的程序框架所使用。核心服务层440提供给应用程序所需要的系统服务和/或程序框架,比如基础(Foundation)框架、账户框架、广告框架、数据存储框架、网络连接框架、地理位置框架、运动框架等等。媒体层460为应用程序提供有关视听方面的接口,如图形图像相关的接口、音频技术相关的接口、视频技术相关的接口、音视频传输技术的无线播放(AirPlay)接口等。可触摸层480为应用程序开发提供了各种常用的界面相关的框架,可触摸层480负责用户在计算机设备上的触摸交互操作。比如本地通知服务、远程推送服务、广告框架、游戏工具框架、消息用户界面接口(User Interface,UI)框架、用户界面UIKit框架、地图框架等等。
在图15所示出的框架中,与大部分应用程序有关的框架包括但不限于:核心服务层440中的基础框架和可触摸层480中的UIKit框架。基础框架提供许多基本的对象类和数据类型,为所有应用程序提供最基本的系统服务,和UI无关。而UIKit框架提供的类是基础的UI类库,用于创建基于触摸的用户界面,iOS应用程序可以基于UIKit框架来提供UI,所以它提供了应用程序的基础架构,用于构建用户界面,绘图、处理和用户交互事件,响应手势等等。
其中,在IOS系统中实现第三方应用程序与操作系统数据通信的方式以及原理可参考Android系统,本申请在此不再赘述。
其中,输入装置130用于接收输入的指令或数据,输入装置130包括但不限于键盘、鼠标、摄像头、麦克风或触控设备。输出装置140用于输出指令或数据,输出装置140包括但不限于显示设备和扬声器等。在一个示例中,输入装置130和输出装置140可以合设,输入装置130和输出装置140为触摸显示屏,该触摸显示屏用于接收用户使用手指、触摸笔等任何适合的物体在其上或附近的触摸操作,以及显示各个应用程序的用户界面。触摸显示屏通常设置在计算机设备的前面板。触摸显示屏可被设计成为全面屏、曲面屏或异型屏。触摸显示屏还可被设计成为全面屏与曲面屏的结合,异型屏与曲面屏的结合,本申请实施例对此不加以限定。
除此之外,本领域技术人员可以理解,上述附图所示出的计算机设备的结构并不构成对计算机设备的限定,计算机设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。比如,计算机设备中还包括射频电路、输入单元、传感器、音频电路、无线保真(wireless fidelity,WiFi)模块、电源、蓝牙模块等部件,在此不再赘述。
在本申请实施例中,各步骤的执行主体可以是上文介绍的计算机设备。可选地,各步骤的执行主体为计算机设备的操作系统。操作系统可以是安卓系统,也可以是IOS系统,或者其它操作系统,本申请实施例对此不作限定。
本申请实施例的计算机设备,其上还可以安装有显示设备,显示设备可以是各种能实现显示功能的设备,例如:阴极射线管显示器(cathode ray tubedisplay,简称CR)、发光二极管显示器(light-emitting diode display,简称LED)、电子墨水屏、液晶显示屏(liquid crystal display,简称LCD)、等离子显示面板(plasma display panel,简称PDP)等。用户可以利用计算机设备101上的显示设备,来查看显示的文字、图像、视频等信息。所述计算机设备可以是智能手机、平板电脑、游戏设备、AR(Augmented Reality,增强现实)设备、汽车、数据存储装置、音频播放装置、视频播放装置、笔记本、桌面计算设备、可穿戴设备诸如电子手表、电子眼镜、电子头盔、电子手链、电子项链、电子衣物等设备。
在图12所示的计算机设备中,处理器110可以用于调用存储器120中存储的分区创建程序,并具体执行以下操作:
确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。
在一个实施例中,所述处理器110在执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置之前,还执行以下操作:
判断待创建的目标分区在所述存储器中是否已经存在;
若待创建的目标分区在所述存储器中已经存在,则在所述目标分区的最后一个扇区之后扩展所述目标分区;
若待创建的目标分区在所述存储器中不存在,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤;
判断扩展后的目标分区是否覆盖所述目标分区的下一个分区;
若扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目标分区;
若扩展后的目标分区覆盖所述目标分区的下一个分区,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤。
在一个实施例中,所述处理器110在执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置之前,还执行以下操作:
获取所述存储器的剩余存储容量;
若所述剩余存储容量大于或者等于预设分区容量,则确定所述存储器中已存在的各相邻分区之间的对齐扇区位置。
在一个实施例中,所述处理器110在执行所述获取所述存储器的剩余存储容量时,具体执行以下操作:
确定所述存储器中已存在的最后一个分区之后的目标对齐扇区位置以及所述存储器的最后一个扇区位置;
将所述最后一个分区之后的目标对齐扇区位置到所述存储器的最后一个扇区位置之间的第二存储容量作为所述存储器的剩余存储容量。
在一个实施例中,所述处理器110在执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置时,具体执行以下操作:
遍历所述存储器中已存在的各分区,基于当前分区中最后一个扇区的扇区编号、扇区容量以及所述存储器的对齐参数,计算所述当前分区中最后一个扇区所属的对齐区域;
基于所述当前分区中最后一个扇区所属的对齐区域、所述存储器的对齐参数、对齐偏移量以及所述扇区容量,计算所述当前分区与下一个分区之间的对齐扇区位置。
在一个实施例中,所述处理器110在执行所述确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量时,具体执行以下操作:
确定所述下一个分区的第一个扇区的起始位置;
若所述当前分区与下一个分区之间的对齐扇区位置小于所述下一个分区的第一个扇区的起始位置,确定所述对齐扇区位置到所述下一个分区的第一个扇区的起始位置之间的第一存储容量;
若所述当前分区与下一个分区之间的对齐扇区位置大于或者等于所述下一个分区的第一个扇区的起始位置,确定所述当前分区到下一个分区之间不存在第一存储容量。
在一个实施例中,所述处理器110在执行所述基于各所述对齐扇区位置到各所述相邻分区中的下 一个分区之间的第一存储容量以及预设分区容量,创建目标分区时,具体执行以下操作:
计算各所述相邻分区之间的第一存储容量的和,得到总存储容量;
若所述总存储容量小于所述预设分区容量,则以所述存储器中已存在的最后一个分区之后的目标对齐扇区位置为起点,以预设的分区容量与所述总存储容量的差值为存储容量,创建目标分区;
若所述总存储容量大于或者等于所述预设分区容量,则在所述总存储容量中选取预设分区容量创建目标分区。
在本申请实施例中,首先获取存储器的剩余存储容量,比较剩余存储容量和预设分区容量,若剩余存储容量小于预设分区容量,则不能建立预设分区容量的目标分区,若剩余存储容量大于或者等于预设分区容量,则可以建立预设分区容量的目标分区,保证了分区创建的可行性;然后判断待创建的目标分区在所述存储器中是否已经存在,确定目标分区的创建是新分区的创建还是对已存在分区的扩展,若待创建的目标分区在所述存储器中已经存在且扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目标分区,方便对于已存在分区的扩展;若存储器中不存在待创建的目标分区,则计算已存在各分区之间的第一存储容量,利用第一存储容量和剩余存储容量创建目标分区,合理的使用了的未使用的第一存储容量,提高了资源的利用率,且基于对齐扇区位置确定的各相邻分区之间的第一存储容量又保证了存储器的读写性能,实现了存储器在空间和性能上的均衡使用。
本领域的技术人员可以清楚地了解到本申请的技术方案可借助软件和/或硬件来实现。本说明书中的“单元”和“模块”是指能够独立完成或与其他部件配合完成特定功能的软件和/或硬件,其中硬件例如可以是现场可编程门阵列(Field-ProgrammaBLE Gate Array,FPGA)、集成电路(Integrated Circuit,IC)等。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些服务接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通进程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储器中,存储器可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。
以上所述者,仅为本公开的示例性实施例,不能以此限定本公开的范围。即但凡依本公开教导所作的等效变化与修饰,皆仍属本公开涵盖的范围内。本领域技术人员在考虑说明书及实践这里的公开后,将容易想到本公开的其它实施方案。本申请旨在涵盖本公开的任何变型、用途或者适应性变化, 这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未记载的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的范围和精神由权利要求限定。

Claims (20)

  1. 一种分区创建方法,其特征在于,应用于计算机设备,所述计算机设备包含存储器,所述方法包括:
    确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
    确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
    基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。
  2. 根据权利要求1所述的分区创建方法,其特征在于,所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置之前,还包括:
    获取所述存储器的剩余存储容量;
    若所述剩余存储容量大于或者等于预设分区容量,则确定所述存储器中已存在的各相邻分区之间的对齐扇区位置。
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:
    若所述剩余存储容量小于预设分区容量,则直接返回,无法创建分区。
  4. 根据权利要求2所述的方法,其特征在于,所述获取所述存储器的剩余存储容量,包括:
    确定所述存储器中已存在的最后一个分区之后的目标对齐扇区位置以及所述存储器的最后一个扇区位置;
    将所述最后一个分区之后的目标对齐扇区位置到所述存储器的最后一个扇区位置之间的第二存储容量作为所述存储器的剩余存储容量。
  5. 根据权利要求1或2所述的分区创建方法,其特征在于,所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置,包括:
    遍历所述存储器中已存在的各分区,基于当前分区中最后一个扇区的扇区编号、扇区容量以及所述存储器的对齐参数,计算所述当前分区中最后一个扇区所属的对齐区域;
    基于所述当前分区中最后一个扇区所属的对齐区域、所述存储器的对齐参数、对齐偏移量以及所述扇区容量,计算所述当前分区与下一个分区之间的对齐扇区位置。
  6. 根据权利要求5所述的分区创建方法,其特征在于,所述确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,包括:
    确定所述下一个分区的第一个扇区的起始位置;
    若所述当前分区与下一个分区之间的对齐扇区位置小于所述下一个分区的第一个扇区的起始位置,确定所述对齐扇区位置到所述下一个分区的第一个扇区的起始位置之间的第一存储容量;
    若所述当前分区与下一个分区之间的对齐扇区位置大于或者等于所述下一个分区的第一个扇区的起始位置,确定所述当前分区到下一个分区之间不存在第一存储容量。
  7. 根据权利要求1所述的分区创建方法,其特征在于,所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置之前,还包括:
    判断待创建的目标分区在所述存储器中是否已经存在;
    若待创建的目标分区在所述存储器中已经存在,则在所述目标分区的最后一个扇区之后扩展所述目标分区;
    判断扩展后的目标分区是否覆盖所述目标分区的下一个分区;
    若扩展后的目标分区覆盖所述目标分区的下一个分区,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤。
  8. 根据权利要求7所述的方法,其特征在于,所述方法还包括:
    若待创建的目标分区在所述存储器中不存在,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤;或
    若扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目标分区。
  9. 根据权利要求1所述的分区创建方法,其特征在于,所述基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区,包括:
    计算各所述相邻分区之间的第一存储容量的和,得到总存储容量;
    若所述总存储容量小于所述预设分区容量,则以所述存储器中已存在的最后一个分区之后的目标对齐扇区位置为起点,以预设的分区容量与所述总存储容量的差值为存储容量,创建目标分区;
    若所述总存储容量大于或者等于所述预设分区容量,则在所述总存储容量中选取预设分区容量创建目标分区。
  10. 一种分区创建装置,其特征在于,包括:
    位置确定模块,用于确定所述存储器中已存在的各相邻分区之间的对齐扇区位置;
    间隙确定模块,用于确定所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量,各所述相邻分区均包括当前分区和下一个分区;
    分区建立模块,用于基于各所述对齐扇区位置到各所述相邻分区中的下一个分区之间的第一存储容量以及预设分区容量,创建目标分区。
  11. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    剩余容量获取模块,用于获取所述存储器的剩余存储容量;
    所述位置确定模块,还用于若所述剩余存储容量大于或者等于预设分区容量,则执行所述确定所 述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤。
  12. 根据权利要求11所述的装置,其特征在于,所述剩余容量获取模块,具体用于:
    确定所述存储器中已存在的最后一个分区之后的目标对齐扇区位置以及所述存储器的最后一个扇区位置;
    将所述最后一个分区之后的目标对齐扇区位置到所述存储器的最后一个扇区位置之间的第二存储容量作为所述存储器的剩余存储容量。
  13. 根据权利要求10或11所述的装置,其特征在于,所述位置确定模块,包括:
    区域计算单元,用于遍历所述存储器中已存在的各分区,基于当前分区中最后一个扇区的扇区编号、扇区容量以及所述存储器的对齐参数,计算所述当前分区中最后一个扇区所属的对齐区域;
    位置计算单元,用于基于所述当前分区中最后一个扇区所属的对齐区域、所述存储器的对齐参数、对齐偏移量以及所述扇区容量,计算所述当前分区与下一个分区之间的对齐扇区位置。
  14. 根据权利要求13所述的装置,其特征在于,所述间隙确定模块,包括:
    起始扇区确定单元,用于确定所述下一个分区的第一个扇区的起始位置;
    第一间隙确定单元,用于若所述当前分区与下一个分区之间的对齐扇区位置小于所述下一个分区的第一个扇区的起始位置,确定所述对齐扇区位置到所述下一个分区的第一个扇区的起始位置之间的第一存储容量;
    第二间隙确定单元,用于若所述当前分区与下一个分区之间的对齐扇区位置大于或者等于所述下一个分区的第一个扇区的起始位置,确定所述当前分区到下一个分区之间不存在第一存储容量。
  15. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    分区判断模块,用于判断待创建的目标分区在所述存储器中是否已经存在;
    分区扩展模块,用于若待创建的目标分区在所述存储器中已经存在,则在所述目标分区的最后一个扇区之后扩展所述目标分区;
    覆盖判断模块,用于判断扩展后的目标分区是否覆盖所述目标分区的下一个分区;
    所述位置确定模块,还用于若扩展后的目标分区覆盖所述目标分区的下一个分区,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤。
  16. 根据权利要求15所述的装置,其特征在于,所述位置确定模块,还用于:
    若待创建的目标分区在所述存储器中不存在,则执行所述确定所述存储器中已存在的各相邻分区之间的对齐扇区位置的步骤。
  17. 根据权利要求15所述的装置,其特征在于,所述位置确定模块,还用于:
    若扩展后的目标分区未覆盖所述目标分区的下一个分区,则将扩展后的目标分区作为所创建的目 标分区。
  18. 根据权利要求10所述的装置,其特征在于,所述分区建立模块,包括:
    总容量获取单元,用于计算各所述相邻分区之间的第一存储容量的和,得到总存储容量;
    第一分区创建单元,用于若所述总存储容量小于所述预设分区容量,则以所述存储器中已存在的最后一个分区之后的目标对齐扇区位置为起点,以预设的分区容量与所述总存储容量的差值为存储容量,创建目标分区;
    第二分区创建单元,用于若所述总存储容量大于或者等于所述预设分区容量,则在所述总存储容量中选取预设分区容量创建目标分区。
  19. 一种存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1~9中任意一项所述方法的步骤。
  20. 一种计算机设备,其特征在于,包括:处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器加载并执行如权利要求1~9中任意一项所述方法的步骤。
PCT/CN2022/088499 2021-05-20 2022-04-22 分区创建方法、装置、存储介质及计算机设备 WO2022242419A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110553721.5A CN113282237B (zh) 2021-05-20 2021-05-20 分区创建方法、装置、存储介质及计算机设备
CN202110553721.5 2021-05-20

Publications (1)

Publication Number Publication Date
WO2022242419A1 true WO2022242419A1 (zh) 2022-11-24

Family

ID=77280500

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/088499 WO2022242419A1 (zh) 2021-05-20 2022-04-22 分区创建方法、装置、存储介质及计算机设备

Country Status (2)

Country Link
CN (1) CN113282237B (zh)
WO (1) WO2022242419A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282237B (zh) * 2021-05-20 2023-08-18 RealMe重庆移动通信有限公司 分区创建方法、装置、存储介质及计算机设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1494681A (zh) * 2000-10-27 2004-05-05 �ֹ��� 分区创建方法及删除方法
US20150169252A1 (en) * 2013-12-13 2015-06-18 Netapp Inc. Techniques for dynamically aligning a partition with a block size boundary
CN107111450A (zh) * 2014-10-24 2017-08-29 微软技术许可有限责任公司 使用分区表进行的磁盘分区拼接和重新均衡
CN113282237A (zh) * 2021-05-20 2021-08-20 RealMe重庆移动通信有限公司 分区创建方法、装置、存储介质及计算机设备

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8285965B2 (en) * 2009-11-20 2012-10-09 Western Digital Technologies, Inc. Aligning data storage device partition to boundary of physical data sector
US8996839B1 (en) * 2012-01-23 2015-03-31 Western Digital Technologies, Inc. Data storage device aligning partition to boundary of sector when partition offset correlates with offset of write commands
US10621044B2 (en) * 2012-04-25 2020-04-14 Pure Storage, Inc. Mapping slice groupings in a dispersed storage network
US10002001B1 (en) * 2013-02-19 2018-06-19 Amazon Technologies, Inc. Importing a virtual disk image into a compute service environment
JP2015082166A (ja) * 2013-10-22 2015-04-27 ルネサスエレクトロニクス株式会社 データ格納用フラッシュメモリの管理方法およびそのプログラム
CN105224253A (zh) * 2015-09-29 2016-01-06 浪潮电子信息产业股份有限公司 一种固态硬盘性能优化的方法
TWI587133B (zh) * 2016-05-20 2017-06-11 慧榮科技股份有限公司 資料儲存裝置之資料頁對齊方法及其查找表的製作方法
CN110245119B (zh) * 2018-11-02 2023-01-31 浙江大华技术股份有限公司 一种文件整理方法及存储系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1494681A (zh) * 2000-10-27 2004-05-05 �ֹ��� 分区创建方法及删除方法
US20150169252A1 (en) * 2013-12-13 2015-06-18 Netapp Inc. Techniques for dynamically aligning a partition with a block size boundary
CN107111450A (zh) * 2014-10-24 2017-08-29 微软技术许可有限责任公司 使用分区表进行的磁盘分区拼接和重新均衡
CN113282237A (zh) * 2021-05-20 2021-08-20 RealMe重庆移动通信有限公司 分区创建方法、装置、存储介质及计算机设备

Also Published As

Publication number Publication date
CN113282237B (zh) 2023-08-18
CN113282237A (zh) 2021-08-20

Similar Documents

Publication Publication Date Title
WO2020147666A1 (zh) 用户界面显示方法、装置、终端及存储介质
WO2020147665A1 (zh) 文件处理方法、装置、终端及存储介质
CN107889070B (zh) 图片处理方法、装置、终端及计算机可读存储介质
US10599336B2 (en) Method of displaying content and electronic device adapted to the same
EP4130994A1 (en) Remote assistance method and apparatus, and storage medium and terminal
WO2020063008A1 (zh) 资源配置方法、装置、终端及存储介质
WO2020143555A1 (zh) 用于展现信息的方法和装置
CN113268212A (zh) 投屏方法、装置、存储介质及电子设备
WO2022242419A1 (zh) 分区创建方法、装置、存储介质及计算机设备
CN114186527A (zh) 一种不依赖于网格点实现集成电路自动布线的方法及装置
CN110572815A (zh) 网络访问方法、装置、存储介质及终端
CN117555459A (zh) 一种应用组处理方法、装置、存储介质及电子设备
CN111857480A (zh) 图标对齐方法、装置、存储介质及电子设备
CN110730300A (zh) 相机控制方法、装置、存储介质和终端
CN112995562A (zh) 摄像头的调用方法、装置、存储介质及终端
RU2635255C2 (ru) Системный когерентный кэш с возможностью фрагментации/дефрагментации
CN108293197A (zh) 一种资源统计方法、装置及终端
CN113972989B (zh) 数据校验方法及存储介质、电子设备
CN116974732A (zh) 一种内存处理方法、装置、终端设备及介质
CN110221892B (zh) 一种滚动窗口信息的方法、装置、介质和电子设备
CN114186526A (zh) 一种基于r树mbr算法的集成电路自动打孔方法及装置
CN113268221A (zh) 文件匹配方法、装置、存储介质及计算机设备
CN113312572A (zh) 一种资源处理方法、装置、存储介质及电子设备
CN113286349A (zh) 个人热点连接方法、装置、终端及存储介质
CN113778386B (zh) 组件生成方法、装置、存储介质及电子设备

Legal Events

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

Ref document number: 22803743

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22803743

Country of ref document: EP

Kind code of ref document: A1