Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5254590pxv; Tue, 6 Jul 2021 22:30:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLdkQSFhdWyJbA4mz05UPPqQgWyqNZn97KSSIXUr1nGadygPaQG/f0srvH/t+Bsm86ZMGU X-Received: by 2002:a92:d9ca:: with SMTP id n10mr691581ilq.14.1625635847279; Tue, 06 Jul 2021 22:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625635847; cv=none; d=google.com; s=arc-20160816; b=LrL7RdR7W/QSP4nTJBT4xeo93XxCdKhw8kBxa45y20F1SOXAMaES21Gm9SZBdHUk/p d8vmHspyrrEOyKz+8h7bi846xc+qZdJkJYfd9pvNk6F+k3DXb0xAQX5zUYJqmY/LlxVo Avre2x5sR9e733+EwRHD4UVI8CXs9zkh9g30a97czeb5uhr2dcAbOhmyiySuDSrX4m6k QVN7lpXy4u9d7GT5sWxpV9PRS4JR7MfIhVqbiRk1AtPGwntA1xvwEtkOJ4qV1Ul2yIZd uoKEY7yhmNjISefoYmT449slRWk+YUzmwWaHGSs0aq/rJD7W0Nz2XHbaud05zMukxkoU Mf5A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WKLA0+FCBowVgG4E9RkNcEjEHS5yJYVCiaDWXv1pfIY=; b=I1m40KXmZBS+pNfS3gelUTS5jm7USqJvOjm/gxl+PnOPBX7KW1pXITkNIovJAnrjaO DN47VwjxuEPfM58ObXIfujXEzBeMhLU31r7fFHShoNh1+7YkB3PAm9V8IWcD/p1O3zTq lW4xcul5xFsx+803DuBvkmv3CcIysrcV6tXjR02uUaKTLlRqQmPXBE6oFE87zzbfFpCm +12JiEi/tKrGNr+qHFZWMjByIdUYsN+fv7PcZjTJ9tWS3aLME6GD/gSVnfOntGjSQIFG M4XT5V9BZQFENC5q0/QxIg6clj5gchO8Kk9TmqLtl3WFqqcqI/UaMyiuEn33VFUSva8j UJ2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oyNGkcJ6; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si5276585jak.26.2021.07.06.22.30.35; Tue, 06 Jul 2021 22:30:47 -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=@gmail.com header.s=20161025 header.b=oyNGkcJ6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbhGGFcm (ORCPT + 99 others); Wed, 7 Jul 2021 01:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbhGGFcf (ORCPT ); Wed, 7 Jul 2021 01:32:35 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86718C06175F; Tue, 6 Jul 2021 22:29:55 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id t24-20020a9d7f980000b029046f4a1a5ec4so1174134otp.1; Tue, 06 Jul 2021 22:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WKLA0+FCBowVgG4E9RkNcEjEHS5yJYVCiaDWXv1pfIY=; b=oyNGkcJ6XnPGYVoJaxg1HQWuHn7uBt5y7r/Ix1cqwQkbbuUTaWpJP0TuYBr1d2ubdh se7hhIxQDEj0iZumZmjuQbDV8xgSJPlT3o3AVterATy6hAB9ZtiCBSmLL5gIPQ9qOON7 Oo6YKmZrkSzsqL60BHJGLXBMHWZViAPekcszR+WP6BRQP7IxyhpFsEe3kY3toIEgK8PZ IJ8cGwkB+n69G3KpjL+Ul4mSQvJx1zNsLziUyRk69nBh0MYfWKySd0cb0fwA9Xlt8y6c q6DszTMFclIC6CD8vhrKWLLvd6Ls3RCg5nHpHY65uHSQlSb7UJAT9bN32sAKR7I/Y8fr kxfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WKLA0+FCBowVgG4E9RkNcEjEHS5yJYVCiaDWXv1pfIY=; b=TXVOZ+KG0c1jesD6yur6vvIBV52/KTg8oHxZUTAFKzPMzUNRru+w9t67p/qdEaMPpR Jhp/uk0DS1sr5E2o3oqb3EkP4ENQR4MtOQNqq9EA61A/Xqd0ogaWQUQk5IXbprcqJJvq u779tMj065d79bTiD+NxaXz2fu5WHLqV/pKAvzb6leU7ODyyqzV2FZDNEjtjrzc3LZIa geSo0pb8x3Kx2l8u9LubGjmuVh0SjivM2ZKgNrau6o4Uiuewm23zyr6r+nAQUxjYeT+m UDrLeuhaKm6znBekTXqPW7YfEnm/hv//ecunOBWQqFKVsUgjbfee9FbIA2TlHOjwQ00Q zw3Q== X-Gm-Message-State: AOAM530nXbs/TQDSKwooAKxtllVw3t8HqeHQgEecJWu5NgJJSNzT8IJY kXGouWn2hAA1wKImUGpwA9eS4z9nZ9Q= X-Received: by 2002:a05:6830:99:: with SMTP id a25mr17281218oto.19.1625635794835; Tue, 06 Jul 2021 22:29:54 -0700 (PDT) Received: from fractal.attlocal.net ([2600:1700:1151:2380:3ec5:124:b596:7a55]) by smtp.googlemail.com with ESMTPSA id l11sm3284843oou.0.2021.07.06.22.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 22:29:54 -0700 (PDT) From: Satya Tangirala To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jens Axboe , Eric Biggers , Satya Tangirala , Satya Tangirala Subject: [PATCH v4 3/9] block: introduce bio_required_sector_alignment() Date: Tue, 6 Jul 2021 22:29:37 -0700 Message-Id: <20210707052943.3960-4-satyaprateek2357@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707052943.3960-1-satyaprateek2357@gmail.com> References: <20210707052943.3960-1-satyaprateek2357@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Satya Tangirala 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/blk.h b/block/blk.h index 4b885c0f6708..047d2c2411f2 100644 --- a/block/blk.h +++ b/block/blk.h @@ -261,6 +261,23 @@ static inline unsigned int bio_allowed_max_sectors(struct request_queue *q) return round_down(UINT_MAX, queue_logical_block_size(q)) >> 9; } +/* + * 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; +} + /* * 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.25.1