Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3887623imu; Mon, 10 Dec 2018 09:20:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKCkbCeezlAWFUE8h1IjqjgIo/KqtCxZou98qlqEU53iGjIKiJrdMVQQTIrvMaQahfSIEX X-Received: by 2002:a63:e915:: with SMTP id i21mr11244014pgh.409.1544462447395; Mon, 10 Dec 2018 09:20:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544462447; cv=none; d=google.com; s=arc-20160816; b=BwM3pNhPLMiPppggZt3KXF22TsTGkqykfdPdOBdWrAxXsu39cuZ8FbnJhJ2xXgMWQR 2sSF9QN8Bt2jmfGztawIaHqiEgnE9KwhK3Gdm7XGG/lLsu7xHS9orcylaCxNANt9BaZ8 A2Ge+YTWW/t/M9jmx+BMTJvDx4XO+OOHRkxQBQucY8rkbkTh465v8JbMs3xDKzReGZxf k0gVIrHXZH49Fsm0P/g2euaqwyYci6ojrUi/tdZxaHk0/2xE73DngMUYQNrMwehP6WL0 Qdw8Z1aNotUKatIG1/TvtwfCrhPqePdT5XY9RuPqiVIKworvcFQY+T5x6adFuZ1w8D/7 2wiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=axmau8p2huqCnhiOG3ZcoV+dlwDEywgYJKxG7zklIu4=; b=fHL466n36EsT0p9Pkmmt5wzJxKFMqa0lw1HHYuXohRfMFi84QBHG80YpiM+8vhWMv/ sKQIeWnqHSjpSUjFSat6w3FrGrXn6XYpHOM/2yQkTpwtp+XhHCESrnsNuzzaj6A5uH7l aYnZtEy0Gjv5yZ58pSUfmZ6AeFza6kI6mnw83FOyRBkWmmp9YH5UbQRoKbbo9/lg9/j2 j3ZEMttu4lWX+b31yy18YLjc1ODjrimV3yRJ2wvmZVRPCAap9zUxP9+VWwoZbXLRstkt T8aiy+ZbreTjqpABe5/RB4M+QjK7Yugu5htSWPo618anLtkOBwaP5EwRPmVvxFaH6BT8 8MbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x23si10284927pln.100.2018.12.10.09.20.32; Mon, 10 Dec 2018 09:20:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728911AbeLJRQm (ORCPT + 99 others); Mon, 10 Dec 2018 12:16:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1903 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728398AbeLJRNg (ORCPT ); Mon, 10 Dec 2018 12:13:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A93A3307D867; Mon, 10 Dec 2018 17:13:35 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69F6B604CE; Mon, 10 Dec 2018 17:13:35 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 9FA7B224273; Mon, 10 Dec 2018 12:13:30 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, sweil@redhat.com, swhiteho@redhat.com Subject: [PATCH 39/52] Release file in process context Date: Mon, 10 Dec 2018 12:13:05 -0500 Message-Id: <20181210171318.16998-40-vgoyal@redhat.com> In-Reply-To: <20181210171318.16998-1-vgoyal@redhat.com> References: <20181210171318.16998-1-vgoyal@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 10 Dec 2018 17:13:35 +0000 (UTC) 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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 6421c94cef46..d86f6e5c4daf 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -451,6 +451,7 @@ void fuse_release_common(struct file *file, int opcode) { struct fuse_file *ff = file->private_data; struct fuse_req *req = ff->reserved_req; + bool sync = false; fuse_prepare_release(ff, file->f_flags, opcode); @@ -471,8 +472,20 @@ void fuse_release_common(struct file *file, int opcode) * 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_req != NULL); + if (IS_DAX(req->misc.release.inode) || ff->fc->destroy_req != NULL) + sync = true; + + fuse_file_put(ff, sync); } static int fuse_open(struct inode *inode, struct file *file) -- 2.13.6