From patchwork Wed Jul 25 14:22:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Edwards X-Patchwork-Id: 10544125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C626A112B for ; Wed, 25 Jul 2018 14:38:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5C152A1C1 for ; Wed, 25 Jul 2018 14:38:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A93332A1CC; Wed, 25 Jul 2018 14:38:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BAC22A1C1 for ; Wed, 25 Jul 2018 14:38:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728631AbeGYPuv (ORCPT ); Wed, 25 Jul 2018 11:50:51 -0400 Received: from legacy.ddn.com ([64.47.133.206]:21860 "EHLO legacy.ddn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727881AbeGYPuv (ORCPT ); Wed, 25 Jul 2018 11:50:51 -0400 Received: from LAX-EX-CAHT3.datadirect.datadirectnet.com (10.8.103.85) by LAX-EX-CAHT3.datadirect.datadirectnet.com (10.8.103.85) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 25 Jul 2018 07:23:47 -0700 Received: from LAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) by LAX-EX-CAHT3.datadirect.datadirectnet.com (10.8.103.85) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 25 Jul 2018 07:23:47 -0700 Received: from soma.datadirect.datadirectnet.com (10.48.114.40) by LAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) with Microsoft SMTP Server (TLS) id 14.3.389.1; Wed, 25 Jul 2018 07:23:46 -0700 From: Greg Edwards To: , CC: Jens Axboe , "Martin K. Petersen" , Greg Edwards Subject: [PATCH 1/2] block: move bio_integrity_{intervals,bytes} into blkdev.h Date: Wed, 25 Jul 2018 10:22:58 -0400 Message-ID: <20180725142259.20562-2-gedwards@ddn.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180725142259.20562-1-gedwards@ddn.com> References: <20180725142259.20562-1-gedwards@ddn.com> MIME-Version: 1.0 X-Originating-IP: [10.48.114.40] Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows bio_integrity_bytes() to be called from drivers instead of open coding it. Signed-off-by: Greg Edwards Acked-by: Martin K. Petersen --- block/bio-integrity.c | 22 ---------------------- include/linux/blkdev.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index add7c7c85335..67b5fb861a51 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -159,28 +159,6 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, } EXPORT_SYMBOL(bio_integrity_add_page); -/** - * bio_integrity_intervals - Return number of integrity intervals for a bio - * @bi: blk_integrity profile for device - * @sectors: Size of the bio in 512-byte sectors - * - * Description: The block layer calculates everything in 512 byte - * sectors but integrity metadata is done in terms of the data integrity - * interval size of the storage device. Convert the block layer sectors - * to the appropriate number of integrity intervals. - */ -static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi, - unsigned int sectors) -{ - return sectors >> (bi->interval_exp - 9); -} - -static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, - unsigned int sectors) -{ - return bio_integrity_intervals(bi, sectors) * bi->tuple_size; -} - /** * bio_integrity_process - Process integrity metadata for a bio * @bio: bio to generate/verify integrity metadata for diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 79226ca8f80f..553cc97900f6 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1877,6 +1877,28 @@ static inline bool integrity_req_gap_front_merge(struct request *req, bip_next->bip_vec[0].bv_offset); } +/** + * bio_integrity_intervals - Return number of integrity intervals for a bio + * @bi: blk_integrity profile for device + * @sectors: Size of the bio in 512-byte sectors + * + * Description: The block layer calculates everything in 512 byte + * sectors but integrity metadata is done in terms of the data integrity + * interval size of the storage device. Convert the block layer sectors + * to the appropriate number of integrity intervals. + */ +static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi, + unsigned int sectors) +{ + return sectors >> (bi->interval_exp - 9); +} + +static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, + unsigned int sectors) +{ + return bio_integrity_intervals(bi, sectors) * bi->tuple_size; +} + #else /* CONFIG_BLK_DEV_INTEGRITY */ struct bio; @@ -1950,6 +1972,18 @@ static inline bool integrity_req_gap_front_merge(struct request *req, return false; } +static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi, + unsigned int sectors) +{ + return 0; +} + +static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, + unsigned int sectors) +{ + return 0; +} + #endif /* CONFIG_BLK_DEV_INTEGRITY */ struct block_device_operations {