From patchwork Mon Jul 2 08:02:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10500653 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 1EB0E60362 for ; Mon, 2 Jul 2018 08:02:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10E6B2832D for ; Mon, 2 Jul 2018 08:02:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03FAB286DB; Mon, 2 Jul 2018 08:02:53 +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 3E3162832D for ; Mon, 2 Jul 2018 08:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753655AbeGBICu (ORCPT ); Mon, 2 Jul 2018 04:02:50 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35277 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752759AbeGBICq (ORCPT ); Mon, 2 Jul 2018 04:02:46 -0400 Received: by mail-lf0-f68.google.com with SMTP id i15-v6so11278075lfc.2 for ; Mon, 02 Jul 2018 01:02:45 -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:mime-version :content-transfer-encoding; bh=1849dU4tG59McCnf2+NkKCCjXyKjWmv/jftBj2/tZ8A=; b=chbA8unZ5vuTHwgR4Egg8bzm1Q+v6UmYVlENtQTOSkMuAOk69qDF9zAV7RVzrsGcf3 LvXtD0Tpe1H/DqfANLL8L/MyJcYYcVgnKKSXf4JuUDn9PYef6n5aVtLPlTK4EuVmqCkJ 7+EIhgu6/lgHFSXTe8sV6vm2SVOqYvDybnaiKnRDMDgc6NqIzdhkmGCORjUlpu/ywuTp WeZvR4zjS9bQAKQNtYowrpHOk9kQ+LlhJBSZu+akx6gf84NgEaL3KpVchw9JlT5yauA+ 6EhUkxD/pfvS6C5z9sSE2Yv6G3brS4Lhb0vdAQA3px+ucswrIR5suq6SSarHDHUoxZ5Y y1OQ== 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:mime-version :content-transfer-encoding; bh=1849dU4tG59McCnf2+NkKCCjXyKjWmv/jftBj2/tZ8A=; b=j97cGgGg8QyP4FBY/nX650ryGxtyB6Me1zbnfRXcQzYsCPYeqL7DAWP0p7T1ZY0yv7 VuEOA+XtPfmfxiNZoQAmeMlLqamSD8+v4ffw5Dw+mjIkPJvGRAikdiMyz5PvvPTqF3R4 nnDQ0rQGb94qJ9lViHnAfhQGI8V5hBweVtA/9h14XwZoqZTq/LO0vydWFSIN51jF8EAP o2XEB8aiab+6xgmy9K7rlx4zoLwg1zEv72H0/VqiKo1p5U7cLUcDDyI2e290EpQYS59E RFX0/gwsjkLzHv66NrZJ9kV05NySKHmt6BoSb++0SuUsIPBelbyymQs784q9yahuMQ4L Hriw== X-Gm-Message-State: APt69E3OWpsZZbl1GVvzohlVh3u+xGc15m0KORcDsZFyiq+Re3WKm3bN LxDmqVAe73is3VTkHpwK2BpZ/1Xr X-Google-Smtp-Source: AAOMgpfOo9PR5tBkImaHkHp1HlpHr8nStHBPXrRi6T7G1KSpbGhGPVowWhQvs0LC+40kUbgIhyqdLQ== X-Received: by 2002:a19:c301:: with SMTP id t1-v6mr14037606lff.45.1530518564857; Mon, 02 Jul 2018 01:02:44 -0700 (PDT) Received: from Macroninja.cnexlabs.com (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.gmail.com with ESMTPSA id 1-v6sm595041ljd.11.2018.07.02.01.02.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 01:02:43 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, javier@cnexlabs.com, hans.holmberg@cnexlabs.com, hlitz@ucsc.edu, youngtack.jin@circuitblvd.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] lightnvm: limit get chunk meta request size Date: Mon, 2 Jul 2018 10:02:23 +0200 Message-Id: <20180702080223.13214-1-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 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 For devices that does not specify a limit on its transfer size, the get_chk_meta command may send down a single I/O retrieving the full chunk metadata table. Resulting in large 2-4MB I/O requests. Instead, split up the I/Os to a maximum of 256KB and issue them separately to reduce memory requirements. Signed-off-by: Matias Bjørling Reviewed-by: Javier González --- drivers/nvme/host/lightnvm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index b9989717418d..3b644b0e9713 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -583,7 +583,13 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev, struct ppa_addr ppa; size_t left = nchks * sizeof(struct nvme_nvm_chk_meta); size_t log_pos, offset, len; - int ret, i; + int ret, i, max_len; + + /* + * limit requests to maximum 256K to avoid issuing arbitrary large + * requests when the device does not specific a maximum transfer size. + */ + max_len = min_t(unsigned int, ctrl->max_hw_sectors << 9, 256 * 1024); /* Normalize lba address space to obtain log offset */ ppa.ppa = slba; @@ -596,7 +602,7 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev, offset = log_pos * sizeof(struct nvme_nvm_chk_meta); while (left) { - len = min_t(unsigned int, left, ctrl->max_hw_sectors << 9); + len = min_t(unsigned int, left, max_len); ret = nvme_get_log_ext(ctrl, ns, NVME_NVM_LOG_REPORT_CHUNK, dev_meta, len, offset);