Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3187755pxj; Mon, 31 May 2021 23:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdHYnQAwUICJ9v4x98ITX2BR2vXLClB/bPkVulbbf4tJ8TY7wlBoYxe6erE8CEeK9+zADS X-Received: by 2002:a05:6402:510e:: with SMTP id m14mr30097360edd.320.1622527374955; Mon, 31 May 2021 23:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622527374; cv=none; d=google.com; s=arc-20160816; b=KbvWKibW9PfycNUylygvGFxmzjkYuJsaJwsLpVFVUPRx/zHOYifrdAVqDkfV38q2Ul +5ChOLrxvmUNK/mA4VtGHn8jSKfFSi8tzjE61SMxtNhrqj2WNmXMMQt9hD6g71NFuwRF /USOzV1msocZBRJhP3FSd0wRtYRrUxWrBcL6ySSEKyBq8xTDwCXbR497Girphyf010N4 YE1WFp/6drKcbA1ghvFpSE8NzmsQwnqniMbt+O2eDDv4eBql1w6MmJyKv9GdwvEhSQ1h 9G/WPpwIragq8IZxJPqn+RkIVIDNspgn5GshBu5Xsbbz19kssn4+dFvVMyzoXNTNDvav o60g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FMK+BlVA/bqQ4G3j0umpuAtgbjll4fk10VR8BwqsbnM=; b=jCdAfxIbicpv6RVdhz/Yf6tCfT2+39+K9NXDUMGhwe9q+bWAiVnUlcS9mWXkfG4c5N Dv88NyXzRLZM3uul4GWczf7kkwkwwXAj5J37jqotQyILWqvX46bluFEvWSQohFohj2la QFxmKkvSCzkZLmNT660rOLYQ10TGexasvb204Ewj5o7N2y1UFm21p+dyUQgTpz2lvCuR mmpXiYGs2ig0ScbwkivqzNIzxSLke315D69KaABCieRWXzpgY7/tsKZV7U98xBLA+nIf AGHwZVIvMoX8Z1INrLWobMA0gCBhSN5oHECBV9j2TZaADxDP4sa0PMTl8YjhTOaqVbgN 62tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Cq1BJQXR; 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 gw16si15006726ejb.250.2021.05.31.23.02.31; Mon, 31 May 2021 23:02:54 -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=@linux-foundation.org header.s=google header.b=Cq1BJQXR; 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 S232894AbhFAGCJ (ORCPT + 99 others); Tue, 1 Jun 2021 02:02:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbhFAGCJ (ORCPT ); Tue, 1 Jun 2021 02:02:09 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3A4C061574 for ; Mon, 31 May 2021 23:00:26 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id x38so19916542lfa.10 for ; Mon, 31 May 2021 23:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FMK+BlVA/bqQ4G3j0umpuAtgbjll4fk10VR8BwqsbnM=; b=Cq1BJQXRRbsAXqGxRHmxlETFypstLuehMX0LFh5G4WwWip0G6ssEb7uQhJQf6qE/w6 q99MLnXgThXbCZe6+0hy/V9sd6Z8pdAbXqzWYO7KoTJokBUNapDj13LzLPptKUN0dXDB dBnWVVEJ54OfnhbSAGqeb8GPq4vKV3/0PFITU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FMK+BlVA/bqQ4G3j0umpuAtgbjll4fk10VR8BwqsbnM=; b=ftIwz5pvs1Il82SxYt78Wws13on6GhubhzrqDCYApUEF+sMydEHjyYvAx3WsTkfSJ0 q2SdpddrVLp9nDIGbSPgF8NgjIMZ5vAicl3d1SwjNOI+6SzQfO/GW+0oOcuRJssJvW5+ +ieI3KdxWRg2q14UYtq/ZE/6M16wcIAZ9/9ANVDzj6kQabGGrZR/FCH2FUkDLehXuS9z RhfrTzy2gv3guQUaOz8BnG8SwgEF/bgSB4TS3wntlNxuQaFBst9UVOm+OZ019xmEwzUW nwMJ4VxMNsAM76X6FZKKtVDItPZH2lIutz/fnxZosKSH/te0dKyDlzwsmgOkMOz9bvrX sLWw== X-Gm-Message-State: AOAM530JDuV5ugO7Bu5zjfUOJEbXReleO4uyN6lKrSv3EBeAEyzuQEhq Iu2Qlg4bKkGEvS5U0V7h14hDoH8rI3lrv4tB X-Received: by 2002:a19:e212:: with SMTP id z18mr10759831lfg.55.1622527225154; Mon, 31 May 2021 23:00:25 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id n130sm1724572lfa.10.2021.05.31.23.00.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 May 2021 23:00:24 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id a4so17630570ljd.5 for ; Mon, 31 May 2021 23:00:24 -0700 (PDT) X-Received: by 2002:a2e:9644:: with SMTP id z4mr1911003ljh.507.1622527224567; Mon, 31 May 2021 23:00:24 -0700 (PDT) MIME-Version: 1.0 References: <20210531170123.243771-1-agruenba@redhat.com> <20210531170123.243771-5-agruenba@redhat.com> In-Reply-To: <20210531170123.243771-5-agruenba@redhat.com> From: Linus Torvalds Date: Mon, 31 May 2021 20:00:08 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 4/9] gfs2: Fix mmap + page fault deadlocks (part 1) To: Andreas Gruenbacher Cc: cluster-devel , Linux Kernel Mailing List , Alexander Viro , Jan Kara , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 31, 2021 at 7:01 AM Andreas Gruenbacher wrote: > > Fix that by recognizing the self-recursion case. Hmm. I get the feeling that the self-recursion case should never have been allowed to happen in the first place. IOW, is there some reason why you can't make the user accesses always be doen with page faults disabled (ie using the "atomic" user space access model), and then if you get a partial read (or write) to user space, at that point you drop the locks in read/write, do the "try to make readable/writable" and try again. IOW, none of this "detect recursion" thing. Just "no recursion in the first place". That way you'd not have these odd rules at fault time at all, because a fault while holding a lock would never get to the filesystem at all, it would be aborted early. And you'd not have any odd "inner/outer" locks, or lock compatibility rules or anything like that. You'd literally have just "oh, I didn't get everything at RW time while I held locks, so let's drop the locks, try to access user space, and retry". Wouldn't that be a lot simpler and more robust? Because what if the mmap is something a bit more complex, like overlayfs or usefaultfd, and completing the fault isn't about gfs2 handling it as a "fault", but about some *other* entity calling back to gfs2 and doing a read/write instead? Now all your "inner/outer" lock logic ends up being entirely pointless, as far as I can tell, and you end up deadlocking on the lock you are holding over the user space access _anyway_. So I literally think that your approach is (a) too complicated (b) doesn't actually fix the issue in the more general case But maybe I'm missing something. Linus Linus