From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuOG-0002Dc-Oh for qemu-devel@nongnu.org; Tue, 11 Apr 2017 07:55:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxuOB-0005cy-PD for qemu-devel@nongnu.org; Tue, 11 Apr 2017 07:55:20 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:34534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxuOB-0005cY-Ip for qemu-devel@nongnu.org; Tue, 11 Apr 2017 07:55:15 -0400 Received: by mail-pf0-x241.google.com with SMTP id o126so12840054pfb.1 for ; Tue, 11 Apr 2017 04:55:13 -0700 (PDT) References: <20170331084147.32716-1-haozhong.zhang@intel.com> <20170331084147.32716-3-haozhong.zhang@intel.com> <20170411082237.4wd5anbqab6pzlz2@hz-desktop> <20170411082928.kpzw3pd5cweqyjt5@hz-desktop> From: Xiao Guangrong Message-ID: <337474c2-59f4-a3e6-fd40-e468e7bc4c22@gmail.com> Date: Tue, 11 Apr 2017 19:55:04 +0800 MIME-Version: 1.0 In-Reply-To: <20170411082928.kpzw3pd5cweqyjt5@hz-desktop> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 2/4] nvdimm: add functions to initialize and perform flush on back store List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, dan.j.williams@intel.com, Xiao Guangrong , Igor Mammedov , "Michael S. Tsirkin" On 04/11/2017 04:29 PM, Haozhong Zhang wrote: > On 04/11/17 16:22 +0800, Haozhong Zhang wrote: >> On 04/06/17 19:52 +0800, Xiao Guangrong wrote: >>> >>> >>> On 03/31/2017 04:41 PM, Haozhong Zhang wrote: >>>> fsync() is used to persist modifications to the back store. If the >>>> host NVDIMM is used as the back store, fsync() on Linux will trigger >>>> the write to the host flush hint address. >>>> >>>> Signed-off-by: Haozhong Zhang >>>> --- >>>> hw/mem/nvdimm.c | 22 ++++++++++++++++++++++ >>>> include/hw/mem/nvdimm.h | 13 +++++++++++++ >>>> 2 files changed, 35 insertions(+) >>>> >>>> diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c >>>> index db896b0..484ab8b 100644 >>>> --- a/hw/mem/nvdimm.c >>>> +++ b/hw/mem/nvdimm.c >>>> @@ -78,6 +78,26 @@ static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm) >>>> return &nvdimm->nvdimm_mr; >>>> } >>>> >>>> +static void nvdimm_flush_init(NVDIMMDevice *nvdimm, MemoryRegion *hostmem_mr) >>>> +{ >>>> + if (nvdimm->flush_hint_enabled) { >>>> + nvdimm->backend_fd = memory_region_get_fd(hostmem_mr); >>> >>> Hmm, IIRC host-mem-file does not initalize backend_fd at all. >> >> Oops, forgot to add this part. Thanks for remind. > > Sorry, I replied too quick. > > For hostmem-file, hostmem_mr->ram_block->fd is set in file_ram_alloc(), > which can be got by memory_region_get_fd() here. Okay, my wrong memory and did not check the code during patch review. :)