From patchwork Fri Jul 13 08:48:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10522827 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 2CF086028E for ; Fri, 13 Jul 2018 08:49:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D08529964 for ; Fri, 13 Jul 2018 08:49:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 110F72997D; Fri, 13 Jul 2018 08:49:36 +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 AB14A29964 for ; Fri, 13 Jul 2018 08:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729899AbeGMJDO (ORCPT ); Fri, 13 Jul 2018 05:03:14 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:46970 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbeGMJDN (ORCPT ); Fri, 13 Jul 2018 05:03:13 -0400 Received: by mail-pl0-f67.google.com with SMTP id 30-v6so11915319pld.13 for ; Fri, 13 Jul 2018 01:49:34 -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=guX+AAdmqPGxri1WBU30oxOqHrngNhPRqJoTW9aS5Js=; b=gbZPjthJ6U9lgH7uR3vWu0E4z7au8/BkEireWOTWBo82tdzxlrbbBC+hvgLO+cQbxv VMg7LQjjIeFFyvglQTr/HvBxk9wlXfe8cLMa5v9v2RmjVRUEmYlYdRsV0xbjKiSbgqhe /Zj6yDWRZJX/11777L2c6iJfDuLtGUDVV64PS4Ou2hndiDIXLuM9cTViJLe9gp7aTcAm KTYNXL2qhxCjtvcXb+R1LfbCxZybla2cIpWiAS1w7Qwch0YeHQ1nAmFzzWncMw9JyFgJ A6l6NS6fjSfJkwdaeaXPicd2cy+mJo/f+cQKI7M/kIRR5LxDB91+XDqc3csCSKZQqC6C 8PcQ== 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=guX+AAdmqPGxri1WBU30oxOqHrngNhPRqJoTW9aS5Js=; b=LhR+DfIQJov63AbT8p7+206/6LglFbm7ZY0ARdMh9aHYgyrHtTJFiya9EU/EHsG5E1 FU3+kIgUta44NBMoufhybIW/DCaNqhFh4CNdcM5pDjpASh/p2u2Hawpkb3ECINK8uJlT inzyV1jl1ATz90QyVOPuoLIyeNFhWEbBUJaqQrmntIqcoj2OZ7Qp0XZR2Czlmh8UK9Sc guVCbtbfSBDz9j26CEjt5dxZ0r6nnpRRZtOt9YLXILwIFLnAlr9Ujc7m5KQtKATqITcf 59lrerGoyR+zUHb9eFmPCFAqwprETpKofGxAAQ3C0Z/uf/asm4fWjuqJB3BS7fP5WPIa IDVw== X-Gm-Message-State: AOUpUlEUNbgLIvvUJdUW5PE47rJaPP/tw6wBafNXFX77Fnx8iCjr9FoP 5/BC69bmfiRVNBj4kCWwnra3Fg== X-Google-Smtp-Source: AAOMgpdSfmSOSlG9/akLgD9qRtcP6bk08Jj9A3n5zaY3yr1q3ccltWtSHmo2LhrtFlryX5f7bq4wEA== X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr5624375pln.290.1531471773962; Fri, 13 Jul 2018 01:49:33 -0700 (PDT) Received: from skyninja.hgst.com (rap-us.hgst.com. [199.255.44.250]) by smtp.gmail.com with ESMTPSA id d18-v6sm569357pgo.74.2018.07.13.01.49.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 01:49:32 -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, bart.vanassche@wdc.com, hans.holmberg@cnexlabs.com, javier@cnexlabs.com, hlitz@ucsc.edu, igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 06/10] lightnvm: limit get chunk meta request size Date: Fri, 13 Jul 2018 10:48:41 +0200 Message-Id: <20180713084845.19511-7-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180713084845.19511-1-mb@lightnvm.io> References: <20180713084845.19511-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 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 a76db8820f1c..d9e4cccd5b66 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);