Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2511167pxa; Fri, 7 Aug 2020 13:01:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRLaj2gv8pHUK7V7crrkWmJH6e1gF+5yPtxDrpknSQB4smnIQER2j4dPIwx8yR+LJuazfU X-Received: by 2002:a17:906:a204:: with SMTP id r4mr10743917ejy.552.1596830460284; Fri, 07 Aug 2020 13:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596830460; cv=none; d=google.com; s=arc-20160816; b=ghagnKl2L65tyPUi37fgXzFlzLnyqsifH5ONZ3kgYCsJZfax9PWuXvwFtFObCQHNrG fAucBrcN1HYKyO7u4x3UI4GiCHH+9sn6oTzFpn2L+hDoT9eDAYfcYrmV862zVXzlA76g /D5Xwdni/u0i5WTOaEKGbHmrd1Z4rGmIz7+aCqyQkBrdV+h9b4umb9B7CvUktyhyQoqw xDch02OKVwffvkEU7Glln709YytsdwCcrgKlL/ZeVCCSJho87Aepf6RXZiGUpBX7J62B iTq3hJOOvWz4ceNHxu2s0MfUMz0dkMZc7Nzd671KL43fU2HDDtTnXKr2DXuCa4WivrXG c1xA== 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=7Vt4OYUmY+cg0HEFATX9XeJVvApvCT7zrfmElMLSgMc=; b=a/mpbLzAseQc/5ZvylLbgHGLxKyVU/roJqz0P6NGV3tREzTm/MahcbCRHh2w4O4bM7 B3gg1dFp7gniGCLIshmGwIxvZVSig5gHpAQnBY/yHkur8zX02nCiaL8zUX/jip6o925R b1RjQTVDS9WrtBDQ2tHLQnfKBuW0sukaGoBiq1PkNOCskk0xLkIytnLpjMtmrNKOpZ5V 2KvDOhb0oTKxNbRlqoTPBxNFGVA2RZN/xajsBWpTbjHN0mb7ms0hdqStIzhU5iZIHPeW MkiFlN2KDVOdv86noPQlgls27Y3hytf/QXD74ts8i3WdC6FRvyO1E7hJj7s9ZKsZ4xlh 1how== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UrtXko35; 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 w12si5808496ejz.421.2020.08.07.13.00.37; Fri, 07 Aug 2020 13:01:00 -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=UrtXko35; 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 S1727964AbgHGT5Q (ORCPT + 99 others); Fri, 7 Aug 2020 15:57:16 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:60650 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726648AbgHGTzv (ORCPT ); Fri, 7 Aug 2020 15:55:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596830150; 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=7Vt4OYUmY+cg0HEFATX9XeJVvApvCT7zrfmElMLSgMc=; b=UrtXko359PrGjTY6gptwk/uWu9eP8iR8YDMxiPAWQ146IOftjUASjvCxmlM9N1CSnmPWFu gSKjwfsIdzfdzFmMiWglWhQ5lRUCh6EPgSCuyRFdBhrcseuiK/DnRckKc6yB7qn1j8OTaa ejHnbrBDZTJB+u1RXdSqw8PrAl7K0UQ= 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-421-FJwWHB0uPeCITfWcL7KA4w-1; Fri, 07 Aug 2020 15:55:48 -0400 X-MC-Unique: FJwWHB0uPeCITfWcL7KA4w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAC011902EA7; Fri, 7 Aug 2020 19:55:47 +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 A93802DE7E; Fri, 7 Aug 2020 19:55:47 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 35F55222E61; 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 19/20] fuse: Take inode lock for dax inode truncation Date: Fri, 7 Aug 2020 15:55:25 -0400 Message-Id: <20200807195526.426056-20-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.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a file is opened with O_TRUNC, we need to make sure that any other DAX operation is not in progress. DAX expects i_size to be stable. In fuse_iomap_begin() we check for i_size at multiple places and we expect i_size to not change. Another problem is, if we setup a mapping in fuse_iomap_begin(), and file gets truncated and dax read/write happens, KVM currently hangs. It tries to fault in a page which does not exist on host (file got truncated). It probably requries fixing in KVM. So for now, take inode lock. Once KVM is fixed, we might have to have a look at it again. Signed-off-by: Vivek Goyal --- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 605976a586c2..f103355bf71f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -467,7 +467,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) int err; bool is_wb_truncate = (file->f_flags & O_TRUNC) && fc->atomic_o_trunc && - fc->writeback_cache; + (fc->writeback_cache || IS_DAX(inode)); err = generic_file_open(inode, file); if (err) -- 2.25.4