<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[NFS remote leaks file descriptors and leaves .nfs files behind after each disable/enable cycle]]></title><description><![CDATA[<p dir="auto">Hi, I noticed that every time an NFS backup remote is disabled and re-enabled in Xen Orchestra, a new empty <code>.nfs</code> file is created while the previous files remain on the storage.</p>
<p dir="auto">Xen Orchestra built from source, commit 54051163e0, mount options: <code>hard,proto=tcp,timeo=600,retrans=2</code></p>
<p dir="auto">The NAS remains available at all times. No network interruption is required to reproduce the issue. I monitored the open file descriptors. Here is an example of consecutive disable/enable cycles:</p>
<pre><code class="language-text">Remote enabled (3 open descriptors):

l-wx------ 1 root root 64 Nov 28 17:15 34 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfd00000048
l-wx------ 1 root root 64 Nov 28 17:15 35 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbff0000004a
l-wx------ 1 root root 64 Nov 28 17:15 36 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfe00000049

Remote disabled (2 open descriptors):

l-wx------ 1 root root 64 Nov 28 17:15 34 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfd00000048
l-wx------ 1 root root 64 Nov 28 17:15 36 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfe00000049

Remote enabled (4 open descriptors):

l-wx------ 1 root root 64 Nov 28 17:15 34 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfd00000048
l-wx------ 1 root root 64 Nov 28 17:15 35 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddc010000004b
l-wx------ 1 root root 64 Nov 28 17:15 36 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfe00000049
l-wx------ 1 root root 64 Nov 28 17:16 37 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddc020000004c

Remote disabled (3 open descriptors):

l-wx------ 1 root root 64 Nov 28 17:15 34 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfd00000048
l-wx------ 1 root root 64 Nov 28 17:15 35 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddc010000004b
l-wx------ 1 root root 64 Nov 28 17:15 36 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfe00000049

Remote enabled (5 open descriptors):

l-wx------ 1 root root 64 Nov 28 17:15 34 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfd00000048
l-wx------ 1 root root 64 Nov 28 17:15 35 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddc010000004b
l-wx------ 1 root root 64 Nov 28 17:15 36 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddbfe00000049
l-wx------ 1 root root 64 Nov 28 17:16 37 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddc040000004d
l-wx------ 1 root root 64 Nov 28 17:16 38 -&gt; /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699/.nfs00000000007ddc050000004e
</code></pre>
<p dir="auto">During an earlier test, I reached 37 open file descriptors. Disabling the remote closed only one of them, leaving 36 still open.</p>
<p dir="auto">Even though the remote is disabled in XO, the NFS filesystem remains mounted at OS level:</p>
<pre><code class="language-text">$ findmnt -t nfs,nfs4
TARGET                                     SOURCE            FSTYPE OPTIONS
/run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699
                                           192.168.10.30:/volume1/backup_xcp
                                                             nfs4   rw,relatime,vers=4.1,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=
</code></pre>
<p dir="auto">Trying to unmount it manually results in the following error:</p>
<pre><code class="language-text">$ sudo umount /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699
umount.nfs4: /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699: device is busy
</code></pre>
<p dir="auto">After stopping the xo-server service, the same unmount command completes successfully.</p>
<p dir="auto">This also appears to explain the failed unmount message during the shutdown of the VM running Xen Orchestra:</p>
<pre><code class="language-text">[FAILED] Failed unmounting /run/xo-server/mounts/e81c1a19-826e-4137-ad0b-e77aecae9699
</code></pre>
<p dir="auto">I asked AI to review the source code in <code>@xen-orchestra/fs/src/_mount.js</code> (<a href="https://github.com/vatesfr/xen-orchestra/blob/54051163e0/@xen-orchestra/fs/src/_mount.js" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/vatesfr/xen-orchestra/blob/54051163e0/@xen-orchestra/fs/src/_mount.js</a>) and found the following:</p>
<pre><code class="language-javascript">const keeperPath = `${realPath}/.keeper_${Math.random().toString(36).slice(2)}`
this.#keeper = await fs.open(keeperPath, 'w')
ignoreErrors.call(fs.unlink(keeperPath))
</code></pre>
<p dir="auto">The creation of <code>.nfs</code> files is expected NFS behaviour because XO intentionally deletes keeper files while keeping their file descriptors open. However, the increasing number of open descriptors is not expected. The observed behaviour suggests that two keeper descriptors are opened during remote activation, but only one is properly closed during deactivation.</p>
<p dir="auto">It may be worth checking whether <code>_sync()</code> is called twice during remote activation, whether the <code>#keeper</code> reference is overwritten without closing the previous descriptor, or whether multiple handler instances are created for the same remote.</p>
<p dir="auto">Another possible cause is the asynchronous handler clean-up in <a href="https://github.com/vatesfr/xen-orchestra/blob/54051163e0/packages/xo-server/src/xo-mixins/remotes.mjs" target="_blank" rel="noopener noreferrer nofollow ugc"><code>packages/xo-server/src/xo-mixins/remotes.mjs</code></a>.</p>
<p dir="auto">A possible solution would be to ensure that existing keeper descriptors are properly closed before opening new ones, wait for handler clean-up to complete before replacing a handler, and prevent overlapping operations for the same remote. Logging failed close and unmount operations instead of silently ignoring them could also help identify the cause.</p>
<p dir="auto">The number of open file descriptors should remain stable across repeated disable/enable cycles. Disabling an unused remote should release all associated file descriptors, remove the temporary <code>.nfs</code> files and allow the NFS filesystem to be unmounted.</p>
<p dir="auto">A simple regression test covering repeated disable/enable cycles could help verify this behaviour.</p>
<p dir="auto">The issue is consistently reproducible, although the exact cause in the source code remains unconfirmed and the proposed changes have not been tested.</p>
<p dir="auto">Possibly related to #10741, although no NFS server outage or network interruption is required to reproduce this issue.</p>
]]></description><link>https://xcp-ng.org/forum/topic/12603/nfs-remote-leaks-file-descriptors-and-leaves-.nfs-files-behind-after-each-disable-enable-cycle</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 17:02:05 GMT</lastBuildDate><atom:link href="https://xcp-ng.org/forum/topic/12603.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Nov 2026 16:37:15 GMT</pubDate><ttl>60</ttl></channel></rss>