Public bug reported:

[ 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:

 * 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 (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 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.

** Affects: ubuntu-pro
     Importance: Undecided
         Status: New

** Affects: ubuntu-pro/20.04
     Importance: Undecided
         Status: New

** Affects: ntirpc (Ubuntu)
     Importance: Undecided
         Status: Fix Released

** Affects: ntirpc (Ubuntu Focal)
     Importance: Undecided
         Status: Won't Fix

** Also affects: ubuntu-pro/20.04
   Importance: Undecided
       Status: New

** Also affects: ntirpc (Ubuntu Focal)
   Importance: Undecided
       Status: New

** Changed in: ntirpc (Ubuntu Focal)
       Status: New => Won't Fix

** Changed in: ntirpc (Ubuntu)
       Status: New => Fix Released

-- 
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