Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp802659pxf; Thu, 25 Mar 2021 14:30:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0yk4GYBThHMLDnje8RIPQC5h79jsvgWFegeVKRpbdc0svpW8eTBSWz/74YvCHNrrI4vXM X-Received: by 2002:a17:906:5949:: with SMTP id g9mr12133928ejr.518.1616707840661; Thu, 25 Mar 2021 14:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616707840; cv=none; d=google.com; s=arc-20160816; b=fMsQ3ilQJjeF1j7RDM5g4HgL3/GQztPPBVinD87jaiyswSEto50zsqCYLL7NSMko+h J0uQofAKDKNDAb7JxoS6FN7QcIGF7d5nXvrUvGj+xKzD0hLIH7S3AII+GL4CRlID9Djn zZIs+L/u2T90Z27rWvxcCR2whALMd7QTJiCXTysDIqOdGpVN05S+DIAKvULrVHAjkM6l 73JpsxYVIV8A+ghL6UD24fik7xUsIgaP2ybhCfO8leUrsKHjJCrsLNCQ5LG6Vtu5ieJo AEt8bPMRDv6ZKRiC7GQTVYa24k++wlXFSFnfADJPN8XTbhWEgMKh+n4TbGCTBklLehtM 8tFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=jcwCmvL2zf0lF3Ank04XNaFIuqNE6u2MJVhR/WWQGZc=; b=JdSNzgdFYb0G0+WmxfVz6rwYUPb5tUvvEGbx1nMrh+Y4ARfT4+PeodGEUOyqNbApH/ nolWbrsN4Bv9MMPAZGWoht3naEgZa/ZZ3hHVdB8plcqFA7GnrA8y1w6QvkheWqis9Frz 7ZHWnOzxkNsEzqx7CGAGJetq8Y7PUsXD6S7fsQtzN/1d78dIoLu/pjLLnIrHvFknZOs3 orHr7jU8CtX7x5PCIiNaNhKdwEsnqjBXTxdzzQBBiBCiX1YGr7kNLDKESeLGzfMCFnur /b+6nL9N6hNeFabuUKotFYrUU0yjsvGwbjlc8Kgpoawc0pbnlFziDLtTG9iqxFal9Yvv ui7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fUGJmbUc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si5184583eja.163.2021.03.25.14.30.17; Thu, 25 Mar 2021 14:30:40 -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=@google.com header.s=20161025 header.b=fUGJmbUc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbhCYV1k (ORCPT + 99 others); Thu, 25 Mar 2021 17:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbhCYV1Q (ORCPT ); Thu, 25 Mar 2021 17:27:16 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A0F8C06174A for ; Thu, 25 Mar 2021 14:27:16 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id s14so4076647qtw.20 for ; Thu, 25 Mar 2021 14:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jcwCmvL2zf0lF3Ank04XNaFIuqNE6u2MJVhR/WWQGZc=; b=fUGJmbUcJs9LLuwYxYrtUvHLhM1TcSpAOUXmXU9i7ZnDvC+dagbI2nRWiKwSzhKIn6 J2TpCtBOE35vXBCihxWEoeINPTXBVETVHLvpHO2733KVglleDWVzIJryyi32kWjj+nP6 YWdKtTHMviMBZFfEpcz7H+m/aZzW2qRD0u6jIUMv9IZAR8iixPQJaqco0CUSkUewAmHs X9UEZpJes0lwNIZdwASUbOtV7WpZVWPE2WLSwgNbEhr97VbdgNEr/YGq6BOOoDSZHi7e GeRiDIF/hZPeQo4HSjSsd7RD21QbbVFei8tLUMSo4UI6bfEa9gryrW23GJeBK4/nos4P yC6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jcwCmvL2zf0lF3Ank04XNaFIuqNE6u2MJVhR/WWQGZc=; b=KR34s+lIE5Ecuzq1pmy1E7Hpff/gbbc5ghICkvKQS4c+wp0gA5OPfBiOUP4ffKMAT4 /5mfxzZlwu4wq19stGnQbGhi6a5yqLp6d+Kxn59Zs3+K/zxiBlZytakzE5EV8CLRzNUQ vc/PWL6iR47Gl0tZBjN6W8VSQ1/179jhyic8tpW/D7cLy5qJ5Log5Kcn/ZZHCG4ui7rH tXa+BnOrBZ2HvKNjyEbu/bx69x319QOXeKIBz3skesBJNLA/CAlxzO6dfdF0WRyc3VD2 9r2QMy6lljsUASEjT05KOF7NV+2SXDWOoWRxhYiNx2mkrQEiFZaMXWnixR2o8qMFga9t kW0Q== X-Gm-Message-State: AOAM530vBTR7AMHV5l7cxjQngaYpu3V2ODGV5LU4jFXXgjjHhNPwflWy BQY3mJ/9Zz6wrt/bDxPNsEF6nMHNaXE= X-Received: from satyaprateek.c.googlers.com ([fda3:e722:ac3:10:24:72f4:c0a8:1092]) (user=satyat job=sendgmr) by 2002:a0c:c345:: with SMTP id j5mr10335420qvi.52.1616707635674; Thu, 25 Mar 2021 14:27:15 -0700 (PDT) Date: Thu, 25 Mar 2021 21:26:05 +0000 In-Reply-To: <20210325212609.492188-1-satyat@google.com> Message-Id: <20210325212609.492188-5-satyat@google.com> Mime-Version: 1.0 References: <20210325212609.492188-1-satyat@google.com> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH v2 4/8] block: introduce bio_required_sector_alignment() From: Satya Tangirala To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jens Axboe , Eric Biggers , Satya Tangirala Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/blk.h b/block/blk.h index 3b53e44b967e..5ef207a6d34c 100644 --- a/block/blk.h +++ b/block/blk.h @@ -261,6 +261,18 @@ 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 + * that's constructed/split must be aligned to this value. + */ +static inline unsigned int bio_required_sector_alignment(struct bio *bio) +{ + struct request_queue *q = bio->bi_bdev->bd_disk->queue; + + return max(queue_logical_block_size(q) >> SECTOR_SHIFT, + blk_crypto_bio_sectors_alignment(bio)); +} + /* * The max bio size which is aligned to q->limits.discard_granularity. This * is a hint to split large discard bio in generic block layer, then if device -- 2.31.0.291.g576ba9dcdaf-goog