Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9985190ybi; Wed, 24 Jul 2019 13:33:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy87ciYoBNiWEY0HN+kxXGJOOc/0tBF9Fk/dwTiIvZCgRZMdNJekDa1/0jbzJ/YLykJVyeu X-Received: by 2002:a63:3fc9:: with SMTP id m192mr84623556pga.429.1564000432580; Wed, 24 Jul 2019 13:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000432; cv=none; d=google.com; s=arc-20160816; b=NfEWDhoT8Z44ee9naiPZ5rFQI8rXdFTrAuk7M1VbK2acCyLTtnGJt7WIrl3fnqojkI 9u8cThTohuyYzax1uSMcIH6SzuBBfkapr2YPBdxAvB9dHkeIA8+H5n4G+OmoymNnlPJi 3oFHqN+xkYjq+q1tzMC3R57cZJFjk8DtP5672RnJMYKtEeOkxzTtDguOSbpmC604YApH i94x/6/PozSFm7fPdY+Doj45+naZWVtS8a1wDi8fawJzBsf7nWJUlNXiTU7xZCtA57Wz pTo1y+xCFA5sBsjaT5nGCBFQAE9+unfbuCc+sGroUvI9m8cSUGZeEDhiCzOx+rL8D9xq EudQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WSiFZBhxZ2011svNrBZJpJNbXcCpB0e7aLN4QDG2oMc=; b=BBqgh3FF9U+pmPRzTGSdtpdkuOtME3/IJ+GW48XUyArgnSpcpTywGxSzJiGALU+DGl Gtd7onXErKVTJKQlryoLYsYHUXaiXAA6RnciWpiQY0SRE4EN6P9CMqHXM+O556Pia2c7 Wc0M8DCXcniHzgwsEl5exdklE3smNta3Be6orIdW+q3AqtuCz6T/ilYImDeJgLTc9lF/ 7au9+NtLUenQXRxdsrT1QT8KNJX+a1D1FggikG5sxkDADiQjiQWThkBkIkTRlBIVIPFZ O91eFQ9ORzMvJMTFVBusXici0NtY/NgfRcwfm+AqI7yu+YQUEqPFvO75hzN+qX7pUUIM ZYmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ACheZDsJ; 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 s21si15965804pfe.204.2019.07.24.13.33.38; Wed, 24 Jul 2019 13:33:52 -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=@kernel.org header.s=default header.b=ACheZDsJ; 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 S2387798AbfGXT3F (ORCPT + 99 others); Wed, 24 Jul 2019 15:29:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:47888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfGXT3D (ORCPT ); Wed, 24 Jul 2019 15:29:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D540120659; Wed, 24 Jul 2019 19:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996542; bh=lbwTJGIjsyqiHonf4g089OTdUtPd+ByjP3cSadNmAnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ACheZDsJVCKTcshcYn1qUPi2x/F1a+Hjmpn+tDzWS0jy4WG0pmo55xUwdKy9q10+7 HpgbKzphpxtsoTUkqu532xn3tOAIP8uGSYQtUaeLBd+ZaYdYp7WCByDeVzSO5KSq6H U6jDlrkr13YRWX/3pFiill95kxvgv6bqA1l1OQe0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiner Litz , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= , Jens Axboe , Sasha Levin Subject: [PATCH 5.2 134/413] lightnvm: pblk: fix freeing of merged pages Date: Wed, 24 Jul 2019 21:17:05 +0200 Message-Id: <20190724191744.598999361@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 510fd8ea98fcb586c01aef93d87c060a159ac30a ] bio_add_pc_page() may merge pages when a bio is padded due to a flush. Fix iteration over the bio to free the correct pages in case of a merge. Signed-off-by: Heiner Litz Reviewed-by: Javier González Signed-off-by: Matias Bjørling Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/lightnvm/pblk-core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 773537804319..f546e6f28b8a 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -323,14 +323,16 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int type) void pblk_bio_free_pages(struct pblk *pblk, struct bio *bio, int off, int nr_pages) { - struct bio_vec bv; - int i; - - WARN_ON(off + nr_pages != bio->bi_vcnt); - - for (i = off; i < nr_pages + off; i++) { - bv = bio->bi_io_vec[i]; - mempool_free(bv.bv_page, &pblk->page_bio_pool); + struct bio_vec *bv; + struct page *page; + int i, e, nbv = 0; + + for (i = 0; i < bio->bi_vcnt; i++) { + bv = &bio->bi_io_vec[i]; + page = bv->bv_page; + for (e = 0; e < bv->bv_len; e += PBLK_EXPOSED_PAGE_SIZE, nbv++) + if (nbv >= off) + mempool_free(page++, &pblk->page_bio_pool); } } -- 2.20.1