Region to host affinity for block allocation in clustered file system volume
A method is provided for a computer to allocate a resource from a clustered file system (CFS) volume stored on one or more physical storage devices to a file. The CFS volume includes resources organized into resource clusters and the resource clusters make up regions. The method includes, for each region of resource clusters, determining a first count of resources allocated to the host computer and a second count of resources allocated to all other host computers, and calculating a region weight based on the first count and the second count. The method further includes sorting a list of the regions based on their region weights, selecting a region at or near the start of the list, and allocating the resource from a resource cluster in the selected region to the file.
1. A method, performed by a host computer having a processor, to allocate a resource from a clustered file system (CFS) volume stored on one or more physical storage devices to a file, the CFS volume comprising resources organized into resource clusters, and the resource clusters make up regions, the method comprising:
for each region of the resource clusters:
determining a first count of resources allocated to the host computer and a second count of resources allocated to all other host computers; and
calculating a region weight based on the first count and the second count;
sorting a list of the regions based on their region weights that starts from the greatest region weight to the least region weight;
selecting a region at or near the start of the list; and
allocating the resource from a resource cluster in the selected region to the file.
2. The method of claim 1 , wherein the region weight is based on magnifying the second count and determining a difference between the first count and the magnified second count.
3. The method of claim 1 , wherein:
the region weight is calculated based on
generating a first product by multiplying a number of resource clusters in each region with a multiplier factor,
generating a first sum by adding to the first product to the first count of resources allocated to the host computer,
generating a second product by multiplying the second count of resources allocated to other host computers with a magnifier factor, and
subtracting the second sum from the first sum.
4. The method of claim 1 , further comprising selecting the resource cluster in the selected region to evenly distribute files in all the resource clusters.
5. The method of claim 4 , wherein selecting the resource cluster comprises:
for each resource cluster, determining an affinity count of files allocated from the resource cluster;
determining an average affinity count of files allocated from all the resource clusters in the CFS volume; and
selecting the resource cluster in the region whose affinity count is less than or equal to the average affinity count.
6. A non-transitory, computer-readable storage medium encoded with instructions executable by a processor to implement a hypervisor on a host computer, to allocate a resource from a clustered file system (CFS) volume stored on one or more physical storage devices to a file, the CFS volume comprising resources organized into resource clusters, and the resource clusters make up regions, the instructions comprising:
for each region of the resource clusters:
determining a first count of resources allocated to the host computer and a second count of resources allocated to all other host computers; and
calculating a region weight based on the first count and the second count;
sorting a list of the regions based on their region weights that starts from the greatest region weight to the least region weight;
selecting a region at or near the start of the list; and allocating the resource from a resource cluster in the selected region to the file.
7. The non-transitory, computer-readable storage medium of claim 6 , wherein the region weight is based on magnifying the second count and determining a difference between the first count and the magnified second count.
8. The non-transitory, computer-readable storage medium of claim 7 , wherein:
the region weight is calculated based on
generating a first product by multiplying a number of resource clusters in each region with a multiplier factor,
generating a first sum by adding to the first product to the first count of resources allocated to the host computer,
generating a second product by multiplying the second count of resources allocated to other host computers with a magnifier factor, and
subtracting the second sum from the first sum.
9. The non-transitory, computer-readable storage medium of claim 7 , wherein the instructions further comprise selecting the resource cluster in the selected region to evenly distribute files in all the resource clusters.
10. The non-transitory, computer-readable storage medium of claim 9 , wherein selecting the resource cluster comprises:
for each resource cluster, determining an affinity count of files allocated from the resource cluster;
determining an average affinity count of files allocated from all the resource clusters in the CFS volume; and
selecting the resource cluster in the region whose affinity count is less than or equal to the average affinity count.
11. A computer having a processor to allocate a resource from a clustered file system (CFS) volume stored on one or more physical storage devices to a file, the CFS volume comprising resources organized into resource clusters, and the resource clusters make up regions, wherein the computer is configured to:
for each region of the resource clusters:
determine a first count of resources allocated to the computer and a second count of resources allocated to all other computers; and
calculate a region weight based on the first count and the second count;
sort a list of the regions based on their region weights that starts from the greatest region weight to the least region weight;
select a region at or near the start of the list; and
allocate the resource from a resource cluster in the selected region to the file.
12. The computer of claim 11 , wherein the region weight is based on magnifying the second count and determining a difference between the first count and the magnified second count.
13. The computer of claim 12 , wherein:
the region weight is calculated based on
generating a first product by multiplying a number of resource clusters in each region with a multiplier factor, and
generating a first sum adding to the first product to the first count of resources allocated to the computer,
generating a second product by multiplying the second count of resources allocated to other computers with a magnifier factor, and
subtracting the second sum from the first sum.
14. The computer of claim 11 , wherein the computer is further configured to select the resource cluster in the selected region to evenly distribute files in all the resource clusters.
15. The computer of claim 14 , wherein the computer selects the resource cluster by:
for each resource cluster, determine an affinity count of files allocated from the resource cluster;
determine an average affinity count of files allocated from all the resource clusters in the CFS volume; and
select the resource cluster in the region whose affinity count is less than or equal to the average affinity count.