Commit ffcf68bb authored by Julius Plenz's avatar Julius Plenz

Call posix_fadvise twice to avoid race condition

The kernel tries once to lock the page to be freed. If this fails, it won't be freed. (This happens quite often, actually!)
parent 6f63abc2
......@@ -141,9 +141,12 @@ static void free_unclaimed_pages(int fd)
if(i == _MAX_FDS)
return; /* not found */
for(j = 0; j < fds[i].nr_pages; j++)
if(!(fds[i].info[j] & 1))
for(j = 0; j < fds[i].nr_pages; j++) {
if(!(fds[i].info[j] & 1)) {
fadv_dontneed(fd, j*PAGESIZE, PAGESIZE);
fadv_dontneed(fd, j*PAGESIZE, PAGESIZE);
}
}
/* forget written contents that go beyond previous file size */
fadv_dontneed(fd, fds[i].size, 0);
......
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