Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5068313imm; Tue, 26 Jun 2018 05:29:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZIbcb7Eh3uTVQ+PRNQ7IwbZk39oMGzM1k+uEY+AU7TRmv+csmVf3eVXet4bcN00KWkalf X-Received: by 2002:a63:7d7:: with SMTP id 206-v6mr1192431pgh.137.1530016142379; Tue, 26 Jun 2018 05:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530016142; cv=none; d=google.com; s=arc-20160816; b=tmeTW30BRgwrxQYa0VLftQSy+1XRZPU8p3Co7Ic36TdRdl2xqw5zcZT9Mycq5qVaDX rwwsc1PbgZ7b1LLLtBG7rVqSOtvtO24Ymhua1Qf3VBST+HY0xWuQAos+uJyBPSld+EFt nUeWg/OhIJUxdpyIvexrAxvFZ9KO2ZtwltDMg/GWeSyAMidqsRgMzUwOBJWyvK+07eoV OwBkHwvUjiuCohw8TqOQPPwV/38yAayafS2K8G4hCAGn5n+7CjmneUIYcuEKE46n8BND 6duVALCpSBvRIhlD+vNjbWiP95HjWWsBw16nY2eOfJDyKaW5oauXe6rG3xE9lL6qWxZb SlTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=uTTDf/OjNj79FSCvDOl6BXjS5FofBA1ikoNLA4as9Co=; b=m72Pq/ItaSb7wwus8PycuYW8P6snGOHFXcei3Quw33o3chBPpzdRPhCOynrPA9RrWs rKHKTkGn9ed/+rZ2z5yxvuKgM0VIgfQ8MMncwJ4MD5Wtx/Br1e/xSATaT1SBVr4f7vWJ rpjCiLQ+hdVWFeheQvzl4yRh1vr2pD3qJVdv9BFcXM4XpUFVBuQhDITZvr6F03GImUgh h1bYVUz5WJs029Q0sb9RLoTxxBvle/pX/RsMX7bKyzil1P6d6ii29us7/FZ7ypR0B952 bxGzykYO/SfjxwnVw21nYSPovzaCetFB20Thh88JaQfIsxxqBS9ZEzReW4Nq/vMWAbVv p9jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Lx9aGm0c; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e39-v6si1476083plg.168.2018.06.26.05.28.47; Tue, 26 Jun 2018 05:29:02 -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=@gmail.com header.s=20161025 header.b=Lx9aGm0c; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964845AbeFZM1E (ORCPT + 99 others); Tue, 26 Jun 2018 08:27:04 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:41984 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933509AbeFZM1D (ORCPT ); Tue, 26 Jun 2018 08:27:03 -0400 Received: by mail-lf0-f66.google.com with SMTP id u202-v6so5064338lff.9; Tue, 26 Jun 2018 05:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=uTTDf/OjNj79FSCvDOl6BXjS5FofBA1ikoNLA4as9Co=; b=Lx9aGm0c/ZGzjfu6KiDIStpyYjKFmblaLRJn/CGLoCZjIrA7FSfTMEcooC9R4w5pLO QLH6wunLaxiXAjMnEiC7KA+OVHJADweRu0ZDu5Qun5HbNdFcvLa0nYzvbzqyY9hMIKZs PC8NKONqVYQYzxtPX2XDnOo+6rALEZ5X+BKusI3DvxkgHim0DvqYmGo0iNftvR8fPIQC 8oSjQmNo8KzoawDCFLtTzfof57UETYvfeRc4as8zzUanP5DE61fu1VQhBvrbAnvKH57/ 6SlrmQJ/skeSGyYNTO8d8koBICOK2E00YvwkKvedccBTFYR0RXlIYM3q9KvGwv7DUcaZ IHnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=uTTDf/OjNj79FSCvDOl6BXjS5FofBA1ikoNLA4as9Co=; b=HQGtxBUh2/ia9KWndtoc1bchWYsolG+4Bf9orT7dGrzsD0nB2uL8vYOwgakWG4iSiA A5O7B4zK7ktC3zD2xMk9+/oMmCJ0JP4aX49BYcBNQWxX36z/fpHaYZfm+54zbsH2H6cP cK/2YBZTBlFnCiqgdZ7I7CH1sU9p5g7F97ftrD5R4tlFTxT2pYhlyb6m3byd/jBfdTO5 f1KIHb//lV2H+UY7NC5RzpmPLyiNSPW1/bFcNgJ2iYuaD9Ib4SLg06yYwqjENjnqrwEZ QmwQBuJ+BRHFl9DA6fh3dMMn2Zhzzq8f2d38P24neTmh/G+wltDbiWskTTiK+t3vGET2 Cw1w== X-Gm-Message-State: APt69E0gbnhhMJ5lpfzk+NBxLU9Yx3nPuEjVbqtiRFicNbx4SAb/5BIJ qu8N+nSVd5n86V09KJc+hjK2Tklv X-Received: by 2002:a19:ed0c:: with SMTP id y12-v6mr1221241lfy.91.1530016021376; Tue, 26 Jun 2018 05:27:01 -0700 (PDT) Received: from [192.168.1.31] (83-94-206-14-cable.dk.customer.tdc.net. [83.94.206.14]) by smtp.gmail.com with ESMTPSA id n79-v6sm168412lfi.51.2018.06.26.05.27.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jun 2018 05:27:00 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] lightnvm: pblk: assume that chunks are closed on 1.2 devices From: =?utf-8?Q?Javier_Gonz=C3=A1lez?= X-Mailer: iPhone Mail (15F79) In-Reply-To: Date: Tue, 26 Jun 2018 14:26:58 +0200 Cc: javier@cnexlabs.com, hans.ml.holmberg@owltronix.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, hans.holmberg@cnexlabs.com Content-Transfer-Encoding: quoted-printable Message-Id: <04C28867-8D30-4031-B7F0-3BD2A5D9B3D7@gmail.com> References: <1529399189-3239-1-git-send-email-hans.ml.holmberg@owltronix.com> <1612C143-24C3-4B6F-B745-945EAF684DFC@cnexlabs.com> <4bcd22df-3899-fc87-d558-27754befae5e@lightnvm.io> To: =?utf-8?Q?Matias_Bj=C3=B8rling?= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 26 Jun 2018, at 14.13, Matias Bj=C3=B8rling wrote: >=20 > On 06/26/2018 01:54 PM, Javier Gonzalez wrote: >>> On 26 Jun 2018, at 13.44, Matias Bj=C3=B8rling wrote: >>>=20 >>>>> On 06/26/2018 01:31 PM, Hans Holmberg wrote: >>>>>> On Tue, Jun 26, 2018 at 1:38 PM, Matias Bj=C3=B8rling wrote: >>>>>> On 06/26/2018 11:37 AM, Javier Gonzalez wrote: >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>>> On 26 Jun 2018, at 10.41, Matias Bj=C3=B8rling wrot= e: >>>>>>>=20 >>>>>>> On 06/19/2018 11:06 AM, Hans Holmberg wrote: >>>>>>>>=20 >>>>>>>> From: Hans Holmberg >>>>>>>> We can't know if a block is closed or not on 1.2 devices, so assume= >>>>>>>> closed state to make sure that blocks are erased before writing. >>>>>>>> Fixes: 32ef9412c114 ("lightnvm: pblk: implement get log report chun= k") >>>>>>>> Signed-off-by: Hans Holmberg >>>>>>>> --- >>>>>>>> This patch applies on: >>>>>>>> ssh://github.com/OpenChannelSSD/linux branch for-4.19/core >>>>>>>> drivers/lightnvm/pblk-init.c | 5 +++-- >>>>>>>> 1 file changed, 3 insertions(+), 2 deletions(-) >>>>>>>> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-i= nit.c >>>>>>>> index aa24264..3b8aa4a 100644 >>>>>>>> --- a/drivers/lightnvm/pblk-init.c >>>>>>>> +++ b/drivers/lightnvm/pblk-init.c >>>>>>>> @@ -717,10 +717,11 @@ static int pblk_setup_line_meta_12(struct pbl= k >>>>>>>> *pblk, struct pblk_line *line, >>>>>>>> /* >>>>>>>> * In 1.2 spec. chunk state is not persisted by the= >>>>>>>> device. Thus >>>>>>>> - * some of the values are reset each time pblk is >>>>>>>> instantiated. >>>>>>>> + * some of the values are reset each time pblk is >>>>>>>> instantiated, >>>>>>>> + * so we have to assume that the block is closed. >>>>>>>> */ >>>>>>>> if (lun_bb_meta[line->id] =3D=3D NVM_BLK_T_FREE) >>>>>>>> - chunk->state =3D NVM_CHK_ST_FREE; >>>>>>>> + chunk->state =3D NVM_CHK_ST_CLOSED; >>>>>>>> else >>>>>>>> chunk->state =3D NVM_CHK_ST_OFFLINE; >>>>>>>>=20 >>>>>>>=20 >>>>>>> pblk should scan (or the lightnvm subsystem) the blocks for their >>>>>>> state, such that it doesn't have to reinitialize a full drive if it i= s >>>>>>> already in a closed state. If marking closed, it does a full erase >>>>>>> cycle on initialization, which should be avoided since it is a limit= ed >>>>>>> resource. >>>>>>=20 >>>>>>=20 >>>>>> In 1.2 there is no such state unfortunately. However, pblk will never= >>>>>> attempt to reinitialize the whole drive - metadata for closed blocks >>>>>> will be recovered and only those going to GC will be erased before >>>>>> usage. In fact, a full close drive is the state pblk expects. >>>>>>=20 >>>>>> This patch only affects "unknown blocks", thus the only case in which= >>>>>> pblk would attempt to double erase is when blocks have been pre-erase= d >>>>>> (e.g., factory or through liblightnvm). After an erase round though, >>>>>> pblk will only erase pre-usage. One thing we could do is attempting t= o >>>>>> read the first page of these unknown blocks and mark them as free if >>>>>> "empty page" is returned. Is this what you mean? >>>>>=20 >>>>>=20 >>>>> Yes, that is what I mean. >>>>>=20 >>>>> Note that this can be >>>>>>=20 >>>>>> costly on large drives; this is the reason we returned to the pre-2.0= >>>>>> behaviour with this patch. We are implementing a log that, among othe= r >>>>>> things, keeps the state so that pblk can have an accurate state for t= he >>>>>> cases this can be a problem. >>>>>=20 >>>>>=20 >>>>> Yep, it will take some time. Good to hear with the log. >>>> Until we have a log in place, this patch unbreaks 1.2 support and has >>>> no negative impact on performance (as compared to pre 2.0 support), so >>>> please consider it for the next window. >>>> The current state is that if a pblk instance is created on a 1.2 disk >>>> with written blocks, writes will fail. >>>> / Hans >>>=20 >>> The negative impact is that all blocks are erased, even if they are in f= ree state. This is a showstopper. We cannot throw out 1/X of the lifetime of= the drive on each initialization. The 1.2 spec is made such that a scan can= recover the block state accurately. >> This fixes patch returns to the original behavior, so it=E2=80=99s not in= troducing a worse behavior than before 2.0. But you=E2=80=99re right, it is n= ot the way it should be. >> Can you consider taking this as a fix for 4.18 to avoid writes failing on= 1.2 devices and I promise to send a patch this week to implement the state b= ased on reads? This new patch would be for 4.19. >> Javier >=20 > Okay, sounds good to me. Thanks Thanks! Javier=