Skip to content

Conversation

lsc2001
Copy link
Contributor

@lsc2001 lsc2001 commented Aug 16, 2025

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:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

@lsc2001 lsc2001 requested a review from a team as a code owner August 16, 2025 04:38
@lsc2001 lsc2001 requested review from hsiangkao, jiangliu and power-more and removed request for a team August 16, 2025 04:38
Copy link

codecov bot commented Aug 16, 2025

Codecov Report

❌ Patch coverage is 9.33333% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.48%. Comparing base (0c53e00) to head (76a3f7a).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
service/src/fusedev.rs 0.00% 62 Missing ⚠️
service/src/upgrade.rs 58.33% 5 Missing ⚠️
src/bin/nydusd/main.rs 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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              
Files with missing lines Coverage Δ
service/src/lib.rs 79.03% <ø> (ø)
src/bin/nydusd/main.rs 0.00% <0.00%> (ø)
service/src/upgrade.rs 65.31% <58.33%> (+0.86%) ⬆️
service/src/fusedev.rs 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


let fd = file.as_raw_fd();
let mut buf = vec![0u8; session.bufsize()];
let writer: FuseDevWriter = FuseDevWriter::new(fd, &mut buf).unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Arg::new("failover-policy")
.long("failover-policy")
.default_value("resend")
.default_value("none")
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any updates?

.ok_or(NydusError::FuseFileNotFound)?;

let fd = file.as_raw_fd();
let mut buf = vec![0u8; session.bufsize()];

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

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",

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

Copy link
Contributor Author

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.

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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same

Copy link
Contributor Author

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.

Arg::new("failover-policy")
.long("failover-policy")
.default_value("resend")
.default_value("none")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any updates?

}
}

Err(open_error.unwrap())
Copy link
Collaborator

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(())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this looks better.

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>
Copy link
Collaborator

@imeoer imeoer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@imeoer imeoer merged commit 637a28a into dragonflyoss:master Sep 15, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants