[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202110140813.44C95229@keescook>
Date: Thu, 14 Oct 2021 08:14:31 -0700
From: Kees Cook <keescook@...omium.org>
To: Dave Kleikamp <dave.kleikamp@...cle.com>
Cc: Anton Altaparmakov <anton@...era.com>,
Christoph Hellwig <hch@....de>, Jens Axboe <axboe@...nel.dk>,
Coly Li <colyli@...e.de>, Mike Snitzer <snitzer@...hat.com>,
Song Liu <song@...nel.org>, David Sterba <dsterba@...e.com>,
Josef Bacik <josef@...icpanda.com>,
Theodore Ts'o <tytso@....edu>,
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
Ryusuke Konishi <konishi.ryusuke@...il.com>,
Konstantin Komarov <almaz.alexandrovich@...agon-software.com>,
Phillip Lougher <phillip@...ashfs.org.uk>,
Jan Kara <jack@...e.com>,
"linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
"dm-devel@...hat.com" <dm-devel@...hat.com>,
"drbd-dev@...ts.linbit.com" <drbd-dev@...ts.linbit.com>,
"linux-bcache@...r.kernel.org" <linux-bcache@...r.kernel.org>,
"linux-raid@...r.kernel.org" <linux-raid@...r.kernel.org>,
"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
"linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>,
"linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
"target-devel@...r.kernel.org" <target-devel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-btrfs@...r.kernel.org" <linux-btrfs@...r.kernel.org>,
"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
"jfs-discussion@...ts.sourceforge.net"
<jfs-discussion@...ts.sourceforge.net>,
"linux-nfs@...r.kernel.org" <linux-nfs@...r.kernel.org>,
"linux-nilfs@...r.kernel.org" <linux-nilfs@...r.kernel.org>,
"linux-ntfs-dev@...ts.sourceforge.net"
<linux-ntfs-dev@...ts.sourceforge.net>,
"ntfs3@...ts.linux.dev" <ntfs3@...ts.linux.dev>,
"reiserfs-devel@...r.kernel.org" <reiserfs-devel@...r.kernel.org>
Subject: Re: don't use ->bd_inode to access the block device size
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 <hch@....de> 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
Powered by blists - more mailing lists