X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fpmemblk.c;h=fc6358e8e11f3730fc6163127830aaf5bc1ebf7a;hb=fab60fa78a1832c17f8bb200292ded4a8b3eb2a5;hp=ed6c2b2feb7ba5b4e690dcc8f254f70cf5615336;hpb=a09986004635b75f82c13c0674bae671a89fb065;p=fio.git diff --git a/engines/pmemblk.c b/engines/pmemblk.c index ed6c2b2f..fc6358e8 100644 --- a/engines/pmemblk.c +++ b/engines/pmemblk.c @@ -1,5 +1,5 @@ /* - * pmemblk: IO engine that uses NVML libpmemblk to read and write data + * pmemblk: IO engine that uses PMDK libpmemblk to read and write data * * Copyright (C) 2016 Hewlett Packard Enterprise Development LP * @@ -14,8 +14,8 @@ * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. */ /* @@ -27,11 +27,11 @@ * ioengine=pmemblk * * Other relevant settings: + * thread=1 REQUIRED * iodepth=1 * direct=1 - * thread=1 REQUIRED * unlink=1 - * filename=/pmem0/fiotestfile,BSIZE,FSIZEMB + * filename=/mnt/pmem0/fiotestfile,BSIZE,FSIZEMiB * * thread must be set to 1 for pmemblk as multiple processes cannot * open the same block pool file. @@ -39,14 +39,23 @@ * iodepth should be set to 1 as pmemblk is always synchronous. * Use numjobs to scale up. * - * direct=1 is implied as pmemblk is always direct. + * direct=1 is implied as pmemblk is always direct. A warning message + * is printed if this is not specified. + * + * unlink=1 removes the block pool file after testing, and is optional. * - * Can set unlink to 1 to remove the block pool file after testing. + * The pmem device must have a DAX-capable filesystem and be mounted + * with DAX enabled. filename must point to a file on that filesystem. + * + * Example: + * mkfs.xfs /dev/pmem0 + * mkdir /mnt/pmem0 + * mount -o dax /dev/pmem0 /mnt/pmem0 * * When specifying the filename, if the block pool file does not already - * exist, then the pmemblk engine can create the pool file if you specify + * exist, then the pmemblk engine creates the pool file if you specify * the block and file sizes. BSIZE is the block size in bytes. - * FSIZEMB is the pool file size in MB. + * FSIZEMB is the pool file size in MiB. * * See examples/pmemblk.fio for more. * @@ -77,10 +86,6 @@ struct fio_pmemblk_file { size_t pmb_bsize; size_t pmb_nblocks; }; -#define FIOFILEPMBSET(_f, _v) do { \ - (_f)->engine_data = (uint64_t)(uintptr_t)(_v); \ -} while(0) -#define FIOFILEPMBGET(_f) ((fio_pmemblk_file_t)((_f)->engine_data)) static fio_pmemblk_file_t Cache; @@ -128,7 +133,7 @@ static void fio_pmemblk_cache_remove(fio_pmemblk_file_t pmb) * level, we allow the block size and file size to be appended * to the file name: * - * path[,bsize,fsizemb] + * path[,bsize,fsizemib] * * note that we do not use the fio option "filesize" to dictate * the file size because we can only give libpmemblk the gross @@ -138,7 +143,7 @@ static void fio_pmemblk_cache_remove(fio_pmemblk_file_t pmb) * the final path without the parameters is returned in ppath. * the block size and file size are returned in pbsize and fsize. * - * note that the user should specify the file size in MiB, but + * note that the user specifies the file size in MiB, but * we return bytes from here. */ static void pmb_parse_path(const char *pathspec, char **ppath, uint64_t *pbsize, @@ -147,7 +152,7 @@ static void pmb_parse_path(const char *pathspec, char **ppath, uint64_t *pbsize, char *path; char *s; uint64_t bsize; - uint64_t fsizemb; + uint64_t fsizemib; path = strdup(pathspec); if (!path) { @@ -157,14 +162,14 @@ static void pmb_parse_path(const char *pathspec, char **ppath, uint64_t *pbsize, /* extract sizes, if given */ s = strrchr(path, ','); - if (s && (fsizemb = strtoull(s + 1, NULL, 10))) { + if (s && (fsizemib = strtoull(s + 1, NULL, 10))) { *s = 0; s = strrchr(path, ','); if (s && (bsize = strtoull(s + 1, NULL, 10))) { *s = 0; *ppath = path; *pbsize = bsize; - *pfsize = fsizemb << 20; + *pfsize = fsizemib << 20; return; } } @@ -215,6 +220,8 @@ static fio_pmemblk_file_t pmb_open(const char *pathspec, int flags) pmb->pmb_nblocks = pmemblk_nblock(pmb->pmb_pool); fio_pmemblk_cache_insert(pmb); + } else { + free(path); } pmb->pmb_refcnt += 1; @@ -295,26 +302,26 @@ static int fio_pmemblk_open_file(struct thread_data *td, struct fio_file *f) if (!pmb) return 1; - FIOFILEPMBSET(f, pmb); + FILE_SET_ENG_DATA(f, pmb); return 0; } static int fio_pmemblk_close_file(struct thread_data fio_unused *td, struct fio_file *f) { - fio_pmemblk_file_t pmb = FIOFILEPMBGET(f); + fio_pmemblk_file_t pmb = FILE_ENG_DATA(f); if (pmb) pmb_close(pmb, false); - FIOFILEPMBSET(f, NULL); + FILE_SET_ENG_DATA(f, NULL); return 0; } static int fio_pmemblk_get_file_size(struct thread_data *td, struct fio_file *f) { uint64_t flags = 0; - fio_pmemblk_file_t pmb = FIOFILEPMBGET(f); + fio_pmemblk_file_t pmb = FILE_ENG_DATA(f); if (fio_file_size_known(f)) return 0; @@ -331,16 +338,17 @@ static int fio_pmemblk_get_file_size(struct thread_data *td, struct fio_file *f) fio_file_set_size_known(f); - if (!FIOFILEPMBGET(f)) + if (!FILE_ENG_DATA(f)) pmb_close(pmb, true); return 0; } -static int fio_pmemblk_queue(struct thread_data *td, struct io_u *io_u) +static enum fio_q_status fio_pmemblk_queue(struct thread_data *td, + struct io_u *io_u) { struct fio_file *f = io_u->file; - fio_pmemblk_file_t pmb = FIOFILEPMBGET(f); + fio_pmemblk_file_t pmb = FILE_ENG_DATA(f); unsigned long long off; unsigned long len; @@ -418,7 +426,7 @@ static int fio_pmemblk_unlink_file(struct thread_data *td, struct fio_file *f) return 0; } -static struct ioengine_ops ioengine = { +FIO_STATIC struct ioengine_ops ioengine = { .name = "pmemblk", .version = FIO_IOOPS_VERSION, .queue = fio_pmemblk_queue,