Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp724407imm; Thu, 13 Sep 2018 06:52:20 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb8RkeB6EW06P77AByG+v2tk2RR4nqIWKd/wX4wGLAtosXGv1J008SbwBJvfbk6Tw+OeduT X-Received: by 2002:a62:2285:: with SMTP id p5-v6mr7602375pfj.53.1536846740110; Thu, 13 Sep 2018 06:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846740; cv=none; d=google.com; s=arc-20160816; b=dhAsCVA4KCB3s3OG3m67kgAsC+Bm3D2GuD9PkcAIjrGAkcPFRMfhDWFHr0B+omcZp4 O3Nq82I2nUQLNmx3YNMTqPlIXCFLxAzf1eL8FjkAeg407RGl0ZImVg/7f0TCDS7W6F6g b9NuhEQUyu+OHPNLFs05wBlHFJPvErNkR3W+9MpRqgo1+tdVOGURjbMquXZtcd1dBQl4 bEPj9PH/6CxT9EKl2loxJJaxYIl/BSik0rYH/Fe4IXY12qGLfH8HaAxwsKBTtXNaBLRn DJF3lxfJccalxzTj7DlKiFy6pdJ8oIOC3n8x9EO655K1h9cAZMpPggLSVEPmjgCAKhBN 15MQ== 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; bh=x1b9U+ll7rYoKFd/VYYIrzyzfxI9HzKoL0fbzN8Co5g=; b=Wc7igWPo1P1sNC7B0kkJQnmFILYlSbHS2/ua+amO4fVcfm0q48W7OR/qWSZhYSwKjo rfEaCLOyvbUyBaLBctNruF/WbvwimYa2h1X3JX8tW0fy+9dR9mzOMckUTXK07k9u7cgH gZ/XtCTbSgpIWGiS7x4LP47c0ePliJPYmmCEq2L/awPmGUL6xLggnBpiyp1czW32CgJ9 wuzYcUvWZug1DdkWhDu6rqKA5Q5E4e+B8Y0kq62kmt9Xr9GnQOPcvV1HUihhFRaAtCpi MHHv6C2SDNqmNtVjVbDlBe7D7r1Z/e2Vt5+MFVyRtZUjuZ8gv2ZC945GPAsQJG0l1Jk3 fVUQ== ARC-Authentication-Results: i=1; mx.google.com; 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 t23-v6si3486055pgk.26.2018.09.13.06.52.04; Thu, 13 Sep 2018 06:52:20 -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; 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 S1730681AbeIMS7k (ORCPT + 99 others); Thu, 13 Sep 2018 14:59:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33106 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728513AbeIMS7j (ORCPT ); Thu, 13 Sep 2018 14:59:39 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B8B1D1B; Thu, 13 Sep 2018 13:50:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= , Jens Axboe , Sudip Mukherjee Subject: [PATCH 4.14 098/115] lightnvm: pblk: free padded entries in write buffer Date: Thu, 13 Sep 2018 15:31:58 +0200 Message-Id: <20180913131829.449589335@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Javier González commit cd8ddbf7a5e206fe6995ab0aee245d597dd6a7f2 upstream. 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 Signed-off-by: Jens Axboe Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/lightnvm/pblk-core.c | 1 - drivers/lightnvm/pblk-write.c | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -190,7 +190,6 @@ void pblk_bio_free_pages(struct pblk *pb 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_bio_pool); --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -33,6 +33,10 @@ static unsigned long pblk_end_w_bio(stru 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 p 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)