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; } }