** Description changed:

  [ Impact ]
  
  On Ubuntu 20.04 (ntirpc 3.0-0ubuntu2, nfs-ganesha 3.0.3-0ubuntu3.2),
- ganesha.nfsd stops answering NFS clients under ordinary read load:
+ ganesha.nfsd stops answering NFS clients under parallel read load:
  
   * shares become unresponsive on the clients ("nfs: server <ip> not 
responding, still trying")
   * new mounts time out
  
  ntirpc 3.0 sends TCP replies with sendmsg(MSG_DONTWAIT). When the socket
  send buffer is full (EWOULDBLOCK), svc_rqst_evchan_write() submits
  sr_rec->ev_wpe to the work pool again, although the svc_rqst_epoll_loop
  of that event channel is already running. Each EWOULDBLOCK therefore
  adds one more thread sitting in epoll_wait() on the same epoll fd, and
  these threads never go away.
  
   * With several loops on one channel, a TCP connection stops being read 
(requests stay in the socket receive queue). Every mount using that connection 
hangs, and another mount from the same client to the same server times out 
because it shares the connection.
   * Once the loops reach RPC_Ioq_ThrdMax (default 200), no thread is left to 
accept or receive, and the whole server stops answering, so mounts from any 
client time out.
  
  The fix is upstream ntirpc PR #198, first released in v3.1:
  https://github.com/nfs-ganesha/ntirpc/pull/198
   c513a16c "Non-Blocking I/O results in hang."
   75905949 "fix erronous bracket"
  It removes the extra work_pool_submit() (and the ev_refcnt increment) from 
svc_rqst_evchan_write(), so only one svc_rqst_epoll_loop runs per event channel.
  
  Only focal needs the fix. bionic has ntirpc 1.6.1, which has no non-
  blocking send path. jammy and later have ntirpc >= 3.5.
  
  [ Test Plan ]
  
  Two VMs: a focal server (2 vCPU, 4G) and a client with the kernel NFS
  client (jammy was used).
  
  Server:
  
  $ sudo apt install nfs-ganesha nfs-ganesha-vfs
  $ sudo mkdir -p /srv/nfs
  $ for i in $(seq 8); do sudo dd if=/dev/urandom of=/srv/nfs/f$i bs=1M 
count=256 status=none; done
  $ cat /etc/ganesha/ganesha.conf
  NFS_CORE_PARAM {
      Protocols = 3,4;
  }
  EXPORT {
      Export_Id = 1;
      Path = /srv/nfs;
      Pseudo = /export;
      Access_Type = RW;
      Squash = No_Root_Squash;
      SecType = sys;
      Protocols = 3,4;
      Transports = TCP;
      FSAL { Name = VFS; }
  }
  $ sudo systemctl restart nfs-ganesha
  
  Client:
  
  $ sudo apt install nfs-common
  $ sudo mkdir -p /mnt/n1
  $ sudo mount -t nfs4 -o vers=4.1,rsize=1048576,hard <server>:/export /mnt/n1
  $ for i in $(seq 8); do (while :; do dd if=/mnt/n1/f$i of=/dev/null bs=1M 
iflag=direct status=none; done) & done
  
  While the load runs, on the server count the threads in epoll_wait
  (syscall 232 on amd64):
  
  $ sudo sh -c 'cat /proc/$(pidof ganesha.nfsd)/task/*/syscall' | awk
  '$1==232' | wc -l
  
  and on the client, from another shell:
  
  $ timeout 15 stat /mnt/n1/f1
  $ sudo mkdir -p /mnt/n2 && sudo timeout 60 mount -t nfs4 -o vers=4.1 
<server>:/export /mnt/n2
  
- Before the fix: the count starts at 5 and grows within 1-2 minutes (33,
- 53 and 200 in three runs). The dd processes stop, stat and the second
- mount time out, and the client logs "nfs: server <ip> not responding,
- still trying".
+ Before the fix: the count starts at 5 and grows within 1-2 minutes (53
+ and 200 in two runs). The dd processes stop, and stat and the second
+ mount time out. The client may also log "nfs: server <ip> not
+ responding, still trying".
  
  After the fix: the count stays at 5 or below, and stat and new mounts
  keep answering for the whole run (5 minutes, about 253,000 RPCs served).
  
  [ Where problems could occur ]
  
- The change is limited to svc_rqst_evchan_write(), which is only reached
- when a TCP send would block. After the change, a blocked send relies on
- the already running epoll loop of the channel to see EPOLLOUT and resume
- it. If that did not happen, replies to a client with a full send buffer
- (large READs, slow or congested clients) would stall, which would show
- up as a hung NFS connection again. Other transports and the receive path
- are not touched.
+ The patch changes how a TCP send that would block is resumed: it now
+ depends on the one epoll loop of the event channel picking up EPOLLOUT
+ for that connection. A regression would show up as NFS replies stalling
+ for clients whose send buffer is full (large READs, slow or congested
+ clients): hung mounts or I/O timeouts on those clients while
+ ganesha.nfsd itself keeps running.

** Description changed:

- [ Impact ]
+ [Impact]
  
- On Ubuntu 20.04 (ntirpc 3.0-0ubuntu2, nfs-ganesha 3.0.3-0ubuntu3.2),
- ganesha.nfsd stops answering NFS clients under parallel read load:
+ On Ubuntu 20.04 (ntirpc 3.0-0ubuntu2, nfs-ganesha 3.0.3-0ubuntu3.2), 
ganesha.nfsd stops answering NFS clients under parallel read load.
+ Shares become unresponsive on the clients ("nfs: server <ip> not responding, 
still trying") and new mounts time out.
  
-  * shares become unresponsive on the clients ("nfs: server <ip> not 
responding, still trying")
-  * new mounts time out
+ ntirpc 3.0 sends TCP replies with sendmsg(MSG_DONTWAIT).
+ When the socket send buffer is full (EWOULDBLOCK), svc_rqst_evchan_write() 
submits sr_rec->ev_wpe to the work pool again, although the svc_rqst_epoll_loop 
of that event channel is already running:
  
- ntirpc 3.0 sends TCP replies with sendmsg(MSG_DONTWAIT). When the socket
- send buffer is full (EWOULDBLOCK), svc_rqst_evchan_write() submits
- sr_rec->ev_wpe to the work pool again, although the svc_rqst_epoll_loop
- of that event channel is already running. Each EWOULDBLOCK therefore
- adds one more thread sitting in epoll_wait() on the same epoll fd, and
- these threads never go away.
+     atomic_inc_int32_t(&sr_rec->ev_refcnt);
+     work_pool_submit(&svc_work_pool, &sr_rec->ev_wpe);
  
-  * With several loops on one channel, a TCP connection stops being read 
(requests stay in the socket receive queue). Every mount using that connection 
hangs, and another mount from the same client to the same server times out 
because it shares the connection.
-  * Once the loops reach RPC_Ioq_ThrdMax (default 200), no thread is left to 
accept or receive, and the whole server stops answering, so mounts from any 
client time out.
+ Each EWOULDBLOCK therefore adds one more thread sitting in epoll_wait()
+ on the same epoll fd, and these threads never exit.
  
- The fix is upstream ntirpc PR #198, first released in v3.1:
- https://github.com/nfs-ganesha/ntirpc/pull/198
-  c513a16c "Non-Blocking I/O results in hang."
-  75905949 "fix erronous bracket"
- It removes the extra work_pool_submit() (and the ev_refcnt increment) from 
svc_rqst_evchan_write(), so only one svc_rqst_epoll_loop runs per event channel.
+  * With several loops on one channel, a TCP connection stops being read 
(requests stay in the socket receive queue), so every mount using that 
connection hangs.
+  * Once the loops reach RPC_Ioq_ThrdMax (default 200), no thread is left to 
accept or receive, and mounts from any client time out.
  
- Only focal needs the fix. bionic has ntirpc 1.6.1, which has no non-
- blocking send path. jammy and later have ntirpc >= 3.5.
+ The fix is upstream ntirpc PR #198, first released in v3.1.
+ It removes the two lines above, so only one svc_rqst_epoll_loop runs per 
event channel.
  
- [ Test Plan ]
+     https://github.com/nfs-ganesha/ntirpc/pull/198
+     c513a16c "Non-Blocking I/O results in hang."
+     75905949 "fix erronous bracket"
  
- Two VMs: a focal server (2 vCPU, 4G) and a client with the kernel NFS
- client (jammy was used).
+ Only focal needs the fix.
+ bionic has ntirpc 1.6.1, which has no non-blocking send path, and jammy and 
later have ntirpc >= 3.5.
+ 
+ [Test Plan]
+ 
+ Use two VMs: a focal server (2 vCPU, 4G) and a client with the kernel
+ NFS client (jammy was used).
  
  Server:
  
- $ sudo apt install nfs-ganesha nfs-ganesha-vfs
- $ sudo mkdir -p /srv/nfs
- $ for i in $(seq 8); do sudo dd if=/dev/urandom of=/srv/nfs/f$i bs=1M 
count=256 status=none; done
- $ cat /etc/ganesha/ganesha.conf
- NFS_CORE_PARAM {
-     Protocols = 3,4;
- }
- EXPORT {
-     Export_Id = 1;
-     Path = /srv/nfs;
-     Pseudo = /export;
-     Access_Type = RW;
-     Squash = No_Root_Squash;
-     SecType = sys;
-     Protocols = 3,4;
-     Transports = TCP;
-     FSAL { Name = VFS; }
- }
- $ sudo systemctl restart nfs-ganesha
+     sudo apt install nfs-ganesha nfs-ganesha-vfs
+     sudo mkdir -p /srv/nfs
+     for i in $(seq 8); do sudo dd if=/dev/urandom of=/srv/nfs/f$i bs=1M 
count=256 status=none; done
+ 
+ Put this in /etc/ganesha/ganesha.conf:
+ 
+     NFS_CORE_PARAM {
+         Protocols = 3,4;
+     }
+     EXPORT {
+         Export_Id = 1;
+         Path = /srv/nfs;
+         Pseudo = /export;
+         Access_Type = RW;
+         Squash = No_Root_Squash;
+         SecType = sys;
+         Protocols = 3,4;
+         Transports = TCP;
+         FSAL { Name = VFS; }
+     }
+ 
+ and restart the service:
+ 
+     sudo systemctl restart nfs-ganesha
  
  Client:
  
- $ sudo apt install nfs-common
- $ sudo mkdir -p /mnt/n1
- $ sudo mount -t nfs4 -o vers=4.1,rsize=1048576,hard <server>:/export /mnt/n1
- $ for i in $(seq 8); do (while :; do dd if=/mnt/n1/f$i of=/dev/null bs=1M 
iflag=direct status=none; done) & done
+     sudo apt install nfs-common
+     sudo mkdir -p /mnt/n1 /mnt/n2
+     sudo mount -t nfs4 -o vers=4.1,rsize=1048576,hard <server>:/export /mnt/n1
+     for i in $(seq 8); do (while :; do dd if=/mnt/n1/f$i of=/dev/null bs=1M 
iflag=direct status=none; done) & done
  
- While the load runs, on the server count the threads in epoll_wait
+ After two minutes of load, count the threads in epoll_wait on the server
  (syscall 232 on amd64):
  
- $ sudo sh -c 'cat /proc/$(pidof ganesha.nfsd)/task/*/syscall' | awk
+     sudo sh -c 'cat /proc/$(pidof ganesha.nfsd)/task/*/syscall' | awk
  '$1==232' | wc -l
  
- and on the client, from another shell:
+ and check the client from another shell:
  
- $ timeout 15 stat /mnt/n1/f1
- $ sudo mkdir -p /mnt/n2 && sudo timeout 60 mount -t nfs4 -o vers=4.1 
<server>:/export /mnt/n2
+     timeout 15 stat /mnt/n1/f1
+     sudo timeout 60 mount -t nfs4 -o vers=4.1 <server>:/export /mnt/n2
  
- Before the fix: the count starts at 5 and grows within 1-2 minutes (53
- and 200 in two runs). The dd processes stop, and stat and the second
- mount time out. The client may also log "nfs: server <ip> not
- responding, still trying".
+ Before the patch:
  
- After the fix: the count stays at 5 or below, and stat and new mounts
- keep answering for the whole run (5 minutes, about 253,000 RPCs served).
+  * The count starts at 5 and grows within 1-2 minutes (53 and 200 in two 
runs).
+  * The dd processes stop, and stat and the second mount time out.
  
- [ Where problems could occur ]
+ After the patch:
  
- The patch changes how a TCP send that would block is resumed: it now
- depends on the one epoll loop of the event channel picking up EPOLLOUT
- for that connection. A regression would show up as NFS replies stalling
- for clients whose send buffer is full (large READs, slow or congested
- clients): hung mounts or I/O timeouts on those clients while
- ganesha.nfsd itself keeps running.
+  * The count stays at 5 or below.
+  * stat and the second mount succeed during a 5 minute run.
+ 
+ [Where problems could occur]
+ 
+ A regression would show up as NFS replies stalling for clients whose send 
buffer is full (large READs, slow or congested clients): hung mounts or I/O 
timeouts on those clients while ganesha.nfsd keeps running.
+ After the patch a blocked send is resumed only by the one epoll loop of the 
event channel, so this would happen if that loop missed the EPOLLOUT event.
+ The Test Plan load exercises this path: the 1M direct reads fill the send 
buffer and hit EWOULDBLOCK.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2175678

Title:
  ntirpc: ganesha.nfsd stops answering NFS clients under read load on
  focal (duplicate svc_rqst_epoll_loop)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-pro/+bug/2175678/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to