From patchwork Wed Sep 6 10:51:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 9940367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 03C926038C for ; Wed, 6 Sep 2017 10:54:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F013428B97 for ; Wed, 6 Sep 2017 10:54:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4F2828B9C; Wed, 6 Sep 2017 10:54:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C57728B98 for ; Wed, 6 Sep 2017 10:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380AbdIFKyK (ORCPT ); Wed, 6 Sep 2017 06:54:10 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:35653 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753366AbdIFKww (ORCPT ); Wed, 6 Sep 2017 06:52:52 -0400 Received: by mail-wm0-f41.google.com with SMTP id f199so7945594wme.0 for ; Wed, 06 Sep 2017 03:52:51 -0700 (PDT) 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=0FXfR5Ouz5+kO5DQ+aMzNiFxlKKUS8LIwbxCONEccvE=; b=sG5v0Yhlij2AU002tW3HyoiRZEFCVeBPnWjcxzuahXSfLA5QUdhSemKNWZ/KisyFKz KGmwlq4QyCng1tjsrqsDTCJkt5isjdaPDhTErLnYfxmrsALDWqAzT1ISPmuP831hqw90 39QpzVy+vnW/ShEQazN+Ugm2V1uCKN3Iow2/3l606jPv+egcC6cgBxoz67T5PDV5W4XK QqR3wSebtxExs2yrYbPVGLTBHv/sINnhT6hWKGIUr0I3LmNDvt+H8nB9/ifsW+SthbfG 4xTlfdzg4OGNYz1TS4AbuE2xopuo+nzqAqdTaNVLBKXwXuAWt6dQBDZivpRNl+h7tT7T IlSQ== 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=0FXfR5Ouz5+kO5DQ+aMzNiFxlKKUS8LIwbxCONEccvE=; b=pJzY0ncOvVMWZP0PAM/Y3QdddnLccYUJrpnGPdaSmUgxkV4vKSOcn+YIFniQf2fCfe qMM5FVpNI18kMIuVgv5HG6wRP9aBoCtOfOC+ORh6do41hNHXef4K+0epFb/Q9ai7SP5K 5hRDaelfPzjTNRF0Kn81sRkeCt5UMCD6tsqyPRMW+6m1wJexKc5yG8IK5DHcXOURA0ij xgNX3i8CpB2NblKa5uy3G3GFBc7Wv7ZoWY2p5qMWQZcfarwPguO+/WruyZUaSgn1owoh 3yAGZB0YLUk2VA+xRAQmHLDUHw8HZbsYUpZQ2ckJBRmkXb4/6mGKsqetJFKuLMdp8hE1 c5Ag== X-Gm-Message-State: AHPjjUhgqIT7/kqltWFC/sEb2glin2Ordg4hlhWUaP1bQicaLjRfOQy0 DjSDxOIEzgMoxF0p X-Google-Smtp-Source: ADKCNb477n9/A70Sx7zexEkEqRltJKfDN9l/HDBnTSsvgJRHXuYH2a8iUVakmsVSxlGiKs0+Lpr4Og== X-Received: by 10.80.177.78 with SMTP id l14mr5876310edd.9.1504695170600; Wed, 06 Sep 2017 03:52:50 -0700 (PDT) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id b8sm1044007edi.46.2017.09.06.03.52.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Sep 2017 03:52:50 -0700 (PDT) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io, axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 15/18] lightnvm: pblk: avoid deadlock on low LUN config Date: Wed, 6 Sep 2017 12:51:08 +0200 Message-Id: <1504695071-25928-16-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504695071-25928-1-git-send-email-javier@cnexlabs.com> References: <1504695071-25928-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On low LUN configurations, make sure not to send bios that are bigger than the buffer size. Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-init.c | 2 +- drivers/lightnvm/pblk-rl.c | 6 ++++++ drivers/lightnvm/pblk.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 8459434edd89..12c05aebac16 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -46,7 +46,7 @@ static int pblk_rw_io(struct request_queue *q, struct pblk *pblk, * user I/Os. Unless stalled, the rate limiter leaves at least 256KB * available for user I/O. */ - if (unlikely(pblk_get_secs(bio) >= pblk_rl_sysfs_rate_show(&pblk->rl))) + if (pblk_get_secs(bio) > pblk_rl_max_io(&pblk->rl)) blk_queue_split(q, &bio); return pblk_write_to_cache(pblk, bio, PBLK_IOTYPE_USER); diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c index 2e6a5361baf0..596bdec433c3 100644 --- a/drivers/lightnvm/pblk-rl.c +++ b/drivers/lightnvm/pblk-rl.c @@ -178,6 +178,11 @@ int pblk_rl_sysfs_rate_show(struct pblk_rl *rl) return rl->rb_user_max; } +int pblk_rl_max_io(struct pblk_rl *rl) +{ + return rl->rb_max_io; +} + static void pblk_rl_u_timer(unsigned long data) { struct pblk_rl *rl = (struct pblk_rl *)data; @@ -214,6 +219,7 @@ void pblk_rl_init(struct pblk_rl *rl, int budget) /* To start with, all buffer is available to user I/O writers */ rl->rb_budget = budget; rl->rb_user_max = budget; + rl->rb_max_io = budget >> 1; rl->rb_gc_max = 0; rl->rb_state = PBLK_RL_HIGH; diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 2304a4891f20..2ae9d94e9852 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -273,6 +273,7 @@ struct pblk_rl { int rb_gc_max; /* Max buffer entries available for GC I/O */ int rb_gc_rsv; /* Reserved buffer entries for GC I/O */ int rb_state; /* Rate-limiter current state */ + int rb_max_io; /* Maximum size for an I/O giving the config */ atomic_t rb_user_cnt; /* User I/O buffer counter */ atomic_t rb_gc_cnt; /* GC I/O buffer counter */ @@ -846,6 +847,7 @@ int pblk_rl_gc_may_insert(struct pblk_rl *rl, int nr_entries); void pblk_rl_gc_in(struct pblk_rl *rl, int nr_entries); void pblk_rl_out(struct pblk_rl *rl, int nr_user, int nr_gc); int pblk_rl_sysfs_rate_show(struct pblk_rl *rl); +int pblk_rl_max_io(struct pblk_rl *rl); void pblk_rl_free_lines_inc(struct pblk_rl *rl, struct pblk_line *line); void pblk_rl_free_lines_dec(struct pblk_rl *rl, struct pblk_line *line); void pblk_rl_set_space_limit(struct pblk_rl *rl, int entries_left);