LinearTapeFileSystem / ltfs

Reference implementation of the LTFS format Spec for stand alone tape drive
BSD 3-Clause "New" or "Revised" License
246 stars 73 forks source link

With multiple LTFS mounted sometimes unmounts fail until another one is unmounted #469

Closed tomaz-beltram closed 2 months ago

tomaz-beltram commented 3 months ago

Describe the bug When using multiple LTFS mounts in parallel it happens sometimes that the unmount returns "Device or resource busy" error repeatedly for a longer period of time. Also lsof shows that the ltfs process holds open handle for a file on that mountpoint. After another LTFS is successfully unmounted all other also succeeds to unmount. It looks like a handle leak in LTFS/FUSE code. Strange thing is that all parallel LTFS mounts are somehow interrelated.

To Reproduce Steps to reproduce the behavior:

  1. Mount at least two LTFS tapes in parallel
  2. Start copying data from all mountpoints.
  3. Finish copying on first mountpoint and issue unmount while other mounpoints are still copying data.
  4. See error

Expected behavior The first LTFS is unmounted w/o error regardless of the other still being busy.

Desktop (please complete the following information):

Additional context Data on tape are several 1GB files.

piste-jp commented 2 months ago

I don't believe such kind of thing happens... because ltfs process never share any resources. On the other hand, I don't have any equipment to confirm this.

Please confirm the only thing that you don't share the mount point within 2 ltfs processes , like /mnt/ltfs and '/mnt/ltfs/ltfs2`.

tomaz-beltram commented 2 months ago

Thanks for your comment. In the meantime we found out that that cause for file system busy error on unmount was file handle inheritance of forked mount processes. Our main process forks different ltfs mount processes and they inherit open handles of the parent (and its child) processes at the time of fork call. The inherited file handle is closed only on child exit. The solution is to use O_CLOEXEC flag when opening files.