US 20030014583 A1 Abstract A bit-parallel system and method for allocating storage space for data objects using a bitmap. It is determined whether a suffix of free space bits in a previous bitmap word can be used with a prefix of free space bits in a current word that is contiguous to the previous word. If so, this renders a string of free space bits spanning multiple words, and it is determined whether the string represents a sufficiently large number of contiguous blocks (“the target”) to store the data object. If not, it is determined whether sufficient contiguous free space bits in the current word exist to fulfill the target. If the target still can't be achieved, the longest suffix of free space bits in the current word is found for possible use with the prefix of the next contiguous word, and the next word is then retrieved and processed. The algorithm for finding the suffix preferably is undertaken by considering bits in parallel.
Claims(17) 1. A computer system, comprising:
a data storage system having a bitmap of bits representing at least free space on a data storage medium; and at least one processor associated with a data storage system, the processor having logic for undertaking method acts comprising:
receiving at least a size of an object to be stored, the size establishing a target number “k” of bits in the bitmap;
operating on bits in parallel, in a first word of bits in the bitmap, determining a suffix sequence of bits when all bit values in the suffix sequence are a predetermined value;
in a second word of bits in the bitmap, determining a prefix sequence of bits when all bit values in the prefix sequence are the predetermined value; and
returning an allocation for the object when the length of the prefix and suffix together equals at least the target number of bits.
2. The system of (a) determining whether each one of a first number of bits in a word has the predetermined bit value, the first number being the minimum of: the word size “w”, and the difference between the target number “k” and a suffix size “s”;
(b) if each one of the first number of bits has the predetermined bit value, determining whether the difference between the target number “k” and suffix size “s” is greater than the word size “w”, and if so,
(c) setting the suffix size “s” to be equal to the suffix size “s” plus the word size “w”, and otherwise returning “found allocation”.
3. The system of (d) when the difference between the target number “k” and suffix size “s” is greater than the word size “w”, retrieving the next contiguous word in the bitmap and repeating acts (a)-(c). 4. The system of (e) when it is determined at act (a) that the first number of contiguous bits is not in the word, determining whether the target number “k” is greater than the word size “w”, and if so, (f) finding a longest suffix of consecutive bits each of which bits has the predetermined value, the longest suffix defining a suffix size, and then retrieving a next word in the bitmap and repeating acts (a)-(c); (g) when it is determined at act (e) that the target number “k” is not greater than the word size “w”, determining whether each one of “k” consecutive bits in the word has the predetermined value, and if so, returning “found allocation”, and otherwise undertaking act (f). 5. A computer program device comprising:
a computer program storage device readable by a processor; and a program on the program storage device and including instructions executable by the processor for using a bitmap to allocate space in a data storage system, the program comprising:
computer readable code means for identifying a contiguous number of bits in the bitmap when each bit in the contiguous number has a predetermined value and when the number of bits in the contiguous number is at least as great as a target number “k” of bits, the contiguous number of bits spanning more than a single word in the bitmap.
6. The computer program device of 7. The computer program device of 8. The computer program device of 9. The computer program device of computer readable code means for determining a suffix sequence of bits in a first word of bits in the bitmap when all bit values in the suffix sequence are a predetermined value; computer readable code means for determining a prefix sequence of bits in a second word of bits in the bitmap when all bit values in the prefix sequence are the predetermined value, the first and second words being contiguous to each other; and computer readable code means for returning an allocation for the object when the length of the prefix and suffix together equals at least the target number “k”. 10. The computer program device of computer readable code means for determining whether each one of a first number of bits in a word has the predetermined bit value, the first number being the minimum of: the word size “w”, and the difference between the target number “k” and a suffix size “s”;
computer readable code means for, if the first number of bits have the predetermined bit value, determining whether the difference between the target number “k” and suffix size “s” is greater than the word size “w”; and
computer readable code means for setting the suffix size “s” to be equal to the suffix size “s” plus the word size “w” when the difference between the target number “k” and suffix size “s” is greater than the word size “w”.
11. The computer program device of computer readable code means for, when the difference between the target number “k” and suffix size “s” is greater than the word size “w”, retrieving the next contiguous word in the bitmap. 12. A computer-implemented method for identifying a target number “k” of storage blocks using a bitmap including words of “w” bits each, comprising:
identifying, in at least a first word or words, a suffix having “s” contiguous bits, each having a predetermined value; and
identifying, in at least a second word or words contiguous to or near the first word or words, a prefix having “p” contiguous bits, each having the predetermined value, wherein “p” and “s” together equal at least “k”.
13. The method of 14. The method of 15. The method of (a) determining whether each one of a first number of bits in a word has the predetermined bit value, the first number being the minimum of: the word size “w”, and the difference between the target number “k” and a suffix size “s”;
(b) if each one of the first number of bits has the predetermined bit value, determining whether the difference between the target number “k” and suffix size “s” is greater than the word size “w”, and if so,
(c) setting the suffix size “s” to be equal to the suffix size “s” plus the word size “w”, and otherwise returning “found allocation”.
16. The method of (d) when the difference between the target number “k” and suffix size “s” is greater than the word size “w”, retrieving the next contiguous word in the bitmap and repeating acts (a)-(c). 17. The method of (e) when it is determined at act (a) that the first number of contiguous bits is not in the word, determining whether the target number “k” is greater than the word size “w”, and if so, (f) finding a longest suffix of consecutive bits in the word each of which bits has the predetermined value, the longest suffix defining a suffix size, and then retrieving a next word in the bitmap and repeating acts (a)-(c); (g) when it is determined at act (e) that the target number “k” is not greater than the word size “w”, determining whether each one of “k” consecutive bits in the word has the predetermined value, and if so, returning “found allocation”, and otherwise undertaking act (f). Description [0001] 1. Field of the Invention [0002] The present invention relates to data storage systems that allocate storage space using bitmaps. [0003] 2. Description of the Related Art [0004] Storage systems, particularly systems that store data objects contiguously, often use bitmaps to represent and manage free space. Typically, the value of each bit in a bitmap represents whether a unit of storage, e.g., a block, is free. A bit value of “1” in a free space bitmaps indicates that the block associated with the bit is free, and a value of “0” indicates that the block is not free. Of course, a used space bitmap would reverse the free/not free values. [0005] Larger storage systems require larger bitmaps, with some bitmaps potentially including many pages. Each page in turn includes many “words” of bits, with the word size being a power of two and generally being equal to the register width of the processor being used, e.g., 16 bits, 32 bits, 64 bits, and so on. Thus, a processor can read up to the word size number of bits in parallel. When it is time to allocate free space for a data object to be stored, the allocation processor searches the bitmap for a sequence of bits that represents free space which is sufficiently large to store the object. [0006] Bitmaps have several advantages over other management tools such as so-called “extent lists” and the “buddy system” disclosed by Knuth in [0007] However, the present invention observes that searching bitmaps for data object allocation purposes can be inefficient. For instance, a linear search of a bitmap requires a fixed number of steps to examine each bit, increasing the time it takes to find an allocation. Also, previous systems such as the GPFS/Tiger Shark file system look in only a single bitmap word for an allocation. As recognized herein, some data objects might be sufficiently large to require an allocation that cannot be represented by a single bitmap word. Moreover, by limiting an allocation to spaces represented in only a single bitmap word, an allocation that might span multiple contiguous words that together have a contiguous string of free space bits cannot be considered. The invention disclosed herein addresses one or more of the critical observations set forth above. [0008] A general purpose computer is programmed according to the inventive steps herein to manage storage space in a storage system. The invention can also be embodied as an article of manufacture—a machine component—that is used by a digital processing apparatus and which tangibly embodies a program of instructions that are executable by the digital processing apparatus to execute the present logic. This invention is realized in a critical machine component that causes a digital processing apparatus to perform the inventive method steps herein. [0009] The invention can be implemented by a computer system including a data storage system having a bitmap of bits representing free and used space on a data storage medium, and a processor associated with a data storage system. The processor has logic for receiving a size of an object to be stored, with the size establishing a target number “k” of bits in the bitmap. The processor also has logic for, in a first word of bits in the bitmap, determining a suffix sequence of bits when all bit values in the suffix sequence are a predetermined value. In a second word of bits in the bitmap, the processor logic determines a prefix sequence of bits when all bit values in the prefix sequence are the predetermined value. The logic of the processor returns an allocation for the object when the length of the prefix and suffix together equals at least the target number “k” of bits. [0010] In another aspect, a computer program device includes a computer program storage device that is readable by a processor. A program is on the program storage device and includes instructions which can be executed by the processor for using a bitmap to allocate space in a data storage system. The program includes computer readable code means for identifying a contiguous number of bits in the bitmap when each bit in the contiguous number has a predetermined value and when the number of bits in the contiguous number is at least as great as a target number “k” of bits. The contiguous number of bits span more than a single word in the bitmap. [0011] In still another aspect, a computer-implemented method for identifying a target number “k” of storage blocks using a bitmap including words of “w” bits each includes identifying, in a first word or words, a suffix having “s” contiguous bits. Each bit has a predetermined value, e.g., “high”. The method also includes identifying, in a second word or words contiguous to or near the first word or words, a prefix having “p” contiguous bits. Each bit in the prefix has the predetermined value, and “p” and “s” together equal at least “k”. [0012] The details of the present invention, both as to its structure and operation, can best be understood in reference to the accompanying drawings, in which like reference numerals refer to like parts, and in which: [0013]FIG. 1 is a schematic diagram showing the system of the present invention; [0014]FIG. 2 is a flow chart showing the present logic; [0015]FIG. 3 is a table illustrating the operation of the gap search routine in a preferred implementation of the logic of FIG. 2; and [0016]FIG. 4 is a table that displays the results of the preferred gap search algorithms. [0017] Referring initially to FIG. 1, a system is shown, generally designated [0018] The system [0019] In one intended embodiment, the processor [0020] The flow charts herein illustrate the structure of the logic embodied by the module [0021] Manifestly, the invention is practiced in its essential embodiment by a machine component that renders the logic elements in a form that instructs a digital processing apparatus (that is, a computer) to perform a sequence of function steps corresponding to those shown. [0022] In other words, the flow charts may be embodied in a computer program that is executed by a processor as a series of computer-executable instructions. These instructions may reside, for example, in a program storage device of the system [0023]FIG. 2 shows the logic of present invention. Commencing at block [0024] When the test at decision diamond [0025] Returning to decision diamond [0026] Failing both of the first two logical loops, however, the process next moves to block [0027] The above algorithm can be undertaken by examining the bits of a word serially or in parallel. For performance reasons, the parallel method is preferred. Accordingly, a particularly preferred implementation that undertakes the logic of FIG. 2 is set forth below, using the following terminology. A variable “p” is the prefix length in the current word under test that is required to reach the target number “k”. A page of the bitmap is labelled “W”. The page consists of a series of words, W=W [0028] For ease of understanding bit operations and displaying bitmap contents in debuggers and programs, the algorithms below are in a big-endian memory (most significant byte first) with the bitmap bits being ordered so that they are sequential and increasing. Bitmap bits that have adjacent indices are adjacent in memory, which facilitates viewing and debugging bitmap contents. Also, in the big-endian format the left and right shift operators (<<and >>) correspond to left and right shifts in registers and memory. Note that the shift operators are specified to shift registers towards the most and least significant bit, not necessarily to the left and right physically. [0029] With the above in mind, the step of determining whether a prefix of a word under test, when added to the suffix of the previous word, equals the target “k” (i.e., the first loop of FIG. 2), can be undertaken by direct calculation. Specifically, given the target “k” and suffix of the previous word of length “s”, the prefix length “p” must be of length p=k−s to fulfill the requested allocation. To check for a length “p” prefix in word W [0030] For any prefix “p” larger than |W|, targets larger than |W| require an allocation across multiple words. The present invention determines whether the current word describes available space, i.e., whether W [0031] With respect to how the preferred algorithm undertakes the second loop of FIG. 2—finding allocations smaller than |W| that are contained within a given word—the algorithm uses bit-parallel search techniques. In greater detail, if an allocation of the target size exists, it starts at some offset between 0 and |W|-k in word W [0032] To search for a gap of size “k”, the preferred method conducts 1 g(k) rounds, with each round shifting the bits minimum(2 [0033] The “gap size” column describes how large a contiguous gap each bit in the word represents. As the skilled artisan will appreciate, for the original word (a [0034] Since d [0035] At the termination of the gap search routine, the presently preferred parallel algorithm evaluates whether a suitable gap exists and locates the bit offset of such a gap. If no gap exists, the algorithm continues to the third loop of FIG. 2, i.e., to calculate a suffix. Any high bit in the result word (W(R)) indicates that an allocation of the target size can be made in the original word. To test this, the algorithm merely evaluates if W(R)=0. For non-zero final result words, to find the offset of the first high bit in the result word, the algorithm performs binary search as indicated in the following pseudocode:
[0036] The above search algorithm finds the leftmost high bit, corresponding to the first gap in which the target length can be allocated. The routine returns an offset which corresponds to the end of the found gap. To locate the start offset, the gap size less one is then subtracted. [0037] The way the preferred parallel algorithm undertakes the final loop of FIG. 2—finding the suffix—is shown below in pseudocode:
[0038] The above routine for finding the suffix size draws on the same concepts and reuses the results computed in the gap search routine. If the algorithm just completed the gap search routine, the result words are reused. Labelling these words by round, i.e. W(O) is the original word and W(R) the result of round R. If these results are not available because the algorithm came directly from the prefix routine, result words W(R) are computed using ½|W| as the target size. [0039] As the skilled artisan will appreciate from the above pseudocode, the suffix finding routine searches backwards through the rounds using already computed values to extend the known length of the suffix. The routine starts by considering the result of the latest round with a high rightmost bit. For notation, the latest round with a high rightmost bit is referred to as W(L). The n [0040] Assume the gap search algorithm looked for, but did not find, a target of 16 for the rightmost bits of three different words, with suffixes of 8, 13, and 15. Call these examples E8, E13 and E15, respectively. FIG. 4 displays the results of the gap search algorithms for the rightmost 16 bits for each of the three original words. The bits that the suffix algorithm considers in each word are underlined. For all three examples, the rightmost bit of W( [0041] As shown in FIG. 4, upon encountering a low bit, like E8 does, the focus of the algorithm shifts to the previous round, but remains at the same bit offset. For the remainder of its rounds, E8 remains at known suffix length 8. [0042] For E13 and E15, on the other hand, the focus shifts four bits to the left and to the previous round (W( [0043] In the final round, E15 again shifts it focus, this time two bits to the left, and E13 remains on the same bit, only changing its round. Both examples find a high bit and increase their known length by one. The suffix routine terminates after examining the original word W( [0044] The suffix finding algorithm shown in the second of the above-disclosed pseudocode routines works backwards through the results words of the gap search algorithm to determine the length of the suffix. It starts with round R(L), which is the highest round with a high rightmost bit, i.e. W(L) [0045] The algorithm iteratively refines the possible length of the suffix by looking in lower rounds. In round L−1, if bit W(L−1) [0046] While the particular SYSTEM AND METHOD FOR ALLOCATING STORAGE SPACE USING BIT-PARALLEL SEARCH OF BITMAP as herein shown and described in detail is fully capable of attaining the above-described objects of the invention, it is to be understood that it is the presently preferred embodiment of the present invention and is thus representative of the subject matter which is broadly contemplated by the present invention, that the scope of the present invention fully encompasses other embodiments which may become obvious to those skilled in the art, and that the scope of the present invention is accordingly to be limited by nothing other than the appended claims, in which reference to an element in the singular means “at least one”. All structural and functional equivalents to the elements of the above-described preferred embodiment that are known or later come to be known to those of ordinary skill in the art are expressly incorporated herein by reference and are intended to be encompassed by the present claims. Moreover, it is not necessary for a device or method to address each and every problem sought to be solved by the present invention, for it to be encompassed by the present claims. Furthermore, no element, component, or method step in the present disclosure is intended to be dedicated to the public regardless of whether the element, component, or method step is explicitly recited in the claims. No claim element herein is to be construed under the provisions of 35 U.S.C. §112, sixth paragraph, unless the element is expressly recited using the phrase “means for”. Referenced by
Classifications
Legal Events
Rotate |