Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6971646yba; Tue, 14 May 2019 17:41:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhWnVr2foAiIjUZodxHYlWzlfVDikQaKqQpM6frZCu40JekkJRDvs/Vx/nJTvH+6cGtgLN X-Received: by 2002:a63:4346:: with SMTP id q67mr40966156pga.241.1557880881375; Tue, 14 May 2019 17:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557880881; cv=none; d=google.com; s=arc-20160816; b=Ho55SRW6H+h6B5o2azKcUZhOTXUAKKRdSWnf/eRTlDmlnXHOCMOQc2Lmf5Znes70rR lT9zfGMRGW6TZ4oVdthy6ZM7g5jgWPDLsk4cx5Dqg25YwTNERqYAOHbAxSqIDr4/0Cfn 6dKpLaNUovcud/y7A+sNbVrH8IY0NwbNvEWdUnyaQgghHFF0I9DljiLE5Ir6DevMuI5l qXit+CQZw7TV63xmVSK3oDoyUxi5WkKsj/UQ/HU326zYXIwaLjr5HP7tz4ktthZcEIDC MwfJ2MzTOPc4ZBKQzr+7Oc2HOo3L6NEALjzux3GsFfdlQ8F7zdPQPPrl/oFbBPiWYItB Z+fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=aBmiAOmZcdYY0O365EiKabnGd5fG0JCgLUx8je4V9gc=; b=JMFD+UTuegfdHBvGz1DO0dI+D2XIpnBsahSHOXzxXS19jQwS9VPYLCuAwEyNrM/ga/ GW6uNi4bwacdI9G2UUW7o7KM1OfLnJ5nCS51pCDotCVmJVE0bJAIGhhYCvLGw7WonP+A LZ9l+rcAILMFyz29/Yo9LT/ueFoO3U7dJ0LzAlGdcQHagFZ4Ocap0AzfI+SHTlTvm9W8 Pr+b6nH8DVJhSbn2SFMqMfYVsQOtp7jTtLKeADGa5zTDw1FKhj8e6lp6lcN3IRKTYS/h avlqDcbpc88xwccvSmWXBqkBqyVlq2A+JwdzDWO+77+BvBwjfnyr/rQ0hkHckewVR/N5 tVoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ucsc.edu header.s=ucsc-google-2018 header.b=hmkVWGZb; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ucsc.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si556352pfo.49.2019.05.14.17.41.05; Tue, 14 May 2019 17:41:21 -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=@ucsc.edu header.s=ucsc-google-2018 header.b=hmkVWGZb; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ucsc.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726279AbfEOAj5 (ORCPT + 99 others); Tue, 14 May 2019 20:39:57 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32989 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbfEOAj5 (ORCPT ); Tue, 14 May 2019 20:39:57 -0400 Received: by mail-pf1-f194.google.com with SMTP id z28so396613pfk.0 for ; Tue, 14 May 2019 17:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucsc.edu; s=ucsc-google-2018; h=from:to:cc:subject:date:message-id; bh=aBmiAOmZcdYY0O365EiKabnGd5fG0JCgLUx8je4V9gc=; b=hmkVWGZbVyVVrQmfIO/zA/A5PprcEYZo9Fgh2bNu/OxBdej3W4auhEAANb9btrTC3z 6WnUnSvpBLIArEZcgVTJOdv5AvWyxa5RbFtgGMjZNP7BYe38q1j7z3E2vtv72P3is6Ej Y8zLMqyZwp9gpLW3cYA/2fv3s+h6aYy08zeAk5vQmOtmh3OC7VyCeyUEscFXQx6r2jlI GycW9Jf+mzGfJXNLVPZC4M3ySs8k/XPhjas7X8U2XXwaClcmq+AfNNGVpO5Lgu14GqXx bPpgxnqG2/P2hygAyd2Qy6hoAvO2UqN9bqm7tv05qd9DlkfC+87qXWIn8mlo73vKzXlp T3Vg== 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; bh=aBmiAOmZcdYY0O365EiKabnGd5fG0JCgLUx8je4V9gc=; b=odx94cLxepzSxrKXD289WWQNqOrBGJ+LLUVMYVi3y0dkJda88evcg3kQd3oWPwzZum GKO5ntHlpg0pcYA/n1hwEOWoN32vfTkJauGFadZkiob4NT/zh/r1opeJhf8uECS2pEX3 q3eSEqTzzZ5odcTcJq1iXwXhVA6JoaeUJK64pLA/wE0+pTsFJjY3ocvuGejHj8iUCBl/ ltXOJzC1w71LNlRryDmOkB13nr0Gw4z/teRRvoeGLZ1kVNT6hFNnxkpPDwQJSLRHkITD I6jEMUFApai/lUZhNXFGDHeg8xUU77x843lKRZlwgCzfR9it17wxfA05Obd5AKs1O5+0 vqrA== X-Gm-Message-State: APjAAAVHqS/qIK0B5BkwhoEPUmJiyFC2mQxqDl/vnqThGy4s1LolsKMS +O3EcKZcFK5PbYSs2lY8gacVE39AUtM= X-Received: by 2002:a63:7054:: with SMTP id a20mr27458699pgn.354.1557880796429; Tue, 14 May 2019 17:39:56 -0700 (PDT) Received: from bohr1.soe.ucsc.edu (bohr1.soe.ucsc.edu. [128.114.52.184]) by smtp.gmail.com with ESMTPSA id c142sm370727pfb.171.2019.05.14.17.39.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 17:39:55 -0700 (PDT) From: Heiner Litz To: mb@lightnvm.io Cc: javier@javigon.com, hans.holmberg@cnexlabs.com, igor.j.konopko@intel.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Heiner Litz Subject: [PATCH] lightnvm: pblk: Fix freeing merged pages Date: Tue, 14 May 2019 17:39:52 -0700 Message-Id: <20190515003952.12541-1-hlitz@ucsc.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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..88d61b27a9ab 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.17.1