Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2978966imu; Sun, 9 Dec 2018 14:10:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSRRy8qAgipM2NqeNZkJWLEcTz8QLhVr9tFyvTAz3yWTorA5T27Q0NkKIk8QOuYWiCrNhG X-Received: by 2002:a17:902:2862:: with SMTP id e89mr10040875plb.158.1544393399981; Sun, 09 Dec 2018 14:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544393399; cv=none; d=google.com; s=arc-20160816; b=zf/54VOUr9DTOp13d3eMIMLO+VuTxgqB7NUpn8JDgenSScexK1aruV4kz92VHgFocO KsRcP0Kr0oLWmznQ1a1adGwyXSvO5q3rmqKe/szB39j3OuWxhjxABvS+/OleLO3Ki7zD 2A3TpggQ0A0+EBKT4DAkxA1Ej1z0bem6N2O9SmzK8bHX2AwPSgZhzk7Gmrbiqq/yQLhQ uhK447Z4nLc+0T31EZ+T8zvuUCCOJOnXeJgkTklplJtmOVnuGVuvwzGAhdYk+f5gMWPl g0AMCqhdnqJKBtMq1DEhp31xfgrOCHUrM/0KWVHwOw1ymnvUjd62sfOheAxy9avH7bEy zmdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=YNGMt2qouNoUXdH413TRktpSCW/r9EbSGQMAu1iLP/M=; b=fnw9V6l4S3p8Ts3D2MNnkw5+MjQiw1+Wpk0fQxGWl4Br3lS6xtq7OeB8eFG0kksF3e nERk6vnWNShUrJVTH3L1PpibxeYA51MZbMcv53n+Js6Pi1OlK3LrX7gJrXB0p5i9lH6O e7kfS+b6BV8x2FWqv3R2O9OaYBjxATk73CTph18IPWVKSO5ECudLPp4oRm0RjOZPjxDA 5Z0fsoG1yAm0MkYIq3mp0OPoCZoifhCPCkwMM5b+GbXbiH4OC+YbxDmy1rSWZNvtIBFd MKh7NcZA6NqM/G4MWSlrjCv9ReFp4b2Q2lrigp+zB2FSWlat6E6h7GaVpZrLn+6A6iUp 109Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si8034295pgb.231.2018.12.09.14.09.45; Sun, 09 Dec 2018 14:09:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727994AbeLIWIS (ORCPT + 99 others); Sun, 9 Dec 2018 17:08:18 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37312 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727690AbeLIWIO (ORCPT ); Sun, 9 Dec 2018 17:08:14 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73L-0002pp-EV; Sun, 09 Dec 2018 21:55:55 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72a-0003IE-S4; Sun, 09 Dec 2018 21:55:08 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Jens Axboe" , "Martin K. Petersen" , "Greg Edwards" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 076/328] block: move bio_integrity_{intervals,bytes} into blkdev.h In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Greg Edwards commit 359f642700f2ff05d9c94cd9216c97af7b8e9553 upstream. This allows bio_integrity_bytes() to be called from drivers instead of open coding it. Acked-by: Martin K. Petersen Signed-off-by: Greg Edwards Signed-off-by: Jens Axboe [bwh: Backported to 3.16: bio_integrity_intervals() was called bio_integrity_hw_sectors() and had a different implementation. Move it without renaming.] Signed-off-by: Ben Hutchings --- block/bio-integrity.c | 22 ---------------------- include/linux/blkdev.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 22 deletions(-) --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -194,32 +194,6 @@ int bio_integrity_enabled(struct bio *bi EXPORT_SYMBOL(bio_integrity_enabled); /** - * bio_integrity_hw_sectors - Convert 512b sectors to hardware ditto - * @bi: blk_integrity profile for device - * @sectors: Number of 512 sectors to convert - * - * Description: The block layer calculates everything in 512 byte - * sectors but integrity metadata is done in terms of the hardware - * sector size of the storage device. Convert the block layer sectors - * to physical sectors. - */ -static inline unsigned int bio_integrity_hw_sectors(struct blk_integrity *bi, - unsigned int sectors) -{ - /* At this point there are only 512b or 4096b DIF/EPP devices */ - if (bi->sector_size == 4096) - return sectors >>= 3; - - return sectors; -} - -static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, - unsigned int sectors) -{ - return bio_integrity_hw_sectors(bi, sectors) * bi->tuple_size; -} - -/** * bio_integrity_tag_size - Retrieve integrity tag space * @bio: bio to inspect * --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1542,6 +1542,32 @@ queue_max_integrity_segments(struct requ return q->limits.max_integrity_segments; } +/** + * bio_integrity_hw_sectors - Convert 512b sectors to hardware ditto + * @bi: blk_integrity profile for device + * @sectors: Number of 512 sectors to convert + * + * Description: The block layer calculates everything in 512 byte + * sectors but integrity metadata is done in terms of the hardware + * sector size of the storage device. Convert the block layer sectors + * to physical sectors. + */ +static inline unsigned int bio_integrity_hw_sectors(struct blk_integrity *bi, + unsigned int sectors) +{ + /* At this point there are only 512b or 4096b DIF/EPP devices */ + if (bi->sector_size == 4096) + return sectors >>= 3; + + return sectors; +} + +static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, + unsigned int sectors) +{ + return bio_integrity_hw_sectors(bi, sectors) * bi->tuple_size; +} + #else /* CONFIG_BLK_DEV_INTEGRITY */ struct bio; @@ -1608,6 +1634,18 @@ static inline bool blk_integrity_is_init { return 0; } + +static inline unsigned int bio_integrity_hw_sectors(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 */