Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3086424rwb; Mon, 15 Aug 2022 17:47:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Fo+UVrYrXAusr4TmX+Ynb2xL2Pf6CVIwEL7DqCDWylTLOa3RoaZWVKjvb4NHHD5A0eSoR X-Received: by 2002:a05:6402:4411:b0:437:b723:72 with SMTP id y17-20020a056402441100b00437b7230072mr17147517eda.38.1660610873139; Mon, 15 Aug 2022 17:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610873; cv=none; d=google.com; s=arc-20160816; b=csaSlpsJ82Cbt4zdCWUhZbo+YMHT++U3mhLj1xhcqhG88fL0hW4U8ZFJyy87FJbaUh yhpeQKaElCJTpeLWcbXrI4imVEqdyBqLFTX6On+/2uppai2/zUOctZwoASYHFYnLz6HQ +BomYuUpTRimKxOzY28K0Et855bC38JqfbykP7jXe/29vQns+QWlcMywvoG6lmFT/r+o ALEMu6OOsFwo+SBVTtrVi2buo6dAnO3U0UBxLX4xEuXn61vTsiF1UmF+67cq7uWiL0xD jkiR8PAO3zkF/BlDGIVuyot5wxVoT3/0IdDxMX3D+evocuOgINEo748SNikVbavQJoiQ 6ZVg== 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=4j4HQemQZkoZ+gBtU+El/2eGsCl6crsX1sRFg5hFP1s=; b=ZRXv8Ruh6/9amaH4cIiyCC1qUtMGoxx8FpCP/dpPAwuxq9pKXEQAhNM0Yy842k99R6 wn4eB+J5TI2jYrDqTKN4tNMeTwz77j7f/RaushecNFhIHCj1R9mPjDSYvk1r8vxARMFx AcheJRf4+RhpuqTK0K2gSsnBeA091Gsci+WhOoccxqx2jTLRSTyqzlYvGCzy7CjS6aXP kC4QYXwM+mgRfdzQPXiQj9SiMJGnOGdYIlpOR/dkwSM0N2e2c9XzCThu6kgJnlrDKqqQ a0j51jY9jdRARGYQ2BfL5xAYgSs3t7uXOzBXrU8sK5dugSIhCCMGbOuRlDBdfKNH9c3G gflg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="M/18iCHY"; 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 qa42-20020a17090786aa00b00734be0ce0e5si9275744ejc.311.2022.08.15.17.47.28; Mon, 15 Aug 2022 17:47: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="M/18iCHY"; 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 S1348916AbiHOW3j (ORCPT + 99 others); Mon, 15 Aug 2022 18:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344115AbiHOWX7 (ORCPT ); Mon, 15 Aug 2022 18:23:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01223125D4D; Mon, 15 Aug 2022 12:44:11 -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 ams.source.kernel.org (Postfix) with ESMTPS id F1104B80EAD; Mon, 15 Aug 2022 19:44:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA33EC433C1; Mon, 15 Aug 2022 19:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592648; bh=GUWeR2HkTWqWqurKf6GRL4U6LrltBq3vNnVNzkov6Oo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M/18iCHYaWZFIJtA08G+I/KnO97auFmng/BrB8cGqCfulioErKkufsyXeVDQTRQ0y HQtJcpbvzU4e20437CsEr8xUFAigbNeu2mwphTk7rMTSQ4OUy4iUkORui5YfguPI/g KOqBFyR9lT5JwjfawzdiWz+unnBKSnu2PqUKiZ/g= 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.18 0821/1095] block: ensure iov_iter advances for added pages Date: Mon, 15 Aug 2022 20:03:40 +0200 Message-Id: <20220815180503.259550889@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 6f6e6e23889c..7d4d5723350b 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1181,6 +1181,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 @@ -1196,7 +1197,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) @@ -1207,13 +1207,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