fscrypt icon indicating copy to clipboard operation
fscrypt copied to clipboard

Concurrency issue when new mounts are added

Open NymanRobin opened this issue 1 year ago • 2 comments

In the filesystem/mountpoint.go file the mountsByDevice map is recreated on each call of update UpdateMountInfo. This causes problem, if these steps occurs!

  1. Mount is assigned to policy.context
  2. UpdateMountInfo is called
  3. policy.apply is called

This will result in the fact that the policy.context.Mount will have the old memory address from the old mountsByDevice map while the filesystems.findMount will find the new object and then in the comparison the following error will be thrown in the policy.apply function.

(%!w(*actions.ErrDifferentFilesystem=&{0xc00157b130 0xc00208a140}).

This currently affects the ceph-csi project and more information can be found in this issue: https://github.com/ceph/ceph-csi/issues/4592

I have tested a solution were only the new mount objects are updated and that would at least work for my specific use-case, I will open a PR for this and look forward to any feedback

NymanRobin avatar Apr 30 '24 11:04 NymanRobin

Another approach to fixing this would just be to compare the Mounts by value rather than by pointer.

Happy to review any PR!

josephlr avatar Apr 30 '24 12:04 josephlr

Great point @josephlr! I went ahead with the comparison as that removed the responsibility of removing unused mounts from the map and made it a tad bit easier

NymanRobin avatar May 02 '24 09:05 NymanRobin

Fixed by 068b9f8f5dec46b222470f6d3f03244ba5b65f5c

ebiggers avatar May 07 '24 18:05 ebiggers

Thanks for the helping me get this change in @ebiggers and @josephlr! I've got one more question: when could we expect a new release of fscrypt? Do you have any plans in mind? I'm asking because I'd like to get this fix into ceph-csi.

NymanRobin avatar May 07 '24 19:05 NymanRobin

There was a release recently, and there haven't been many changes since then, so it probably will be at least a few months before we do another release.

ebiggers avatar May 07 '24 20:05 ebiggers