0

I want to create a ansible role that creates some bindfs-mounts and map those to a bunch of users.

Now those users can change. And this is why I cannot check, whether the mount already exists and then use bindfs - I have to do that all the time, as the mount might be existing, but with the wrong user mapping.

So basically, everytime the playbook runs, the bindfs-command is being fired. Additionally, I cannot extract the current mapping from the mount-overview.

So my question is: Given the fact that userA is uploading a laaaaarge file to the mounted directory and in this moment the bindfs-command is fired again, can this cause data corruption?

The command basically is nothing fancy and looks like this:

bindfs -o nonempty --map=userA/userB /var/foo/bar /mnt/foo/bar

One option, which I thought of at the moment, was to create a passwd-file, as bindfs offers to use --map-passwd. If the file changes, I can register a variable and only in this case I would remount.

But still: In this event, would I risk corrupt data?

Thanks for your help.

1
  • Don't you umount the previous mount first? Are you stacking mounts there without limit? Commented May 4 at 23:05

1 Answer 1

2

The answer is No. There is no risk in corrupting data by mounting another directory while the current one is in use. When a user starts e.g. an upload, the OS places a Mutex on the inode that is being accessed. All references to this file for the duration of the mutex take place through the inode on the system level; so even when this file stops being relevant -- whether by re-mounting its parent directory, or even if someone else deletes this file -- the upload continues until it is finished. As long as the OS has access to the inode (e.g. as long as the physical device on which the file is located has not been removed), there is no danger of data corruption.

In my experience, even after finishing the upload, while I am still in the same directory, then I am still inside the previously-mounted location. But if I execute a cd command, that's when the OS checks for the mount location, and then I end up in the newly-mounted directory. But this is obviously OS-specific.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.