mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
block: Return the soft block size for compat BLKBSZGET
BLKBSZGET returns the block device's soft block size, while BLKSSZGET
returns its logical sector size. The compat BLKBSZGET_32 handler uses
bdev_logical_block_size(), so it returns the wrong value when these
sizes differ.
For example, on an x86_64 kernel a native query of a RAM or loop device
with 512-byte logical sectors returns the initial soft block size of
4096 bytes, but an i386 process gets 512 bytes. This makes 32-bit
blockdev --getbsz and the BSZ column of --report disagree with native
queries, even without a preceding BLKBSZSET.
Use block_size() as the native handler and the pre-regression compat
handler do, and correct the case comment to describe the soft size.
Fixes: 9b81648cb5 ("compat_ioctl: simplify up block/ioctl.c")
Cc: [email protected]
Signed-off-by: Hungyu Lin <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Arnd Bergmann <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
+2
-2
@@ -835,8 +835,8 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
|
||||
return compat_put_ulong(argp, bdev_nr_sectors(bdev));
|
||||
|
||||
/* The data is compatible, but the command number is different */
|
||||
case BLKBSZGET_32: /* get the logical block size (cf. BLKSSZGET) */
|
||||
return put_int(argp, bdev_logical_block_size(bdev));
|
||||
case BLKBSZGET_32: /* get the soft block size (cf. BLKSSZGET) */
|
||||
return put_int(argp, block_size(bdev));
|
||||
case BLKBSZSET_32:
|
||||
return blkdev_bszset(file, mode, argp);
|
||||
case BLKGETSIZE64_32:
|
||||
|
||||
Reference in New Issue
Block a user