Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3091871rwb; Mon, 15 Aug 2022 17:55:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR6DJEfjgSMgPpTlLMeTSufj0peGUAEuKzOQq7Mhxqbj9OlUwy8A19/QHPzDnZHfCJVamaNt X-Received: by 2002:a05:6402:449a:b0:442:c81c:b938 with SMTP id er26-20020a056402449a00b00442c81cb938mr16368994edb.289.1660611353275; Mon, 15 Aug 2022 17:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611353; cv=none; d=google.com; s=arc-20160816; b=hAcwtZioODf/421xHU2dn1Tow4fUoA/dWXGPasJiqEtBnjAp0IBPaS/qahR7dRXHKa o1TL3eMlfym70WqMZ/2B3cmxcU2D0OZ+z990iZLtxVgI/kgZb5quTfHBS+4e1eR8V4V9 Vlrrq1/ykpJhEJLsWu1snakEIpWNn/sKDuPjcdD9/dlQ38eUZBGC9uCbwO+WQcmbtPCU BkMIw1pxY8zcdnu8KLnFe+rX0s1yXyXttA7nUE2riN/aa1h0sclB26onV2tTM9zn/Agp 5x7GwLspBdKN5TPnYJhp28g1EC8so//vI/lYtiY7/EbmB8wW89YZRNgbWysa2LuXXwlz Paxg== 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=hUlDE66ktnYMcNcxd5aVFEur13zTqy1O5JhMMCHoOW8=; b=Ajo75HYUTnsefbTm/KwHdiLzZtZiuzKqkPxrJpyYXjtpBpLxVsgVTu0aJfm4R3Hvgi ZsyRcu7K9qGTZ+cvTzdv/6k8riV0+f8NUWHbboiq8YrMjs7EwLz7piRdtVjFBZR+XIiS 3hsIxUw8BI3rOIWP2Cjhp/+ugUUhZ14FzN2ZymQtYzGX0RGRazqLiUtAhVA1PRFSLAz8 rIdgExVA+5A5AQeXOsuhknoe16Dghb2m8ZoW4UoD0rBbYWlNI6x2VplN9lXR/dQ4Hzl+ o+vTOhOVBKOS6fLQSfPA6DAXu57LC3F5VvfI5q5Df7AC3+eCa1OrFxdniEF3sYb0xWrR QVQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1bhdNSAJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o30-20020a509b1e000000b0043d4e0eb3c1si8417600edi.382.2022.08.15.17.55.28; Mon, 15 Aug 2022 17:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1bhdNSAJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244473AbiHPAgo (ORCPT + 99 others); Mon, 15 Aug 2022 20:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348778AbiHPAcY (ORCPT ); Mon, 15 Aug 2022 20:32:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C0E186EAC; Mon, 15 Aug 2022 13:36:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F1A34611D2; Mon, 15 Aug 2022 20:36:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECDE1C433D7; Mon, 15 Aug 2022 20:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595817; bh=ODX781OjagjZqRdZMPht02M+391MRlrl9iZmqo9YD4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1bhdNSAJkF0WWVAVcVka9ci/VRIhD/bY/MCPW6J9CkRy/sZwPSw1K26h0LXlTM+DP JGWWZzf7B0o2nvzB/6ZjJlxrJFeXC9dL27uzvMwOQYyJFBkJuhQG/O2sbSZCBZp27Y fhIibtjLDYU6i8v7GtxN+k2d/PSNY0VsI6wvPXxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Keith Busch , Jens Axboe , Sasha Levin Subject: [PATCH 5.19 0884/1157] block: ensure iov_iter advances for added pages Date: Mon, 15 Aug 2022 20:04:00 +0200 Message-Id: <20220815180514.793517975@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keith Busch [ Upstream commit 325347d965e7ccf5424a05398807a6d801846612 ] There are cases where a bio may not accept additional pages, and the iov needs to advance to the last data length that was accepted. The zone append used to handle this correctly, but was inadvertently broken when the setup was made common with the normal r/w case. Fixes: 576ed9135489c ("block: use bio_add_page in bio_iov_iter_get_pages") Fixes: c58c0074c54c2 ("block/bio: remove duplicate append pages code") Signed-off-by: Keith Busch Link: https://lore.kernel.org/r/20220712153256.2202024-1-kbusch@fb.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/bio.c b/block/bio.c index ee5fe1bb015e..eb7cc591ee93 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1211,6 +1211,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) ssize_t size, left; unsigned len, i; size_t offset; + int ret = 0; /* * Move page array up in the allocated memory for the bio vecs as far as @@ -1226,7 +1227,6 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) for (left = size, i = 0; left > 0; left -= len, i++) { struct page *page = pages[i]; - int ret; len = min_t(size_t, PAGE_SIZE - offset, left); if (bio_op(bio) == REQ_OP_ZONE_APPEND) @@ -1237,13 +1237,13 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) if (ret) { bio_put_pages(pages + i, left, offset); - return ret; + break; } offset = 0; } - iov_iter_advance(iter, size); - return 0; + iov_iter_advance(iter, size - left); + return ret; } /** -- 2.35.1