Verified Commit f0eeebcd authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

Improoved trace log on read/write

parent 290fe440
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -298,6 +298,7 @@ ssize_t adafs_pwrite_ws(int fd, const void* buf, size_t count, off64_t offset) {
    init_ld_env_if_needed();
    auto adafs_fd = CTX->file_map()->get(fd);
    auto path = make_shared<string>(adafs_fd->path());
    CTX->log()->trace("{}() fd: {}, count: {}, offset: {}", __func__, fd, count, offset);
    auto append_flag = adafs_fd->get_flag(OpenFile_flags::append);
    ssize_t ret = 0;
    long updated_size = 0;
@@ -318,6 +319,7 @@ ssize_t adafs_pread_ws(int fd, void* buf, size_t count, off64_t offset) {
    init_ld_env_if_needed();
    auto adafs_fd = CTX->file_map()->get(fd);
    auto path = make_shared<string>(adafs_fd->path());
    CTX->log()->trace("{}() fd: {}, count: {}, offset: {}", __func__, fd, count, offset);
    // Zeroing buffer before read is only relevant for sparse files. Otherwise sparse regions contain invalid data.
#if defined(ZERO_BUFFER_BEFORE_READ)
    memset(buf, 0, sizeof(char)*count);
+2 −1
Original line number Diff line number Diff line
@@ -842,7 +842,7 @@ ssize_t readv(int fd, const struct iovec *iov, int iovcnt) {
ssize_t read(int fd, void* buf, size_t count) {
    init_passthrough_if_needed();
    if(CTX->initialized()) {
        CTX->log()->trace("{}() called with fd {}", __func__, fd);
        CTX->log()->trace("{}() called with fd {}, count {}", __func__, fd, count);
        if (CTX->file_map()->exist(fd)) {
            auto adafs_fd = CTX->file_map()->get(fd);
            auto pos = adafs_fd->pos(); //retrieve the current offset
@@ -851,6 +851,7 @@ ssize_t read(int fd, void* buf, size_t count) {
            if (ret > 0) {
                adafs_fd->pos(pos + ret);
            }
            CTX->log()->trace("{}() returning {}", __func__, ret);
            return ret;
        }
    }