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

How to prevent overlapping calls to read? #57

Closed
moefear85 opened this issue Jan 10, 2024 · 3 comments
Closed

How to prevent overlapping calls to read? #57

moefear85 opened this issue Jan 10, 2024 · 3 comments

Comments

@moefear85
Copy link

Hi,

I'm a noob in both fuse and python-fuse. I've implemented the read(...) callback, but when I access a file from the outside, the read callback gets executed concurrently more than once, and even though I'm trying to access the data in order, the size and offset arguments passed to read seem to indicate it is getting called out of order (non-sequentially).

How do I prevent this? I don't want another call to read() to be triggered before the first one has fully completed.

Also, the mount options are a bit confusing. How do I pass command line arguments when I'm not creating the Fuse object from the command line? I'd like to let any user, specifically root, be able to access the fuse filesystem even when it's running as a normal user process.

@glensc
Copy link
Contributor

glensc commented Jan 15, 2024

without knowing the internals of fuse or this library, you can prevent concurrent access with lock:

@moefear85
Copy link
Author

thx im using them. i also discovered the -s option.

@glensc
Copy link
Contributor

glensc commented Jan 15, 2024

yeah, I wanted to point out that there's dash_s_do option controlling multithreading:

  • python-fuse/fuse.py

    Lines 211 to 236 in e6c876f

    dash_s_do
    String: ``whine``, ``undef``, or ``setsingle`` [default is ``whine``].
    The ``-s`` option -- traditionally for asking for single-threadedness --
    is an oddball: single/multi threadedness of a fuse-py fs doesn't depend
    on the FUSE command line, we have direct control over it.
    Therefore we have two conflicting principles:
    - *Orthogonality*: option parsing shouldn't affect the backing `Fuse`
    instance directly, only via its `fuse_args` attribute.
    - *POLS*: behave like other FUSE based fs-es do. The stock FUSE help
    makes mention of ``-s`` as a single-threadedness setter.
    So, if we follow POLS and implement a conventional ``-s`` option, then
    we have to go beyond the `fuse_args` attribute and set the respective
    Fuse attribute directly, hence violating orthogonality.
    We let the fs authors make their choice: ``dash_s_do=undef`` leaves this
    option unhandled, and the fs author can add a handler as she desires.
    ``dash_s_do=setsingle`` enables the traditional behaviour.
    Using ``dash_s_do=setsingle`` is not problematic at all, but we want fs
    authors be aware of the particularity of ``-s``, therefore the default is
    the ``dash_s_do=whine`` setting which raises an exception for ``-s`` and
    suggests the user to read this documentation.

it's set to setsingle in examples, it's where you usually start with? :)

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

No branches or pull requests

2 participants