-
Notifications
You must be signed in to change notification settings - Fork 390
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
[#5873] feat(gvfs-fuse): add debug log for FuseApiHandle #5905
base: main
Are you sure you want to change the base?
Conversation
9ae9ea0
to
3574bce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, we need to verify the log format to see if it meets expectations. This needs to be validated in the #5886, and you can wait for it to be merged.
} | ||
|
||
impl<T: RawFileSystem> Filesystem for FuseApiHandleDebug<T> { | ||
async fn init(&self, req: Request) -> fuse3::Result<ReplyInit> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to implement all interfaces of the Filesystem. If they are not implemented yet, an error log should be recorded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you implement all the Filesystem interfaces?
Please refer to other PRs for the format of PR titles and descriptions. |
d1bfdba
to
425c490
Compare
close and reopen to run workflow |
@diqiu50 Please help review this PR, Thanks. |
"readdir [id={}]: req: {:?}, parent: {:?}, fh: {:?}, offset: {:?}", | ||
req.unique, req, parent, fh, offset | ||
); | ||
let result = self.inner.readdir(req, parent, fh, offset).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to show dir entries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
req.unique, | ||
FileAttrDebug { | ||
file_attr: &reply.attr | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructing an object is not as clear as using a function like to_desc_string()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented some methods like reply_attr_to_desc_str
, reply_entry_to_desc_str
to manually control the format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, there is no issue. The readability of the logs needs to be improved and made more concise. Unimportant information can be ignored.
Implement a few methods for printing commonly used structures, without having to print them in the struct format
1d9ff8a
to
d619db0
Compare
@unknowntpo All the code are merged to the main brach. you need to merge the pr to main |
@diqiu50 Okay, (I'm still working this PR) |
d4627de
to
ec48523
Compare
479e7be
to
87e01ff
Compare
Note that I use e.g.
|
@diqiu50 Done, please take a look. |
… by fuse_debug option
… by fuse_debug option
0444a02
to
2ee68cf
Compare
@@ -46,6 +47,7 @@ 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"] } | |||
tracing = "0.1.41" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use tracing
instead of log
, please remove log
.
@@ -20,6 +20,7 @@ | |||
file_mask = 0o600 | |||
dir_mask = 0o700 | |||
fs_type = "memory" | |||
fuse_debug=true | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the format
@@ -265,6 +265,8 @@ pub struct FuseConfig { | |||
#[serde(default)] | |||
pub fs_type: String, | |||
#[serde(default)] | |||
pub fuse_debug: bool, | |||
#[serde(default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to handle default value like other configurations.
@@ -53,7 +53,7 @@ impl<T: RawFileSystem> FuseApiHandle<T> { | |||
} | |||
} | |||
|
|||
async fn get_modified_file_stat( | |||
pub async fn get_modified_file_stat( | |||
&self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use this function to retrieve the file name. use the RawFileSystem::get_file_path
|
||
/// Convert `ReplyAttr` to descriptive string. | ||
/// | ||
/// Example: `ttl: 1s, FileAttr: { ino: 10000, size: 0, blocks: 0, atime: "2025-01-16 02:42:52.600436", mtime: "2025-01-16 02:42:52.600436", ctime: "2025-01-16 02:42:52.600436", crtime: "2025-01-16 02:42:52.600436", kind: RegularFile, perm: 600, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 8192 }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long , you can format it like this.
/// Example: `ttl: 1s, FileAttr: { ino: 10000, size: 0, blocks: 0, atime: "2025-01-16 02:42:52.600436",
/// mtime: "2025-01-16 02:42:52.600436", ctime: "2025-01-16 02:42:52.600436", crtime: "2025-01-16
/// 02:42:52.600436", kind: RegularFile, perm: 600, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 8192 }`
|
||
/// Convert `ReplyAttr` to descriptive string. | ||
/// | ||
/// Example: `ttl: 1s, FileAttr: { ino: 10000, size: 0, blocks: 0, atime: "2025-01-16 02:42:52.600436", mtime: "2025-01-16 02:42:52.600436", ctime: "2025-01-16 02:42:52.600436", crtime: "2025-01-16 02:42:52.600436", kind: RegularFile, perm: 600, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 8192 }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long , you can format it like this.
/// Example: `ttl: 1s, FileAttr: { ino: 10000, size: 0, blocks: 0, atime: "2025-01-16 02:42:52.600436",
/// mtime: "2025-01-16 02:42:52.600436", ctime: "2025-01-16 02:42:52.600436", crtime: "2025-01-16
/// 02:42:52.600436", kind: RegularFile, perm: 600, nlink: 1, uid: 501, gid: 20, rdev: 0, flags: 0, blksize: 8192 }`
file_attr_to_desc_str(&reply_attr.attr) | ||
) | ||
.unwrap(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is better like this:
write!(output, "ttl: {:?}, FileAttr: {}, generation: {}",
reply_entry.ttl,
file_attr_to_desc_str(&reply_entry.attr),
reply_entry.generation).unwrap();
.inner | ||
.get_modified_file_stat(parent, Option::None, Option::None, Option::None) | ||
.await?; | ||
debug!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the debug code readable.
like :
debug!("format string", x1, x2, x3)
self.inner.readdirplus(req, parent, fh, offset, lock_owner), | ||
"readdirplus", | ||
req | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you print the child DirectoryEntry in the log?
I've checked your run logs, and they look pretty good. However, please pay attention to the following points:
|
This is the new format I came up with:
|
We need to print the directory list on a single line; otherwise, it’s hard to tell which request the result belongs to. |
Ok, I can put them in the same line like this
|
What changes were proposed in this pull request?
Implement
FuseApiHandleDebug
so we can log all input arguments and return values ofFuseApiHandle
.I use
tracing::debug
,tracing::error
with structure logging to format the message in key value pair format, so we don't need to control format manually.e.g.
And user can set
fuse_debug = true
in[fuse] section
at config file likegvfs_fuse_memory.toml
to decide whether they need fuse debug logging or not.Fix: #5873
Does this PR introduce any user-facing change?
No.
How was this patch tested?
tested with
fuse_test.rs
, along withMemoryFileSystem
.Now,
FuseApiHandleDebug
will wrapFuseApiHandle
and log all input arguments and returned values, if return value isResult
, we usematch
to extract and log the status of result, note that error will be logged if occured.To test this PR, set
fuse_debug = true
ingvfs_fuse_memory.toml
and run:Here's some example logging generated by
test_fuse_system_with_auto
infuse_test.rs
: