Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4703919ybf; Wed, 4 Mar 2020 09:03:13 -0800 (PST) X-Google-Smtp-Source: ADFU+vszfQ+QU5JSMJuWXyJTs8Wt1RXKymtWrJ6NeHBTYkm++UzAK2fIMTZH2jDUWh8krtErW+Zb X-Received: by 2002:aca:fcd8:: with SMTP id a207mr2545973oii.56.1583341393293; Wed, 04 Mar 2020 09:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583341393; cv=none; d=google.com; s=arc-20160816; b=IhS7fhDp/nmdeSANgO4Qe4DnupIUSc/rposlUKDRhxxKDz8FALAFUwIGkpOPf4u6w5 zTFIBwCzWAQyuha5ShQxgQxi4gAxOkzZuhbryzHy0SBJXF2HX/NmLqczp7pKeHdWtSzw 7/4lXaV0TMoFlXCcFGUu9fdpcJwOqUqC1S6zO0Ee89Y7fQCv8emD8kya7IaCqb8JVbH8 Aeq4qntfXY2K4O1AjtqvnizWlFsgVJtDYHQZ2kiay5m+12WL9W3dyg3mZe3fdqES/z+A iVuLRdbZtu4jSOqkmR8Qng/rUMJBTJ/43hBs5/kUz+lSrcdu3z7vEou5qV7hJTEztt2s QufA== 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=mBFU8IIvnGbLA1VTtFFHfhcbNjvcmVFEe+Go+jm56Gc=; b=i7XPrCC4A3PkoRx1BDRoBW8kROwe5QdNW1hdlTL0ZNpO/yFR+D7190NR9ydy+Ulm1L 3RFVr+EgLy9hKoOQkOZNhoFRQDca804cbMu+/j3e4bqqgf1zMPOp2Bqyh9GXjA9md/sw z6kV2F38MQT9NliIXrEHhXaN0zYWPU+W4ArtYekRts/txGNG4znV3QpY1myDZkaoOAz6 AL40zjmdeAxNItuz/2nhFtjeez8jhDaKn/ym9WOjD7APMHU8b/uv8wZnW7mQL7SZCmtj bcWLDZYzNXDQbKjh4B7E6wOGSZZCWhfaXH/Ru/ZhrEljf7kFxMpA9sE6VfZ7h0jqKXo1 Sl7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KoWzMtbI; 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=pass (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 q72si1595973oic.148.2020.03.04.09.02.54; Wed, 04 Mar 2020 09:03:13 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KoWzMtbI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730076AbgCDRBe (ORCPT + 99 others); Wed, 4 Mar 2020 12:01:34 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:42259 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729834AbgCDQ7Q (ORCPT ); Wed, 4 Mar 2020 11:59:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583341155; 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=mBFU8IIvnGbLA1VTtFFHfhcbNjvcmVFEe+Go+jm56Gc=; b=KoWzMtbIYiOE2taaRDHf48EzvTU37Azub6aIWTpNdtHyw/7YDhZHZeSuCSKeuC1tTQ5LCN jgjRSpRGShsRyDcODXWFsn0aJtQf72E5606gKbh6AVEM+jDA/uJ1ViZZ2I0JPCrZT533Hg AYS/WCGOm7XRb26YXuyw15/4TtFpthY= 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-471-ul4BurxFNO22LBVyUIglCg-1; Wed, 04 Mar 2020 11:59:13 -0500 X-MC-Unique: ul4BurxFNO22LBVyUIglCg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EDDC800D55; Wed, 4 Mar 2020 16:59:12 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C46A5C1D4; Wed, 4 Mar 2020 16:59:12 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 8F8E9225819; Wed, 4 Mar 2020 11:59:03 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, virtio-fs@redhat.com, miklos@szeredi.hu Cc: vgoyal@redhat.com, stefanha@redhat.com, dgilbert@redhat.com, mst@redhat.com Subject: [PATCH 19/20] fuse: Take inode lock for dax inode truncation Date: Wed, 4 Mar 2020 11:58:44 -0500 Message-Id: <20200304165845.3081-20-vgoyal@redhat.com> In-Reply-To: <20200304165845.3081-1-vgoyal@redhat.com> References: <20200304165845.3081-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Content-Transfer-Encoding: quoted-printable 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 expec= t 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 561428b66101..8b264fcb9b3c 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -483,7 +483,7 @@ int fuse_open_common(struct inode *inode, struct file= *file, bool isdir) int err; bool is_wb_truncate =3D (file->f_flags & O_TRUNC) && fc->atomic_o_trunc && - fc->writeback_cache; + (fc->writeback_cache || IS_DAX(inode)); =20 err =3D generic_file_open(inode, file); if (err) --=20 2.20.1