Increase the space of an existing file using libpmem.

41 views
Skip to first unread message

Herold Christian

unread,
Jul 31, 2019, 7:17:52 AM7/31/19
to pmem
Is it possible to increase the space of an existing file?
Currently, I used ftruncate from POSIX. Is there a way with libpmem?

I have also another question:
Is it possible to increase the space of an mapped file?

Cheers,
Christian

Steve Scargall

unread,
Aug 1, 2019, 1:13:56 PM8/1/19
to pmem
Hi Christian,

It is currently not possible to grow an existing file/pool directly.  You can achieve the desired result by creating a persistent memory pool consisting of one or more file parts.  We call this a "pool set".  See the poolset man page (http://pmem.io/pmdk/manpages/linux/v1.6/poolset/poolset.5).  Also, see the heap.size.granularity and heap.size.extend CTL entry points here:
https://pmem.io/pmdk/manpages/linux/master/libpmemobj/pmemobj_ctl_get.3.  The poolset(5) man page shows an example of concatenating 3 files of different sizes across different mount points (not a requirement btw):

File: mypool.set
PMEMPOOLSET
OPTION NOHDRS
100G /mountpoint0/myfile.part0
200G /mountpoint1/myfile.part1
400G /mountpoint2/myfile.part2


In this example, if your application was to open the "mypool.set" instead of the underlying pool file (memory-mapped file), you would get a 700GB pool.  If you added another 100G file to mypool.set, it would grow to 800GB.  All file parts can reside on the same file system or multiple file systems as shown above.  Poolsets also allow for remote replication across nodes.  For automatic growth of poolsets, review the DIRECTORIES section of the poolset(5) man page.  If you're switching from a single pool/file to a poolset you'll need to restart the app.

HTH
   Steve


Steve Scargall

unread,
Aug 1, 2019, 1:25:37 PM8/1/19
to pmem
Correction: You can grow a single file/pool using the *truncate command in Linux.  There's an open feature request for "pmempool resize" that would assist in the simple cases (https://github.com/pmem/issues/issues/875)
Reply all
Reply to author
Forward
0 new messages