Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4485729yba; Tue, 9 Apr 2019 21:11:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQdcU1aNI1/zpdbvc8VgPYdMO16+U2TF98/kqhvUI81nSIu6uF7sRAnxF5ZXvlK/GnvGfe X-Received: by 2002:a62:204b:: with SMTP id g72mr40173820pfg.51.1554869519490; Tue, 09 Apr 2019 21:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554869519; cv=none; d=google.com; s=arc-20160816; b=Z1Nfvs+7vICBOyqu/JaGj9qY4vmcrlxC8f9KwjriSfbBCw4QIZH8rsers6wSghu17j LyYvjiiCraZYwUm+2BCpM6eQ3OIHcJnBihdMCNrMqHM7LhuVw3QVj1E+C6eP8KeG/umC 9vlu+HW7yPZPxdp8NSwsRijgDzDxA357GDtzU+Dm4PHX0l+qh2xpIjm/clwIJ8+mlQkh EYGqO//LFL4xyBHNqjSzuGC556xa+swA7eqT4y1RcRzmen//dXo8VlY3wSKeraSYJc8O xd05UwSDp3ncEEie9WlM4r9g2Ty75fTL0NqOYUiBa6l2r/aevoVSW7JlU6mJo3Y+cEct nJhw== 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=Nl32PonXliZrKyAyF3G8ZGPG36yKMfRqbv4RdTuXCps=; b=Bw/mx9+wshaaHfS2rjooXcxdjKgKXtt2+J9ksGW5NbvK301hVG1KPLBJFy6D+evr// iEt9HNOTsGGVaWXh0NHkSEVBM4MLQLx2j8hayKlpHF0FN14M6SDdVWWOCeBWoP2+w1sk VBEObMIHTvXhrL3xIsvFrSlSKnu3JcaLo70ee45hHQ9Pu7uXXpPdc+Op82iU5+BdPXei V20MvzBS3nHzcg4NMHyofKoft1KolwgLdXjL8rzlx7d0XQ+76ubB5vFXVKg6LTIWrbNA LYODHHQP3f7CYy4R8Vj1i3fPfDoSBCCv0CI+C1ySFqYv4vmDolNCV/loGR/uE+l8EPXR XHkA== 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 a66si30942338pfb.210.2019.04.09.21.11.35; Tue, 09 Apr 2019 21:11:59 -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 S1727302AbfDJEK3 (ORCPT + 99 others); Wed, 10 Apr 2019 00:10:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60504 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbfDJEK3 (ORCPT ); Wed, 10 Apr 2019 00:10:29 -0400 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 DEBA688AAD; Wed, 10 Apr 2019 04:10:28 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (dhcp-10-65-161-59.pnq.redhat.com [10.65.161.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4489B6013A; Wed, 10 Apr 2019 04:10:03 +0000 (UTC) From: Pankaj Gupta To: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-acpi@vger.kernel.org, qemu-devel@nongnu.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Cc: dan.j.williams@intel.com, zwisler@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, mst@redhat.com, jasowang@redhat.com, willy@infradead.org, rjw@rjwysocki.net, hch@infradead.org, lenb@kernel.org, jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, darrick.wong@oracle.com, lcapitulino@redhat.com, kwolf@redhat.com, imammedo@redhat.com, jmoyer@redhat.com, nilal@redhat.com, riel@surriel.com, stefanha@redhat.com, aarcange@redhat.com, david@redhat.com, david@fromorbit.com, cohuck@redhat.com, xiaoguangrong.eric@gmail.com, pbonzini@redhat.com, kilobyte@angband.pl, yuval.shaia@oracle.com, pagupta@redhat.com Subject: [PATCH v5 4/6] dax: check synchronous mapping is supported Date: Wed, 10 Apr 2019 09:38:24 +0530 Message-Id: <20190410040826.24371-5-pagupta@redhat.com> In-Reply-To: <20190410040826.24371-1-pagupta@redhat.com> References: <20190410040826.24371-1-pagupta@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.26]); Wed, 10 Apr 2019 04:10:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces 'daxdev_mapping_supported' helper which checks if 'MAP_SYNC' is supported with filesystem mapping. It also checks if corresponding dax_device is synchronous. Virtio pmem device is asynchronous and does not not support VM_SYNC. Suggested-by: Jan Kara Signed-off-by: Pankaj Gupta --- include/linux/dax.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/dax.h b/include/linux/dax.h index b896706a5ee9..4a2a60ffec86 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -38,6 +38,24 @@ void kill_dax(struct dax_device *dax_dev); void dax_write_cache(struct dax_device *dax_dev, bool wc); bool dax_write_cache_enabled(struct dax_device *dax_dev); bool dax_synchronous(struct dax_device *dax_dev); + +/* + * Callers check if synchronous mapping is enabled for DAX file + * and attached dax device is also synchronous. + * + * dax_synchronous function verifies if dax device is synchronous. + * Currently, only virtio pmem device supports asynchronous device + * flush. + */ +static inline bool daxdev_mapping_supported(struct vm_area_struct *vma, + struct dax_device *dax_dev) +{ + if (!(vma->vm_flags & VM_SYNC)) + return true; + if (!IS_DAX(file_inode(vma->vm_file))) + return false; + return dax_synchronous(dax_dev); +} #else static inline struct dax_device *dax_get_by_host(const char *host) { @@ -69,6 +87,11 @@ static inline bool dax_synchronous(struct dax_device *dax_dev) { return true; } +static inline bool daxdev_mapping_supported(struct vm_area_struct *vma, + struct dax_device *dax_dev) +{ + return true; +} #endif struct writeback_control; -- 2.20.1