From patchwork Mon Apr 3 14:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2357427vqo; Mon, 3 Apr 2023 07:48:18 -0700 (PDT) X-Google-Smtp-Source: AKy350Yg5bvuTtMNypNMqU9+m3ZDE2OqN6hKfgxQjKoMGEsFXlVyIa2n23LkTB92RUR3eSCTba8v X-Received: by 2002:a17:907:d30e:b0:922:78e2:7680 with SMTP id vg14-20020a170907d30e00b0092278e27680mr38132675ejc.52.1680533298388; Mon, 03 Apr 2023 07:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680533298; cv=none; d=google.com; s=arc-20160816; b=oXFetBrfjYtZXi4SC0Y92uqqKv95g0zvnU/9IrXh7e5BIWCeF1ZczJwa76gFvbMfh6 0wRLcCIIb3q4e/BgxJCGBA2G3Cdv4zHOcEVmckt56G86d6zZrijMGv/2BA/hqqVy4iu3 wrYeEkXC6LKBA9mW/NuhYKnSDKgxdbtlfPWqiTXRQPt9bH4LuGV14FxFude9pcixp8Kb Sn5CIEuQZT49j+wUBFgYDhYYUnIH9jlhJpGo8OzpgTe9iWGgPrEo/qYD9TfjIbWRMKAh p5jV/3UcFdxdJMCoIO/rok6wv33OdtFKykeRO80nQoOHCZ77BKgBbz9Kt0Br70ZYi0iW 5bCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jf893Mr1zYfCNeUs9dWOENLdN29rryafRcjFVjzmYec=; b=dP8muB6cQ5epTKaBOBZKrtttIo+VhV1zuVPnVfETvJ/R1ePX7nQlcTgHEUsqdW+L3a dgaiqjsA8NanPwo3KuO4MNgjCYIi/z4/hTPDnS1lWUIJtTcs+t/sRJ0s5i1GT+GmL1e7 QlqK+UA8mATl8tLCzgy+zEZTmwnV/c5h5+kQTA+RNQ5b6coyeT2iQc5dJI+uQN9vXhLC ksIeOSj+tuQT+vWr/ObF3eTfPGu6MutqtMItCTt6VFEnib93EUKFVA8he9fepPtXf9ir ANxRa8GkMA0caHQLoFX9RBhWqHK65XCgk/7qtKIWj7NQLiHOaLgS9wCKgQ7NL/lpi+No jTrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Cu71jNlO; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vr4-20020a170907a50400b00947c6b4a29asi7014659ejc.1037.2023.04.03.07.47.23; Mon, 03 Apr 2023 07:48:18 -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=@canonical.com header.s=20210705 header.b=Cu71jNlO; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234002AbjDCOqg (ORCPT + 99 others); Mon, 3 Apr 2023 10:46:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233999AbjDCOq3 (ORCPT ); Mon, 3 Apr 2023 10:46:29 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B081827B for ; Mon, 3 Apr 2023 07:46:09 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D18C93F23B for ; Mon, 3 Apr 2023 14:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533141; bh=jf893Mr1zYfCNeUs9dWOENLdN29rryafRcjFVjzmYec=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Cu71jNlOHlvKXnfePaLd31d3MLifuemvpFu3smVJs9hhNr6YRr6/SmMIujq4aLDUo HBT5PsQ+Lq+afkEzIuFGYkHJRkB65ifO3FeL2MjcF3Yv0JwgHb+kKqGd0tWlHB91v9 aZXCCEXmCfkKDm7zkbr9c21a/omRrl4cS9qVv1N3h5kpvscSosGgdjy3C49bJPxa5c ReepLOwJa7TbG/A53cxdtXm1EqhXCIfJa7EhbREKJDFKVWI30Xbmpf0qsigo7geT/7 zIDXYfKU0gs+5Fl+ly0ILWxbWOzNUTpG0o/s8WJuxlClCDV0GcgKSrbFqB/ukw13cC bWMphIJPmGRoQ== Received: by mail-ed1-f70.google.com with SMTP id fi8-20020a056402550800b004a26cc7f6cbso41490223edb.4 for ; Mon, 03 Apr 2023 07:45:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533137; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jf893Mr1zYfCNeUs9dWOENLdN29rryafRcjFVjzmYec=; b=I5ZlQQglFxinnEXBmdtQkMO1T5C+le01KfzdNp6nmpN1GlELrjYsbego2pO9JEqE0P iBOwJvCYgbQjgq2HfLsb68/EpfCwtP3PTBf2RVLzM23KU6vQv58HLf6eAYuLiUGP78Qc Hq/xevDWYNVeP2ZtudMwkdnGfAyB69zUrPb8qOnkM2SIXHLKum6N4BvbeP8VIfJK41Kw 8BAZ42R9OoxvaFIK9FZ+W+6cngIoHefVJPp+oCiLbGp2WlmF6PA7J6fxPJRvuUBp0UXI MtUqI050vfLV5dzCa5YaybrYwK6ylHHvVa35rHO5Zw7y4e38g0AFvbMJO739BCZyS+q+ IGrw== X-Gm-Message-State: AAQBX9fOH9zQj4w7jdxPdpGmMTmHMDYyy6ymqqhD4BxMrki9s9CCuFFc WNPJYz+rGFafeYdDEvWTlypcG3owSDSrSsAKtv6rYzNCZIncZC+HI58/y7pOr90bmWH35cHivWZ zIe5omembNyFVJ6mZURCOZCLOnrJkG9aPWdMOKYaB2w== X-Received: by 2002:a05:6402:411:b0:502:251b:3a4c with SMTP id q17-20020a056402041100b00502251b3a4cmr30174831edv.20.1680533137387; Mon, 03 Apr 2023 07:45:37 -0700 (PDT) X-Received: by 2002:a05:6402:411:b0:502:251b:3a4c with SMTP id q17-20020a056402041100b00502251b3a4cmr30174814edv.20.1680533137108; Mon, 03 Apr 2023 07:45:37 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:36 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 1/9] fuse: move FUSE_DEFAULT_* defines to fuse common header Date: Mon, 3 Apr 2023 16:45:09 +0200 Message-Id: <20230403144517.347517-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762166883914153258?= X-GMAIL-MSGID: =?utf-8?q?1762166883914153258?= Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/fuse_i.h | 6 ++++++ fs/fuse/inode.c | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 9b7fc7d3c7f1..69af0acecb69 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -47,6 +47,12 @@ /** Number of dentries for each connection in the control filesystem */ #define FUSE_CTL_NUM_DENTRIES 5 +/** Maximum number of outstanding background requests */ +#define FUSE_DEFAULT_MAX_BACKGROUND 12 + +/** Congestion starts at 75% of maximum */ +#define FUSE_DEFAULT_CONGESTION_THRESHOLD (FUSE_DEFAULT_MAX_BACKGROUND * 3 / 4) + /** List of active connections */ extern struct list_head fuse_conn_list; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 660be31aaabc..3de950104f15 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -53,12 +53,6 @@ MODULE_PARM_DESC(max_user_congthresh, #define FUSE_DEFAULT_BLKSIZE 512 -/** Maximum number of outstanding background requests */ -#define FUSE_DEFAULT_MAX_BACKGROUND 12 - -/** Congestion starts at 75% of maximum */ -#define FUSE_DEFAULT_CONGESTION_THRESHOLD (FUSE_DEFAULT_MAX_BACKGROUND * 3 / 4) - #ifdef CONFIG_BLOCK static struct file_system_type fuseblk_fs_type; #endif From patchwork Mon Apr 3 14:45:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2373975vqo; Mon, 3 Apr 2023 08:10:39 -0700 (PDT) X-Google-Smtp-Source: AKy350ZuBFVBPDgitX4QKVdBXYtC0/gX8s4GARsWsfV/xKHJxp15yQYdMcaMDM+HVUDO8BoJWpRH X-Received: by 2002:a17:90b:1a88:b0:23f:680e:78be with SMTP id ng8-20020a17090b1a8800b0023f680e78bemr37380750pjb.48.1680534639147; Mon, 03 Apr 2023 08:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680534639; cv=none; d=google.com; s=arc-20160816; b=YMQOZrWWN+tBYvZBGSr+a4FOllOt0BOLXtpa0jhHe4pOU5MEKbRy3Yno7oXu+i5T8O mTPEfkt9jopiS/6KHt5O0FQcBMLR3fbkUUYzTigDO2FlRbfuYPdod6PhAkwrlSZOMVT1 1RCv8JnxQuPaIrNzIDRR6X4DRdQySXQ7pQ0bxS0okB6WOuWht6CuWcX0oBIMPGiS2lYq N6X0dh+irZ4eKJThd5WwHyzG/7fUg1Rhzl9k/KCZ990IzcGamfgoKnfGWAywjLtqOZV6 E/gYEuUNBcnLw2L4jg31icy9BlG94QVkxcFk0CO6zl8AFz5Qh+qOTk54ZblR1hDfabQ7 MZQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bVeWuEcFFA9BOaey9u9VyyM5TuRxdAhm6TBxfMNpyiQ=; b=dmMKVqxZ/bc0uHZOwpgdgzwhpzASJzMJlU8lyJcgXQl2ih/nnTg6IwfArLsJEYwvF5 k+XlbHU5W+1mPaJGgSQPijGwf/bLlieWyC77iNdhr3EOtHHxIjfZdwcFHvEtncCTmN0m w1/1IzeTr4yF7dXqqy5JCto1s+/JmjTbva5Nt6rVv/lUSyFEvpj/Vu7nU0LbjnX6lGMO GzFRGaoB4RTNRWAaO7Ix2M7hQqQE0i362VHssb5sX/eqcmYI2LYFA2VqxqGoA0xUVklz YzJrDVQ877kKTD3+IpWuMkxFpbeiTC68S62ewiZw37srBQyOSKTGBqDR9CppqvuEMHQ3 Ky+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=ShYw+yvJ; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u27-20020a63235b000000b005031abe8d8bsi346124pgm.745.2023.04.03.08.10.25; Mon, 03 Apr 2023 08:10:39 -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=@canonical.com header.s=20210705 header.b=ShYw+yvJ; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234012AbjDCOqe (ORCPT + 99 others); Mon, 3 Apr 2023 10:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233996AbjDCOq1 (ORCPT ); Mon, 3 Apr 2023 10:46:27 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC78280F2 for ; Mon, 3 Apr 2023 07:46:05 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 129113F23A for ; Mon, 3 Apr 2023 14:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533139; bh=bVeWuEcFFA9BOaey9u9VyyM5TuRxdAhm6TBxfMNpyiQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ShYw+yvJL3g/L8PFFXuhOLMPSmHDcwKtiig9o+g++ghQw5cyNK5YLs1v/t0eeO+5M pVi+aMy3pt6lzrIFAnqeA9YKnyiXRRjjfmeHJc2+hqUc2mrSKz5AlO/HMyWmuvzWYe kEWpW4V9lU1nJuTfbaGCyBvv5guwZ3xPpCLSAhQ0bepQEysnDWYE+bIJ9mxuEVgXAV VAVDj70o5s5AtOk22X04GNoQGCjSzqmCOq6W//FZV9XzeYFGvGnsM0pUMwGkCRQuwk fMfbtHQq3yC2JwgP/g0fBi+VknXyPgkGB3xJeGDjYwTZOS0gOg7Sr0gYNZn28wJ/EE pIlrdoSwLaAUA== Received: by mail-ed1-f71.google.com with SMTP id x35-20020a50baa6000000b005021d1b1e9eso41907530ede.13 for ; Mon, 03 Apr 2023 07:45:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533139; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bVeWuEcFFA9BOaey9u9VyyM5TuRxdAhm6TBxfMNpyiQ=; b=DlJ+Aa4yFhekeuL3Tik2tN9HnqPJX0vpbWge+5aBIRR9ItPOe8g34X0bOgYnG+aSln EwNOe7j9C2jPWm5sa2X3PMnzeqhrBHxxxskqjB2VbmgiuX5IpJQDV7asg0VxSc+X0SAM Y+Eb8XZ0Yj9DxoReX/ZRVGBLBLC9WKLzVzfz7wY4WCP9TlIvCKY7q67B8zgUGn3HrlWE y0nU9i8vTIpH96yU12DvmL9gNKKQpGOF76f97BUQcvX/MZWeB7UNp8ObdEaEDgGgAGMt xasn+/UjEI3lzxF486C2l3ar58xW73R0QJwGMkEo8MsU8MFKiwNJDtAd0CSkEW3AvIZe GvbA== X-Gm-Message-State: AAQBX9cPgPOP+/B2WUPxIhus1OL6GNhpMDEfUtnd5Gt7y4gSGX9bFt+k 0t5Cc1ySYR8u2BrhR/AJRaskPUZN3H0zTww8wRrQnPMDmIkegjwRG1R3hODOJJD9Gr4ZKJerMae d9mjfiAvyTyFfG2Arn50ZCxNkIE6zkDCCnDtH5mxxEw== X-Received: by 2002:a05:6402:8d9:b0:4fe:19cb:4788 with SMTP id d25-20020a05640208d900b004fe19cb4788mr32810324edz.42.1680533138915; Mon, 03 Apr 2023 07:45:38 -0700 (PDT) X-Received: by 2002:a05:6402:8d9:b0:4fe:19cb:4788 with SMTP id d25-20020a05640208d900b004fe19cb4788mr32810305edz.42.1680533138636; Mon, 03 Apr 2023 07:45:38 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:38 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 2/9] fuse: add const qualifiers to common fuse helpers Date: Mon, 3 Apr 2023 16:45:10 +0200 Message-Id: <20230403144517.347517-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762168290133113529?= X-GMAIL-MSGID: =?utf-8?q?1762168290133113529?= Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/fuse_i.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 69af0acecb69..6d3d3ca4f136 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -870,32 +870,32 @@ struct fuse_mount { struct list_head fc_entry; }; -static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb) +static inline struct fuse_mount *get_fuse_mount_super(const struct super_block *sb) { return sb->s_fs_info; } -static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) +static inline struct fuse_conn *get_fuse_conn_super(const struct super_block *sb) { return get_fuse_mount_super(sb)->fc; } -static inline struct fuse_mount *get_fuse_mount(struct inode *inode) +static inline struct fuse_mount *get_fuse_mount(const struct inode *inode) { return get_fuse_mount_super(inode->i_sb); } -static inline struct fuse_conn *get_fuse_conn(struct inode *inode) +static inline struct fuse_conn *get_fuse_conn(const struct inode *inode) { return get_fuse_mount_super(inode->i_sb)->fc; } -static inline struct fuse_inode *get_fuse_inode(struct inode *inode) +static inline struct fuse_inode *get_fuse_inode(const struct inode *inode) { return container_of(inode, struct fuse_inode, inode); } -static inline u64 get_node_id(struct inode *inode) +static inline u64 get_node_id(const struct inode *inode) { return get_fuse_inode(inode)->nodeid; } @@ -905,7 +905,7 @@ static inline int invalid_nodeid(u64 nodeid) return !nodeid || nodeid == FUSE_ROOT_ID; } -static inline u64 fuse_get_attr_version(struct fuse_conn *fc) +static inline u64 fuse_get_attr_version(const struct fuse_conn *fc) { return atomic64_read(&fc->attr_version); } @@ -923,7 +923,7 @@ static inline void fuse_make_bad(struct inode *inode) set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state); } -static inline bool fuse_is_bad(struct inode *inode) +static inline bool fuse_is_bad(const struct inode *inode) { return unlikely(test_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state)); } From patchwork Mon Apr 3 14:45:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2357938vqo; Mon, 3 Apr 2023 07:49:08 -0700 (PDT) X-Google-Smtp-Source: AKy350ZvDYC0Gmq03qCm/MpC4dQcNsup/Qv0Ctu9+MYmtZoH7kwuNdMf+u5u20LVBUGtFOkWy2ta X-Received: by 2002:a17:906:68c5:b0:932:748b:196e with SMTP id y5-20020a17090668c500b00932748b196emr35229364ejr.45.1680533348476; Mon, 03 Apr 2023 07:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680533348; cv=none; d=google.com; s=arc-20160816; b=wSrGpWDlekXqjC/chLLO0bKp4pKUAOQKnLRW3HEA421NHwU0gYzrlBgoNKQBUrLDIV FPpgN8+Gu+ycaJSt3KikEcAhBVwPbxU/E+f7EeDn4JItNAGewDERCMlzB9zzaNYvsCrG qS2grT+bgI7vaO3Iy8tQ+PDBI54MsR1zvbw7V08bNLb8T2I9PbCSvhopIV04fuUCWRxm 0AGFOFoia2TCaA5TvOem+O0lvoRmjeVQuZx4stGB0meaOkIPY7u9NlZHEsNhDHU82omx vaqci8oeQMEArCU2Icj9Lz4k54ngGTkXY4awp3tpgrPtrqJsWQBR7KQsiPXJa/4fZaKu I7Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mIRd3G7EmqzBYzec9Xklmi0CbHz6DDwl1OuXrzwAvTA=; b=VkQNuvRHyjfIZVzvhPuFaViUf5VLN3AMhsA7iuK8JgtEfACuEafyNP+gCTsDjccP+6 MdmuX8QGE9LW/UiTwUSK9OEuO+ZtyJ4PAWyMu0yrbXevCPA53zA94IaJGuqJZVOAKLXO yOQnmz1Bl3GLE3LwbLC9UqHvWQlHMA+XF79EGemV9MLr27NRSo+smwepKcIpyenX7FzR clvIDbYbBs3w2MTqxbbPIg1M1AsaWX9jm5GDXkLWY93LAqYOHqo9Q5yJGVW9DDZz21sj oKrTbkZKysQOeyRC17837AqvpkS5JHU2L3GyzQAV35Z7ms/aoUIf5K6Fhdw6yLg2kHK+ sp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=lGB7KEMA; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s22-20020a056402165600b005024afeb6f8si2352238edx.625.2023.04.03.07.48.44; Mon, 03 Apr 2023 07:49:08 -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=@canonical.com header.s=20210705 header.b=lGB7KEMA; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234137AbjDCOrt (ORCPT + 99 others); Mon, 3 Apr 2023 10:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234069AbjDCOrX (ORCPT ); Mon, 3 Apr 2023 10:47:23 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A0D29BE8 for ; Mon, 3 Apr 2023 07:46:44 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 92AE53F327 for ; Mon, 3 Apr 2023 14:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533148; bh=mIRd3G7EmqzBYzec9Xklmi0CbHz6DDwl1OuXrzwAvTA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lGB7KEMA+Bvahdxr6tUIYznJ0MsIdOopPdZXoM3XiWo22EeZFpnC7Hkx1pobC1JfG eNRIppJQYPSNykhO4TD36GXVBcyUtt9KYnHJHWWrxHr7X+TJWjPJlPFIJNdFAX9rYW vEq5aJ0TtB4VGa8Y6E7W4N0VPh4yiuDzmGiWKhieuMCTVQNRmwgzepnloMmLEmmEGU 9GDtZ9o2lp4OIRHnC8ZU2JnFWdcPFbPLlx1nzuSJ03rC8xu61s4eT1htw8zQIlKmn/ nhPqt/PkvEiJButikBeIATMUiddb3srhmHndhSPC/jPGxrWD+CJADCnWvpGHaYgzmG nqwFf5WmiSZFg== Received: by mail-ed1-f71.google.com with SMTP id b1-20020aa7dc01000000b004ad062fee5eso41220795edu.17 for ; Mon, 03 Apr 2023 07:45:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mIRd3G7EmqzBYzec9Xklmi0CbHz6DDwl1OuXrzwAvTA=; b=i2u4j+y/5YaJWPImy4jdj7z7ORuMyDWu0PaaLtuAQDpMOCr3zGPjAUYpCvI4+5GQMr t6Bd8MBzZs7ck3O13tCtOyjVc1kZrF0yP+B9H+d4OZfBH9qdHUyNnCGpyPbKBLe8OsZM rS4CeGNNHCG9aXF2+lDJHbpb/Am4Ywhg51/YT8hobUcW0LVZIg4P6YrC+e2qTb100Uit CsiE9Rzf/GByphkrTom/FluLpbiBJZRrNEC2VER4Sg5+6C8QA5/estUSsy0sgb3oYmmS JRY1btAYzAuAeZDNAhe8kn2h5Szyq1iZDY0xbPl33qCAAfNjTfWocQZ1KmYqai7Ku54U 3diw== X-Gm-Message-State: AAQBX9f+q8amIfXvg6VkeO6Qlr8vbvp5gcqRqAixKLVIA/AXtGh27t94 7mdGQZ3ouhzv6cNRusBBcbrfRrrQ8cYbnYRbjL0f0Ctfn8ghvq1YoTL9UBbBoOx41ePL0BF4gxJ fNCghO92jRLlOsfMGxkNN3F6fZCNIgq2LKeI6JYeCXg== X-Received: by 2002:a17:906:8a41:b0:930:18f5:d016 with SMTP id gx1-20020a1709068a4100b0093018f5d016mr35370791ejc.15.1680533140352; Mon, 03 Apr 2023 07:45:40 -0700 (PDT) X-Received: by 2002:a17:906:8a41:b0:930:18f5:d016 with SMTP id gx1-20020a1709068a4100b0093018f5d016mr35370775ejc.15.1680533140205; Mon, 03 Apr 2023 07:45:40 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:39 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 3/9] fuse: add fuse connection generation Date: Mon, 3 Apr 2023 16:45:11 +0200 Message-Id: <20230403144517.347517-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762166936640926939?= X-GMAIL-MSGID: =?utf-8?q?1762166936640926939?= We will use connection generation to detect stale inodes from the "old" fuse daemon and invalidate/revalidate them. There is no functional changes. Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/file.c | 1 + fs/fuse/fuse_i.h | 29 +++++++++++++++++++++++++++++ fs/fuse/inode.c | 2 ++ 3 files changed, 32 insertions(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index de37a3a06a71..1e36cd9490c6 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -79,6 +79,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm) init_waitqueue_head(&ff->poll_wait); ff->kh = atomic64_inc_return(&fm->fc->khctr); + ff->conn_gen = READ_ONCE(fm->fc->conn_gen); return ff; } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 6d3d3ca4f136..8d4276d7ab1e 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -161,6 +161,9 @@ struct fuse_inode { */ struct fuse_inode_dax *dax; #endif + + /** Fuse connection (fuse_conn) generation when inode was allocated */ + u32 conn_gen; }; /** FUSE inode state bits */ @@ -232,6 +235,9 @@ struct fuse_file { /** Has flock been performed on this file? */ bool flock:1; + + /** Fuse connection (fuse_conn) generation when file was allocated */ + u32 conn_gen; }; /** One input argument of a request */ @@ -847,6 +853,18 @@ struct fuse_conn { /* New writepages go into this bucket */ struct fuse_sync_bucket __rcu *curr_bucket; + + /** + * Connection generation. + * Used to determine if inodes/files were created with an "old" + * fuse connection and have to be invalidated. So, all requests + * related to these inodes should fail with -EIO. + * + * CHECKME: do we really need conn_gen for struct fuse_file? + * Right now it's only needed for fuse_file_put(), where we have + * no access to the inode in some cases. + */ + u32 conn_gen; }; /* @@ -910,6 +928,17 @@ static inline u64 fuse_get_attr_version(const struct fuse_conn *fc) return atomic64_read(&fc->attr_version); } +static inline bool fuse_stale_ff(const struct fuse_file *ff) +{ + return unlikely(READ_ONCE(ff->fm->fc->conn_gen) != ff->conn_gen); +} + +static inline bool fuse_stale_inode_conn(const struct inode *inode) +{ + return unlikely(READ_ONCE(get_fuse_conn(inode)->conn_gen) != + get_fuse_inode(inode)->conn_gen); +} + static inline bool fuse_stale_inode(const struct inode *inode, int generation, struct fuse_attr *attr) { diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3de950104f15..009fe5bbb855 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -77,6 +77,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb) fi->attr_version = 0; fi->orig_ino = 0; fi->state = 0; + fi->conn_gen = READ_ONCE(get_fuse_conn_super(sb)->conn_gen); mutex_init(&fi->mutex); spin_lock_init(&fi->lock); fi->forget = fuse_alloc_forget(); @@ -848,6 +849,7 @@ void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm, fc->user_ns = get_user_ns(user_ns); fc->max_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; fc->max_pages_limit = FUSE_MAX_MAX_PAGES; + fc->conn_gen = 1; INIT_LIST_HEAD(&fc->mounts); list_add(&fm->fc_entry, &fc->mounts); From patchwork Mon Apr 3 14:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2375317vqo; Mon, 3 Apr 2023 08:12:20 -0700 (PDT) X-Google-Smtp-Source: AKy350aVmWsQR+Dxzm0DEVzsxVZjhP+46HFvqWjyfhEoiANRULdOinZc/M18AIcGRXp+TQdvTZfv X-Received: by 2002:a17:903:1d1:b0:1a0:76d1:545c with SMTP id e17-20020a17090301d100b001a076d1545cmr18174429plh.10.1680534739957; Mon, 03 Apr 2023 08:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680534739; cv=none; d=google.com; s=arc-20160816; b=mZpIlmQORP7q0WlTxy7iA9g3/kZNStyq4QTQi8uwFAl0kXatwQ6ziPOj8lDYsJWupc 0sPuMPrn2llKJ7dS1mVwfjq99QZ8LrguU61BtY+0eIUwmfxHWS/b8P4tL81PO2Vc/jYf fZlN71EpCVPm30rBPcb0MIk949vdq84+0v2P5EouNWj4QG0zz/sWVPpPef+TgSMUU+a/ wvyHr1s/jie+IWnWibAD0QDZTHlvVenZ/2gA27mrdepAoX2tvKhJO+9Sifk8Onmwi0/g oN5dTDbxfEZlJGIOsaDtNWPlwwNFmD3DnJ29xJWzoJIJvaSKKfmKgKLakfk9np6ax5m9 LcaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sfvJPZXm6cJkfP1IztZnpclfjk/5sorCwMJVKfMiws4=; b=qgUQbOZbd7qt8Xcm49fXycr3B3ziEEhLy1UkKQgIojx3LguRFMB2CaBks/Xyv+FNkr xAgSo//qcN22OAG2mdbrp81qsbiosUHEbOOQYPy8+CCYMuBNSAAa6eIWJidvDpLVeK17 owU8GOdNrDxTDgwjEmPnaTfCvw2zE9i6Xr81R+xKGg/Zr5s4SgWY9wYi3p3Eyv4Tx0KR //GTvx/K3lbrVF/awqb0aszEOdWscmknVj7vJs+lEN28MC4hh35sY1i3yKYKybPmqrMy 0uqDE0eoKAjgtIeS7QI1HFWU9IhtPo8bnFp4jJxnSZ6CKzhNW+S+QEKjq3RJJNIKYQuY 9GgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=FYJkJm44; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a6543c7000000b00513522599casi7924064pgp.831.2023.04.03.08.12.07; Mon, 03 Apr 2023 08:12:19 -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=@canonical.com header.s=20210705 header.b=FYJkJm44; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234083AbjDCOrz (ORCPT + 99 others); Mon, 3 Apr 2023 10:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234021AbjDCOr0 (ORCPT ); Mon, 3 Apr 2023 10:47:26 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8E3280CF for ; Mon, 3 Apr 2023 07:46:45 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 15CC53F238 for ; Mon, 3 Apr 2023 14:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533147; bh=sfvJPZXm6cJkfP1IztZnpclfjk/5sorCwMJVKfMiws4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=FYJkJm44yfHAU6oqo2eHiaAvu3iXwpZxlvjz+gUEdmd8QtywQPLnu3NSz160zbnL9 aKmnOEidWu5jvJWTme6iIlU5gQoQIbH9ISn6xlktQyFkXUhBSU5y+tzhvFd8QqeNNV E6LiZNab97Vbqr3lHL1MofZk7+rxNurv3yVlURkGg4LZ4kcyGq6OOjas6Q/087zRlR gCcUTA1xzuxxRx92JadpOvhOXSPGHXt2+MK/sFyLR1HduPt/DHQN69WlO9tnuyAFWM rgmuWgiuaF/I6OJj/WK0PzFaH4ihA7eXIebm7yQrzbB/ev+elV/wC7ehzazZbDOH6Q KkWnkdTiTj8vA== Received: by mail-ed1-f71.google.com with SMTP id b1-20020aa7dc01000000b004ad062fee5eso41220905edu.17 for ; Mon, 03 Apr 2023 07:45:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533142; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sfvJPZXm6cJkfP1IztZnpclfjk/5sorCwMJVKfMiws4=; b=wOzaAT976hOe0Gkt2z3IfH8VYqLvJ2fwK6nWA2jhDcMGtroTRK6TWFL3VzMs339SPN vsXfb0PKglg3TfVhfXhKFscHz6OTr1f6abcQr404tS9DLSaVvVkzqPI92Hcv/h4PNisU tYV6mPO8pTozBpjEieZ6wU8Xj+Yg0VnBRj8TAVVG4BNxLxiUDvT8rXy+XSsfb6qEDnfX R3jsHq/M+JXClK+dio2lsj6JIRI2XvFNpHdkun44mblUPNvejUxbsQe+PZ0lwYJIIklc q6DVrl48akW2d6ZOcwK5Jj7VXG83SsWG/8YXO/jYy6EYIoCZ8EHTX8joVnKeU1XgsOEt OsbA== X-Gm-Message-State: AAQBX9f/hR4rKW/szE1zjw9wSK9z4UqaJ4y67T88QuMqg9V+xGYWkfeK MFYDeR8XUdUUDs/3l5vpet2HfZxaG5PVL8+OVVjHdO1HlOZ7E72NibFo5/pqaWPR7nit+MnuMa0 I71Q3RpO8yEtxZJAgWeMPg3bsae1sKthMe4a7r3e+XA== X-Received: by 2002:aa7:d7d3:0:b0:501:d542:4d0c with SMTP id e19-20020aa7d7d3000000b00501d5424d0cmr34895169eds.22.1680533142014; Mon, 03 Apr 2023 07:45:42 -0700 (PDT) X-Received: by 2002:aa7:d7d3:0:b0:501:d542:4d0c with SMTP id e19-20020aa7d7d3000000b00501d5424d0cmr34895154eds.22.1680533141811; Mon, 03 Apr 2023 07:45:41 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:41 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 4/9] fuse: handle stale inode connection in fuse_queue_forget Date: Mon, 3 Apr 2023 16:45:12 +0200 Message-Id: <20230403144517.347517-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762168395291387159?= X-GMAIL-MSGID: =?utf-8?q?1762168395291387159?= We don't want to send FUSE_FORGET request to the new fuse daemon if inode was lookuped by the old fuse daemon because it can confuse and break userspace (libfuse). For now, just add a new argument to fuse_queue_forget and handle it. Adjust all callers to match the old behaviour. Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dev.c | 4 ++-- fs/fuse/dir.c | 8 ++++---- fs/fuse/fuse_i.h | 2 +- fs/fuse/inode.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index eb4f88e3dc97..2e7cd60b685e 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -234,7 +234,7 @@ __releases(fiq->lock) } void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, - u64 nodeid, u64 nlookup) + u64 nodeid, u64 nlookup, bool stale_inode_conn) { struct fuse_iqueue *fiq = &fc->iq; @@ -242,7 +242,7 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, forget->forget_one.nlookup = nlookup; spin_lock(&fiq->lock); - if (fiq->connected) { + if (fiq->connected && likely(!stale_inode_conn)) { fiq->forget_list_tail->next = forget; fiq->forget_list_tail = forget; fiq->ops->wake_forget_and_unlock(fiq); diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 5a4a7155cf1c..7e308a655191 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -250,7 +250,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) if (outarg.nodeid != get_node_id(inode) || (bool) IS_AUTOMOUNT(inode) != (bool) (outarg.attr.flags & FUSE_ATTR_SUBMOUNT)) { fuse_queue_forget(fm->fc, forget, - outarg.nodeid, 1); + outarg.nodeid, 1, false); goto invalid; } spin_lock(&fi->lock); @@ -403,7 +403,7 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name attr_version); err = -ENOMEM; if (!*inode) { - fuse_queue_forget(fm->fc, forget, outarg->nodeid, 1); + fuse_queue_forget(fm->fc, forget, outarg->nodeid, 1, false); goto out; } err = 0; @@ -690,7 +690,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, if (!inode) { flags &= ~(O_CREAT | O_EXCL | O_TRUNC); fuse_sync_release(NULL, ff, flags); - fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1); + fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1, false); err = -ENOMEM; goto out_err; } @@ -815,7 +815,7 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args, inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, &outarg.attr, entry_attr_timeout(&outarg), 0); if (!inode) { - fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1); + fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1, false); return -ENOMEM; } kfree(forget); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 8d4276d7ab1e..be5d5d3fe6f5 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1008,7 +1008,7 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name * Send FORGET command */ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, - u64 nodeid, u64 nlookup); + u64 nodeid, u64 nlookup, bool stale_inode_conn); struct fuse_forget_link *fuse_alloc_forget(void); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 009fe5bbb855..e5ad5d4c215a 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -124,7 +124,7 @@ static void fuse_evict_inode(struct inode *inode) fuse_dax_inode_cleanup(inode); if (fi->nlookup) { fuse_queue_forget(fc, fi->forget, fi->nodeid, - fi->nlookup); + fi->nlookup, false); fi->forget = NULL; } } From patchwork Mon Apr 3 14:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2368325vqo; Mon, 3 Apr 2023 08:03:56 -0700 (PDT) X-Google-Smtp-Source: AKy350buRCqhki/O2H3zMhuaZ1FJnfylAQiy5UKcePpAJbq02HOiI47N2QPpL1VpRflI8jwbkEGz X-Received: by 2002:a17:902:e80c:b0:19e:82aa:dc8a with SMTP id u12-20020a170902e80c00b0019e82aadc8amr46309578plg.22.1680534235945; Mon, 03 Apr 2023 08:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680534235; cv=none; d=google.com; s=arc-20160816; b=cg9vzQCgGg8D8DVM2nfiTqyGaT1pZ5u8brhFXKU+7DveBOyBSqfxJ+7Sbw9Ckri7kv pl/a+88uifIi3vak5VY9ulsX127mmMT+w80+TjAAk7rsIfjUgwFyv2GLm1PDMirjAXSp IrCZbg61WCcTSyn8EveyzUzS2UnVV1GvDC7dWJW3hRvLU9fH741BbtBDpvGMKIX+hs36 eQkTFKhKOec0Y5mY//luCXGq+qG/L1UBWGvSTEdpvGOevVgc6HAdGncYW1iYSvu5Zt95 xXfZMaG6Gh18nbbOhi4ZRQk2XuPoTDwYVzKg09OH+cQOWhp5+3oBIviOKhxaciv2Vip0 j4gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x5RnUDjgYT8e/ziRn/O8mcriKdksyC0pPXgew4XaumM=; b=URaPmTOnP76NLoOArAtQ2Ms2+YViXkPeacSrIstmO2BosUsHhxm66rMYwtKHJHRySK eRHDmdaxpjmU8a0RX+G81JvbzEiLaffeCiHbrvuG/3jqpvS5lrh3/GlXUevBYXO1kEw+ nVVVdF/oEM/0/wpV6FZKUz1EujhWrhT3Rn+zhHQKDGDf9eJ3+TXYn+RSvyWlO5MOwl/D 2wQsWWRnhUhVPVFI3CNp3RpMjkMhknMuDEW87L98EUNnmTksW6fWW5x4a11VYwUDL0E6 QrcLJ6qEoKWIdQuNKDesW4T7xuc1dZNRaBDvAuQ6IO9KkNF9V2kicwmq5nbEUNwNaRg6 jdkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=mgR4qhPo; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a170902a51800b001a1def4a04bsi7925948plq.375.2023.04.03.08.02.57; Mon, 03 Apr 2023 08:03:55 -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=@canonical.com header.s=20210705 header.b=mgR4qhPo; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234026AbjDCOq6 (ORCPT + 99 others); Mon, 3 Apr 2023 10:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234000AbjDCOqh (ORCPT ); Mon, 3 Apr 2023 10:46:37 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F33D35031 for ; Mon, 3 Apr 2023 07:46:18 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 524D43F23B for ; Mon, 3 Apr 2023 14:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533144; bh=x5RnUDjgYT8e/ziRn/O8mcriKdksyC0pPXgew4XaumM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=mgR4qhPohZ0/rMm+w4p6fTDQZ5j99kJ1JRspxRoPhPup+y8Aa6EFbBOe6ucVjCcPz ZyxQT5Pc0YzbtGAVxRtvWJnozAHsskXuo1BzPvnJlKIYKF2avu3FDCdeblMMFGNO2W ZJjd5A0xadzA4bulb+/dAJj8Ueo7rJ9FCe1WKlA9noDBIS7LHFrAaido6qXjr7p07M b3gkVx+8k0tDQJTscUr2p/AC5bktmSW0nN7ag2fEjXKT+WyqY/iWMPjYxxS3z4LcyX 1A5QJKPeY2weIuXgj/5WTql4QnQ3s0Wag1d0jUOC+kR/rGNBTtWoDXE+iPYel/NQIc u+z78FrDaDstQ== Received: by mail-ed1-f71.google.com with SMTP id t14-20020a056402240e00b004fb36e6d670so41324187eda.5 for ; Mon, 03 Apr 2023 07:45:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533144; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x5RnUDjgYT8e/ziRn/O8mcriKdksyC0pPXgew4XaumM=; b=Dme5RyuffoYty0D5ZnXL1ZihBne/x+kA3Kzw4QU6IJxTviYUfC0BfcpNaHnCWkQ10B QbFLS/042e6ctfuBBxD95+YTvOUmqds2wU1gjyTZsBCkWOI5eyf5nej2CVfUCLP/cqzT KM4Jp5O/B4s5TuTkbJ2igAY0n2o/XyZBbeIWS2xsW5J/uVNb/z9R3cmSZCHVs5MzfWVl YKROdjlwP82ChUcrm8sQCZuCa9KGR5f+RX8/Op4L1Mb8eslvhVqavk8I//vBGdUg/ium A62hflRzf4mnjbsOgoI5zWwsg6x5avlY7fVuuM9wQROaoG7CuH+QAxTi27rFn54Oe7zk VQug== X-Gm-Message-State: AAQBX9df+/+JrVAytBYl3kqafvHiuHej0uSo+YGQmRFz54+SsIpuicWK DLr8A5iPYBry+OHIBFyGxdx8GVaLxTQIIScgCdmaI+NX1zxPt+UaOZKTGi9x/gV1PYARwrHYT5m 0wOIipkGwaydEoSRp0TZAamOm6Mw78khiC6oXUGHudQ== X-Received: by 2002:a05:6402:18c:b0:502:9885:f359 with SMTP id r12-20020a056402018c00b005029885f359mr4502646edv.39.1680533143814; Mon, 03 Apr 2023 07:45:43 -0700 (PDT) X-Received: by 2002:a05:6402:18c:b0:502:9885:f359 with SMTP id r12-20020a056402018c00b005029885f359mr4502622edv.39.1680533143426; Mon, 03 Apr 2023 07:45:43 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:43 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 5/9] fuse: move fuse connection flags to the separate structure Date: Mon, 3 Apr 2023 16:45:13 +0200 Message-Id: <20230403144517.347517-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762167866762630251?= X-GMAIL-MSGID: =?utf-8?q?1762167866762630251?= Let's move all the fuse connection flags that can be safely zeroed after connection reinitialization to the separate structure fuse_conn_flags. All of these flags values are calculated dynamically basing on the userspace daemon capabilities (like no_open, no_flush) or on the response for FUSE_INIT request. Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/acl.c | 6 +- fs/fuse/dev.c | 4 +- fs/fuse/dir.c | 26 +++--- fs/fuse/file.c | 80 ++++++++-------- fs/fuse/fuse_i.h | 228 ++++++++++++++++++++++++---------------------- fs/fuse/inode.c | 52 +++++------ fs/fuse/readdir.c | 8 +- fs/fuse/xattr.c | 18 ++-- 8 files changed, 218 insertions(+), 204 deletions(-) diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c index 3d192b80a561..549b5a1da7ff 100644 --- a/fs/fuse/acl.c +++ b/fs/fuse/acl.c @@ -26,7 +26,7 @@ static struct posix_acl *__fuse_get_acl(struct fuse_conn *fc, if (fuse_is_bad(inode)) return ERR_PTR(-EIO); - if (fc->no_getxattr) + if (fc->flags.no_getxattr) return NULL; if (type == ACL_TYPE_ACCESS) @@ -43,7 +43,7 @@ static struct posix_acl *__fuse_get_acl(struct fuse_conn *fc, if (size > 0) acl = posix_acl_from_xattr(fc->user_ns, value, size); else if ((size == 0) || (size == -ENODATA) || - (size == -EOPNOTSUPP && fc->no_getxattr)) + (size == -EOPNOTSUPP && fc->flags.no_getxattr)) acl = NULL; else if (size == -ERANGE) acl = ERR_PTR(-E2BIG); @@ -105,7 +105,7 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, if (fuse_is_bad(inode)) return -EIO; - if (fc->no_setxattr || fuse_no_acl(fc, inode)) + if (fc->flags.no_setxattr || fuse_no_acl(fc, inode)) return -EOPNOTSUPP; if (type == ACL_TYPE_ACCESS) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 2e7cd60b685e..b4501a10c379 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -367,7 +367,7 @@ static void request_wait_answer(struct fuse_req *req) struct fuse_iqueue *fiq = &fc->iq; int err; - if (!fc->no_interrupt) { + if (!fc->flags.no_interrupt) { /* Any signal may interrupt this */ err = wait_event_interruptible(req->waitq, test_bit(FR_FINISHED, &req->flags)); @@ -1901,7 +1901,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, if (nbytes != sizeof(struct fuse_out_header)) err = -EINVAL; else if (oh.error == -ENOSYS) - fc->no_interrupt = 1; + fc->flags.no_interrupt = 1; else if (oh.error == -EAGAIN) err = queue_interrupt(req); diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 7e308a655191..bfbe59e8fce2 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -705,7 +705,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, } else { file->private_data = ff; fuse_finish_open(inode, file); - if (fm->fc->atomic_o_trunc && trunc) + if (fm->fc->flags.atomic_o_trunc && trunc) truncate_pagecache(inode, 0); else if (!(ff->open_flags & FOPEN_KEEP_CACHE)) invalidate_inode_pages2(inode->i_mapping); @@ -748,12 +748,12 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, /* Only creates */ file->f_mode |= FMODE_CREATED; - if (fc->no_create) + if (fc->flags.no_create) goto mknod; err = fuse_create_open(dir, entry, file, flags, mode, FUSE_CREATE); if (err == -ENOSYS) { - fc->no_create = 1; + fc->flags.no_create = 1; goto mknod; } out_dput: @@ -1078,14 +1078,14 @@ static int fuse_rename2(struct mnt_idmap *idmap, struct inode *olddir, return -EINVAL; if (flags) { - if (fc->no_rename2 || fc->minor < 23) + if (fc->flags.no_rename2 || fc->minor < 23) return -EINVAL; err = fuse_rename_common(olddir, oldent, newdir, newent, flags, FUSE_RENAME2, sizeof(struct fuse_rename2_in)); if (err == -ENOSYS) { - fc->no_rename2 = 1; + fc->flags.no_rename2 = 1; err = -EINVAL; } } else { @@ -1352,7 +1352,7 @@ static int fuse_access(struct inode *inode, int mask) BUG_ON(mask & MAY_NOT_BLOCK); - if (fm->fc->no_access) + if (fm->fc->flags.no_access) return 0; memset(&inarg, 0, sizeof(inarg)); @@ -1364,7 +1364,7 @@ static int fuse_access(struct inode *inode, int mask) args.in_args[0].value = &inarg; err = fuse_simple_request(fm, &args); if (err == -ENOSYS) { - fm->fc->no_access = 1; + fm->fc->flags.no_access = 1; err = 0; } return err; @@ -1501,7 +1501,7 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode, if (fuse_is_bad(inode)) goto out_err; - if (fc->cache_symlinks) + if (fc->flags.cache_symlinks) return page_get_link(dentry, inode, callback); err = -ECHILD; @@ -1549,13 +1549,13 @@ static int fuse_dir_fsync(struct file *file, loff_t start, loff_t end, if (fuse_is_bad(inode)) return -EIO; - if (fc->no_fsyncdir) + if (fc->flags.no_fsyncdir) return 0; inode_lock(inode); err = fuse_fsync_common(file, start, end, datasync, FUSE_FSYNCDIR); if (err == -ENOSYS) { - fc->no_fsyncdir = 1; + fc->flags.no_fsyncdir = 1; err = 0; } inode_unlock(inode); @@ -1747,7 +1747,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr, struct fuse_setattr_in inarg; struct fuse_attr_out outarg; bool is_truncate = false; - bool is_wb = fc->writeback_cache && S_ISREG(inode->i_mode); + bool is_wb = fc->flags.writeback_cache && S_ISREG(inode->i_mode); loff_t oldsize; int err; bool trust_local_cmtime = is_wb; @@ -1780,7 +1780,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr, /* This is coming from open(..., ... | O_TRUNC); */ WARN_ON(!(attr->ia_valid & ATTR_SIZE)); WARN_ON(attr->ia_size != 0); - if (fc->atomic_o_trunc) { + if (fc->flags.atomic_o_trunc) { /* * No need to send request to userspace, since actual * truncation has already been done by OPEN. But still @@ -1927,7 +1927,7 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry, * * This should be done on write(), truncate() and chown(). */ - if (!fc->handle_killpriv && !fc->handle_killpriv_v2) { + if (!fc->flags.handle_killpriv && !fc->handle_killpriv_v2) { /* * ia_mode calculation may have used stale i_mode. * Refresh and recalculate. diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1e36cd9490c6..742f90b4e638 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -30,7 +30,7 @@ static int fuse_send_open(struct fuse_mount *fm, u64 nodeid, memset(&inarg, 0, sizeof(inarg)); inarg.flags = open_flags & ~(O_CREAT | O_EXCL | O_NOCTTY); - if (!fm->fc->atomic_o_trunc) + if (!fm->fc->flags.atomic_o_trunc) inarg.flags &= ~O_TRUNC; if (fm->fc->handle_killpriv_v2 && @@ -111,7 +111,7 @@ static void fuse_file_put(struct fuse_file *ff, bool sync, bool isdir) if (refcount_dec_and_test(&ff->count)) { struct fuse_args *args = &ff->release_args->args; - if (isdir ? ff->fm->fc->no_opendir : ff->fm->fc->no_open) { + if (isdir ? ff->fm->fc->flags.no_opendir : ff->fm->fc->flags.no_open) { /* Do nothing when client does not implement 'open' */ fuse_release_end(ff->fm, args, 0); } else if (sync) { @@ -141,7 +141,7 @@ struct fuse_file *fuse_file_open(struct fuse_mount *fm, u64 nodeid, ff->fh = 0; /* Default for no-open */ ff->open_flags = FOPEN_KEEP_CACHE | (isdir ? FOPEN_CACHE_DIR : 0); - if (isdir ? !fc->no_opendir : !fc->no_open) { + if (isdir ? !fc->flags.no_opendir : !fc->flags.no_open) { struct fuse_open_out outarg; int err; @@ -155,9 +155,9 @@ struct fuse_file *fuse_file_open(struct fuse_mount *fm, u64 nodeid, return ERR_PTR(err); } else { if (isdir) - fc->no_opendir = 1; + fc->flags.no_opendir = 1; else - fc->no_open = 1; + fc->flags.no_open = 1; } } @@ -206,7 +206,7 @@ void fuse_finish_open(struct inode *inode, struct file *file) else if (ff->open_flags & FOPEN_NONSEEKABLE) nonseekable_open(inode, file); - if (fc->atomic_o_trunc && (file->f_flags & O_TRUNC)) { + if (fc->flags.atomic_o_trunc && (file->f_flags & O_TRUNC)) { struct fuse_inode *fi = get_fuse_inode(inode); spin_lock(&fi->lock); @@ -216,7 +216,7 @@ void fuse_finish_open(struct inode *inode, struct file *file) file_update_time(file); fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE); } - if ((file->f_mode & FMODE_WRITE) && fc->writeback_cache) + if ((file->f_mode & FMODE_WRITE) && fc->flags.writeback_cache) fuse_link_write_file(file); } @@ -226,10 +226,10 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) struct fuse_conn *fc = fm->fc; int err; bool is_wb_truncate = (file->f_flags & O_TRUNC) && - fc->atomic_o_trunc && - fc->writeback_cache; + fc->flags.atomic_o_trunc && + fc->flags.writeback_cache; bool dax_truncate = (file->f_flags & O_TRUNC) && - fc->atomic_o_trunc && FUSE_IS_DAX(inode); + fc->flags.atomic_o_trunc && FUSE_IS_DAX(inode); if (fuse_is_bad(inode)) return -EIO; @@ -260,7 +260,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) if (!err) { struct fuse_file *ff = file->private_data; - if (fc->atomic_o_trunc && (file->f_flags & O_TRUNC)) + if (fc->flags.atomic_o_trunc && (file->f_flags & O_TRUNC)) truncate_pagecache(inode, 0); else if (!(ff->open_flags & FOPEN_KEEP_CACHE)) invalidate_inode_pages2(inode->i_mapping); @@ -351,7 +351,7 @@ static int fuse_release(struct inode *inode, struct file *file) * Dirty pages might remain despite write_inode_now() call from * fuse_flush() due to writes racing with the close. */ - if (fc->writeback_cache) + if (fc->flags.writeback_cache) write_inode_now(inode, 1); fuse_release_common(file, false); @@ -506,12 +506,12 @@ static int fuse_do_flush(struct fuse_flush_args *fa) goto out; err = 0; - if (fm->fc->no_flush) + if (fm->fc->flags.no_flush) goto inval_attr_out; err = fuse_simple_request(fm, &fa->args); if (err == -ENOSYS) { - fm->fc->no_flush = 1; + fm->fc->flags.no_flush = 1; err = 0; } @@ -520,7 +520,7 @@ static int fuse_do_flush(struct fuse_flush_args *fa) * In memory i_blocks is not maintained by fuse, if writeback cache is * enabled, i_blocks from cached attr may not be accurate. */ - if (!err && fm->fc->writeback_cache) + if (!err && fm->fc->flags.writeback_cache) fuse_invalidate_attr_mask(inode, STATX_BLOCKS); out: @@ -546,7 +546,7 @@ static int fuse_flush(struct file *file, fl_owner_t id) if (fuse_is_bad(inode)) return -EIO; - if (ff->open_flags & FOPEN_NOFLUSH && !fm->fc->writeback_cache) + if (ff->open_flags & FOPEN_NOFLUSH && !fm->fc->flags.writeback_cache) return 0; fa = kzalloc(sizeof(*fa), GFP_KERNEL); @@ -629,12 +629,12 @@ static int fuse_fsync(struct file *file, loff_t start, loff_t end, if (err) goto out; - if (fc->no_fsync) + if (fc->flags.no_fsync) goto out; err = fuse_fsync_common(file, start, end, datasync, FUSE_FSYNC); if (err == -ENOSYS) { - fc->no_fsync = 1; + fc->flags.no_fsync = 1; err = 0; } out: @@ -859,7 +859,7 @@ static void fuse_short_read(struct inode *inode, u64 attr_ver, size_t num_read, * the file. Some data after the hole is in page cache, but has not * reached the client fs yet. So the hole is not present there. */ - if (!fc->writeback_cache) { + if (!fc->flags.writeback_cache) { loff_t pos = page_offset(ap->pages[0]) + num_read; fuse_read_update_size(inode, pos, attr_ver); } @@ -990,7 +990,7 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) fuse_read_args_fill(ia, file, pos, count, FUSE_READ); ia->read.attr_ver = fuse_get_attr_version(fm->fc); - if (fm->fc->async_read) { + if (fm->fc->flags.async_read) { ia->ff = fuse_file_get(ff); ap->args.end = fuse_readpages_end; err = fuse_simple_background(fm, &ap->args, GFP_KERNEL); @@ -1057,7 +1057,7 @@ static ssize_t fuse_cache_read_iter(struct kiocb *iocb, struct iov_iter *to) * Otherwise, only update if we attempt to read past EOF (to ensure * i_size is up to date). */ - if (fc->auto_inval_data || + if (fc->flags.auto_inval_data || (iocb->ki_pos + iov_iter_count(to) > i_size_read(inode))) { int err; err = fuse_update_attributes(inode, iocb->ki_filp, STATX_SIZE); @@ -1264,7 +1264,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, ia->write.page_locked = true; break; } - if (!fc->big_writes) + if (!fc->flags.big_writes) break; } while (iov_iter_count(ii) && count < fc->max_write && ap->num_pages < max_pages && offset == 0); @@ -1344,7 +1344,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) struct fuse_conn *fc = get_fuse_conn(inode); loff_t endbyte = 0; - if (fc->writeback_cache) { + if (fc->flags.writeback_cache) { /* Update size (EOF optimization) and mode (SUID clearing) */ err = fuse_update_attributes(mapping->host, file, STATX_SIZE | STATX_MODE); @@ -1866,7 +1866,7 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args, * Do this only if writeback_cache is not enabled. If writeback_cache * is enabled, we trust local ctime/mtime. */ - if (!fc->writeback_cache) + if (!fc->flags.writeback_cache) fuse_invalidate_attr_mask(inode, FUSE_STATX_MODIFY); spin_lock(&fi->lock); rb_erase(&wpa->writepages_entry, &fi->writepages); @@ -2370,7 +2370,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping, loff_t fsize; int err = -ENOMEM; - WARN_ON(!fc->writeback_cache); + WARN_ON(!fc->flags.writeback_cache); page = grab_cache_page_write_begin(mapping, index); if (!page) @@ -2643,13 +2643,13 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) if (cmd == F_CANCELLK) { err = 0; } else if (cmd == F_GETLK) { - if (fc->no_lock) { + if (fc->flags.no_lock) { posix_test_lock(file, fl); err = 0; } else err = fuse_getlk(file, fl); } else { - if (fc->no_lock) + if (fc->flags.no_lock) err = posix_lock_file(file, fl, NULL); else err = fuse_setlk(file, fl, 0); @@ -2663,7 +2663,7 @@ static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) struct fuse_conn *fc = get_fuse_conn(inode); int err; - if (fc->no_flock) { + if (fc->flags.no_flock) { err = locks_lock_file_wait(file, fl); } else { struct fuse_file *ff = file->private_data; @@ -2685,7 +2685,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) struct fuse_bmap_out outarg; int err; - if (!inode->i_sb->s_bdev || fm->fc->no_bmap) + if (!inode->i_sb->s_bdev || fm->fc->flags.no_bmap) return 0; memset(&inarg, 0, sizeof(inarg)); @@ -2701,7 +2701,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) args.out_args[0].value = &outarg; err = fuse_simple_request(fm, &args); if (err == -ENOSYS) - fm->fc->no_bmap = 1; + fm->fc->flags.no_bmap = 1; return err ? 0 : outarg.block; } @@ -2720,7 +2720,7 @@ static loff_t fuse_lseek(struct file *file, loff_t offset, int whence) struct fuse_lseek_out outarg; int err; - if (fm->fc->no_lseek) + if (fm->fc->flags.no_lseek) goto fallback; args.opcode = FUSE_LSEEK; @@ -2734,7 +2734,7 @@ static loff_t fuse_lseek(struct file *file, loff_t offset, int whence) err = fuse_simple_request(fm, &args); if (err) { if (err == -ENOSYS) { - fm->fc->no_lseek = 1; + fm->fc->flags.no_lseek = 1; goto fallback; } return err; @@ -2841,7 +2841,7 @@ __poll_t fuse_file_poll(struct file *file, poll_table *wait) FUSE_ARGS(args); int err; - if (fm->fc->no_poll) + if (fm->fc->flags.no_poll) return DEFAULT_POLLMASK; poll_wait(file, &ff->poll_wait, wait); @@ -2869,7 +2869,7 @@ __poll_t fuse_file_poll(struct file *file, poll_table *wait) if (!err) return demangle_poll(outarg.revents); if (err == -ENOSYS) { - fm->fc->no_poll = 1; + fm->fc->flags.no_poll = 1; return DEFAULT_POLLMASK; } return EPOLLERR; @@ -2955,7 +2955,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) * By default, we want to optimize all I/Os with async request * submission to the client filesystem if supported. */ - io->async = ff->fm->fc->async_dio; + io->async = ff->fm->fc->flags.async_dio; io->iocb = iocb; io->blocking = is_sync_kiocb(iocb); @@ -3048,7 +3048,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, FALLOC_FL_ZERO_RANGE)) return -EOPNOTSUPP; - if (fm->fc->no_fallocate) + if (fm->fc->flags.no_fallocate) return -EOPNOTSUPP; inode_lock(inode); @@ -3088,7 +3088,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, args.in_args[0].value = &inarg; err = fuse_simple_request(fm, &args); if (err == -ENOSYS) { - fm->fc->no_fallocate = 1; + fm->fc->flags.no_fallocate = 1; err = -EOPNOTSUPP; } if (err) @@ -3144,10 +3144,10 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in, ssize_t err; /* mark unstable when write-back is not used, and file_out gets * extended */ - bool is_unstable = (!fc->writeback_cache) && + bool is_unstable = (!fc->flags.writeback_cache) && ((pos_out + len) > inode_out->i_size); - if (fc->no_copy_file_range) + if (fc->flags.no_copy_file_range) return -EOPNOTSUPP; if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) @@ -3200,7 +3200,7 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in, args.out_args[0].value = &outarg; err = fuse_simple_request(fm, &args); if (err == -ENOSYS) { - fc->no_copy_file_range = 1; + fc->flags.no_copy_file_range = 1; err = -EOPNOTSUPP; } if (err) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index be5d5d3fe6f5..943d5011dfa0 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -543,6 +543,125 @@ struct fuse_sync_bucket { struct rcu_head rcu; }; +/** + * A Fuse connection flags. + * + * This structure describes fuse connection capabilities, depending on the + * userspace daemon implementation. + * Most of this flags are calculated during the processing of reply to FUSE_INIT request, + * but some flags values are determined after connection initialization, for example, + * no_flush, no_setxattr, etc. These flags are safe to clear, because they always can be + * restored with a proper values in runtime. + */ +struct fuse_conn_flags { + /** Do readahead asynchronously? Only set in INIT */ + unsigned async_read:1; + + /** Do not send separate SETATTR request before open(O_TRUNC) */ + unsigned atomic_o_trunc:1; + + /** Filesystem supports NFS exporting. Only set in INIT */ + unsigned export_support:1; + + /** write-back cache policy (default is write-through) */ + unsigned writeback_cache:1; + + /** allow parallel lookups and readdir (default is serialized) */ + unsigned parallel_dirops:1; + + /** handle fs handles killing suid/sgid/cap on write/chown/trunc */ + unsigned handle_killpriv:1; + + /** cache READLINK responses in page cache */ + unsigned cache_symlinks:1; + + /* + * The following bitfields are only for optimization purposes + * and hence races in setting them will not cause malfunction + */ + + /** Is open/release not implemented by fs? */ + unsigned no_open:1; + + /** Is opendir/releasedir not implemented by fs? */ + unsigned no_opendir:1; + + /** Is fsync not implemented by fs? */ + unsigned no_fsync:1; + + /** Is fsyncdir not implemented by fs? */ + unsigned no_fsyncdir:1; + + /** Is flush not implemented by fs? */ + unsigned no_flush:1; + + /** Is setxattr not implemented by fs? */ + unsigned no_setxattr:1; + + /** Does file server support extended setxattr */ + unsigned setxattr_ext:1; + + /** Is getxattr not implemented by fs? */ + unsigned no_getxattr:1; + + /** Is listxattr not implemented by fs? */ + unsigned no_listxattr:1; + + /** Is removexattr not implemented by fs? */ + unsigned no_removexattr:1; + + /** Are posix file locking primitives not implemented by fs? */ + unsigned no_lock:1; + + /** Is access not implemented by fs? */ + unsigned no_access:1; + + /** Is create not implemented by fs? */ + unsigned no_create:1; + + /** Is interrupt not implemented by fs? */ + unsigned no_interrupt:1; + + /** Is bmap not implemented by fs? */ + unsigned no_bmap:1; + + /** Is poll not implemented by fs? */ + unsigned no_poll:1; + + /** Do multi-page cached writes */ + unsigned big_writes:1; + + /** Are BSD file locking primitives not implemented by fs? */ + unsigned no_flock:1; + + /** Is fallocate not implemented by fs? */ + unsigned no_fallocate:1; + + /** Is rename with flags implemented by fs? */ + unsigned no_rename2:1; + + /** Use enhanced/automatic page cache invalidation. */ + unsigned auto_inval_data:1; + + /** Filesystem is fully responsible for page cache invalidation. */ + unsigned explicit_inval_data:1; + + /** Does the filesystem support readdirplus? */ + unsigned do_readdirplus:1; + + /** Does the filesystem want adaptive readdirplus? */ + unsigned readdirplus_auto:1; + + /** Does the filesystem support asynchronous direct-IO submission? */ + unsigned async_dio:1; + + /** Is lseek not implemented by fs? */ + unsigned no_lseek:1; + + /** Does the filesystem support copy_file_range? */ + unsigned no_copy_file_range:1; +}; + /** * A Fuse connection. * @@ -641,30 +760,9 @@ struct fuse_conn { /** Connection successful. Only set in INIT */ unsigned conn_init:1; - /** Do readahead asynchronously? Only set in INIT */ - unsigned async_read:1; - /** Return an unique read error after abort. Only set in INIT */ unsigned abort_err:1; - /** Do not send separate SETATTR request before open(O_TRUNC) */ - unsigned atomic_o_trunc:1; - - /** Filesystem supports NFS exporting. Only set in INIT */ - unsigned export_support:1; - - /** write-back cache policy (default is write-through) */ - unsigned writeback_cache:1; - - /** allow parallel lookups and readdir (default is serialized) */ - unsigned parallel_dirops:1; - - /** handle fs handles killing suid/sgid/cap on write/chown/trunc */ - unsigned handle_killpriv:1; - - /** cache READLINK responses in page cache */ - unsigned cache_symlinks:1; - /* show legacy mount options */ unsigned int legacy_opts_show:1; @@ -676,92 +774,9 @@ struct fuse_conn { */ unsigned handle_killpriv_v2:1; - /* - * The following bitfields are only for optimization purposes - * and hence races in setting them will not cause malfunction - */ - - /** Is open/release not implemented by fs? */ - unsigned no_open:1; - - /** Is opendir/releasedir not implemented by fs? */ - unsigned no_opendir:1; - - /** Is fsync not implemented by fs? */ - unsigned no_fsync:1; - - /** Is fsyncdir not implemented by fs? */ - unsigned no_fsyncdir:1; - - /** Is flush not implemented by fs? */ - unsigned no_flush:1; - - /** Is setxattr not implemented by fs? */ - unsigned no_setxattr:1; - - /** Does file server support extended setxattr */ - unsigned setxattr_ext:1; - - /** Is getxattr not implemented by fs? */ - unsigned no_getxattr:1; - - /** Is listxattr not implemented by fs? */ - unsigned no_listxattr:1; - - /** Is removexattr not implemented by fs? */ - unsigned no_removexattr:1; - - /** Are posix file locking primitives not implemented by fs? */ - unsigned no_lock:1; - - /** Is access not implemented by fs? */ - unsigned no_access:1; - - /** Is create not implemented by fs? */ - unsigned no_create:1; - - /** Is interrupt not implemented by fs? */ - unsigned no_interrupt:1; - - /** Is bmap not implemented by fs? */ - unsigned no_bmap:1; - - /** Is poll not implemented by fs? */ - unsigned no_poll:1; - - /** Do multi-page cached writes */ - unsigned big_writes:1; - /** Don't apply umask to creation modes */ unsigned dont_mask:1; - /** Are BSD file locking primitives not implemented by fs? */ - unsigned no_flock:1; - - /** Is fallocate not implemented by fs? */ - unsigned no_fallocate:1; - - /** Is rename with flags implemented by fs? */ - unsigned no_rename2:1; - - /** Use enhanced/automatic page cache invalidation. */ - unsigned auto_inval_data:1; - - /** Filesystem is fully responsible for page cache invalidation. */ - unsigned explicit_inval_data:1; - - /** Does the filesystem support readdirplus? */ - unsigned do_readdirplus:1; - - /** Does the filesystem want adaptive readdirplus? */ - unsigned readdirplus_auto:1; - - /** Does the filesystem support asynchronous direct-IO submission? */ - unsigned async_dio:1; - - /** Is lseek not implemented by fs? */ - unsigned no_lseek:1; - /** Does the filesystem support posix acls? */ unsigned posix_acl:1; @@ -771,9 +786,6 @@ struct fuse_conn { /** Allow other than the mounter user to access the filesystem ? */ unsigned allow_other:1; - /** Does the filesystem support copy_file_range? */ - unsigned no_copy_file_range:1; - /* Send DESTROY request */ unsigned int destroy:1; @@ -804,6 +816,8 @@ struct fuse_conn { /* Is tmpfile not implemented by fs? */ unsigned int no_tmpfile:1; + struct fuse_conn_flags flags; + /** The number of requests waiting for completion */ atomic_t num_waiting; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index e5ad5d4c215a..389bea6e4a69 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -224,7 +224,7 @@ u32 fuse_get_cache_mask(struct inode *inode) { struct fuse_conn *fc = get_fuse_conn(inode); - if (!fc->writeback_cache || !S_ISREG(inode->i_mode)) + if (!fc->flags.writeback_cache || !S_ISREG(inode->i_mode)) return 0; return STATX_MTIME | STATX_CTIME | STATX_SIZE; @@ -282,9 +282,9 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, if (oldsize != attr->size) { truncate_pagecache(inode, attr->size); - if (!fc->explicit_inval_data) + if (!fc->flags.explicit_inval_data) inval = true; - } else if (fc->auto_inval_data) { + } else if (fc->flags.auto_inval_data) { struct timespec64 new_mtime = { .tv_sec = attr->mtime, .tv_nsec = attr->mtimensec, @@ -387,7 +387,7 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid, if ((inode->i_state & I_NEW)) { inode->i_flags |= S_NOATIME; - if (!fc->writeback_cache || !S_ISREG(attr->mode)) + if (!fc->flags.writeback_cache || !S_ISREG(attr->mode)) inode->i_flags |= S_NOCMTIME; inode->i_generation = generation; fuse_init_inode(inode, attr, fc); @@ -466,7 +466,7 @@ bool fuse_lock_inode(struct inode *inode) { bool locked = false; - if (!get_fuse_conn(inode)->parallel_dirops) { + if (!get_fuse_conn(inode)->flags.parallel_dirops) { mutex_lock(&get_fuse_inode(inode)->mutex); locked = true; } @@ -918,7 +918,7 @@ static struct dentry *fuse_get_dentry(struct super_block *sb, struct fuse_entry_out outarg; const struct qstr name = QSTR_INIT(".", 1); - if (!fc->export_support) + if (!fc->flags.export_support) goto out_err; err = fuse_lookup_name(sb, handle->nodeid, &name, &outarg, @@ -1018,7 +1018,7 @@ static struct dentry *fuse_get_parent(struct dentry *child) struct fuse_entry_out outarg; int err; - if (!fc->export_support) + if (!fc->flags.export_support) return ERR_PTR(-ESTALE); err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode), @@ -1134,44 +1134,44 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, ra_pages = arg->max_readahead / PAGE_SIZE; if (flags & FUSE_ASYNC_READ) - fc->async_read = 1; + fc->flags.async_read = 1; if (!(flags & FUSE_POSIX_LOCKS)) - fc->no_lock = 1; + fc->flags.no_lock = 1; if (arg->minor >= 17) { if (!(flags & FUSE_FLOCK_LOCKS)) - fc->no_flock = 1; + fc->flags.no_flock = 1; } else { if (!(flags & FUSE_POSIX_LOCKS)) - fc->no_flock = 1; + fc->flags.no_flock = 1; } if (flags & FUSE_ATOMIC_O_TRUNC) - fc->atomic_o_trunc = 1; + fc->flags.atomic_o_trunc = 1; if (arg->minor >= 9) { /* LOOKUP has dependency on proto version */ if (flags & FUSE_EXPORT_SUPPORT) - fc->export_support = 1; + fc->flags.export_support = 1; } if (flags & FUSE_BIG_WRITES) - fc->big_writes = 1; + fc->flags.big_writes = 1; if (flags & FUSE_DONT_MASK) fc->dont_mask = 1; if (flags & FUSE_AUTO_INVAL_DATA) - fc->auto_inval_data = 1; + fc->flags.auto_inval_data = 1; else if (flags & FUSE_EXPLICIT_INVAL_DATA) - fc->explicit_inval_data = 1; + fc->flags.explicit_inval_data = 1; if (flags & FUSE_DO_READDIRPLUS) { - fc->do_readdirplus = 1; + fc->flags.do_readdirplus = 1; if (flags & FUSE_READDIRPLUS_AUTO) - fc->readdirplus_auto = 1; + fc->flags.readdirplus_auto = 1; } if (flags & FUSE_ASYNC_DIO) - fc->async_dio = 1; + fc->flags.async_dio = 1; if (flags & FUSE_WRITEBACK_CACHE) - fc->writeback_cache = 1; + fc->flags.writeback_cache = 1; if (flags & FUSE_PARALLEL_DIROPS) - fc->parallel_dirops = 1; + fc->flags.parallel_dirops = 1; if (flags & FUSE_HANDLE_KILLPRIV) - fc->handle_killpriv = 1; + fc->flags.handle_killpriv = 1; if (arg->time_gran && arg->time_gran <= 1000000000) fm->sb->s_time_gran = arg->time_gran; if ((flags & FUSE_POSIX_ACL)) { @@ -1179,7 +1179,7 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, fc->posix_acl = 1; } if (flags & FUSE_CACHE_SYMLINKS) - fc->cache_symlinks = 1; + fc->flags.cache_symlinks = 1; if (flags & FUSE_ABORT_ERROR) fc->abort_err = 1; if (flags & FUSE_MAX_PAGES) { @@ -1200,15 +1200,15 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, fm->sb->s_flags |= SB_NOSEC; } if (flags & FUSE_SETXATTR_EXT) - fc->setxattr_ext = 1; + fc->flags.setxattr_ext = 1; if (flags & FUSE_SECURITY_CTX) fc->init_security = 1; if (flags & FUSE_CREATE_SUPP_GROUP) fc->create_supp_group = 1; } else { ra_pages = fc->max_read / PAGE_SIZE; - fc->no_lock = 1; - fc->no_flock = 1; + fc->flags.no_lock = 1; + fc->flags.no_flock = 1; } fm->sb->s_bdi->ra_pages = diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index dc603479b30e..2a5bfb52ebf3 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -18,9 +18,9 @@ static bool fuse_use_readdirplus(struct inode *dir, struct dir_context *ctx) struct fuse_conn *fc = get_fuse_conn(dir); struct fuse_inode *fi = get_fuse_inode(dir); - if (!fc->do_readdirplus) + if (!fc->flags.do_readdirplus) return false; - if (!fc->readdirplus_auto) + if (!fc->flags.readdirplus_auto) return true; if (test_and_clear_bit(FUSE_I_ADVISE_RDPLUS, &fi->state)) return true; @@ -246,7 +246,7 @@ static int fuse_direntplus_link(struct file *file, if (IS_ERR(dentry)) return PTR_ERR(dentry); } - if (fc->readdirplus_auto) + if (fc->flags.readdirplus_auto) set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state); fuse_change_entry_timeout(dentry, o); @@ -455,7 +455,7 @@ static int fuse_readdir_cached(struct file *file, struct dir_context *ctx) * We're just about to start reading into the cache or reading the * cache; both cases require an up-to-date mtime value. */ - if (!ctx->pos && fc->auto_inval_data) { + if (!ctx->pos && fc->flags.auto_inval_data) { int err = fuse_update_attributes(inode, file, STATX_MTIME); if (err) diff --git a/fs/fuse/xattr.c b/fs/fuse/xattr.c index 49c01559580f..5d8603f9c355 100644 --- a/fs/fuse/xattr.c +++ b/fs/fuse/xattr.c @@ -19,7 +19,7 @@ int fuse_setxattr(struct inode *inode, const char *name, const void *value, struct fuse_setxattr_in inarg; int err; - if (fm->fc->no_setxattr) + if (fm->fc->flags.no_setxattr) return -EOPNOTSUPP; memset(&inarg, 0, sizeof(inarg)); @@ -30,7 +30,7 @@ int fuse_setxattr(struct inode *inode, const char *name, const void *value, args.opcode = FUSE_SETXATTR; args.nodeid = get_node_id(inode); args.in_numargs = 3; - args.in_args[0].size = fm->fc->setxattr_ext ? + args.in_args[0].size = fm->fc->flags.setxattr_ext ? sizeof(inarg) : FUSE_COMPAT_SETXATTR_IN_SIZE; args.in_args[0].value = &inarg; args.in_args[1].size = strlen(name) + 1; @@ -39,7 +39,7 @@ int fuse_setxattr(struct inode *inode, const char *name, const void *value, args.in_args[2].value = value; err = fuse_simple_request(fm, &args); if (err == -ENOSYS) { - fm->fc->no_setxattr = 1; + fm->fc->flags.no_setxattr = 1; err = -EOPNOTSUPP; } if (!err) @@ -57,7 +57,7 @@ ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value, struct fuse_getxattr_out outarg; ssize_t ret; - if (fm->fc->no_getxattr) + if (fm->fc->flags.no_getxattr) return -EOPNOTSUPP; memset(&inarg, 0, sizeof(inarg)); @@ -83,7 +83,7 @@ ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value, if (!ret && !size) ret = min_t(ssize_t, outarg.size, XATTR_SIZE_MAX); if (ret == -ENOSYS) { - fm->fc->no_getxattr = 1; + fm->fc->flags.no_getxattr = 1; ret = -EOPNOTSUPP; } return ret; @@ -121,7 +121,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) if (!fuse_allow_current_process(fm->fc)) return -EACCES; - if (fm->fc->no_listxattr) + if (fm->fc->flags.no_listxattr) return -EOPNOTSUPP; memset(&inarg, 0, sizeof(inarg)); @@ -147,7 +147,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) if (ret > 0 && size) ret = fuse_verify_xattr_list(list, ret); if (ret == -ENOSYS) { - fm->fc->no_listxattr = 1; + fm->fc->flags.no_listxattr = 1; ret = -EOPNOTSUPP; } return ret; @@ -159,7 +159,7 @@ int fuse_removexattr(struct inode *inode, const char *name) FUSE_ARGS(args); int err; - if (fm->fc->no_removexattr) + if (fm->fc->flags.no_removexattr) return -EOPNOTSUPP; args.opcode = FUSE_REMOVEXATTR; @@ -169,7 +169,7 @@ int fuse_removexattr(struct inode *inode, const char *name) args.in_args[0].value = name; err = fuse_simple_request(fm, &args); if (err == -ENOSYS) { - fm->fc->no_removexattr = 1; + fm->fc->flags.no_removexattr = 1; err = -EOPNOTSUPP; } if (!err) From patchwork Mon Apr 3 14:45:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2373002vqo; Mon, 3 Apr 2023 08:09:29 -0700 (PDT) X-Google-Smtp-Source: AKy350adSzttySOWs7mlriJYOOSlpkawHRy5udGqJ5gtEeHr1EP1sXrTIuc80HTiJ+zRkeaoNR8y X-Received: by 2002:a17:90a:5105:b0:234:a88e:d67e with SMTP id t5-20020a17090a510500b00234a88ed67emr40886109pjh.34.1680534568941; Mon, 03 Apr 2023 08:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680534568; cv=none; d=google.com; s=arc-20160816; b=jq4cIzpcL2Q+i/s/8AmATTU6CZrcIZLUk2EjqUaI49+7vxsTOSs8IdbPhP7QFmz2Rw FoSUyKYT5e0HIsDSBh4j9GRv42CX5zmFBtqa4kMylF9n0opwYdICvVMwo72XaI4/ak2F 4xWwOVqdbfAGzORsY9ZT6vAOP27y1f/yLfYXCMQLR31FFvgIT1MajWVdhCpX73tnC3oV RA47+60pVU7hFHEZks695PifEEYiuZxohfYMMrRS/EQCR8UlF4Brbw6EQlEjlH38M6Ps sHkp1MAnuSdADqiuZ98Y4q0taHIOkR2u46UXBcYMytjf+KV1HrrxvB2RNXhjcmU06yhj cQvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Lg0DTuk088FU5MRineNk5kP+9dFQFrGExo9YX6St3wI=; b=eK3L7bRIUfrnt2nXtybvSfDHLze49CJeGL1bRswfvg9LzDc0NrLpjv7N6vkS8IhIkP zICXWMBoBsnTGWs+K61K0Huzz6pe7lgvkAhyEhDbZOx2rklz13S5n6jfmxlmCH8dcFob ycPwm4QrlJQIexaAVC71rSO+RqiLTiTg3i9lvyQER956qrxEOJuN6oh3pkkBjENCaWMg sFN/EFUyjGhwLTGdn/it83Auxo0+JMiDei1cCB+DUqKEAM9+6KdfNKiZSDz55JQSdPtw GgFJan28nQN9V/ghW/zwSEJlFlcsSZAOJckfZFHhy75PWolYS1cljpY16W9dTk+ct6dW J2Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=FYjtv+G8; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk10-20020a17090b33ca00b00233b40ad95dsi8273495pjb.177.2023.04.03.08.09.16; Mon, 03 Apr 2023 08:09:28 -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=@canonical.com header.s=20210705 header.b=FYjtv+G8; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233999AbjDCOqv (ORCPT + 99 others); Mon, 3 Apr 2023 10:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234015AbjDCOqf (ORCPT ); Mon, 3 Apr 2023 10:46:35 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A3F3503C for ; Mon, 3 Apr 2023 07:46:18 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id A5DAB3F855 for ; Mon, 3 Apr 2023 14:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533145; bh=Lg0DTuk088FU5MRineNk5kP+9dFQFrGExo9YX6St3wI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=FYjtv+G8Z7RtbLghHZjhsQYgNo+31Ay7F2e+mURsYInPgE9643OAym4SOVt8v6Llu O0G8IKgHPDu/wEWnA2i1AAc3mJlpLPcvC5KytlR8IKfmxPCeuSdvOPzpyLhg4RflLH mZLJXvxQYegS7S6PsytEAX+/B8HH4ePnb+6s5wOrvOJBIFoPT4r2G18MUe2vTXt9Au rZMv9/lMEi9nPZ8icW+kT+y4dO0wV6PormQWSpLbwuWj24xaS+QT1I1LGXez7M4UKb 4k5AjDW3o5Re5yMffPw4fZk0Pgw3bR1hziP2bQ9NjltjcXKAVKiQZgNQhVu+VpIlJW MK2IGjBQ+z6UQ== Received: by mail-ed1-f70.google.com with SMTP id m18-20020a50d7d2000000b00501dfd867a4so41940087edj.20 for ; Mon, 03 Apr 2023 07:45:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533145; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lg0DTuk088FU5MRineNk5kP+9dFQFrGExo9YX6St3wI=; b=o4n9I2XuGkXV31ckQcCbv4IuYgqvmFoW0wNvYwPQBB5LA2PsUvyIRuOxnKjsBROQQb MFs6MA1o2Kg6L0r2nLMrjxJD9ajeXHIC/6Wrdiqq5gDiAv7FT3A3apef6VVt335Cdmb+ QjZ8Y0m8RlFEvW3e/25D7WaVpnxGgO0VMLJZayXeaDCsE5w/VhBcyf5BmEGM+HSckwNT cBWWWfAirfxVg83ggkXndfA4FeIiZWu0TuWOC5GQcUO9DbpdrQnlaW4s1WJPO8WBpXBV 51lQqGwWYCLKxqPKlZX0mkHUVNjWuHwS5V+wzyNCVAz3EpnKlrnv9EgLA+E2M1CqfXhR coVA== X-Gm-Message-State: AAQBX9dXkIl1p4g0ms4zGz7bef9jBooDix/w2Nb409dJ+HiIlBfrlC9m iFOxxVQOA69mRQZ5nWP2XMCJybj0iwqTKwR+EQoSZlw4MVMmdxrECfqze2cYgDOkuCfuDN/PUy8 AxG7MAeT8fZ8ojlnanOl4a1ZECpuubdl09DjfRhiTHQ== X-Received: by 2002:a05:6402:1356:b0:4fb:1c02:8750 with SMTP id y22-20020a056402135600b004fb1c028750mr36144457edw.23.1680533145465; Mon, 03 Apr 2023 07:45:45 -0700 (PDT) X-Received: by 2002:a05:6402:1356:b0:4fb:1c02:8750 with SMTP id y22-20020a056402135600b004fb1c028750mr36144442edw.23.1680533145306; Mon, 03 Apr 2023 07:45:45 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:44 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 6/9] fuse: take fuse connection generation into account Date: Mon, 3 Apr 2023 16:45:14 +0200 Message-Id: <20230403144517.347517-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762168215684862809?= X-GMAIL-MSGID: =?utf-8?q?1762168215684862809?= - modify dentry revalidation algorithm to check inode/connection generations. If them are not equal then perform revalidation. remark: during forced dentry revalidation we are sending FUSE_LOOKUP request to the userspace daemon and if it return the same inode after lookup then we can "upgrade" inode connection generation without invalidating it. - don't send FUSE_FSYNC, FUSE_RELEASE, etc requests to the userspace daemon about stale inodes (this can confuse libfuse) Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dir.c | 4 +++- fs/fuse/file.c | 13 ++++++++++--- fs/fuse/fuse_i.h | 3 ++- fs/fuse/inode.c | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index bfbe59e8fce2..d0fdf7289d56 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -213,7 +213,8 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) inode = d_inode_rcu(entry); if (inode && fuse_is_bad(inode)) goto invalid; - else if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) || + else if ((inode && fuse_stale_inode_conn(inode)) || + time_before64(fuse_dentry_time(entry), get_jiffies_64()) || (flags & (LOOKUP_EXCL | LOOKUP_REVAL | LOOKUP_RENAME_TARGET))) { struct fuse_entry_out outarg; FUSE_ARGS(args); @@ -255,6 +256,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) } spin_lock(&fi->lock); fi->nlookup++; + fi->conn_gen = READ_ONCE(get_fuse_conn(inode)->conn_gen); spin_unlock(&fi->lock); } kfree(forget); diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 742f90b4e638..b977d087b925 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -111,8 +111,14 @@ static void fuse_file_put(struct fuse_file *ff, bool sync, bool isdir) if (refcount_dec_and_test(&ff->count)) { struct fuse_args *args = &ff->release_args->args; - if (isdir ? ff->fm->fc->flags.no_opendir : ff->fm->fc->flags.no_open) { - /* Do nothing when client does not implement 'open' */ + if (fuse_stale_ff(ff) || + (isdir ? ff->fm->fc->flags.no_opendir : ff->fm->fc->flags.no_open)) { + /* + * Do nothing when client does not implement 'open' OR + * file descriptor was opened in the previous connection generation, + * so, current daemon likely not aware of this FD, let's just skip + * FUSE_RELEASE(DIR) request. + */ fuse_release_end(ff->fm, args, 0); } else if (sync) { fuse_simple_request(ff->fm, args); @@ -598,9 +604,10 @@ static int fuse_fsync(struct file *file, loff_t start, loff_t end, { struct inode *inode = file->f_mapping->host; struct fuse_conn *fc = get_fuse_conn(inode); + struct fuse_file *ff = file->private_data; int err; - if (fuse_is_bad(inode)) + if (fuse_stale_ff(ff) || fuse_is_bad(inode)) return -EIO; inode_lock(inode); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 943d5011dfa0..90c5b3459864 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -957,7 +957,8 @@ static inline bool fuse_stale_inode(const struct inode *inode, int generation, struct fuse_attr *attr) { return inode->i_generation != generation || - inode_wrong_type(inode, attr->mode); + inode_wrong_type(inode, attr->mode) || + fuse_stale_inode_conn(inode); } static inline void fuse_make_bad(struct inode *inode) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 389bea6e4a69..26a4149f6db7 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -124,7 +124,7 @@ static void fuse_evict_inode(struct inode *inode) fuse_dax_inode_cleanup(inode); if (fi->nlookup) { fuse_queue_forget(fc, fi->forget, fi->nodeid, - fi->nlookup, false); + fi->nlookup, fuse_stale_inode_conn(inode)); fi->forget = NULL; } } From patchwork Mon Apr 3 14:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2381802vqo; Mon, 3 Apr 2023 08:21:01 -0700 (PDT) X-Google-Smtp-Source: AKy350bArGXdddZa1PNoCpJrwuPKPG65qOV+6KsmiE/RF00M+ck0P8lKy7KZH4I3Tyh7VBU2xjx5 X-Received: by 2002:aa7:9424:0:b0:626:1c2a:2805 with SMTP id y4-20020aa79424000000b006261c2a2805mr33972806pfo.25.1680535260760; Mon, 03 Apr 2023 08:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680535260; cv=none; d=google.com; s=arc-20160816; b=EUIvrMmvD+nrmfKbOdLu2eSEJXFivl4o9B5zQIAXU1JZbXYDdloE4phfl9cQ7nOxom Fxu76Tl71C2JF9XqKmSLnXHMn4pkl7NTET/XiZlXuVNZYAByhLIBhqhiHdPI3ZRBcDJi YBovQlT6kImh29++FfjRa6rPq2Ep1rV+FR1PSO7W5Tpz+2C0DWqn3g8QXLxhHB14Ixel W6Xs0LWLk7b6Wlrw+b0xAPGMvjLmGGIsl/aP6MhlaIqKCJf+rz0BPqblw6JGuA2MUj/q 3CXZ8wyCshMnMtR5tH7/Wk2cIQvMWKQ4yf9MpmJCRFiiCLdw62gCQG0BenmwJv3rqi8a S49A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N1lNLcfnab/Xak3vE1BXdEngtUghqVUaWAQgAOaQ90I=; b=PhDb71YDYWgdD+Rb2XjVndLAxvIW+bKQn6PNx/PANXY39mNejKlmleRtKpe0hxbgrC A00CtZeZXh7Z1V4xrDNiehovmf+yhwZ8pFWT6+lhkwpxZV3Qdz1khK5xLfFZ3ZFD8iQu E7IEzxE+lhrJhxBGK5u4zUk0BVEalLfuPi2J/aQCMWSVwxUuSWRJli4M73RYEBAaTqoK pahbOBXd+xfIAMVWLeWD9moxAFyC3z/q08NtxjkyL29mYvPCBq+k9hfGiMZwFAzu1cBY P/tLcOP38LJu7CwuXlGbWCcLyaG3uwYL88VcjJeWinbYqs5ckOzv3vSvcLWRxsUXh6dT smIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=plq84R7Z; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t185-20020a6381c2000000b00513237b6b61si8439617pgd.562.2023.04.03.08.20.45; Mon, 03 Apr 2023 08:21:00 -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=@canonical.com header.s=20210705 header.b=plq84R7Z; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234133AbjDCOrq (ORCPT + 99 others); Mon, 3 Apr 2023 10:47:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234063AbjDCOrX (ORCPT ); Mon, 3 Apr 2023 10:47:23 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 224CD28EAE for ; Mon, 3 Apr 2023 07:46:43 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id EA9873F246 for ; Mon, 3 Apr 2023 14:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533148; bh=N1lNLcfnab/Xak3vE1BXdEngtUghqVUaWAQgAOaQ90I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=plq84R7Z9jKFbIRv8EFmGTOulD5ur48J4seBXMRPakcSxy97onxVI2xse4tzpet8u 7HR2+Nh8jSnNutWb+z8XD5d/nDDUyTYYkEjUIcdW0X8N57cHYp42ChVtqXXpspSaBj 7rsZDhThH6jfe/r5O6AuFNGogtM9yPPHSwUhPMURgh0vu1VrnAUxLyuRU7wjbtKjtB ync77zd/Am1CBtIuyqj4FnVz9OQeX7alutCXIu945gdthH5Y1wX7mPtfJio7VAWCPL Uz/g0KE2pDDAXHkeuTA2G/YVNv7rLD3+hPWA10Fge8o1m39yitJ0lod6LR2E8Vm6fO KUYQXtIVOUOFQ== Received: by mail-ed1-f72.google.com with SMTP id a40-20020a509eab000000b005024c025bf4so29334093edf.14 for ; Mon, 03 Apr 2023 07:45:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N1lNLcfnab/Xak3vE1BXdEngtUghqVUaWAQgAOaQ90I=; b=u4KQ6S0DWD7WrTXdeoU31PQWidmcjPphS+GtyH6ALH3aLz+cldx60h+fwRc5XPqx/p Vz0S5BIqSs94CDlrVp1f2LnchVt06WKuZxH27+Y9tIW8/x7s2Cq520pZarNrANV/HKzM 9gpjOG6+dHw3ZrzfNZj7GyV5E8ZChs0Z8NNjim62HaZJTx5h/HkCuwx099U6wdJV81JX N+F0ENr5eBVy8ZbGSrb3LXVRWJMN+JOJpObiI+E5bnXGNTzdoZRTzEF+ohsRqiYpPYA5 2x8bhok1hVN/90TwgfDxKSj2Dy/oP4DjTjkzDpQd0Ide9LvcmZCff/EhpPcjE4djeua0 kvyw== X-Gm-Message-State: AAQBX9ckwN+SYcnN1fNdtoXxb0fxCzJAWgnsPQ3NTfu+PcE5KtswiAZh ei68OxTA+hsHR5vQkpV2o4L3CRJiK+RCbM5D7rNW7oBd6kj3PBUHNdxkO5hIcEd0/oD/pMY8oS5 QlUSIH6sPWKZGxw5TMHVeGXzBxuCMA6r5kpFmrrubGQ== X-Received: by 2002:a17:907:d487:b0:93f:fbe:c388 with SMTP id vj7-20020a170907d48700b0093f0fbec388mr34735174ejc.27.1680533147536; Mon, 03 Apr 2023 07:45:47 -0700 (PDT) X-Received: by 2002:a17:907:d487:b0:93f:fbe:c388 with SMTP id vj7-20020a170907d48700b0093f0fbec388mr34735154ejc.27.1680533147248; Mon, 03 Apr 2023 07:45:47 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:46 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 7/9] fuse: add fuse device ioctl(FUSE_DEV_IOC_REINIT) Date: Mon, 3 Apr 2023 16:45:15 +0200 Message-Id: <20230403144517.347517-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762168941890192150?= X-GMAIL-MSGID: =?utf-8?q?1762168941890192150?= This ioctl aborts fuse connection and then reinitializes it, sends FUSE_INIT request to allow a new userspace daemon to pick up the fuse connection. Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dev.c | 152 ++++++++++++++++++++++++++++++++++++++ fs/fuse/fuse_i.h | 3 + include/uapi/linux/fuse.h | 1 + 3 files changed, 156 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index b4501a10c379..93a457c90b49 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2187,6 +2187,132 @@ void fuse_abort_conn(struct fuse_conn *fc) } EXPORT_SYMBOL_GPL(fuse_abort_conn); +static int fuse_reinit_conn(struct fuse_conn *fc) +{ + struct fuse_iqueue *fiq = &fc->iq; + struct fuse_dev *fud; + unsigned int i; + + spin_lock(&fc->lock); + if (fc->reinit_in_progress) { + spin_unlock(&fc->lock); + return -EBUSY; + } + + if (fc->conn_gen + 1 < fc->conn_gen) { + spin_unlock(&fc->lock); + return -EOVERFLOW; + } + + fc->reinit_in_progress = true; + spin_unlock(&fc->lock); + + /* + * Unsets fc->connected and fiq->connected and + * ensures that no new requests can be queued + */ + fuse_abort_conn(fc); + fuse_wait_aborted(fc); + + spin_lock(&fc->lock); + if (fc->connected) { + fc->reinit_in_progress = false; + spin_unlock(&fc->lock); + return -EINVAL; + } + + fc->conn_gen++; + + spin_lock(&fiq->lock); + if (request_pending(fiq) || fiq->forget_list_tail != &fiq->forget_list_head) { + spin_unlock(&fiq->lock); + fc->reinit_in_progress = false; + spin_unlock(&fc->lock); + return -EINVAL; + } + + if (&fuse_dev_fiq_ops != fiq->ops) { + spin_unlock(&fiq->lock); + fc->reinit_in_progress = false; + spin_unlock(&fc->lock); + return -EOPNOTSUPP; + } + + fiq->connected = 1; + spin_unlock(&fiq->lock); + + spin_lock(&fc->bg_lock); + if (!list_empty(&fc->bg_queue)) { + spin_unlock(&fc->bg_lock); + fc->reinit_in_progress = false; + spin_unlock(&fc->lock); + return -EINVAL; + } + + fc->blocked = 0; + fc->max_background = FUSE_DEFAULT_MAX_BACKGROUND; + spin_unlock(&fc->bg_lock); + + list_for_each_entry(fud, &fc->devices, entry) { + struct fuse_pqueue *fpq = &fud->pq; + + spin_lock(&fpq->lock); + if (!list_empty(&fpq->io)) { + spin_unlock(&fpq->lock); + fc->reinit_in_progress = false; + spin_unlock(&fc->lock); + return -EINVAL; + } + + for (i = 0; i < FUSE_PQ_HASH_SIZE; i++) { + if (!list_empty(&fpq->processing[i])) { + spin_unlock(&fpq->lock); + fc->reinit_in_progress = false; + spin_unlock(&fc->lock); + return -EINVAL; + } + } + + fpq->connected = 1; + spin_unlock(&fpq->lock); + } + + fuse_set_initialized(fc); + + /* Background queuing checks fc->connected under bg_lock */ + spin_lock(&fc->bg_lock); + fc->connected = 1; + spin_unlock(&fc->bg_lock); + + fc->aborted = false; + fc->abort_err = 0; + + /* nullify all the flags */ + memset(&fc->flags, 0, sizeof(struct fuse_conn_flags)); + + spin_unlock(&fc->lock); + + down_read(&fc->killsb); + if (!list_empty(&fc->mounts)) { + struct fuse_mount *fm; + + fm = list_first_entry(&fc->mounts, struct fuse_mount, fc_entry); + if (!fm->sb) { + up_read(&fc->killsb); + return -EINVAL; + } + + fuse_send_init(fm); + } + up_read(&fc->killsb); + + spin_lock(&fc->lock); + fc->reinit_in_progress = false; + spin_unlock(&fc->lock); + + return 0; +} + void fuse_wait_aborted(struct fuse_conn *fc) { /* matches implicit memory barrier in fuse_drop_waiting() */ @@ -2282,6 +2408,32 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, } } break; + case FUSE_DEV_IOC_REINIT: + struct fuse_conn *fc; + + if (!checkpoint_restore_ns_capable(file->f_cred->user_ns)) + return -EPERM; + + res = -EINVAL; + fud = fuse_get_dev(file); + + /* + * Only fuse mounts with an already initialized fuse + * connection are supported + */ + if (file->f_op == &fuse_dev_operations && fud) { + mutex_lock(&fuse_mutex); + fc = fud->fc; + if (fc) + fc = fuse_conn_get(fc); + mutex_unlock(&fuse_mutex); + + if (fc) { + res = fuse_reinit_conn(fc); + fuse_conn_put(fc); + } + } + break; default: res = -ENOTTY; break; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 90c5b3459864..8f2c0f969f6f 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -752,6 +752,9 @@ struct fuse_conn { /** Connection aborted via sysfs */ bool aborted; + /** Connection reinit in progress */ + bool reinit_in_progress; + /** Connection failed (version mismatch). Cannot race with setting other bitfields since it is only set once in INIT reply, before any other request, and never cleared */ diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index b3fcab13fcd3..325da23431ef 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -992,6 +992,7 @@ struct fuse_notify_retrieve_in { /* Device ioctls: */ #define FUSE_DEV_IOC_MAGIC 229 #define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t) +#define FUSE_DEV_IOC_REINIT _IO(FUSE_DEV_IOC_MAGIC, 0) struct fuse_lseek_in { uint64_t fh; From patchwork Mon Apr 3 14:45:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78590 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2382945vqo; Mon, 3 Apr 2023 08:22:43 -0700 (PDT) X-Google-Smtp-Source: AKy350YDUKpICEuTrk8PlVcyBd5fumE7gKrebvQOmJACeQJMev+9Sd3n3lncs65FH7/R7UVprUVc X-Received: by 2002:a17:90a:3e46:b0:237:2edb:d4e3 with SMTP id t6-20020a17090a3e4600b002372edbd4e3mr43035138pjm.27.1680535362992; Mon, 03 Apr 2023 08:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680535362; cv=none; d=google.com; s=arc-20160816; b=VrMVSXnVf0o/npsgj8kugabAV0iHTRU1e3TQoN04b6EDTbKZr3kjTCFUQPem8i8txU rktTAm99bPu8iE9XTXE9YURrEr+OoNmq0jMoSG5bA3PHIVj2CUpaLM+a6HyOIRiwqz2h 0fEW6dR9vt6/NX0BtzYqv1Vi8npkusL+Lc6/UznNgz+u75qj3rJaIJ1wt5EKal9i5Scb CvYf7Q/d2iDFd8lHr2KDAUV5WPMuOhrrAfhLJ6aZWgWnRZVldvB4xGUHTr733lD/2CUL MdTjFY9jXmA/mKpuhclZzSLArwpSICvzLAGfje32fRJF6A0kVXcAaS9AgGOfFiaCMXKK DO2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CML0MX+E6RHRMEZDuKLkjuHXCZn0KNZeg1m8eYp9u4Q=; b=iEWKAdUCfYRvnTOOGyYb3yjTQ76Mfy972nTDaY1yiGrmm9qDkgLF9+ChJCMKOkYBxK t5RkHQtTN7/9uv3021bunj/TDowidd/hzv8DoecTrReJbq2smUAblXQHRqWWzuNfc2Tc Wt2skcfMaJQ0bJKkUV9wdDv6jE4fiUFl9vgMtti87IkibfePuUWegK9RhKxatFxA4JIl q6F/Cv+H0QrtaFDele4JIQauediGmrCzEHiRvheUx3Ajh5/hQ+1+C7U3mrIwXKeuGcNs 0/xAToCm+as+eshLI8j3xUlu5AiJhM71Os6kFZIh+qbH/TCmkDTqzUDW8Fp25q13qVG2 LmaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=b7OYEYkG; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a170902da8200b001a296d607d9si8679525plx.561.2023.04.03.08.22.31; Mon, 03 Apr 2023 08:22:42 -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=@canonical.com header.s=20210705 header.b=b7OYEYkG; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234017AbjDCOro (ORCPT + 99 others); Mon, 3 Apr 2023 10:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234060AbjDCOrV (ORCPT ); Mon, 3 Apr 2023 10:47:21 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1CBE29BE2 for ; Mon, 3 Apr 2023 07:46:42 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 4F6233F57D for ; Mon, 3 Apr 2023 14:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533150; bh=CML0MX+E6RHRMEZDuKLkjuHXCZn0KNZeg1m8eYp9u4Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=b7OYEYkG1Xf77jtOGLCV/1MDNd/skiChtKPzO0+m/hc2hjPKjb64I7fmXOg7UtNGX GXBuuFIo4Rj6BVIt1IhYkCkFY4n6SeTwLiJmyn+zxtw5rEkZJ5mlwrxGTQkjRnFO74 4Jrz/BQWKXE9eI7PfvEBT9ZMM3IO1vG1FcD8sXyUIcG4z85Zr8FmB4rtB/10d9vgzg DivbyFHxmG6bn4DlGHX/qHV/yrm4aOMpYfj5IPIkvnjFQQ/x+b8uvsnByF0SKpr6MC eNym/Ed/5dWC2zl94otk5Y2LM67Khy7MiT0yMxdQp5Z/484f7Ccajgtpvehr4mmgfu qFIvWYpvyXWSQ== Received: by mail-ed1-f71.google.com with SMTP id v1-20020a50d581000000b0050291cda08aso7957470edi.15 for ; Mon, 03 Apr 2023 07:45:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533149; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CML0MX+E6RHRMEZDuKLkjuHXCZn0KNZeg1m8eYp9u4Q=; b=QK9sN9hTUIeEt/clzcntwWd/aFPekw5v8FQrk05d9el8MEQn6+Pr/7ZllNKNvUKYbx FQwuZRJTieaoZw/aD1R/BwnZe/I57/nrf5oR4hXExVf/flqHAbSSK47fDI+rWRSoyo5n Yxfk3dOirC9myscJ0awjTpt7cHdLwq00uU5NdEAs2VKd8uRMoOwRy5rO40COcmikSeGX 9yN7PbI08PQTSjWvHTro7eRTlVWTbiSXr3Sxl3wJzStsfIxm+ChOCN5dh7if2MBIaHD8 PWlT8v27q5gi0LI/FCtLZZoUDMyXHH2xS9uUhKRA+GM0bRV0m1cLT0EfNPs3GH1WuNS1 yyZQ== X-Gm-Message-State: AAQBX9f4A2fiPxkTFe0zJdhOmH6hWfzKYxkcTYv27ONAhmmLb594GDy/ vpJvX3L68clXMKBJdcwiYonp9wkX8L77Cs+Cmy00PCBh63v7KI1cPE8n1d/WoNaOZMdy457l2yP GoNDFC1rPhrilg0UYdQ+huiLpfMmslMzLZWEKZA6sJA== X-Received: by 2002:a05:6402:215:b0:502:9c52:447f with SMTP id t21-20020a056402021500b005029c52447fmr4105688edv.17.1680533148976; Mon, 03 Apr 2023 07:45:48 -0700 (PDT) X-Received: by 2002:a05:6402:215:b0:502:9c52:447f with SMTP id t21-20020a056402021500b005029c52447fmr4105680edv.17.1680533148816; Mon, 03 Apr 2023 07:45:48 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:48 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 8/9] namespace: add sb_revalidate_bindmounts helper Date: Mon, 3 Apr 2023 16:45:16 +0200 Message-Id: <20230403144517.347517-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762169048337772427?= X-GMAIL-MSGID: =?utf-8?q?1762169048337772427?= Useful if for some reason bindmounts root dentries get invalidated but it's needed to revalidate existing bindmounts without remounting. Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/namespace.c | 90 +++++++++++++++++++++++++++++++++++ include/linux/mnt_namespace.h | 3 ++ 2 files changed, 93 insertions(+) diff --git a/fs/namespace.c b/fs/namespace.c index bc0f15257b49..b74d00d6abb0 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -568,6 +568,96 @@ static int mnt_make_readonly(struct mount *mnt) return ret; } +struct bind_mount_list_item { + struct list_head list; + struct vfsmount *mnt; +}; + +/* + * sb_revalidate_bindmounts - Relookup/reset bindmounts root dentries + * + * Useful if for some reason bindmount root dentries get invalidated + * but it's needed to revalidate existing bindmounts without remounting. + */ +int sb_revalidate_bindmounts(struct super_block *sb) +{ + struct mount *mnt; + struct bind_mount_list_item *bmnt, *next; + int err = 0; + struct vfsmount *root_mnt = NULL; + LIST_HEAD(mnt_to_update); + char *buf; + + buf = (char *) __get_free_page(GFP_KERNEL); + if (!buf) + return -ENOMEM; + + lock_mount_hash(); + list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) { + /* we only want to touch bindmounts */ + if (mnt->mnt.mnt_root == sb->s_root) { + if (!root_mnt) + root_mnt = mntget(&mnt->mnt); + + continue; + } + + bmnt = kzalloc(sizeof(struct bind_mount_list_item), GFP_NOWAIT | __GFP_NOWARN); + if (!bmnt) { + err = -ENOMEM; + goto exit; + } + + bmnt->mnt = mntget(&mnt->mnt); + list_add_tail(&bmnt->list, &mnt_to_update); + } + unlock_mount_hash(); + + /* TODO: get rid of this limitation */ + if (!root_mnt) { + err = -ENOENT; + goto exit; + } + + list_for_each_entry_safe(bmnt, next, &mnt_to_update, list) { + struct vfsmount *cur_mnt = bmnt->mnt; + struct path path; + struct dentry *old_root; + char *p; + + p = dentry_path(cur_mnt->mnt_root, buf, PAGE_SIZE); + if (IS_ERR(p)) + goto exit; + + /* TODO: are these lookup flags fully safe and correct? */ + err = vfs_path_lookup(root_mnt->mnt_root, root_mnt, + p, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT|LOOKUP_REVAL, &path); + if (err) + goto exit; + + /* replace bindmount root dentry */ + lock_mount_hash(); + old_root = cur_mnt->mnt_root; + cur_mnt->mnt_root = dget(path.dentry); + dput(old_root); + unlock_mount_hash(); + + path_put(&path); + } + +exit: + free_page((unsigned long) buf); + mntput(root_mnt); + list_for_each_entry_safe(bmnt, next, &mnt_to_update, list) { + list_del(&bmnt->list); + mntput(bmnt->mnt); + kfree(bmnt); + } + + return err; +} +EXPORT_SYMBOL_GPL(sb_revalidate_bindmounts); + int sb_prepare_remount_readonly(struct super_block *sb) { struct mount *mnt; diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h index 8f882f5881e8..20ac29e702f5 100644 --- a/include/linux/mnt_namespace.h +++ b/include/linux/mnt_namespace.h @@ -3,6 +3,7 @@ #define _NAMESPACE_H_ #ifdef __KERNEL__ +struct super_block; struct mnt_namespace; struct fs_struct; struct user_namespace; @@ -13,6 +14,8 @@ extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, extern void put_mnt_ns(struct mnt_namespace *ns); extern struct ns_common *from_mnt_ns(struct mnt_namespace *); +extern int sb_revalidate_bindmounts(struct super_block *sb); + extern const struct file_operations proc_mounts_operations; extern const struct file_operations proc_mountinfo_operations; extern const struct file_operations proc_mountstats_operations; From patchwork Mon Apr 3 14:45:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 78580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2378328vqo; Mon, 3 Apr 2023 08:16:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Zkl8hNku8iLxN5kYuyVf400OwOIMK9RyfHn10fvJQ36hJOOf7O9X0a+PLUSF2d2lPdW3T0 X-Received: by 2002:a17:906:b28c:b0:931:baf:259 with SMTP id q12-20020a170906b28c00b009310baf0259mr38650771ejz.63.1680534971260; Mon, 03 Apr 2023 08:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680534971; cv=none; d=google.com; s=arc-20160816; b=NYV1G+6gtDIsvNW8Lt9FyefBC+97ihBsZ96mabBer3U27CJrmfNXyqUzjC2689lw+Z QuMBI6MM1tweRgU+Qe4nNROBmGS8GYb8vKb2Rd+HqrqovH+s3YKzXNl2ckj4xhv+oNxF xrwjAJS+weQKai5SKO2hLI+OjQ93TEINoKqLdIcEVL8G5X9YPftFfRqSv+sKokHpY83C BCAOd5+hy7EyaWq/jlDC83F+9hgVXrEOVAVFKVFcQewPewKJT89UMpyxBetJCfMFYVzl kQo67P6qDlQ7Rd3wmK6Vn2LkI85tn9Jtjon7j+1cM0dvRT9it4WazjJSbaJeyotrGoZE WvxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EXiQokygEgtdFby6V0DaIlICChGvv1djpoKsAB/p2vA=; b=fpXnvAbCSTVlEuLoBmGQGX+f929vHixuY4qF4g+t1Odi3yYvww0QLr+Ug//dpgISVN HN7hQOKbNbWy1H9vGLObpRuqJvXLbr9Rd5kpseyHRA1FsAWh6VNEtvDsmLSXAYwFxuDH uoV1BJDul0j1X34SsfLk9iCsbUDyDc87/tYEB688+KQWovp1n1Nslfy0qMJMpNQozLy8 uTReIc5ScgyOyD9fjglm/t9BFEp1qEnyHYuNpvYOIfZOP1UqqBkECGi9S6qXg77yUkFM i5DwwXEvBdeLKB2Yuo5I2KmkghjebfEdQpnn5U5X+8HwHzwuP0qJ5DqhnT8CI8Gb5Uzf sqkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=AB7oqhJJ; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a1709065e0c00b0093b064e5934si874460eju.464.2023.04.03.08.15.44; Mon, 03 Apr 2023 08:16:11 -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=@canonical.com header.s=20210705 header.b=AB7oqhJJ; 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=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234007AbjDCOrm (ORCPT + 99 others); Mon, 3 Apr 2023 10:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234061AbjDCOrV (ORCPT ); Mon, 3 Apr 2023 10:47:21 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AECED29BE0 for ; Mon, 3 Apr 2023 07:46:42 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id C43D43F4A5 for ; Mon, 3 Apr 2023 14:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1680533150; bh=EXiQokygEgtdFby6V0DaIlICChGvv1djpoKsAB/p2vA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=AB7oqhJJEk/EGurhNt2yIxzjHn5eyb7aPxGFZLyNh/JJ5TIJ/o4Mpn+GYyFayH+Is 2MQvo/CTcf8628ZHsqquNTtIKyIVfLb7oOKL+e38ZY5/6QHfLQKJVFfoijidG+DJoU TFt6JwHlUlUBgU71s4lkJm8IqcmjQ6oiVtk81r1EQ9TIa9c+Ap11O/cVvSUSxuvTB4 45jn7CaCNzsH/m7uiKDgQKkQEsXAAsavselvXNs+Ld8YTdnybHcd/E/gADXam4xus/ yasVU2oqKseuwYqN8ZRdtuDP7JN9steHnWLS5OmrjOSnFSqu7UYq3Nwcw0LOzlTPJR GWa/1DZaIW4Xw== Received: by mail-ed1-f71.google.com with SMTP id r19-20020a50aad3000000b005002e950cd3so42069816edc.11 for ; Mon, 03 Apr 2023 07:45:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533150; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EXiQokygEgtdFby6V0DaIlICChGvv1djpoKsAB/p2vA=; b=qhCXbWTAR0OU5yRf1MmlKfRu9q7oazZcdv5LnaDsp9weUHlKjiHfFmJuF1o067FnX/ JDeGvVEcz461/d8yCGz5kIeUAFQYGll+aBCLAlsdVVhz+JIAxHG/5Ya9Ppe1lY5W6H6p oJWfYx9ot6p/hom+DwQbFKMkQoFl4vmCT5ovGM4ubwvOHFMhUNaQOnmWBxqgprPyqCJp awJ9xZkOsungOgnBHn6fezKrLJ9TK4ETCCf9wR+vgqASHFC6QCSiRp9QmUeSXp2oX8dg 29jap1C/y6tQfMFtkh4v/AsRCoMa/0maINliKLOvFf96JL63p3Qg/3XoG/M6IjOPdi4x 1YWA== X-Gm-Message-State: AAQBX9cfQiKfXFWEm2TcNORFUYjnpP+7BiaWkSas6iX+bDghTA9ds0/c xkR1F97jBwyCZn5Yo8fQ9WMOkEHYUUMJDnusfz0C8XRdVBCsAn+I4Qir+xtB/nfp8ez/6kwSST6 g0CoQE7f/0l9JpjRd+sCjedW4OyKh9qGny8wfrnFaBQ== X-Received: by 2002:a05:6402:12cc:b0:4f9:f07d:a978 with SMTP id k12-20020a05640212cc00b004f9f07da978mr32552813edx.5.1680533150585; Mon, 03 Apr 2023 07:45:50 -0700 (PDT) X-Received: by 2002:a05:6402:12cc:b0:4f9:f07d:a978 with SMTP id k12-20020a05640212cc00b004f9f07da978mr32552802edx.5.1680533150434; Mon, 03 Apr 2023 07:45:50 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id i5-20020a50d745000000b004fa19f5ba99sm4735804edj.79.2023.04.03.07.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:45:50 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: flyingpeng@tencent.com, Alexander Mikhalitsyn , Al Viro , Amir Goldstein , =?utf-8?q?St=C3=A9phane_Graber?= , Seth Forshee , Christian Brauner , Andrei Vagin , Pavel Tikhomirov , Bernd Schubert , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, criu@openvz.org Subject: [RFC PATCH v2 9/9] fuse: add fuse device ioctl(FUSE_DEV_IOC_BM_REVAL) Date: Mon, 3 Apr 2023 16:45:17 +0200 Message-Id: <20230403144517.347517-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> References: <20230403144517.347517-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762168638059519192?= X-GMAIL-MSGID: =?utf-8?q?1762168638059519192?= This ioctl allows to revalidate all the existing fuse bindmounts by performing relookup of all root dentries and resetting them. Useful if it's needed to make fuse bindmounts work without remounting them after fuse connection reinitialization. Cc: Miklos Szeredi Cc: Al Viro Cc: Amir Goldstein Cc: Stéphane Graber Cc: Seth Forshee Cc: Christian Brauner Cc: Andrei Vagin Cc: Pavel Tikhomirov Cc: Bernd Schubert Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: criu@openvz.org Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dev.c | 29 ++++++++++++++++++++++++++++- include/uapi/linux/fuse.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 93a457c90b49..dae4d718b03a 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -2313,6 +2314,27 @@ static int fuse_reinit_conn(struct fuse_conn *fc) return 0; } +static ssize_t fuse_revalidate_bindmounts(struct fuse_conn *fc) +{ + int ret = 0; + + down_read(&fc->killsb); + if (!list_empty(&fc->mounts)) { + struct fuse_mount *fm; + + fm = list_first_entry(&fc->mounts, struct fuse_mount, fc_entry); + if (!fm->sb) { + up_read(&fc->killsb); + return -EINVAL; + } + + ret = sb_revalidate_bindmounts(fm->sb); + } + up_read(&fc->killsb); + + return ret; +} + void fuse_wait_aborted(struct fuse_conn *fc) { /* matches implicit memory barrier in fuse_drop_waiting() */ @@ -2409,6 +2431,7 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, } break; case FUSE_DEV_IOC_REINIT: + case FUSE_DEV_IOC_BM_REVAL: struct fuse_conn *fc; if (!checkpoint_restore_ns_capable(file->f_cred->user_ns)) @@ -2429,7 +2452,11 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, mutex_unlock(&fuse_mutex); if (fc) { - res = fuse_reinit_conn(fc); + if (cmd == FUSE_DEV_IOC_REINIT) + res = fuse_reinit_conn(fc); + else if (cmd == FUSE_DEV_IOC_BM_REVAL) + res = fuse_revalidate_bindmounts(fc); + fuse_conn_put(fc); } } diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 325da23431ef..d8d1997876d8 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -993,6 +993,7 @@ struct fuse_notify_retrieve_in { #define FUSE_DEV_IOC_MAGIC 229 #define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t) #define FUSE_DEV_IOC_REINIT _IO(FUSE_DEV_IOC_MAGIC, 0) +#define FUSE_DEV_IOC_BM_REVAL _IO(FUSE_DEV_IOC_MAGIC, 1) struct fuse_lseek_in { uint64_t fh;