From patchwork Fri Oct 13 12:46:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 10004445 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 7A24260216 for ; Fri, 13 Oct 2017 12:47:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BB7328FD4 for ; Fri, 13 Oct 2017 12:47:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60A4A29057; Fri, 13 Oct 2017 12:47:30 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 E9EFE28FD4 for ; Fri, 13 Oct 2017 12:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758149AbdJMMr1 (ORCPT ); Fri, 13 Oct 2017 08:47:27 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:57255 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758164AbdJMMrW (ORCPT ); Fri, 13 Oct 2017 08:47:22 -0400 Received: by mail-wm0-f66.google.com with SMTP id l68so21509846wmd.5 for ; Fri, 13 Oct 2017 05:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=au//LLeLKqgF4ml6yLU/HjX/d4pPod+BCaYsKNCs1Pw=; b=rg7zW2+VN142ByjG6Nm2bujWZgZh5nDLs4f7jMbQvyLx9/WdlIbwiR5tgGitrEKynU w1QGso2bMIXdPDHokGRhjtln/wEuQMwMWsrmtwVgs8NvaJ9JHU1HpE8u+7MXG142lsYs CirhBRcJKjNdUGielJb1/Phf5tmQo4Kc3HeZc= 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=au//LLeLKqgF4ml6yLU/HjX/d4pPod+BCaYsKNCs1Pw=; b=P4HX93zOVUGlmLoweKj6SYi5p7MTp9vQCjkBZkNP3B3v7ZDxo9dO4X9dPKGICpOIbV /UpCRTv5w5Eu/QucASTOf8R5cxaEBYMLJqD0fraex8NjsQj8dbIfmwMmf9tnAaWSLZu5 6zEsoPGvAwOChmYKsADHvBoYxirnwFnSPplUZUIsMFutgBxGutUMVenmiB0NSRNELjaA A7zeTcRnHlU/h6umjGIWe/z90u5UVnQ5t9VscjBxfUKe5kjzr4XpI3SpgZqWoyEW8tgm 32yJWp0cawugps4X493X9hgN2ri0S/2Nh9H0e59aEGOl+SBQnlb9k1Z8Ok6htQim5KP2 z2AA== X-Gm-Message-State: AMCzsaUd1fre1/2YRYAC93r+1XAIiOKz8brWhmukR8nJRw3ScFMBEDtW b5Ln6oxPPMVV3EACPj+J6WB/X4eD X-Google-Smtp-Source: AOwi7QB625KLveZOlTl1YCO/NnIXx6ypnJqmaN0y1UTBM64f9JRNdnfeCrirstJaITi3r7arhVvetw== X-Received: by 10.80.212.133 with SMTP id s5mr2054984edi.286.1507898841759; Fri, 13 Oct 2017 05:47:21 -0700 (PDT) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id p91sm735012edp.69.2017.10.13.05.47.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:21 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: 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: [GIT PULL 16/58] lightnvm: pblk: avoid deadlock on low LUN config Date: Fri, 13 Oct 2017 14:46:05 +0200 Message-Id: <20171013124647.32668-17-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171013124647.32668-1-m@bjorling.me> References: <20171013124647.32668-1-m@bjorling.me> 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 From: Javier González On low LUN configurations, make sure not to send bios that are bigger than the buffer size. Fixes: a4bd217b4326 ("lightnvm: physical block device (pblk) target") 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 8344511..eee4eeb 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 9565c3b..0896439 100644 --- a/drivers/lightnvm/pblk-rl.c +++ b/drivers/lightnvm/pblk-rl.c @@ -163,6 +163,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; @@ -199,6 +204,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 3a07c5b..b592e51 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -267,6 +267,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 */ @@ -844,6 +845,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);