From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 8F1B242104D for ; Fri, 15 Oct 2021 17:58:01 +0200 (CEST) Received: by mail-pj1-f50.google.com with SMTP id ls18-20020a17090b351200b001a00250584aso9636124pjb.4 for ; Fri, 15 Oct 2021 08:58:01 -0700 (PDT) Date: Fri, 15 Oct 2021 08:57:59 -0700 From: Kees Cook To: Christoph Hellwig Message-ID: <202110150857.A7E96DAE@keescook> References: <20211015132643.1621913-1-hch@lst.de> <20211015132643.1621913-9-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211015132643.1621913-9-hch@lst.de> Cc: Dave Kleikamp , jfs-discussion@lists.sourceforge.net, Mike Snitzer , linux-nvme@lists.infradead.org, Konstantin Komarov , Song Liu , dm-devel@redhat.com, target-devel@vger.kernel.org, reiserfs-devel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-nilfs@vger.kernel.org, linux-scsi@vger.kernel.org, OGAWA Hirofumi , linux-ext4@vger.kernel.org, Chaitanya Kulkarni , Josef Bacik , Coly Li , linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, David Sterba , Ryusuke Konishi , Anton Altaparmakov , Jens Axboe , linux-block@vger.kernel.org, linux-nfs@vger.kernel.org, Theodore Ts'o , linux-ntfs-dev@lists.sourceforge.net, Jan Kara , linux-fsdevel@vger.kernel.org, Phillip Lougher , ntfs3@lists.linux.dev, linux-btrfs@vger.kernel.org Subject: Re: [Drbd-dev] [PATCH 08/30] target/iblock: use bdev_nr_bytes instead of open coding it List-Id: "*Coordination* of development, patches, contributions -- *Questions* \(even to developers\) go to drbd-user, please." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Fri, Oct 15, 2021 at 03:26:21PM +0200, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > Reviewed-by: Chaitanya Kulkarni Is this basically an open-coded non-sb version of sb_bdev_nr_blocks()? Reviewed-by: Kees Cook > --- > drivers/target/target_core_iblock.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index 31df20abe141f..b1ef041cacd81 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -232,9 +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); > u32 block_size = bdev_logical_block_size(bd); > + unsigned long long blocks_long = > + div_u64(bdev_nr_bytes(bd), block_size) - 1; > > if (block_size == dev->dev_attrib.block_size) > return blocks_long; > -- > 2.30.2 > -- Kees Cook