Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Jan 2022 10:51:31 -0800
From:      Xin Li via freebsd-current <freebsd-current@freebsd.org>
To:        freebsd-current <freebsd-current@freebsd.org>
Cc:        rmacklem@freebsd.org, "re@FreeBSD.org Engineering Team" <re@freebsd.org>
Subject:   [RFC] Making mount_nfs to attempt NFSv4 before NFSv3 and NFSv2?
Message-ID:  <dc6de81f-ce20-a772-18b6-d94a3aea97e1@delphij.net>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------emBi8ePUfEbKBsuUI3TW0MQo
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Currently, mount_nfs will attempt to use NFSv3 and fallback to NFSv2. 
The manual page says:

      nfsv2   Use the NFS Version 2 protocol (the default is to try
              version 3 first then version 2).  Note that NFS version 2
              has a file size limit of 2 gigabytes.

And the code agrees, too:

%%%%%%%%
         if (trymntmode == V4) {
                 nfsvers = 4;
                 mntvers = 3; /* Workaround for GCC. */
         } else if (trymntmode == V2) {
                 nfsvers = 2;
                 mntvers = 1;
         } else {
                 nfsvers = 3;
                 mntvers = 3;
         }
%%%%%%%%

When trymntmode == ANY, which is the default, mount_nfs would attempt 
NFSv3, and if rpcb_getaddr() returned RPC_PROGVERSMISMATCH, it would try 
again with trymntmode = V2.

Nowadays, it seems that NFSv4 is becoming more and more popular.  If a 
server is providing only NFSv4 service, when mounting without -o nfsv4, 
the user would receive message like:

	RPCPROG_MNT: RPC:Timed out

A friend of mine who is using TrueNAS core hit this yesterday and his 
Linux client worked just fine.  It took me some time to figure out that 
the root cause.  It seems that modern Linux distributions have been 
using NFSv4 by default for some time.

So I think it makes sense to teach mount_nfs to attempt NFSv4, then 
NFSv3 and NFSv2.  However, this might be a POLA violation and we would 
like to know if there is any objections.

(I've attached a patch but I haven't actually tested it yet).

Cheers,
--------------emBi8ePUfEbKBsuUI3TW0MQo
Content-Type: text/x-patch; charset=UTF-8;
 name="0001-mount_nfs-Attempt-NFSv4-before-NFSv3-and-NFSv2.patch"
Content-Disposition: attachment;
 filename*0="0001-mount_nfs-Attempt-NFSv4-before-NFSv3-and-NFSv2.patch"
Content-Transfer-Encoding: base64

RnJvbSBlYjZlNjAyMzNkODQwZDA3MmQwMjgwMzI1Y2EyY2IzNzQ1NWRjMmYxIE1vbiBTZXAg
MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBYaW4gTEkgPGRlbHBoaWpARnJlZUJTRC5vcmc+CkRh
dGU6IE1vbiwgMyBKYW4gMjAyMiAxMDo0ODoxNyAtMDgwMApTdWJqZWN0OiBbUEFUQ0hdIG1v
dW50X25mczogQXR0ZW1wdCBORlN2NCBiZWZvcmUgTkZTdjMgYW5kIE5GU3YyLgoKLS0tCiBz
YmluL21vdW50X25mcy9tb3VudF9uZnMuOCB8ICA2ICsrKy0tLQogc2Jpbi9tb3VudF9uZnMv
bW91bnRfbmZzLmMgfCAyOSArKysrKysrKysrKysrKysrKysrKy0tLS0tLS0tLQogMiBmaWxl
cyBjaGFuZ2VkLCAyMyBpbnNlcnRpb25zKCspLCAxMiBkZWxldGlvbnMoLSkKCmRpZmYgLS1n
aXQgYS9zYmluL21vdW50X25mcy9tb3VudF9uZnMuOCBiL3NiaW4vbW91bnRfbmZzL21vdW50
X25mcy44CmluZGV4IDY0OGNiMjEyOGU5MC4uNzQxYjVjMjRhMDgwIDEwMDY0NAotLS0gYS9z
YmluL21vdW50X25mcy9tb3VudF9uZnMuOAorKysgYi9zYmluL21vdW50X25mcy9tb3VudF9u
ZnMuOApAQCAtMjgsNyArMjgsNyBAQAogLlwiCUAoIyltb3VudF9uZnMuOAk4LjMgKEJlcmtl
bGV5KSAzLzI5Lzk1CiAuXCIgJEZyZWVCU0QkCiAuXCIKLS5EZCBKdWx5IDEwLCAyMDIxCisu
RGQgSmFudWFyeSAxMCwgMjAyMgogLkR0IE1PVU5UX05GUyA4CiAuT3MKIC5TaCBOQU1FCkBA
IC0yMTYsOCArMjE2LDggQE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HJ5bW50bW9kZSA9IFYyOworCQkJCQlnb3RvIHRyeWFnYWluOworCQkJCX0KIAkJCX0K
IAkJCXNucHJpbnRmKGVycmJ1Ziwgc2l6ZW9mIGVycmJ1ZiwgIlslc10gJXM6JXM6ICVzIiwK
IAkJCSAgICBuZXRpZCwgaG9zdHAsIHNwZWMsCi0tIAoyLjM0LjEKCg==

--------------emBi8ePUfEbKBsuUI3TW0MQo--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?dc6de81f-ce20-a772-18b6-d94a3aea97e1>