master - dev-type: dev_get_primary_dev fn: use dev_types and provide better return codes
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=65d0089c6477e6bc30ef64ce9fd79e8c855c4529 Commit: 65d0089c6477e6bc30ef64ce9fd79e8c855c4529 Parent: c6f48b7c1a0271255405346c50d6bee8cc8b9241 Author: Peter Rajnoha <[email protected]> AuthorDate: Wed Jun 12 12:14:11 2013 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Wed Jun 12 12:14:11 2013 +0200
dev-type: dev_get_primary_dev fn: use dev_types and provide better return codes
The dev_get_primary_dev fn now returns:
0 if the dev is already a primary dev
1 if the dev is a partition, primary dev is returned in "result" (output arg) -1 on error
This way, we can better differentiate between the error state and the state in which the dev supplied is not a partition in the caller (this was same return value before).
Also, if we already have information about the device type, we can check its major number against the list of known device types (cmd->dev_types) directly, so we don't need to go through the sysfs - we only check the major:minor pair which is a bit more straightforward and faster. If the dev_types does not have any info about this device type, the code just fallbacks to the original sysfs interface to get the partition info.
--- lib/device/dev-md.c | 2 +- lib/device/dev-type.c | 63 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 17 deletions(-)
lib/device/dev-md.c +1 -1
@@ -141,7 +141,7 @@ static int _md_sysfs_attribute_snprintf(char *path, size_t size,if (MAJOR (dev) == dt->blkext_major) {/* lookup parent MD device from blkext partition */ -if (!dev_get_primary_dev (dt, blkdev, &dev)) +if (dev_get_primary_dev (dt, blkdev, &dev) <1 )return ret; }
lib/device/dev-type.c +47 -16
132 lines not on this page · raw message