fuser on NFS

Latest response

We mount from a NetApp filer the following:

netapp:/volume1/qtree1 under mountpoint /abc
and
netapp:/volume1/qtree2 under mountpoint /xyz
--> diferent qtrees in one volume.

fuser -mk /abc shows also the processes for /xyz (different qtree same voume)
We want to use fuser -k command to kill processes before umounting the filesystem /abc
but not kill the procs for /xyz

guenter.lehmann@infineon.com's picture

Responses

You may try umount -lf /abc instead.

//Zdenek

Hello,

I have the same issue for my Customer with the fuser tool on NetApp NFS shares. I did some investigation in my LAB (RHEL6 NFS Server/Client) and I think it's related how to fuser works.

The 'fuser' command goes over entries in '/proc' - resolves '/proc//fd' symlinks (all opened files are represented as symlinks to original files), file mappings ('/proc//maps') etc. in order to find references to files.

By default, all NFS shares from the same server, have the same the major and minor device numbers associated with the mounted file systems (see below output from command: cat /proc/fs/nfsfs/volumes). Probably it causes wrong output from fuser. For that source code for fuser should be analysed.

As a solution we have to set a unique filesystem id for each NFS export on the NFS server using the fsid= parameter in /etc/exports. After that fuser command works as expected and can display proper processes per file system.

Please see below example for details:

# RHEL6 server
192.168.111.20:/nfs-ro      /nfs/RHEL6/ro       nfs defaults,_netdev 0 0
192.168.111.20:/nfs/rhel6   /nfs/RHEL6/rw       nfs defaults,_netdev 0 0

NFS without fsid= parameters, default configuration

  • Identify the major and minor device numbers associated with the mounted file systems
[root@rhel6 ~]# mountpoint -d /nfs/RHEL6/ro
0:21
[root@rhel6 ~]# mountpoint -d /nfs/RHEL6/rw
0:21
  • Identify nfs servers
[root@rhel6 ~]# cat /proc/fs/nfsfs/servers 
NV SERVER   PORT USE HOSTNAME
v4 c0a86f14  801   1 192.168.111.20
  • Identify the corresponding fsid from this device number in /proc/fs/nfsfs/volumes
[root@rhel6 ~]# cat /proc/fs/nfsfs/volumes 
NV SERVER   PORT DEV     FSID              FSC
v4 c0a86f14  801 0:21    672381d7f8bc424f  no 
  • Wrong output, fuser shows processes from both mount points:
[root@rhel6 ~]# fuser -mu -v  /nfs/RHEL6/ro /nfs/RHEL6/rw
 USER        PID ACCESS COMMAND
/nfs/RHEL6/ro:       root       1627 ..c.. (root)bash
                  root       1636 ..c.. (root)bash
/nfs/RHEL6/rw:      root       1627 ..c.. (root)bash
                   root       1636 ..c.. (root)bash

NFS with fsid= parameters per nfs share, example for changed configuration

  • NFS server modification, fsid= options have been added for shares
# diff exports.orig exports
1c1
< /nfs-ro       192.168.111.0/24(ro,no_root_squash)
---
> /nfs-ro       192.168.111.0/24(ro,no_root_squash,fsid=1)
3c3
< /nfs/rhel6    192.168.111.11(rw)
---
> /nfs/rhel6    192.168.111.11(rw,fsid=2)
  • We can see different the major and minor device numbers associated with the mounted file systems
[root@rhel6 ~]# mountpoint -d /nfs/RHEL6/ro
0:21
[root@rhel6 ~]# mountpoint -d /nfs/RHEL6/rw
0:22
  • Identify nfs servers, no changes as expected
[root@rhel6 ~]# cat /proc/fs/nfsfs/servers 
NV SERVER   PORT USE HOSTNAME
v4 c0a86f14  801   2 192.168.111.20
  • Identify the corresponding fsid from this device numbers in /proc/fs/nfsfs/volumes. We can see different fsid as expected
[root@rhel6 ~]# cat /proc/fs/nfsfs/volumes 
NV SERVER   PORT DEV     FSID              FSC
v4 c0a86f14  801 0:22    2:0               no 
v4 c0a86f14  801 0:21    1:0               no 
  • The expected result, fuser shows processes only for specific file system
[root@rhel6 ~]# fuser -mu -v  /nfs/RHEL6/ro /nfs/RHEL6/rw
 USER        PID ACCESS COMMAND
/nfs/RHEL6/ro:       root       1636 ..c.. (root)bash
/nfs/RHEL6/rw:       root      1627 ..c.. (root)bash

Can you can validate this example and share with your comments? Best Regards. W.

I've prepared KCS draft for this topic: https://access.redhat.com/solutions/3006341

Best Regards. W.

Was this helpful?

We appreciate your feedback. Leave a comment if you would like to provide more detail.
It looks like we have some work to do. Leave a comment to let us know how we could improve.