Bug 1684078 - blockdev –-getbsz forever return 4096.
Summary: blockdev –-getbsz forever return 4096.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: rawhide
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-28 11:23 UTC by izyk
Modified: 2020-12-04 07:16 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-02-28 13:00:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description izyk 2019-02-28 11:23:15 UTC
Description of problem:
“blockdev –-getbsz” forever return 4096.

Version-Release number of selected component (if applicable):
All.

How reproducible:
Run:
smartctl -i /dev/sda; blockdev --getbsz --getpbsz /dev/sda

Steps to Reproduce:
smartctl --getbsz /dev/sda

Actual results:
4096

Expected results:
512

Additional info:
This utility get me the strange
results (output reduced):

 smartctl -i /dev/sda; blockdev --getbsz --getpbsz /dev/sda
Device Model:     INTEL SSDSC2KB480G8
User Capacity:    480,103,981,056 bytes [480 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
4096
4096

 smartctl -i /dev/sdb; blockdev --getbsz --getpbsz /dev/sdb
Device Model:     HGST HUS722T2TALA604
User Capacity:    2,000,398,934,016 bytes [2.00 TB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    7200 rpm
Form Factor:      3.5 inches
4096
512

As you can see “-–getbsz” forever 4096.
But I think it must be forever 512.

Thank you.
Ilia.

Comment 1 Karel Zak 2019-02-28 13:00:46 UTC
Linux kernel provides three basic ioctls:

        case BLKBSZGET: /* get block device soft block size (cf. BLKSSZGET) */
                return put_int(arg, block_size(bdev));
        case BLKSSZGET: /* get block device logical block size */
                return put_int(arg, bdev_logical_block_size(bdev));
        case BLKPBSZGET: /* get block device physical block size */

--getbsz means BLKBSZGET. 

This size does not describes the device from "topology" point of view (like logical or physical sector), but it's block used internally by kernel for the device. 

It's for example on the fly modified by filesystem. See "mkfs.ext4 -b <size>" (default is 4KiB). You can also change from userspace by --setbsz (but the setting is valid only for the open descriptor). I'll add more information to the upstream blockdev.8 man page to make it more obvios.

So, not a bug. Although at first glance it seems strange :-)

Comment 2 Karel Zak 2019-02-28 13:06:24 UTC
Example:

# mkfs.ext4 -b $((2 * 1024)) /dev/sdc
# blockdev --getbsz /dev/sdc
4096

# mount /dev/sdc /mnt/test
# blockdev --getbsz /dev/sdc
2048

# umount /mnt/test
# blockdev --getbsz /dev/sdc
4096

Note that the default is usually 4096 due to system PAGE_SIZE.

Comment 3 izyk 2019-02-28 13:27:46 UTC
Oh.
Maybe you can add new parameter for more obvious.

--getlbsz - Get logical block (sector) size. Physical disk. See BLKSSZGET
analog of:
--getpbsz - Get physical block (sector) size.  Physical disk. See BLKPBSZGET
--getbsz  - Print blocksize in bytes. Used inside kernel. See BLKBSZGET

Or something similar.
Thank you.


Note You need to log in before you can comment on or make changes to this bug.