Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2509207pxa; Fri, 7 Aug 2020 12:57:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzM7VLXUrDZVemY4F7r60CpR09wRuzL6+nh7SgAQcHYqip+MEpba67fdVGeeiwipmb9IPrN X-Received: by 2002:a17:906:c7d3:: with SMTP id dc19mr10882352ejb.495.1596830273197; Fri, 07 Aug 2020 12:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596830273; cv=none; d=google.com; s=arc-20160816; b=Uk9lZwkznAcOMR503rQ8f2EoARJ4SmNxD9P4yUnltLIbbqtrIA2NAts/KmuNEtWCvr Uf0XtyWVpc1187xqdyTxnnPH3gHRIxv1SF1thK3vf9nD5EaW7YLaNUM6BfnBAWIMU/gX ya+jW9WttG/zz+S0hL1MUU4Gi/dYDIbmuT1UaIFw8hLaVDrGpkhLOvWky29OTTmkESsO HpJeq1p4gbadXYzwRKRYG27imykro8mWSmPTZnkxexQZFSSQfa9z+Jx9bVlNqCsgKqft jaWifQt2lAe3R1HynaXhColbA5WCxnZ39Pd6FHxnOST/YUw2pN94r84VPYIWxjTYP28d MWGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j6JUyG/bf2+dwOM6AHu3hayOozdITAyDx7At5vTKLkw=; b=e1i9pYiNedHOQhc2fcvSY4b4ISBTpP/ifbv2VpjUo+j+fecDikjF31eJX0dHdXgqdk L4kkA6IOVrym16GRxV12m+4C+f2T3Yy4ah6jbl3KnlwyFlAQxnGDzCWbmG9cO4xHCb3z 4goIaiqON2saTDhNdZ1VOKMhG2fMXEanw0GfrzsxkHroJLCnmbod0+642bPkaOy+n5T1 nuXeI8xJDpdLvTi0EN7Uj7xMmLA/QaI/LyTA/Yjw6nNMZ+KX+5xAj06LALMGJvx/RM2l k6PQCC2YAOAymbooQfqLNTN+uoJk/jmEn38SlqVTiytArHUlflJbGE+YstYGG+1H55Hh nYaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H4mMytjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si6592416ejc.533.2020.08.07.12.57.30; Fri, 07 Aug 2020 12:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H4mMytjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbgHGT4V (ORCPT + 99 others); Fri, 7 Aug 2020 15:56:21 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:38765 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726977AbgHGTz4 (ORCPT ); Fri, 7 Aug 2020 15:55:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596830154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j6JUyG/bf2+dwOM6AHu3hayOozdITAyDx7At5vTKLkw=; b=H4mMytjMXG4dT4X5vQ6FspXSEXUMugZchqJi73s+9ajkjA+T1DKWlI80KU5Nra+mvMjVEY hxWsWYdFkozuY4hA2/5P6phJz3aU4iSUnPDZIGYDSXGquJFvpe9aUIgEGxE0016zSYmvnX 3XOsTj6xXuTL1UJTS7R6jaeO+fcxPhs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-rgZc1ktAMj-7QPss3k7dow-1; Fri, 07 Aug 2020 15:55:53 -0400 X-MC-Unique: rgZc1ktAMj-7QPss3k7dow-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A5EA1DE1; Fri, 7 Aug 2020 19:55:52 +0000 (UTC) Received: from horse.redhat.com (ovpn-113-142.rdu2.redhat.com [10.10.113.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DF215D9FC; Fri, 7 Aug 2020 19:55:47 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 30843222E60; Fri, 7 Aug 2020 15:55:39 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, virtio-fs@redhat.com Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com Subject: [PATCH v2 18/20] fuse: Release file in process context Date: Fri, 7 Aug 2020 15:55:24 -0400 Message-Id: <20200807195526.426056-19-vgoyal@redhat.com> In-Reply-To: <20200807195526.426056-1-vgoyal@redhat.com> References: <20200807195526.426056-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fuse_file_put(sync) can be called with sync=true/false. If sync=true, it waits for release request response and then calls iput() in the caller's context. If sync=false, it does not wait for release request response, frees the fuse_file struct immediately and req->end function does the iput(). iput() can be a problem with DAX if called in req->end context. If this is last reference to inode (VFS has let go its reference already), then iput() will clean DAX mappings as well and send REMOVEMAPPING requests and wait for completion. (All the the worker thread context which is processing fuse replies from daemon on the host). That means it blocks worker thread and it stops processing further replies and system deadlocks. So for now, force sync release of file in case of DAX inodes. Signed-off-by: Vivek Goyal --- fs/fuse/file.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ecd2a42f6e30..605976a586c2 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -527,6 +527,7 @@ void fuse_release_common(struct file *file, bool isdir) struct fuse_file *ff = file->private_data; struct fuse_release_args *ra = ff->release_args; int opcode = isdir ? FUSE_RELEASEDIR : FUSE_RELEASE; + bool sync = false; fuse_prepare_release(fi, ff, file->f_flags, opcode); @@ -546,8 +547,19 @@ void fuse_release_common(struct file *file, bool isdir) * Make the release synchronous if this is a fuseblk mount, * synchronous RELEASE is allowed (and desirable) in this case * because the server can be trusted not to screw up. + * + * For DAX, fuse server is trusted. So it should be fine to + * do a sync file put. Doing async file put is creating + * problems right now because when request finish, iput() + * can lead to freeing of inode. That means it tears down + * mappings backing DAX memory and sends REMOVEMAPPING message + * to server and blocks for completion. Currently, waiting + * in req->end context deadlocks the system as same worker thread + * can't process REMOVEMAPPING reply it is waiting for. */ - fuse_file_put(ff, ff->fc->destroy, isdir); + if (IS_DAX(file_inode(file)) || ff->fc->destroy) + sync = true; + fuse_file_put(ff, sync, isdir); } static int fuse_open(struct inode *inode, struct file *file) -- 2.25.4