Tech ONTAP Blogs
Tech ONTAP Blogs
I'm excited to kick off a new blog series called Back to Basics (B2B). The goal is to revisit fundamental concepts that often slip through the cracks because the world is going too fast, life happens, and you have to keep all the plates spinning without breaking any of them.
Mounting an NFS share might seem like a straightforward task - but have you ever wondered what really happens behind the scenes when you do it on a Linux client? To answer this question, we'll take a closer look at the NFS protocol and use some powerful tools to peek under the hood from the client's perspective. Let's dive in!
sudo modprobe sunrpc
sudo modprobe nfs
sudo modprobe nfsv4
sudo modprobe nfs_layout_nfsv41_files
echo 1 | sudo tee /sys/kernel/tracing/events/sunrpc/enabled
echo 1 | sudo tee /sys/kernel/tracing/events/nfs/enabled
echo 1 | sudo tee /sys/kernel/tracing/events/nfs4/enabled
cat /sys/kernel/tracing/trace_pipe
This streams live trace events as they occur, allowing us to observe the interaction between the NFS client and server in real-time.
sudo mount -t nfs4 -o vers=4.1,rsize=65536,wsize=65536,proto=tcp 10.26.128.221:/vol_cp_5node /cp
The original tracing output was 899 lines long. To keep things consice and focused, I filtered the data to include only the relevant events needed to understand the communication flow between the NFS client and server, from the client's perspective.
<...>-3331 [012] ..... 949.293271: nfs_mount_option: option source
<...>-3331 [012] ..... 949.293276: nfs_mount_option: option vers
<...>-3331 [012] ..... 949.293277: nfs_mount_assign: option vers=4.1
<...>-3331 [012] ..... 949.293278: nfs_mount_option: option rsize
<...>-3331 [012] ..... 949.293279: nfs_mount_option: option wsize
<...>-3331 [012] ..... 949.293280: nfs_mount_option: option proto
<...>-3331 [012] ..... 949.293280: nfs_mount_assign: option proto=tcp
<...>-3331 [012] ..... 949.293282: nfs_mount_option: option addr
<...>-3331 [012] ..... 949.293282: nfs_mount_assign: option addr=10.26.128.221
mount.nfs-3331 [012] ..... 949.293283: nfs_mount_option: option clientaddr
mount.nfs-3331 [012] ..... 949.293283: nfs_mount_assign: option clientaddr=10.26.56.192
mount.nfs-3331 [012] ..... 949.293286: nfs_mount_path: path='/vol_cp_5node'
mount.nfs-3331 [012] ..... 949.293390: xprt_create: peer=[10.26.128.221]:2049 state=BOUND
mount.nfs-3331 [012] ..... 949.293405: rpc_clnt_new: client=00000000 peer=[10.26.128.221]:2049 program=nfs server=10.26.128.221 xprtsec=none flags=DISCRTRY|INFINITE_SLOTS|NO_RETRANS_TIMEOUT
mount.nfs-3331 [012] ..... 949.293407: rpc_task_begin: task:00000001@00000000 flags=NULLCREDS|DYNAMIC|SOFT|SOFTCONN|CRED_NOREF runstate=ACTIVE status=0 action=0x0
mount.nfs-3331 [012] ..... 949.294496: rpc_connect_status: task:00000001@00000000 status=-11
mount.nfs-3331 [012] ..... 949.295698: rpc_request: task:00000002@00000000 nfsv4 EXCHANGE_ID (sync)
mount.nfs-3331 [012] ..... 949.296538: rpc_stats_latency: task:00000002@00000000 xid=0x734ec2e0 nfsv4 EXCHANGE_ID backlog=11 rtt=719 execute=841
mount.nfs-3331 [012] ..... 949.296541: nfs4_exchange_id: error=0 (OK) dstaddr=10.26.128.221
10.26.128.221-m-3333 [001] ..... 949.297657: rpc_request: task:00000004@00000000 nfsv4 CREATE_SESSION (sync)
10.26.128.221-m-3333 [001] ..... 949.298389: rpc_stats_latency: task:00000004@00000000 xid=0x754ec2e0 nfsv4 CREATE_SESSION backlog=10 rtt=583 execute=731
10.26.128.221-m-3333 [001] ..... 949.298393: nfs4_create_session: error=0 (OK) dstaddr=10.26.128.221
10.26.128.221-m-3333 [001] ..... 949.299115: nfs4_sequence_done: error=0 (OK) session=0x87e0d01f slot_nr=0 seq_nr=1 highest_slotid=63 target_highest_slotid=63 status_flags=0x0 ()
mount.nfs-3331 [012] ..... 949.299259: rpc_request: task:00000001@00000001 nfsv4 SECINFO_NO_NAME (sync)
mount.nfs-3331 [012] ..... 949.300992: rpc_stats_latency: task:00000001@00000001 xid=0x774ec2e0 nfsv4 SECINFO_NO_NAME backlog=718 rtt=1612 execute=2444
mount.nfs-3331 [012] ..... 949.305147: nfs4_setup_sequence: session=0x87e0d01f slot_nr=0 seq_nr=3 highest_used_slotid=0
mount.nfs-3331 [012] ..... 949.305148: rpc_request: task:00000002@00000001 nfsv4 LOOKUP_ROOT (sync)
mount.nfs-3331 [012] ..... 949.306163: rpc_stats_latency: task:00000002@00000001 xid=0x784ec2e0 nfsv4 LOOKUP_ROOT backlog=10 rtt=782 execute=1020
mount.nfs-3331 [012] ..... 949.306164: nfs4_sequence_done: error=0 (OK) session=0x87e0d01f slot_nr=0 seq_nr=3 highest_slotid=63 target_highest_slotid=63 status_flags=0x0 ()
mount.nfs-3331 [012] ..... 949.306168: nfs4_lookup_root: error=0 (OK) fileid=00:00:64 fhandle=0x507c44a0 valid=TYPE|MODE|NLINK|OWNER|GROUP|SIZE|FSID|FILEID|ATIME|MTIME|CTIME|CHANGE|0x400200
mount.nfs-3331 [012] ..... 949.306786: nfs4_setup_sequence: session=0x87e0d01f slot_nr=0 seq_nr=5 highest_used_slotid=0
mount.nfs-3331 [012] ..... 949.306786: rpc_request: task:00000004@00000001 nfsv4 FSINFO (sync)
mount.nfs-3331 [012] ..... 949.307693: rpc_stats_latency: task:00000004@00000001 xid=0x7a4ec2e0 nfsv4 FSINFO backlog=3 rtt=897 execute=907
mount.nfs-3331 [012] ..... 949.307693: nfs4_sequence_done: error=0 (OK) session=0x87e0d01f slot_nr=0 seq_nr=5 highest_slotid=63 target_highest_slotid=63 status_flags=0x0 ()
mount.nfs-3331 [012] ..... 949.307694: nfs4_fsinfo: error=0 (OK) fileid=00:00:64 fhandle=0x507c44a0 valid=TYPE|MODE|NLINK|OWNER|GROUP|SIZE|FSID|FILEID|ATIME|MTIME|CTIME|CHANGE|0x400200
mount.nfs-3331 [012] ..... 949.307696: nfs4_setup_sequence: session=0x87e0d01f slot_nr=0 seq_nr=6 highest_used_slotid=0
mount.nfs-3331 [012] ..... 949.307697: rpc_request: task:00000005@00000001 nfsv4 SERVER_CAPS (sync)
mount.nfs-3331 [012] ..... 949.308249: rpc_stats_latency: task:00000005@00000001 xid=0x7b4ec2e0 nfsv4 SERVER_CAPS backlog=3 rtt=452 execute=552
mount.nfs-3331 [012] ..... 949.308249: nfs4_sequence_done: error=0 (OK) session=0x87e0d01f slot_nr=0 seq_nr=6 highest_slotid=63 target_highest_slotid=63 status_flags=0x0 ()
mount.nfs-3331 [012] ..... 949.309855: nfs4_setup_sequence: session=0x87e0d01f slot_nr=0 seq_nr=10 highest_used_slotid=0
mount.nfs-3331 [012] ..... 949.309855: rpc_request: task:00000009@00000001 nfsv4 GETATTR (sync)
mount.nfs-3331 [012] ..... 949.310555: nfs4_sequence_done: error=0 (OK) session=0x87e0d01f slot_nr=0 seq_nr=10 highest_slotid=63 target_highest_slotid=63 status_flags=0x0 ()
mount.nfs-3331 [012] ..... 949.310557: nfs4_getattr: error=0 (OK) fileid=00:2f:64 fhandle=0x507c44a0 valid=TYPE|MODE|NLINK|OWNER|GROUP|SIZE|FSID|FILEID|ATIME|MTIME|CTIME|CHANGE|0x400200
mount.nfs-3331 [012] ..... 949.310575: nfs_access_enter: fileid=00:2f:64 fhandle=0x507c44a0 version=1881467492116116952
mount.nfs-3331 [012] ..... 949.310577: nfs_access_exit: error=-10 (CHILD) fileid=00:2f:64 fhandle=0x507c44a0 type=4 (DIR) version=1881467492116116952 size=4096 cache_validity=0x0 () nfs_flags=0x0 () mask=0x81 permitted=0xffffffff
mount.nfs-3331 [012] ..... 949.310577: nfs_access_enter: fileid=00:2f:64 fhandle=0x507c44a0 version=1881467492116116952
mount.nfs-3331 [012] ..... 949.310580: nfs4_setup_sequence: session=0x87e0d01f slot_nr=0 seq_nr=11 highest_used_slotid=0
mount.nfs-3331 [012] ..... 949.310580: rpc_request: task:0000000a@00000001 nfsv4 ACCESS (sync)
mount.nfs-3331 [012] ..... 949.311414: rpc_stats_latency: task:0000000a@00000001 xid=0x804ec2e0 nfsv4 ACCESS backlog=3 rtt=688 execute=834
mount.nfs-3331 [012] ..... 949.311415: nfs4_sequence_done: error=0 (OK) session=0x87e0d01f slot_nr=0 seq_nr=11 highest_slotid=63 target_highest_slotid=63 status_flags=0x0 ()
mount.nfs-3331 [012] ..... 949.311421: nfs4_access: error=0 (OK) fileid=00:2f:64 fhandle=0x507c44a0
mount.nfs-3331 [012] ..... 949.311422: nfs_access_exit: error=0 (OK) fileid=00:2f:64 fhandle=0x507c44a0 type=4 (DIR) version=1881467492116116952 size=4096 cache_validity=0x0 () nfs_flags=0x4 (ACL_LRU_SET) mask=0x1 permitted=0x7
mount.nfs-3331 [012] ..... 949.311428: nfs_lookup_enter: flags=0x5 (FOLLOW|AUTOMOUNT) name=00:2f:64/vol_cp_5node fileid=0
mount.nfs-3331 [012] ..... 949.311429: nfs4_setup_sequence: session=0x87e0d01f slot_nr=0 seq_nr=12 highest_used_slotid=0
mount.nfs-3331 [012] ..... 949.312312: nfs4_sequence_done: error=0 (OK) session=0x87e0d01f slot_nr=0 seq_nr=12 highest_slotid=63 target_highest_slotid=63 status_flags=0x0 ()
mount.nfs-3331 [012] ..... 949.312317: nfs4_lookup: error=0 (OK) name=00:2f:64/vol_cp_5node
mount.nfs-3331 [012] ..... 949.312320: nfs_lookup_exit: error=0 (OK) flags=0x5 (FOLLOW|AUTOMOUNT) name=00:2f:64/vol_cp_5node fileid=105
Finally, the mount completes successfully and the RPC resources are released:
mount.nfs-3331 [012] ..... 949.315199: nfs_mount_option: option source
mount.nfs-3331 [012] ..... 949.315201: nfs_mount_path: path='/vol_cp_5node'
mount.nfs-3331 [012] ..... 949.316737: rpc_clnt_shutdown: client=00000002
mount.nfs-3331 [012] ..... 949.316738: rpc_clnt_release: client=00000002
kworker/12:1-450 [012] ..... 949.316760: rpc_clnt_free: client=00000002
mount.nfs-3331 [012] ..... 949.328981: rpc_clnt_shutdown: client=00000001
mount.nfs-3331 [012] ..... 949.328990: rpc_clnt_release: client=00000001
kworker/12:1-450 [012] ..... 949.329007: rpc_clnt_free: client=00000001
Suppose you issue an NFS mount command and it hangs without any obvious reason. In such cases, you can terminate the command. Next, enable tracing for the sunrpc and nfs subsystems, then re-run the mount operation. With tracing enabled, you can observe the communication flow and identify exactly where the process is getting stuck.