Commit e8c05a22 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/ram_shmfs: Warn users explicitly if fallocate() is not supported

Currently wendelin.core does not work on e.g. Debian 7, because that
distro has too old kernel without support for fallocate on tmpfs.
But the diagnostics of failure is not clear and looks like just being
out of memory:

    bigfile/tests/../virtmem.c:845 OOM      BUG!

what happens in fact is that

    - virtmem tries to allocate a page -> calls shmfs_alloc_page(),
    - fallocate() fails with "operation not supported" error code
    - virtmem sees this as page allocation failure,
    - tries to reclaim pages,
    - but there are no allocated pages at all -> OOM

Detect whether fallocate() error is operational error, or simply
"fallocate not supported" and if latter, report to user. Now it looks
like:

    bigfile/tests/../ram_shmfs.c:129 shmfs_alloc_page WARN: fallocate() not supported
    bigfile/tests/../virtmem.c:845 OOM      BUG!

/cc @Tyagov
parent ab9ca2df
......@@ -41,6 +41,7 @@
#include <sys/vfs.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <errno.h>
/* we'll manage RAM in "pages" of 2M
......@@ -122,8 +123,12 @@ pgoff_t shmfs_alloc_page(RAMH *ramh0, pgoff_t pgoffset_hint)
err = fallocate(ramh->ramh_fd, 0 /* without KEEP_SIZE */,
ramh_pgoffset * pagesize, pagesize);
if (err)
if (err) {
/* warn users explicitly, if fallocate() is not supported */
if (errno == EOPNOTSUPP)
WARN("fallocate() not supported");
return RAMH_PGOFF_ALLOCFAIL;
}
if (ramh_pgoffset >= ramh->ramh_fpgsize)
ramh->ramh_fpgsize = ramh_pgoffset+1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment