All of lore.kernel.org
 help / color / mirror / Atom feed
* How to separate NFS mounts have same device ID
@ 2020-05-21  2:30 Craig Small
  2020-05-21  5:12 ` NeilBrown
  0 siblings, 1 reply; 3+ messages in thread
From: Craig Small @ 2020-05-21  2:30 UTC (permalink / raw)
  To: linux-nfs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to separate NFS mounts have same device ID
  2020-05-21  2:30 How to separate NFS mounts have same device ID Craig Small
@ 2020-05-21  5:12 ` NeilBrown
  2020-05-21  6:28   ` Craig Small
  0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2020-05-21  5:12 UTC (permalink / raw)
  To: Craig Small, linux-nfs

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to separate NFS mounts have same device ID
  2020-05-21  5:12 ` NeilBrown
@ 2020-05-21  6:28   ` Craig Small
  0 siblings, 0 replies; 3+ messages in thread
From: Craig Small @ 2020-05-21  6:28 UTC (permalink / raw)
  To: NeilBrown; +Cc: linux-nfs

On Thu, 21 May 2020 at 15:12, NeilBrown <neilb@suse.de> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-21  6:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21  2:30 How to separate NFS mounts have same device ID Craig Small
2020-05-21  5:12 ` NeilBrown
2020-05-21  6:28   ` Craig Small

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.