- w = f->windows + wt;
-
- if (_likely_(w->ptr &&
- w->offset <= offset &&
- w->offset + w->size >= offset + size)) {
-
- *ret = (uint8_t*) w->ptr + (offset - w->offset);
- return 0;
- }
-
- if (w->ptr) {
- if (munmap(w->ptr, w->size) < 0)
- return -errno;
-
- w->ptr = NULL;
- w->size = w->offset = 0;
- }
-
- if (size < DEFAULT_WINDOW_SIZE) {
- /* If the default window size is larger then what was
- * asked for extend the mapping a bit in the hope to
- * minimize needed remappings later on. We add half
- * the window space before and half behind the
- * requested mapping */
-
- delta = (DEFAULT_WINDOW_SIZE - size) / 2;
-
- if (delta > offset)
- delta = offset;
-
- offset -= delta;
- size = DEFAULT_WINDOW_SIZE;
- } else
- delta = 0;
-
- if (offset + size > (uint64_t) f->last_stat.st_size)
- size = (uint64_t) f->last_stat.st_size - offset;
-
- if (size <= 0)
- return -EADDRNOTAVAIL;
-
- r = journal_file_map(f,
- offset, size,
- &w->ptr, &w->offset, &w->size,
- &p);
-
- if (r < 0)
- return r;
-
- *ret = (uint8_t*) p + delta;
- return 0;
+ return mmap_cache_get(f->mmap, f->fd, f->prot, context, offset, size, ret);