Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3551081pxm; Tue, 1 Mar 2022 00:05:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJYW0Hz2zqmk8Kz7LAPgaZ3dQLTgL0uhwo4RCUZwr6nV1UwaLvg4exemIpPLapJN84c539 X-Received: by 2002:a05:6402:3508:b0:403:ba8f:4265 with SMTP id b8-20020a056402350800b00403ba8f4265mr23031525edd.184.1646121906502; Tue, 01 Mar 2022 00:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646121906; cv=none; d=google.com; s=arc-20160816; b=L1ewyBZJL+8dogWrbRU1ZLgHkuMPNHZKwHcp+qFbqFOg5AAfJA5dF03AhL83SDIKZT WjGnv8c3F4BuFZu2bSL5tYpdM9qs5YsqiRCtGxHL31mO4hG5P6gsha66a0II9iccYklW 4jxC2M7xfeCkB+zaJcIikP/56GHy9U8Ojge3V/9CReJ0n9Z3LuEVf5HTgt5Zhr2Vqfn1 joqHkrlXUwxKiLAB6/yOrLxZrXU9EWT5qQN+QsJudNwn4pEIyqzTn5th6iDVhXrHCWS+ TcX2QEGddjtvfquT8GZJIDNiuuYmD15qJdQLhHb9MhwUCJbmXxB860RmyU3kH9deIB2R Qv1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=CWqzKCfzxz3sHOyyf3gGRmfhR9Z6tAnI1OJD5qFwojk=; b=Gh5haNskBU+vM0wWMH7ZyMGbyW5hoPH08BN2ikG9kxIJBsrDsbGFulPc0LlL8oYyx9 muF33GOx21yMC4I/5rwgjwqHUru+/ruXKbyHZyOQDEj16dlt58AFhvDlm1gQeGq00vnK CyccFPIQvnpsjt2vCrAOPrfB2Jk73e/xY5MjdWf1TWSE+SVGuc/HkomBib7po1AU5g+J xyBz8mWZvv8l0YhXj8zhL5gvMWEH72w/P/cdyl1qneHvwrAp4sho3KBKIjs1mUXvEGa9 TP0tipqs+znGborS86pf5ZjyLh0tuLAVxhkLW9KOnC1fxhhRC8WuA2dRFtVPSwPpo68B lY8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=s9+xjrCJ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=0NguVe2P; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v25-20020a50d099000000b00410a4b42d14si8323366edd.447.2022.03.01.00.04.30; Tue, 01 Mar 2022 00:05:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=s9+xjrCJ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=0NguVe2P; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231972AbiCADon (ORCPT + 99 others); Mon, 28 Feb 2022 22:44:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbiCADom (ORCPT ); Mon, 28 Feb 2022 22:44:42 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F30061A1F for ; Mon, 28 Feb 2022 19:44:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DBFD8219A6; Tue, 1 Mar 2022 03:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646106240; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CWqzKCfzxz3sHOyyf3gGRmfhR9Z6tAnI1OJD5qFwojk=; b=s9+xjrCJmE1ihxUyptYcN6GRhAq/q6s7U5300OYGBS9QYPOlFeoi/ZHc4LFP271Bi8v6kc X/mFxmB9Ejhg9L/UEHzgk53E3i0R2JiMeWVTgUYfs0Dy5U34VZYi8KkD1PkKjqSRbyMMul GPlzoY4N/yaeqHS+HhvbWftGl8hx8Ao= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646106240; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CWqzKCfzxz3sHOyyf3gGRmfhR9Z6tAnI1OJD5qFwojk=; b=0NguVe2PnEIqmvU2n9NBvQ+SrLZU2DsFfZKSZU0KdEDD/3qZWC0VPawtwZIwyK8TEyo4DI Mzxf5qSmyHf8srAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8D6C513AF5; Tue, 1 Mar 2022 03:43:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hlEZE3+WHWIxbQAAMHmgww (envelope-from ); Tue, 01 Mar 2022 03:43:59 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Benjamin Coddington" , "Steve Dickson" Cc: "Chuck Lever III" , "Linux NFS Mailing List" Subject: [PATCH] nfs.man: document requirements for NFS mounts in a container In-reply-to: <164505339057.10228.4638327664904213534@noble.neil.brown.name> References: , =?utf-8?q?=3C9c04664?= =?utf-8?q?8bfd9c8260ec7bd37e0a93f7821e0842f=2E1644515977=2Egit=2Ebcodding?= =?utf-8?q?=40redhat=2Ecom=3E=2C?= <7642FA55-F3F2-4813-86E2-1B65185E6B36@oracle.com>, <3d2992df-7ef7-50ba-4f11-f4de588620d2@redhat.com>, , , , <4657F9AE-3B9E-4992-9334-3FF1CF18EF31@redhat.com>, , <945849B4-BE30-434C-88E9-8E901AAFA638@redhat.com>, <06B01290-E375-455E-A6D7-419CA653A0D1@oracle.com>, <948D8123-E310-4A35-BF04-C030F20EA83C@redhat.com>, <164479707170.27779.15384523062754338136@noble.neil.brown.name>, <863AB69A-D5D6-4F22-950C-E5F468CD4552@redhat.com>, <42AAFEDD-F4EE-4A91-BD23-E08B1149EF1C@oracle.com>, <3AF29DC6-2EEB-4C3E-BD6C-BE31910921AE@redhat.com>, <9FC005FB-370E-4AFA-AD80-8599CBFCC1E0@oracle.com>, <2965D098-7AEE-419D-BF8B-4D7AF4AB40FB@redhat.com>, <164505339057.10228.4638327664904213534@noble.neil.brown.name> Date: Tue, 01 Mar 2022 14:43:56 +1100 Message-id: <164610623626.24921.6124450559951707560@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When mounting NFS filesystems in a network namespace using v4, some care must be taken to ensure a unique and stable client identity. Add documentation explaining the requirements for container managers. Signed-off-by: NeilBrown --- NOTE I originally suggested using uuidgen to generate a uuid from a container name. I've changed it to use the name as-is because I cannot see a justification for using a uuid - though I think that was suggested somewhere in the discussion. If someone would like to provide that justification, I'm happy to include it in the document. Thanks, NeilBrown utils/mount/nfs.man | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/utils/mount/nfs.man b/utils/mount/nfs.man index d9f34df36b42..4ab76fb2df91 100644 --- a/utils/mount/nfs.man +++ b/utils/mount/nfs.man @@ -1844,6 +1844,69 @@ export pathname, but not both, during a remount. For = example, merges the mount option .B ro with the mount options already saved on disk for the NFS server mounted at /= mnt. +.SH "NFS IN A CONTAINER" +When NFS is used to mount filesystems in a container, and specifically +in a separate network name-space, these mounts are treated as quite +separate from any mounts in a different container or not in a +container (i.e. in a different network name-space). +.P +In the NFSv4 protocol, each client must have a unique identifier. +This is used by the server to determine when a client has restarted, +allowing any state from a previous instance can be discarded. So any two +concurrent clients that might access the same server MUST have +different identifiers, and any two consecutive instances of the same +client SHOULD have the same identifier. +.P +Linux constructs the identifier (referred to as=20 +.B co_ownerid +in the NFS specifications) from various pieces of information, three of +which can be controlled by the sysadmin: +.TP +Hostname +The hostname can be different in different containers if they +have different "UTS" name-spaces. If the container system ensures +each container sees a unique host name, then this is +sufficient for a correctly functioning NFS identifier. +The host name is copied when the first NFS filesystem is mounted in +a given network name-space. Any subsequent change in the apparent +hostname will not change the NFSv4 identifier. +.TP +.B nfs.nfs4_unique_id +This module parameter is the same for all containers on a given host +so it is not useful to differentiate between containers. +.TP +.B /sys/fs/nfs/client/net/identifier +This virtual file (available since Linux 5.3) is local to the network +name-space in which it is accessed and so can provided uniqueness between +containers when the hostname is uniform among containers. +.RS +.PP +This value is empty on name-space creation. +If the value is to be set, that should be done before the first +mount (much as the hostname is copied before the first mount). +If the container system has access to some sort of per-container +identity, then a command like +.RS 4 +echo "$CONTAINER_IDENTITY" \\ +.br + > /sys/fs/nfs/client/net/identifier=20 +.RE +might be suitable. If the container system provides no stable name, +but does have stable storage, then something like +.RS 4 +[ -s /etc/nfsv4-uuid ] || uuidgen > /etc/nfsv4-uuid &&=20 +.br +cat /etc/nfsv4-uuid > /sys/fs/nfs/client/net/identifier=20 +.RE +would suffice. +.PP +If a container has neither a stable name nor stable (local) storage, +then it is not possible to provide a stable identifier, so providing +a random one to ensure uniqueness would be best +.RS 4 +uuidgen > /sys/fs/nfs/client/net/identifier +.RE +.RE .SH FILES .TP 1.5i .I /etc/fstab --=20 2.35.1