OpenFAM Reference Implementation

openfam::fam::fam_resize_region

Resize an existing region in FAM

Synopsis

void fam_resize_region(Fam_Region_Descriptor *descriptor, uint64_t nbytes);

Description

This method resizes a region in FAM.

Input Arguments

NameDescription
descriptorDescriptor of the region to be resized.
nbytesNew requested size of the region.

Return Values

None. Throws Fam_Exception on error.

Fam Error Numbers

ErrorDescription
FAM_ERR_NOPERMCaller does not have access rights
FAM_ERR_NOTFOUNDRegion name is not present in FAM
FAM_ERR_LIBFABRICLibfabric error occurred.
FAM_ERR_RPCCommunication error from grpc layer.
FAM_ERR_RPC_CLIENT_NOTFOUNDRPC service not available.
FAM_ERR_METADATAMetadata service error.
FAM_ERR_MEMORYMemory service error.
FAM_ERR_RESOURCEResource not available.

Notes

Regions may safely be increased in size (subject to system-wide limits). Reducing the region size (although allowed) implies that any data items in the truncated part of the region will be lost. The behavior of the library if those items are accessed later is implementation dependent.

Example

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fam/fam.h>
#include <fam/fam_exception.h>
using namespace std;
using namespace openfam;

int main(void) {
	fam *myFam = new fam();

	// .. initialization code here
	

            Fam_Region_Attributes* regionAttributes = (Fam_Region_Attributes*)calloc(1, sizeof(Fam_Region_Attributes));
        try {
                regionAttributes->memoryType = VOLATILE;

	
	try {
		// create a 10 GB region with 0777 permissions and RAID5 redundancy
                Fam_Region_Descriptor *rd = myFam->fam_create_region("myRegion", (uint64_t)10000000000, 0777, regionAttributes);
			
		// use the created region...
		printf("fam_create_region successful\n");
			
		// resize the region to 20 GB
		myFam->fam_resize_region(rd, (uint64_t)20000000000);
			
		// use the re-sized region
		printf("fam_resize_region successful\n");
		// ... continuation code here
			
		// we are finished. Destroy the region and everything in it
		myFam->fam_destroy_region(rd);
		printf("fam_destroy_region successful\n");
	} catch (Fam_Exception &e) {
		printf("Create/Destroy region failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
	free(regionAttributes);
	// ... finalization code here
}