Skip to content

Commit

Permalink
DAOS-16286 client: intercept fdatasync() (#14835)
Browse files Browse the repository at this point in the history
Signed-off-by: Lei Huang <lei.huang@intel.com>
  • Loading branch information
wiliamhuang authored Jul 31, 2024
1 parent 26df545 commit a0af03d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/client/dfuse/pil4dfs/int_dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ static int (*next_unlinkat)(int dirfd, const char *path, int flags);

static int (*next_fsync)(int fd);

static int (*next_fdatasync)(int fd);

static int (*next_truncate)(const char *path, off_t length);

static int (*next_ftruncate)(int fd, off_t length);
Expand Down Expand Up @@ -5309,6 +5311,28 @@ fsync(int fd)
return 0;
}

int
fdatasync(int fd)
{
int fd_directed;

if (next_fdatasync == NULL) {
next_fdatasync = dlsym(RTLD_NEXT, "fdatasync");
D_ASSERT(next_fdatasync != NULL);
}
if (!d_hook_enabled)
return next_fdatasync(fd);

fd_directed = d_get_fd_redirected(fd);
if (fd_directed < FD_FILE_BASE)
return next_fdatasync(fd);

if (fd < FD_DIR_BASE && d_compatible_mode)
return next_fdatasync(fd);

return 0;
}

int
ftruncate(int fd, off_t length)
{
Expand Down
4 changes: 4 additions & 0 deletions src/tests/suite/dfuse_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ do_openat(void **state)
rc = write(fd, input_buf, sizeof(input_buf));
assert_return_code(rc, errno);

/* test fdatasync() */
rc = fdatasync(fd);
assert_return_code(rc, errno);

/* First fstat. IL will forward this to the kernel so it can save ino for future calls */
rc = fstat(fd, &stbuf0);
assert_return_code(rc, errno);
Expand Down

0 comments on commit a0af03d

Please sign in to comment.