Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp229338yba; Thu, 25 Apr 2019 22:04:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtAYo9KdALwPe0mnlHMJdbZfRDY+4ZSo5Vo/17YdNDimU7Htr7se9dvVuld6Wh1Kv4MXMy X-Received: by 2002:a17:902:a5ca:: with SMTP id t10mr44163966plq.234.1556255046218; Thu, 25 Apr 2019 22:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556255046; cv=none; d=google.com; s=arc-20160816; b=qQD2gHUqDfCLA6ztN6pCZDE6Cq5WY2RPuzQN8QmZarlyCKy4C0vQ0q2EAaJwjEvQs+ xSqY6cNHZCHJQoNykZuq9kQ4RJqjiXI9c4cI9X+j1XlZsZOg/u3665dd7AOwK3/iiKvq ituTyl2yN3I84IuWXf+DUmV5xZIGKa2UivcLZK5l6HkhCtj6B+BUZqbkISV2xGyYphTJ P93JlmAgsPH399jFo5FRE3i6z0LyqK1KNSUwvPoMrazWrQQFdK4YhWbnst6YnbsptvWy aYAmEmCHGda1kdJY3nXGAGhVTOJiGXOS7U0zUKosxAysvWMUEqzOPR+o7J6Uqd19GxSM HnsA== 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=3XRir+iVZrkjIeSly6nV+sZWQo3KIe3lWGe5pvrCl6c=; b=TN8OcqGSxD/mfYrXZ8z2cFKl2mRtK2TbaGtav9v9WGCAoFSDIcPH0trrtXBklzDWMX JREK/nL9YDmEoA/jHm78oz9s+9cnTgjKKglaEIIYIzz5cA5ZWRY6vhXKmkeYGP7HTs7I oylYBxPRHrT4YdhkmtwmpLi3trk/Ng2Mf4UoKOOIsVkD9K5FIYhg0coaso4U3s2r523V WWDFRCEiEJ3VDvXCnSbJHDL8q+xjh+gg0Zuq6rpF7v+4AFQ2fKPFEc3uncvkV7gXgPHd muzd6B8eNSr6KkC30XF6pUh8bK29T1tSqA7QxjPTch3JDrBzr9zoycJgBmIH0aJj/Fjx lWuw== 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 f7si23370098pgq.522.2019.04.25.22.03.50; Thu, 25 Apr 2019 22:04:06 -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 S1727298AbfDZFCc (ORCPT + 99 others); Fri, 26 Apr 2019 01:02:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49986 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbfDZFCc (ORCPT ); Fri, 26 Apr 2019 01:02:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6ABE30A3AEC; Fri, 26 Apr 2019 05:02:31 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (unknown [10.65.16.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA0D160856; Fri, 26 Apr 2019 05:02:11 +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 v7 4/6] dax: check synchronous mapping is supported Date: Fri, 26 Apr 2019 10:30:37 +0530 Message-Id: <20190426050039.17460-5-pagupta@redhat.com> In-Reply-To: <20190426050039.17460-1-pagupta@redhat.com> References: <20190426050039.17460-1-pagupta@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 26 Apr 2019 05:02:32 +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 c97fc0cc7167..41b4a5db6305 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -41,6 +41,18 @@ 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); +/* + * 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) { @@ -68,6 +80,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->flags & VM_SYNC); +} #endif struct writeback_control; -- 2.20.1