CN113282237B - Partition creation method, partition creation device, storage medium and computer equipment - Google Patents

Partition creation method, partition creation device, storage medium and computer equipment Download PDF

Info

Publication number
CN113282237B
CN113282237B CN202110553721.5A CN202110553721A CN113282237B CN 113282237 B CN113282237 B CN 113282237B CN 202110553721 A CN202110553721 A CN 202110553721A CN 113282237 B CN113282237 B CN 113282237B
Authority
CN
China
Prior art keywords
partition
sector
memory
capacity
storage capacity
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110553721.5A
Other languages
Chinese (zh)
Other versions
CN113282237A (en
Inventor
赵创
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Realme Chongqing Mobile Communications Co Ltd
Original Assignee
Realme Chongqing Mobile Communications Co Ltd
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 Chongqing Mobile Communications Co Ltd filed Critical Realme Chongqing Mobile Communications Co Ltd
Priority to CN202110553721.5A priority Critical patent/CN113282237B/en
Publication of CN113282237A publication Critical patent/CN113282237A/en
Priority to PCT/CN2022/088499 priority patent/WO2022242419A1/en
Application granted granted Critical
Publication of CN113282237B publication Critical patent/CN113282237B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

Abstract

The embodiment of the application discloses a partition creation method, a partition creation device, a storage medium and computer equipment, wherein the method comprises the following steps: an aligned sector location between each adjacent partition that is already present in the memory is determined, then a first storage capacity between the aligned sector location and a next partition in each of the adjacent partitions is determined, and a target partition is created based on the first storage capacity between each aligned sector location and the next partition in each of the adjacent partitions and a preset partition capacity. By adopting the embodiment of the application, the new target partition can be established by utilizing the unused first partition capacity among the existing adjacent partitions, the waste of resources is reduced, and the first storage capacity determined based on the aligned sector positions of the memory ensures the read-write performance of the memory.

Description

Partition creation method, partition creation device, storage medium and computer equipment
Technical Field
The present application relates to the field of computer application technologies, and in particular, to a partition creating method, a partition creating device, a storage medium, and a computer device.
Background
The partitioning of memory is accomplished by dividing the memory into several logical portions, each representing a partition, using a partition editor (partition editor). After the memory is divided into a plurality of partitions (Partition), different types of directories and files can be stored in different partitions.
In the conventional technology, if a partition is to be newly added, a new partition is generally marked out in unused partitions, and a part of blocks are reserved in each new partition to solve the problem of bad blocks in the memory, so that resources are wasted. And then, in order to solve the problem of resource waste, a method for dynamic partitioning is provided, namely, by recording and detecting the states of the blocks of each partition, different numbers of blocks are reserved for each partition according to the detected states for the number of bad blocks, so that the problem of resource waste caused by reserving more blocks for the partition in order to avoid the bad blocks in the memory is solved, but the problem of reduced read-write performance of the memory caused by fragmentation of storage space exists.
Disclosure of Invention
The embodiment of the application provides a partition creation method, a partition creation device, a storage medium and computer equipment, which can determine unused first storage capacity among existing partitions by calculating the positions of aligned sectors, and create a target partition by using the first storage capacity, thereby improving the space utilization rate of a memory and simultaneously ensuring the read-write performance.
The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a partition creation method, where the method includes:
Determining aligned sector locations between adjacent partitions already present in the memory;
determining a first storage capacity between the aligned sector location to a next partition in each of the adjacent partitions, each of the adjacent partitions including a current partition and a next partition;
a target partition is created based on a first storage capacity between each of the aligned sector locations to a next one of the adjacent partitions and a preset partition capacity.
In a second aspect, an embodiment of the present application provides a partition creation apparatus, including:
an aligned sector determining module, configured to determine aligned sector positions between adjacent partitions existing in the memory;
a first capacity determination module for determining a first storage capacity between the aligned sector location to a next partition in each of the adjacent partitions, each of the adjacent partitions including a current partition and a next partition;
a partition establishing module, configured to create a target partition based on a first storage capacity between each aligned sector position and a next partition in each adjacent partition and a preset partition capacity.
In a third aspect, embodiments of the present application provide a storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-described method steps.
In a fourth aspect, embodiments of the present application provide a computer device, which may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
The technical scheme provided by the embodiments of the application has the beneficial effects that at least:
in the embodiment of the application, firstly, the aligned sector position between each adjacent partition existing in the memory is determined, then, the first storage capacity between the aligned sector position and the next partition in each adjacent partition is determined, and finally, according to the partition capacity of the target partition to be created, the target partition is created by utilizing the unused first storage capacity between each adjacent partition of the existing partition, thereby reducing the waste of resources, and the read-write performance of the memory is ensured based on the first storage capacity determined by the aligned sector position.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a partition creation method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of a partition creation method according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating an example of partition coverage according to an embodiment of the present application;
FIG. 4 provides an exemplary illustration of a partition uncovered in accordance with an embodiment of the present application;
FIG. 5 is a schematic diagram of an embodiment of the present application for calculating sector numbers of aligned sectors;
FIG. 6 provides an exemplary schematic diagram of determining partition gaps in accordance with an embodiment of the present application;
FIG. 7 is a schematic diagram illustrating an example of creating a target partition according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a partition creating apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a location determining module 15 according to an embodiment of the present application;
fig. 10 is a schematic structural view of a gap determining module 16 according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of a partition establishing module 17 according to an embodiment of the present application;
FIG. 12 is a schematic diagram of a computer device according to an embodiment of the present application;
FIG. 13 is a schematic diagram of an operating system and user space according to an embodiment of the present application;
FIG. 14 is an architecture diagram of the android operating system of FIG. 12;
FIG. 15 is an architecture diagram of the IOS operating system of FIG. 12.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the description of the present application, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In the description of the present application, it should be noted that, unless expressly specified and limited otherwise, "comprise" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The specific meaning of the above terms in the present application will be understood in specific cases by those of ordinary skill in the art. Furthermore, in the description of the present application, unless otherwise indicated, "a plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
In order to more clearly describe the technical solution of the embodiments of the present invention, before the description, some concepts of the present invention are described in detail so as to better understand the present solution. The scheme is applied to computer equipment, wherein the computer equipment comprises a memory, and the memory comprises but is not limited to storage equipment such as a mechanical hard disk, a solid state hard disk, a memory, a flash memory and the like. The partition of the memory is to divide the whole storage space of the memory into a plurality of independent areas for storing different types of data such as an operating system, application programs, data files and the like from the standpoint of convenience, easiness and rapidness of file storage and management. The traditional partition creating method is to create a new partition by newly dividing a section of space in an unused partition on the basis of the original partition according to the capacity of the new partition to be created, and so on. It should be noted that, because the storage medium has the characteristic of random distribution of bad blocks, the block refers to the minimum unit of access data, one block at least includes several sectors, and the sectors are the minimum unit of the value memory, generally, the capacity size of one sector is 512 bytes, and the storage medium has the characteristic of random distribution of bad blocks, that is, the random distribution of sectors in the storage medium cannot perform access operation, so that creating a new partition needs to consider the capacity of the new partition, and a part of sectors need to be reserved for avoiding the problem of the random distribution of bad blocks in the storage medium, but in the traditional partition creating method, the number of reserved sectors is not reasonably distributed, in addition, the random distribution of the positions of partition creation causes the construction of unusable partition gaps in adjacent partitions, which causes serious resource waste problem, and the random distribution of the partitions seriously affects the read-write performance of the memory. And then, in order to solve the problem of resource waste, a method for dynamic partitioning is provided, namely, by recording and detecting the states of the blocks of each partition, different numbers of blocks are reserved for each partition according to the detected states, so that the problem of resource waste caused by reserving more sectors for the partition in order to avoid the bad blocks distributed randomly in the memory is solved, but the partition is not processed and the read-write performance of the memory is not considered.
The partition creation method provided by the application creates a new target partition by determining the unused first storage capacity between adjacent partitions of the existing partition and utilizing the first partition capacity, thereby not only reasonably using the unused first storage capacity, improving the utilization rate of resources, but also ensuring the read-write performance of the memory based on the first storage capacity between adjacent partitions determined by the aligned sectors, and realizing the balanced use of the memory in space and performance.
The following is a detailed description of specific embodiments. The implementations described in the following exemplary examples do not represent all implementations consistent with the application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application as detailed in the accompanying claims. The flow diagrams depicted in the figures are exemplary only and are not necessarily to be taken in the order shown. For example, some steps are juxtaposed and there is no strict order of logic, so the actual order of execution is variable.
Referring to fig. 1, a flow chart of a partition creating method is provided in an embodiment of the present application. The execution main body of the embodiment of the application is computer equipment, and the computer equipment comprises a memory. As shown in fig. 1, the partition creation method may include the following steps S101 to S103.
S101, determining the positions of aligned sectors among all adjacent partitions existing in the memory;
a sector is a basic unit for data reading and writing in a memory, but because the capacity of the sector is relatively small and the number of sectors in a memory is large, addressing is difficult when reading and writing data, so a plurality of sectors are usually combined together to form a block, and the block is addressed first, and then the sectors are addressed, for example: sectors 101 to 300 are the first block and sectors 301 to 500 are the second block, where the first sector of each block is defined as an aligned sector, e.g., sectors 101 and 301. The basic unit of the memory when reading and writing data is a sector, and each sector has a storage space of 512B.
Specifically, there are already several partitions of the memory, and an aligned sector with the smallest sector number is determined from among unused sectors between adjacent partitions, where the sector number of the aligned sector indicates the location of the pair Ji Shanou in the memory.
The adjacent partition, i.e. there is no other partition between the two partitions, for example, the sector area divided by partition 1 includes 101 th to 3000 th sectors, the sector area divided by partition 2 is 4000 th to 6400 th sectors, and the 3001 th to 3999 th sectors are not used by the partition, and the partition 1 and the partition 2 are considered to be adjacent partitions.
S102, determining a first storage capacity between the aligned sector position and the next partition in each adjacent partition, wherein each adjacent partition comprises a current partition and the next partition;
specifically, the aligned sector position is located between the current partition and the next partition, and unused storage space between the aligned sector position and the next partition is used as the first storage capacity.
S103, creating a target partition based on the first storage capacity between each aligned sector position and the next partition in each adjacent partition and the preset partition capacity.
Specifically, according to the preset partition capacity and the capacity of the first partition capacity between the adjacent partitions, creating a target partition by using the first partition capacity, if the total storage capacity of each first partition capacity is greater than or equal to the preset partition capacity, creating the target partition by using only each partition gap, if the total storage capacity of each first partition capacity is less than the preset partition capacity, taking each first partition capacity as a part of the target partition, and then creating a target partition of the rest part at a position where no partition is performed after the last partition.
It will be appreciated that the capacity of the partition gap may be calculated based on how many sectors are included between each partition gap.
The unit of the partition capacity is a byte (B), which is the smallest unit representing the meaning of information in a computer, and KB, MB, GB, T and the like, which represent units of storage capacity in addition to bytes, 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 provided by the application creates a new target partition by determining the unused first storage capacity between adjacent partitions of the existing partition and utilizing the first partition capacity, thereby not only reasonably using the unused first storage capacity, improving the utilization rate of resources, but also ensuring the read-write performance of the memory based on the first storage capacity between adjacent partitions determined by the aligned sectors, and realizing the balanced use of the memory in space and performance.
Referring to fig. 2, a flow chart of a partition creating method is provided in an embodiment of the present application. The execution main body of the embodiment of the application is computer equipment, and the computer equipment comprises a memory. As shown in fig. 2, the partition creation method may include the following steps S201 to S212.
S201, acquiring the residual storage capacity of the memory;
specifically, determining a target alignment sector position after the last partition existing in the memory and the last sector position of the memory, and taking a second storage capacity from the target alignment sector position after the last partition to the last sector position of the memory as the remaining storage capacity of the memory.
S202, if the residual storage capacity is greater than or equal to a preset partition capacity, judging whether a target partition to be created exists in the memory or not;
specifically, if the remaining storage capacity is smaller than the preset partition capacity, the target partition with the preset partition capacity cannot be established, and if the remaining storage capacity is greater than or equal to the preset partition capacity, which indicates that there is enough remaining storage space in the memory to create a new partition, whether the existing partition in the memory includes the target partition to be created is determined. For example, there is already a master blaze partition in the memory, and now the master blaze partition is updated significantly, and a partition needs to be established for storage, i.e. there is already a target partition to be created in the memory.
Further, if the remaining storage capacity is smaller than the preset partition capacity, the method returns directly, and a new partition cannot be created.
S203, if the target partition to be created does not exist in the memory, executing the step of determining the alignment sector position between the adjacent partitions existing in the memory;
s204, if the target partition to be created exists in the memory, expanding the target partition after the last sector of the target partition;
specifically, if a target partition to be created exists in the existing partitions in the memory, the target partition is expanded from the last sector of the target partition based on a preset partition capacity.
S205, judging whether the expanded target partition covers the next partition of the target partition;
specifically, after the target partition is expanded in step S203, the ending sector of the target partition changes, the ending sector position of the target partition cannot exceed the starting sector position of the next partition of the target partition, if the ending sector position of the target partition exceeds the starting sector position of the next partition of the target partition, the expanded target partition is considered to cover the next partition of the target partition, otherwise, if the ending sector position of the target partition does not exceed the starting sector position of the next partition of the target partition, the expanded target partition is considered not to cover the next partition of the target partition.
S206, if the expanded target partition covers the next partition of the target partition, executing the step of determining the alignment sector position between each adjacent partition existing in the memory;
referring to fig. 3, an exemplary schematic diagram of partition coverage is provided in an embodiment of the present application.
As shown in fig. 3, the existing partition 1 includes sectors 201 to 1556, the existing partition 2 includes sectors 2701 to 4158, if the partition 1 is expanded according to the preset partition capacity, the expanded partition includes sectors 1557 to 3358 as a dotted line, and it is obvious that the storage areas of sectors 2701 to 3358 are already used by the partition 2, that is, the expanded target partition covers the next partition of the target partition.
S207, if the expanded target partition does not cover the next partition of the target partition, taking the expanded target partition as the created target partition;
referring to fig. 4, an exemplary schematic diagram of partition uncovering is provided in an embodiment of the present application.
As shown in fig. 4, the existing partition 1 includes sectors 201 to 1556, the existing partition 2 includes sectors 2701 to 4158, if the partition 1 is expanded according to the preset partition capacity, the expanded partition includes sectors 1557 to 2594 as a dotted line, it is obvious that the expanded portion of the partition 1 does not cover any one partition, 2594<2701, that is, the expanded target partition does not cover the next partition of the target partition, and the storage area from the sectors 201 to 2594 is directly used as the target partition.
S208, determining the alignment sector position between each adjacent partition existing in the memory;
specifically, each existing partition in the memory is traversed, an alignment area to which the last sector in the current partition belongs is calculated based on a sector number, a sector capacity and an alignment parameter of the memory of the last sector in the current partition, and an alignment sector position between the current partition and the next partition is calculated based on the alignment area to which the last sector in the current partition belongs, the alignment parameter, the alignment offset and the sector capacity of the memory.
The alignment parameter of the memory is a single block capacity, the alignment area is a block, and the calculation of the alignment area to which the last sector in the current partition belongs is the calculation of the block number of the block to which the last sector in the current partition belongs.
Firstly, calculating the total capacity from the first sector to the last sector of the current partition, namely multiplying the sector number of the last sector of the current partition by the capacity of a single sector to obtain the total capacity from the first sector to the last sector of the current partition, dividing the total capacity from the first sector to the last sector of the current partition by the capacity of a single block, and finally taking the result up to an integer, wherein the obtained result is the block number of the block to which the last sector of the current partition belongs. The current partition refers to one of the existing partitions, and by using the method, all the existing partitions in the memory are traversed, so that the block number of the block to which the last sector of each partition belongs can be obtained.
And calculating the aligned sector position between the current partition and the next partition based on the aligned area to which the last sector in the current partition belongs, the aligned parameter of the memory, the aligned offset and the sector capacity. The alignment offset refers to an alignment offset that is a storage capacity between the first aligned sector and the first aligned sector from the sector with the sector number 1, for example: the first aligned sector has a sector number of 61, and the alignment offset is 60 sectors.
Specifically, the alignment area, that is, the block number of the block to which the last sector belongs in the current partition is utilized, the block number is multiplied by the alignment parameter of the memory, the obtained result is added with the alignment offset to obtain the storage capacity from the sector with the sector number of 1 to the last sector of the alignment area, the storage capacity from the sector with the sector number of 1 to the last sector of the alignment area is divided by the capacity of a single sector, that is, the number of sectors from the sector with the sector number of 1 to the last sector of the alignment area is obtained, and the obtained number of sectors is added with 1 to obtain the sector number of the alignment sector.
Referring to fig. 5, an exemplary schematic diagram of calculating sector numbers of aligned sectors is provided in an embodiment of the present application.
As shown in fig. 5, including 2 existing partitions, partition 1 and partition 2, where partition 1 includes 201 th to 1556 th sectors, partition 2 includes 2701 st to 5000 th sectors, the alignment offset includes sectors 1 to 101, a total of 100 sectors, each alignment area has a capacity of 204800B, the first alignment area is 101 th to 500 th sectors, and so on. Firstly, calculating an alignment area to which a last sector of the partition 1 belongs, wherein the alignment area can also be called a block, multiplying a sector number of the last sector of the partition 1 by a capacity of a single sector and dividing the capacity of the single alignment area by a capacity of the single alignment area, namely (1556×512)/204800 =3.89 as shown in fig. 5, and then taking an integer equal to 4 upwards by 3.89, namely the alignment area to which the last sector of the partition 1 belongs is a 4 th alignment area, multiplying a number of the alignment area to which the last sector belongs by a capacity of the single alignment area and adding an alignment offset to multiply the capacity of the single sector to obtain a total capacity of 4 alignment areas plus the alignment offset, dividing the total capacity by the capacity of the single sector, and finally adding 1 to obtain the sector number of the alignment sector as shown in fig. 5 (4×204800+100×512)/512+1=1701.
S209, determining a first storage capacity between the aligned sector position and a next partition in each adjacent partition, wherein each adjacent partition comprises a current partition and a next partition;
specifically, determining a starting position of a first sector of the next partition, determining a first storage capacity between the aligned sector position and 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, and determining that the first storage capacity does not exist between the current partition and 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.
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, and the next partition is the next partition of each adjacent partition, for example, partition 1 and partition 2 are adjacent partitions, the sector area divided by partition 1 comprises 101 th to 3000 th sectors, the sector area divided by partition 2 is 4000 th to 6400 th sectors, partition 1 is the current partition, partition 2 is the next partition, and the sector number of the first sector of the next partition is 4000.
The current partition and the next partition are adjacent partitions, a certain number of unused sectors exist between the current partition and the next partition, and whether the aligned sector calculated based on the current partition belongs to the unused sector between the current partition and the next partition is judged.
And if the sector number of the aligned sector is smaller than the sector number of the first sector of the next partition, taking the gap between the aligned sector position between the current partition and the next partition and the starting position of the first sector of the next partition as the first storage capacity between the current partition and the next partition.
And if the sector number of the aligned sector is greater than or equal to the sector number of the first sector of the next partition, determining that the first storage capacity does not exist between the current partition and the next partition.
It is to be understood that, because the memory reads and writes data based on blocks, if a string of data is stored in a block, the memory only needs to read a block; if a string of data is stored in two blocks and a part of the data is stored in one block, the memory needs to read the two blocks if the string of data is to be read, and more time is wasted compared with storing the string of data in one block for reading, so that each first storage capacity is used from the first sector of one block when the data is stored in the first sector of the next partition in a manner of determining the first storage capacity from the aligned sectors.
Referring to fig. 6, an exemplary schematic diagram of determining a first storage capacity is provided in an embodiment of the application.
As shown in fig. 6, there are three existing partitions including partition 1, partition 2 and partition 3, wherein partition 1 and partition 2 are adjacent partitions, partition 2 and partition 3 are adjacent partitions, partition 1 includes 201 th to 1556 th sectors, partition 2 includes 2701 th to 4158 th sectors, partition 3 includes 4276 th to 5875 th sectors, an aligned sector between partition 1 and partition 2 is calculated from the last sector of partition 1 is sector 1701, and the first sector of partition 2 is sector 2701, and if sector 1701 does not exceed sector 2701, there is a first storage capacity of sectors 1701 to 2701; and according to the last sector of the partition 2, the aligned sector between the partition 2 and the partition 3 is calculated as a sector 4501, in the figure, the first sector of the partition 3 is a sector 4276, the sector 4501 exceeds the sector 4276, the sector number of the aligned sector is greater than the sector number of the first sector of the partition 3, and then the first storage capacity does not exist between the partition 2 and the partition 3.
S210, calculating the sum of the first storage capacities between the adjacent partitions to obtain the total storage capacity;
Specifically, the first storage capacities calculated from between the adjacent partitions are added to obtain the total storage capacity.
S211, if the total storage capacity is smaller than the preset partition capacity, creating a target partition by taking the position of a target alignment sector after the last partition existing in the memory as a starting point and taking the difference value between the preset partition capacity and the total storage capacity as a storage capacity;
specifically, if the total storage capacity of the partition gap between each adjacent partition is smaller than the preset partition capacity, taking each first storage capacity as a part of the target partition, then determining the last partition of each partition existing in the memory, acquiring the sector number of the last sector of the last partition, then determining the sector number of the first aligned sector behind the last partition according to the mode described in step S208, wherein the sector number of the aligned sector represents the aligned sector position, taking the aligned sector position as a starting point, taking the difference between the preset partition capacity and the total storage capacity as the storage capacity, creating a sub-partition, and finally taking each first storage capacity and the sub-partition as the target partition.
Optionally, if the total storage capacity of the partition gap between each adjacent partition is smaller than the preset partition capacity, the target partition is created without using the first partition capacity, the last partition of each partition existing in the memory is directly determined, the sector number of the last sector of the last partition is obtained, then the sector number of the first aligned sector behind the last partition is determined according to the manner described in step S208, the sector number of the aligned sector characterizes the aligned sector position, the aligned sector position is used as a starting point, and the preset partition capacity is used as the storage capacity, so that the target partition is created.
S212, if the total storage capacity is greater than or equal to the preset partition capacity, selecting a preset partition capacity from the total storage capacity to create a target partition.
Specifically, if the total storage capacity of each first storage capacity between each adjacent partition is equal to the preset partition capacity, directly using each first storage capacity to create a target partition, if the total storage capacity of each first storage capacity between each adjacent partition is greater than the preset partition capacity, overlapping each first storage capacity according to the sequence of each first storage capacity, and when the overlapped storage capacity is equal to the preset partition capacity, taking the overlapped first partition capacity as the target partition.
The sequence of the first storage capacities may be ordered according to sector numbers of the sectors in the first storage capacities, the smaller the sector numbers of the sectors are, the more front the sector numbers of the sectors are, the stacking of the first storage capacities means that the first storage capacities are stacked one by one according to the sequence and compared with a preset partition capacity in a stacking process, and then when the stacked storage capacities are equal to the preset partition capacity, the stacked first storage capacities are taken as the target partition, for example, to explain: the memory has five first storage capacities, namely a first storage capacity 1, a first storage capacity 2, a first storage capacity 3, a first storage capacity 4 and a first storage capacity 5, respectively, first comparing the first storage capacity 1 with a preset partition capacity, if the preset partition capacity is larger than the first storage capacity 1, overlapping the first storage capacity 1 with the first storage capacity 2, then comparing the storage capacity overlapped by the first storage capacity 1 and the first storage capacity 2 with the preset partition capacity, and similarly, if the storage capacity overlapped by the first storage capacity 1, the first storage capacity 2, the first storage capacity 3 and the first storage capacity 4 is larger than the preset partition capacity, taking the first storage capacity 1, the first storage capacity 2, the first storage capacity 3 and the first storage capacity 4 as target partitions.
Optionally, if the storage capacity of the stacked 4 first storage capacities is greater than the preset partition capacity, the storage capacities of the first three first storage capacities may be stacked, the first three first storage capacities are taken as a part of the target partition, then the sector number of the first sector of the 4 th first storage capacity is determined, the first sector of the 4 th first storage capacity is taken as a starting point, the difference between the preset partition capacity and the storage capacity stacked by the first three first storage capacities is taken as the storage capacity, a sub-partition is created, and finally the first three first storage capacities and the sub-partition are taken as the target partition.
Referring to fig. 7 together with steps S211 to S212, an exemplary schematic diagram of creating a target partition is provided in an embodiment of the present application.
As shown in fig. 7, 4 first storage capacities are present between adjacent partitions, wherein the first storage capacity 1 has a gap capacity of 256000, a total of 500 sectors, the first storage capacity 2 has a gap capacity of 204800, a total of 400 sectors, the first storage capacity 3 has a gap capacity of 307200, a total of 600 sectors, and the first storage capacity 4 has a gap capacity of 358400, and a total of 700 sectors.
Next, referring to fig. 7, three cases, that is, the total storage capacity of the first storage capacity is smaller than the preset partition capacity, the total storage capacity of the first storage capacity is equal to the preset partition capacity, and the total storage capacity of the first storage capacity is larger than the preset partition capacity, will be described by way of example.
In the first case, if the partition capacity of the target partition is 1500000, 2930 sectors are required, that is, the total storage capacity of the first storage capacity is smaller than the preset partition capacity, and at this time, the target partition should include a first storage capacity 1, a first storage capacity 2, a first storage capacity 3, a first storage capacity 4, and a sub-partition created after the last partition, where the capacity of the sub-partition is equal to the preset partition capacity minus the total storage capacity of the 4 first storage capacities, and 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.
In the second case, if the preset partition capacity is 1126400, 2200 sectors are required in total, and the total storage capacity of the first storage capacity is equal to the preset partition capacity, the target partition should include the first storage capacity 1, the first storage capacity 2, the first storage capacity 3, and the first storage capacity 4.
In the third case, if the preset partition capacity is 660000, 1290 sectors are required, that is, the total storage capacity of the first storage capacities is greater than the preset partition capacity, and since the storage capacities of the first storage capacity 1, the first storage capacity 2, and the first storage capacity 3, which are obtained by stacking the 3 first storage capacities, are already greater than the preset partition capacity, the target partition should include the first storage capacity 1, the first storage capacity 2, and the first storage capacity 3.
It should be noted that, in the embodiment of the present application, the steps of obtaining the remaining storage capacity of the memory, comparing the remaining storage capacity with the preset storage capacity, and determining whether the target partition to be created already exists in the memory may be parallel, which may be executed separately, and there is no limited logical sequence.
In the embodiment of the application, the residual storage capacity of the memory is firstly obtained, the residual storage capacity is compared with the preset partition capacity, if the residual storage capacity is smaller than the preset partition capacity, the target partition of the preset partition capacity cannot be established, and if the residual storage capacity is greater than or equal to the preset partition capacity, the target partition of the preset partition capacity can be established, so that the feasibility of partition establishment is ensured; then judging whether a target partition to be created exists in the memory, determining whether the creation of the target partition is the creation of a new partition or the expansion of the existing partition, and if the target partition to be created exists in the memory and the expanded target partition does not cover the next partition of the target partition, taking the expanded target partition as the created target partition, so that the expansion of the existing partition is facilitated; if the target partition to be created does not exist in the memory, the first storage capacity among all the existing partitions is calculated, the target partition is created by utilizing the first storage capacity and the residual storage capacity, the unused first storage capacity is reasonably used, the utilization rate of resources is improved, the first storage capacity among all the adjacent partitions determined based on the aligned sector positions guarantees the read-write performance of the memory, and the balanced use of the memory in space and performance is realized.
Referring to fig. 8, a schematic structural diagram of a partition creating apparatus is provided in an embodiment of the present application. As shown in fig. 8, the partition creating apparatus 1 may be implemented as all or a part of the terminal device by software, hardware, or a combination of both. According to some embodiments, the partition creating apparatus 1 includes, a remaining capacity obtaining module 11, a partition judging module 12, a partition expanding module 13, a coverage judging module 14, a position determining module 15, a gap determining module 16, a partition establishing module 17, specifically including:
a remaining capacity acquisition module 11 for acquiring a remaining storage capacity of the memory;
a partition determination module 12, configured to determine whether a target partition to be created already exists in the memory;
a partition expansion module 13, configured to expand a target partition to be created after a last sector of the target partition if the target partition already exists in the memory;
a coverage judging module 14, configured to judge whether the expanded target partition covers a next partition of the target partition;
a location determination module 15 for determining aligned sector locations between adjacent partitions already present in the memory;
A gap determination module 16 for determining a first storage capacity between the aligned sector location to a next sector in each of the adjacent partitions, each of the adjacent partitions including a current sector and a next sector;
a partition establishing module 17, configured to create a target partition based on a first storage capacity between each aligned sector position and a next partition in each adjacent partition and a preset partition capacity.
Optionally, the remaining capacity obtaining module is specifically configured to:
determining a target aligned sector location after a last partition already present in the memory and a last sector location of the memory;
and taking the second storage capacity from the target alignment sector position after the last partition to the last sector position of the memory as the residual storage capacity of the memory.
Optionally, the location determining module is further configured to execute the step of determining the location of the aligned sector between each adjacent partition existing in the memory if the remaining storage capacity is greater than or equal to a preset partition capacity.
Optionally, the location determining module is further configured to execute the step of determining the location of the aligned sector between each neighboring partition existing in the memory if the expanded target partition covers the next partition of the target partition.
Optionally, the location determining module is further configured to execute the step of determining an aligned sector location between adjacent partitions existing in the memory if the target partition to be created does not exist in the memory;
optionally, the partition expansion module is further configured to take the expanded target partition as the created target partition if the expanded target partition does not cover the next partition of the target partition.
Optionally, as shown in fig. 9, a schematic structural diagram of the location determining module 15 is provided in an embodiment of the present application.
The location determination module 15 comprises:
a region calculating unit 151, configured to traverse each partition existing in the memory, and calculate an alignment region to which a last sector in a current partition belongs based on a sector number of the last sector in the current partition, a sector capacity, and an alignment parameter of the memory;
a position calculating unit 152, configured to calculate an aligned sector position between the current partition and the next partition based on an aligned area to which the last sector in the current partition belongs, an aligned parameter of the memory, an aligned offset, and the sector capacity.
Alternatively, as shown in fig. 10, a schematic structural diagram of a gap determining module 16 is provided in accordance with an embodiment of the present application.
The gap determination module 16 includes:
a start sector determining unit 161 for determining a start position of a first sector of the next partition;
a first gap determining unit 162, configured to determine a first storage capacity from a position of an aligned sector to a start position of a first sector of a next partition if the position of the aligned sector between the current partition and the next partition is smaller than the start position of the first sector of the next partition;
a second gap determining unit 163, configured to determine that the first storage capacity does not exist between the current partition and the next partition if the aligned sector position between the current partition and the next partition is greater than or equal to the start position of the first sector of the next partition.
Optionally, as shown in fig. 11, a schematic structural diagram of the partition establishing module 17 is provided in an embodiment of the present application.
The partition establishing module 17 includes:
a total capacity obtaining unit 171 for calculating a sum of the first storage capacities between the adjacent partitions to obtain a total storage capacity;
A first partition creating unit 172, configured to create a target partition with a target aligned sector position after a last partition already existing in the memory as a start point and a difference between a preset partition capacity and the total storage capacity as a storage capacity if the total storage capacity is smaller than the preset partition capacity;
the second partition creating unit 173 is configured to select a preset partition capacity creating target partition from the total storage capacities if the total storage capacity is greater than or equal to the preset partition capacity.
It should be noted that, when the partition creating apparatus provided in the foregoing embodiment performs the partition creating method, only the division of the foregoing functional modules is used as an example, and in practical application, the foregoing functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the partition creating device and the partition creating method provided in the foregoing embodiments belong to the same concept, which embody the detailed implementation process of the method embodiment, and are not described herein again.
The foregoing embodiment numbers of the present application are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
In the embodiment of the application, the residual storage capacity of the memory is firstly obtained, the residual storage capacity is compared with the preset partition capacity, if the residual storage capacity is smaller than the preset partition capacity, the target partition of the preset partition capacity cannot be established, and if the residual storage capacity is greater than or equal to the preset partition capacity, the target partition of the preset partition capacity can be established, so that the feasibility of partition establishment is ensured; then judging whether a target partition to be created exists in the memory, determining whether the creation of the target partition is the creation of a new partition or the expansion of the existing partition, and if the target partition to be created exists in the memory and the expanded target partition does not cover the next partition of the target partition, taking the expanded target partition as the created target partition, so that the expansion of the existing partition is facilitated; if the target partition to be created does not exist in the memory, the first storage capacity among all the existing partitions is calculated, the target partition is created by utilizing the first storage capacity and the residual storage capacity, the unused first storage capacity is reasonably used, the utilization rate of resources is improved, the first storage capacity among all the adjacent partitions determined based on the aligned sector positions guarantees the read-write performance of the memory, and the balanced use of the memory in space and performance is realized.
The embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are suitable for being loaded by a processor and executed by the processor, where the specific execution process may refer to the specific description of the embodiment shown in fig. 1 to 7, and details are not described herein.
The present application also provides a computer program product, where at least one instruction is stored, where the at least one instruction is loaded by the processor and executed by the processor to perform the partition creating method according to the embodiment shown in fig. 1 to fig. 7, and the specific execution process may refer to the specific description of the embodiment shown in fig. 1 to fig. 7, which is not repeated herein.
Referring to FIG. 12, a block diagram of a computer device according to an exemplary embodiment of the present application is shown. The computer device of the present application may include one or more of the following: processor 110, memory 120, input device 130, output device 140, and bus 150. The processor 110, the memory 120, the input device 130, and the output device 140 may be connected by a bus 150.
Processor 110 may include one or more processing cores. The processor 110 utilizes various interfaces and lines to connect various portions of the overall computer device, perform various functions of the computer device 100 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 120, and invoking data stored in the memory 120. Alternatively, the processor 110 may be implemented in at least one hardware form of digital signal processing (digital signal processing, DSP), field-programmable gate array (field-programmable gate array, FPGA), programmable logic array (programmable logic Array, PLA). The processor 110 may integrate one or a combination of several of a central processing unit (central processing unit, CPU), an image processor (graphics processing unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for being responsible for rendering and drawing of display content; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into the processor 110 and may be implemented solely by a single communication chip.
The memory 120 may include a random access memory (random Access Memory, RAM) or a read-only memory (ROM). Optionally, the memory 120 includes a non-transitory computer readable medium (non-transitory computer-readable storage medium). Memory 120 may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory 120 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, which may be an Android (Android) system, including an Android system-based deep development system, an IOS system developed by apple corporation, including an IOS system-based deep development system, or other systems, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing various method embodiments described below, and the like. The storage data area may also store data created by the computer device in use, such as phonebooks, audiovisual data, chat log data, and the like.
Referring to FIG. 13, the memory 120 may be divided into an operating system space in which the operating system is running and a user space in which native and third party applications are running. In order to ensure that different third party application programs can achieve better operation effects, the operating system allocates corresponding system resources for the different third party application programs. However, the requirements of different application scenarios in the same third party application program on system resources are different, for example, under the local resource loading scenario, the third party application program has higher requirement on the disk reading speed; in the animation rendering scene, the third party application program has higher requirements on the GPU performance. The operating system and the third party application program are mutually independent, and the operating system often cannot timely sense the current application scene of the third party application program, so that the operating system cannot perform targeted system resource adaptation according to the specific application scene of the third party application program.
In order to enable the operating system to distinguish specific application scenes of the third-party application program, data communication between the third-party application program and the operating system needs to be communicated, so that the operating system can acquire current scene information of the third-party application program at any time, and targeted system resource adaptation is performed based on the current scene.
Taking an operating system as an Android system as an example, as shown in fig. 14, a program and data stored in the memory 120 may be stored in the memory 120 with a Linux kernel layer 320, a system runtime library layer 340, an application framework layer 360 and an application layer 380, where the Linux kernel layer 320, the system runtime library layer 340 and the application framework layer 360 belong to an operating system space, and the application layer 380 belongs to a user space. The Linux kernel layer 320 provides the underlying drivers for various hardware of the computer device, such as display drivers, audio drivers, camera drivers, bluetooth drivers, wi-Fi drivers, power management, and the like. The system runtime layer 340 provides the main feature support for the Android system through some C/c++ libraries. For example, the SQLite library provides support for databases, the OpenGL/ES library provides support for 3D graphics, the Webkit library provides support for browser kernels, and the like. Also provided in the system runtime library layer 340 is a An Zhuoyun runtime library (Android run) which provides mainly some core libraries that can allow developers to write Android applications using the Java language. The application framework layer 360 provides various APIs that may be used in building applications, which developers can also build their own applications by using, for example, campaign management, window management, view management, notification management, content provider, package management, call management, resource management, location management. At least one application program is running in the application layer 380, and these application programs may be native application programs of the operating system, such as a contact program, a short message program, a clock program, a camera application, etc.; and may also be a third party application developed by a third party developer, such as a game-like application, instant messaging program, photo beautification program, partition creation program, etc.
Taking an operating system as an IOS system as an example, the program and data stored in the memory 120 are shown in fig. 15, the IOS system includes: core operating system layer 420 (Core OS layer), core service layer 440 (Core Services layer), media layer 460 (Media layer), and touchable layer 480 (Cocoa Touch Layer). The core operating system layer 420 includes an operating system kernel, drivers, and underlying program frameworks that provide more hardware-like functionality for use by the program frameworks at the core services layer 440. The core services layer 440 provides system services and/or program frameworks required by the application, such as a Foundation (Foundation) framework, an account framework, an advertisement framework, a data storage framework, a network connection framework, a geographic location framework, a sports framework, and the like. The media layer 460 provides an interface for applications related to audiovisual aspects, such as a graphics-image related interface, an audio technology related interface, a video technology related interface, an audio video transmission technology wireless play (AirPlay) interface, and so forth. The touchable layer 480 provides various commonly used interface-related frameworks for application development, with the touchable layer 480 being responsible for user touch interactions on the computer device. Such as a local notification service, a remote push service, an advertisement framework, a game tool framework, a message User Interface (UI) framework, a User Interface UIKit framework, a map framework, and so forth.
Among the frameworks illustrated in fig. 15, frameworks related to most applications include, but are not limited to: the infrastructure in core services layer 440 and the UIKit framework in touchable layer 480. The infrastructure provides many basic object classes and data types, providing the most basic system services for all applications, independent of the UI. While the class provided by the UIKit framework is a basic UI class library for creating touch-based user interfaces, iOS applications can provide UIs based on the UIKit framework, so it provides the infrastructure for applications to build user interfaces, draw, process and user interaction events, respond to gestures, and so on.
The manner and principle of implementing data communication between the third party application program and the operating system in the IOS system can refer to the Android system, and the application is not described herein.
The input device 130 is configured to receive input instructions or data, and the input device 130 includes, but is 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 is not limited to, a display device, a speaker, and the like. In one example, the input device 130 and the output device 140 may be combined, and the input device 130 and the output device 140 are a touch display screen for receiving a touch operation thereon or thereabout by a user using a finger, a touch pen, or any other suitable object, and displaying a user interface of each application program. Touch display screens are typically provided on the front panel of a computer device. The touch display screen may be designed as a full screen, a curved screen, or a contoured screen. The touch display screen may also be designed as a combination of a full screen and a curved screen, and the combination of a special-shaped screen and a curved screen, which is not limited in the embodiment of the present application.
In addition, those skilled in the art will appreciate that the structures of the computer devices shown in the above-described figures are not limiting and that a computer device may include more or fewer components than shown, or may combine certain components, or a different arrangement of components. For example, the computer device further includes components such as a radio frequency circuit, an input unit, a sensor, an audio circuit, a wireless fidelity (wireless fidelity, wiFi) module, a power supply, and a bluetooth module, which are not described herein.
In the embodiment of the present application, the execution subject of each step may be the computer device described above. Optionally, the execution subject of each step is an operating system of the computer device. The operating system may be an android system, an IOS system, or other operating systems, which is not limited by the embodiments of the present application.
The computer device of the embodiment of the application can be further provided with a display device, and the display device can be various devices capable of realizing display functions, such as: cathode ray tube displays (cathode ray tubedisplay, CR), light-emitting diode displays (light-emitting diode display, LED), electronic ink screens, liquid crystal displays (liquid crystal display, LCD), plasma display panels (plasma display panel, PDP), and the like. A user may utilize a display device on computer device 101 to view displayed text, images, video, etc. The computer device may be a smart phone, tablet, gaming device, AR (Augmented Reality ) device, automobile, data storage, audio playback, video playback, notebook, desktop computing device, wearable device such as an electronic watch, electronic glasses, electronic helmet, electronic bracelet, electronic necklace, electronic clothing, etc.
In the computer device shown in fig. 12, the processor 110 may be configured to call a partition creation program stored in the memory 120, and specifically perform the following operations:
determining aligned sector locations between adjacent partitions already present in the memory;
determining a first storage capacity between the aligned sector location to a next partition in each of the adjacent partitions, each of the adjacent partitions including a current partition and a next partition;
a target partition is created based on a first storage capacity between each of the aligned sector locations to a next one of the adjacent partitions and a preset partition capacity.
In one embodiment, the processor 110, prior to performing the determining the aligned sector locations between adjacent partitions already present in the memory, further performs the following:
judging whether a target partition to be created exists in the memory or not;
if the target partition to be created already exists in the memory, expanding the target partition after the last sector of the target partition;
if the target partition to be created does not exist in the memory, executing the step of determining the alignment sector position between the adjacent partitions existing in the memory;
Judging whether the expanded target partition covers the next partition of the target partition or not;
if the expanded target partition does not cover the next partition of the target partition, taking the expanded target partition as the created target partition;
and if the expanded target partition covers the next partition of the target partition, executing the step of determining the alignment sector position between all the adjacent partitions existing in the memory.
In one embodiment, the processor 110, prior to performing the determining the aligned sector locations between adjacent partitions already present in the memory, further performs the following:
acquiring the residual storage capacity of the memory;
and if the residual storage capacity is greater than or equal to the preset partition capacity, determining the alignment sector position among all the adjacent partitions existing in the memory.
In one embodiment, the processor 110, when executing the obtaining the remaining storage capacity of the memory, specifically performs the following operations:
determining a target aligned sector location after a last partition already present in the memory and a last sector location of the memory;
And taking the second storage capacity from the target alignment sector position after the last partition to the last sector position of the memory as the residual storage capacity of the memory.
In one embodiment, the processor 110, in performing the determining the aligned sector locations between adjacent partitions already present in the memory, specifically performs the following operations:
traversing all existing partitions in the memory, and calculating an alignment area of the last sector in the current partition based on the sector number and the sector capacity of the last sector in the current partition and the alignment parameters of the memory;
and calculating the aligned sector position between the current partition and the next partition based on the aligned area to which the last sector in the current partition belongs, the aligned parameter of the memory, the aligned offset and the sector capacity.
In one embodiment, the processor 110, in performing the determining the aligned sector location to a first storage capacity between a next partition in each of the adjacent partitions, specifically performs the following operations:
determining a starting position of a 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, determining a first storage capacity from the aligned sector position to the starting position of the first sector of the next partition;
and 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, determining that no first storage capacity exists between the current partition and the next partition.
In one embodiment, the processor 110, when executing the creating a target partition based on the first storage capacity between each of the aligned sector positions to a next partition in each of the adjacent partitions and a preset partition capacity, specifically performs the following operations:
calculating the sum of the first storage capacities between the adjacent partitions to obtain a total storage capacity;
if the total storage capacity is smaller than the preset partition capacity, a target partition is created by taking the position of a target alignment sector after the last partition existing in the memory as a starting point and taking the difference value between the preset partition capacity and the total storage capacity as a storage capacity;
And if the total storage capacity is larger than or equal to the preset partition capacity, selecting the preset partition capacity from the total storage capacity to create a target partition.
In the embodiment of the application, the residual storage capacity of the memory is firstly obtained, the residual storage capacity is compared with the preset partition capacity, if the residual storage capacity is smaller than the preset partition capacity, the target partition of the preset partition capacity cannot be established, and if the residual storage capacity is greater than or equal to the preset partition capacity, the target partition of the preset partition capacity can be established, so that the feasibility of partition establishment is ensured; then judging whether a target partition to be created exists in the memory, determining whether the creation of the target partition is the creation of a new partition or the expansion of the existing partition, and if the target partition to be created exists in the memory and the expanded target partition does not cover the next partition of the target partition, taking the expanded target partition as the created target partition, so that the expansion of the existing partition is facilitated; if the target partition to be created does not exist in the memory, the first storage capacity among all the existing partitions is calculated, the target partition is created by utilizing the first storage capacity and the residual storage capacity, the unused first storage capacity is reasonably used, the utilization rate of resources is improved, the first storage capacity among all the adjacent partitions determined based on the aligned sector positions guarantees the read-write performance of the memory, and the balanced use of the memory in space and performance is realized.
It will be clear to a person skilled in the art that the solution according to the application can be implemented by means of software and/or hardware. "Unit" and "module" in this specification refer to software and/or hardware capable of performing a specific function, either alone or in combination with other components, such as Field programmable gate arrays (Field-ProgrammaBLE Gate Array, FPGAs), integrated circuits (Integrated Circuit, ICs), etc.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of acts, but it should be understood by those skilled in the art that the present application is not limited by the order of acts described, as some steps may be performed in other orders or concurrently in accordance with the present application. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required for the present application.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to related descriptions of other embodiments.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, such as the division of the units, merely a logical function division, and there may be additional manners of dividing the actual implementation, such as multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some service interface, device or unit indirect coupling or communication connection, electrical or otherwise.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable memory. Based on this understanding, the technical solution of the present application may be embodied essentially or partly in the form of a software product, or all or part of the technical solution, which is stored in a memory, and includes several instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned memory includes: a U-disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Those of ordinary skill in the art will appreciate that all or a portion of the steps in the various methods of the above embodiments may be performed by hardware associated with a program that is stored in a computer readable memory, which may include: flash disk, read-Only Memory (ROM), random-access Memory (Random Access Memory, RAM), magnetic or optical disk, and the like.
The foregoing is merely exemplary embodiments of the present disclosure and is not intended to limit the scope of the present disclosure. That is, equivalent changes and modifications are contemplated by the teachings of this disclosure, which fall within the scope of the present disclosure. Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a scope and spirit of the disclosure being indicated by the claims.

Claims (10)

1. A partition creation method applied to a computer device, the computer device containing a memory, the method comprising:
Traversing all existing partitions in the memory, and calculating an alignment area of the last sector in the current partition based on the sector number and the sector capacity of the last sector in the current partition and the alignment parameters of the memory;
calculating an aligned sector position between the current partition and the next partition based on an aligned area to which a last sector in the current partition belongs, an aligned parameter of the memory, an aligned offset and the sector capacity;
determining a first storage capacity between the aligned sector location to a next sector in each adjacent sector, each of the adjacent sectors including a current sector and a next sector;
a target partition is created based on a first storage capacity between each of the aligned sector locations to a next one of the adjacent partitions and a preset partition capacity.
2. The partition creation method of claim 1, wherein prior to determining the aligned sector locations between adjacent partitions already present in the memory, further comprising:
acquiring the residual storage capacity of the memory;
and if the residual storage capacity is greater than or equal to the preset partition capacity, determining the alignment sector position among all the adjacent partitions existing in the memory.
3. The method of claim 2, wherein the obtaining the remaining storage capacity of the memory comprises:
determining a target aligned sector location after a last partition already present in the memory and a last sector location of the memory;
and taking the second storage capacity from the target alignment sector position after the last partition to the last sector position of the memory as the residual storage capacity of the memory.
4. The partition creation method of claim 1, wherein the determining a first storage capacity between the aligned sector location to a next partition in each of the adjacent partitions comprises:
determining a starting position of a 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, determining a first storage capacity from the aligned sector position to the starting position of the first sector of the next partition;
and 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, determining that no first storage capacity exists between the current partition and the next partition.
5. The partition creation method of claim 1, wherein prior to determining the aligned sector locations between adjacent partitions already present in the memory, further comprising:
judging whether a target partition to be created exists in the memory or not;
if the target partition to be created already exists in the memory, expanding the target partition after the last sector of the target partition;
judging whether the expanded target partition covers the next partition of the target partition or not;
and if the expanded target partition covers the next partition of the target partition, executing the step of determining the alignment sector position between all the adjacent partitions existing in the memory.
6. The method of claim 5, wherein the method further comprises:
if the target partition to be created does not exist in the memory, executing the step of determining the alignment sector position between the adjacent partitions existing in the memory; or (b)
And if the expanded target partition does not cover the next partition of the target partition, taking the expanded target partition as the created target partition.
7. The partition creation method of claim 1, wherein the creating a target partition based on a first storage capacity between each of the aligned sector locations to a next partition in each of the adjacent partitions and a preset partition capacity, comprises:
calculating the sum of the first storage capacities between the adjacent partitions to obtain a total storage capacity;
if the total storage capacity is smaller than the preset partition capacity, a target partition is created by taking the position of a target alignment sector after the last partition existing in the memory as a starting point and taking the difference value between the preset partition capacity and the total storage capacity as a storage capacity;
and if the total storage capacity is larger than or equal to the preset partition capacity, selecting the preset partition capacity from the total storage capacity to create a target partition.
8. A partition creation apparatus, comprising:
the alignment sector determining module is used for traversing all existing partitions in the memory, calculating an alignment area of the last sector in the current partition based on a sector number of the last sector in the current partition, a sector capacity and an alignment parameter of the memory, and calculating an alignment sector position between the current partition and the next partition based on the alignment area of the last sector in the current partition, the alignment parameter of the memory, an alignment offset and the sector capacity;
A first capacity determination module configured to determine a first storage capacity between the aligned sector location to a next partition in each of adjacent partitions, each of the adjacent partitions including a current partition and a next partition;
a partition establishing module, configured to create a target partition based on a first storage capacity between each aligned sector position and a next partition in each adjacent partition and a preset partition capacity.
9. A storage medium having stored thereon a computer program, which when executed by a processor performs the steps of the method according to any of claims 1 to 7.
10. A computer device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the steps of the method according to any one of claims 1-7.
CN202110553721.5A 2021-05-20 2021-05-20 Partition creation method, partition creation device, storage medium and computer equipment Active CN113282237B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110553721.5A CN113282237B (en) 2021-05-20 2021-05-20 Partition creation method, partition creation device, storage medium and computer equipment
PCT/CN2022/088499 WO2022242419A1 (en) 2021-05-20 2022-04-22 Partition creation method and apparatus, and storage medium and computer device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110553721.5A CN113282237B (en) 2021-05-20 2021-05-20 Partition creation method, partition creation device, storage medium and computer equipment

Publications (2)

Publication Number Publication Date
CN113282237A CN113282237A (en) 2021-08-20
CN113282237B true CN113282237B (en) 2023-08-18

Family

ID=77280500

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110553721.5A Active CN113282237B (en) 2021-05-20 2021-05-20 Partition creation method, partition creation device, storage medium and computer equipment

Country Status (2)

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

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282237B (en) * 2021-05-20 2023-08-18 RealMe重庆移动通信有限公司 Partition creation method, partition creation device, storage medium and computer equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1494681A (en) * 2000-10-27 2004-05-05 �ֹ��� Partition creating method and deleting method
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
CN105224253A (en) * 2015-09-29 2016-01-06 浪潮电子信息产业股份有限公司 A kind of method of solid state hard disc performance optimization
CN107403637A (en) * 2016-05-20 2017-11-28 慧荣科技股份有限公司 Data page alignment method of data storage device and method for making lookup table thereof
US10002001B1 (en) * 2013-02-19 2018-06-19 Amazon Technologies, Inc. Importing a virtual disk image into a compute service environment
CN110245119A (en) * 2018-11-02 2019-09-17 浙江大华技术股份有限公司 A kind of file consolidation method and storage system

Family Cites Families (6)

* 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
US10621044B2 (en) * 2012-04-25 2020-04-14 Pure Storage, Inc. Mapping slice groupings in a dispersed storage network
JP2015082166A (en) * 2013-10-22 2015-04-27 ルネサスエレクトロニクス株式会社 Method for managing data storage flash memory and program therefor
US10203902B2 (en) * 2013-12-13 2019-02-12 Netapp, Inc. Techniques for dynamically aligning a partition with a block size boundary
US10048865B2 (en) * 2014-10-24 2018-08-14 Microsoft Technology Licensing, Llc Disk partition stitching and rebalancing using a partition table
CN113282237B (en) * 2021-05-20 2023-08-18 RealMe重庆移动通信有限公司 Partition creation method, partition creation device, storage medium and computer equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1494681A (en) * 2000-10-27 2004-05-05 �ֹ��� Partition creating method and deleting method
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
US10002001B1 (en) * 2013-02-19 2018-06-19 Amazon Technologies, Inc. Importing a virtual disk image into a compute service environment
CN105224253A (en) * 2015-09-29 2016-01-06 浪潮电子信息产业股份有限公司 A kind of method of solid state hard disc performance optimization
CN107403637A (en) * 2016-05-20 2017-11-28 慧荣科技股份有限公司 Data page alignment method of data storage device and method for making lookup table thereof
CN110245119A (en) * 2018-11-02 2019-09-17 浙江大华技术股份有限公司 A kind of file consolidation method and storage system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
4K对齐的实现与应用;刘俊杰;《信息技术与信息化》;20140715(第07期);全文 *

Also Published As

Publication number Publication date
WO2022242419A1 (en) 2022-11-24
CN113282237A (en) 2021-08-20

Similar Documents

Publication Publication Date Title
CN107889070B (en) Picture processing method, device, terminal and computer readable storage medium
CN111459586B (en) Remote assistance method, device, storage medium and terminal
CN111124668B (en) Memory release method, memory release device, storage medium and terminal
CN113282237B (en) Partition creation method, partition creation device, storage medium and computer equipment
CN112116212A (en) Application evaluation method and device, storage medium and electronic equipment
CN114186527A (en) Method and device for realizing automatic wiring of integrated circuit independent of grid point
CN110782272A (en) Advertisement display method and device for application program
CN117555459A (en) Application group processing method and device, storage medium and electronic equipment
CN114118403A (en) Neural network architecture searching method, device, storage medium and electronic equipment
CN111913614B (en) Multi-picture display control method and device, storage medium and display
CN107562324A (en) The method and terminal of data display control
CN110702346B (en) Vibration testing method and device, storage medium and terminal
CN110730300A (en) Camera control method, device, storage medium and terminal
CN113825022B (en) Method and device for detecting play control state, storage medium and electronic equipment
CN112995562A (en) Camera calling method and device, storage medium and terminal
CN111857480B (en) Icon alignment method and device, storage medium and electronic equipment
CN114186526A (en) Automatic punching method and device for integrated circuit based on R tree MBR algorithm
CN113286349B (en) Personal hot spot connection method, device, terminal and storage medium
CN113268414A (en) Distribution method and device of experimental versions, storage medium and computer equipment
CN113268221A (en) File matching method and device, storage medium and computer equipment
CN110221892B (en) Method, device, medium and electronic equipment for scrolling window information
CN113490028A (en) Video processing method, device, storage medium and terminal
CN112612633A (en) Inter-process communication method, device, storage medium and terminal
CN113972989A (en) Data verification method and device, storage medium and electronic equipment
CN113098859B (en) Webpage page rollback method, device, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant