Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp695314ybi; Fri, 21 Jun 2019 06:40:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxa92SibmKPcdsFrAFC/GFxSBRN7JIV/24C8/FLEGYpYq0g17S7RKCDYbSbVPQrEv/02HHP X-Received: by 2002:a17:902:f216:: with SMTP id gn22mr112564028plb.118.1561124415898; Fri, 21 Jun 2019 06:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561124415; cv=none; d=google.com; s=arc-20160816; b=atGKmpVPHtfthBR7ahoMSRhOymwRkttPmiod6uvCplKL5F2VBaOVTO7Id4bL/PjrOU 01YmbHKpBQcX9PkiGaLrzDeYaNBYo5zU+WvnkuXVbrUJIEDXyHmIdlfUdBxldK+YwtMp X2HwBf1vT5UXoxsgFM4MeUeXM1GeAsCSus3+znhhKwZbDrhMH+1SqvQPkR070d//RZKj Nx/M00RFJg+TubZzUrJ1r7HZZcQmB4tFk8KKxwW3kKOTP5lOfrmF9X9hSd4xXwZLyUAh OuzAmIq/+ot+3JMNWErdpKWR0rNtJBOupOfbb8/sV/zrLuKHJTHxSt/Nois0RVoPnUp2 MXeg== 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=Ux7DzIfMktgQm5rv6VGokNV1RzFK6nuqoUkwb7sq8Ms=; b=hFZAI0mxKVvsqTn5vTjRZb1o8ENa+g2S6Pd7M9acTp/Sd5KoYuPIpuvM8cjqjFIr80 liIwUnnolWRpt/up4VJEfMDhSyNqAXE5wMugyBVJ3xYM5LDZGlgVwfGmTGncbAYy4pWl CCclZLGGk2xz4HslYqffggZcYPG16hHmoYSoKaY1LW95W28EMdFZAX8weD+YcO5aFOuf EcUGQDW75JQLps76l2RIZLWBDVdPZH2GB+5WpbKi021N3qEJ6YWXvA650ShC1hK5aKFO C4FY3Aw80naliZj1v5dwiz1Rd+liI2LlNnaNQZMuutx2sHNTxfZOG6e7Yjkj/KQ6fYCz iDew== 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 g8si2561518pgd.64.2019.06.21.06.40.00; Fri, 21 Jun 2019 06:40:15 -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 S1726362AbfFUNjp (ORCPT + 99 others); Fri, 21 Jun 2019 09:39:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55092 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbfFUNjp (ORCPT ); Fri, 21 Jun 2019 09:39:45 -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 D9916307D850; Fri, 21 Jun 2019 13:39:44 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (ovpn-116-60.sin2.redhat.com [10.67.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CD9C5B689; Fri, 21 Jun 2019 13:38:46 +0000 (UTC) From: Pankaj Gupta To: dm-devel@redhat.com, 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, jstaron@google.com, rdunlap@infradead.org, snitzer@redhat.com Subject: [PATCH v14 5/7] dax: check synchronous mapping is supported Date: Fri, 21 Jun 2019 19:04:53 +0530 Message-Id: <20190621133455.3303-6-pagupta@redhat.com> In-Reply-To: <20190621133455.3303-1-pagupta@redhat.com> References: <20190621133455.3303-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.48]); Fri, 21 Jun 2019 13:39:45 +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 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 86fc55c99b58..d1bea3979b5a 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -53,6 +53,18 @@ static inline void set_dax_synchronous(struct dax_device *dax_dev) { __set_dax_synchronous(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) { @@ -87,6 +99,11 @@ static inline bool dax_synchronous(struct dax_device *dax_dev) static inline void set_dax_synchronous(struct dax_device *dax_dev) { } +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