From owner-freebsd-current@freebsd.org Tue Nov 28 23:19:01 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D7830DF1DDE; Tue, 28 Nov 2017 23:19:01 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0042.outbound.protection.outlook.com [104.47.32.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT SSL SHA2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6B3927D29F; Tue, 28 Nov 2017 23:19:00 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from YTOPR0101MB2172.CANPRD01.PROD.OUTLOOK.COM (52.132.46.161) by YTOPR0101MB2171.CANPRD01.PROD.OUTLOOK.COM (52.132.46.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.260.4; Tue, 28 Nov 2017 23:18:59 +0000 Received: from YTOPR0101MB2172.CANPRD01.PROD.OUTLOOK.COM ([fe80::f072:85d3:769:e6f8]) by YTOPR0101MB2172.CANPRD01.PROD.OUTLOOK.COM ([fe80::f072:85d3:769:e6f8%13]) with mapi id 15.20.0260.007; Tue, 28 Nov 2017 23:18:57 +0000 From: Rick Macklem To: Emmanuel Vadot CC: Konstantin Belousov , FreeBSD Current , "freebsd-fs@freebsd.org" , Rick Macklem Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? Thread-Topic: Switch vfs.nfsd.issue_delegations to TUNABLE ? Thread-Index: AQHTaEyAfy6q2cCLHkW9s1ZyeaxyRaMpzDeAgAAEfyqAAB1rAIAANPobgABJSsyAAAEe3g== Date: Tue, 28 Nov 2017 23:18:57 +0000 Message-ID: References: <20171128114136.10e44d5bcfd563e9b4ab5453@bidouilliste.com> <20171128110428.GN2272@kib.kiev.ua> <20171128142610.6ab535b0b8c6b5d372cd3f27@bidouilliste.com> <20171128134009.GQ2272@kib.kiev.ua> , <20171128164132.290bf07218b16164db613242@bidouilliste.com>, , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; YTOPR0101MB2171; 6:kqoz5f9CHPgWAMFJyzcl5A+3GStgDFV9rEe/BdspUneWbRWr0anaEe0jbBs+x5q42dfA+8ozUockrgnf0aY9t0CV4+fC5vDwuRCdOedY13mPjOlVOWiFQma/g2dgHKuWoUjiFtbbB6uFtn7RVaQsuDAGjIH3Lv19PB5wVnksA0BHYCS5/VMFDrRZQuVteBQvmndLhHXil0kRclf0xQlly7VQ6CyrJY7xvMEuhoXXTmACYEpRldwiw/7rMNe2mtiZ72Ii6+vqZLuV7Cx9+knmQx7FJaXGegLvFjHjubqhAO1y166VfzPVUktdvfCwGiZX2dOaO0CtRNwtFScuqryw/v3TQeATAf01iCipdVYk5Ro=; 5:5bhncfadejoejFRnow/FMLCpNU1kwpQOObVCN5YW5WTuiQHRL9q7Kf58GjVCdmRGrsAI/ytbCChN+EK4qvA35pJJY0hO1FofVwsrKnPfqRe5nBT2K2UJUAQMCheMyaP1fs2BkrzlUnTjkH/XThll25qLpKbxdD/tssPv27zDy2I=; 24:Y87QWcn6vYx6tq9E22giMehLFRK0CAhEjaZ+JUIdgeMqqcxDZ6NVVPuXxuR9p1ml6/iLNHJN11dTnXBGuCXOv5vXRAI+ePB9NTEmUYf97IQ=; 7:VjQ2K4+zpyTuKWX3frij7Xd0ZGy7j/S84j78cDweaWoaByddLojaWPlKJx8WMcsaMBSenQAwfVRZHHKflyEYXX6XH3tFLJg9bKa0UBuwx89Bkt1J4xhLeNj5PMZha2QRRAa5M8M7O+QK16ZR5R3nuSpspfllk7QWj2HBr0hiISuwWEtowszf3q0uFe+P2+1wMuXkPHtAQwBMzOPQi96scH71E6FR0I9V83odKzT8onGLIv8RDRlnk/8909IcqOdf x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 59445177-2c8c-4f87-b52a-08d536b666bb x-microsoft-antispam: UriScan:(18154293887054); BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(8989060)(201703031133081)(201702281549075)(8990040)(5600026)(4604075)(2017052603261)(49563074); SRVR:YTOPR0101MB2171; x-ms-traffictypediagnostic: YTOPR0101MB2171: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863)(18154293887054); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040450)(2401047)(5005006)(8121501046)(3231022)(10201501046)(3002001)(93006095)(93001095)(6041248)(20161123560025)(20161123564025)(20161123555025)(20161123558100)(20161123562025)(201703131423075)(201702281529075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:YTOPR0101MB2171; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:YTOPR0101MB2171; x-forefront-prvs: 0505147DDB x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(366004)(24454002)(189002)(199003)(5890100001)(25786009)(316002)(786003)(76176999)(5250100002)(189998001)(478600001)(86362001)(55016002)(54906003)(53546010)(68736007)(2940100002)(4326008)(3280700002)(8676002)(97736004)(7696005)(74316002)(305945005)(81156014)(81166006)(9686003)(3660700001)(5660300001)(2950100002)(14454004)(6916009)(105586002)(2900100001)(93886005)(39060400002)(2906002)(33656002)(8936002)(106356001)(229853002)(74482002)(102836003)(54356999)(99936001)(99286004)(6246003)(53936002)(6436002)(101416001)(50986999)(6506006); DIR:OUT; SFP:1101; SCL:1; SRVR:YTOPR0101MB2171; H:YTOPR0101MB2172.CANPRD01.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: uoguelph.ca does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rmacklem@uoguelph.ca; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/mixed; boundary="_002_YTOPR0101MB21721E82EF605249D38064A1DD3A0YTOPR0101MB2172_" MIME-Version: 1.0 X-OriginatorOrg: uoguelph.ca X-MS-Exchange-CrossTenant-Network-Message-Id: 59445177-2c8c-4f87-b52a-08d536b666bb X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2017 23:18:57.7537 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: be62a12b-2cad-49a1-a5fa-85f4f3156a7d X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTOPR0101MB2171 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Nov 2017 23:19:02 -0000 --_002_YTOPR0101MB21721E82EF605249D38064A1DD3A0YTOPR0101MB2172_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Did my usual and forgot to attach it. Here's the patch, rick ________________________________________ From: Rick Macklem Sent: Tuesday, November 28, 2017 6:17:13 PM To: Emmanuel Vadot Cc: Konstantin Belousov; FreeBSD Current; freebsd-fs@freebsd.org; Rick Mack= lem Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? I think the attached patch should fix your performance problem. It simply checks for nfsrv_delegatecnt !=3D 0 before doing all the locking stuff in nfsrv_checkgetattr(). If this fixes your performance problem (with delegations disabled), I'll probably add a separate counter for write delegations and use atomics to increment/decrement it so that it is SMP safe without acquiring any lock. If you can test this, please let me know how it goes? rick ________________________________________ From: Rick Macklem Sent: Tuesday, November 28, 2017 2:09:51 PM To: Emmanuel Vadot Cc: Konstantin Belousov; FreeBSD Current; freebsd-fs@freebsd.org; Rick Mack= lem Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? Emmanuel Vadot wrote: >I wrote: >> Since it defaults to "disabled", I don't see why a tunable would be nece= ssary? >> (Just do nothing and delegations don't happen. If you want the server >> to issue delegations, then use the sysctl to turn them on. If you want = to turn >> them off again at the server, reboot the server without setting the sys= ctl.) > >If you need to reboot to make things working again without delegation >this shouldn't be a sysctl. Turning them off without rebooting doesn't break anything. I just wrote it that way since you seemed to want to use a tunable, which implied rebooting was your preference. > > > > The reason behind it is recent problem at work on some on our file= r > > > > related to NFS. > > > > We use NFSv4 without delegation as we never been able to have good > > > > performance with FreeBSD server and Linux client (we need to do tes= t > > > > again but that's for later). > Delegations are almost never useful, especially with Linux clients. Emmanuel Vadot wrote: >Can you elaborate ? Reading what delegation are I see that this is >exactly what I'm looking for to have better performance with NFS for my >workload (I only have one client per mount point). Delegations allow the client to do Opens locally without contacting the server. Unless, the delegation is a write delegation, this only applied to read-only delegations. Also, since most implementors couldn`t agree on how to check permissions via the delegation, most client implementations still do an Access check at open, which is almost as much overhead as the Open RPC. (For example, Solaris servers always specified an empty ACE in th= e delegation, forcing the client to do an Access. I have no idea what the current Linux server=E9client does. If you capture packets when a Linux client is mounted with delegations enabled, you could look for RPCs like Ac= cess when are Opened multiple times. If you see them, then delegations aren`t saving = RPCs. Also, they are `per file`, so are only useful if the client is Opening the same file multiple times. Further, if another client Opens the same file and the first client got a W= rite delegation, then the write delegation must be recalled, which is a lot of overhead and one of the few cases where the FreeBSD server must exclusively lock the state lists, forcing all other RPCs related to Open, Close to wait= . They sounded good in theory and might have worked well if the implementors had agreed to do them, but that didn=E8t happen. (Companies pay for servers= , but the clients don=E8t get funded so delegation support in the clients are lacking= . I tried to make them useful in the FreeBSD client, but I=E8m not sure I succeeded.) > [stuff snipped] If I understood your original post, you have a performance problem caused by lock contention, where the server grabs the state lock to check for dele= gations for every Getattr from a client. As below, I think the fix is to add code to check for no delegations issued= that does not require acquisition of the state lock. Btw, large numbers of Getattrs will not perform well with delegations. (Again, the client should be able to do Getattr operations locally in the client when it has a delegation for the file, but if the client is not doi= ng that...) I wrote: > > Having a per-mount version of this would be overkill, I think. It would h= ave to > disable callbacks on the mount point, since there is no way for a client = to say > "don't give me delegations" except disabling callbacks, which the server > requires for delegation issue. > [stuff snipped] > The case where there has never been delegations issued will result in an > empty delegation queue. Maybe this case can be handled without acquiring > the "global NFSv4 state lock", which is what sounds like is causing the > performance issue. Maybe a global counter of how many delegations are > issued that is handled by atomic ops. > --> If it is 0, nfsrv_checkgetattr() can just return without acquiring th= e lock. > > I'll take a look at this, rick > rick --_002_YTOPR0101MB21721E82EF605249D38064A1DD3A0YTOPR0101MB2172_ Content-Type: application/octet-stream; name="checkgetattr.patch" Content-Description: checkgetattr.patch Content-Disposition: attachment; filename="checkgetattr.patch"; size=393; creation-date="Tue, 28 Nov 2017 23:18:53 GMT"; modification-date="Tue, 28 Nov 2017 23:18:53 GMT" Content-Transfer-Encoding: base64 LS0tIGZzL25mc3NlcnZlci9uZnNfbmZzZHN0YXRlLmMuc2F2CTIwMTctMTEtMjggMDk6NTY6Mjcu NzA4NTk5MDAwIC0wNTAwCisrKyBmcy9uZnNzZXJ2ZXIvbmZzX25mc2RzdGF0ZS5jCTIwMTctMTEt MjggMDk6NTc6MzEuMTEzMTYzMDAwIC0wNTAwCkBAIC01Mjk4LDcgKzUyOTgsNyBAQCBuZnNydl9j aGVja2dldGF0dHIoc3RydWN0IG5mc3J2X2Rlc2NyaXB0CiAJdV9xdWFkX3QgZGVsZWdmaWxlcmV2 OwogCiAJTkZTQ0JHRVRBVFRSX0FUVFJCSVQoYXR0cmJpdHAsICZjYmJpdHMpOwotCWlmICghTkZT Tk9OWkVST19BVFRSQklUKCZjYmJpdHMpKQorCWlmICghTkZTTk9OWkVST19BVFRSQklUKCZjYmJp dHMpIHx8IG5mc3J2X2RlbGVnYXRlY250ID09IDApCiAJCWdvdG8gb3V0OwogCiAJLyoK --_002_YTOPR0101MB21721E82EF605249D38064A1DD3A0YTOPR0101MB2172_--