Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3741233rwb; Fri, 30 Sep 2022 07:45:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ZqkMJrJGzWMkYol/rB3lp/vBJ5BhiZpC7YAoqcfQtv/zjDiFyvJICCTw1n39G30+zhDPV X-Received: by 2002:a17:902:b94c:b0:178:336f:13d6 with SMTP id h12-20020a170902b94c00b00178336f13d6mr9472306pls.64.1664549135981; Fri, 30 Sep 2022 07:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664549135; cv=none; d=google.com; s=arc-20160816; b=AlIraZK1RRXSbKXTm6LaDpd63RWHPD7eZ/ORhK/qUfGZCiafCk6uUNsaxa527QUv2S 17VnZqq2q3bkMTy7lgr9kGqDxem9tTxkrS/sa3kyRkK21e9PwHj88SY+Gs3Ou6GapXoY 9xZ3U3+brGNlGcR0MVRgD1/6w0qPYhf37VaFhGUg2eV0Ez/ofjqqCCHkK3TNh1KTq9S4 n0d4jaUFwlcuxiUXYOxOBLnGAsioNfLXE7bge+81VehpDSk5UUw48vXpzJaHmblmXvxd A7WCP5eCZXnztihAhY30UUZ4Jhzp6cO+VNVD5EPAUBQaNy78/aRc4m6XAIng6VM/FUvr pSHA== 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=/1DxuLJFLLsCcKR9xIk/BovDONGX4FOkeIuowA2lYU0=; b=Xdbf9B8cfXusbn1nLYGZG2MDkciqn8MzSVovlhxAXJ99g202Ak06u8x7f8zX6QRsAs zITNPnDwOFy+cWKklTFHwS8tXWa3NRv1sn37tFxKgZygaW3P2P7WmJZGEnZRwkNUwtoS jyt+DvrCJ0QkWlodTAOQQbfVVnZHh1mUSSIz47TwBn7xk3OE4I/S2CDXGiHMUBububFb noR9R9dsJSPIRbtjJSkrAgU4xfezI/oL/OMXcXVDA9aT6RZORyCip7SKlTNR3xQgJyoM v9IDRa0V54/lncTbtnKCyQQ3zEKAZVkqEFHG6JQu62OjDdUEyUSeJ84vQOTw0IY6MYUB uANA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=pbDuPVnX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t19-20020a056a0021d300b005481144090asi2833499pfj.6.2022.09.30.07.45.22; Fri, 30 Sep 2022 07:45:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=pbDuPVnX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbiI3Olw (ORCPT + 99 others); Fri, 30 Sep 2022 10:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbiI3Olv (ORCPT ); Fri, 30 Sep 2022 10:41:51 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196EB10502E for ; Fri, 30 Sep 2022 07:41:50 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id u24so6229193edb.11 for ; Fri, 30 Sep 2022 07:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=/1DxuLJFLLsCcKR9xIk/BovDONGX4FOkeIuowA2lYU0=; b=pbDuPVnXVQSqgprmcVlW0DAPHC+MGTmo5rSeDEcxUAoBd0kQjtq5RNHKDR+Ongl4Qw kbi9DoKcWs7lfkeHXRtT2WTMm7sQqlu0U86+Kvk85znR3zD4Wyhzgz2NqApjHAVQewIl 0sjYlH6eZgX4uBw0OMgVCDp4kUkRPfarhBOrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=/1DxuLJFLLsCcKR9xIk/BovDONGX4FOkeIuowA2lYU0=; b=ujXA8zfykXtJQwUvvzQpZCQC73SDs+UeMk1YOdMC0wdnYVDsNY0CCtfjTa/S2kzIhp ljROyy81FvolRxy7qI75ZlsjLGQHCn9IEn++8CrPYiL/tKgtUB21ZqX1HG2KsOIsQsBX qMo4GxJgUaTQ2CSf/DeQVU3Ixfs2VgYrohBoa4c0JCMsqH056im3Xn1eJLC99UeJy/Gb ehdkMIc17/kaP1jD2CDQa7Ppr4WQPZVrIIClUl0YN6RNu3jNwH0FeUqo/hzlhN8sAJ0R CsCMJrn5E/LSQrYBG1ocoRed0paG9CfUZjqLmwtpdPF+CvAP8QYH3xHQCfpKpTZqez5P GqYA== X-Gm-Message-State: ACrzQf1p5HbG9Ma2OySz4TBcgkXR2dlm/FO5PQGYhYzgaxuQt7C+NsI5 FmKxqMhcJIWoNk48BgL/1J/6EPvLPqf3nd+CTZLGrg== X-Received: by 2002:a05:6402:370c:b0:453:9fab:1b53 with SMTP id ek12-20020a056402370c00b004539fab1b53mr8307036edb.28.1664548908613; Fri, 30 Sep 2022 07:41:48 -0700 (PDT) MIME-Version: 1.0 References: <20220929163944.195913-1-tycho@tycho.pizza> In-Reply-To: From: Miklos Szeredi Date: Fri, 30 Sep 2022 16:41:37 +0200 Message-ID: Subject: Re: [PATCH v2] fuse: In fuse_flush only wait if someone wants the return code To: Tycho Andersen Cc: Eric Biederman , "Serge E. Hallyn" , linux-kernel@vger.kernel.org, fuse-devel@lists.sourceforge.net Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Sept 2022 at 16:01, Tycho Andersen wrote: > > On Fri, Sep 30, 2022 at 03:35:16PM +0200, Miklos Szeredi wrote: > > On Thu, 29 Sept 2022 at 18:40, Tycho Andersen wrote: > > > > > > If a fuse filesystem is mounted inside a container, there is a problem > > > during pid namespace destruction. The scenario is: > > > > > > 1. task (a thread in the fuse server, with a fuse file open) starts > > > exiting, does exit_signals(), goes into fuse_flush() -> wait > > > > Can't the same happen through > > > > fuse_flush -> fuse_sync_writes -> fuse_set_nowrite -> wait > > > > ? > > Looks like yes, though I haven't seen this in the wild, I guess > because there aren't multiple writers most of the time the user code > that causes this. > > I'm not exactly sure how to fix this. Reading through 3be5a52b30aa > ("fuse: support writable mmap"), we don't want to allow multiple > writes since that may do allocations, which could cause deadlocks. But > in this case we have no reliable way to wait (besides a busy loop, I > suppose). > > Maybe just a check for PF_EXITING and a pr_warn() with "echo 1 > > /sys/fs/fuse/connections/$N/abort" or something? AFAICS it should be perfectly normal (and trivial to trigger) for an exiting process to have its dirty pages flushed through fuse_flush(). We could do that asynchronously as well, generally there are no promises about dirty pages being synced as part of the process exiting . But ordering between dirty page flushing and sending the FUSE_FLUSH request should be kept. Which needs more complexity, unfortunately. Thanks, Miklos