Skip to content

Commit c043134

Browse files
rock-gitchuandew
authored andcommitted
[feat][mds] Support file and dir read cache at fuse.
1 parent 2e9f27a commit c043134

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/client/fuse/fuse_op.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,12 @@ void FuseOpOpen(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) {
400400
ReplyError(req, s);
401401
} else {
402402
fi->fh = fh;
403-
fi->direct_io = FLAGS_client_fuse_file_info_direct_io ? 1 : 0;
403+
404+
fi->direct_io =
405+
(dingofs::IsInternalNode(ino) || FLAGS_client_fuse_file_info_direct_io)
406+
? 1
407+
: 0;
404408
fi->keep_cache = FLAGS_client_fuse_file_info_keep_cache ? 1 : 0;
405-
if (dingofs::IsInternalNode(ino)) {
406-
fi->direct_io = 1;
407-
}
408409

409410
ReplyOpen(req, fi);
410411
}
@@ -478,6 +479,10 @@ void FuseOpOpenDir(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) {
478479
ReplyError(req, s);
479480
} else {
480481
fi->fh = fh;
482+
483+
fi->cache_readdir = FLAGS_client_fuse_file_info_keep_cache ? 1 : 0;
484+
fi->keep_cache = FLAGS_client_fuse_file_info_keep_cache ? 1 : 0;
485+
481486
ReplyOpen(req, fi);
482487
}
483488
}
@@ -704,6 +709,13 @@ void FuseOpCreate(fuse_req_t req, fuse_ino_t parent, const char* name,
704709
ReplyError(req, s);
705710
} else {
706711
fi->fh = fh;
712+
713+
fi->direct_io = (dingofs::IsInternalNode(attr.ino) ||
714+
FLAGS_client_fuse_file_info_direct_io)
715+
? 1
716+
: 0;
717+
fi->keep_cache = FLAGS_client_fuse_file_info_keep_cache ? 1 : 0;
718+
707719
ReplyCreate(req, fi, attr);
708720
}
709721
}

src/mds/filesystem/store_operation.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,11 +1171,12 @@ Status OpenFileOperation::RunInBatch(TxnUPtr& txn, AttrEntry& attr, const std::v
11711171
if (flags_ & O_TRUNC) {
11721172
result_.delta_bytes = -static_cast<int64_t>(attr.length());
11731173
attr.set_length(0);
1174+
1175+
attr.set_ctime(std::max(attr.ctime(), GetTime()));
1176+
attr.set_mtime(std::max(attr.mtime(), GetTime()));
11741177
}
11751178

11761179
attr.set_atime(std::max(attr.atime(), GetTime()));
1177-
attr.set_ctime(std::max(attr.ctime(), GetTime()));
1178-
attr.set_mtime(std::max(attr.mtime(), GetTime()));
11791180

11801181
// add file session
11811182
txn->Put(MetaCodec::EncodeFileSessionKey(file_session_.fs_id(), file_session_.ino(), file_session_.session_id()),

0 commit comments

Comments
 (0)