Skip to content

Conversation

@ddiss
Copy link

@ddiss ddiss commented Jul 2, 2025

Duplicate mounts are a risk when running multiple lklfuse instances, as we don't have a single arbitrator to manage access. This patchset adds a new lock parameter, which can provide host-side flock() based exclusion.

The following changes since commit 46f599b0575197f5756d2d171c294e1242e25a9d:

  Merge pull request #610 from ddiss/minor_test_changes (2025-07-03 14:53:53 -0700)

are available in the Git repository at:

  https://github.com/ddiss/linux lklfuse_flock

for you to fetch changes up to 656eccf1fe59c61d980bc8f3a97cb705699e0d8a:

  lkl: tests: fix net setup_backend return status (2025-07-04 14:51:32 +1000)

----------------------------------------------------------------
David Disseldorp (5):
      lklfuse: add lock parameter to avoid duplicate mounts
      lkl: systemd: use lklfuse lock parameter
      lkl: tests: add lklfuse_lock_conflict test
      lkl: tests: drop sleep before lklfuse unmount
      lkl: tests: fix net setup_backend return status

 Documentation/lkl/lklfuse.rst            |  4 +++-
 tools/lkl/lklfuse.c                      | 27 ++++++++++++++++++++++++---
 tools/lkl/systemd/lklfuse-mount@.service |  8 ++++++--
 tools/lkl/tests/lklfuse.sh               | 29 ++++++++++++++++++++++-------
 tools/lkl/tests/net.sh                   |  2 +-
 5 files changed, 56 insertions(+), 14 deletions(-)

@ddiss
Copy link
Author

ddiss commented Jul 3, 2025

The windows build failure here appears to be the same gcc -std=gnu23 issue fixed in #610 , so I'll rebase atop that for a clean build. The checkpatch warning is also legit so will fix.

@ddiss
Copy link
Author

ddiss commented Jul 3, 2025

v2:

@ddiss
Copy link
Author

ddiss commented Jul 3, 2025

checkpatch still complains but I think it can be ignored:


Run tools/lkl/scripts/checkpatch.sh
grep: write error: Broken pipe
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#13: 
  176 |                 return host_setsockopt(fd, level, optname, optval, optlen);

/tmp/tmp.mYV5y8POUm/0001-lkl-hijack-explicitly-build-with-std-gnu11.patch total: 0 errors, 1 warnings, 6 lines checked
WARNING: Missing commit description - Add an appropriate one

/tmp/tmp.mYV5y8POUm/0001-lkl-tests-fix-net-setup_backend-return-status.patch total: 0 errors, 1 warnings, 8 lines checked
Error: Process completed with exit code 1.

Copy link
Member

@tavip tavip left a comment

Choose a reason for hiding this comment

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

LGTM, left a couple minor comments. Thanks @ddiss!

ddiss added 5 commits July 4, 2025 14:01
This lock-while-mounted behaviour is similar to what QEMU does, and can
help avoid duplicate mounts.
Allowing for an explicit lock path that differs from the filesystem
image / block device path was intentional, to ensure non-flock
supporting filesystems can still be used. Also, there are cases where
a block device and partition (e.g. sda and sda1) can both provide access
to the same filesystem image, in which case an FS-ID based lock would
make sense.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Use an ID_FS_UUID based lock file to avoid duplicate mounts.
If udev doesn't provide an id then use a static noid path, ensuring lock
conflict with any other id-less mount.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This tests that two lklfuse instances using the same lock file result
in a lock conflict (exit status 2) for the instance started last.

Signed-off-by: David Disseldorp <ddiss@suse.de>
The sleep appears to have been there since the initial tests were added.
It shouldn't be necessary so remove it.

Signed-off-by: David Disseldorp <ddiss@suse.de>
TEST_FAILED isn't set anywhere. Use test.sh defined TEST_FAILURE.

Signed-off-by: David Disseldorp <ddiss@suse.de>
@ddiss
Copy link
Author

ddiss commented Jul 4, 2025

@tavip : thanks for the review!
v3:

  • drop 1s sleep in lklfuse.sh test cleanup
  • use block-device instead of file for lklfuse -ro help text
  • minor commit msg changes

@tavip tavip merged commit 5b7acfc into lkl:master Jul 4, 2025
13 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.

2 participants