how to avoid .nfs files in mounted drive

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
Bvm 18Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
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.
sarabandeCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.