Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3305186yba; Tue, 23 Apr 2019 01:09:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIhqDLkHp+0zHmwZ4XkVQZMk2Tj1j9ljAGpE+ePvqkj52QccWGcDpUJ/ik9FCPga4AY2iM X-Received: by 2002:a63:2bc8:: with SMTP id r191mr22956079pgr.72.1556006962882; Tue, 23 Apr 2019 01:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556006962; cv=none; d=google.com; s=arc-20160816; b=SO5a927f7vR5iyiSX6Lt7E+z168U9ZKfNhzsSdMKaSc7NoevyixLHbHVGhDJsI2q4g ueJktefzVEUac47iwXnluJ2fxDfOZGYscGpB0ObSaizl3NgdMn4DWojoB9zqPZeVlFil IoAZeXEjVIv5f/gYAazEVbbMb0rL4ZxaRh+laIYcItyPQgIP8PYIcvllk9VQ5v9VkyLn vC39/swtOxv2W2SMDDnu2B/xRUgadQUuIjDgbFYhQ2ZHh360XgEnUAc+9PnL03O6Hrau z+TnF1ZS0ZhlaubCaplYrlxPpo5qLOYKrxfTUpqhGu48TJGnzSIFtse9sabn7QEvHrMw 7dJw== 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=0RZ6MdnRaDGtcx9M3n4JyOX+mbnrTno+Dw5+Xiz8Qu0=; b=QnDZEAZBHwQItsU0WsEa5sr2I6ol/nT+ktON7e+OvDfQb6HIl9Eb9Sz7hg0j7EP9xI CvWAW8tBvu92sQibyJJ4S4wngNIzCUffxocY/udYFYumDax/7XdrOtzY+t9RxN6l4IA+ oPqluyEuo0+wKR6iC4+R7e9d/yJZ0GzYfE9WonJgEU6i/Zdib7wtWNk7gFpDQsMyh/zZ 4sbdi8dOE57ai8fGHC1g8MUBId/Rz5uaX4x48LtZyIJkZ6yFbIsd8DW5O2UnBLz8rWcO 7fCi9kvMc/o6xK6BvOq5L+Tf2smYCGxTn6yxpU8sKTrzbzuPwrCDw8C7a3zDqzmcHjty aSjA== 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 g123si16368740pfb.24.2019.04.23.01.09.07; Tue, 23 Apr 2019 01:09:22 -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 S1726830AbfDWIHw (ORCPT + 99 others); Tue, 23 Apr 2019 04:07:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37820 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfDWIHw (ORCPT ); Tue, 23 Apr 2019 04:07: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 79217309E976; Tue, 23 Apr 2019 08:07:51 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (unknown [10.65.16.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id D37C31001DC5; Tue, 23 Apr 2019 08:07:29 +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, pagupta@redhat.com, pbonzini@redhat.com, yuval.shaia@oracle.com, kilobyte@angband.pl Subject: [PATCH v6 4/6] dax: check synchronous mapping is supported Date: Tue, 23 Apr 2019 13:36:10 +0530 Message-Id: <20190423080612.15361-5-pagupta@redhat.com> In-Reply-To: <20190423080612.15361-1-pagupta@redhat.com> References: <20190423080612.15361-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, 23 Apr 2019 08:07:51 +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 | 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