From patchwork Sat Sep 17 19:32:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9337331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C6401601C2 for ; Sat, 17 Sep 2016 19:32:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7733291CB for ; Sat, 17 Sep 2016 19:32:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 854FF291DC; Sat, 17 Sep 2016 19:32:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71070291CB for ; Sat, 17 Sep 2016 19:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbcIQTcQ (ORCPT ); Sat, 17 Sep 2016 15:32:16 -0400 Received: from us-smtp-delivery-194.mimecast.com ([216.205.24.194]:41060 "EHLO us-smtp-delivery-194.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751128AbcIQTcP (ORCPT ); Sat, 17 Sep 2016 15:32:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=PrimaryData.onmicrosoft.com; s=selector1-primarydata-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Kq3vDDOvrI8LT4YlxLBdoXbZI4IfzfAxJhMLpv9Z5lM=; b=gW2tGenxlKLKxXlFkjmn0r4UEE1y8RoVjaIOJHqyUL6D0bAjB54iXmfjLnevr2RIuarKc/Bd6g2SrD+YZ4OHOtbuNzIbLcYpsBfvGJ7ZXCxASFEYYj3xkTMZXQvt7HQDSqoqgE68D22kDAOAn0TeZJ7X48Da/TckWxZ5XHoLU1w= Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02lp0018.outbound.protection.outlook.com [216.32.180.18]) (Using TLS) by us-smtp-1.mimecast.com with ESMTP id us-mta-29-KSDsaCcBND6b-ZjjMygINw-1; Sat, 17 Sep 2016 15:32:12 -0400 Received: from BN6PR11MB1570.namprd11.prod.outlook.com (10.172.22.149) by BN6PR11MB1569.namprd11.prod.outlook.com (10.172.22.148) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10; Sat, 17 Sep 2016 19:32:09 +0000 Received: from BN6PR11MB1570.namprd11.prod.outlook.com ([10.172.22.149]) by BN6PR11MB1570.namprd11.prod.outlook.com ([10.172.22.149]) with mapi id 15.01.0619.016; Sat, 17 Sep 2016 19:32:09 +0000 From: Trond Myklebust To: "green@linuxhacker.ru" CC: "anna.schumaker@netapp.com" , "linux-nfs@vger.kernel.org" Subject: Re: [PATCH v5 00/25] Fix delegation behaviour when server revokes some state Thread-Topic: [PATCH v5 00/25] Fix delegation behaviour when server revokes some state Thread-Index: AQHSEKJBrJIeY7mnGES4qGyzQzZ0NqB9+pYAgAAD0oCAABBbgIAABFKA Date: Sat, 17 Sep 2016 19:32:09 +0000 Message-ID: <1474140727.7526.1.camel@primarydata.com> References: <1474089213-104014-1-git-send-email-trond.myklebust@primarydata.com> <838E325D-2DA1-4229-A046-76316302F813@linuxhacker.ru> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [68.49.162.121] x-ms-office365-filtering-correlation-id: aaa3183b-7009-4a83-90fa-08d3df31512a x-microsoft-exchange-diagnostics: 1; BN6PR11MB1569; 20:0ugRSWmxFLLYT1zKRhyyJKdTJNGRvc75GTdxMIQkFTqlC1qly6h4OvaWAFOt/VaVgS03hjNgt3QPa6XZY9SjamwueGOya7paKja8iEbjOt/Rdvwl0xbP8u5eG2inP3mFe1zPEQkkndenDYNPk7sY6N3FyLIjPZtpCtJjv+MrMbo= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR11MB1569; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6043046)(6042046); SRVR:BN6PR11MB1569; BCL:0; PCL:0; RULEID:; SRVR:BN6PR11MB1569; x-forefront-prvs: 0068C7E410 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(24454002)(377424004)(199003)(377454003)(189002)(81166006)(86362001)(575784001)(4477795004)(5002640100001)(81156014)(66066001)(2501003)(103116003)(586003)(5660300001)(6116002)(3846002)(93886004)(102836003)(33646002)(5640700001)(3280700002)(3660700001)(2906002)(4326007)(92566002)(122556002)(36756003)(8936002)(106356001)(106116001)(99286002)(105586002)(19580395003)(2351001)(97736004)(19580405001)(11100500001)(10400500002)(189998001)(68736007)(77096005)(2900100001)(2950100001)(7846002)(7736002)(50986999)(76176999)(305945005)(8676002)(110136003)(101416001)(87936001)(54356999)(1730700003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR11MB1569; H:BN6PR11MB1570.namprd11.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <6256129B222E0143B344183B5C9D53DA@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: primarydata.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2016 19:32:09.3183 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 03193ed6-8726-4bb3-a832-18ab0d28adb7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1569 X-MC-Unique: KSDsaCcBND6b-ZjjMygINw-1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, 2016-09-17 at 15:16 -0400, Oleg Drokin wrote: > On Sep 17, 2016, at 2:18 PM, Trond Myklebust wrote: > > > > > > > > > > > On Sep 17, 2016, at 14:04, Oleg Drokin > > > wrote: > > > > > > > > > On Sep 17, 2016, at 1:13 AM, Trond Myklebust wrote: > > > > > > > > > > > According to RFC5661, if any of the SEQUENCE status bits > > > > SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED, > > > > SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED, > > > > SEQ4_STATUS_ADMIN_STATE_REVOKED, > > > > or SEQ4_STATUS_RECALLABLE_STATE_REVOKED are set, then we need > > > > to use > > > > TEST_STATEID to figure out which stateids have been revoked, so > > > > we > > > > can acknowledge the loss of state using FREE_STATEID. > > > > > > > > While we already do this for open and lock state, we have not > > > > been doing > > > > so for all the delegations. > > > > > > > > v2: nfs_v4_2_minor_ops needs to set .test_and_free_expired too > > > > v3: Now with added lock revoke fixes and > > > > close/delegreturn/locku fixes > > > > v4: Close a bunch of corner cases > > > > v5: Report revoked delegations as invalid in > > > > nfs_have_delegation() > > > >  Fix an infinite loop in nfs_reap_expired_delegations. > > > >  Fixes for other looping behaviour > > > > > > This time around the loop seems to be more tight, > > > in userspace process: > > > > > > [ 9197.256571] --> nfs41_call_sync_prepare data->seq_server > > > ffff8800a73ce000 > > > [ 9197.256572] --> nfs41_setup_sequence > > > [ 9197.256573] --> nfs4_alloc_slot used_slots=0000 > > > highest_used=4294967295 max_slots=31 > > > [ 9197.256574] <-- nfs4_alloc_slot used_slots=0001 highest_used=0 > > > slotid=0 > > > [ 9197.256574] <-- nfs41_setup_sequence slotid=0 seqid=14013800 > > > [ 9197.256582] encode_sequence: sessionid=1474126170:1:2:0 > > > seqid=14013800 slotid=0 max_slotid=0 cache_this=1 > > > [ 9197.256755] --> nfs4_alloc_slot used_slots=0001 highest_used=0 > > > max_slots=31 > > > [ 9197.256756] <-- nfs4_alloc_slot used_slots=0003 highest_used=1 > > > slotid=1 > > > [ 9197.256757] nfs4_free_slot: slotid 1 highest_used_slotid 0 > > > [ 9197.256758] nfs41_sequence_process: Error 0 free the slot  > > > [ 9197.256760] nfs4_free_slot: slotid 0 highest_used_slotid > > > 4294967295 > > > [ 9197.256779] --> nfs_put_client({2}) > > > > What operation is the userspace process hanging on? Do you have a > > stack trace for it? > > seems to be open_create->truncate->ssetattr coming from: > cp /bin/sleep /mnt/nfs2/racer/12 > > (gdb) bt > #0  nfs41_setup_sequence (session=0xffff88005a853800, > args=0xffff8800a7253b80,  >     res=0xffff8800a7253b48, task=0xffff8800b0eb0f00) >     at /home/green/bk/linux-test/fs/nfs/nfs4proc.c:876 > #1  0xffffffff813a751c in nfs41_call_sync_prepare (task= out>,  >     calldata=0xffff8800a7253b80) >     at /home/green/bk/linux-test/fs/nfs/nfs4proc.c:966 > #2  0xffffffff8185c639 in rpc_prepare_task (task=) >     at /home/green/bk/linux-test/net/sunrpc/sched.c:683 > #3  0xffffffff8185f12b in __rpc_execute (task=0xffff88005a853800) >     at /home/green/bk/linux-test/net/sunrpc/sched.c:775 > #4  0xffffffff818617b4 in rpc_execute (task=0xffff88005a853800) >     at /home/green/bk/linux-test/net/sunrpc/sched.c:843 > #5  0xffffffff818539b9 in rpc_run_task > (task_setup_data=0xffff8800a7253a50) >     at /home/green/bk/linux-test/net/sunrpc/clnt.c:1052 > #6  0xffffffff813a75e3 in nfs4_call_sync_sequence (clnt= out>,  >     server=, msg=, args= out>,  >     res=) at /home/green/bk/linux- > test/fs/nfs/nfs4proc.c:1051 > #7  0xffffffff813b4645 in nfs4_call_sync (cache_reply= out>,  >     res=, args=, msg=,  >     server=, clnt=) >     at /home/green/bk/linux-test/fs/nfs/nfs4proc.c:1069 > #8  _nfs4_do_setattr (state=, cred=,  >     res=, arg=, inode=) > ---Type to continue, or q to quit--- >     at /home/green/bk/linux-test/fs/nfs/nfs4proc.c:2916 > #9  nfs4_do_setattr (inode=0xffff880079b152a8, cred=,  >     fattr=, sattr=, > state=0xffff880060588e00,  >     ilabel=, olabel=0x0 ) >     at /home/green/bk/linux-test/fs/nfs/nfs4proc.c:2955 > #10 0xffffffff813b4a16 in nfs4_proc_setattr (dentry=,  >     fattr=0xffff8800a7253b80, sattr=0xffff8800a7253b48) >     at /home/green/bk/linux-test/fs/nfs/nfs4proc.c:3684 > #11 0xffffffff8138f1cb in nfs_setattr (dentry=0xffff8800740c1000,  >  Cool! Does the following help? 8<------------------------------------------------------------ From 98ddf32a99cfe00e9ae108044e2be67522987511 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Sat, 17 Sep 2016 15:27:10 -0400 Subject: [PATCH] NFS: Don't assume a stateid represents a delegation in nfs4_do_handle_exception If the stateid being passed to the error handler is not a delegation stateid, we want to mark the locks/open_state it does represent for recovery. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 7cecb1d7a217..acc572c51735 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -397,6 +397,10 @@ static int nfs4_do_handle_exception(struct nfs_server *server, exception->delay = 0; exception->recovering = 0; exception->retry = 0; + + if (stateid == NULL && state != NULL) + stateid = &state->stateid; + switch(errorcode) { case 0: return 0; @@ -405,7 +409,7 @@ static int nfs4_do_handle_exception(struct nfs_server *server, case -NFS4ERR_EXPIRED: case -NFS4ERR_BAD_STATEID: if (inode != NULL && stateid != NULL) { - nfs_inode_find_delegation_state_and_recover(inode, + nfs_inode_find_state_and_recover(inode, stateid); goto wait_on_recovery; }