Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6461515yba; Tue, 14 May 2019 07:59:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5PKYhfAVgw6AZE79GkZ7KgVYMLbAirLWAmy0i+S+Hkxo4to9JFSj8gYHn2aH+Hf+ugheh X-Received: by 2002:a17:902:2b89:: with SMTP id l9mr39055676plb.331.1557845951176; Tue, 14 May 2019 07:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557845951; cv=none; d=google.com; s=arc-20160816; b=sUT/LQhJ0PWx3K8r2O4tG+c80LMiEkSBu3JEsGQ/TtSwewwcIgfK86+A23GmFk3dDR spxrSiKd/TUXoERp+ajPMF42I/YAQcFP5YJhGHAMuoR5ENb97s6+giJidccqHmDtKGqe d2p2ByhWBJJQz9MHOJvbFGbV3QWBv8LhiK6IqPHkpwnNnfoXxqDGIzoQKkaamn1/v3n5 GlUd2l4IHQkQaaBT2Qqf1uIwB0LyTj3QReov7aD6RdhQyfUPp96FZZJxfRwzV/cdPbcK 3jRAYijJ3Pr6mgJZh/NhbbaMQ279DGFZ3FyMR4ERP4PUXyFPdUzOrhf/N6ZLQ0zcvRyf S5Zg== 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=bxM5ILhJKIB7bmKrInlBVpAPSh6CTAyGffjnuKSHpKc=; b=r50dfn9co6eHvp00B7DY32eHDur9AQeJjdbxz+WBCrPNxJhyy8cxzzPu0BVd7iNkaI MUwCuOf+xmF1B7+7qbcAIa7A3kspsB9j4v35gKHnZ89CEdvJ5rfjVBaCigA5dI1DfhOm w163/kvAQbd8R3IvnN6OPk3ZWxki9PiCa15rtCvDmM+4BoPRWsxnldapjCsXvQU2O9HU 5AWhKhvkJygPGWy8gXjcRNlSWtAdvrZyt4rDnI8cqnJm8jQCuOh2XpmDfq25U+4R06ey 2XJL0J0SANZVneR9RcfiFzZjChfhdYiC1UHaHuNm6WsZTLXvs90zN0lmtZX2RXQBDSOp Bmvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 o8si20773453pgc.137.2019.05.14.07.58.56; Tue, 14 May 2019 07:59:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 S1726449AbfENO6N (ORCPT + 99 others); Tue, 14 May 2019 10:58:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44010 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbfENO6N (ORCPT ); Tue, 14 May 2019 10:58:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97F23300487E; Tue, 14 May 2019 14:58:12 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (unknown [10.65.16.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id A57145D6A6; Tue, 14 May 2019 14:57:46 +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, jstaron@google.com, pagupta@redhat.com Subject: [PATCH v9 5/7] dax: check synchronous mapping is supported Date: Tue, 14 May 2019 20:24:20 +0530 Message-Id: <20190514145422.16923-6-pagupta@redhat.com> In-Reply-To: <20190514145422.16923-1-pagupta@redhat.com> References: <20190514145422.16923-1-pagupta@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 14 May 2019 14:58:12 +0000 (UTC) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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 Reviewed-by: Jan Kara --- include/linux/dax.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/dax.h b/include/linux/dax.h index 2b106752b1b8..267251a394fa 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -42,6 +42,18 @@ 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); void set_dax_synchronous(struct dax_device *dax_dev); +/* + * Check if given mapping is supported by the file / underlying device. + */ +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 +81,11 @@ static inline bool dax_write_cache_enabled(struct dax_device *dax_dev) { return false; } +static inline bool daxdev_mapping_supported(struct vm_area_struct *vma, + struct dax_device *dax_dev) +{ + return !(vma->vm_flags & VM_SYNC); +} #endif struct writeback_control; -- 2.20.1