Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6012] feat (gvfs-fuse): Support Gravitino S3 fileset filesystem operation in gvfs fuse #6013

Merged
merged 116 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
f025216
Add SimpleFilesystem
diqiu50 Dec 17, 2024
97e066d
Update
diqiu50 Dec 17, 2024
d0b6958
Add uts
diqiu50 Dec 17, 2024
3769400
Fix test error
diqiu50 Dec 17, 2024
3ecb980
Update comments
diqiu50 Dec 17, 2024
4fe58f2
Fix ci error
diqiu50 Dec 17, 2024
a55bff8
Add description of gvfs-fuse filesystem struct
diqiu50 Dec 18, 2024
58922e1
Update
diqiu50 Dec 18, 2024
cda8275
Update
diqiu50 Dec 18, 2024
5f93717
Update
diqiu50 Dec 18, 2024
39e55fe
Update for review
diqiu50 Dec 18, 2024
366c77a
Update
diqiu50 Dec 18, 2024
33dc3bd
Update
diqiu50 Dec 18, 2024
865f213
Update
diqiu50 Dec 18, 2024
2570eb8
Update
diqiu50 Dec 18, 2024
bfd3945
Update
diqiu50 Dec 19, 2024
4fb77e1
Update
diqiu50 Dec 19, 2024
8cf0c4a
Update
diqiu50 Dec 19, 2024
21b080d
Update
diqiu50 Dec 19, 2024
4fe5fe3
Update
diqiu50 Dec 19, 2024
2517afa
Update
diqiu50 Dec 19, 2024
d32cd6a
Add
diqiu50 Dec 19, 2024
53e4c4e
remove unused mod
diqiu50 Dec 19, 2024
568fefe
Update
diqiu50 Dec 20, 2024
76305a9
Update
diqiu50 Dec 20, 2024
5459622
Update path interface
diqiu50 Dec 20, 2024
1ea53ef
Merge branch 'gvfs-pr2' into gvfs-pr3
diqiu50 Dec 20, 2024
dbca557
Fix error
diqiu50 Dec 20, 2024
d444ad3
Fix
diqiu50 Dec 20, 2024
2570f54
Update
diqiu50 Dec 23, 2024
f6ce011
Update
diqiu50 Dec 23, 2024
8fb13bb
Update
diqiu50 Dec 23, 2024
e23a589
Update
diqiu50 Dec 23, 2024
e8c74f6
Update
diqiu50 Dec 23, 2024
b99af10
Update
diqiu50 Dec 24, 2024
4dd5bf4
Update
diqiu50 Dec 24, 2024
01d90a6
Update
diqiu50 Dec 24, 2024
14609cf
Update
diqiu50 Dec 24, 2024
127cb41
Update
diqiu50 Dec 24, 2024
df48db4
Update
diqiu50 Dec 24, 2024
37a46d6
Update
diqiu50 Dec 24, 2024
2bd05da
Merge branch 'gvfs-pr2' into gvfs-pr3
diqiu50 Dec 24, 2024
364ce34
Merge remote-tracking branch 'gt/branch-gvfs-fuse-dev' into gvfs-pr3
diqiu50 Dec 24, 2024
3a863ed
Update
diqiu50 Dec 24, 2024
406641b
Update
diqiu50 Dec 24, 2024
0e512fc
Update
diqiu50 Dec 24, 2024
da02b01
Add testers
diqiu50 Dec 24, 2024
c043b95
Fix test
diqiu50 Dec 24, 2024
d4da504
Add testers
diqiu50 Dec 24, 2024
3b12f11
Change v1
diqiu50 Dec 25, 2024
252d399
Temp
diqiu50 Dec 25, 2024
1debe02
Merge remote-tracking branch 'gt/branch-gvfs-fuse-dev' into gvfs-pr4
diqiu50 Dec 25, 2024
573c80b
Update
diqiu50 Dec 25, 2024
f9c4546
refact config
diqiu50 Dec 26, 2024
40d1543
Update
diqiu50 Dec 26, 2024
7071618
Add error handling
diqiu50 Dec 26, 2024
81f5e71
fix testers
diqiu50 Dec 26, 2024
4fcd913
Update
diqiu50 Dec 26, 2024
757a486
Udpate
diqiu50 Dec 26, 2024
01e6f6e
Fix error
diqiu50 Dec 26, 2024
0677f2f
Add comments
diqiu50 Dec 26, 2024
0eecbd8
Fix some errors
diqiu50 Dec 26, 2024
f78adee
Support s3
diqiu50 Dec 26, 2024
e702a88
split fs creator
diqiu50 Dec 26, 2024
33e1588
Update conf
diqiu50 Dec 26, 2024
97ff491
Merge branch 'gvfs-pr4' into gvfs-pr5
diqiu50 Dec 26, 2024
b6d6201
Add opendal error
diqiu50 Dec 26, 2024
5fa74f6
Add
diqiu50 Dec 26, 2024
17ddd8f
Add
diqiu50 Dec 26, 2024
05ef46a
Update clients/filesystem-fuse/src/config.rs
diqiu50 Dec 27, 2024
254627d
Update clients/filesystem-fuse/src/gvfs_fuse.rs
diqiu50 Dec 27, 2024
b2558fc
Update clients/filesystem-fuse/src/config.rs
diqiu50 Dec 27, 2024
16437c3
Update for review
diqiu50 Dec 27, 2024
8296ea0
Update
diqiu50 Dec 27, 2024
2223415
Merge branch 'gvfs-pr4' into gvfs-pr5
diqiu50 Dec 27, 2024
def5957
Fix config error
diqiu50 Dec 27, 2024
86e5308
Fix error
diqiu50 Dec 27, 2024
bdd0928
Fix error
diqiu50 Dec 27, 2024
b2564cc
Fix config error
diqiu50 Dec 27, 2024
c0c4a72
Fix
diqiu50 Dec 27, 2024
671afca
Merge branch 'gvfs-pr4' into gvfs-pr5
diqiu50 Dec 27, 2024
06f5c23
Update main
diqiu50 Dec 27, 2024
fdc72e1
Fix
diqiu50 Dec 27, 2024
fd78faf
Update
diqiu50 Dec 27, 2024
e474d04
Update
diqiu50 Dec 30, 2024
18400c2
Update
diqiu50 Dec 30, 2024
735466e
Update
diqiu50 Dec 30, 2024
166770b
Update
diqiu50 Dec 30, 2024
ec55465
Update
diqiu50 Dec 30, 2024
3c78ab1
Fix ci error
diqiu50 Dec 30, 2024
220b6d5
Update
diqiu50 Dec 30, 2024
d471fe5
Add
diqiu50 Dec 30, 2024
99e73be
Update
diqiu50 Dec 30, 2024
18ffaf5
Fix bugs
diqiu50 Dec 31, 2024
fcc8b9e
Update
diqiu50 Dec 31, 2024
4b6c737
Update
diqiu50 Dec 31, 2024
28cf414
Fix
diqiu50 Dec 31, 2024
101bf6e
Merge branch 'gvfs-pr4' into gvfs-pr5
diqiu50 Dec 31, 2024
fe34265
Merge branch 'branch-gvfs-fuse-dev' into gvfs-pr5
diqiu50 Dec 31, 2024
1d46c07
Fix
diqiu50 Dec 31, 2024
816573c
Update
diqiu50 Dec 31, 2024
7e4d21f
managed the .gvfs_meta file by DefaultRawFileSystem
diqiu50 Dec 31, 2024
bd4de61
Update
diqiu50 Dec 31, 2024
02c28ef
Add testers for s3fs
diqiu50 Dec 31, 2024
b5bfd18
Update testers
diqiu50 Dec 31, 2024
0462f11
Update
diqiu50 Dec 31, 2024
3ddb5a3
Update
diqiu50 Jan 2, 2025
61418c9
Update
diqiu50 Jan 2, 2025
a3cb1da
Fix
diqiu50 Jan 2, 2025
8cb7daf
Add UT for s3fs
diqiu50 Jan 2, 2025
d0bb9d8
Fix
diqiu50 Jan 3, 2025
50f1931
Handle args
diqiu50 Jan 3, 2025
aeffc3c
Fix
diqiu50 Jan 3, 2025
c175ec7
Fix
diqiu50 Jan 3, 2025
aafffdf
Fix
diqiu50 Jan 3, 2025
ec03ba8
Fix
diqiu50 Jan 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clients/filesystem-fuse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ futures-util = "0.3.30"
libc = "0.2.168"
log = "0.4.22"
once_cell = "1.20.2"
opendal = { version = "0.46.0", features = ["services-s3"] }
reqwest = { version = "0.12.9", features = ["json"] }
serde = { version = "1.0.216", features = ["derive"] }
tokio = { version = "1.38.0", features = ["full"] }
Expand Down
6 changes: 3 additions & 3 deletions clients/filesystem-fuse/conf/gvfs_fuse.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ block_size = 8192
uri = "http://localhost:8090"
metalake = "your_metalake"

# extent settings
# extend settings
[extend_config]
access_key = "your access_key"
secret_key = "your_secret_key"
s3-access_key_id = "your access_key"
s3-secret_access_key = "your_secret_key"
6 changes: 3 additions & 3 deletions clients/filesystem-fuse/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,18 @@ mod test {

#[test]
fn test_config_from_file() {
let config = AppConfig::from_file(Some("tests/conf/gvfs_fuse_test.toml")).unwrap();
let config = AppConfig::from_file(Some("tests/conf/config_test.toml")).unwrap();
assert_eq!(config.fuse.file_mask, 0o644);
assert_eq!(config.fuse.dir_mask, 0o755);
assert_eq!(config.filesystem.block_size, 8192);
assert_eq!(config.gravitino.uri, "http://localhost:8090");
assert_eq!(config.gravitino.metalake, "test");
assert_eq!(
config.extend_config.get("access_key"),
config.extend_config.get("s3-access_key_id"),
Some(&"XXX_access_key".to_string())
);
assert_eq!(
config.extend_config.get("secret_key"),
config.extend_config.get("s3-secret_access_key"),
Some(&"XXX_secret_key".to_string())
);
}
Expand Down
98 changes: 77 additions & 21 deletions clients/filesystem-fuse/src/default_raw_filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
use crate::config::AppConfig;
use crate::filesystem::{
FileStat, FileSystemContext, PathFileSystem, RawFileSystem, Result, INITIAL_FILE_ID,
ROOT_DIR_FILE_ID, ROOT_DIR_PARENT_FILE_ID, ROOT_DIR_PATH,
FileStat, FileSystemContext, PathFileSystem, RawFileSystem, Result, FS_META_FILE_ID,
FS_META_FILE_NAME, FS_META_FILE_PATH, INITIAL_FILE_ID, ROOT_DIR_FILE_ID,
ROOT_DIR_PARENT_FILE_ID, ROOT_DIR_PATH,
};
use crate::opened_file::{FileHandle, OpenFileFlags};
use crate::opened_file::{FileHandle, OpenFileFlags, OpenedFile};
use crate::opened_file_manager::OpenedFileManager;
use async_trait::async_trait;
use bytes::Bytes;
Expand Down Expand Up @@ -78,6 +79,7 @@ impl<T: PathFileSystem> DefaultRawFileSystem<T> {
}

async fn resolve_file_id_to_filestat(&self, file_stat: &mut FileStat, parent_file_id: u64) {
debug_assert!(parent_file_id != 0);
let mut file_manager = self.file_entry_manager.write().await;
let file_entry = file_manager.get_file_entry_by_path(&file_stat.path);
match file_entry {
Expand Down Expand Up @@ -132,6 +134,21 @@ impl<T: PathFileSystem> DefaultRawFileSystem<T> {
let mut file_manager = self.file_entry_manager.write().await;
file_manager.insert(parent_file_id, file_id, path);
}

fn get_meta_file_stat(&self) -> FileStat {
let mut meta_file_stat =
FileStat::new_file_filestat_with_path(Path::new(FS_META_FILE_PATH), 0);
meta_file_stat.set_file_id(ROOT_DIR_FILE_ID, FS_META_FILE_ID);
meta_file_stat
}

fn is_meta_file(&self, file_id: u64) -> bool {
file_id == FS_META_FILE_ID
}

fn is_meta_file_name(&self, parent_file_id: u64, name: &OsStr) -> bool {
parent_file_id == ROOT_DIR_FILE_ID && name == OsStr::new(FS_META_FILE_NAME)
}
}

#[async_trait]
Expand All @@ -144,6 +161,13 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
Path::new(ROOT_DIR_PATH),
)
.await;

self.insert_file_entry_locked(
ROOT_DIR_FILE_ID,
FS_META_FILE_ID,
Path::new(FS_META_FILE_PATH),
)
.await;
self.fs.init().await
}

Expand All @@ -168,15 +192,22 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
}

async fn stat(&self, file_id: u64) -> Result<FileStat> {
if self.is_meta_file(file_id) {
return Ok(self.get_meta_file_stat());
}

let file_entry = self.get_file_entry(file_id).await?;
let mut file_stat = self.fs.stat(&file_entry.path).await?;
file_stat.set_file_id(file_entry.parent_file_id, file_entry.file_id);
Ok(file_stat)
}

async fn lookup(&self, parent_file_id: u64, name: &OsStr) -> Result<FileStat> {
let parent_file_entry = self.get_file_entry(parent_file_id).await?;
if self.is_meta_file_name(parent_file_id, name) {
return Ok(self.get_meta_file_stat());
}

let parent_file_entry = self.get_file_entry(parent_file_id).await?;
let path = parent_file_entry.path.join(name);
let mut file_stat = self.fs.stat(&path).await?;
// fill the file id to file stat
Expand All @@ -192,10 +223,21 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
for file_stat in child_filestats.iter_mut() {
self.resolve_file_id_to_filestat(file_stat, file_id).await;
}

if file_id == ROOT_DIR_FILE_ID {
child_filestats.push(self.get_meta_file_stat());
}
Ok(child_filestats)
}

async fn open_file(&self, file_id: u64, flags: u32) -> Result<FileHandle> {
if self.is_meta_file(file_id) {
let meta_file = OpenedFile::new(self.get_meta_file_stat());
let resutl = self.opened_file_manager.put(meta_file);
let file = resutl.lock().await;
return Ok(file.file_handle());
}

self.open_file_internal(file_id, flags, FileType::RegularFile)
.await
}
Expand All @@ -211,6 +253,10 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
name: &OsStr,
flags: u32,
) -> Result<FileHandle> {
if self.is_meta_file_name(parent_file_id, name) {
return Err(Errno::from(libc::EEXIST));
}

let parent_file_entry = self.get_file_entry(parent_file_id).await?;
let mut file_without_id = self
.fs
Expand Down Expand Up @@ -247,11 +293,19 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
}

async fn set_attr(&self, file_id: u64, file_stat: &FileStat) -> Result<()> {
if self.is_meta_file(file_id) {
return Ok(());
}

let file_entry = self.get_file_entry(file_id).await?;
self.fs.set_attr(&file_entry.path, file_stat, true).await
}

async fn remove_file(&self, parent_file_id: u64, name: &OsStr) -> Result<()> {
if self.is_meta_file_name(parent_file_id, name) {
return Err(Errno::from(libc::EPERM));
}

let parent_file_entry = self.get_file_entry(parent_file_id).await?;
let path = parent_file_entry.path.join(name);
self.fs.remove_file(&path).await?;
Expand All @@ -271,6 +325,15 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
Ok(())
}

async fn flush_file(&self, _file_id: u64, fh: u64) -> Result<()> {
let opened_file = self
.opened_file_manager
.get(fh)
.ok_or(Errno::from(libc::EBADF))?;
let mut file = opened_file.lock().await;
file.flush().await
}

async fn close_file(&self, _file_id: u64, fh: u64) -> Result<()> {
let opened_file = self
.opened_file_manager
Expand All @@ -280,7 +343,11 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
file.close().await
}

async fn read(&self, _file_id: u64, fh: u64, offset: u64, size: u32) -> Result<Bytes> {
async fn read(&self, file_id: u64, fh: u64, offset: u64, size: u32) -> Result<Bytes> {
if self.is_meta_file(file_id) {
return Ok(Bytes::new());
}

let (data, file_stat) = {
let opened_file = self
.opened_file_manager
Expand All @@ -297,7 +364,11 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
data
}

async fn write(&self, _file_id: u64, fh: u64, offset: u64, data: &[u8]) -> Result<u32> {
async fn write(&self, file_id: u64, fh: u64, offset: u64, data: &[u8]) -> Result<u32> {
if self.is_meta_file(file_id) {
return Err(Errno::from(libc::EPERM));
}

let (len, file_stat) = {
let opened_file = self
.opened_file_manager
Expand Down Expand Up @@ -368,8 +439,6 @@ impl FileEntryManager {
#[cfg(test)]
mod tests {
use super::*;
use crate::filesystem::tests::TestRawFileSystem;
use crate::memory_filesystem::MemoryFileSystem;

#[test]
fn test_file_entry_manager() {
Expand All @@ -389,17 +458,4 @@ mod tests {
assert!(manager.get_file_entry_by_id(2).is_none());
assert!(manager.get_file_entry_by_path(Path::new("a/b")).is_none());
}

#[tokio::test]
async fn test_default_raw_file_system() {
FANNG1 marked this conversation as resolved.
Show resolved Hide resolved
let memory_fs = MemoryFileSystem::new().await;
let raw_fs = DefaultRawFileSystem::new(
memory_fs,
&AppConfig::default(),
&FileSystemContext::default(),
);
let _ = raw_fs.init().await;
let mut tester = TestRawFileSystem::new(raw_fs);
tester.test_raw_file_system().await;
}
}
2 changes: 2 additions & 0 deletions clients/filesystem-fuse/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub enum ErrorCode {
GravitinoClientError,
InvalidConfig,
ConfigNotFound,
OpenDalError,
}

impl ErrorCode {
Expand All @@ -39,6 +40,7 @@ impl std::fmt::Display for ErrorCode {
ErrorCode::GravitinoClientError => write!(f, "Gravitino client error"),
ErrorCode::InvalidConfig => write!(f, "Invalid config"),
ErrorCode::ConfigNotFound => write!(f, "Config not found"),
ErrorCode::OpenDalError => write!(f, "OpenDal error"),
}
}
}
Expand Down
Loading
Loading