From patchwork Thu Jun 23 13:30:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9195137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B12A66077D for ; Thu, 23 Jun 2016 13:29:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A04AF28459 for ; Thu, 23 Jun 2016 13:29:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 924B72845A; Thu, 23 Jun 2016 13:29:58 +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=-6.9 required=2.0 tests=BAYES_00,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 20BF228455 for ; Thu, 23 Jun 2016 13:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbcFWN3L (ORCPT ); Thu, 23 Jun 2016 09:29:11 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:60459 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751265AbcFWN3G (ORCPT ); Thu, 23 Jun 2016 09:29:06 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0M51UE-1baFC03Zh0-00zE7F; Thu, 23 Jun 2016 15:28:11 +0200 From: Arnd Bergmann To: Jens Axboe Cc: "Nicholas A . Bellinger" , Mike Christie , Andy Grover , Hannes Reinecke , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Davidlohr Bueso , linux-efi@vger.kernel.org, linux-block@vger.kernel.org, Arnd Bergmann Subject: [PATCH v2 3/3] target/iblock: use bdev_logical_block_count() Date: Thu, 23 Jun 2016 15:30:16 +0200 Message-Id: <20160623133016.3781907-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160623133016.3781907-1-arnd@arndb.de> References: <20160623133016.3781907-1-arnd@arndb.de> X-Provags-ID: V03:K0:11c3Wy/iks015af/kameWtW0yk8UAKKZ1tkxAKt5nRtsCoNcW/j Kl/jMCN3kJuHntGJbiDbhmXLLdUBAJDx2qEMBW4xiKhDx9PzIdd3DZoQ4o9HoX8CPu2r8XK q/iijyfSmk9aAXIMN3codGdDCR9NLJxykq/ceDu0ykGwITh7PR+a0lnKZPfeHkdECueMBKx 1HwobQ3fiCz6AB9R7Tz9w== X-UI-Out-Filterresults: notjunk:1; V01:K0:7JgAqogzuPg=:pGnEB/aNj2uGK0mWnO2eCS LGMhVhd79mPI0Z5lG7nrWt4q6Rjkgqj062WLcam+fLmCnpmk0RX12S61ymDDjWkA8Gfjg3M7/ udnchAPh4yAOr2UUnbzIMUA4TFJmvYyyaG7AKVXfIf8FydAoMfNaQ2xp1iSto7hGfGMxu7d8c kOd5TuvNZXTstnwzpIsxgl/4iIZDQKrdv9d5NO4ESjgtTiRBc3k66TBN+jsS+fnvZlMZkWo4/ hIlFeo0NrO4haYJn/TUEMSXkfcQg+bF0F76JE138rtfDVpPSYxAO63V8OBwT1nAC0OQ+Pa5gX UPyrq7USdJF0Ms7yvgf98EOrnd4eGqdqEnVp75WfHbO2TPVNhuDe1q4YmsoVqDVc3b8R9+DCq DTcVVIX3RzfL4defaQ6AvB9wPto+6MVi5n4KBUeKKD8Pc12G1lq+TZXzA/kmQOh6XgukLaG0O Vr1DupBC17pRz6u5oHQ0dl5Mwv4zP+5lu/x2mlP0gqcYCJd/q/pPXI0o20A+c3hpnEOWXLMZd lA0inm10DOCrKpNLno0s83H5nPYoyJ3xb02aZrLWCGTMw2Rrac30W2ApYQbygF8BeT9DNN34Z o5Cf2gagNjdyyfXZUH8DBfUfZRJfYqshOd5jwAFu9k1/GvpezkN5xsSvTw0lfQBIX6AOAa2xs xFmqy9x322YUfpkeyLU54Ke+US89Ma1cEjQ9ancMYIUMOs70KHgSuZoLJcX7HD3lZJ/w= 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 Enabling CONFIG_UBSAN_SANITIZE_ALL on ARM caused a link error: drivers/target/built-in.o: In function `iblock_emulate_read_cap_with_block_size.constprop.1': target_core_iblock.c:(.text+0xc2774): undefined reference to `____ilog2_NaN' target_core_iblock.c:(.text+0xc27f8): undefined reference to `__aeabi_uldivmod' target_core_iblock.c:(.text+0xc299c): undefined reference to `__aeabi_uldivmod' This is caused by gcc not behaving in the expected ways with __builtin_constant_p(), but it also points to somewhat inefficient code based on an expensive 64-bit division. I have introduced a better bdev_logical_block_count() now, so we can use that here. Signed-off-by: Arnd Bergmann --- drivers/target/target_core_iblock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 22af12f8b8eb..2dc0129553e1 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -201,9 +201,8 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( struct block_device *bd, struct request_queue *q) { - unsigned long long blocks_long = (div_u64(i_size_read(bd->bd_inode), - bdev_logical_block_size(bd)) - 1); u32 block_size = bdev_logical_block_size(bd); + unsigned long long blocks_long = bdev_logical_block_count(bd) - 1; if (block_size == dev->dev_attrib.block_size) return blocks_long;