A batch file access permission asynchronous processing method, device, equipment and medium

CN116467055BActive Publication Date: 2026-10-20JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310348042.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2026-10-20
Estimated Expiration
2043-03-30

AI Technical Summary

Technical Problem

对于企业环境百万或千万级别的子目录和子文件,整个设置过程作为一个串行处理的流程,总体处理结果相对缓慢

Benefits of technology

[0035]由此可见,本申请公开了一种批量文件访问权限异步处理方法,应用于客户端,包括:当接收到批量文件访问权限设置操作请求时,根据线程的当前线程资源将所述批量文件访问权限设置操作请求添加至对应线程的任务队列中;启动用于处理异步文件访问权限设置操作请求应答的目标定时器;监听所述目标定时器,当接收到所述目标定时器发送的表征异步挂起应答状态码时,对当前文件访问权限设置操作请求进行处理,并发送下一文件访问权限设置操作请求的设置指令;基于所述设置指令从所述任务队列中获取下一访问权限设置操作请求并处理,重新跳转执行监听所述目标定时器步骤,直至所述批量文件访问权限设置操作请求设置完成。可见,通过将各个文件访问权限设置操作请求设置过程划分到一组不同的异步任务队列中,并提前对客户端发出一个任务请求正在处理的异步应答,保证客户端可以接着发出下一个文件访问权限设置操作请求设置过程。整个过程将单个文件的平均处理时间从毫秒级降低至微妙级,保证了批量文件访问权限设置速度有着数十倍至上百倍的提升。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116467055B_ABST
    Figure CN116467055B_ABST
Patent Text Reader

Abstract

The application discloses a batch file access permission asynchronous processing method and device, equipment and medium, and relates to the technical field of file asynchronous setting, which comprises the following steps: when a batch file access permission setting operation request is received, the batch file access permission setting operation request is added to the task queue of the corresponding thread according to the current thread resource of the thread; a target timer for processing asynchronous file access permission setting operation request response is started; the target timer is listened to, when a code representing an asynchronous suspension response state sent by the target timer is received, the current file access permission setting operation request is processed, and a setting instruction of the next file access permission setting operation request is sent; the next access permission setting operation request is obtained from the task queue based on the setting instruction and processed, and the step of listening to the target timer is re-executed until the batch file access permission setting operation request is set, so that the processing time of each file access permission request is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of asynchronous file setting technology, and in particular to a method, apparatus, device, and medium for asynchronous processing of batch file access permissions. Background Technology

[0002] The SMB (Server Message Block) protocol includes a set of interfaces for operating the NTFS file system, with main functions including file data reading and writing, and file attribute setting. File ACL (Access Control List) information is a type of file attribute and is also supported in the SMB protocol. When an ACL is set for a file on a Windows SMB network drive, the entire ACL information is encapsulated in a separate SMB message packet and sent to the SMB server. Setting an ACL for a single file is relatively simple, involving opening the file, retrieving ACL information, modifying ACL information, and closing the file. Setting ACLs for multiple files is more complex, requiring recursive traversal of subdirectories and setting each ACL individually. In a Linux environment, the SMB ACL setting process is a sequential process by default; the client can only issue the ACL setting command for the next file after the ACL for one file is set and a response is sent to the client. For enterprise environments with millions or tens of millions of subdirectories and files, the entire setting process, as a sequential flow, is relatively slow overall.

[0003] In summary, how to achieve rapid processing of batch file access permission requests, reduce the processing time of each file access permission request, and improve the speed of setting batch file access permission requests are technical problems that need to be solved in this field. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for asynchronous processing of batch file access permissions, which can realize the rapid processing of batch file access permission requests, reduce the processing time of each file access permission request, and improve the setting speed of batch file access permission requests. The specific solution is as follows:

[0005] Firstly, this application discloses a batch file access permission asynchronous processing method, applied to a client, including:

[0006] When a batch file access permission setting operation request is received, the batch file access permission setting operation request is added to the task queue of the corresponding thread according to the current thread resources of the thread;

[0007] Start the target timer for handling asynchronous file access permission setting operation request responses;

[0008] Listen to the target timer; when a status code indicating asynchronous suspension is received from the target timer, process the current file access permission setting operation request and send the setting instruction for the next file access permission setting operation request.

[0009] Based on the setting instruction, the next access permission setting operation request is obtained from the task queue and processed. The process then jumps back to the step of listening to the target timer until the batch file access permission setting operation request is completed.

[0010] Optionally, adding the batch file access permission setting operation request to the task queue of the corresponding thread based on the current thread resources includes:

[0011] Determine if there are any idle thread tasks;

[0012] If there are no idle thread tasks and the current number of threads equals the preset threshold, then the batch file access permission setting operation request is added to the task queue of the target thread with the fewest current requests, and the target thread's target semaphore is triggered;

[0013] If there are no idle thread tasks and the current number of threads is less than a preset threshold, a new thread is created, and the batch file access permission setting operation request is added to the new task queue of the new thread, and then the new semaphore of the new thread is triggered.

[0014] Optionally, the batch file access permission asynchronous processing method further includes:

[0015] The waiting time of the target semaphore or the new semaphore is detected. If the waiting time is greater than the preset waiting time and the task queue is empty, the corresponding thread to be destroyed is destroyed and the thread resources of the thread to be destroyed are reclaimed.

[0016] Optionally, when the target timer is monitored and a status code indicating asynchronous suspension is received from the target timer, the request for setting the current file access permissions is processed, including:

[0017] When the target timer sends an asynchronous suspension response status code, the file access setting operation request is extracted from the task queue, and the NTFS format security descriptor data structure of the file access permission data is parsed.

[0018] The security descriptor data structure is sequentially disassembled and extracted to obtain file access permission list items in different formats.

[0019] Optionally, after processing the request to set access permissions for the current file, the method further includes:

[0020] The processing result generated by the current file access permission setting operation request is written to a preset read / write channel via an asynchronous thread, so that the processing result can be sent to the main thread.

[0021] Optionally, the step of retrieving and processing the next access permission setting operation request from the task queue based on the setting instruction includes:

[0022] A semaphore operation instruction is triggered and issued so that after the asynchronous thread receives the semaphore operation instruction, it triggers a separate asynchronous thread to execute the instruction to obtain the next access permission setting operation request from the task queue and process it.

[0023] Optionally, the batch file access permission asynchronous processing method further includes:

[0024] If the asynchronous thread executes the current file access permission setting operation request, then wait for the asynchronous thread to complete the processing of the current file access permission setting operation request.

[0025] The corresponding processing result is sent to the main thread so that the main thread can enter the service process exit process.

[0026] Secondly, this application discloses a batch file access permission asynchronous processing device, applied to a client, comprising:

[0027] The request add module is used to add the batch file access permission setting operation request to the task queue of the corresponding thread according to the current thread resources when a batch file access permission setting operation request is received.

[0028] The timer startup module is used to start the target timer for handling asynchronous file access permission setting operation request responses;

[0029] An asynchronous processing module is used to monitor the target timer. When it receives an asynchronous suspension response status code sent by the target timer, it processes the current file access permission setting operation request and sends the setting instruction for the next file access permission setting operation request.

[0030] The request processing module is used to obtain the next access permission setting operation request from the task queue based on the setting instruction and process it, and then jump back to the step of listening to the target timer until the batch file access permission setting operation request is completed.

[0031] Thirdly, this application discloses an electronic device, comprising:

[0032] Memory, used to store computer programs;

[0033] A processor is configured to execute the computer program to implement the steps of the aforementioned disclosed asynchronous batch file access permission processing method.

[0034] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed asynchronous processing method for batch file access permissions.

[0035] Therefore, this application discloses a batch file access permission asynchronous processing method applied to a client, comprising: when a batch file access permission setting operation request is received, adding the batch file access permission setting operation request to the task queue of the corresponding thread according to the current thread resources; starting a target timer for processing asynchronous file access permission setting operation request responses; listening to the target timer, and when receiving an asynchronous suspension response status code sent by the target timer, processing the current file access permission setting operation request and sending a setting instruction for the next file access permission setting operation request; obtaining the next access permission setting operation request from the task queue based on the setting instruction and processing it, and then re-jumping to execute the step of listening to the target timer until the batch file access permission setting operation request is set. It is evident that by dividing the setting process of each file access permission setting operation request into a different asynchronous task queue, and sending an asynchronous response indicating that a task request is being processed to the client in advance, it is ensured that the client can then send the next file access permission setting operation request. The entire process reduces the average processing time of a single file from milliseconds to microseconds, ensuring a speed improvement of tens to hundreds of times for batch file access permission setting. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0037] Figure 1 This is a flowchart of a batch file access permission asynchronous processing method disclosed in this application;

[0038] Figure 2 This application discloses a specific flowchart of an asynchronous batch file access permission processing method.

[0039] Figure 3 This is a schematic diagram of the structure of an asynchronous processing device for batch file access permissions disclosed in this application;

[0040] Figure 4 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0041] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0042] The SMB protocol includes a set of interfaces for operating the NTFS file system, with main functions including file data reading and writing, and file attribute setting. File ACL information is a type of file attribute and is also supported in the SMB protocol. When an ACL is set for a file on a Windows SMB network mapped drive, the entire ACL information is encapsulated in a separate SMB message packet and sent to the SMB server. Setting an ACL for a single file is relatively simple, involving opening the file, retrieving ACL information, modifying ACL information, and closing the file. Setting ACLs for batches of files is more complex, requiring recursive traversal of subdirectories and setting each ACL individually. In a Linux environment, the SMB ACL setting process is a serial process by default; the client can only issue the ACL setting command for the next file after the ACL setting for one file is completed and a response is sent to the client. For enterprise environments with millions or tens of millions of subdirectories and subfiles, the entire setting process, as a serial flow, is relatively slow overall.

[0043] To address this, this application provides an asynchronous processing scheme for batch file access permissions, which enables rapid processing of batch file access permission requests, reduces the processing time for each file access permission request, and improves the speed of setting batch file access permission requests.

[0044] Reference Figure 1 As shown, this embodiment of the invention discloses a batch file access permission asynchronous processing method, applied to a client, including:

[0045] Step S11: When a batch file access permission setting operation request is received, the batch file access permission setting operation request is added to the task queue of the corresponding thread according to the current thread resources of the thread.

[0046] In this embodiment, the SMB first initializes the asynchronous resource pool. Then, upon receiving an ACL request, it determines whether to start a new thread resource or use an existing one. After the thread resource completes its execution, it checks if there are any new tasks. If not, it enters a semaphore timeout state and exits. The asynchronous thread pool initialization defines the thread pool structure, including semaphores, mutexes, pipe objects, the maximum number of thread resources, and thread idle exit time. After the server receives and successfully authenticates a client connection request, it performs asynchronous thread pool initialization in the initialization process. This includes initializing the semaphore object (used by the main thread to notify asynchronous threads to execute tasks), the mutex object (used to control the main thread placing tasks in the task queue, and the asynchronous thread retrieving and executing tasks from the queue), and the pipe object (the main thread adds the pipe read object to the EPOLL event interface, and the asynchronous thread writes the execution result to the pipe write object). Other fixed constants are also initialized, such as the maximum number of thread resources (to control the maximum number of thread resources that can be created) and the thread idle exit time (to control the thread timeout exit time when the task queue is empty).

[0047] In this embodiment, it is determined whether there are any idle thread tasks. If there are no idle thread tasks and the current number of threads equals a preset threshold, the batch file access permission setting operation request is added to the task queue of the target thread with the fewest current requests, and the target semaphore of the target thread is triggered. If there are no idle thread tasks and the current number of threads is less than the preset threshold, a new thread is created, and the batch file access permission setting operation request is added to the new task queue of the new thread, and then the new semaphore of the new thread is triggered. It can be understood that when an SMB ACL setting operation request arrives, the main thread determines whether there are any idle thread tasks. If not, and the current number of threads is less than the maximum value, a new thread task is created. After the thread task is created, it will enter a semaphore waiting state by default. At this time, the main thread adds the SMB ACL setting as a separate operation task to the new task queue and triggers the semaphore of the corresponding thread. If the number of threads has reached the maximum, the main thread selects the thread resource with the fewest tasks, adds the task to its task queue, and triggers the semaphore of the corresponding thread. Specifically, when the main thread receives an ACL setting request, it executes an asynchronous task addition action. The main thread checks if there are any idle thread resources. If so, it adds the ACL setting request to the thread pool task queue and triggers a semaphore notification. Threads receiving the semaphore notification then execute the action. If not, it checks if the thread pool can create new thread resources. If so, it creates new thread resources and adds the task to the task queue of the newly created thread. If the number of thread resources has reached the set maximum, it selects the thread resource with the fewest tasks and appends the new ACL setting task to the end of the task queue. A single ACL setting task includes the following setting information: file handle (fd), file ACL tags such as autocorrelation and automatic inheritance, and various ACL list items. A single ACL list item includes user / group, permissions, and permission inheritance tags. It is evident that a dynamically expandable thread resource pool is used specifically to handle various ACL requests sent from clients.

[0048] In this embodiment, after the semaphore of the corresponding thread is triggered, the waiting time of the semaphore needs to be detected. Specifically, the waiting time of the target semaphore or the new semaphore is detected. If the waiting time is greater than a preset waiting time and the task queue is empty, the corresponding thread to be destroyed is destroyed and its thread resources are reclaimed. It can be understood that detecting the waiting time of the semaphore is also detecting whether the thread is being used. If the waiting time of the semaphore is too long, a specific judgment method is to set a waiting time threshold, for example, 30 microseconds, and determine whether the waiting time of the semaphore is greater than 30 microseconds. If the waiting time is greater than 30 microseconds and the thread's task queue is empty, indicating no specific task requests, it means that the thread has no task requests to process, and the thread is destroyed and its thread resources are reclaimed.

[0049] Step S12: Start the target timer for handling asynchronous file access permission setting operation request responses.

[0050] In this embodiment, after the main thread completes the addition of the ACL task, it starts a separate timer structure to handle asynchronous file access permission setting operation request and response activities. It can be understood that by providing a time threshold for this timer, it can be used to detect the relationship between the time consumption of a single asynchronous processing task and the time threshold.

[0051] Step S13: Listen to the target timer. When the target timer sends an asynchronous suspension response status code, process the current file access permission setting operation request and send the setting instruction for the next file access permission setting operation request.

[0052] In this embodiment, the target timer is monitored. If the time taken for a single asynchronous processing task exceeds a certain time threshold, an asynchronous suspension response needs to be sent to the client in advance. This indicates to the client that the current task is being processed asynchronously, and the client can then immediately send the next ACL setting command. Otherwise, the Windows client will wait for the asynchronous request to completely finish before processing the next task. Following the recommended values ​​of the SMB protocol, the timer's time threshold is set to 500µs. If the asynchronous task finishes processing within the time threshold, the timer is automatically destroyed. If the time threshold is reached and the asynchronous task has not finished processing, a message with the status code NT_STATUS_PENDING is sent to the client in advance, which is an asynchronous suspension response status code.

[0053] In this embodiment, when the asynchronous suspension response status code sent by the target timer is received, the file access setting operation request is extracted from the task queue, and the NTFS format security descriptor data structure of the file access permission data is parsed; the security descriptor data structure is then disassembled and extracted sequentially to obtain file access permission list items in different formats. Understandably, when the asynchronous thread receives a signal and obtains an ACL setting task, it executes the specific ACL processing actions. It retrieves an ACL setting task from the task queue, extracts the file handle, ACL flags, and various ACL list entries. Specifically, it parses the NTFS format security descriptor data structure of the ACL data, disassembles the ACL information in the security descriptor data structure, including user SID conversion, ACL flag extraction, and extraction of permission and inheritance bits for each ACL list entry. It then performs ACL list entry disassembly, splitting different ACL list entries into UNIX ACL formats based on inheritance types: Access ACL and Default ACL. Access ACL represents permissions effective on the current file or directory, while Default ACL represents permissions inherited when creating subfiles or directories. Specifically, to maintain compatibility with UNIX ACLs, the Windows client's NTFS ACL format is disassembled into the UNIX ACL format. It then determines the inheritance flag of the ACL list entry. If the inheritance flag applies to the current folder, it means the current permission needs to be effective on the current directory, and a copy of that permission is added to the Access ACL list. If the inheritance flag applies to subfolders and files, it is copied to the Default ACL. The ACL list is used to control the permissions that can be inherited by the next level directory; for the two sets of ACL information, namely AccessACL and DefaultACL, the file system interface layer API is called to set the parameters of the two sets of ACLs respectively.

[0054] In this embodiment, after receiving the NT_STATUS_PENDING message, the client automatically recognizes that the current task has entered a suspended processing flow and automatically issues the ACL setting action for the next file. By sending an asynchronous response indicating that a task is being processed in advance, the client is guaranteed to be able to continue issuing the next ACL setting procedure. The entire process reduces the average processing time for a single file from milliseconds to microseconds.

[0055] Step S14: Based on the setting instruction, retrieve the next access permission setting operation request from the task queue and process it, then jump back to the step of listening to the target timer until the batch file access permission setting operation request is completed.

[0056] In this embodiment, the next access permission setting operation request is obtained from the task queue based on the setting instruction, and the operation request is processed. Then, the process jumps back to the target timer step and performs batch ACL settings in sequence until all ACL settings are completed.

[0057] Therefore, this application discloses a batch file access permission asynchronous processing method applied to a client, comprising: when a batch file access permission setting operation request is received, adding the batch file access permission setting operation request to the task queue of the corresponding thread according to the current thread resources; starting a target timer for processing asynchronous file access permission setting operation request responses; listening to the target timer, and when receiving an asynchronous suspension response status code sent by the target timer, processing the current file access permission setting operation request and sending a setting instruction for the next file access permission setting operation request; obtaining the next access permission setting operation request from the task queue based on the setting instruction and processing it, and then re-jumping to execute the step of listening to the target timer until the batch file access permission setting operation request is set. It is evident that by dividing the setting process of each file access permission setting operation request into a different asynchronous task queue, and sending an asynchronous response indicating that a task request is being processed to the client in advance, it is ensured that the client can then send the next file access permission setting operation request. The entire process reduces the average processing time of a single file from milliseconds to microseconds, ensuring a speed improvement of tens to hundreds of times for batch file access permission setting.

[0058] Reference Figure 2 As shown, this embodiment of the invention discloses a specific method for asynchronous processing of batch file access permissions. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically:

[0059] Step S21: When a batch file access permission setting operation request is received, the batch file access permission setting operation request is added to the task queue of the corresponding thread according to the current thread resources of the thread.

[0060] Step S22: Start the target timer for handling asynchronous file access permission setting operation request responses.

[0061] Step S23: Listen to the target timer. When the target timer sends an asynchronous suspension response status code, process the current file access permission setting operation request and send the setting instruction for the next file access permission setting operation request.

[0062] For more detailed processing procedures in steps S21, S22, and S23, please refer to the aforementioned disclosed embodiments; they will not be repeated here.

[0063] Step S24: Write the processing result generated by processing the current file access permission setting operation request into a preset read / write channel through an asynchronous thread, so that the processing result can be sent to the main thread.

[0064] In this embodiment, the main thread needs to send the ACL setting task to the asynchronous thread, and the asynchronous thread needs to send a termination notice to the main thread after completing the task. Specifically, the asynchronous thread creates a read-write pipe from the main thread by default. When the asynchronous thread completes the task by calling the underlying file system interface, it encapsulates the file handle and execution result into a structure and sends it to the main thread. That is, after the ACL is set successfully, the asynchronous thread writes the processing result of the current ACL task into the pipe and feeds it back to the main thread.

[0065] Step S25: Trigger and issue a semaphore operation instruction so that after the asynchronous thread receives the semaphore operation instruction, it triggers a separate asynchronous thread to execute the instruction to obtain the next access permission setting operation request from the task queue and process it.

[0066] In this embodiment, after the current ACL action is completed, the asynchronous thread continuously retrieves the next ACL task from the task queue and executes it. If it is determined that there is no task to be executed in the current task queue, the asynchronous thread enters a semaphore timeout waiting state. When the set time is exceeded, it automatically exits. Specifically, when the main thread issues an asynchronous task request, it triggers a semaphore operation. When an asynchronous thread receives a semaphore notification from the main thread, it triggers the invocation of the asynchronous ACL task processing module, so that the asynchronous ACL task processing module can trigger a separate asynchronous thread to execute instructions to retrieve the next access permission setting operation request from the task queue and process it.

[0067] Step S26: Re-execute the step of listening to the target timer until the batch file access permission setting operation request is completed.

[0068] In this embodiment, to support asynchronous processing of batch ACLs, a separate asynchronous processing subsystem is designed on the Linux SMB server. This subsystem consists of a set of sub-threads that can be dynamically created and destroyed, used to concurrently process multiple ACL setting tasks. The asynchronous processing subsystem achieves the following objectives:

[0069] 1. Supports asynchronous processing of ACL configuration tasks;

[0070] 2. Supports early suspension and response when ACL tasks are processed asynchronously;

[0071] 3. Supports dynamic expansion and changes of asynchronous processing threads;

[0072] 4. Supports interactive processing between asynchronous threads and the main thread;

[0073] 5. Supports task cleanup when the service exits normally.

[0074] To achieve the above objectives, the asynchronous processing subsystem includes the following modules: an asynchronous thread pool management module, an asynchronous thread and main thread interaction module, an asynchronous ACL task processing module, and an asynchronous ACL task early response module. The asynchronous thread pool management module is used for thread pool initialization, dynamic expansion, and eventual destruction. After initialization, the thread pool has empty thread resources by default. As the number of tasks increases, the thread resources will dynamically expand. To prevent indefinite expansion, a maximum value is set during expansion. When the maximum value is reached, expansion stops, and tasks are appended to the task queue of existing threads. The asynchronous thread and main thread interaction module: The main thread needs to send ACL setting tasks to asynchronous threads, and asynchronous threads need to send a termination notification to the main thread after completing their tasks. The asynchronous ACL task processing module: This module serves as a common execution module for each individual asynchronous thread, used to execute specific ACL tasks. Asynchronous ACL Task Early Response Module: A separate timer structure. When the time taken for a single asynchronous processing task exceeds a certain time threshold, an asynchronous suspension response needs to be sent to the client in advance to indicate that the current task is being processed asynchronously. The client can then immediately send the next ACL setting command. Otherwise, the Windows client will wait for the asynchronous request to be completely completed before processing the next task. If the asynchronous task is completed within the time threshold, the timer is automatically destroyed.

[0075] The above describes the normal ACL processing flow. For handling exceptions in asynchronous ACLs, specific measures include processing when the service process exits. Specifically, this involves triggering the service process exit process. If the asynchronous thread is executing a request to set the current file access permissions, the process waits for the asynchronous thread to complete this request. The corresponding processing result is then sent to the main thread, allowing the main thread to enter the service process exit process. It's understandable that for process exit processing, when the process is actively disconnected by the client or server, the SMB service process will automatically enter an exit process. If the asynchronous thread is currently executing a task, the main thread needs to wait. Once the asynchronous thread has completed all its tasks, the main thread enters the subsequent exit process. Handling exceptions in asynchronous ACLs also includes handling ACL setting timeouts or other errors. Specifically, when an error occurs during ACL setting on the Linux side, the Linux error code needs to be converted to an appropriate NTFS error code and returned to the client.

[0076] Therefore, it can be seen that by using a separate asynchronous ACL processing subsystem to solve the problem of insufficient performance in batch ACL setting, the ACL task setting action is put into an asynchronous thread for execution. From the client's perspective, the action of a single ACL setting task is compressed to an average of 500us. This can bring significant performance improvement to scenarios such as inherited permission changes or client recursive traversal of ACL setting process, thus making it more conducive to large-scale file permission changes in enterprise environments.

[0077] Reference Figure 3 As shown, this embodiment of the invention discloses a batch file access permission asynchronous processing device, applied to a client, comprising:

[0078] The request addition module 11 is used to add the batch file access permission setting operation request to the task queue of the corresponding thread according to the current thread resources of the thread when a batch file access permission setting operation request is received.

[0079] Timer startup module 12 is used to start a target timer for handling asynchronous file access permission setting operation request responses;

[0080] The asynchronous processing module 13 is used to monitor the target timer. When it receives the asynchronous suspension response status code sent by the target timer, it processes the current file access permission setting operation request and sends the setting instruction for the next file access permission setting operation request.

[0081] Request processing module 14 is used to obtain the next access permission setting operation request from the task queue based on the setting instruction and process it, and then jump back to the target timer listening step until the batch file access permission setting operation request is completed.

[0082] Therefore, this application discloses a method for handling batch file access permission setting requests. Upon receiving such requests, the method adds the requests to the corresponding thread's task queue based on the thread's current thread resources. It then starts a target timer to process asynchronous file access permission setting request responses. The method monitors the target timer, and upon receiving a status code indicating asynchronous suspension, processes the current file access permission setting request and sends a setting instruction for the next request. Based on the setting instruction, it retrieves the next access permission setting request from the task queue, processes it, and then jumps back to the target timer monitoring step until the batch file access permission setting requests are completed. By dividing the setting process of each file access permission setting request into a different asynchronous task queue and sending an asynchronous response indicating that a task request is being processed to the client in advance, the client can be guaranteed to send the next file access permission setting request. This process reduces the average processing time for a single file from milliseconds to microseconds, ensuring a speed improvement of tens to hundreds of times for batch file access permission setting.

[0083] In some specific embodiments, the request adding module 11 may specifically include:

[0084] The request addition unit is used to determine whether there are idle thread tasks. If there are no idle thread tasks and the current number of threads is equal to a preset threshold, the batch file access permission setting operation request is added to the task queue of the target thread with the fewest current requests, and the target semaphore of the target thread is triggered. If there are no idle thread tasks and the current number of threads is less than the preset threshold, a new thread is created, and the batch file access permission setting operation request is added to the new task queue of the new thread, and then the new semaphore of the new thread is triggered.

[0085] In some specific embodiments, the batch file access permission asynchronous processing device may specifically include:

[0086] The thread destruction unit is used to detect the waiting time of the target semaphore or the new semaphore. If the waiting time is greater than the preset waiting time and the task queue is empty, the corresponding thread to be destroyed is destroyed and the thread resources of the thread to be destroyed are reclaimed.

[0087] In some specific embodiments, the asynchronous processing module 13 may specifically include:

[0088] The list item acquisition unit is used to extract the file access setting operation request from the task queue when it receives the asynchronous suspension response status code sent by the target timer, and parse the NTFS format security descriptor data structure of the file access permission data; and sequentially perform decomposition and extraction operations on the security descriptor data structure to obtain file access permission list items in different formats.

[0089] In some specific embodiments, the batch file access permission asynchronous processing device may specifically include:

[0090] The result sending unit is used to write the processing result generated by processing the current file access permission setting operation request into a preset read / write channel through an asynchronous thread, so as to send the processing result to the main thread.

[0091] In some specific embodiments, the request processing module 14 may specifically include:

[0092] The request processing unit is used to trigger and issue a semaphore operation instruction, so that after the asynchronous thread receives the semaphore operation instruction, it triggers a separate asynchronous thread to execute the instruction to obtain the next access permission setting operation request from the task queue and process it.

[0093] In some specific embodiments, the batch file access permission asynchronous processing device may specifically include:

[0094] If the asynchronous thread executes a request to set the current file access permissions, the process will wait for the asynchronous thread to complete the processing of the request. The corresponding processing result will then be sent to the main thread so that the main thread can enter the service process exit process.

[0095] Furthermore, embodiments of this application also disclose an electronic device, Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0096] Figure 4 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the asynchronous batch file access permission processing method disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0097] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0098] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0099] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0100] The operating system 221 manages and controls the various hardware devices and computer programs 222 on the electronic device 20 to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. The operating system 221 can be Windows Server, Netware, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the batch file access permission asynchronous processing method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.

[0101] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned asynchronous processing method for batch file access permissions. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0102] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0103] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can implement the described functions using different methods for each specific application, but such implementation should not be considered beyond the scope of this application. The steps of the methods or algorithms described in connection with the embodiments disclosed herein can be implemented directly in hardware, software modules executed by a processor, or a combination of both. Software modules can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the art.

[0104] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0105] The present invention has provided a detailed description of a batch file access permission asynchronous processing method, apparatus, device, and medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for asynchronous processing of batch file access permissions, characterized in that, Applied to the client side, including: When a batch file access permission setting operation request is received, the batch file access permission setting operation request is added to the task queue of the corresponding thread according to the current thread resources of the thread; Start the target timer for handling asynchronous file access permission setting operation request responses; Listen to the target timer; when a status code indicating asynchronous suspension is received from the target timer, process the current file access permission setting operation request and send the setting instruction for the next file access permission setting operation request. Based on the setting instruction, the next access permission setting operation request is obtained from the task queue and processed. The process then jumps back to the step of listening to the target timer until the batch file access permission setting operation request is completed. When the system monitors the target timer and receives an asynchronous suspension response status code from the target timer, it processes the current file access permission setting operation request and sends a setting instruction for the next file access permission setting operation request, including: When the target timer is detected to have reached a preset time threshold and the current file access permission setting operation request has not been processed, an asynchronous suspension response status code is generated and sent to the client. After receiving the asynchronous suspension response status code, the client determines that the current file access permission setting operation request has entered the suspension processing flow, so that the client can send the setting instruction for the next file access permission setting operation request. When the system monitors the target timer and receives an asynchronous suspension response status code from the target timer, it processes the current file access permission setting operation request, including: When the asynchronous suspension response status code sent by the target timer is received, the file access setting operation request is extracted from the task queue, and the NTFS format security descriptor data structure of the file access permission data is parsed. The security descriptor data structure is sequentially disassembled and extracted to obtain file access permission list items in different formats.

2. The batch file access permission asynchronous processing method according to claim 1, characterized in that, The step of adding the batch file access permission setting operation request to the task queue of the corresponding thread based on the current thread resources includes: Determine if there are any idle thread tasks; If there are no idle thread tasks and the current number of threads equals the preset threshold, then the batch file access permission setting operation request is added to the task queue of the target thread with the fewest current requests, and the target thread's target semaphore is triggered. If there are no idle thread tasks and the current number of threads is less than a preset threshold, a new thread is created, and the batch file access permission setting operation request is added to the new task queue of the new thread, and then the new semaphore of the new thread is triggered.

3. The batch file access permission asynchronous processing method according to claim 2, characterized in that, Also includes: The waiting time of the target semaphore or the new semaphore is detected. If the waiting time is greater than the preset waiting time and the task queue is empty, the corresponding thread to be destroyed is destroyed and the thread resources of the thread to be destroyed are reclaimed.

4. The batch file access permission asynchronous processing method according to claim 1, characterized in that, After processing the request to set access permissions for the current file, the process also includes: The processing result generated by the current file access permission setting operation request is written to a preset read / write channel through an asynchronous thread, so that the processing result can be sent to the main thread.

5. The batch file access permission asynchronous processing method according to claim 4, characterized in that, The step of retrieving and processing the next access permission setting operation request from the task queue based on the setting instruction includes: A semaphore operation instruction is triggered and issued so that after the asynchronous thread receives the semaphore operation instruction, it triggers a separate asynchronous thread to execute the instruction to obtain the next access permission setting operation request from the task queue and process it.

6. The batch file access permission asynchronous processing method according to any one of claims 1 to 5, characterized in that, Also includes: If the asynchronous thread executes the current file access permission setting operation request, then wait for the asynchronous thread to complete the processing of the current file access permission setting operation request. The corresponding processing result is sent to the main thread so that the main thread can enter the service process exit process.

7. A batch file access permission asynchronous processing device, characterized in that, Applied to the client side, including: The request add module is used to add the batch file access permission setting operation request to the task queue of the corresponding thread according to the current thread resources when a batch file access permission setting operation request is received. The timer startup module is used to start the target timer for handling asynchronous file access permission setting operation request responses; An asynchronous processing module is used to monitor the target timer. When it receives an asynchronous suspension response status code sent by the target timer, it processes the current file access permission setting operation request and sends the setting instruction for the next file access permission setting operation request. The request processing module is used to obtain the next access permission setting operation request from the task queue based on the setting instruction and process it, and then jump back to the step of listening to the target timer until the batch file access permission setting operation request is completed; The asynchronous processing module is specifically used to generate an asynchronous suspension response status code and send it to the client when it detects that the target timer has reached a preset time threshold and the current file access permission setting operation request has not been processed. After receiving the asynchronous suspension response status code, the client determines that the current file access permission setting operation request has entered the suspension processing flow so that the client can send the setting instruction for the next file access permission setting operation request. The list item acquisition unit is used to extract the file access setting operation request from the task queue when it receives the asynchronous suspension response status code sent by the target timer, and parse the NTFS format security descriptor data structure of the file access permission data; and sequentially perform decomposition and extraction operations on the security descriptor data structure to obtain file access permission list items in different formats.

8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the asynchronous processing method for batch file access permissions as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the steps of the asynchronous processing method for batch file access permissions as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method, system and device for client to access file system and storage medium

    CN107704328A

  • Parallel download method for digital subscriber line nest plate initialization

    CN1633117A