Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5053999imm; Tue, 26 Jun 2018 05:14:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcRLPp1Z6BnktA/QGWO7WVaWxq9ofKjcmRetPM+unZmxP+ZvxaWUlVPxCjyrWsDjGVFvVQD X-Received: by 2002:a62:8995:: with SMTP id n21-v6mr1294469pfk.83.1530015287829; Tue, 26 Jun 2018 05:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530015287; cv=none; d=google.com; s=arc-20160816; b=O/t/AudySxdZ3LFJTFcxO7S1HWjWORq9HbMC8Msh8fzVh52r/Bvo7u8WQRIBdoN07A vhImTs1WD1XH4DO/tPZy0VPVkuXJ+m+EUMizFarQUHK2Qqp6vthLRD3pUf20ipTfGGw3 zrD1F/DLRM2ZWoh9aMeIoJ4YFkuZMswourblNjzbvKKxSOvQuvy9x56GD5yJ6slIKtqO SXPVh8TRV4Nw/bE7hN2X6zJUzYy4XD4PkQ3u8h7InppoKB2Fef6ffz2QDmhfZgCYUcD9 NEurrrjjkjHcJoByimcEBCBpgLQPvoyoI5fDdGaqbW6pmiMK/ktbb20l36DHaMaNa2CZ D9Bg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=QDBrm/nyR+1KXV+JW8VIKI+5dLKJUiPxsi5eNl8aDso=; b=bYvny9d0kbfPE3VV7uf/FGjsgOm8MJVYmiRBULhSht483EvNYgKtwMyzon3T0GZwYH ATJ4THh4GMcOkvSLMDdDyZcua8CoZO3t7rFJ45/T1k6Ix/f1j5B0GjYVeq0GJpeoxUDS ocUJscWyO6ft7c0D3qeD3qmJzMsw4vJZ3aAV0N5hR4ZxoPbYk8mOM923Rqm/fl7yfhm1 g1OMrnEHkCJU8Eu6r/18GXmf8bgzNEVpHqrD2y28SI8hrPCvXwzNc2YB/v0FYxHNtxDn eTbssU69mbNRWwRGZmUQE59jTqN5s3pYkypROxAViHEkGS8t2/5lUdHVsjPkItuqcTzN aOyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=K6Prq22A; 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 e39-v6si1476083plg.168.2018.06.26.05.14.33; Tue, 26 Jun 2018 05:14:47 -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=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=K6Prq22A; 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 S935428AbeFZMNh (ORCPT + 99 others); Tue, 26 Jun 2018 08:13:37 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:33588 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935110AbeFZMNe (ORCPT ); Tue, 26 Jun 2018 08:13:34 -0400 Received: by mail-pl0-f65.google.com with SMTP id 6-v6so8446386plb.0 for ; Tue, 26 Jun 2018 05:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=QDBrm/nyR+1KXV+JW8VIKI+5dLKJUiPxsi5eNl8aDso=; b=K6Prq22A0FqkUiQLfs1p5cYdEsnd6nFkCeAXRMzdKK1vlqFnHDjvBxh7us6z1WkzD8 dhKjeaXdPmIpMr3DybPdSywjYeoZLhYoqayqCuWvElcwdtXZ/vPa2m5jSogme6E9f2Wo BONDb1LftRrStrztAkW7hobNIgJlTMf2uLo2TXR9WuvgKW7l5s/DN1R6E+gsb54xV0FN Rp5Sz+KSDYojyBko67QgDxtp8jWt+VLd28BupCk2Oi6k6bZ4Cscbdj8NcqQ5i7pgUnSp TL7ldXKATKIoiNCUjftkEeU6EpbW92jdClp4RfsyluGXzy8W+gAc+qx6/9e2Us2PloMB wBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QDBrm/nyR+1KXV+JW8VIKI+5dLKJUiPxsi5eNl8aDso=; b=ZIUlvLmCQDi+fhKIvSvwIWrkhyl+zPl9LZkBJIO6H+T5vi0JwbskAL8o/EcrGCrCck 4i0rpMf1bQgKuBhz1bYxG0SXmb71qE+2+9jjJfm9/qPIxNQObZwJMV7vJ38SB1bdpQTN ok0CXuEnutMsT2Iw4tDEyl67cxUqt1q2qpe8Jp5WMndjpYM8Lgg7ok0NHsqKb8qJltBC a7Iqj2+uj4y/Spf56HTx/CMGfNM8BQ4QFyDh0L87eWjogjT1KKEyLV83jdlXuxJHSZg4 Jb77qFHqa/c6i8BGnmJhfQfkTl9Ls5VDGkHCvZX+Z9AIeGNsL+aSLj8lA4cFWNC+mKGW mBBw== X-Gm-Message-State: APt69E1rwRtvfGEZquQG8XgGvfz9IVCUKMH9j8lrwH6Ziy3QWTlAtgBt uzfoLJXVUI6Bt/dcqUJrqtr45Q== X-Received: by 2002:a17:902:2702:: with SMTP id c2-v6mr297309plb.297.1530015214202; Tue, 26 Jun 2018 05:13:34 -0700 (PDT) Received: from [10.86.48.245] (rap-us.hgst.com. [199.255.44.250]) by smtp.googlemail.com with ESMTPSA id n26-v6sm3018715pfi.168.2018.06.26.05.13.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jun 2018 05:13:33 -0700 (PDT) Subject: Re: [PATCH] lightnvm: pblk: assume that chunks are closed on 1.2 devices To: javier@cnexlabs.com Cc: hans.ml.holmberg@owltronix.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, hans.holmberg@cnexlabs.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> From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: Date: Tue, 26 Jun 2018 14:13:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/26/2018 01:54 PM, Javier Gonzalez wrote: > >> On 26 Jun 2018, at 13.44, Matias Bjørling wrote: >> >>> On 06/26/2018 01:31 PM, Hans Holmberg wrote: >>>> On Tue, Jun 26, 2018 at 1:38 PM, Matias Bjørling wrote: >>>>> On 06/26/2018 11:37 AM, Javier Gonzalez wrote: >>>>> >>>>> >>>>> >>>>>> On 26 Jun 2018, at 10.41, Matias Bjørling wrote: >>>>>> >>>>>> On 06/19/2018 11:06 AM, Hans Holmberg wrote: >>>>>>> >>>>>>> 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 chunk") >>>>>>> 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-init.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 pblk >>>>>>> *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] == NVM_BLK_T_FREE) >>>>>>> - chunk->state = NVM_CHK_ST_FREE; >>>>>>> + chunk->state = NVM_CHK_ST_CLOSED; >>>>>>> else >>>>>>> chunk->state = NVM_CHK_ST_OFFLINE; >>>>>>> >>>>>> >>>>>> 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 is >>>>>> already in a closed state. If marking closed, it does a full erase >>>>>> cycle on initialization, which should be avoided since it is a limited >>>>>> resource. >>>>> >>>>> >>>>> 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. >>>>> >>>>> This patch only affects "unknown blocks", thus the only case in which >>>>> pblk would attempt to double erase is when blocks have been pre-erased >>>>> (e.g., factory or through liblightnvm). After an erase round though, >>>>> pblk will only erase pre-usage. One thing we could do is attempting to >>>>> read the first page of these unknown blocks and mark them as free if >>>>> "empty page" is returned. Is this what you mean? >>>> >>>> >>>> Yes, that is what I mean. >>>> >>>> Note that this can be >>>>> >>>>> 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 other >>>>> things, keeps the state so that pblk can have an accurate state for the >>>>> cases this can be a problem. >>>> >>>> >>>> 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 >> >> The negative impact is that all blocks are erased, even if they are in free 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’s not introducing a worse behavior than before 2.0. But you’re right, it is not 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 based on reads? This new patch would be for 4.19. > > Javier > Okay, sounds good to me. Thanks