Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp935154yba; Wed, 15 May 2019 12:33:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3VEZVAWnTf00vB+RNpBEoNXo8bDEkx4fhTpNo/TxbL/KBRxDKHRD2q8MaKpVjapIXxHV0 X-Received: by 2002:a17:902:b412:: with SMTP id x18mr45861018plr.304.1557948786455; Wed, 15 May 2019 12:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557948786; cv=none; d=google.com; s=arc-20160816; b=zU1PojWwIIyivrAsJzYSDyIiOsAsdtPIdmBU3wFh3zZUkcWudSR9NGu1jh7BE1Rlfp L+aGuwC0WCKkz7bxcnZ528aSk2wSITNf3GLHdgbYxiBgl6drINdqHMdCUYIYJRecg7tM 9lBxhgUSKwHUOrjG5fbFwQ7OiNYhmwV6m3kDVdQjsBtuOyfF5+zY3sW1Cgk3UelpDzm1 KpzlJCtWDxBwSWgBu/5h+hroOqVSuihQB7vAOXPvdj3NTrmFyAs+27f8E/Yj2KQbznN7 X3CX88ZnfnERpPJsjRh0Cx7C5iohrg/Dx2dOOcByoxRvQONbzv6YUjc8Al5TskP9Sywa lMag== 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; bh=3ZiYiIXSiCTa9h4ApqvyM9Ti2eGGdnEVc3ysf3VHlI4=; b=Yz9k9t7/7DlS12j8EYMroZE+zV6nyC9EQu20j/tPV6l0o2HKfOt9DGD2SAYeBUfCA1 +0k3pqMs6e4OE1Gjv+Vq+dqd/qfeahd/b7l7hOSNzaWXT2oPVbNGFOkBG1vTLDPHByUw WOZDTGV04BaLN98kXQ+9O9vfFIyKebQLpti+SUBnr/89oG8DrVIV7IeU6B4Blpz/blJy RxD4PUuHQWcoYXeA3Kr+n8RmHiP0QrJbsgUV7OBzi0E1+nx8Bjl9DaeDHEshSpKhnVo0 zLFGOxkrkWHsGjGYYTgqadpRTjlKFYXKKjQf3Hile1fK6NzCVddee+fRBSe8Gzg0AolM +i4g== 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 h123si2990272pfe.21.2019.05.15.12.32.51; Wed, 15 May 2019 12:33:06 -0700 (PDT) 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 S1728244AbfEOT3j (ORCPT + 99 others); Wed, 15 May 2019 15:29:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53908 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727634AbfEOT1e (ORCPT ); Wed, 15 May 2019 15:27:34 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 20248308ED54; Wed, 15 May 2019 19:27:34 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE3501972A; Wed, 15 May 2019 19:27:33 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 2B3EB225491; Wed, 15 May 2019 15:27:30 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-nvdimm@lists.01.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, swhiteho@redhat.com Subject: [PATCH v2 29/30] fuse: Take inode lock for dax inode truncation Date: Wed, 15 May 2019 15:27:14 -0400 Message-Id: <20190515192715.18000-30-vgoyal@redhat.com> In-Reply-To: <20190515192715.18000-1-vgoyal@redhat.com> References: <20190515192715.18000-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 15 May 2019 19:27:34 +0000 (UTC) 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 9b82d9b4ebc3..d0979dc32f08 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -420,7 +420,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) int err; bool lock_inode = (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.20.1