Movatterモバイル変換


[0]ホーム

URL:


CN112346663A - Multi-partition rotation data writing and clearing method and system - Google Patents

Multi-partition rotation data writing and clearing method and system
Download PDF

Info

Publication number
CN112346663A
CN112346663ACN202011352910.8ACN202011352910ACN112346663ACN 112346663 ACN112346663 ACN 112346663ACN 202011352910 ACN202011352910 ACN 202011352910ACN 112346663 ACN112346663 ACN 112346663A
Authority
CN
China
Prior art keywords
partition
data
current
main
written
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011352910.8A
Other languages
Chinese (zh)
Other versions
CN112346663B (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.)
Shanghai Netis Technologies Co ltd
Original Assignee
Shanghai Netis Technologies 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 Shanghai Netis Technologies Co ltdfiledCriticalShanghai Netis Technologies Co ltd
Priority to CN202011352910.8ApriorityCriticalpatent/CN112346663B/en
Publication of CN112346663ApublicationCriticalpatent/CN112346663A/en
Application grantedgrantedCritical
Publication of CN112346663BpublicationCriticalpatent/CN112346663B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

The invention provides a data writing and clearing method and a system for multi-partition rotation, which comprises the following steps: preparing a main partition, and mounting the main partition to a first directory; mounting all partitions of the disk to a second directory respectively; selecting a partition in which data is written last as a current partition, and selecting a preset partition as the current partition by a disk started for the first time; detecting the usage amount of the current partition; judging whether the usage amount is larger than a preset threshold value or not, if so, entering a first operation step, and if not, entering a second operation step; a first operation step: formatting and re-mounting a next partition of the current partition to be used as a new current partition; a second operation step: and linking the data needing to be written from the main partition to the current partition in a file soft connection or directory soft connection mode, and redirecting the real position of the written data from the main partition to the current partition. The invention can greatly reduce the disk load caused by deleting the old data.

Description

Multi-partition rotation data writing and clearing method and system
Technical Field
The invention relates to the technical field of data storage, in particular to a multi-partition rotation data writing and clearing method and system.
Background
In many program systems, a large amount of new data needs to be written to disk, while a large amount of old data needs to be deleted in the disk file system. Repeated data write and delete operations can result in fragmentation of the file system, which can result in reduced write performance and increased latency of the disk. In a relatively real-time system, it is also impossible to defragment a file system having a large number of read and write disk requests.
The existing solutions are as follows:
1) and (4) performing partition arrangement at the time of a low flow (such as a non-working period). Obviously, the method has limited application scenes and low system efficiency. Meanwhile, if the partition arrangement time is too long, the normal working time period is influenced.
2) File systems are allocated in advance, and the writing and fragmentation of files are managed by themselves. Obviously, the method has high development cost and poor compatibility. Meanwhile, various optimization mechanisms of OS and RAID card hardware cannot be utilized, and sequential reading and writing and randomness cannot be well processed simultaneously.
Patent document CN103474087A discloses a management method and device for simply preventing disk fragments from generating video files, which formats and fixes the disk in a video recorder to one or several partitions, and uses different formatting methods provided by the operating system for different file systems; establishing a video file index database and providing a video file retrieval service; fixing the size of the video file, and recording as A (Byte); when the disk is not full, adopting a general file creating and writing mode; and after the disk is fully written, finding out the file with the oldest creation time on the disk, taking the file as a new video file, overwriting the file from the initial position of the file, and repeating the steps. The scheme needs to fix the size of the video file, needs an additional video file index database, adopts a mode of repeatedly using the old file to prevent file fragments, and is complex in implementation mode.
Disclosure of Invention
In view of the defects in the prior art, the present invention provides a method and a system for writing and clearing data in a multi-partition rotation.
The invention provides a data writing and clearing method for multi-partition rotation, which comprises the following steps:
main partition preparation: preparing a main partition, and mounting the main partition to a first directory;
a partition preparation step: mounting all partitions of the disk to a second directory respectively;
current partition selection: selecting a partition in which data is written last as a current partition, and selecting a preset partition as the current partition by a disk started for the first time;
and (3) usage amount detection: detecting the usage amount of the current partition;
and (3) judging the dosage: judging whether the usage amount is larger than a preset threshold value or not, if so, entering a first operation step, and if not, entering a second operation step;
a first operation step: formatting and re-mounting a next partition of the current partition to be used as a new current partition;
a second operation step: and linking the data needing to be written from the main partition to the current partition in a file soft connection or directory soft connection mode, and redirecting the real position of the written data from the main partition to the current partition.
Preferably, the main partition is on the same disk as the partition, or on a different disk.
Preferably, after the first operating step or the second operating step is performed, the method further includes performing:
CPU abandoning step: and giving up the CPU preset time, and returning to the usage detection step.
Preferably, the first operating step comprises:
unloading the next partition of the current partition, formatting and then re-mounting;
the next partition of the current partition is designated as the new current partition.
Preferably, the second operating step comprises:
calculating the file name or directory name of data to be written;
linking data needing to be written from a main partition to a current partition in a file soft connection or directory soft connection mode;
the real location of the written data is redirected by the main partition to the current partition.
The invention provides a multi-partition rotating data writing and clearing system, which comprises:
a main partition preparation module: preparing a main partition, and mounting the main partition to a first directory;
a partition preparation module: mounting all partitions of the disk to a second directory respectively;
a current partition selection module: selecting a partition in which data is written last as a current partition, and selecting a preset partition as the current partition by a disk started for the first time;
a usage detection module: detecting the usage amount of the current partition;
a dosage judgment module: judging whether the usage amount is larger than a preset threshold value or not, if so, entering a first operation module, and if not, entering a second operation module;
a first operation module: formatting and re-mounting a next partition of the current partition to be used as a new current partition;
a second operation module: and linking the data needing to be written from the main partition to the current partition in a file soft connection or directory soft connection mode, and redirecting the real position of the written data from the main partition to the current partition.
Preferably, the main partition is on the same disk as the partition, or on a different disk.
Preferably, after executing the first operation module or the second operation module, the method further includes executing:
a CPU abandon module: and giving up the CPU preset time, and returning to the usage detection module.
Preferably, the first operating module includes:
unloading the next partition of the current partition, formatting and then re-mounting;
the next partition of the current partition is designated as the new current partition.
Preferably, the second operation module includes:
calculating the file name or directory name of data to be written;
linking data needing to be written from a main partition to a current partition in a file soft connection or directory soft connection mode;
the real location of the written data is redirected by the main partition to the current partition.
Compared with the prior art, the invention has the following beneficial effects:
1) the invention can greatly reduce the disk load caused by deleting the old data.
2) The invention solves the problems of reduced read-write performance and increased delay of the disk caused by fragmentation of the file system.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments with reference to the following drawings:
FIG. 1 is a flow chart of the operation of the present invention.
Detailed Description
The present invention will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the invention, but are not intended to limit the invention in any way. It should be noted that it would be obvious to those skilled in the art that various changes and modifications can be made without departing from the spirit of the invention. All falling within the scope of the present invention.
The invention provides a scheme of multi-partition rotation, and old data is cleaned in a formatted partition mode, so that the disk load caused by deleting the old data is greatly reduced, and the problems of reduced disk read-write performance and increased delay caused by fragmentation of a file system are solved. The small partitions are divided and stored on a large whole disk, so that the number of partition inodes can be reduced, and the IO retrieval speed of the file can be increased.
Referring to fig. 1, the data writing and clearing method for multi-partition rotation includes the following steps:
step 1: a main partition (which may or may not be on the same physical disk as the "n disk partitions" described in step 2) is prepared in advance. The main partition is the destination file system to which the external program was originally prepared to write files. Suppose the main partition is mounted to/main/path by mount.
Step 2: n disk partitions with the numbers of 1- > n are divided on a disk in advance, and the n partition mount is placed in a pre-designated directory during starting. Such as/dev/sdb 1,/dev/sdb2 …/dev/sdbn mount to/mnt/dir 1,/mnt/dir2 …/mnt/dirn, respectively; (the main partition may be on the disk or may be another disk).
And step 3: and selecting the disk partition written last time the program is exited last time as the current partition. If started for the first time, partition 1 may be selected as the current partition.
And 4, step 4: and detecting the disk usage amount of the current partition.
And 5: and judging whether the disk usage is larger than or equal to a specified threshold (such as 80%), if so, executing the step 6, otherwise, executing the step 7.
Step 6: executing the operation that the usage of the disk is more than or equal to a specified threshold; after the execution is finished, step 8 is executed.
And 7: executing the operation that the usage of the disk is less than a specified threshold; after the execution is finished, step 8 is executed.
And 8: the program gives up the CPU for several seconds, waits for the next detection operation, and returns to step 4.
Wherein, the step 6 comprises the following steps:
step 6.1: and unloading the next partition of the current partition from the system umount, and mounting the mount again after formatting.
Step 6.2: the next partition of the current partition is designated as the new current partition.
The step 7 comprises the following steps:
step 7.1: and calculating the file name required to be written by the next external program or the directory name required to be written into the path. This step requires that the file names or directory names of the next set of files to be written by the external program are predictable, typically in a video recording system that performs file segmentation according to a fixed time length;
step 7.2: and linking the next batch of files to be written from the main partition to the current partition in a file soft link or directory soft link mode. Assuming that the external program writes the file directory split by hours, i.e. writes/main/path/2019072013, then the/main/path/2019072013 directory is linked to/mnt/dirx/2019072013 in a soft link manner;
step 7.3: the external program writes the actual write disk location of the file, which is redirected to the current partition by the main partition. I.e., from the main partition where/main/path/2019072013 is located, to the/dev/sdbx partition where/mnt/dirx/2019072013 is located.
Those skilled in the art will appreciate that, in addition to implementing the system and its various devices, modules, units provided by the present invention as pure computer readable program code, the system and its various devices, modules, units provided by the present invention can be fully implemented by logically programming method steps in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Therefore, the system and various devices, modules and units thereof provided by the invention can be regarded as a hardware component, and the devices, modules and units included in the system for realizing various functions can also be regarded as structures in the hardware component; means, modules, units for performing the various functions may also be regarded as structures within both software modules and hardware components for performing the method.
In the description of the present application, it is to be understood that the terms "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like indicate orientations or positional relationships based on those shown in the drawings, and are only for convenience in describing the present application and simplifying the description, but do not indicate or imply that the referred device or element must have a specific orientation, be constructed in a specific orientation, and be operated, and thus, should not be construed as limiting the present application.
The foregoing description of specific embodiments of the present invention has been presented. It is to be understood that the present invention is not limited to the specific embodiments described above, and that various changes or modifications may be made by one skilled in the art within the scope of the appended claims without departing from the spirit of the invention. The embodiments and features of the embodiments of the present application may be combined with each other arbitrarily without conflict.

Claims (10)

CN202011352910.8A2020-11-262020-11-26Multi-partition rotation data writing and clearing method and systemActiveCN112346663B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202011352910.8ACN112346663B (en)2020-11-262020-11-26Multi-partition rotation data writing and clearing method and system

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202011352910.8ACN112346663B (en)2020-11-262020-11-26Multi-partition rotation data writing and clearing method and system

Publications (2)

Publication NumberPublication Date
CN112346663Atrue CN112346663A (en)2021-02-09
CN112346663B CN112346663B (en)2022-10-11

Family

ID=74364892

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202011352910.8AActiveCN112346663B (en)2020-11-262020-11-26Multi-partition rotation data writing and clearing method and system

Country Status (1)

CountryLink
CN (1)CN112346663B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115407940A (en)*2022-08-252022-11-29福建天晴在线互动科技有限公司 Method and system for cleaning and optimizing disk files
CN116010160A (en)*2023-03-092023-04-25安超云软件有限公司Method for distributing erasure code data of distributed file system and application thereof

Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20030115438A1 (en)*2001-12-192003-06-19Mallik MahalingamObject-level migration in a partition-based distributed file system
CN101403987A (en)*2008-11-132009-04-08上海第二工业大学Method for one-key backup and PC software system recovery
CN102331953A (en)*2011-09-282012-01-25奇智软件(北京)有限公司 Method and device for repairing disk partition failure
CN103474087A (en)*2013-09-062013-12-25南京南自信息技术有限公司Video recording file management method and device for easily preventing disk fragments from being generated
CN105117177A (en)*2015-09-142015-12-02许昌许继软件技术有限公司Big data management method based on single-hard-disk multi-partition mode
CN105701162A (en)*2015-12-302016-06-22青岛海信移动通信技术股份有限公司User data partition management method of intelligent terminal and intelligent terminal
US20170212680A1 (en)*2016-01-222017-07-27Suraj Prabhakar WAGHULDEAdaptive prefix tree based order partitioned data storage system
CN110333887A (en)*2019-07-042019-10-15郑州天迈科技股份有限公司Vehicle-mounted machine picture recording module upgrades optimization system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20030115438A1 (en)*2001-12-192003-06-19Mallik MahalingamObject-level migration in a partition-based distributed file system
CN101403987A (en)*2008-11-132009-04-08上海第二工业大学Method for one-key backup and PC software system recovery
CN102331953A (en)*2011-09-282012-01-25奇智软件(北京)有限公司 Method and device for repairing disk partition failure
CN103474087A (en)*2013-09-062013-12-25南京南自信息技术有限公司Video recording file management method and device for easily preventing disk fragments from being generated
CN105117177A (en)*2015-09-142015-12-02许昌许继软件技术有限公司Big data management method based on single-hard-disk multi-partition mode
CN105701162A (en)*2015-12-302016-06-22青岛海信移动通信技术股份有限公司User data partition management method of intelligent terminal and intelligent terminal
US20170212680A1 (en)*2016-01-222017-07-27Suraj Prabhakar WAGHULDEAdaptive prefix tree based order partitioned data storage system
CN110333887A (en)*2019-07-042019-10-15郑州天迈科技股份有限公司Vehicle-mounted machine picture recording module upgrades optimization system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘洋洋: "硬盘数据恢复技术探究", 《技术研究》*

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115407940A (en)*2022-08-252022-11-29福建天晴在线互动科技有限公司 Method and system for cleaning and optimizing disk files
CN116010160A (en)*2023-03-092023-04-25安超云软件有限公司Method for distributing erasure code data of distributed file system and application thereof

Also Published As

Publication numberPublication date
CN112346663B (en)2022-10-11

Similar Documents

PublicationPublication DateTitle
US6691136B2 (en)Fast data retrieval based upon contiguous consolidation of records according to frequency of access
US8738845B2 (en)Transaction-safe fat file system improvements
US8856469B2 (en)Apparatus and method for logging optimization using non-volatile memory
US6823417B2 (en)Memory controller for memory card manages file allocation table
US9336095B2 (en)Computing system and related data management method thereof
US9069673B2 (en)Memory system configured to perform segment cleaning and related method of operation
CA2549917C (en)File system storing transaction records in a storage media
CN100565530C (en) A kind of snapshot system and using method thereof
US8667029B2 (en)Optimized startup verification of file system integrity
US7240172B2 (en)Snapshot by deferred propagation
US8914579B2 (en)Access device, information recording device, controller, and information recording system
CN108628542B (en) A file merging method and controller
US20040117567A1 (en)System and method for efficient write operations for repeated snapshots by copying-on-write to most recent snapshot
CN112463753B (en)Block chain data storage method, system, equipment and readable storage medium
US11630595B2 (en)Methods and systems of efficiently storing data
CN112346663B (en)Multi-partition rotation data writing and clearing method and system
CN114138200B (en)Method and system for pre-writing log based on RocksDB
CN112882859A (en)Virtual machine synthetic backup method and system
CN116257460B (en)Trim command processing method based on solid state disk and solid state disk
US20090094299A1 (en)Apparatus and method for defragmenting files on a hydrid hard disk
US20140095771A1 (en)Host device, computing system and method for flushing a cache
US11366609B2 (en)Technique for encoding deferred reference count increments and decrements
TWI792534B (en)Method of performing garbage collection with partial clean operation and related controller and storage system
US6510499B1 (en)Method, apparatus, and article of manufacture for providing access to data stored in compressed files
CN111522512B (en)Optimized cold and hot data separation method, device, computer equipment and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp