Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp528372pxj; Tue, 18 May 2021 08:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKBNvnbhHuehcjCuqm8XB0x2f5kJGdGGRttUt4Trg5nT2B+8M1HlqTjerokUuNMmPSH1sl X-Received: by 2002:a92:db07:: with SMTP id b7mr3057779iln.282.1621352296540; Tue, 18 May 2021 08:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352296; cv=none; d=google.com; s=arc-20160816; b=gUmvrCMvI1Of/JgEEeZPzcuOlO79EpK0WEO5IEpXJ1kpL9iDXeaEpuXYtfo4NahfBD VGpeBjy7XTRo8rqG7r0P8j2hf33JKZ0ujkJ5fJrMP5Ji0zcfiokbe3/3FgXAfe2KsytR GEzje5lIwCE7FgIHfdiZlKhEZ/+OLWZTsOgul7EKqqlF/ASqncC3K5KUpoeTZbpPPm8V y+Z3SZvPLoovAuczbTXkWFlGwdPbXQ29781dtQEnm6LgfrAbjs7p9m6THbAwEuJaG+Jr hyd9cmw3oO68Z7gRfnVB7pjS5VebBBYunGVOG6t5tnB0i2MjBFi46hjKouDdNoh4KqW3 jKHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rtvAgRchvCMU4q3muSZPGyX/GOdb4vkO439I9CkF4ZY=; b=kWYe3Y/Za1RanN+Kubu4ic3xo6z5uNZJ2dbgEhOqotwzR6Fe9eG9WU+Q2rcqIDoslQ vbzwn30OS4x/1fihFr0txW/vX8o0eN5S1z3iSy+c2sPzcA94HYgNbUwPs7z84iW3sR7v h88z6i3NFhveOpXiH3hyHHK1Qm2ob8WY7aK9IqkDfpAhzbPhCgxWIvCDsX2TEfCtzokD JkkwaTGmgEgoFHwoFIHosAj+QRucymK2xTsIXjd0nHVa4E9yXevNUI5/A8TMrmF6UVMF 33pQoxVEVgRU9N9Jal/z1YDKiB1fXm2NGELGjZy4vI+AaOJlt2Vr3W/iL4rv6B1OmA+V qNnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n5Ro8opF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si21756179ilx.117.2021.05.18.08.37.58; Tue, 18 May 2021 08:38:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n5Ro8opF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345367AbhEQPzW (ORCPT + 99 others); Mon, 17 May 2021 11:55:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244187AbhEQPgn (ORCPT ); Mon, 17 May 2021 11:36:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50DED6193B; Mon, 17 May 2021 14:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262415; bh=ZYBXfh3RkmqL8v5AMtyZ1QUZJzFMuyQUWoQSFTM50eo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n5Ro8opFPo6snZENiyWIe4XXeex4ZqkBiqrhBUcEepCqPwZMDIlC3eX2cU2kQIFqs 6XmEDzFgAFNi9HAs9OTc1qJOGCpCWBH3mJLIVD9kWsiD/xGJrH6NW6vxNKATUJZbTb GBF7bQpBjwWn/d0itH8DDuQOvouEHF+XyIhhLyX4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitanya Kulkarni , Sagi Grimberg , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.11 273/329] nvmet: fix inline bio check for passthru Date: Mon, 17 May 2021 16:03:04 +0200 Message-Id: <20210517140311.352823035@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chaitanya Kulkarni [ Upstream commit ab96de5def854d8fc51280b6a20597e64b14ac31 ] When handling passthru commands, for inline bio allocation we only consider the transfer size. This works well when req->sg_cnt fits into the req->inline_bvec, but it will result in the early return from bio_add_hw_page() when req->sg_cnt > NVMET_MAX_INLINE_BVEC. Consider an I/O of size 32768 and first buffer is not aligned to the page boundary, then I/O is split in following manner :- [ 2206.256140] nvmet: sg->length 3440 sg->offset 656 [ 2206.256144] nvmet: sg->length 4096 sg->offset 0 [ 2206.256148] nvmet: sg->length 4096 sg->offset 0 [ 2206.256152] nvmet: sg->length 4096 sg->offset 0 [ 2206.256155] nvmet: sg->length 4096 sg->offset 0 [ 2206.256159] nvmet: sg->length 4096 sg->offset 0 [ 2206.256163] nvmet: sg->length 4096 sg->offset 0 [ 2206.256166] nvmet: sg->length 4096 sg->offset 0 [ 2206.256170] nvmet: sg->length 656 sg->offset 0 Now the req->transfer_size == NVMET_MAX_INLINE_DATA_LEN i.e. 32768, but the req->sg_cnt is (9) > NVMET_MAX_INLINE_BIOVEC which is (8). This will result in early return in the following code path :- nvmet_bdev_execute_rw() bio_add_pc_page() bio_add_hw_page() if (bio_full(bio, len)) return 0; Use previously introduced helper nvmet_use_inline_bvec() to consider req->sg_cnt when using inline bio. This only affects nvme-loop transport. Fixes: dab3902b19a0 ("nvmet: use inline bio for passthru fast path") Signed-off-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/passthru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c index b9776fc8f08f..df6f64870cec 100644 --- a/drivers/nvme/target/passthru.c +++ b/drivers/nvme/target/passthru.c @@ -194,7 +194,7 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq) if (req->sg_cnt > BIO_MAX_PAGES) return -EINVAL; - if (req->transfer_len <= NVMET_MAX_INLINE_DATA_LEN) { + if (nvmet_use_inline_bvec(req)) { bio = &req->p.inline_bio; bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec)); } else { -- 2.30.2