Skip to content

Commit

Permalink
DAOS-16556 client: call fstat() before mmap() to update file status i…
Browse files Browse the repository at this point in the history
…n kernel (#15244)

Signed-off-by: Lei Huang <lei.huang@intel.com>
  • Loading branch information
wiliamhuang authored Oct 10, 2024
1 parent d6ae532 commit 032849e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/client/dfuse/pil4dfs/int_dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -6302,6 +6302,14 @@ new_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)

atomic_fetch_add_relaxed(&num_mmap, 1);

if ((fd < FD_FILE_BASE) && (fd_directed >= FD_FILE_BASE) && d_compatible_mode) {
/* DAOS-14494: Force the kernel to update the size before mapping. */
rc = next_fxstat(1, fd, &stat_buf);
if (rc == -1)
return MAP_FAILED;
return next_mmap(addr, length, prot, flags, fd, offset);
}

addr_ret = next_mmap(addr, length, prot, flags | MAP_ANONYMOUS, -1, offset);
if (addr_ret == MAP_FAILED)
return MAP_FAILED;
Expand Down Expand Up @@ -7086,10 +7094,8 @@ init_myhook(void)

register_a_hook("libc", "fcntl", (void *)new_fcntl, (long int *)(&libc_fcntl));

if (d_compatible_mode == false) {
register_a_hook("libc", "mmap", (void *)new_mmap, (long int *)(&next_mmap));
register_a_hook("libc", "munmap", (void *)new_munmap, (long int *)(&next_munmap));
}
register_a_hook("libc", "mmap", (void *)new_mmap, (long int *)(&next_mmap));
register_a_hook("libc", "munmap", (void *)new_munmap, (long int *)(&next_munmap));

register_a_hook("libc", "exit", (void *)new_exit, (long int *)(&next_exit));
register_a_hook("libc", "dup3", (void *)new_dup3, (long int *)(&libc_dup3));
Expand Down

0 comments on commit 032849e

Please sign in to comment.