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

Does ntfs-3g support Mandatory File Locking? #128

Open
sibidharan opened this issue Nov 3, 2024 · 3 comments
Open

Does ntfs-3g support Mandatory File Locking? #128

sibidharan opened this issue Nov 3, 2024 · 3 comments

Comments

@sibidharan
Copy link

I am trying to run multiple Tally Prime software instances via Wine running inside KASM containers sharing data simulating Citrix on Windows. When Tally is run on Citrix on Windows, the NTFS driver provides mandatory file locking that makes multiple clients access tally data simultaneously. But this is not happening in Linux since Linux do not have real support for mandatory file locking and recently deprecated mand mount option also, that throws a warning in dmesg.

Can I rely on ntfs-3g for Mandatory File Locking? Is this really implemented into the linux driver? If so can I use them inside containers?

@jpandre
Copy link
Collaborator

jpandre commented Nov 4, 2024

the NTFS driver provides mandatory file locking that makes multiple clients access tally data simultaneously.

ntfs-3g runs in user space and does not implement any locking at all, however fuse serializes the requests from the clients. So what matters here is whether you need several ntfs-3g processes acting on the same partition. This would be unsafe. Having several clients to a single ntfs-3g process would be safe.

@sibidharan
Copy link
Author

That means mounting the ntfs-3g in host with sudo ntfs-3g /dev/sdX1 /mnt/ntfs-mount and then bind mounting all containers to access this mount will ensure all operations happen sequentially? Is this safe?

With Ext4 bind mounts the data gets corrupt while multiple clients access, that does not happen on NTFS on windows. Can I make the same with docker and ntfs-3g ? Lets say I run a container with

docker run -d \ --name container_name \ -v /mnt/ntfs-mount:/path/in/container \ your_image

Does this work like multiple clients access single ntfs-3g process?

@jpandre
Copy link
Collaborator

jpandre commented Nov 4, 2024

That means mounting the ntfs-3g in host with sudo ntfs-3g /dev/sdX1 /mnt/ntfs-mount and then bind mounting all containers to access this mount will ensure all operations happen sequentially? Is this safe?

When mounting with "sudo ntfs-3g /dev/sdX1 /mnt/ntfs-mount" a single process is created, and /dev/sdX1 is opened with O_EXCL so preventing another process from accessing it.

I imagine that a bind mount is sort of symbolic link, using the existing mount relying on the existing process, this is easy to check, and I would say this is safe.

With Ext4 bind mounts the data gets corrupt while multiple clients access,

ext4 is reentrant code acting on behalf of client processes, so it has to deal with interprocess lockings, which your architecture apparently defeats.

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