Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3633639ybt; Tue, 30 Jun 2020 07:44:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQKkcalFoUkBmnTImXOyVo+F7JKn69RaIekyd+Yn1dfi05zBt0SXq8vxfNZIryM+n+p09B X-Received: by 2002:a17:906:915:: with SMTP id i21mr18766298ejd.313.1593528272171; Tue, 30 Jun 2020 07:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593528272; cv=none; d=google.com; s=arc-20160816; b=gMXeWFpvuoDK9Uo5CgDfvbie73arHpyNe0ZPFTZhexIu2hkr6U/riTkuqMXKKfuefZ 47Rm1fqUNTY82Fd5T2FgjMwvAVQ4DnEMge8tyPS+v2wswhptDy0d52SLdY6fmcH2K0YV DbzPe/d0cJEAA2+UpaSgcSvm42aCly77SlBzqukesaOsCmkF1mwdrVjiCcR9noPqghk/ AV5MpyzlWYhkML/Q6BA22poLOC0jkjbkl8c2LWUUXHZthJ3RwmveZI+qQ1Fp0KrmT9+i lTJ/gPEhfk0d9+wIKXjYeulpV4d1WNDt3ahncfdbEUURQ8LR3Do0V4pC6Q3rvbVN5Hp5 zmPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=IROXVKUsfZyh0HVar6jmDbdiIlGqWmtU8R2zRYgMIrU=; b=nw8LH7m4vGHBU6iePzNC956T2HGY5DPsZVDlT8SHIIt2QH3vQysNInuHqFFl1oYeQh aJQ0jEkYN3FUNWntilqYfQ58ox1w1Xj+Xy+YegU3zT+nSwZ8+8FoaOI3DmNuWCd5mnQ+ dp6lv34KQD93bggPzto9KeJIxs1yp7oMkiq1K3iKNXTDgIsRAGUgqtiZld/lSuCxnizg 9MxeryAkIsSAsIwt/KQJD4hR+PQhE75xydkYnqhgMg6c5scwIjvLNGyA+mTYYmxFkusz mwC9tp9ai02DS4i7fX1isGvzaUvET8jF9GS0e6FOt36/JfJYiUAnIcfX2fqEtMAJjogT Zalw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk7si1241533edb.86.2020.06.30.07.44.09; Tue, 30 Jun 2020 07:44:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731825AbgF3On7 (ORCPT + 99 others); Tue, 30 Jun 2020 10:43:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:58852 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbgF3On7 (ORCPT ); Tue, 30 Jun 2020 10:43:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 06EF1AB3D; Tue, 30 Jun 2020 14:43:57 +0000 (UTC) Date: Tue, 30 Jun 2020 16:43:55 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Mike Snitzer Cc: Mikulas Patocka , linux-nvdimm@lists.01.org, "Aneesh Kumar K.V" , Jan Kara , Alasdair Kergon , dm-devel@redhat.com, "Michael S. Tsirkin" , Yuval Shaia , Cornelia Huck , Jakub Staron , linux-kernel@vger.kernel.org Subject: Re: dm writecache: reject asynchronous pmem. Message-ID: <20200630144355.GA21462@kitsune.suse.cz> References: <20200630123528.29660-1-msuchanek@suse.de> <20200630141022.GZ21462@kitsune.suse.cz> <20200630133546.GA20439@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200630133546.GA20439@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 09:36:33AM -0400, Mike Snitzer wrote: > On Tue, Jun 30 2020 at 10:10am -0400, > Michal Such?nek wrote: > > > On Tue, Jun 30, 2020 at 09:32:01AM -0400, Mikulas Patocka wrote: > > > > > > > > > On Tue, 30 Jun 2020, Michal Suchanek wrote: > > > > > > > The writecache driver does not handle asynchronous pmem. Reject it when > > > > supplied as cache. > > > > > > > > Link: https://lore.kernel.org/linux-nvdimm/87lfk5hahc.fsf@linux.ibm.com/ > > > > Fixes: 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver") > > > > > > > > Signed-off-by: Michal Suchanek > > > > --- > > > > drivers/md/dm-writecache.c | 6 ++++++ > > > > 1 file changed, 6 insertions(+) > > > > > > > > diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c > > > > index 30505d70f423..57b0a972f6fd 100644 > > > > --- a/drivers/md/dm-writecache.c > > > > +++ b/drivers/md/dm-writecache.c > > > > @@ -2277,6 +2277,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) > > > > > > > > wc->memory_map_size -= (uint64_t)wc->start_sector << SECTOR_SHIFT; > > > > > > > > + if (!dax_synchronous(wc->ssd_dev->dax_dev)) { > > > > + r = -EOPNOTSUPP; > > > > + ti->error = "Asynchronous persistent memory not supported as pmem cache"; > > > > + goto bad; > > > > + } > > > > + > > > > bio_list_init(&wc->flush_list); > > > > wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush"); > > > > if (IS_ERR(wc->flush_thread)) { > > > > -- > > > > > > Hi > > > > > > Shouldn't this be in the "if (WC_MODE_PMEM(wc))" block? > > That should be always the case at this point. > > > > > > WC_MODE_PMEM(wc) retrurns true if we are using persistent memory as a > > > cache device, otherwise we are using generic block device as a cache > > > device. > > > > This is to prevent the situation where we have WC_MODE_PMEM(wc) but > > cannot guarantee consistency because the async flush is not handled. > > The writecache operates in 2 modes. SSD or PMEM. Mikulas is saying > your dax_synchronous() check should go within a WC_MODE_PMEM(wc) block > because it doesn't make sense to do the check when in SSD mode. Indeed, it's in the wrong if/else branch. Thanks Michal