Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3560639pxj; Tue, 11 May 2021 07:12:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuxOJVF+AbXijZa/zQ9oRuK9AyIcUvTZO384/8zn7Z/L/UzgXJOzZYvHZB/nOZqr9Ua+Ud X-Received: by 2002:a05:651c:1316:: with SMTP id u22mr25515631lja.197.1620742378940; Tue, 11 May 2021 07:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620742378; cv=none; d=google.com; s=arc-20160816; b=IVEgL1I402flolsFXAJtWyhwXKMJrrFGZkOTA80yXfOoQt+LEKlyZHAxLj7BwJ3Igc pIM9onPoI2w0iko4b5LrvMhckdPVB2/q2bQdM6of/7O8fFvxXcSTrxpMczcImeemJA9B /g3oYQKtIdXhSWYwHtDD7o99rG/KZzqKYx3UjbezcJxcb2ydWnH2BK0B6Fd4Qfgklteh WVsTgNHT3wZl/i0BtHsod/pHDmJxzABZFufmaxFwrJNqkQqSnZ9mHvj7y4oJu3ptsN0h xmbhWbQYnGpLSu0nuGbbtR7cgPYV066xSMiAxxddQ24YS0sMDTi3eZrDlnFDbU+/34ju jd/Q== 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=ns8g+nbJuyOh7gET8cGtylgrkk3eWd9nQ8qX/kCPn/g=; b=EN2GeaSp4dqntoCsWje7ynvIUGDkFmfqvTWpPmnI1XyFjYHl05xHom+Z1LiPg9VVIM E2Gxw1h9xorFiEP26tqAmbBbN5b/GATakLOen/ZsVdKGrzpSCpdTwCa1Jm9loixq4OZV /y9PXKY5xfkB3nqpZmv2/jmm+EPll/rpZkRhVz4wmqWAgA05OuoABf3NWXuAgQOb35sa pXsxylkLADzqIuOBqw/knyQLf6fEbxv97qKBji7Chil0sM65mrcUzSTp9o4s9BgA/LLx H+m4usbYQ86eey7e9atbyyBHhJoWu8oI7vdEpCUZuT7K1gIjYZK+k2UqkJhS4IS6H+vO 1vcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=OwhXZQ5O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q20si22195255lfu.303.2021.05.11.07.12.28; Tue, 11 May 2021 07:12:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=OwhXZQ5O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231641AbhEKOMS (ORCPT + 99 others); Tue, 11 May 2021 10:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbhEKOMR (ORCPT ); Tue, 11 May 2021 10:12:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7A9C061574; Tue, 11 May 2021 07:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=ns8g+nbJuyOh7gET8cGtylgrkk3eWd9nQ8qX/kCPn/g=; b=OwhXZQ5On+tzASMhUb2984kocS 1Frf3mPfcEpNd55eNxRrmNjwPhGF7elCZstOL2y+a1YvHvfNj/1c3cM1PL27yCVgV3zQmpuHYAGrd XAGS1wSxtU8NW+O3rQfhSHkWK5SHoJqfzodt4BuARecYiQWd3pVF1EYXknqsoE/0DXASJ7Oatycb7 nJXL1d1eYjPmh/ebfV+LVQZKScTgfbI+IthIciBMJ50mpO4XFxUvuQ54zVrcZpZyTJwZHtKkVOneY mnmE5GZCh3Xw6WC+7iVDwTXiY9UprnqEnfDP0ufc6Bfu0o4UYUst1u1xunaIwpbWuph0RQkXUAjLl xIuqA6Dw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lgT6C-007LRP-4h; Tue, 11 May 2021 14:11:04 +0000 Date: Tue, 11 May 2021 15:11:00 +0100 From: Matthew Wilcox To: Andreas Gruenbacher Cc: linux-fsdevel@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jan Kara Subject: Re: [PATCH] [RFC] Trigger retry from fault vm operation Message-ID: References: <20210511140113.1225981-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210511140113.1225981-1-agruenba@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 11, 2021 at 04:01:13PM +0200, Andreas Gruenbacher wrote: > we have a locking problem in gfs2 that I don't have a proper solution for, so > I'm looking for suggestions. > > What's happening is that a page fault triggers during a read or write > operation, while we're holding a glock (the cluster-wide gfs2 inode > lock), and the page fault requires another glock. We can recognize and > handle the case when both glocks are the same, but when the page fault requires > another glock, there is a chance that taking that other glock would deadlock. So we're looking at something like one file on a gfs2 filesystem being mmaped() and then doing read() or write() to another gfs2 file with the mmaped address being the passed to read()/write()? Have you looked at iov_iter_fault_in_readable() as a solution to your locking order? That way, you bring the mmaped page in first (see generic_perform_write()). > When we realize that we may not be able to take the other glock in gfs2_fault, > we need to communicate that to the read or write operation, which will then > drop and re-acquire the "outer" glock and retry. However, there doesn't seem > to be a good way to do that; we can only indicate that a page fault should fail > by returning VM_FAULT_SIGBUS or similar; that will then be mapped to -EFAULT. > We'd need something like VM_FAULT_RESTART that can be mapped to -EBUSY so that > we can tell the retry case apart from genuine -EFAULT errors. We do have VM_FAULT_RETRY ... does that retry at the wrong level?