Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
lvm2
device-use-BLKPBSZGET-for-physical-block-size.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File device-use-BLKPBSZGET-for-physical-block-size.patch of Package lvm2
From 0ee0f1b9c1ee55c745a78302cdd0f8d93680e318 Mon Sep 17 00:00:00 2001 From: Liuhua Wang <lwang@suse.com> Date: Mon, 2 Nov 2015 13:48:17 +0800 Subject: [PATCH] device: use BLKPBSZGET for physical block size only if the op is available, otherwise use logical block size Upstream-commit: 3652083f38ca21276c8467f54eeaa8f1365ec6fe --- lib/device/dev-io.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c index 1f88d9e..3b0d32e 100644 --- a/lib/device/dev-io.c +++ b/lib/device/dev-io.c @@ -137,16 +137,7 @@ int dev_get_block_size(struct device *dev, unsigned int *physical_block_size, un if (needs_open && !dev_open_readonly(dev)) return_0; - if (dev->phys_block_size == -1) { - if (ioctl(dev_fd(dev), BLKPBSZGET, &dev->phys_block_size) < 0) { - log_sys_error("ioctl BLKPBSZGET", name); - r = 0; - goto out; - } - log_debug("%s: physical block size is %u bytes", name, dev->phys_block_size); - } - - if (dev->block_size == -1) { + if (dev->block_size == -1) { if (ioctl(dev_fd(dev), BLKBSZGET, &dev->block_size) < 0) { log_sys_error("ioctl BLKBSZGET", name); r = 0; @@ -155,6 +146,23 @@ int dev_get_block_size(struct device *dev, unsigned int *physical_block_size, un log_debug("%s: block size is %u bytes", name, dev->block_size); } +#ifdef BLKPBSZGET + /* BLKPBSZGET is available in kernel >= 2.6.32 only */ + if (dev->phys_block_size == -1) { + if (ioctl(dev_fd(dev), BLKPBSZGET, &dev->phys_block_size) < 0) { + log_sys_error("ioctl BLKPBSZGET", name); + r = 0; + goto out; + } + log_debug("%s: physical block size is %u bytes", name, dev->phys_block_size); + } +#else + /* if we can't get physical block size, just use logical block size instead */ + dev->phys_block_size = dev->block_size; + log_debug("%s: physical block size can't be determined, using logical " + "block size of %u bytes instead", name, dev->phys_block_size); +#endif + *physical_block_size = (unsigned int) dev->phys_block_size; *block_size = (unsigned int) dev->block_size; out: -- 1.8.4.5
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor