From patchwork Fri Jun 21 09:11:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 11008831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE0C26C5 for ; Fri, 21 Jun 2019 09:12:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE539289DA for ; Fri, 21 Jun 2019 09:12:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2932289E5; Fri, 21 Jun 2019 09:12:20 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 60C54289DA for ; Fri, 21 Jun 2019 09:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbfFUJMT (ORCPT ); Fri, 21 Jun 2019 05:12:19 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:38099 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbfFUJML (ORCPT ); Fri, 21 Jun 2019 05:12:11 -0400 Received: by mail-lf1-f67.google.com with SMTP id b11so4515841lfa.5 for ; Fri, 21 Jun 2019 02:12:09 -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=wGWPck9wpyZRR3E02z/BR5xB8SDUTdEAXPWir9EA+Iw=; b=w6zy5RcYtlwpn9uZXBTPnNqk13OWqgW/Z2IEW/b5Va7tVCdbZbgJ0Cnouiv1j8bK7K bWDV6rGP+wes+RvdAIhBg3cRGlsDMwzbX/6Pfp6zyqHpiYqTGnTFvLM0Pg65iaGyGe9S wL+Qtd2PN1OIZ6m+5zeoMcbz9V58AEbYH7Ozo007qVRWkc4c0o/JWGYAueBfZWH3kyVJ GiMfrOUImqgt+6PJ9Mmm3Q25GZAXsoP7p0h+TeEEOa9HMFuROrH4kUTSFef/409yBtpA SZksPiF4DLQ6yesYrrSClVK54ohgnvbcEUQAx3MFCpdpHzGuDwlT14kmhEqQv6OX076f LdMQ== 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=wGWPck9wpyZRR3E02z/BR5xB8SDUTdEAXPWir9EA+Iw=; b=Beru1fdCY3DE0VCn9FyCkHdkT6qBGehq4Fuli7HyNgHL34LFFIkszfc8+DX+eJnbpi wZdv/oQwB+8BouDrK9HjTM9RNGVEK7aca9Moj964Jfxomy86xOtwJGj4w9g6qYyX/5t8 Hi3WHFZDXkcCniBP3ro+Q6yg9/WuvG/H5pX1cbOvscx2ngWva8unUavV5kZ4WDdXhNpL iCBzpLBlK3UCXFergk16QmMFbNiRC1idLm2tdza1/rJNNJc0rXanFGl6V88g9eh8/38V pkjm3FhTQZszHSiQX9jrM1aQMMMahQUlBR68GPA9OdVig/dJ0jhgQDWfHnGDcH9kfG7a aipQ== X-Gm-Message-State: APjAAAUHePAXLBl+d/TnpjSwvmFhBKb5mVXjihdHuUh2G7W7CHzxxQZs eqR0zbQY0zlClDAXi0K8UQ9ElA== X-Google-Smtp-Source: APXvYqwEQaPtv/AT8pgQU9n75IZ6a1nGoS44tadH/5E9dMkzEJyY5mAnoUx0dj0rJvAXeL1ic/ruZA== X-Received: by 2002:a19:d5:: with SMTP id 204mr1954825lfa.66.1561108328971; Fri, 21 Jun 2019 02:12:08 -0700 (PDT) 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 z26sm303178ljz.64.2019.06.21.02.12.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 02:12:08 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Heiner Litz , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 1/2] lightnvm: pblk: fix freeing of merged pages Date: Fri, 21 Jun 2019 11:11:59 +0200 Message-Id: <20190621091200.23168-2-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190621091200.23168-1-mb@lightnvm.io> References: <20190621091200.23168-1-mb@lightnvm.io> 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: Heiner Litz 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 --- drivers/lightnvm/pblk-core.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 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; + struct bio_vec *bv; + struct page *page; + int i, e, nbv = 0; - 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); + 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); } }