From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 97969420FEA for ; Wed, 13 Oct 2021 08:16:13 +0200 (CEST) Received: by mail-pg1-f175.google.com with SMTP id a73so1351643pge.0 for ; Tue, 12 Oct 2021 23:16:13 -0700 (PDT) Date: Tue, 12 Oct 2021 23:16:11 -0700 From: Kees Cook To: Christoph Hellwig Message-ID: <202110122315.7CFF5F6@keescook> References: <20211013051042.1065752-1-hch@lst.de> <20211013051042.1065752-13-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211013051042.1065752-13-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, linux-mtd@lists.infradead.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, 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 12/29] cramfs: use bdev_nr_sectors 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 Wed, Oct 13, 2021 at 07:10:25AM +0200, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > --- > fs/cramfs/inode.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c > index 2be65269a987c..3e44cc3ed0543 100644 > --- a/fs/cramfs/inode.c > +++ b/fs/cramfs/inode.c > @@ -209,7 +209,7 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset, > return read_buffers[i] + blk_offset; > } > > - devsize = mapping->host->i_size >> PAGE_SHIFT; > + devsize = bdev_nr_sectors(sb->s_bdev) >> (PAGE_SHIFT - SECTOR_SHIFT); I find this less readable than "bytes >> PAGE_SHIFT". I'd suggest this use a new bdev_nr_bytes() helper. -- Kees Cook