Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp955391imu; Wed, 9 Jan 2019 09:05:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN5OKGJrp39vvIQ6c5rj9ISPJzajzx654FBGUO4eDMxGivJQ6vN4CHEcdHPgcI84aGbeYT7m X-Received: by 2002:a62:a99:: with SMTP id 25mr6629336pfk.121.1547053542677; Wed, 09 Jan 2019 09:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547053542; cv=none; d=google.com; s=arc-20160816; b=smHjQgnfcalAvUSKNwydTe531UeXDHjgDOiyPzKYQoRaLSiWf/C5gTGRc9sDkeFKn1 KEkSoiJiAUMjoI4au0jxe/HojKZfN23yGnTUcRPbPReTfPBgMpH3+bu7cpKgyPP63eWZ lmlEJHYAqTe3edQpnVp1nGOuaiDrkC3d7nyIP3RB3sivvr6B7CwKJgPcCl4fj43Fi+tr vTzSV43FY2n5CrnVB9swfDtnTDkDI3fNHMxO18kboZKvOAHny4v6CZLhYUvrwgwiWND1 VvGXQOhaeCQcu/Sx1DaQeLFms4GebwgEHAtTdXRQG3+y/sWpoH4hU1hkhQ2RL2Re03ei Op+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+7sNnDMFw4VIZsLXOrJLZvpnECNNbNnsIn5HyYP9TH8=; b=ZwCw57MySiA8lpDU4iXVOP9I1TFjHxTZFrT44yfg3Bn7WSrp2Kh2yQIQlJzqYR+aBJ FhEf7LFEuA309bBeU9vtAe5Ar2evka2HUJH7yEsLh+4EhbvYjL53hgwXf9xCbNcA2oBl KZ58DFmiXkRHSN2kAItWRAEb9w1278oph162Yzlj9LKUnq8tqrVKFwS0s43hpm0UHBNZ V6R4VM6MZx/mZ6l+N95056ZWxiAkZ14k+osKE/8Qyc+AcMQo1j3ciAF4m8Kg4XDUGTTO IxU1HE1C/9ZgSEqimaqXErDi/RXK2pvOnYwxW/UYo9Ra8B8opa124jSgS5wgo/I6Befe oM1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=ZwK21aCK; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d12si13268611pga.506.2019.01.09.09.05.26; Wed, 09 Jan 2019 09:05:42 -0800 (PST) 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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=ZwK21aCK; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726710AbfAIRCU (ORCPT + 99 others); Wed, 9 Jan 2019 12:02:20 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:44532 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbfAIRCT (ORCPT ); Wed, 9 Jan 2019 12:02:19 -0500 Received: by mail-oi1-f196.google.com with SMTP id m6so6843635oig.11 for ; Wed, 09 Jan 2019 09:02:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+7sNnDMFw4VIZsLXOrJLZvpnECNNbNnsIn5HyYP9TH8=; b=ZwK21aCKJy3sN9O9+FB6O5TtQVui4KsvCS4DIJr1cIH02xEhwhaUlQNfNK+40SK0co sAJCljM+wAQozgzPqPr9ByJDneqCHGL28A4qVs15kmX272rrqHAr4fVVFCC0jHVZATr2 jYibFBr2R8Cq58bn3DMHlYF1kfWhRhr9t5DVksJuRdnJm1T/1ZRMT7nlTfDbIe7K89FT rfghw8w1Uwx3+RbHwZT9VzfcozyWnkaMNjTh7xyaFgfRpOkZYj+BYqfImpJ5gYrBfoq6 mKpMgS5f29My91FxV+MxlEuIMMnYepvn3UlDGgqLXa6Tlu4QLrS0aK5oVkkNaT+6xSQu j7wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+7sNnDMFw4VIZsLXOrJLZvpnECNNbNnsIn5HyYP9TH8=; b=W1vJukXlJpyUISzm1g8Dfty9trFSiW+mHHLR/spF6RowN9CywI6W2vqnOmirPbcvlN 7dkE0ZWl7anAGCWIF09uSB5RqZUnYbk7AN8fWES63Fiu3CyAqsSwBDcs7O8+B0OQFRgb OQ+EhwW2sJB9WBNNtphTStt4sJFdyWlkv7yrZOxH5N2sgvH6zDQv8M2uLr5oUwGnjgj4 zMT1NHxCvcGo5mHUkCsjrWdAb3wpc8926HWLjiqUE4fl6dfyIi/wvjSyWpTLo4nWB5pH /wBJEDUzaGSKsxx/n9yRtX6PrL6LtvAUdkmM7KMkL16qlQkXFQDdvJBvWQhTUOcWtPDw 21Zw== X-Gm-Message-State: AJcUukfT3QBCelaxVAIfa+1Xy+pwMrUdbDfETn76GpTCThOJRXGzVifn LNHeNAunT2mk9FYCFc5Ec31rw/mr360kqOX/iWdDdg== X-Received: by 2002:aca:f4c2:: with SMTP id s185mr4547835oih.244.1547053338706; Wed, 09 Jan 2019 09:02:18 -0800 (PST) MIME-Version: 1.0 References: <20190109135024.14093-1-pagupta@redhat.com> <20190109135024.14093-4-pagupta@redhat.com> In-Reply-To: <20190109135024.14093-4-pagupta@redhat.com> From: Dan Williams Date: Wed, 9 Jan 2019 09:02:07 -0800 Message-ID: Subject: Re: [PATCH v3 3/5] libnvdimm: add nd_region buffered dax_dev flag To: Pankaj Gupta Cc: Linux Kernel Mailing List , KVM list , Qemu Developers , linux-nvdimm , linux-fsdevel , virtualization@lists.linux-foundation.org, Linux ACPI , linux-ext4 , linux-xfs , Jan Kara , Stefan Hajnoczi , Rik van Riel , Nitesh Narayan Lal , Kevin Wolf , Paolo Bonzini , Ross Zwisler , Vishal L Verma , Dave Jiang , David Hildenbrand , jmoyer , Xiao Guangrong , Christoph Hellwig , "Michael S. Tsirkin" , Jason Wang , lcapitulino@redhat.com, Igor Mammedov , Eric Blake , Matthew Wilcox , "Theodore Ts'o" , Andreas Dilger , "Darrick J. Wong" , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 9, 2019 at 5:53 AM Pankaj Gupta wrote: > > This patch adds 'DAXDEV_BUFFERED' flag which is set > for virtio pmem corresponding nd_region. This later > is used to disable MAP_SYNC functionality for ext4 > & xfs filesystem. > > Signed-off-by: Pankaj Gupta > --- > drivers/dax/super.c | 17 +++++++++++++++++ > drivers/nvdimm/pmem.c | 3 +++ > drivers/nvdimm/region_devs.c | 7 +++++++ > drivers/virtio/pmem.c | 1 + > include/linux/dax.h | 9 +++++++++ > include/linux/libnvdimm.h | 6 ++++++ > 6 files changed, 43 insertions(+) > > diff --git a/drivers/dax/super.c b/drivers/dax/super.c > index 6e928f3..9128740 100644 > --- a/drivers/dax/super.c > +++ b/drivers/dax/super.c > @@ -167,6 +167,8 @@ enum dax_device_flags { > DAXDEV_ALIVE, > /* gate whether dax_flush() calls the low level flush routine */ > DAXDEV_WRITE_CACHE, > + /* flag to disable MAP_SYNC for virtio based host page cache flush */ > + DAXDEV_BUFFERED, > }; > > /** > @@ -335,6 +337,21 @@ bool dax_write_cache_enabled(struct dax_device *dax_dev) > } > EXPORT_SYMBOL_GPL(dax_write_cache_enabled); > > +void virtio_pmem_host_cache(struct dax_device *dax_dev, bool wc) > +{ > + if (wc) > + set_bit(DAXDEV_BUFFERED, &dax_dev->flags); > + else > + clear_bit(DAXDEV_BUFFERED, &dax_dev->flags); > +} > +EXPORT_SYMBOL_GPL(virtio_pmem_host_cache); The "write_cache" property was structured this way because it can conceivably change at runtime. The MAP_SYNC capability should be static and never changed after init. > +bool virtio_pmem_host_cache_enabled(struct dax_device *dax_dev) > +{ > + return test_bit(DAXDEV_BUFFERED, &dax_dev->flags); > +} > +EXPORT_SYMBOL_GPL(virtio_pmem_host_cache_enabled); Echoing Darrick and Jan this is should be a generic property of a dax_device and not specific to virtio. I don't like the "buffered" designation as that's not accurate. There may be hardware reasons why a dax_device is not synchronous, like a requirement to flush a write-pending queue or otherwise notify the device of new writes. I would just have a dax_synchronous() helper and a DAXDEV_SYNC flag. I would also modify alloc_dax() to take a flags argument so that the capability can be instantiated when the dax_device is allocated.