From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id E1B5F420FDA for ; Thu, 14 Oct 2021 17:14:33 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id n11so4400757plf.4 for ; Thu, 14 Oct 2021 08:14:33 -0700 (PDT) Date: Thu, 14 Oct 2021 08:14:31 -0700 From: Kees Cook To: Dave Kleikamp Message-ID: <202110140813.44C95229@keescook> References: <20211013051042.1065752-1-hch@lst.de> <20211014062844.GA25448@lst.de> <3AB8052D-DD45-478B-85F2-BFBEC1C7E9DF@tuxera.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: "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" , Christoph Hellwig , "drbd-dev@lists.linbit.com" , "linux-nilfs@vger.kernel.org" , "linux-scsi@vger.kernel.org" , Anton Altaparmakov , "linux-ext4@vger.kernel.org" , Josef Bacik , Coly Li , "linux-block@vger.kernel.org" , "linux-bcache@vger.kernel.org" , David Sterba , Ryusuke Konishi , OGAWA Hirofumi , Jens Axboe , "linux-raid@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] don't use ->bd_inode to access the block device size 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 Thu, Oct 14, 2021 at 08:13:59AM -0500, Dave Kleikamp wrote: > On 10/14/21 4:32AM, Anton Altaparmakov wrote: > > Hi Christoph, > > > > > On 14 Oct 2021, at 07:28, Christoph Hellwig wrote: > > > > > > On Wed, Oct 13, 2021 at 07:10:13AM +0200, Christoph Hellwig wrote: > > > > I wondered about adding a helper for looking at the size in byte units > > > > to avoid the SECTOR_SHIFT shifts in various places. But given that > > > > I could not come up with a good name and block devices fundamentally > > > > work in sector size granularity I decided against that. > > > > > > So it seems like the biggest review feedback is that we should have > > > such a helper. I think the bdev_size name is the worst as size does > > > not imply a particular unit. bdev_nr_bytes is a little better but I'm > > > not too happy. Any other suggestions or strong opinions? > > > > bdev_byte_size() would seem to address your concerns? > > > > bdev_nr_bytes() would work though - it is analogous to bdev_nr_sectors() after all. > > > > No strong opinion here but I do agree with you that bdev_size() is a bad choice for sure. It is bound to cause bugs down the line when people forget what unit it is in. > > I don't really mind bdev_size since it's analogous to i_size, but > bdev_nr_bytes seems good to me. I much prefer bdev_nr_bytes(), as "size" has no units. -- Kees Cook