Hi,
I'm the author of the psmisc programs that include things like killall and fuser. I have a problem with finding files open on NFS mounts from the same server. The issue is at https://gitlab.com/psmisc/psmisc/-/issues/10
The way fuser does its job is to find the mounts you specify and collect the device IDs, then scans all /proc/<PID/fd/* for matching devices. However, NFS mounts from the same server have the same device ID so fuser reports every mount has the same file opened.
Putting it another way, if I said "here is file /proc/<PID>/fd/3, dereference the symlink and tell me which of these two NFS mounts from the same server it comes from?" how would you do it?
A simple string match (/mnt/a vs /mnt/b) does not work because you can have symlinks across mounts.
Any help here would be appreciated. I'm not subscribed to the list so hopefully, this makes it through whatever filters there are and please CC me on replies.
- Craig
On Thu, May 21 2020, Craig Small wrote:
> Hi,
> I'm the author of the psmisc programs that include things like killall and fuser. I have a problem with finding files open on NFS mounts from the same server. The issue is at https://gitlab.com/psmisc/psmisc/-/issues/10
>
> The way fuser does its job is to find the mounts you specify and collect the device IDs, then scans all /proc/<PID/fd/* for matching devices. However, NFS mounts from the same server have the same device ID so fuser reports every mount has the same file opened.
>
> Putting it another way, if I said "here is file /proc/<PID>/fd/3, dereference the symlink and tell me which of these two NFS mounts from the same server it comes from?" how would you do it?
> A simple string match (/mnt/a vs /mnt/b) does not work because you can have symlinks across mounts.
I would examine /proc/<PID>/fdinfo/3 and extract the 'mnt_id:' number,
then look for that (as the first field) in /proc/<PID>/mountinfo.
NeilBrown
>
> Any help here would be appreciated. I'm not subscribed to the list so hopefully, this makes it through whatever filters there are and please CC me on replies.
>
> - Craig
On Thu, 21 May 2020 at 15:12, NeilBrown <[email protected]> wrote:
> I would examine /proc/<PID>/fdinfo/3 and extract the 'mnt_id:' number,
> then look for that (as the first field) in /proc/<PID>/mountinfo.
The mountinfo looks very promising and a better way of uniquely
working out where a file is mounted. Thanks!
- Craig