CN113934699A - File state determination method and device, storage medium and equipment - Google Patents

File state determination method and device, storage medium and equipment Download PDF

Info

Publication number
CN113934699A
CN113934699A CN202010676744.0A CN202010676744A CN113934699A CN 113934699 A CN113934699 A CN 113934699A CN 202010676744 A CN202010676744 A CN 202010676744A CN 113934699 A CN113934699 A CN 113934699A
Authority
CN
China
Prior art keywords
file
target file
lease
determining
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010676744.0A
Other languages
Chinese (zh)
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010676744.0A priority Critical patent/CN113934699A/en
Publication of CN113934699A publication Critical patent/CN113934699A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/176Support for shared access to files; File sharing support
    • G06F16/1767Concurrency control, e.g. optimistic or pessimistic approaches
    • G06F16/1774Locking methods, e.g. locking methods for file systems allowing shared and concurrent access to files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/122File system administration, e.g. details of archiving or snapshots using management policies

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the disclosure discloses a file state determination method, a file state determination device, a storage medium and equipment. The method comprises the following steps: and if the result of the attempt is that the acquisition is successful, determining that the current state of the target file is not operated. By adopting the technical scheme, when the current state of the file needs to be determined, the process or the thread of the application program does not need to acquire the file lock, but directly determines the current state of the file by trying to acquire the lease trial result of the file, and does not need to lock the file when the file needs to be used, so that the system resource is saved.

Description

File state determination method and device, storage medium and equipment
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a file state determination method, a file state determination device, a storage medium and a file state determination device.
Background
In the current software development process, if an application needs to determine the file state in a certain process during running, for example, whether a file is being used by other processes or threads is determined, a file lock-based scheme is generally adopted.
The file lock-based scheme requires a file user to explicitly call a lock (lock) method to construct a file lock (FileLock) at each place where a file is used (e.g., read, write, open, delete, etc.), and call a release (release) method to release the file lock after the file is used. When the application program needs to determine the file state, the application program tries to acquire the file lock, if the file lock is acquired, the file state is indicated to be unoccupied, otherwise, the file state is indicated to be occupied. This solution has the following problems that if the file user does not actively lock, the application program may obtain an erroneous result when determining the file state, and if no other process or thread needs to determine the file state, the locking operation of the file user may become meaningless and resources may be wasted, so that the current file state determination solution needs to be improved.
Disclosure of Invention
The embodiment of the disclosure provides a file state determination method, a file state determination device, a storage medium and a device, which can optimize the existing file state determination scheme.
In a first aspect, an embodiment of the present disclosure provides a file state determination method, including:
detecting that a state determination event of a target file is triggered;
attempting to obtain a lease for the target document;
and if the attempt result is that the acquisition is successful, determining that the current state of the target file is not operated.
In a second aspect, an embodiment of the present disclosure provides a file state determining apparatus, including:
the state determination event detection module is used for detecting whether a state determination event of the target file is triggered or not;
the system comprises a lease acquisition attempting module, a lease acquisition module and a lease acquisition module, wherein the lease acquisition attempting module is used for attempting to acquire a lease of a target file when a state determining event of the target file is triggered;
and the file state determining module is used for determining that the current state of the target file is not operated when the acquisition is successful as a result of the attempt.
In a third aspect, the present disclosure provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the file state determination method provided by the embodiments of the present disclosure.
In a fourth aspect, an embodiment of the present disclosure provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the file state determination method provided in the embodiment of the present disclosure when executing the computer program.
According to the file state determining scheme provided by the embodiment of the disclosure, a state determining event of the target file is triggered when the state determining event is detected, a lease of the target file is tried to be acquired, and if the trying result is successful, the current state of the target file is determined to be not operated. By adopting the technical scheme, when the current state of the file needs to be determined, the process or the thread of the application program does not need to acquire the file lock, but directly determines the current state of the file by trying to acquire the trial result of the lease of the file, and does not need to lock the file when the file needs to be used, so that the system resource is saved.
Drawings
Fig. 1 is a schematic flowchart of a file state determination method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of another file state determination method according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a file operating process provided by an embodiment of the present disclosure;
fig. 4 is a block diagram of a file status determining apparatus according to an embodiment of the present disclosure;
fig. 5 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
In the following embodiments, optional features and examples are provided in each embodiment, and various features described in the embodiments may be combined to form a plurality of alternatives, and each numbered embodiment should not be regarded as only one technical solution.
Fig. 1 is a flowchart illustrating a file state determination method according to an embodiment of the present disclosure, where the method may be performed by a file state determination apparatus, where the apparatus may be implemented by software and/or hardware, and may be generally integrated in an electronic device. The electronic device may be, for example, a mobile phone, a tablet computer, a notebook computer, other computer devices, and the like. As shown in fig. 1, the method includes:
step 101, detecting that a state determination event of a target file is triggered.
By way of example, the target file may be any file in the electronic device, and is not limited in particular. For example, the file may be a video cache file generated in the shooting process, a temporary file generated in the downloading process, a video file uploaded in the video uploading process, and the like. For a target file, there may be two or more processes or threads that have file manipulation requirements for the target file at the same time. File operations herein may include, for example, read, write, open, modify, or delete, etc.
Optionally, whether the state determination event of the target file is triggered may be determined by detecting whether a preset file operation requirement for the target file exists. Illustratively, this step may include: when a preset file operation requirement for a target file is detected, determining that a state determination event of the target file is triggered. The preset file operation requirements may include, for example, a write operation requirement, a modify operation requirement, and a delete operation requirement, which all change the target file, and therefore, based on factors such as ensuring integrity of the file and system security, it is necessary to determine a file state first and then determine whether to perform a file operation on the target file. For the read operation requirement or the operation requirement for opening the file stream, the read operation requirement or the operation requirement for opening the file stream may also be a preset file operation requirement, because if the target file is being operated by other processes or threads, the target file may also be changed, and the read or opened target file may be inaccurate at this time, and after the file state is determined, whether to perform a file read operation or an opening operation on the target file may be determined.
Step 102, attempting to obtain a lease for a target document.
For example, a lease mechanism exists in a file system of an operating system such as Linux, and is used for file system management, where the file system may include, for example, a Fourth-generation Extended file system (EXT 4), EXT3, and the like. For example, the operating system loaded in the electronic device in the embodiment of the present disclosure may be a Linux system, and may also be a Linux-based system. For example, the kernel of the Android operating system is implemented based on Linux, and the adopted file system is EXT4 system of Linux, so that a lease mechanism also exists. In the lease mechanism, when a certain file is operated, the file system marks the state of acquiring a lease in a region of a file header, the marking process is usually implemented in a kernel (kernel) layer, and at this time, if another process attempts to acquire a lease, the process fails. In the embodiment of the present disclosure, the existing lease mechanism in the operating system may be utilized to achieve the purpose of determining the state of the file, and therefore, after detecting that the state determination event of the target file is triggered, an attempt is made to acquire the lease of the target file.
And 103, if the acquisition is successful, determining that the current state of the target file is not operated.
For example, if the result of the attempt is that the obtaining is successful, that is, the lease of the target file can be obtained, it is stated that the file system does not give the lease to other processes or threads, that is, there is no other process or thread currently operating on the target file, and therefore, it is determined that the current state of the target file is not operated.
According to the file state determining method provided by the embodiment of the disclosure, a state determining event of the target file is triggered when the state determining event is detected, a lease of the target file is tried to be acquired, and if the trying result is successful, the current state of the target file is determined to be not operated. By adopting the technical scheme, when the current state of the file needs to be determined, the process or the thread of the application program does not need to acquire the file lock, but directly determines the current state of the file by trying to acquire the trial result of the lease of the file, and does not need to lock the file when the file needs to be used, so that the system resource is saved. In the existing scheme based on the file lock, a party using the file can be understood as a production end, a party needing to determine the file state can be understood as a consumption end, the production end needs to actively lock the file when operating the file, the production end needs to acquire the file lock before the file is required to be operated, namely, the production end and the consumption end are both operated, and if the production end forgets to actively lock the file or forgets to release the file lock after being used, the consumption end cannot acquire the accurate file state; the scheme in the embodiment of the disclosure is equivalent to that the production end has no additional file locking operation, and only when the production end is used as a consumption end, an attempt to acquire a lease of a file is needed, that is, a file user does not need to care about whether the file can judge a use state in other processes or threads, and can judge whether the file is occupied in the use place in a unilateral way, the file system defaults that a lease state is added to the file being used (accessed), logic for judging the lease is added in the use place, if the judgment is not needed, no work needs to be done, the scheme is not perceived by the file user, only a module for judging the file state needs to process, and the file state can be accurately acquired without adding any service logic code, so that unnecessary operations are reduced, and system resources are saved.
In some embodiments, after the determining that the current state of the target file is not operated, further comprising: and carrying out file operation on the target file, and releasing the acquired lease after the file operation is finished. The method has the advantages that after the target file is determined not to be operated by other processes or threads, the file operation can be carried out on the target file, and the lease can be released in time after the operation is finished, so that the use of the target file by other processes or threads is prevented from being influenced. The releasing of the obtained lease may specifically be notifying the file system to delete the marked lease status corresponding to the target file.
In some embodiments, the method further comprises: and if the attempt result is that the acquisition fails, determining that the current state of the target file is in operation. Upon determining that the current state of the target file is being operated upon, the file operation on the target file may be aborted. This has the advantage that if the target file has been marked with a lease status, indicating that the target file is being used by another process or thread, the current status needs to be determined to be in operation. If lease acquisition fails due to other reasons, such as system errors, etc., it can be shown that the current target file may also have problems, and if forced operation is performed, the current state of the target file may be determined as being operated against the problems of operation failure of the target file or influence on system stability, etc., so that the target file is not operated, the integrity and correctness of the target file are ensured, and the system stability is ensured.
In some embodiments, after the determining that the current state of the target file is in operation, further comprising: and after waiting for a preset time, retrying to acquire the lease of the target file. This has the advantage that after a period of time, the lease for the target file may have been released, and the target file may be operated by reattempting to acquire the lease. The preset duration may be set according to an actual situation, and may be a fixed value or a dynamically changing value, for example, 5 seconds. Alternatively, the lease for the target file may be retried multiple times. For example, after the determining that the current state of the target file is in operation, the method includes: and acquiring the current retry number, if the current retry number is smaller than a preset number threshold, acquiring a target preset time corresponding to the current retry number, and after waiting for the target preset time, retrying to acquire the lease of the target file. Optionally, the larger the current retry number is, the smaller the corresponding target preset duration is, and preset durations corresponding to different retry numbers may be preset. The setting has the advantages that the waiting time can be continuously shortened, and the file operation efficiency is improved.
In some embodiments, the attempting to obtain the lease of the target file comprises: and if the lease identification in the file header of the target file is read through a preset interface, the attempt to acquire the lease of the target file fails. The advantage of this is that it is possible to accurately determine whether an attempt is successful. The preset Interface may be a Java Native Interface (JNI), and if the lease identifier in the header of the target file (added by the file system) can be read through the JNI, the file system may be considered to have given the lease of the target file to other processes or threads, and the obtaining of the lease fails. Optionally, if the lease identifier in the file header of the target file is not read through the preset interface, the attempt to acquire the lease of the target file is successful.
Fig. 2 is a schematic flowchart of another file state determination method provided by an embodiment of the present disclosure, which is optimized based on various alternatives in the foregoing embodiments, and the method may be applied to an electronic device, and the electronic device may be loaded with a Linux-based operating system, for example, an android operating system.
Specifically, the method comprises the following steps:
step 201, when a preset file operation requirement for a target file is detected, determining that a state determination event for detecting the target file is triggered.
For example, the preset file operation requirement may include a read operation requirement, a write operation requirement, an open file stream operation requirement, a modify operation requirement, or a delete operation requirement.
Step 202, judging whether a lease mark in a file header of a target file can be read through a preset interface, if so, executing step 203; otherwise, step 205 is performed.
The preset interface may be a JNI interface, for example.
Step 203, determining that the lease is not successfully acquired and the current state of the target file is in operation.
Step 204, waiting for a preset time length, and returning to execute the step 202.
Step 205, determining that the lease is successfully acquired and the current state of the target file is not operated.
And step 206, performing file operation on the target file, and releasing the acquired lease after the file operation is finished.
Illustratively, the file operation herein corresponds to the file operation requirement described above. After the file operation is finished, the file system can be informed to delete the lease identification in the file header of the target file.
According to the file state determining method provided by the embodiment of the disclosure, when a process or thread in an electronic device has a preset file operation requirement for a target file, whether a lease identifier in a file header of the target file can be read through a preset interface can be judged, if the lease identifier can be read, it is indicated that other processes or threads are operating on the target file, retry can be performed after waiting for a preset time, if the lease identifier cannot be read, it is indicated that no other processes or threads are operating on the target file, file operation can be performed on the target file, and the lease is released after the operation is completed. Therefore, the file state can be accurately acquired, unnecessary operations can be reduced, and system resources are saved.
Fig. 3 is a schematic view of a file operation process provided by the embodiment of the present disclosure, and as shown in fig. 3, it is assumed that two processes exist, which are respectively denoted as process 1 and process 2, and process 1 and process 2 may belong to one application program or may belong to different application programs. File 1, file 2, and file 3 are being operated on in process 1 (read, write, and open streams, respectively), and there is also a need for process 2 to operate on these files (read, write, and delete, respectively). If the operation of the process 2 is deleting or writing (that is, the preset file operation requirement is a deleting operation requirement or a writing operation requirement), the lease state of the file needs to be judged, if no other process occupies the lease (that is, the lease identification cannot be read), the file can be safely deleted or written, otherwise, the file can be damaged, or the process 1 is abnormal. If the operation of the process 2 is reading, the lease state of the file can be judged, and if no other process occupies the lease state, the reading operation can be carried out; the read operation may also be performed directly without determining the lease status of the file, but the accuracy of the read operation may not be guaranteed at this time.
Taking the example that the process 1 and the process 2 belong to different applications, it is assumed that the process 1 is an uploading video process in a social application, and the process 2 is a space cleaning process in a housekeeping application. When the process 1 uploads the video (file reading operation), the process 2 cannot acquire the lease of the video file, and the process 2 is not allowed to clear the video file which is not uploaded (file deleting operation), so that mistaken deletion or misoperation can be prevented.
Fig. 4 is a block diagram of a file state determination apparatus according to a fourth embodiment of the present disclosure, where the apparatus may be implemented by software and/or hardware, and may be generally integrated in an electronic device, and may perform file state determination by executing a file state determination method. As shown in fig. 4, the apparatus includes:
a state determination event detection module 401, configured to detect whether a state determination event of the target file is triggered;
a lease acquisition attempting module 402, configured to attempt to acquire a lease of a target file when it is detected that a status determining event of the target file is triggered;
a file status determining module 403, configured to determine that the current status of the target file is not operated when the acquisition is successful as a result of the attempt.
The file state determining device provided in the embodiment of the present disclosure detects that a state determining event of a target file is triggered, attempts to acquire a lease of the target file, and determines that a current state of the target file is not operated if an attempt result is successful. By adopting the technical scheme, when the current state of the file needs to be determined, the application program does not need to acquire the file lock, but directly and accurately determines the current state of the file by trying to acquire the lease trial result of the file, and does not need to lock the file when the file needs to be used, so that the system resource is saved.
Optionally, the apparatus further comprises:
and the file operation module is used for performing file operation on the target file after the current state of the target file is determined to be not operated, and releasing the acquired lease after the file operation is finished.
Optionally, the file state determination module is further configured to: and if the attempt result is that the acquisition fails, determining that the current state of the target file is in operation.
Optionally, the lease acquisition attempting module is further configured to, after determining that the current state of the target file is in operation and waiting for a preset time period, reattempt to acquire the lease of the target file.
Optionally, the detecting that the state determination event of the target file is triggered includes:
when a preset file operation requirement for a target file is detected, determining that a state determination event of the target file is triggered.
Optionally, the attempting to obtain the lease of the target file includes:
and if the lease identification in the file header of the target file is read through a preset interface, the attempt to acquire the lease of the target file fails.
Optionally, the apparatus is integrated in an electronic device loaded with a Linux-based operating system. .
Referring now to FIG. 5, a block diagram of an electronic device 500 suitable for use in implementing embodiments of the present disclosure is shown. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 5, electronic device 500 may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the electronic apparatus 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage devices 508 including, for example, magnetic tape, hard disk, etc.; and a communication device 509. The communication means 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 illustrates an electronic device 500 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or installed from the storage means 508, or installed from the ROM 502. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 501.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: detecting that a state determination event of a target file is triggered; attempting to obtain a lease for the target document; and if the attempt result is that the acquisition is successful, determining that the current state of the target file is not operated.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. The name of the module does not constitute a limitation to the module itself in some cases, for example, the file status determination module may also be described as "determining the current status of the target file as an unoperated module when the acquisition is successful as a result of the attempt".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a file state determination method including:
detecting that a state determination event of a target file is triggered;
attempting to obtain a lease for the target document;
and if the attempt result is that the acquisition is successful, determining that the current state of the target file is not operated.
Further, after the determining that the current state of the target file is not operated, the method further includes:
and carrying out file operation on the target file, and releasing the acquired lease after the file operation is finished.
Further, the method also comprises the following steps:
and if the attempt result is that the acquisition fails, determining that the current state of the target file is in operation.
Further, after the determining that the current state of the target file is in operation, the method further includes:
and after waiting for a preset time, retrying to acquire the lease of the target file.
Further, the detecting that the state determination event of the target file is triggered includes:
when a preset file operation requirement for a target file is detected, determining that a state determination event of the target file is triggered.
Further, the attempting to obtain the lease of the target file comprises:
and if the lease identification in the file header of the target file is read through a preset interface, the attempt to acquire the lease of the target file fails.
Further, the method is applied to the electronic equipment loaded with the Linux-based operating system.
According to one or more embodiments of the present disclosure, there is provided a file state determination apparatus including:
the state determination event detection module is used for detecting whether a state determination event of the target file is triggered or not;
the system comprises a lease acquisition attempting module, a lease acquisition module and a lease acquisition module, wherein the lease acquisition attempting module is used for attempting to acquire a lease of a target file when a state determining event of the target file is triggered;
and the file state determining module is used for determining that the current state of the target file is not operated when the acquisition is successful as a result of the attempt.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (10)

1. A method for determining a file status, comprising:
detecting that a state determination event of a target file is triggered;
attempting to obtain a lease for the target document;
and if the attempt result is that the acquisition is successful, determining that the current state of the target file is not operated.
2. The method of claim 1, after said determining that the current state of the target file is not operated, further comprising:
and carrying out file operation on the target file, and releasing the acquired lease after the file operation is finished.
3. The method of claim 1, further comprising:
and if the attempt result is that the acquisition fails, determining that the current state of the target file is in operation.
4. The method of claim 3, further comprising, after said determining that the current state of the target file is operational:
and after waiting for a preset time, retrying to acquire the lease of the target file.
5. The method of claim 1, wherein the detecting that the state determination event of the target file is triggered comprises:
when a preset file operation requirement for a target file is detected, determining that a state determination event of the target file is triggered.
6. The method of claim 1, wherein attempting to obtain the lease for the target file comprises:
and if the lease identification in the file header of the target file is read through a preset interface, the attempt to acquire the lease of the target file fails.
7. The method according to claim 1, applied to an electronic device loaded with a Linux-based operating system.
8. A file status determination apparatus, comprising:
the state determination event detection module is used for detecting whether a state determination event of the target file is triggered or not;
the system comprises a lease acquisition attempting module, a lease acquisition module and a lease acquisition module, wherein the lease acquisition attempting module is used for attempting to acquire a lease of a target file when a state determining event of the target file is triggered;
and the file state determining module is used for determining that the current state of the target file is not operated when the acquisition is successful as a result of the attempt.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-7 when executing the computer program.
CN202010676744.0A 2020-07-14 2020-07-14 File state determination method and device, storage medium and equipment Pending CN113934699A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010676744.0A CN113934699A (en) 2020-07-14 2020-07-14 File state determination method and device, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010676744.0A CN113934699A (en) 2020-07-14 2020-07-14 File state determination method and device, storage medium and equipment

Publications (1)

Publication Number Publication Date
CN113934699A true CN113934699A (en) 2022-01-14

Family

ID=79273738

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010676744.0A Pending CN113934699A (en) 2020-07-14 2020-07-14 File state determination method and device, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN113934699A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766055A (en) * 2017-09-29 2018-03-06 郑州云海信息技术有限公司 A kind of client linux system installation method based on GUI module
CN110928841A (en) * 2019-11-27 2020-03-27 深信服科技股份有限公司 File operation control method, device, equipment and storage medium
CN111324573A (en) * 2020-02-13 2020-06-23 苏州浪潮智能科技有限公司 Network file system state management method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766055A (en) * 2017-09-29 2018-03-06 郑州云海信息技术有限公司 A kind of client linux system installation method based on GUI module
CN110928841A (en) * 2019-11-27 2020-03-27 深信服科技股份有限公司 File operation control method, device, equipment and storage medium
CN111324573A (en) * 2020-02-13 2020-06-23 苏州浪潮智能科技有限公司 Network file system state management method and system

Similar Documents

Publication Publication Date Title
CN111897740B (en) User interface testing method and device, electronic equipment and computer readable medium
CN111555940B (en) Client test method and device, electronic equipment and computer readable storage medium
CN110688353A (en) File management method, device and computer readable medium
CN111198777A (en) Data processing method, device, terminal and storage medium
CN111611145A (en) Breakdown information collection method and device, storage medium and electronic equipment
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN111813465B (en) Information acquisition method, device, medium and equipment
CN111625422B (en) Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium
CN112965761A (en) Data processing method, system, electronic equipment and storage medium
CN106484779B (en) File operation method and device
CN110674050B (en) Memory out-of-range detection method and device, electronic equipment and computer storage medium
CN113760503A (en) Task migration method and device, electronic equipment and computer readable medium
CN109408387B (en) Page testing method and device
CN113934699A (en) File state determination method and device, storage medium and equipment
CN112988549B (en) Method for obtaining log based on vehicle machine system and electronic equipment
CN111984496B (en) Method, device, medium and electronic equipment for monitoring stack memory leakage
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN113934692A (en) File cleaning method and device, storage medium and equipment
CN112306683A (en) Function hijacking method, device, medium and electronic equipment
CN111857915A (en) Application page display method and device
CN113760631A (en) Page loading duration determination method, device, equipment and storage medium
US9619306B2 (en) Information processing device, control method thereof, and recording medium
CN112181467A (en) Method and device for upgrading memory firmware of terminal, terminal and storage medium
CN111538577A (en) Program execution control device and method, terminal and storage medium
CN111782410B (en) Lock jam monitoring method and device, electronic equipment and computer readable 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