From patchwork Fri Oct 13 12:46:03 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: 10004635 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 263BB60360 for ; Fri, 13 Oct 2017 13:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18E5E2909E for ; Fri, 13 Oct 2017 13:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D37C2909B; Fri, 13 Oct 2017 13:00:34 +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=unavailable 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 844E9290A3 for ; Fri, 13 Oct 2017 13:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758170AbdJMMrZ (ORCPT ); Fri, 13 Oct 2017 08:47:25 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:48926 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758151AbdJMMrV (ORCPT ); Fri, 13 Oct 2017 08:47:21 -0400 Received: by mail-wm0-f68.google.com with SMTP id i124so21102868wmf.3 for ; Fri, 13 Oct 2017 05:47:20 -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=Cd+Z+XLXEGbc2Sb/VT5NciMIDZcxep7cMPoonccr7T4=; b=LSH1lLSRwDv/dAzfaMd+jt5JZJAxK+L3S9H5/b0UFRLwcB1o15bCNTTupLhSh9x8pD chDNH0hW4yu++Ag/NvRHZ0t1PAQ5nusnR5mI7rYjLpCqpxDD9J4Qb8AItMHPbSKIdO3Q ewXrPvckUCRvyPzoKYBZgls1ZGUaabo9FBlL4= 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=Cd+Z+XLXEGbc2Sb/VT5NciMIDZcxep7cMPoonccr7T4=; b=t1/S7JZyyzt7JAB3ysMEpiUC/gihK9H9uubKgqcDDg45mN71PYcznI+TMNrEZisLa5 k96GoL6ApxLCEQT90l6V+Fen9ytIwnGOLzYRRgmYcB0ebjDkZQ27UR9gfaC0aCDKEve6 bJznzRQ58AhuL/aFoq86p0ozKyOl+Nz+NWks9EDkSX24QAgL6tIWwT2dbfJJQWWrfYas 1L3g8lQpLcdvlezK81p1/BYl/Phc8dI8LsFVeUG8qyaHK/M4csEnIFBMTTBr0yuiu76N zeNv3gheAAK5VbtFFDsCXms6vFwuyQ0cr0wZlIQNCXYLkF4BlO0lfwsETZQcpyVAkebs 5YJQ== X-Gm-Message-State: AMCzsaVe/HGfIs2nngtWrvS7WsglzYBFphcGpFLV4Rh28vgPqqufKE0y m5rVWPxfLPjVZmxvLR53sugXcw== X-Google-Smtp-Source: AOwi7QCKCIxjZ+VpaE88hhEgs2xC8g1gKO4d9fNc9A4q4zZbGKJqvI8404NOPYQMCMXyPxxbGFlfmw== X-Received: by 10.80.201.12 with SMTP id o12mr1982367edh.98.1507898839945; Fri, 13 Oct 2017 05:47:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:19 -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 14/58] lightnvm: pblk: free padded entries in write buffer Date: Fri, 13 Oct 2017 14:46:03 +0200 Message-Id: <20171013124647.32668-15-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 When a REQ_FLUSH reaches pblk, the bio cannot be directly completed. Instead, data on the write buffer is flushed and the bio is completed on the completion pah. This might require some sectors to be padded in order to guarantee a successful write. This patch fixes a memory leak on the padded pages. A consequence of this bad free was that internal bios not containing data (only a flush) were not being completed. Fixes: a4bd217b4326 ("lightnvm: physical block device (pblk) target") Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 1 - drivers/lightnvm/pblk-write.c | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index a68c6ae..9299a5a 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -190,7 +190,6 @@ void pblk_bio_free_pages(struct pblk *pblk, struct bio *bio, int off, WARN_ON(off + nr_pages != bio->bi_vcnt); - bio_advance(bio, off * PBLK_EXPOSED_PAGE_SIZE); for (i = off; i < nr_pages + off; i++) { bv = bio->bi_io_vec[i]; mempool_free(bv.bv_page, pblk->page_pool); diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index 3ad9e56..d89ac57 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -33,6 +33,10 @@ static unsigned long pblk_end_w_bio(struct pblk *pblk, struct nvm_rq *rqd, bio_endio(original_bio); } + if (c_ctx->nr_padded) + pblk_bio_free_pages(pblk, rqd->bio, c_ctx->nr_valid, + c_ctx->nr_padded); + #ifdef CONFIG_NVM_DEBUG atomic_long_add(c_ctx->nr_valid, &pblk->sync_writes); #endif @@ -521,7 +525,8 @@ static void pblk_free_write_rqd(struct pblk *pblk, struct nvm_rq *rqd) struct bio *bio = rqd->bio; if (c_ctx->nr_padded) - pblk_bio_free_pages(pblk, bio, rqd->nr_ppas, c_ctx->nr_padded); + pblk_bio_free_pages(pblk, bio, c_ctx->nr_valid, + c_ctx->nr_padded); } static int pblk_submit_write(struct pblk *pblk)