Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2082070yba; Sun, 5 May 2019 22:17:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/mKt1JONApPlnrLntWzxXKkiBB8mgyQzvHYLBiP4IVpJ97MHLZe+RulzSPoD4qBtujr6S X-Received: by 2002:a17:902:2ba6:: with SMTP id l35mr30005995plb.56.1557119851607; Sun, 05 May 2019 22:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557119851; cv=none; d=google.com; s=arc-20160816; b=A/AbQGUlNCE0P37oIZ0tVBMQdIGzR7kX86lJWYmtQ5+jpyBbgqVfgnwWioWYXuQAum HaltIAt99EUsdbnz86fxuZbA9n4dO3NrGxzCpRsVWduIBXBl7pANxi/7JsNclB0eIMSE uekeaRLgIJMqMvaBP6DCYIVC8JCzbICaAnZK2clDjh/hi0pI1Csv4LQ2ZAi4nOJJ0srM wzSzX/pcN4+g/SS9KuG3Sik7cD3Qnux4T+VtyIccE7CQI2+8Dwo8MYoZNOMIeN4kl8Df 2tW6qSsMQe5Xcv/zoU6ZAgPNh0TYs9z+lM7sFNd0rkggbOwPmgPXPMuGX+qbgWYOUAWI adOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jCh6x+ORi5EWv/IlypawahbbvpnK5RHTjISz62KuNKg=; b=gSG6A1uzeirOotTcTVyEb9tAuz8kdoKNqVCOyf4CF3bcteTOaAgnOUkw2vckiPW5Ni EjLciTEGkutHjiswQzMniCN9e61s+Cqt2v0OuI2m4CK3StkebtILz1kwG8AkRkhHQYjc EtlRsYOMzdSYVmLcpcY4f2dvxtfWWZs9eWfqrfl3n9D+q/VdTZ8/8r11VUKWfG7foQsR B7GH00FpZzMMA1jOjvDmhidXVyfDETV0gP7ouQKTuekLHJPO7Z7pF/7KlmKmH9WNaVwD riWnUaCPYqNPxJ99f7qFOp41BJ1cLvY3Buix6rXuz6dIjvfCF8maDzwkS4Man6pbrBir UmIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ucsc.edu header.s=ucsc-google-2018 header.b="O/PZC2uA"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ucsc.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1si13781111pgq.551.2019.05.05.22.17.15; Sun, 05 May 2019 22:17:31 -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=@ucsc.edu header.s=ucsc-google-2018 header.b="O/PZC2uA"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ucsc.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbfEFFQ1 (ORCPT + 99 others); Mon, 6 May 2019 01:16:27 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34872 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbfEFFQ1 (ORCPT ); Mon, 6 May 2019 01:16:27 -0400 Received: by mail-wr1-f68.google.com with SMTP id w12so2029696wrp.2 for ; Sun, 05 May 2019 22:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucsc.edu; s=ucsc-google-2018; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jCh6x+ORi5EWv/IlypawahbbvpnK5RHTjISz62KuNKg=; b=O/PZC2uANw4749yGxquasq82LLBwHsDNYDcytpi8MLvw8XUUWK3lDggrfpWl+FsV8S dNE8ALd6B+SRamBl6n6yaRzROVtPN6QRl7VO46g0bAmW+VBC7rBQ6TGbgOrLifoEBOiN aRSWUOFgTXgqNsYEjgN+golZVOJBQmJY+/EvLNRTdOIfdxsYsmyv8XvdoZW/WNTlRKn8 mLs8j003f2pqKvF8mfTL/Ra55S8bp9iLinYFxkxzCN5htz+REXwUZ2wmhrmf3KQzzYO5 QNLo+eJRbPgU/clyxPb03HGxYzpQRmMb8ZuKCJPVjj9/Hme17ypQ7+IEuu6ZlidXCIu+ yNng== 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:content-transfer-encoding; bh=jCh6x+ORi5EWv/IlypawahbbvpnK5RHTjISz62KuNKg=; b=AfeLOBaNP2fzPnZzrgE1O1AiqglqJJgHpcMnQekfL32ycvvTinewCJuy4fW8nOprc0 fcxDA2ETJZRY36Sse3UjVi8B1n+f5/bUZQ6/i1XAAiP+JYzbXo1hb5Xfx7qhAwytHBxz zkDEDTSFCYeusLPGMhk6vkTZOfe/GSiQwbaFSiJ1SvjFYVVOf7XkIUpRhN7wJn1scsGa N0M2hvCDFf+NHDDZpVOj4giGhZ6S+QDQ8FZHS+0HRLWftJVOVz1QXRKNb8wJNIqxRD1/ figZ87Z3uWv8djr6XjuZ+j4UcI6ptS6aarW9mTaiSMgIyzte8WAd7C7pOoZDUGwZo1Kj TQFA== X-Gm-Message-State: APjAAAULXaaNJBTjCIO46aYmY1iItPALPSS7lQZCxGRi9vte+1AXpcUn DgZ1tXI9RJHJ437wcpvWbtUCshZp7zjiKiFptCcUOg== X-Received: by 2002:adf:f9c5:: with SMTP id w5mr91669wrr.26.1557119784614; Sun, 05 May 2019 22:16:24 -0700 (PDT) MIME-Version: 1.0 References: <20190425052152.6571-1-hlitz@ucsc.edu> <66434cc7-2bac-dd10-6edc-4560e6a0f89f@intel.com> <139AF16B-E69C-4AA5-A9AC-38576BB9BD4B@javigon.com> In-Reply-To: From: Heiner Litz Date: Sun, 5 May 2019 22:16:13 -0700 Message-ID: Subject: Re: [PATCH] lightnvm: pblk: Introduce hot-cold data separation To: Igor Konopko Cc: =?UTF-8?Q?Javier_Gonz=C3=A1lez?= , =?UTF-8?Q?Matias_Bj=C3=B8rling?= , Hans Holmberg , linux-block@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Igor, Javier, both of you are right. Here is what I came up with after some more thinking= . We can avoid the races in 2. and 3. with the following two invariants: I1: If we have a GC line with seq_id X, only garbage collect from lines older than X (this addresses 2.) I2: Guarantee that the open GC line always has a smaller seq_id than all open user lines (this addresses 3) We can enforce I2 by adding a minor seq_id. The major sequence id is only incremented when allocating a user line. Whenever a GC line is allocated we read the current major seq_id (open user line) and increment the minor seq_id. This allows us to order all GC lines before the open user line during recovery. Problem with this approach: Consider the following example: There exist user lines U0, U1, U2 (where 0,1,2 are seq_ids) and a non-empty GC5 line (with seq_id 5). If we now do only sequential writes all user lines will be overwritten without GC being required. As a result, data will now reside on U6, U7, U8. If we now need to GC we cannot because of I1. Solution: We cannot fast-forward the GC line's seq_id because it contains old data, so pad the GC line with zeros, close it and open a new GC9 line. Generality: This approach extends to schemes that use e.g. hot, warm, cold open lines (adding a minor_minor_seq_id) Heiner On Thu, May 2, 2019 at 2:08 AM Igor Konopko wrot= e: > > > > On 01.05.2019 22:20, Heiner Litz wrote: > > Javier, Igor, > > you are correct. The problem exists if we have a power loss and we > > have an open gc and an open user line and both contain the same LBA. > > In that case, I think we need to care about the 4 scenarios: > > > > 1. user_seq_id > gc_seq_id and user_write after gc_write: No issue > > 2. user_seq_id > gc_seq_id and gc_write > user_write: Cannot happen, > > open user lines are not gc'ed > > Maybe it would be just a theoretical scenario, but I'm not seeing any > reason why this cannot happen in pblk implementation: > Let assume that user line X+1 is opened when GC line X is already open > and the user line is closed when GC line X is still in use. Then GC > quickly choose user line X+1 as a GC victim and we are hitting 2nd case. > > > 3. gc_seq_id > user_seq_id and user_write after gc_write: RACE > > 4. gc_seq_id > user_seq_id and gc_write after user_write: No issue > > > > To address 3.) we can do the following: > > Whenever a gc line is opened, determine all open user lines and store > > them in a field of pblk_line. When choosing a victim for GC, ignore > > those lines. > > Your solution sounds right, but I would extend this based on my previous > comment to 2nd case by sth like: during opening new user data also add > this line ID to this "blacklist" for the GC selection. > > Igor > > > > > Let me know if that sounds good and I will send a v2 > > Heiner > > > > On Tue, Apr 30, 2019 at 11:19 PM Javier Gonz=C3=A1lez wrote: > >> > >>> On 26 Apr 2019, at 18.23, Heiner Litz wrote: > >>> > >>> Nice catch Igor, I hadn't thought of that. > >>> > >>> Nevertheless, here is what I think: In the absence of a flush we don'= t > >>> need to enforce ordering so we don't care about recovering the older > >>> gc'ed write. If we completed a flush after the user write, we should > >>> have already invalidated the gc mapping and hence will not recover it= . > >>> Let me know if I am missing something. > >> > >> I think that this problem is orthogonal to a flush on the user path. F= or example > >> > >> - Write to LBA0 + completion to host > >> - [=E2=80=A6] > >> - GC LBA0 > >> - Write to LBA0 + completion to host > >> - fsync() + completion > >> - Power Failure > >> > >> When we power up and do recovery in the current implementation, you > >> might get the old LBA0 mapped correctly in the L2P table. > >> > >> If we enforce ID ordering for GC lines this problem goes away as we ca= n > >> continue ordering lines based on ID and then recovering sequentially. > >> > >> Thoughts? > >> > >> Thanks, > >> Javier > >> > >>> > >>> On Fri, Apr 26, 2019 at 6:46 AM Igor Konopko wrote: > >>>> On 26.04.2019 12:04, Javier Gonz=C3=A1lez wrote: > >>>>>> On 26 Apr 2019, at 11.11, Igor Konopko = wrote: > >>>>>> > >>>>>> On 25.04.2019 07:21, Heiner Litz wrote: > >>>>>>> Introduce the capability to manage multiple open lines. Maintain = one line > >>>>>>> for user writes (hot) and a second line for gc writes (cold). As = user and > >>>>>>> gc writes still utilize a shared ring buffer, in rare cases a mul= ti-sector > >>>>>>> write will contain both gc and user data. This is acceptable, as = on a > >>>>>>> tested SSD with minimum write size of 64KB, less than 1% of all w= rites > >>>>>>> contain both hot and cold sectors. > >>>>>> > >>>>>> Hi Heiner > >>>>>> > >>>>>> Generally I really like this changes, I was thinking about sth sim= ilar since a while, so it is very good to see that patch. > >>>>>> > >>>>>> I have a one question related to this patch, since it is not very = clear for me - how you ensure the data integrity in following scenarios: > >>>>>> -we have open line X for user data and line Y for GC > >>>>>> -GC writes LBA=3DN to line Y > >>>>>> -user writes LBA=3DN to line X > >>>>>> -we have power failure when both line X and Y were not written com= pletely > >>>>>> -during pblk creation we are executing OOB metadata recovery > >>>>>> And here is the question, how we distinguish whether LBA=3DN from = line Y or LBA=3DN from line X is the valid one? > >>>>>> Line X and Y might have seq_id either descending or ascending - th= is would create two possible scenarios too. > >>>>>> > >>>>>> Thanks > >>>>>> Igor > >>>>> > >>>>> You are right, I think this is possible in the current implementati= on. > >>>>> > >>>>> We need an extra constrain so that we only GC lines above the GC li= ne > >>>>> ID. This way, when we order lines on recovery, we can guarantee > >>>>> consistency. This means potentially that we would need several open > >>>>> lines for GC to avoid padding in case this constrain forces to choo= se a > >>>>> line with an ID higher than the GC line ID. > >>>>> > >>>>> What do you think? > >>>> > >>>> I'm not sure yet about your approach, I need to think and analyze th= is a > >>>> little more. > >>>> > >>>> I also believe that probably we need to ensure that current user dat= a > >>>> line seq_id is always above the current GC line seq_id or sth like t= hat. > >>>> We cannot also then GC any data from the lines which are still open,= but > >>>> I believe that this is a case even right now. > >>>> > >>>>> Thanks, > >>>>> Javier