Method and device for non-aligned sequential writing of data in storage system

By implementing non-aligned sequential writing of data in the storage system, the problem of low writing efficiency when data storage is less than 4K in the prior art is solved, and a more efficient data writing operation is achieved.

CN120010751APending Publication Date: 2025-05-16BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311533667.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-16
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

In the prior art, the minimum index granularity of the storage area of ​​the data storage of a distributed system is 4K, which results in frequent reading and merging of data when storing data less than 4K, resulting in low data writing efficiency.

Method used

By implementing the method of non-aligned sequential writing of data in the storage system, the specific steps include: determining the data length and the starting write address of the data write request, determining the head sub-region and tail sub-region of the first data in the storage area, obtaining the second data in these sub-regions from the cache space, combining the first data and the second data into target data, and writing the target data into the storage area.

Benefits of technology

This method improves the writing efficiency of data, avoids frequent reading of data from the underlying storage area, and thus improves the overall performance of the storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120010751A_ABST
    Figure CN120010751A_ABST
Patent Text Reader

Abstract

The invention relates to a method and a device for non-aligned sequential writing of data of a storage system. The method comprises the steps that when a data writing request is received in a certain section of target space, the data length of first data requested to be written by the data writing request and an initial writing address corresponding to the data writing request in a storage area are determined; determining a head sub-region and a tail sub-region of the first data in the storage region according to the initial write-in address and the data length; obtaining second data stored in the head sub-region and the tail sub-region from a cache space allocated for the target space according to the first region identifier of the head sub-region and the second region identifier of the tail sub-region; and writing target data obtained by splicing and merging the first data and the second data into a target sub-region of the storage region. The technical problem of low data writing efficiency in storage is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a method and device for writing data in a non-aligned order in a storage system. Background Art

[0002] In the prior art, the minimum index granularity of the storage area for data storage in the distributed system is 4K, and in the storage, the data to be stored by the user includes data smaller than 4K. For the storage of data smaller than 4K, the prior art can adopt a method of first reading, then merging, and then writing. However, if this method is adopted, for each data to be written, the data in the first 4K storage area and the last 4K storage area to be occupied by the data must be read from the underlying storage area of ​​the storage, and then spliced ​​with the data to be written by the user. Since the data must be read from the underlying storage area each time the data is written, the data writing efficiency is low. Summary of the invention

[0003] The present application provides a method and device for non-aligned sequential writing of data in a storage system, so as to solve the technical problem of low efficiency of data writing in storage.

[0004] In a first aspect, the present application provides a method for non-aligned sequential writing of data in a storage system, comprising: upon receiving a data write request for a target space, determining the data length of the first data requested to be written by the data write request and the starting write address corresponding to the data write request in a storage area, wherein the storage area is an area for storing data provided by the storage system for the target space; determining a head sub-area and a tail sub-area of ​​the first data in the storage area according to the starting write address and the data length, wherein the storage area is composed of a plurality of sub-storage areas, each of which is the minimum unit of the index granularity of the storage area; obtaining the second data stored in the head sub-area and the tail sub-area from the cache space allocated for the target space according to the first area identifier of the head sub-area and the second area identifier of the tail sub-area; and writing the target data obtained by combining the first data and the second data into the target sub-area of ​​the storage area, wherein the target sub-area includes the head sub-area, the tail sub-area, and a sub-area between the head sub-area and the tail sub-area.

[0005] In a second aspect, the present application provides a device for non-aligned sequential writing of data in a storage system, comprising: a first determination module, for determining, upon receiving a data write request for a target space, the data length of the first data requested to be written by the data write request and the starting write address corresponding to the data write request in a storage area, wherein the storage area is an area for storing data provided by the storage system for the target space; a second determination module, for determining, based on the starting write address and the data length, a head sub-area and a tail sub-area of ​​the first data in the storage area, wherein the storage area is composed of a plurality of sub-storage areas, each of which is the minimum unit of the index granularity of the storage area; an acquisition module, for acquiring, from a cache space allocated to the target space, the second data stored in the head sub-area and the tail sub-area, based on a first area identifier of the head sub-area and a second area identifier of the tail sub-area; a writing module, for writing the target data obtained by combining the first data and the second data into a target sub-area of ​​the storage area, wherein the target sub-area includes the head sub-area, the tail sub-area, and a sub-area between the head sub-area and the tail sub-area.

[0006] As an optional example, the acquisition module includes: a search unit, used to search for the first area identifier and the second area identifier in the first cache space of the cache space, wherein the cache space includes the first cache space and the second cache space, the first cache space is used to cache the correspondence between the area identifier and the storage address, and the second cache space is used to cache the second data; when the first area identifier is found, the first storage address corresponding to the first area identifier in the first cache space is obtained, and the data corresponding to the first storage address in the second cache space is determined as the header data in the second data, wherein the second data consists of the header data and the tail data; when the second area identifier is found, the second storage address corresponding to the second area identifier in the first cache space is obtained, and the data corresponding to the second storage address in the second cache space is determined as the tail data in the second data.

[0007] As an optional example, the acquisition module further includes: an acquisition unit for acquiring the header data of the second data from the header sub-area of ​​the storage area when the first area identifier is not found in the first cache space; or acquiring the tail data of the second data from the tail sub-area of ​​the storage area when the second area identifier is not found in the first cache space.

[0008] As an optional example, the above-mentioned writing module includes: a splicing unit, used to splice the tail of the data before the above-mentioned starting write address in the header data of the above-mentioned second data with the header of the above-mentioned first data; splice the header of the data after the ending write address in the tail data of the above-mentioned second data with the tail of the above-mentioned first data, wherein the above-mentioned ending write address is determined according to the above-mentioned starting write address and the above-mentioned data length, and the above-mentioned second data consists of the above-mentioned header data and the above-mentioned tail data; determine the data obtained after splicing as the above-mentioned target data; and write the above-mentioned target data into the above-mentioned target sub-area.

[0009] As an optional example, the above-mentioned writing module includes: a writing unit, used to divide the above-mentioned target data into multiple copies of data from beginning to end according to the size of the sub-storage area; according to the order of each copy of the above-mentioned multiple copies of data and the order of multiple sub-storage areas of the above-mentioned target sub-area, write each copy of the data into a corresponding sub-storage area.

[0010] As an optional example, the above-mentioned device also includes: a storage unit, which is used to write the area identifier of the first sub-storage area where the above-mentioned target data is written and the area identifier of the last sub-storage area into the first cache space of the above-mentioned cache space after writing the above-mentioned target data into the above-mentioned target sub-area; write the data of the first sub-storage area where the above-mentioned target data is written and the data of the last sub-storage area into the second cache space of the above-mentioned cache space; and write the correspondence between the above-mentioned area identifier and the storage address of the above-mentioned data into the above-mentioned first cache space.

[0011] As an optional example, the second determination module includes: a determination unit, used to determine the sub-storage area where the starting write address is located as the head sub-area; and to determine the sub-storage area where the ending write address is located by adding the starting write address to the data length as the tail sub-area.

[0012] In a third aspect, the present application provides an electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the memory stores a computer program, and the processor is configured to implement any one of the methods for non-aligned sequential writing of data to the storage system when executing the computer program.

[0013] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the method for non-aligned sequential writing of data in the storage system of any one of the above items of the present application.

[0014] The above-mentioned technical scheme provided by the embodiment of the present application has the following advantages compared with the prior art: when the first data is to be written into the target space, the data length of the first data and the starting write address in the storage area are determined, and the head sub-area and the tail sub-area of ​​the above-mentioned first data in the storage area are determined according to the data length and the starting write address, and then the second data stored in the head sub-area and the tail sub-area are read from the cache space, and the second data is spliced ​​with the first data into target data, and the target data is written into the storage area, thereby eliminating the need to read the data in the first 4K storage area and the last 4K storage area to be occupied from the underlying storage area, thereby improving the data writing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0017] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0018] Figure 1 A flowchart of a method for non-aligned sequential writing of data in a storage system provided in an embodiment of the present application;

[0019] Figure 2 A schematic diagram of a storage area of ​​a method for writing data in a non-aligned order in a storage system provided by an embodiment of the present application;

[0020] Figure 3 A flowchart of another method for non-aligned sequential writing of data in a storage system provided by an embodiment of the present application;

[0021] Figure 4 A schematic diagram of a cache space of a method for writing data in a non-aligned order in a storage system provided by an embodiment of the present application;

[0022] Figure 5 A flowchart of a method for non-aligned sequential writing of data in a storage system provided in an embodiment of the present application;

[0023] Figure 6A schematic diagram of data splicing of a method for writing data in a non-aligned order in a storage system provided by an embodiment of the present application;

[0024] Figure 7 A flowchart of a method for non-aligned sequential writing of data in a storage system provided in an embodiment of the present application;

[0025] Figure 8 A system flow chart of a method for non-aligned sequential writing of data in a storage system provided in an embodiment of the present application;

[0026] Fig. 9 A schematic diagram of the structure of a device for writing data in a non-aligned order in a storage system provided by an embodiment of the present application;

[0027] Fig.10 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0029] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0030] In order to solve the technical problem of low data writing efficiency in storage in the prior art, the present application provides a method for non-aligned sequential writing of data in a storage system, which can achieve the effect of improving the efficiency of storing data writing.

[0031] Figure 1 A flowchart of a method for writing data in a non-aligned order in a storage system provided by an embodiment of the present application. Figure 1 As shown, the method for writing data in a non-aligned order in the storage system includes:

[0032] S102, when receiving a data write request to the target space, determining the data length of the first data requested to be written by the data write request and a starting write address corresponding to the data write request in a storage area, wherein the storage area is an area provided by the storage system for storing data for the target space;

[0033] S104, determining a head sub-region and a tail sub-region of the first data in the storage region according to the start write address and the data length, wherein the storage region is composed of a plurality of sub-storage regions, and each sub-storage region is a minimum unit of index granularity of the storage region;

[0034] S106, acquiring second data stored in the head sub-region and the tail sub-region from the cache space allocated for the target space according to the first region identifier of the head sub-region and the second region identifier of the tail sub-region;

[0035] S108, writing target data obtained by combining the first data and the second data into a target sub-region of the storage region, wherein the target sub-region includes a head sub-region, a tail sub-region, and a sub-region between the head sub-region and the tail sub-region.

[0036] In this embodiment, each logical volume requested by a user corresponds to a storage area, which can be an area opened for the logical volume requested by the user to store the data of the target space, and the data of logical volumes requested by different users are stored in different storage areas. If a target space wants to write data to the storage area, it can write through a data write request, which carries the starting write address and data length of the first data to be written in the storage area.

[0037] The storage area in this embodiment may be a storage area composed of multiple sub-storage areas, where the sub-storage area is the smallest unit that can be divided in index granularity, such as 4K, and each sub-storage area is 4K in size. 4K is an example, and other values ​​may also be set.

[0038] The region identifier of the storage area can be calculated by the formula. The region identifier of the tail storage area cur_tail_pageId = (offset + len) / PageSize, where offset is the starting write address, len is the data length, and PageSize is the minimum index granularity, which is 4K in the above embodiment. The head region identifier cur_head_pageId = offset / PageSize

[0039] In this embodiment, the sub-storage area where the starting write address is located can be determined as the head sub-area; the sub-storage area where the ending write address is located, which is obtained by adding the starting write address to the data length, is determined as the tail sub-area. Through the above-mentioned starting write address and data length, the ending write address of the first data in the storage area can be determined. The starting write address is located in a sub-storage area, which is the head sub-area, and the ending write address is located in another sub-storage area, which is the tail sub-area. The head sub-area and the tail sub-area can be the same sub-area, or they can be adjacent sub-areas, or there can be multiple sub-storage areas in between. For example, Figure 2 As shown, Figure 2 In the example, each 4K size is a sub-storage area, and the starting write address of 7K size data is in Figure 2 The first sub-storage area in the memory is the head sub-area, and the end write address of the 7K data is located in the third sub-storage area, which is the tail sub-area.

[0040] The second data is the data stored in the determined head sub-region and tail sub-region. In this embodiment, a cache space is allocated to the target space, and the data stored in the head sub-region and tail sub-region are also stored in the cache space. The data can be obtained from the cache space. The first data and the second data are combined to obtain the target data, that is, the first data and the second data are combined to obtain the target data.

[0041] The acquired second data and the first data are spliced ​​into target data, and the target data is written into a target sub-region in the storage region. If the head sub-region and the tail sub-region are the same sub-region, the target sub-region is the head sub-region or the tail sub-region. If the head sub-region and the tail sub-region are adjacent sub-regions, the target sub-region is the head sub-region + the tail sub-region. If there are other sub-storage regions between the head sub-region and the tail sub-region, the target sub-region is the head sub-region + other sub-regions + the tail sub-region.

[0042] In this embodiment, when the first data is to be written into the target space, the data length of the first data and the starting write address in the storage area are determined, and the head sub-area and the tail sub-area of ​​the first data in the storage area are determined according to the data length and the starting write address. Then, the second data stored in the head sub-area and the tail sub-area are read from the cache space, and the second data is concatenated with the first data into target data, and the target data is written into the storage area. Therefore, there is no need to read the data in the first 4K storage area and the last 4K storage area to be occupied from the underlying storage area, thereby improving the data writing efficiency.

[0043] As an alternative example, Figure 3 As shown, obtaining the second data stored in the head sub-region and the tail sub-region from the cache space allocated for the target space according to the first region identifier of the head sub-region and the second region identifier of the tail sub-region includes:

[0044] S302, searching for a first region identifier and a second region identifier in a first cache space of the cache space, wherein the cache space includes a first cache space and a second cache space, the first cache space is used to cache a correspondence between the region identifier and the storage address, and the second cache space is used to cache second data;

[0045] S304, when the first region identifier is found, obtaining a first storage address corresponding to the first region identifier in the first cache space, and determining data corresponding to the first storage address in the second cache space as header data in the second data, wherein the second data consists of header data and tail data;

[0046] S306, when the second region identifier is found, obtain a second storage address corresponding to the second region identifier in the first cache space, and determine the data corresponding to the second storage address in the second cache space as the tail data in the second data.

[0047] In this embodiment, the cache space includes a first cache space and a second cache space. The first cache space is used to store the correspondence between the region identifier and the storage address. The storage address is the location where data is stored in the second cache space. The second cache space is used to store data.

[0048] It is queried whether the first cache space includes the first region identifier and the second region identifier. If the first region identifier and the second region identifier are found, the corresponding first storage address and second storage address can be obtained, and the corresponding data can be obtained from the second cache space according to the first storage address and the second storage address.

[0049] For example, Figure 4 As shown, the region identifier is searched in the first cache space, the storage address is found according to the region identifier, and the corresponding data is searched from the second cache space through the storage address.

[0050] As an optional example, the above method also includes: when the first area identifier is not found in the first cache space, obtaining the header data of the second data from the head sub-area of ​​the storage area; or, when the second area identifier is not found in the first cache space, obtaining the tail data of the second data from the tail sub-area of ​​the storage area.

[0051] In this embodiment, if the first region identifier and the second region identifier are not found in the first cache space, it means that the first region identifier and the second region identifier are not stored in the cache space. At this time, the second data can be obtained from the head storage area and the tail storage area of ​​the underlying storage area, and then the second data can be stored in the second cache space, and the storage location of the second data in the second cache space is written to the first cache space, and an association relationship is established with the first region identifier and the second region identifier.

[0052] As an alternative example, Figure 5 As shown, writing the target data obtained by combining the first data and the second data into the target sub-area of ​​the storage area includes:

[0053] S502, splicing the tail of the data before the start writing address in the header data of the second data with the header of the first data;

[0054] S504, splicing the head of the data after the end write address in the tail data of the second data with the tail of the first data, wherein the end write address is determined according to the start write address and the data length, and the second data consists of the head data and the tail data;

[0055] S506, determining the data obtained after splicing as target data;

[0056] S508, writing the target data into the target sub-area.

[0057] In this embodiment, the header data of the second data includes data of 4K or less. In this part of data, the data before the start write address will be retained and spliced ​​with the header of the first data, while the data after the start write address will not be used, or will be discarded or shelved. In the tail data of the second data, the data after the end write address will be retained and spliced ​​with the tail of the first data, while the data before the end write address will not be used, or will be discarded or shelved. For example, Figure 6 As shown, 4K of the first sub-storage area and 4K of the second sub-storage area are filled with vertical lines, indicating that data is stored therein, and 4K of the third sub-storage area is filled with horizontal lines, indicating that data is stored therein (there is no difference between the horizontal and vertical lines, in order to distinguish them later). For 7K data, the starting position is at 3 / 4 of the first sub-storage area, then the 7K data is spliced ​​with the first 3 / 4 of the data in the first sub-storage area and with the last 1 / 2 of the data in the third sub-storage area to obtain the target data.

[0058] As an alternative example, Figure 7 As shown, writing target data to the target sub-area includes:

[0059] S702, dividing the target data into multiple pieces of data from beginning to end according to the size of the sub-storage area;

[0060] S704, writing each piece of data into a corresponding sub-storage area according to the sequence of each piece of data in the plurality of pieces of data and the sequence of the plurality of sub-storage areas in the target sub-area.

[0061] Continue to combine Figure 6 As shown in the figure, after splicing the 7K data with the first 3 / 4 data in the head sub-area and the last 1 / 2 data in the tail sub-area, 3*4=12K data is obtained. The 12K data is written into the head sub-area, the tail sub-area and the sub-area between them. Then, in the original storage area, the last 1 / 4 data of the first sub-storage area, all the data of the second sub-storage area and the last 1 / 2 data of the third sub-storage area are replaced by the 7K data.

[0062] As an optional example, after writing the target data to the target sub-area, the above method also includes: writing the area identifier of the first sub-storage area where the target data is written and the area identifier of the last sub-storage area into the first cache space of the cache space; writing the data of the first sub-storage area where the target data is written and the data of the last sub-storage area into the second cache space of the cache space; and writing the correspondence between the area identifier and the storage address of the data into the first cache space.

[0063] In this embodiment, after the target data is written to the target sub-area, the area identifiers of the first sub-storage area and the last sub-storage area in the target sub-area can be stored in the first cache space, and then the data stored in the first sub-storage area and the data stored in the last sub-storage area in the target data are written to the second cache space, as well as the association relationship between the cache data identifier in the first cache space and the data stored in the second cache space.

[0064] Figure 8It is a system flow chart of this embodiment. The present application creates a corresponding cache space for each user, and the cache space includes a first cache space and a second cache space. When a user requests to write a first input to the cloud storage service, the cloud storage service writes the data to the storage area in a non-aligned sequential write manner. When writing, first search the first cache space for the region identifier of the head storage area and the tail storage area where the data to be written is located. If the region identifier can be found (complete hit), the storage address corresponding to the region identifier is used to search the data of the head storage area and the tail storage area in the second cache space without searching in the underlying storage area. If there is no region identifier of the head storage area or the tail storage area in the first cache space (no hit or partial hit), the data stored in the head storage area and the tail storage area can only be obtained from the underlying storage area. The acquired data is spliced ​​with the first data to be written by the user as the target data and written into the storage area.

[0065] In order to avoid the problem that subsequent overwrites of the unaligned cache may miss data that has not updated the cache space, and that subsequent unaligned writes may read old data in the cache space, the following logic is added before the final processing flow of the successful write after each successful write: If the area identifier pageid cache is not hit in the cache space, the previous process is followed. If the page id cache is hit in the cache space, the data corresponding to the page id in the write request is written back to the corresponding data cache item.

[0066] In this embodiment, the first cache space is organized in the form of a linked list. If the user finishes writing data and closes the storage service, the first cache space and the second cache space can be released.

[0067] Fig. 9 The present invention provides a schematic diagram of a device for writing data in a non-aligned order in a storage system according to an embodiment of the present invention. Fig. 9 As shown, the device for writing data in a non-aligned order in the above storage system includes:

[0068] A first determination module 902 is used to determine, when receiving a data write request to a target space, a data length of first data requested to be written by the data write request and a starting write address corresponding to the data write request in a storage area, wherein the storage area is an area provided by the storage system for storing data for the target space;

[0069] A second determination module 904 is used to determine, according to the start write address and the data length, a head sub-region and a tail sub-region of the first data in the storage region, wherein the storage region is composed of a plurality of sub-storage regions, and each sub-storage region is a minimum unit of the index granularity of the storage region;

[0070] An acquisition module 906, configured to acquire second data stored in the head sub-region and the tail sub-region from the cache space allocated for the target space according to the first region identifier of the head sub-region and the second region identifier of the tail sub-region;

[0071] The writing module 908 is used to write the target data obtained by combining the first data and the second data into the target sub-region of the storage area, wherein the target sub-region includes a head sub-region, a tail sub-region, and a sub-region between the head sub-region and the tail sub-region.

[0072] In this embodiment, each logical volume requested by a user corresponds to a storage area, which can be an area opened for the logical volume requested by the user to store the data of the target space, and the data of logical volumes requested by different users are stored in different storage areas. If a target space wants to write data to the storage area, it can write through a data write request, which carries the starting write address and data length of the first data to be written in the storage area.

[0073] The storage area in this embodiment may be a storage area composed of multiple sub-storage areas, where the sub-storage area is the smallest unit that can be divided in index granularity, such as 4K, and each sub-storage area is 4K in size. 4K is an example, and other values ​​may also be set.

[0074] In this embodiment, the sub-storage area where the starting write address is located can be determined as the head sub-area; the sub-storage area where the ending write address is located, which is obtained by adding the starting write address to the data length, is determined as the tail sub-area. Through the above-mentioned starting write address and data length, the ending write address of the first data in the storage area can be determined. The starting write address is located in a sub-storage area, which is the head sub-area, and the ending write address is located in another sub-storage area, which is the tail sub-area. The head sub-area and the tail sub-area can be the same sub-area, or they can be adjacent sub-areas, or there can be multiple sub-storage areas in between. For example, Figure 2 As shown, Figure 2 In the example, each 4K size is a sub-storage area, and the starting write address of 7K size data is in Figure 2 The first sub-storage area in the memory is the head sub-area, and the end write address of the 7K data is located in the third sub-storage area, which is the tail sub-area.

[0075] The second data mentioned above is the data stored in the determined head sub-region and tail sub-region. In this embodiment, cache space is allocated to the target space, and the data stored in the head sub-region and tail sub-region are also stored in the cache space. This part of the data can be obtained from the cache space.

[0076] The acquired second data and the first data are spliced ​​into target data, and the target data is written into a target sub-region in the storage region. If the head sub-region and the tail sub-region are the same sub-region, the target sub-region is the head sub-region or the tail sub-region. If the head sub-region and the tail sub-region are adjacent sub-regions, the target sub-region is the head sub-region + the tail sub-region. If there are other sub-storage regions between the head sub-region and the tail sub-region, the target sub-region is the head sub-region + other sub-regions + the tail sub-region.

[0077] In this embodiment, when the first data is to be written into the target space, the data length of the first data and the starting write address in the storage area are determined, and the head sub-area and the tail sub-area of ​​the first data in the storage area are determined according to the data length and the starting write address. Then, the second data stored in the head sub-area and the tail sub-area are read from the cache space, and the second data is concatenated with the first data into target data, and the target data is written into the storage area. Therefore, there is no need to read the data in the first 4K storage area and the last 4K storage area to be occupied from the underlying storage area, thereby improving the data writing efficiency.

[0078] For other examples of this embodiment, please refer to the above examples and will not be described in detail here.

[0079] like Fig. 9 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0080] Memory 113, used for storing computer programs;

[0081] In one embodiment of the present application, the processor 111 is used to implement the method for non-aligned sequential writing of data in the storage system provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113.

[0082] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of a method for non-aligned sequential writing of data in a storage system provided by any of the aforementioned method embodiments are implemented.

[0083] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0084] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0085] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0086] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for writing data in a non-aligned order in a storage system, characterized in that: include: In case of receiving a data write request to the target space, determining the data length of the first data requested to be written by the data write request and the starting write address corresponding to the data write request in the storage area, wherein the storage area is an area provided by the storage system for storing data for the target space; Determine, according to the start write address and the data length, a head sub-region and a tail sub-region of the first data in the storage region, wherein the storage region is composed of a plurality of sub-storage regions, and each of the sub-storage regions is a minimum unit of index granularity of the storage region; Acquire the second data stored in the head sub-region and the tail sub-region from the cache space allocated for the target space according to the first region identifier of the head sub-region and the second region identifier of the tail sub-region; The target data obtained by combining the first data and the second data is written into a target sub-region of the storage area, wherein the target sub-region includes the head sub-region, the tail sub-region, and a sub-region between the head sub-region and the tail sub-region.

2. The method according to claim 1, characterized in that The acquiring, from the cache space allocated for the target space according to the first region identifier of the head sub-region and the second region identifier of the tail sub-region, the second data stored in the head sub-region and the tail sub-region comprises: searching the first region identifier and the second region identifier in a first cache space of the cache space, wherein the cache space includes a first cache space and a second cache space, the first cache space is used to cache a correspondence between a region identifier and a storage address, and the second cache space is used to cache the second data; When the first region identifier is found, obtaining a first storage address corresponding to the first region identifier in the first cache space, and determining data corresponding to the first storage address in the second cache space as header data in the second data, wherein the second data consists of header data and tail data; When the second region identifier is found, a second storage address corresponding to the second region identifier in the first cache space is obtained, and data corresponding to the second storage address in the second cache space is determined as the tail data in the second data.

3. The method according to claim 2, characterized in that The method further comprises: If the first region identifier is not found in the first cache space, obtaining the header data of the second data from the header sub-region of the storage region; or When the second region identifier is not found in the first cache space, the tail data of the second data is obtained from the tail sub-region of the storage region.

4. The method according to claim 1, characterized in that: Writing the target data obtained by combining the first data and the second data into the target sub-area of ​​the storage area comprises: splicing the tail of the data before the start write address in the header data of the second data with the header of the first data; splicing together the head of the data after the end write address in the tail data of the second data and the tail of the first data, wherein the end write address is determined according to the start write address and the data length, and the second data consists of the head data and the tail data; Determining the data obtained after splicing as the target data; The target data is written into the target sub-area.

5. The method according to claim 4, characterized in that Writing the target data into the target sub-area comprises: Dividing the target data into multiple pieces of data from beginning to end according to the size of the sub-storage area; According to the sequence of each of the multiple copies of data and the sequence of the multiple sub-storage areas of the target sub-area, each copy of the data is written into a corresponding sub-storage area.

6. The method according to claim 5, characterized in that After writing the target data into the target sub-area, the method further includes: Writing the region identifier of the first sub-storage region and the region identifier of the last sub-storage region into which the target data is written into the first cache space of the cache space; Writing the data of the first sub-storage area and the data of the last sub-storage area in which the target data is written into the second cache space of the cache space; The correspondence between the region identifier and the storage address of the data is written into the first cache space.

7. The method according to claim 1, characterized in that The determining, according to the start write address and the data length, a head sub-area and a tail sub-area of ​​the first data in the storage area comprises: Determine the sub-storage area where the start write address is located as the head sub-area; The sub-storage area where the end write address is located by adding the data length to the start write address is determined as the tail sub-area.

8. A device for writing data in a non-aligned order in a storage system, characterized in that: include: A first determination module is used to determine, when receiving a data write request to a target space, a data length of first data requested to be written by the data write request and a starting write address corresponding to the data write request in a storage area, wherein the storage area is an area provided by the storage system for storing data for the target space; A second determination module is used to determine, according to the start write address and the data length, a head sub-region and a tail sub-region of the first data in the storage area, wherein the storage area is composed of a plurality of sub-storage areas, and each of the sub-storage areas is a minimum unit of index granularity of the storage area; an acquisition module, configured to acquire, from a cache space allocated to the target space, second data stored in the head sub-region and the tail sub-region according to a first region identifier of the head sub-region and a second region identifier of the tail sub-region; A writing module is used to write target data obtained by combining the first data and the second data into a target sub-area of ​​the storage area, wherein the target sub-area includes the head sub-area, the tail sub-area, and a sub-area between the head sub-area and the tail sub-area.

9. An electronic device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, wherein the storage medium stores computer-executable instructions, wherein the computer-executable instructions are used to execute the method described in any one of claims 1 to 7 of the present application.

Citation Information

Patent Citations

  • Data processing method, device and equipment and readable storage medium

    CN113031876A

  • Storage apparatus and writing control method

    US20140198402A1