Commit 8068d1ae authored by Marc Vef's avatar Marc Vef
Browse files

Merge branch 'random-IO' into 'master'



Random IO

See merge request zdvresearch_bsc/adafs!36

Signed-off-by: default avatarMarc Vef <vef@uni-mainz.de>
parents 236e9201 1b9095b0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -95,8 +95,8 @@ void read_file_abt(void* _arg) {
    chnk_path /= fmt::FormatInt(arg->chnk_id).c_str();;

    int fd = open(chnk_path.c_str(), R_OK);
    if (fd < 0) {
        read_size = static_cast<size_t>(EIO);
    if (fd < 0) { //the case that file does not exist e.g sparse file or random write
        read_size = static_cast<size_t>(0); 
        ABT_eventual_set(arg->eventual, &read_size, sizeof(size_t));
        return;
    }
+2 −4
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ int get_metadentry_size(const string& path, size_t& ret_size) {
 * @return the updated size
 */
int update_metadentry_size(const string& path, size_t io_size, off64_t offset, bool append, size_t& read_size) {
    // XXX This function has to be completely atomic. Do we need transactions here? or a separate locking db?
    // XXX This function will be replaced soon by the rocksdb function - just to test for the random IO
#ifdef LOG_TRACE
    db_iterate_all_entries();
#endif
@@ -118,15 +118,13 @@ int update_metadentry_size(const string& path, size_t io_size, off64_t offset, b
        return ENOENT;
    }
    Metadata md{path, val};
    if (static_cast<unsigned long>(offset) > md.size()) // Writing beyond file dimensions is prohibited for now XXX
        return EFAULT;
    // update io_size
    if (append)
        md.size(md.size() + io_size);
    else { // if no append but io_size exceeds the file's size, update the size correspondingly
        if (io_size + static_cast<unsigned long>(offset) > md.size())
            md.size(io_size + offset);
        else {
        else { // if not keep the current size
            read_size = md.size();
            return 0;
        }
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ ssize_t adafs_pread_ws(int fd, void* buf, size_t count, off64_t offset) {
    init_ld_env_if_needed();
    auto adafs_fd = file_map.get(fd);
    auto path = make_shared<string>(adafs_fd->path());

    memset(buf, 0, sizeof(char)*count);
    auto ret = rpc_send_read(*path, buf, offset, count);
    if (ret < 0) {
        ld_logger->warn("{}() rpc_send_read failed with ret {}", __func__, ret);
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ int main(int argc, char* argv[]) {
        cerr << "Error opening file (write)" << endl;
        return -1;
    }
    auto nw = write(fd, buffIn, strlen(buffIn));
    auto nw = pwrite(fd, buffIn, strlen(buffIn), 10000);
    if(nw != strlen(buffIn)){
        cerr << "Error writing file" << endl;
        return -1;