From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B2ABC43334 for ; Mon, 25 Jul 2022 14:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233838AbiGYOrB (ORCPT ); Mon, 25 Jul 2022 10:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiGYOrB (ORCPT ); Mon, 25 Jul 2022 10:47:01 -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 9243C13F1A; Mon, 25 Jul 2022 07:47:00 -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 3D037B80DE9; Mon, 25 Jul 2022 14:46:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12A5DC341C6; Mon, 25 Jul 2022 14:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658760418; bh=PZKVLgIIqdh9g4wPfJ5NHR7BP7/xQGyMshytByH1RJM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dmS4DNDrLhJ9CA/GNgiKyZDaLdV2ZqESyyBrwX5Anr3zbwmlC1Amcvm+cxJKZtQFf A5qRBVTOO0svm8DcPHWQREspfRrbKbEnZaPgemr6LNsWMT+YMiL6DO/VXbgLE7Siq1 jB1WtmFqomimhIRA2JXinRRzjMeQg4LHCNjMDGFty2LHhtLN+XrYTQULac6rfd1HnR wqs8aa3KpPYNMU/iS8RU7gujJmvwcZei2+8mgr4biHSxlEDfK/fEJMBQrg4Ov6WQMn Xd6uKDKNKxDjF4h0wpfyPRjUbewJEUxWHeQ+ESR7RovV5uy1MEdFVZMXmtuwup6PpK gelQyAxIBu9xQ== Date: Mon, 25 Jul 2022 08:46:54 -0600 From: Keith Busch To: Bart Van Assche Cc: Keith Busch , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, axboe@kernel.dk, Kernel Team , hch@lst.de, damien.lemoal@opensource.wdc.com, ebiggers@kernel.org, pankydev8@gmail.com, Pankaj Raghav Subject: Re: [PATCHv6 07/11] block/bounce: count bytes instead of sectors Message-ID: References: <20220610195830.3574005-1-kbusch@fb.com> <20220610195830.3574005-8-kbusch@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Fri, Jul 22, 2022 at 03:01:06PM -0700, Bart Van Assche wrote: > On 6/10/22 12:58, Keith Busch wrote: > > From: Keith Busch > > > > Individual bv_len's may not be a sector size. > > > > Signed-off-by: Keith Busch > > Reviewed-by: Damien Le Moal > > Reviewed-by: Pankaj Raghav > > --- > > block/bounce.c | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/block/bounce.c b/block/bounce.c > > index 8f7b6fe3b4db..fbadf179601f 100644 > > --- a/block/bounce.c > > +++ b/block/bounce.c > > @@ -205,19 +205,26 @@ void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig) > > int rw = bio_data_dir(*bio_orig); > > struct bio_vec *to, from; > > struct bvec_iter iter; > > - unsigned i = 0; > > + unsigned i = 0, bytes = 0; > > bool bounce = false; > > - int sectors = 0; > > + int sectors; > > bio_for_each_segment(from, *bio_orig, iter) { > > if (i++ < BIO_MAX_VECS) > > - sectors += from.bv_len >> 9; > > + bytes += from.bv_len; > > if (PageHighMem(from.bv_page)) > > bounce = true; > > } > > if (!bounce) > > return; > > + /* > > + * Individual bvecs might not be logical block aligned. Round down > > + * the split size so that each bio is properly block size aligned, > > + * even if we do not use the full hardware limits. > > + */ > > + sectors = ALIGN_DOWN(bytes, queue_logical_block_size(q)) >> > > + SECTOR_SHIFT; > > if (sectors < bio_sectors(*bio_orig)) { > > bio = bio_split(*bio_orig, sectors, GFP_NOIO, &bounce_bio_split); > > bio_chain(bio, *bio_orig); > > Do I see correctly that there are two changes in this patch: counting bytes > instead of sectors and also splitting at logical block boundaries instead of > a 512-byte boundary? Should this patch perhaps be split? The code previously would only split on a bvec boundary. All bvecs were logical block sized, so that part is not changing. We just needed to be able to split mid-bvec since the series enables unaligned offsets to match hardware capabilities.