.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "" "" "2023-05-31" "PMDK - " "PMDK Programmer's Manual" .hy .\" SPDX-License-Identifier: BSD-3-Clause .\" Copyright 2017-2023, Intel Corporation .SH NAME .PP \f[B]pmemblk_create\f[R]()(DEPRECATED), \f[B]pmemblk_open\f[R]()(DEPRECATED), \f[B]pmemblk_close\f[R]()(DEPRECATED), \f[B]pmemblk_check\f[R]()(DEPRECATED) - create, open, close and validate block pool .SH SYNOPSIS .IP .nf \f[C] #include PMEMblkpool *pmemblk_create(const char *path, size_t bsize, size_t poolsize, mode_t mode); PMEMblkpool *pmemblk_open(const char *path, size_t bsize); void pmemblk_close(PMEMblkpool *pbp); int pmemblk_check(const char *path, size_t bsize); \f[R] .fi .SH DESCRIPTION .PP The \f[B]pmemblk_create\f[R]() function creates a block memory pool with the given total \f[I]poolsize\f[R], divided into as many elements of size \f[I]bsize\f[R] as will fit in the pool. Since the transactional nature of a block memory pool requires some space overhead in the memory pool, the resulting number of available blocks is less than \f[I]poolsize\f[R]/\f[I]bsize\f[R], and is made available to the caller via the \f[B]pmemblk_nblock\f[R](3) function. Given the specifics of the implementation, the number of available blocks for the user cannot be less than 256. This translates to at least 512 internal blocks. \f[I]path\f[R] specifies the name of the memory pool file to be created. \f[I]mode\f[R] specifies the permissions to use when creating the file, as described by \f[B]creat\f[R](2). The memory pool file is fully allocated to the size \f[I]poolsize\f[R] using \f[B]posix_fallocate\f[R](3). The caller may choose to take responsibility for creating the memory pool file by creating it before calling \f[B]pmemblk_create\f[R](), and then specifying \f[I]poolsize\f[R] as zero. In this case \f[B]pmemblk_create\f[R]() will take the pool size from the size of the existing file, and will verify that the file appears to be empty by searching for any non-zero data in the pool header at the beginning of the file. The net pool size of a pool file is equal to the file size. The minimum net pool size allowed by the library for a block pool is defined in \f[B]\f[R] as \f[B]PMEMBLK_MIN_POOL\f[R]. \f[I]bsize\f[R] can be any non-zero value; however, \f[B]libpmemblk\f[R] will silently round up the given size to \f[B]PMEMBLK_MIN_BLK\f[R], as defined in \f[B]\f[R]. .PP Depending on the configuration of the system, the available non-volatile memory space may be divided into multiple memory devices. In such case, the maximum size of the pmemblk memory pool could be limited by the capacity of a single memory device. \f[B]libpmemblk\f[R](7) allows building a persistent memory resident array spanning multiple memory devices by creation of persistent memory pools consisting of multiple files, where each part of such a \f[I]pool set\f[R] may be stored on a different memory device or pmem-aware filesystem. .PP Creation of all the parts of the pool set can be done with \f[B]pmemblk_create\f[R](); however, the recommended method for creating pool sets is by using the \f[B]pmempool\f[R](1) utility. .PP When creating a pool set consisting of multiple files, the \f[I]path\f[R] argument passed to \f[B]pmemblk_create\f[R]() must point to the special \f[I]set\f[R] file that defines the pool layout and the location of all the parts of the pool set. The \f[I]poolsize\f[R] argument must be 0. The meaning of the \f[I]mode\f[R] argument does not change, except that the same \f[I]mode\f[R] is used for creation of all the parts of the pool set. .PP For more information on pool set format, see \f[B]poolset\f[R](5). .PP The \f[B]pmemblk_open\f[R]() function opens an existing block memory pool. As with \f[B]pmemblk_create\f[R](), \f[I]path\f[R] must identify either an existing block memory pool file, or the \f[I]set\f[R] file used to create a pool set. The application must have permission to open the file and memory map the file or pool set with read/write permissions. If \f[I]bsize\f[R] is non-zero, \f[B]pmemblk_open\f[R]() will verify that the given block size matches the block size used when the pool was created. Otherwise, \f[B]pmemblk_open\f[R]() will open the pool without verifying the block size. The \f[I]bsize\f[R] can be determined using the \f[B]pmemblk_bsize\f[R](3) function. .PP Be aware that if the pool contains bad blocks inside, opening can be aborted by the SIGBUS signal, because currently the pool is not checked against bad blocks during opening. It can be turned on by setting the CHECK_BAD_BLOCKS compat feature. For details see description of this feature in \f[B]pmempool-feature\f[R](1). .PP The \f[B]pmemblk_close\f[R]() function closes the memory pool indicated by \f[I]pbp\f[R] and deletes the memory pool handle. The block memory pool itself lives on in the file that contains it and may be re-opened at a later time using \f[B]pmemblk_open\f[R]() as described above. .PP The \f[B]pmemblk_check\f[R]() function performs a consistency check of the file indicated by \f[I]path\f[R], and returns 1 if the memory pool is found to be consistent. If the pool is found not to be consistent, further use of the file with \f[B]libpmemblk\f[R] will result in undefined behavior. The debug version of \f[B]libpmemblk\f[R] will provide additional details on inconsistencies when \f[B]PMEMBLK_LOG_LEVEL\f[R] is at least 1, as described in the \f[B]DEBUGGING AND ERROR HANDLING\f[R] section in \f[B]libpmemblk\f[R](7). \f[B]pmemblk_check\f[R]() opens the given \f[I]path\f[R] read-only so it never makes any changes to the file. This function is not supported on Device DAX. .SH RETURN VALUE .PP On success, \f[B]pmemblk_create\f[R]() returns a \f[I]PMEMblkpool*\f[R] handle to the block memory pool. On error, it returns NULL and sets \f[I]errno\f[R] appropriately. .PP On success, \f[B]pmemblk_open\f[R]() returns a \f[I]PMEMblkpool*\f[R] handle that can be used with most of the functions in \f[B]libpmemblk\f[R](7). On error, it returns NULL and sets \f[I]errno\f[R] appropriately. Possible errors include: .IP \[bu] 2 failure to open \f[I]path\f[R] .IP \[bu] 2 \f[I]path\f[R] specifies a \f[I]set\f[R] file and any of the pool set files cannot be opened .IP \[bu] 2 \f[I]path\f[R] specifies a \f[I]set\f[R] file and the actual size of any file does not match the corresponding part size defined in the \f[I]set\f[R] file .IP \[bu] 2 \f[I]bsize\f[R] is non-zero and does not match the block size given when the pool was created. \f[I]errno\f[R] is set to \f[B]EINVAL\f[R] in this case. .PP The \f[B]pmemblk_close\f[R]() function returns no value. .PP \f[B]pmemblk_check\f[R]() returns 1 if the memory pool is found to be consistent. If the check is successfully performed but the pool is found to be inconsistent, \f[B]pmemblk_check\f[R]() returns 0. This includes the case where \f[I]bsize\f[R] is non-zero and does not match the block size given when the pool was created. If the consistency check cannot be performed, \f[B]pmemblk_check\f[R]() returns -1 and sets \f[I]errno\f[R] appropriately. .SH CAVEATS .PP Not all file systems support \f[B]posix_fallocate\f[R](3). \f[B]pmemblk_create\f[R]() will fail if the underlying file system does not support \f[B]posix_fallocate\f[R](3). .SH SEE ALSO .PP \f[B]pmempool\f[R](1), \f[B]creat\f[R](2), \f[B]pmemblk_nblock\f[R](3), \f[B]posix_fallocate\f[R](3), \f[B]poolset\f[R](5), \f[B]libpmemblk\f[R](7) and \f[B]\f[R]