Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp492212rdb; Fri, 17 Nov 2023 05:01:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHz3wniRZMXXUH1KD/vtSnpaAZXcpIvRSasj+ymPe/QPCFzwGm2sOUx24L3u3I1T38b2ssy X-Received: by 2002:a05:6808:320b:b0:3b5:9965:2bc2 with SMTP id cb11-20020a056808320b00b003b599652bc2mr25304112oib.23.1700226086610; Fri, 17 Nov 2023 05:01:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700226086; cv=none; d=google.com; s=arc-20160816; b=AxGIIg1tlYXMnH2n14/WhQLslBg+u4K7M04RMJDtlIxVNGEsuEy0c/ou679fwhJXpj YR58KDE9qPLAZ6LMG4Q83+Zb3zRlaK6p/rA7BOJjOw8xfqlg6aJs+iJ6VaasHkzU3mRK 5KkzAfqb8CikhwsFsQPmT3sngEoZm2Qfc1ZOD/kqWrKqRB52JwIZyJ9ykSMkslGFFOA9 jxP8pwmaTkCjG3gfrepE/FAj9RWgvYudFmGxkdxIFOyy3ivY3X88XcCDlmZUmHnZr9qi mYERemDkx+bfGyEsWltj6mHS2G9IhSeI6HgDDCFoENSPmHB6XBABMFMpU1rTZDfvBu4m il8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=92EM5xD3/y6vRocEo33waLmBWQM6YZ2esZ+B1IvkENU=; fh=+qcSuqZZ+6RmbTtQSxFRtua5BXNUXdMAe3eKTv5CzkY=; b=hIjXifar+9sq3me9sQHcQL0yH+4+HTDl0N8IzhcHMleciylBjHmukBx4xub8EqNjw2 A8BtryGpZUiLMtvdm03/PlnPPtGNl9D4iFSv4Zx+TExh3VjAOmylIg5LU/xvSyFpmGZz GBxGm4TwVG8ksAUahLN3i9z3RnBWwsmaRzLw5mEhb1Wt5IRK75KpLunGarOVoTqGLOyN J/vaRv5c/3GH65bnDZ9DRRgyf418tmkLSQ1yONKRCafJWn1EyY0bnpNVqgLf6LdKYvO1 425zWIGOBXl6eTcvwBxE5pm6ZZQhYoozTDYQ9uztMy4vJjg3IdMhhuwakhFFX4HyC212 bHug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=YNcY8DFE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id a5-20020a056808128500b003ae04bb334bsi590633oiw.10.2023.11.17.05.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 05:01:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=YNcY8DFE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4D8A78285F48; Fri, 17 Nov 2023 05:00:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346049AbjKQNAr (ORCPT + 99 others); Fri, 17 Nov 2023 08:00:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235706AbjKQNAg (ORCPT ); Fri, 17 Nov 2023 08:00:36 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81FB4D6A for ; Fri, 17 Nov 2023 05:00:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=92EM5xD3/y6vRocEo33waLmBWQM6YZ2esZ+B1IvkENU=; b=YNcY8DFEV0N5PiQHr3IWOIyPPI DWQu8jrwhxiH/gvX5PoSkb3Ufc1bfTjLOS6UdRP/rXhNE0lXIujsGZaG4kQpwJhYYXcFwxza68NZ9 fYJ57JMVT4L2ThoRIKiRH/hEE4/KMEvJIGH3g0frSgwyVrikZQ7UnIKu0zngmK1qj3vdIAAc5l0U/ VNbF9yvU8Biuz9rtqFqbVncYFsjYuAH6Pe/3ycJhIIRKKV4ycBwkQ92SHk/ucOBeYV5btwfIx6rEL 5RC5+0bDZes4moSQGA1jGZqdqOxsAB4MTQ5KrUNtDAMjDhqW1Q9vLD22a+w0DL3p0nF0lwf6lTmDt YGXGTg8g==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1r3yS9-006b5Z-2f; Fri, 17 Nov 2023 13:00:09 +0000 Date: Fri, 17 Nov 2023 05:00:09 -0800 From: Christoph Hellwig To: Jeff Layton Cc: Chuck Lever III , Benjamin Coddington , Christoph Hellwig , Linux NFS Mailing List Subject: Re: Blocklayoutdriver deadlock with knfsd Message-ID: References: <1CC82EC5-6120-4EE4-A7F0-019CF7BC762C@redhat.com> <787DAC8F-5294-4876-9725-096D639B3D9C@oracle.com> <465037c9585f910c2192bf896139e7bf01d587d4.camel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <465037c9585f910c2192bf896139e7bf01d587d4.camel@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 17 Nov 2023 05:00:48 -0800 (PST) On Thu, Nov 16, 2023 at 03:32:34PM -0500, Jeff Layton wrote: > One thing that might help would be make the nfsd threadpool more > dynamic. If it could just spin up another thread, we'd be OK. > > Maybe the server could keep an emergency thread around that is just for > processing LAYOUTRETURN/DELEGRETURN (maybe also CLOSE, etc.) calls? > Sometimes these ops are mixed into compounds with other sorts of calls > though, so we'd need to deal with that somehow. I think having an extra thread just for LAYOUTRETURN/DELEGRETURN is fundamentally the right thing to do, as they need to be processed to allow everyone else to progress. > > If nfsd threads are waiting indefinitely, that's a potential DoS > > vector. Ideally the thread should preserve the waiting request > > somehow (or return NFS4ERR_DELAY, maybe?). At some later point > > when the lease conflict is resolved, the requests can be reprocessed. > > > > That's my naive 800,000 ft view. > > That is probably a good idea on top of the above. > So you can always get stuck in that inner break_layout call. We could > try to use IOCB_NOWAIT for I/Os coming from nfsd, which would prevent > that, but that seems like it could change the I/O behavior in other ways > we don't want. It's not clear to me how that would work alongside > IOCB_SYNC anyway. So I definitively think using IOCB_NOWAIT from nfsd and not block the thread for trivial I/O is a good thing. This might even enable not offloading I/O to threads until the IOCB_NOWAIT failed. But any IOCB_NOWAIT that returned -EAGAIN needs to eventually fall back to doing blocking I/O as there is no progress guarantee for IOCB_NOWAIT, and some I/O simply is entirely impossible with IOCB_NOWAIT. > It's not immediately clear to me how we'd do this with the existing > IOCB_* flags, so we might need a new one (IOCB_NFSD?). Then, we could > just make sure that break_layout call is always nonblocking if that flag > is set. I'd name it about the behavior that it controls and not the callers, but otherwise this too seems like a good idea.