Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3120904pxb; Tue, 12 Oct 2021 22:22:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4WP19o7Pq25kRkqcJEqiasQ4NRO9rXFD6YiImaGyFngRxJQFuEWIX+1/EnId31+mBr+Ij X-Received: by 2002:a63:83c7:: with SMTP id h190mr10766442pge.440.1634102545158; Tue, 12 Oct 2021 22:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634102545; cv=none; d=google.com; s=arc-20160816; b=WCt/Bi2J6gXqaZK7BYfhUAJQYCy55BIpLxALRjeVIiAsaApeM7jlhXs1tyMQ16F15a ebYooLgquQcKUFGoBkWGdgOrS5XB63EKm4QUU4fac3/4DvOIDB91qResMzk7W3mhVSZ5 Y4zDlv/fheKkehS0P+e/Oe8CFcAQwgoqZ/85QnkHGMDbQJ7AOftQGGMh3JjTcwgBRdoF gnPARIKkGapk7hzt+94s3f9mCTxCeDgPiinrrup9bVndWUuVgbfY5Yq9tEwKfpNvyR2r h0tmHV0KeSGsjF936TSPA2WfchMx+Wxjn47HxBCL+B4yxaTQv3CnaFVhKWLBYUWr8Mxa WxKA== 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=2DQz2WV/6nrwiR72242gRkqq8vUi4whhUhfjcP1bIOA=; b=JZHcHqKtjSLh6oGnb4EZNPKwAeE2tyY21olkECNopFGoKx9K5HD8VEu1zp1brpDRVV WwLXdzdgSmogjSx3VJhgBdRXjOltPaHFTOnm7grnKzscNJdG79cBlaGMIuRHufi7JCr8 cKUri6T98nQ3OSEABvT0DO5b2AulHjAkC3UFoorJBHZhpNUI1/Qkb0ttcIaed9B1eUzB wR0e0UdnEYn3Nwa3jt3vt+GbARVvwkar7UJXq3g67bCmbEh0BNHpgRvx/bc9QBRybY08 wI4wBjDUtKPbZoIfRvO61AvCnQBLxh7ea3gbzhoBoZibkZvdMuLlOKWkePwdCzzjKreB OEKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Xa7GvbJU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a187si18006593pge.330.2021.10.12.22.22.12; Tue, 12 Oct 2021 22:22:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@infradead.org header.s=casper.20170209 header.b=Xa7GvbJU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237684AbhJMFXu (ORCPT + 99 others); Wed, 13 Oct 2021 01:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236497AbhJMFXt (ORCPT ); Wed, 13 Oct 2021 01:23:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 124B2C061570; Tue, 12 Oct 2021 22:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=2DQz2WV/6nrwiR72242gRkqq8vUi4whhUhfjcP1bIOA=; b=Xa7GvbJUMqzfvYueWwVUK3Ux0y yeuPdYMbBAsv9epgGKu1vVzGX5AB9rd3WONNmNoS6gf48CEj/PVW94BBUJX37asekH4NgbraHAxgt WFbcI0BRgTaJDdjCqpms7HMs5C8IrEAXCvDE3EtdqraUh37FzwbfyoXL8GMrpEuNmvxXHABcddDQj moa/NVUObti9FIhR2tmwTqQ9CsQE6vspnROJ/w7q712HU1YfTb1JyVgsUDPAlJjCQuTqpVjblOKfa d1LJSuZJXvLyYiS+rDzxGbQbtLoGp+8OE0X2NKJLWnwHbMtue0DP5hxKAu9iTrDO6aiD7Uy0tXmC+ 90afCgmw==; Received: from 089144212063.atnat0021.highway.a1.net ([89.144.212.63] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1maWdg-0076G9-GA; Wed, 13 Oct 2021 05:17:32 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Coly Li , Mike Snitzer , Song Liu , David Sterba , Josef Bacik , "Theodore Ts'o" , OGAWA Hirofumi , Dave Kleikamp , Ryusuke Konishi , Anton Altaparmakov , Konstantin Komarov , Kees Cook , Phillip Lougher , Jan Kara , linux-block@vger.kernel.org, dm-devel@redhat.com, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev, reiserfs-devel@vger.kernel.org Subject: [PATCH 07/29] target/iblock: use bdev_nr_sectors instead of open coding it Date: Wed, 13 Oct 2021 07:10:20 +0200 Message-Id: <20211013051042.1065752-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211013051042.1065752-1-hch@lst.de> References: <20211013051042.1065752-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Use the proper helper to read the block device size. Signed-off-by: Christoph Hellwig --- drivers/target/target_core_iblock.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 31df20abe141f..ab7f5678ebc44 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -232,8 +232,9 @@ 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); + loff_t size = bdev_nr_sectors(bd) << SECTOR_SHIFT; + unsigned long long blocks_long = + div_u64(size, bdev_logical_block_size(bd)) - 1; u32 block_size = bdev_logical_block_size(bd); if (block_size == dev->dev_attrib.block_size) -- 2.30.2