Re: [nfsv4] Notes regarding discussion of directory scalabiliy issues

Rick Macklem <rmacklem@uoguelph.ca> Fri, 03 July 2020 01:03 UTC

Return-Path: <rmacklem@uoguelph.ca>
X-Original-To: nfsv4@ietfa.amsl.com
Delivered-To: nfsv4@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D1E063A09EB for <nfsv4@ietfa.amsl.com>; Thu, 2 Jul 2020 18:03:18 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.101
X-Spam-Level:
X-Spam-Status: No, score=-2.101 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=uoguelph.ca
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c6AB2gQ--Sgn for <nfsv4@ietfa.amsl.com>; Thu, 2 Jul 2020 18:03:16 -0700 (PDT)
Received: from CAN01-TO1-obe.outbound.protection.outlook.com (mail-eopbgr670081.outbound.protection.outlook.com [40.107.67.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1FB713A00D3 for <nfsv4@ietf.org>; Thu, 2 Jul 2020 18:03:15 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7bakEKsBs7U9+Mpk5crQN/PoJe+aAydVA35Y/IFt+kvCfCP4IA2RBZjxy2wdlBrZ1jpTyCBBA7FhtMAJFvfgrD4x1CBMjxPlY4eqTEHyk7/95gR6O9nxDU5SV5keLPwh7DDQ9V4vqfevisXLHN/DtxgRfFS0Rwp6CVJZMrR7RjxRbRGJzxdpcf9G0PbO4ycuW6yYr4eBQNVlETr1T0dLX7J8bLVPPLQ7hzlhUG1AdhI3tmCFA9gk/8AVXpE8nEQsp2yo/WoLbReaPOfjFOywNHRyi5Gd1O+/wGmHlFTKiFBui6FH02lxZZylG//KLUA79K2gmLLZOTRDpyWRkw0bg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X0uDp/EkWZ+CEZWOnOC4wTgNZWF6N1CmWGSvmNEJmsE=; b=aRhuancZ0n7wgUoYEkxOfJwJmD1qYIafDlulhO8SL6CNe5+GhuaDOAjXToMQNm67DTTnkBT+HzYuQ1RWfBAotUd2SxI5liJJ/Nr0IW8P3vlBMOITm8TYL7hkpY1SMP97NA0vMHs7FKMqty20GS9E1EIJMMNH+aa/ld+2OPAfUJOksM0rzx6qfRVp3TpTTYOHe+A63ENlzxqkU5qsTvYwYVLMQ7A8fLQGGK2eyTa5HzQ0GLvO5N7ymESRp/lqvJ1hFC6vq+IM2o7kQEzsHSRcq+sCBf0emhHqfNby+MVViANWw30JN7CG6JUCLB7fUPix44suN+bsp2SZWyZ7eFXjJw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=uoguelph.ca; dmarc=pass action=none header.from=uoguelph.ca; dkim=pass header.d=uoguelph.ca; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uoguelph.ca; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X0uDp/EkWZ+CEZWOnOC4wTgNZWF6N1CmWGSvmNEJmsE=; b=nOs2apYhheJQ921Z7S+zFVB2eFRb2FnmBeTQKuqeJh4iNEMT9Yw+3zpJ6zpLDMSgwNZ94k472kT/cvmpblKUxdBeV5s1Vo5kByeByOyRdcPSNGWTghb+x3QKXplUtPHWCma1Sjxg7cuhxTfo7jvGl7eqoHZufdkEpzaDD5CWPqNSmYVqoQhjW7MI3ixq7iDBEtUDSvjgOdxwhGWje1CERnN/QyJi+X/0P+MV2HRNFJWCySdyO8ZBUQds7S4fbvQcry4X/TC+8wFZ076Uxz0fYTlSXdBAL4Z9NWmw1As/N6QSClsWGQpHRPU61dPixxKjqLhzYVtK06mVZNkFh/zT4A==
Received: from QB1PR01MB3364.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:38::14) by QB1PR01MB3729.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:36::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Fri, 3 Jul 2020 01:03:09 +0000
Received: from QB1PR01MB3364.CANPRD01.PROD.OUTLOOK.COM ([fe80::60f3:4ca2:8a4a:1e91]) by QB1PR01MB3364.CANPRD01.PROD.OUTLOOK.COM ([fe80::60f3:4ca2:8a4a:1e91%7]) with mapi id 15.20.3153.024; Fri, 3 Jul 2020 01:03:09 +0000
From: Rick Macklem <rmacklem@uoguelph.ca>
To: David Noveck <davenoveck@gmail.com>, Trond Myklebust <trondmy@hammerspace.com>
CC: "nfsv4@ietf.org" <nfsv4@ietf.org>
Thread-Topic: [nfsv4] Notes regarding discussion of directory scalabiliy issues
Thread-Index: AQHWTturJpknuX+EYESd2ig3Ds4JHqjxKBOAgALrPICAAPM3TA==
Date: Fri, 03 Jul 2020 01:03:09 +0000
Message-ID: <QB1PR01MB3364D6132B8D515B7766A606DD6A0@QB1PR01MB3364.CANPRD01.PROD.OUTLOOK.COM>
References: <CADaq8jev+tUs=mrGDMnZMpfmQXL=KLwDKW5S-CbBLpL-54RJTA@mail.gmail.com> <3fc0af37d7d870eeb6ab854a75d6eeb5aae61a0d.camel@hammerspace.com> <CADaq8jcb5BLiE49SyS3wxbbDmz88GJNWeLgeh5XU4oGkdBuJmw@mail.gmail.com> <5d9b4f697ec698a7f07e8168f56826dbb52e234b.camel@hammerspace.com>, <CADaq8jenX2Su1MpMGpcvMuJncoDU+JMnMmdXaED9eYXiKrnGcA@mail.gmail.com>
In-Reply-To: <CADaq8jenX2Su1MpMGpcvMuJncoDU+JMnMmdXaED9eYXiKrnGcA@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=uoguelph.ca;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: f40b3f3e-128c-4c7d-e3d8-08d81eecda5c
x-ms-traffictypediagnostic: QB1PR01MB3729:
x-microsoft-antispam-prvs: <QB1PR01MB3729545FE058B3C68018422DDD6A0@QB1PR01MB3729.CANPRD01.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:9508;
x-forefront-prvs: 045315E1EE
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: sIoJ5Ui3RdXTj4M38GLmHcAmEk5BjzXi8NGjoxueHeCwm+FE7RyixfSLr2w6vProv1nUHP8keB54vZt+ad1XHjNP+CoXR5nSBtnnJh1H2PFjA14CKUcB0TJhf3gS3qem8mZvh6qi1pAYF0YVr7GYY454ZKAl+JaTP2FjmK739ezGMcmdZvN+vii3lvEFWoRkwSCkTMVq41QTV32+XWRsjcDpAUAvlQHyhScBJi85uA1Z26A/PAAGHrkI+qe9Sag1LPb6vN/thbj+zDhwB3xT3Em+5U3+VZvzEh2B/RUMLSXIAhRV8jz51J10JeTpLgl+8vlrVoOHeHcqhiuN6ukVh8tpGK+KJ92tpJT94LKQB6Fq/gk4Dz10y21BD8th+OGaIFOnaY05Z5ZgD/IWt56VfA==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:QB1PR01MB3364.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(136003)(39860400002)(396003)(366004)(346002)(376002)(9686003)(8676002)(8936002)(5660300002)(966005)(2906002)(478600001)(30864003)(52536014)(76116006)(64756008)(66946007)(71200400001)(66476007)(66556008)(66446008)(110136005)(55016002)(186003)(86362001)(33656002)(7696005)(316002)(786003)(6506007)(83380400001)(53546011)(4326008); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata: ajsrwak51e+vW7O8cjSn3fG1/4jfm6x0Qd6pkJDFXy4fgwZBrG9NIa8hriOB+qjAFgGHn9DVt38thjy5yNErVOb0eLLIZ5VLGnkl7rTSL+ryX2ISOysz1qOFB+z1BZR2hj3wHkzzNn6/cmio3JtlprmFLBKg5hD0J+/X1poqPseNwNPQAxVgECW/cpOIE4mHDOFMwqshWUzRLJj1k/sYxiMWOmnz51U2X6WWHbZ51OWFk3010xsUv59dQ4rMxmnu1DHYPmKPJ63IKVFOzZudaSnGGRUpXowMDmiUp1qVJaanaUHSulBH8w8ZrG532TFJePxNUr6fQIqAxI/rwGl4BOghx8t3h3cGs1egJ5r3QX9uqOJnUWGA7RaNwBKFzpwfNwAQ6fCeCBgvI46k1Np3hpeKwWTVFXlJoSExQdly96RNx98ts5SK9DLuOX8HZNSq7Ejr29ERcRHUNiAF4Fn/vzM/hzQsGk/1mxpLMapynDNU/GRkxm2HCUGlpP8969mz6nIQjmBsM4BoekrJTX43VM+C/bR9pl0TshUPSBMdt6g=
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-OriginatorOrg: uoguelph.ca
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: QB1PR01MB3364.CANPRD01.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: f40b3f3e-128c-4c7d-e3d8-08d81eecda5c
X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2020 01:03:09.6611 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: be62a12b-2cad-49a1-a5fa-85f4f3156a7d
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: zgZjb4442VxsvGR/J1XZobBJJ0nnjK+uRPgci2/NVnznWaYh9517HMOAeN7/3U6hm2UptAe0WItNyWPoT/QxtA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: QB1PR01MB3729
Archived-At: <https://mailarchive.ietf.org/arch/msg/nfsv4/gYAbLo-Tna5_K4xERivuKp9B_m8>
Subject: Re: [nfsv4] Notes regarding discussion of directory scalabiliy issues
X-BeenThere: nfsv4@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NFSv4 Working Group <nfsv4.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/nfsv4>, <mailto:nfsv4-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/nfsv4/>
List-Post: <mailto:nfsv4@ietf.org>
List-Help: <mailto:nfsv4-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/nfsv4>, <mailto:nfsv4-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 03 Jul 2020 01:03:19 -0000

Well, I'll throw out a simple suggestion w.r.t. directory cookies.

What if the cookies generated by the server were required to have the
following properties:
- Monotonically increasing numeric values.
- Sparse enough that new entries can be created with numeric values
  between them.
- Guaranteed to not change and remain valid (and referring to the same entry)
  despite additions/deletions. (Until a deletion callback is received by the client.)

For example, for a simple case of a UFS file system on a server, the UFS
directory consists of blocks of directory entries.
- When an entry is added, it goes in a gap within the directory or grows a
   new block at the end (if I vaguely recall this correctly;-).
- When an entry is removed, the entry is erased without moving other
   entries.
For this example, the directory offset cookie can simply be the byte offset
of the entry.
(I haven't looked at other file systems, but hopefully offset cookies with the
 above properties can be created for most of them?)

When an entry is added/deleted, the server issues a callback to the client
with the new directory cookie offset (and the directory entry for the add case).

The client can maintain this structure in any number of ways (and it could be
fun figuring out what works well), but a trivial version could be:
- The reply to a readdir is kept as a list head (with the directory offset of the
   first entry) and a linked list of the entries in order, with their cookie.
  (Remember that the cookies are in the same ordering as the entries.)
- The next readdir reply creates the next head/list.

readdir() just works through each list, following each head in order.
telldir() returns the cookie for the entry.
seekdir() just finds the correct list and then searches down that list for a match.

The remove/add entry callbacks just insert/delete entrie(s) in the appropriate
list.
(I'd probably keep these lists in the kernel client under the VFS for FreeBSD,
 as malloc'd data structures, but that is simply an implementation choice.)

You would require the monotonically increasing property for directory
delegations to be issued. (Without that you don't know where to insert
additions.) You would also require that extant directory entry cookies
remain valid and unchanged when additions/deletions occur.
(Note that removing an entry and then adding an entry at the same offset
 is allowed under POSIX telldir()/seekdir() as I understand it.)

This avoids any need for the client to synthesize cookies and just use the ones
returned by the server, I think?

Just a simple idea that may be worth considering?
(If this has already been discussed, I apologize for not seeing it.)

rick

________________________________________
From: nfsv4 <nfsv4-bounces@ietf.org> on behalf of David Noveck <davenoveck@gmail.com>
Sent: Thursday, July 2, 2020 6:06 AM
To: Trond Myklebust
Cc: nfsv4@ietf.org
Subject: Re: [nfsv4] Notes regarding discussion of directory scalabiliy issues

CAUTION: This email originated from outside of the University of Guelph. Do not click links or open attachments unless you recognize the sender and know the content is safe. If in doubt, forward suspicious emails to IThelp@uoguelph.ca



On Tuesday, June 30, 2020, Trond Myklebust <trondmy@hammerspace.com<mailto:trondmy@hammerspace.com>> wrote:
On Tue, 2020-06-30 at 08:40 -0400, David Noveck wrote:
Thanks for your helpful comments.

On Mon, Jun 29, 2020 at 2:43 PM Trond Myklebust <trondmy@hammerspace.com<mailto:trondmy@hammerspace.com>> wrote:
Like it or not, the readdir cookie is an attribute of the directory.


If the protocol treated them as such, then the attribute notifications feature could provide updates to the client.   Given that it doesn't, we could add a cookie update feature to directory notification feaure as a v4.2 extension to the protocol.  However, I'm reluctant to start work on the necessary protocol additions until we are sure they are needed to provide better directory cacheability.

Actually, they are attributes of directory streams.   The difference is not all that important given that client implementations are unlikely to be aware of the specific steam associated with any particular request.  However, there are a few cases in which the difference is important in determining whether various approaches to client handling of cookies might or might not work, and will be important in the discussion below:

  *   Two requests made on different clients necessarily are made on distinct streams.
  *   Two requests made on different instances of the same client (with an intervening restart/reboot) also have to arise on different streams.

If I want to support the POSIX telldir() and seekdir() operations ( https://pubs.opengroup.org/onlinepubs/9699919799/functions/seekdir.html ), then I need to ensure that when the application calls seekdir(), I return to the exact same cursor location in the stream that I was at when I called telldir().


Agreed.

Without a server side cookie on which to anchor my telldir() cookies,


Every client has these available but it is not clear to me useful such anchoring is.   I think the flexibility that each client has to assign cookies to streams it is responsible for is valuable and could be compromised if anchoring to the server cookies is made the focus of the implementation.

then all I have is a list of filenames that can and will change every time a file is created, deleted or renamed.


Clearly it will change.  However, the directory notifications feature makes some assumptions, currently implicit about how the list will change.   Once these are made explicit, the wg could decide that server/fs pairs incapable of staying within these reasonable restrictions (if they are, in fact, reasonable), cannot support the directory notifications feature.

Both the length and ordering of that list may change whenever the directory is modified,


Clearly the length will change, but the reasonable expectation is that creating a file will increase the length by one and deleting one will decrease it by one.   I don't see the value of supporting directory notifications on server fs that do something else.

With regard ro ordering,  suppose the spec allows an fs to shuffle the directory order every time a change is made, but I'm unaware of any actual file systems that do this.   Do we need to support directory notifications for such fs's?


touch foo; touch bar; ln foo baz; rm foo; mv baz foo

There... Most filesystems will end up reordering 'foo' and 'bar' in the directory stream given the above sequence of commands. How does the client figure out what happened if the above sequence of commands is performed on the server?
Now let's say that is a directory of a million files, and something like the above is made to happen regularly. How do I maintain a stable list of synthetic cookies on the client?

I think you are right about there being cases in which it is impossible, but we either disagree or are simply talking past one another about other cases.

If the caching client is making the directory changes, then I agree this cannot be done and you are stuck having to refetch potentially large directories to deal with new READDIR requests☹️

Where we might disagree is the case in which another client is making the change.  In that case directory notifications would allow you to avoid repeated READDIR ops, whether you are providing the user synthetic or server-based cookies.

My talk on directory caching will discuss the possibility of v4.2 extensions to address the same-client directory caching issue, as well as possible clarifications regarding directory delegation/notification in v4.1.


meaning that a naive implementation


OK.   I'll plead guilty to one misdemeanor count of directory naivety.

of synthetic cookies as an offset is not compatible with the telldir()/seekdir() requirements.


It's not clear to me how this incompatibility would manifest itself.  I think I need to understand what would break.

To make matters worse, the list size is for all intents and purposes unbounded, because there is no hard limit on the size of a directory. That makes it also impossible to create a cached mapping between a synthetic cookie and a filename; such a mapping would be unbounded both in size and in duration (since we don't know a priori how long the application will keep the directory open, or for that matter, which exact set of cookies it may have cached).


Such a mapping would, in essence, be part of the cached directory.   So, if it is too big to keep in client memory,then it is too big to cache and you might as well decide not to cache it.

I expect there is an issue that is a worry in the case in which a reasonably sized directory  grows over time to be too big to cache while an open directory stream retains some directory cookies which might be incompatible with the client dropping  caching of directories and switching to server-based cookies.😖
I feel it is reasonable to treat this situation as one might a cookie-verifier failure, particularly if this is the only worrisome failure mode.   However, this possibility means that I would not ask clients to implement such local cookies. To enable that, we would have to make explicit the same sort of reasonableness requirement for cookie changes that we have already discussed for ordering changes.  RFC7530 already alludes to the need to avoid spurious cookie invalidations although not in as explicit or strict way as we would need to support directory notifications:

   As there is no way for the client to indicate that a cookie value,

   once received, will not be subsequently used, server implementations

   should avoid schemes that allocate memory corresponding to a returned

   cookie.  Such allocation can be avoided if the server bases cookie

   values on a value such as the offset within the directory where the

   scan is to be resumed.


   Cookies generated by such techniques should be designed to remain

   valid despite modification of the associated directory.  If a server

   were to invalidate a cookie because of a directory modification,

   READDIRs of large directories might never finish.


So in order to make this work the client would basically have to create its own B-tree and persist it in storage somewhere.


I don't see the need to make this persistent.  If the client restarts, all directory streams have ceased to exist and we know  a posteriori  that there are no outstanding directory cookies to which the client would have to respond.
<mailto:nfsv4@ietf.org>

--

--

Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com<mailto:trond.myklebust@primarydata.com>