Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2525868imj; Mon, 11 Feb 2019 04:26:20 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia0/aY0nPZzjdGJcssF9ehv7Z6NXr28OLs8GOO5+am9FAq5qeeXn1Fn1xsgsWZSsykrrTO4 X-Received: by 2002:a63:ce50:: with SMTP id r16mr32616802pgi.217.1549887980015; Mon, 11 Feb 2019 04:26:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549887980; cv=none; d=google.com; s=arc-20160816; b=Fkx5u8xsbncqFb2zOJNHV1wtIE9hewvGVWbfLIpzGb/sBUzbj9zE6xBjxGERWHppxr CAVMKem9tZdh2LodTX+ALt5pV/E1QyA5QVSHQcNp1uQOHHA/RBymK6x5faqyk6qumKXk J20oHGZnoJ4/k/FW4yGXBicJAH7Rf8p8WF44xYAg+1dlj8io9IkwqmP74DR4oGoXIUev SVBrJDJVtB+BQKIai9QGraHLbF2K85htqvXdGLHXSurB/jdVeomu0bHBReV9d7nTOMcv BATZZ2a3oeTHTrxpmXexSmEjWS+7xi0E83pSlv1To7vuE/hWnJ+OZOnM3XZWc5vll3gY PcJQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=horUJaYN1AtPap9Tf3+ti1ICSvr2tumzRYfiNboXyUE=; b=r1FnvHY0eNzZKaHdsq/1ZxbvlOecfFCC7+xsqP+JtbyJuIRFFC53GaVfWW6aq81zo9 +2Nne7Ay1Td+oa30tvqAa7tYngdxC61m6/kTob/i0kyumiApMflAHSvQoH3r/eTJ7h6s poeHQciLAjxgHEV7GjSNbJ1GmjjKNmEfaqpslyfrTF1UVaDIBV3L0tAhN6UwvMvTyoDt 0Dyz6jDx2VoupcskWnk8UQXqbuAQh61tZmEAHFYNBxhcKwiK7FI58iJwNbhDojNltt5O 5FJSm+WvqFJWIjWW5PdPqq1CNJn58Z3T7Chl8/4c3wQSKtIcKwsOiBwnEqfJvqeTG9HN 6SDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=qdkB2bHQ; 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 ay7si9838889plb.410.2019.02.11.04.26.04; Mon, 11 Feb 2019 04:26:20 -0800 (PST) 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=qdkB2bHQ; 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 S1727383AbfBKMZe (ORCPT + 99 others); Mon, 11 Feb 2019 07:25:34 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36348 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727352AbfBKMZa (ORCPT ); Mon, 11 Feb 2019 07:25:30 -0500 Received: by mail-lf1-f66.google.com with SMTP id q11so7590631lfd.3 for ; Mon, 11 Feb 2019 04:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=horUJaYN1AtPap9Tf3+ti1ICSvr2tumzRYfiNboXyUE=; b=qdkB2bHQC/o2xcAnKZMyX7sQM6OtYJVunYcRuZpTUU5MWef4Wu/5X7VcEHyruwl2DJ aiHkB/BV4PVUjVABDCT2ui+/3H+mkiJNGBqxNuEmOyTWkxP12wIopAZGOMRiUcra48EK pxEnFE38dJgZul2XO+jq3pY/NLMntCuolNkI0zVX1BtEtAI39DqbQeN0NyWAruQm7l/V aCGoxbQT+181G1LNP9mEO9dG9OSrDL3ZcUr+gg3HKc3H17d5WoN2vYAaAd2Jg/5AFJ1Y 6qs5Y2L/EPuGcKFVgifa6vTSeQ+NRNq8UP6IaYfQl19F/RCb72C8GHIcOUZ/FxScDn+Q qIGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=horUJaYN1AtPap9Tf3+ti1ICSvr2tumzRYfiNboXyUE=; b=CJ5wbYGgVCyfSBWAqgX4JAKhz/jRiR9lQiIkDyYQYpaOKRf2Bc9wCMxGAXsI12fvai j608FKrXxTTWJ6oazYRQw5F0eLabXlEH2GTF982mXD+nLe4wLRLn0yvcFScZxVkdwk9N e8E4RVopxleDRi3yKute/8gQ0rX0mAQ1M6jcYL1Um8xQsmM0YSVYqwx+MO7Zt769apNE doNrAYUCDwIlA3mOndNs69q5j7MMSN3oq6zpr5eEgxF/a6Ef5OopPgwaQ8dkr+SaeIGa 5kK5/G5wNAkWsyqafkZZ8azXMRlYibXWfyeEXspbkFv5nEZKJyHgqBLGAlQqiiRqbkM7 dNWA== X-Gm-Message-State: AHQUAuaxBlr/Da+WbdlQhAhhb0db1xngukqYPWiVJOYaFYj9uPGzSC0J GJs6FvjSexo2JkkqgHDJnga+9A== X-Received: by 2002:ac2:5085:: with SMTP id f5mr21611025lfm.30.1549887928681; Mon, 11 Feb 2019 04:25:28 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:27 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 6/8] lightnvm: pblk: extend line wp balance check Date: Mon, 11 Feb 2019 13:25:07 +0100 Message-Id: <20190211122509.19910-7-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Holmberg pblk stripes writes of minimal write size across all non-offline chunks in a line, which means that the maximum write pointer delta should not exceed the minimal write size. Extend the line write pointer balance check to cover this case, and ignore the offline chunk wps. This will render us a warning during recovery if something unexpected has happened to the chunk write pointers (i.e. powerloss, a spurious chunk reset, ..). Reported-by: Zhoujie Wu Tested-by: Zhoujie Wu Reviewed-by: Javier González Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-recovery.c | 56 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index 6761d2afa4d0..d86f580036d3 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -302,35 +302,55 @@ static int pblk_pad_distance(struct pblk *pblk, struct pblk_line *line) return (distance > line->left_msecs) ? line->left_msecs : distance; } -static int pblk_line_wp_is_unbalanced(struct pblk *pblk, - struct pblk_line *line) +/* Return a chunk belonging to a line by stripe(write order) index */ +static struct nvm_chk_meta *pblk_get_stripe_chunk(struct pblk *pblk, + struct pblk_line *line, + int index) { struct nvm_tgt_dev *dev = pblk->dev; struct nvm_geo *geo = &dev->geo; - struct pblk_line_meta *lm = &pblk->lm; struct pblk_lun *rlun; - struct nvm_chk_meta *chunk; struct ppa_addr ppa; - u64 line_wp; - int pos, i; + int pos; - rlun = &pblk->luns[0]; + rlun = &pblk->luns[index]; ppa = rlun->bppa; pos = pblk_ppa_to_pos(geo, ppa); - chunk = &line->chks[pos]; - line_wp = chunk->wp; + return &line->chks[pos]; +} - for (i = 1; i < lm->blk_per_line; i++) { - rlun = &pblk->luns[i]; - ppa = rlun->bppa; - pos = pblk_ppa_to_pos(geo, ppa); - chunk = &line->chks[pos]; +static int pblk_line_wps_are_unbalanced(struct pblk *pblk, + struct pblk_line *line) +{ + struct pblk_line_meta *lm = &pblk->lm; + int blk_in_line = lm->blk_per_line; + struct nvm_chk_meta *chunk; + u64 max_wp, min_wp; + int i; - if (chunk->wp > line_wp) + i = find_first_zero_bit(line->blk_bitmap, blk_in_line); + + /* If there is one or zero good chunks in the line, + * the write pointers can't be unbalanced. + */ + if (i >= (blk_in_line - 1)) + return 0; + + chunk = pblk_get_stripe_chunk(pblk, line, i); + max_wp = chunk->wp; + if (max_wp > pblk->max_write_pgs) + min_wp = max_wp - pblk->max_write_pgs; + else + min_wp = 0; + + i = find_next_zero_bit(line->blk_bitmap, blk_in_line, i + 1); + while (i < blk_in_line) { + chunk = pblk_get_stripe_chunk(pblk, line, i); + if (chunk->wp > max_wp || chunk->wp < min_wp) return 1; - else if (chunk->wp < line_wp) - line_wp = chunk->wp; + + i = find_next_zero_bit(line->blk_bitmap, blk_in_line, i + 1); } return 0; @@ -356,7 +376,7 @@ static int pblk_recov_scan_oob(struct pblk *pblk, struct pblk_line *line, int ret; u64 left_ppas = pblk_sec_in_open_line(pblk, line) - lm->smeta_sec; - if (pblk_line_wp_is_unbalanced(pblk, line)) + if (pblk_line_wps_are_unbalanced(pblk, line)) pblk_warn(pblk, "recovering unbalanced line (%d)\n", line->id); ppa_list = p.ppa_list; -- 2.19.1