From nobody Sat Apr 20 00:07:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557845996; cv=none; d=zoho.com; s=zohoarc; b=ELlF2RApF3145bfCjwxTPbK+Vyg1k2ian+8x9JT8tGJy6jg5SyRi6e7+1I3khLtyQQATGEqD85kOc74R/0G4wef1+oAu1FFQMN0ZPFf7bssrX7CLIQ1RydfJzbZgAxzuV/YxyFKkbuRwHK3kTQbD0LsSXPgrklREtPZrl8Tylq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557845996; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bxM5ILhJKIB7bmKrInlBVpAPSh6CTAyGffjnuKSHpKc=; b=Nj+8BXoAA0gT/X1woCGYZAlAosuCcnyI0eUXi5/j3KQAxqPDK9wfxAt9G4TMIZJpa31b78xX2/xMF2cHgyDnuMKU2LAfcEjO8hpKb7stC5ZBZNVugi5hZup24fHytW5RQsJUfgj/xj7E6JOo0nWd9J9edOa6J6auq+2SYj6YOhI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557845996311378.267384921627; Tue, 14 May 2019 07:59:56 -0700 (PDT) Received: from localhost ([127.0.0.1]:49469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQYuJ-0005ql-92 for importer@patchew.org; Tue, 14 May 2019 10:59:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQYsn-0004yH-EA for qemu-devel@nongnu.org; Tue, 14 May 2019 10:58:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQYsl-0000Cu-F8 for qemu-devel@nongnu.org; Tue, 14 May 2019 10:58:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQYsj-0008Vo-FL for qemu-devel@nongnu.org; Tue, 14 May 2019 10:58:18 -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 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) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v9 5/7] dax: check synchronous mapping is supported X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pagupta@redhat.com, jack@suse.cz, mst@redhat.com, jasowang@redhat.com, david@fromorbit.com, lcapitulino@redhat.com, adilger.kernel@dilger.ca, zwisler@kernel.org, aarcange@redhat.com, dave.jiang@intel.com, jstaron@google.com, darrick.wong@oracle.com, vishal.l.verma@intel.com, david@redhat.com, willy@infradead.org, hch@infradead.org, jmoyer@redhat.com, nilal@redhat.com, lenb@kernel.org, kilobyte@angband.pl, riel@surriel.com, yuval.shaia@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, kwolf@redhat.com, tytso@mit.edu, xiaoguangrong.eric@gmail.com, cohuck@redhat.com, rjw@rjwysocki.net, imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_de= vice *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 =20 struct writeback_control; --=20 2.20.1