Thread (76 messages) 76 messages, 15 authors, 2021-10-14

Re: don't use ->bd_inode to access the block device size

From: Kees Cook <hidden>
Date: 2021-10-14 15:14:36
Also in: dm-devel, linux-bcache, linux-btrfs, linux-ext4, linux-fsdevel, linux-nfs, linux-nvme, linux-raid, linux-scsi, ntfs3, target-devel

On Thu, Oct 14, 2021 at 08:13:59AM -0500, Dave Kleikamp wrote:
On 10/14/21 4:32AM, Anton Altaparmakov wrote:
quoted
Hi Christoph,
quoted
On 14 Oct 2021, at 07:28, Christoph Hellwig [off-list ref] wrote:

On Wed, Oct 13, 2021 at 07:10:13AM +0200, Christoph Hellwig wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help