how to avoid .nfs files in mounted drive

Bvm 18
Bvm 18 used Ask the Experts™
on
Hi,

Parent and child processes are accessing same content from nfs share. based on some logic parent process deleted files which are already opened by child process. I think, it's internally created files which are .nfsxxxxxxx. These are with c++ application. Is there any settings or configuration to handle such issues to avoid .nfsxxxx files.

Thanks,
Bvm
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018
Commented:
If you delete these files, depending on which process is doing i/o to the file, you can end up crashing applications in ways which are impossible to debug.

Tip: Only delete .nfsXXXX files at your peril. NFS will clean up these files when all processes have closed their file descriptors pointing to these files.

These files are files which have been opened on NFS volumes + then the directory entry deleted + file descriptor is still open + i/o still being done.

Sometimes referred to as ghost files or orphan files.

With NFS, you can't have a ghost file (no directory entry) as this breaks NFS internals, hence these files are renamed to NFSXXXX.

So if you delete them, you will likely kill some process somewhere.

If you'd like to never see a NFSXXXX then you'll run lsof on these files... hum... likely from all machines accessing the NFS volume, till you find the offending process, then fix the code to defer the file deletion, till the file usage is complete.

Or... better... you can just ignore these files + let NFS do it's job to clean up files after they're no longer being used.
Top Expert 2016
Commented:
the only way out is to write a service/daemon that would handle all file access by request. then, if parent requests file deletion, the operation would be deferred until the last child which has locked the file would release the lock. however, this still fails if the OS or any other program would access the files.

you can just ignore these files + let NFS do it's job to clean up files after they're no longer being used.

the problem with this could be that after 'deletion' a child should no longer be able to process the file. by using an own server you could deny further client requests and handle the case.

Sara

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial