Received: by 10.192.165.148 with SMTP id m20csp2378261imm; Thu, 26 Apr 2018 09:59:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx49PZgYSoGo6dfo+pcs/shoJQHW0+9t7dKygu7azPmWbcRJRsg1z7BRYESngB8QpjF1LT54u X-Received: by 2002:a17:902:2924:: with SMTP id g33-v6mr32404059plb.26.1524761997001; Thu, 26 Apr 2018 09:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524761996; cv=none; d=google.com; s=arc-20160816; b=K9ABXlDrdRtBjW8tnGk1n1GY1xRVcpFKDNiPNY8PAo86RRzruPm7YwhFhoc3E8coIN nbRa1aiXiUXRy6+gSf2kGzD0NTy36V2Tp69qvxBiK5/uL3eWnv9lAuWuZ3qBeRzQLZhb dHF9CcwDMAQv/NRjrkyxoyrnO0a0i9bXdISaQjrGF02d4A62vbUjyd2Fp7HcSbkWMOyt L82cKodJGZGpI2gjCI25/w50u1iAxuOkDDuvKQr8GGWNZgHCsRR8WeZj7t1iUKZEBFAn ON51HjSJFTa0cDz5Tpj9s09q20JG0ZM1cTrFnvRh+0IEPgZo/CX0r7M4S/JJujPGDLws QnJQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Tw8o7ZJCEiAESMSzsMhHRmXG3gFJZg5zOpmFI4YydxE=; b=RnN64JInWwprSMHRdQZNv05/3MttOGnnnaJCMb5EJAjQkdcY+01EpcTscrQNaimaAf XFBAtG5V/DNmqt11Ji9IbVBx+1xD5Baag3mT6Z0qBeSL3RnXowlg2+QjMA00ZtCFhnyN SapdFO/Z0yKZlqK6ajBhc1QhVDjBzHtzvniCjA1Es/eCr5Gg9Ma4jdE7dOtL5sMfGz8f l93F1Wefu+74de6N0e3Iy/dbFVUw9GI/2aIY7FwGPvorpwan/3Rrp+cN8Piuk/vtbad/ KHGMWKYo3yMFZuSanIzygdzrmbbUcAlCPdFtlXWqi7Gdh0uAow2VLUzbk14z6Hx1CuWa JSqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=B2PmWyeD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 125si16335480pge.133.2018.04.26.09.59.43; Thu, 26 Apr 2018 09:59:56 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=B2PmWyeD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757178AbeDZQ6B (ORCPT + 99 others); Thu, 26 Apr 2018 12:58:01 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:36764 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756779AbeDZQ5q (ORCPT ); Thu, 26 Apr 2018 12:57:46 -0400 Received: by mail-oi0-f68.google.com with SMTP id v2-v6so10999567oif.3 for ; Thu, 26 Apr 2018 09:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Tw8o7ZJCEiAESMSzsMhHRmXG3gFJZg5zOpmFI4YydxE=; b=B2PmWyeDBcFmD1T9Mn1yY1+ynG9Wui1IFq3j2ajkH8ME+sCRIRN639DJx+f6Q0RMKE /s4l2RQH0vmaLoPeLCvlXFY8RkWe8SCzCHqA5dcBonYwgEuxfyDRmbe0Kn6ga4t5JGPf DiECOg4HT1wTHUNzQu05nW3mh8vinmrXHV7oPl92ua9gynEZ48FkFpn095cxDzBUXM9g FiBc2kR6mniRwGa3b1YV7KILz/CJIY/gNPWiyLrpU0BrIZG2fV6abqPJybkIQ0tAW2y/ /TlGan3Ze4o0bqqDES8m53TmRYWDmaTsCd8qMJIhMIqDgom1E1vxT8kz3RX3AyUQd83t wpYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Tw8o7ZJCEiAESMSzsMhHRmXG3gFJZg5zOpmFI4YydxE=; b=KSeGEodqO51niLqpiFYWDZJ3jIhEBlqUHo5h2dpIesi89sQcrhI1WX00bFiFoQwbIr 8lcBpIvHrkFLEXqqE5P71yIpYopgkc28dVi9OrcdTnUmK/3nb4gB8qFs/tAESnSK+CSU Hh6eRZhtV2b5WKrdn1SlWPI36f6QGB/1Dcnihk5qP5sbNWYmWyeF6YixVBEg1X7qBn04 IzebzBF/hAJYuRwEuRjfwDhCLIDbUI1nFWskcV6jFuMCc93DjWAUr+PQywAiKGZXgLKx Fw9edfRpHwGHpj9gAABaHVU8XzeqdBvkVpoavKfTj7IY5ryncEhHQn1cgGQTeCnOU0ON Ho/g== X-Gm-Message-State: ALQs6tDaExOllNc6GlPnv4Dl1StjXcL736xGEeg/B02tIvfvr0nQnLX9 qxaCxUb1n/mkqnkbNI8bU9NelIdGLRZ2pE0qUp7T6Q== X-Received: by 2002:aca:dd06:: with SMTP id u6-v6mr19834924oig.295.1524761866231; Thu, 26 Apr 2018 09:57:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2d36:0:0:0:0:0 with HTTP; Thu, 26 Apr 2018 09:57:45 -0700 (PDT) In-Reply-To: <58645254.23011245.1524760853269.JavaMail.zimbra@redhat.com> References: <20180425112415.12327-1-pagupta@redhat.com> <20180425112415.12327-3-pagupta@redhat.com> <20180426131517.GB30991@stefanha-x1.localdomain> <58645254.23011245.1524760853269.JavaMail.zimbra@redhat.com> From: Dan Williams Date: Thu, 26 Apr 2018 09:57:45 -0700 Message-ID: Subject: Re: [RFC v2 2/2] pmem: device flush over VIRTIO To: Pankaj Gupta Cc: Stefan Hajnoczi , Linux Kernel Mailing List , KVM list , Qemu Developers , linux-nvdimm , Linux MM , Jan Kara , Stefan Hajnoczi , Rik van Riel , haozhong zhang , Nitesh Narayan Lal , Kevin Wolf , Paolo Bonzini , ross zwisler , David Hildenbrand , xiaoguangrong eric , Christoph Hellwig , Marcel Apfelbaum , "Michael S. Tsirkin" , niteshnarayanlal@hotmail.com, Igor Mammedov , lcapitulino@redhat.com 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 Thu, Apr 26, 2018 at 9:40 AM, Pankaj Gupta wrote: > >> >> On Wed, Apr 25, 2018 at 04:54:14PM +0530, Pankaj Gupta wrote: >> > This patch adds functionality to perform >> > flush from guest to hosy over VIRTIO >> > when 'ND_REGION_VIRTIO'flag is set on >> > nd_negion. Flag is set by 'virtio-pmem' >> > driver. >> > >> > Signed-off-by: Pankaj Gupta >> > --- >> > drivers/nvdimm/region_devs.c | 7 +++++++ >> > 1 file changed, 7 insertions(+) >> > >> > diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c >> > index a612be6..6c6454e 100644 >> > --- a/drivers/nvdimm/region_devs.c >> > +++ b/drivers/nvdimm/region_devs.c >> > @@ -20,6 +20,7 @@ >> > #include >> > #include "nd-core.h" >> > #include "nd.h" >> > +#include >> > >> > /* >> > * For readq() and writeq() on 32-bit builds, the hi-lo, lo-hi order is >> > @@ -1074,6 +1075,12 @@ void nvdimm_flush(struct nd_region *nd_region) >> > struct nd_region_data *ndrd = dev_get_drvdata(&nd_region->dev); >> > int i, idx; >> > >> > + /* call PV device flush */ >> > + if (test_bit(ND_REGION_VIRTIO, &nd_region->flags)) { >> > + virtio_pmem_flush(&nd_region->dev); >> > + return; >> > + } >> >> How does libnvdimm know when flush has completed? >> >> Callers expect the flush to be finished when nvdimm_flush() returns but >> the virtio driver has only queued the request, it hasn't waited for >> completion! > > I tried to implement what nvdimm does right now. It just writes to > flush hint address to make sure data persists. nvdimm_flush() is currently expected to be synchronous. Currently it is sfence(); write to special address; sfence(). By the time the second sfence returns the data is flushed. So you would need to make this virtio flush interface synchronous as well, but that appears problematic to stop the guest for unbounded amounts of time. Instead, you need to rework nvdimm_flush() and the pmem driver to make these flush requests asynchronous and add the plumbing for completion callbacks via bio_endio(). > I just did not want to block guest write requests till host side > fsync completes. You must complete the flush before bio_endio(), otherwise you're violating the expectations of the guest filesystem/block-layer. > > be worse for operations on different guest files because all these operations would happen > ultimately on same file at host. > > I think with current way, we can achieve an asynchronous queuing mechanism on cost of not > 100% sure when fsync would complete but it is assured it will happen. Also, its entire block > flush. No, again, that's broken. We need to add the plumbing for communicating the fsync() completion relative the WRITE_{FLUSH,FUA} bio in the guest.