-
Notifications
You must be signed in to change notification settings - Fork 230
[Feature] Support resending fuse requests when restoring nydusd. #1740
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1740 +/- ##
==========================================
- Coverage 55.54% 55.48% -0.06%
==========================================
Files 197 197
Lines 53122 53188 +66
Branches 44443 44509 +66
==========================================
+ Hits 29507 29512 +5
- Misses 22144 22205 +61
Partials 1471 1471
🚀 New features to boost your workflow:
|
service/src/fusedev.rs
Outdated
|
||
let fd = file.as_raw_fd(); | ||
let mut buf = vec![0u8; session.bufsize()]; | ||
let writer: FuseDevWriter = FuseDevWriter::new(fd, &mut buf).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.
let writer: FuseDevWriter = FuseDevWriter::new(fd, &mut buf).unwrap(); | |
let writer: FuseDevWriter = FuseDevWriter::new(fd, &mut buf)?; |
It is more appropriate to use the ? operator.
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.
Thanks for this suggestion. I'll fix it.
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.
se.with_writer(|writer| {
self.server
.notify_resend(writer)
.unwrap_or_else(|e| println!("failed to send resend notification {}", e));
});
I think we have expose a with_writer on session to make it easy to acquire writer from session
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.
se.with_writer(|writer| { self.server .notify_resend(writer) .unwrap_or_else(|e| println!("failed to send resend notification {}", e)); });
I think we have expose a with_writer on session to make it easy to acquire writer from session
I noticed with_writer
, but I need the error returned by notify_resend
.
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.
ok, I see.
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.
cloud-hypervisor/fuse-backend-rs#216
I make a PR to update the with_writer to try_with_writer to handle error properly, let me know if that satisfy your expectation
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.
cloud-hypervisor/fuse-backend-rs#216 I make a PR to update the with_writer to try_with_writer to handle error properly, let me know if that satisfy your expectation
Yes, I need it. I'll update my code after fuse-backend-rs version of nydusd getting updated.
src/bin/nydusd/main.rs
Outdated
Arg::new("failover-policy") | ||
.long("failover-policy") | ||
.default_value("resend") | ||
.default_value("none") |
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.
Maybe keep resend as default value.
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.
OK, I'll fix it.
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.
Any updates?
service/src/fusedev.rs
Outdated
.ok_or(NydusError::FuseFileNotFound)?; | ||
|
||
let fd = file.as_raw_fd(); | ||
let mut buf = vec![0u8; session.bufsize()]; |
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.
Maybe it's better to put buf allocation out of the lock
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.
OK, I'll fix it.
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.
Maybe it's better to put buf allocation out of the lock
But we maybe have to lock session before we get the bufsize.
service/src/fusedev.rs
Outdated
fn notify_resend_by_sysfs(&self) -> NydusResult<()> { | ||
// Notify the kernel to resend the request by writing to `/sys/fs/fuse/connections/<cid>/resend` | ||
let path = format!( | ||
"/sys/fs/fuse/connections/{}/resend", |
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.
try to avoid fusectl path hardcode: /sys/fs/fuse/connections/{}/resend
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.
OK, I'll fix it.
service/src/fusedev.rs
Outdated
fn notify_flush_by_sysfs(&self) -> NydusResult<()> { | ||
// Notify the kernel to flush the request by writing to `/sys/fs/fuse/connections/<cid>/flush` | ||
let path = format!( | ||
"/sys/fs/fuse/connections/{}/flush", |
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.
the same
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.
OK, I'll fix it.
01d85b5
to
b85ccb1
Compare
src/bin/nydusd/main.rs
Outdated
Arg::new("failover-policy") | ||
.long("failover-policy") | ||
.default_value("resend") | ||
.default_value("none") |
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.
Any updates?
service/src/fusedev.rs
Outdated
} | ||
} | ||
|
||
Err(open_error.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.
How about:
for (idx, path) in paths.iter().enumerate() {
match self.try_notify_with_path(base_path, event) {
Ok(()) => return Ok(()),
Err(e) => {
if !matches!(e, NydusError::SysfsOpenError(_)) ||
idx == paths.len() - 1 {
return Err(e);
}
}
}
}
Ok(())
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.
OK, this looks better.
b85ccb1
to
f57e4ec
Compare
Resend the fuse request when nydusd undergoes a hot upgrade or during a fault recovery process. Support resend requests by fuse device and sysfs. Signed-off-by: Sicheng Liu <lsc2001@outlook.com>
f57e4ec
to
76a3f7a
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.
Thanks, LGTM!
Relevant Issue
#1697
Details
Support resending the fuse request when nydusd undergoes a hot upgrade or during a fault recovery process.
Requests can be resend by fuse device and sysfs.
Types of changes
What types of changes does your PullRequest introduce? Put an
x
in all the boxes that apply: