Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp968781ybm; Tue, 21 May 2019 06:43:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzluLAoVLx+LSg+0DenM1KChWIN9boBu1HhRl45tDyIA9Xh1Mha9zvZx5Rsy0RytJhqV4U X-Received: by 2002:a62:f247:: with SMTP id y7mr86325382pfl.18.1558446208232; Tue, 21 May 2019 06:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558446208; cv=none; d=google.com; s=arc-20160816; b=oRYbm/2ZXxOAUgaFUf0Pd8PYH/D3CoiPrnJ1/032b6HoHKIudLvzoZ1cJmWJb0XfT/ COYPh4vprCXgmmlGipvUcgqiMfa/tkj0YJxvaoDkyHZxyqOlR2HM9qbech8Q5NqOTSoq DRPleoqlG095GnEdOzm/S5TlSH3ZGC7NKop7dLLGJS2EQOAo4VVt0DiZ7pyGnhZ3Mc2s 1TLI78LujvODelv0u3VtG3Op/3oQDWLR7AoZ3/VXwA0pmTXrOjeE9UOMrLQdfMvEx0AT uX0w2vm9gqPQQLTS77NpZDewsEKSeQDktTJJFirxd9fc++10CN1zz6YDBBA/5Mp1NbBZ jV1A== 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=kLYFEG0/RW3SEkSQsyz5yLBDJwTrWYQIVw1Ia1B09kJJCCWdbID9cP3hQn0gcJy3yD aeHb0lUMfu+qV9HMidAbegShxjExqldZcxJJIREFetMr4ZhZZuSjUe/GzALs91MUulvy e9uN9lpkdMs4kHHm0B1OuD547Wni4gPW1t7lQn7Vj8YaTru0SF0xW7tO20UuLFD7OgZs 39mg1PHMdfExnqUmnezN9AAacOjm89vCVy8v0WnswU5XpthAWZYBenSTbsyq/8gw4QyI /gp1U4wUXYcJbk6Z6IxrrxNFTOhS7x5gHtzRgt997VdDWIKuI8SOK81tStCgstZvYt0w mnUA== 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 76si21205661pgf.582.2019.05.21.06.43.13; Tue, 21 May 2019 06:43:28 -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 S1728325AbfEUNmw (ORCPT + 99 others); Tue, 21 May 2019 09:42:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60702 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfEUNmw (ORCPT ); Tue, 21 May 2019 09:42:52 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04CC930BC581; Tue, 21 May 2019 13:42:51 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (ovpn-116-97.sin2.redhat.com [10.67.116.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id F35F610C9E7C; Tue, 21 May 2019 13:42:21 +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, dm-devel@redhat.com 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, pagupta@redhat.com, pbonzini@redhat.com, yuval.shaia@oracle.com, kilobyte@angband.pl, jstaron@google.com, rdunlap@infradead.org, snitzer@redhat.com Subject: [PATCH v10 5/7] dax: check synchronous mapping is supported Date: Tue, 21 May 2019 19:07:11 +0530 Message-Id: <20190521133713.31653-6-pagupta@redhat.com> In-Reply-To: <20190521133713.31653-1-pagupta@redhat.com> References: <20190521133713.31653-1-pagupta@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 21 May 2019 13:42:51 +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