Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp41601pxj; Wed, 16 Jun 2021 19:44:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw14qgw0n2Qczv7ytBGoIMYHcy2A51/3mJVEeLu2+aw72s9gtVncTn1vXIo1GqfjaUw0ZP7 X-Received: by 2002:a17:906:16cb:: with SMTP id t11mr2625998ejd.112.1623897890305; Wed, 16 Jun 2021 19:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623897890; cv=none; d=google.com; s=arc-20160816; b=U9TkZKVrmawc+6UgmiLEBTtAxOws2eAfhroFBj9A4VNYFvA22VGeCum6VMUKbemMp7 c04wExZr7bJz4A4sEb3NG4dUCppRrooy487Bz/v5tqujSHOCZhE6WW/3IevZjo5M29Qo J0IDo5ReO3JkHX5BJcaejCE4QqsnThT7N66HJp4rKEQrK0/7AhXznJg2MU1XBOSxjKle isdMlLslCMzQ6VUDLtJOMsJyHAKLLWmXv1SGrbI+yVtPnIbCXGR4kTf7KM5I7sb/l50l 72+3xRMu4kJnUxLeDQA/z4FGGJ/HxKbLRXSvzJ91kGjUYmAQFLvY8CtDocw4RDISYkUf EcnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Sd3TKlUNt9JJHo5720KeNP5FpO4z1dpeo1L3Lhhc5sQ=; b=jqtjUFPnazqnqGsPe07QSp2LW3VD2iFepCb0aOAGmfNrRqSwIYMS1yV01jtBEndTNc NlIYk+0M/qusdvQdjqpaNpwnhmRei4bMMA/3s/TARU/CPWwOaKAWmOTgTDyvl6KJ2X5s 76+u8Ux+lyDzM81x6MWi5ZqG8I+kz/WE4X68Jl1a8N8Ez5BKFA+8J89H/eB8TSXsbSi0 xgjGV7oYUPgodagcIV3UUmeAPg6Hwa+XYxEGbRETImYJhw/UHS9tECUgaEAQzEd9LaCs Al1SeTkc5xzSP4/8Uo9OetxMOx1S43O8iQrkxDcRG3jPy2reP/GFaupzdU5HxLEeE5lK f9Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vc8kzuGf; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz19si4320941ejb.86.2021.06.16.19.44.20; Wed, 16 Jun 2021 19:44:50 -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=@kernel.org header.s=k20201202 header.b=Vc8kzuGf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235036AbhFQAj3 (ORCPT + 99 others); Wed, 16 Jun 2021 20:39:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:60002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbhFQAj2 (ORCPT ); Wed, 16 Jun 2021 20:39:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C9EED613B9; Thu, 17 Jun 2021 00:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623890241; bh=SXA3yBsohkpZT852yLw/Ew5Vyq6uE3A+kzcgpLwYHgg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Vc8kzuGfX+c2v/+HG4VJgoJs6jYqcGL6ybW7bKooIRoQeH9QVMMOiTw3vY4gCoK3W 1S7ue3Nmv37xD6UmVlE27K1+dM7SSZvCu4DSvHP2lhdK9Ply04NfXIpiFW2tEuD2R3 XCHEDjGkqGp9V9ieJwL4M006qQpUnZ0DPWZutnHTrJFczsXphj3u7nt2cMyVImJMwF iQcCgmaVpHaxye+AN8HBqvVYDjWgRHKsa8CVezI19MrtaFywilZ4xxvFy3lw8+L6EC KZO7asNI3GApZLy9Kn3Wu/5XfSglJVONa2hf+UYVQoN+O8UN6ytriKKRuiUKrd6LOQ Qmr9dYx0IJzcQ== Date: Wed, 16 Jun 2021 17:37:20 -0700 From: Eric Biggers To: Satya Tangirala Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Jens Axboe Subject: Re: [PATCH v3 03/10] block: introduce bio_required_sector_alignment() Message-ID: References: <20210604195900.2096121-1-satyat@google.com> <20210604195900.2096121-4-satyat@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210604195900.2096121-4-satyat@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 04, 2021 at 07:58:53PM +0000, Satya Tangirala wrote: > This function returns the required alignment for the number of sectors in > a bio. In particular, the number of sectors passed to bio_split() must be > aligned to this value. > > Signed-off-by: Satya Tangirala > --- > block/blk.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/block/blk.h b/block/blk.h > index 8b3591aee0a5..c8dcad7dde81 100644 > --- a/block/blk.h > +++ b/block/blk.h > @@ -262,6 +262,20 @@ static inline unsigned int bio_allowed_max_sectors(struct request_queue *q) > return round_down(UINT_MAX, queue_logical_block_size(q)) >> 9; > } > > +/* > + * The required sector alignment for a bio. The number of sectors in any bio > + * must be aligned to this value. > + */ > +static inline unsigned int bio_required_sector_alignment(struct bio *bio) > +{ > + unsigned int alignmask = > + (bdev_logical_block_size(bio->bi_bdev) >> SECTOR_SHIFT) - 1; > + > + alignmask |= blk_crypto_bio_sectors_alignment(bio) - 1; > + > + return alignmask + 1; > +} Looks fine, but I think we could rework the comment to be a bit easier to understand: /* * Return the number of sectors to which the size of the given bio (and any bios * split from it) must be aligned. * * Normally this is just the disk's logical block size in sectors, but it may be * greater if the bio has an encryption context. */ static inline unsigned int bio_required_sector_alignment(struct bio *bio) { unsigned int alignmask = (bdev_logical_block_size(bio->bi_bdev) >> SECTOR_SHIFT) - 1; alignmask |= blk_crypto_bio_sectors_alignment(bio) - 1; return alignmask + 1; }