llapi_layout(7) llapi_layout(7) NAME llapi_layout - abstract interface to the layout of a Lustre file SYNOPSIS #include DESCRIPTION The llapi_layout family of functions functions provides an abstract interface to manipulating the layout information of a file in a Lustre filesystem. Layouts are represented by the opaque data type llapi_lay- out_t which is passed as a handle to the various functions. A layout has a number of attributes that describe how a file's data are stored in the filesystem. These include stripe count, stripe size, RAID pattern, pool name, and the OST index associated with each stripe. Refer to the Lustre Operations Manual for detailed descriptions of these attributes. For each attribute, there exists a pair of functions with the suffixes _get and _set that are used to read and assign the attribute value in a given layout. Using this interface to create a file might consist of the following steps. o Allocate a layout with llapi_layout_alloc(). o Assign attribute values using the llapi_layout_*_set() func- tions. o Create the file using llapi_layout_file_create(). o Free the layout memory using llapi_layout_free(). Similarly, these steps might be used to read a file layout: o Obtain the layout with llapi_layout_get_by_path(), llapi_lay- out_get_by_fd(), or llapi_layout_get_by_fid(). o Read attribute values using the llapi_layout_*_get() functions. o Free the layout memory using llapi_layout_free(). EXAMPLE #include #include #include #include #include #include int main(int argc, char *argv[]) { int fd; struct llapi_layout *layout; uint64_t count = 2; uint64_t size = 1048576; char *path; if (argc != 2) return -1; path = argv[1]; layout = llapi_layout_alloc(); llapi_layout_stripe_count_set(layout, count); llapi_layout_stripe_size_set(layout, size); fd = llapi_layout_file_create(path, 0, 0640, layout); if (fd < 0) { fprintf(stderr, "cannot create %s: %s\n", path, strerror(errno)); return -1; } close(fd); llapi_layout_free(layout); layout = llapi_layout_get_by_path(path, 0); llapi_layout_stripe_size_get(layout, &size), llapi_layout_stripe_count_get(layout, &count); printf("%s with stripe size %llu, striped across %llu OSTs," " has been created!\n", path, size, count); llapi_layout_free(layout); return 0; } BUGS Setting the OST index number is only supported for stripe number 0. The RAID pattern may only be set to 0. SEE ALSO open(2), lustre(7), lustreapi(7), llapi_layout_alloc(3), llapi_lay- out_file_create(3), llapi_layout_file_open(3), llapi_layout_free(3), llapi_layout_get_by_fd(3), llapi_layout_get_by_fid(3), llapi_lay- out_get_by_path(3), llapi_layout_ost_index_get(3), llapi_lay- out_ost_index_set(3), llapi_layout_pattern_get(3), llapi_layout_pat- tern_set(3), llapi_layout_pool_name_get(3), llapi_lay- out_pool_name_set(3), llapi_layout_stripe_count_get(3), llapi_lay- out_stripe_count_set(3), llapi_layout_stripe_size_get(3), llapi_lay- out_stripe_size_set(3), lfs(1) Lustre User API 2013 Oct 31 llapi_layout(7)