Bug 1201947 - fix the way libblockdev handles sizes
Summary: fix the way libblockdev handles sizes
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: libblockdev
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Vratislav Podzimek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-13 22:58 UTC by mulhern
Modified: 2016-07-19 19:05 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-19 19:05:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1200812 0 unspecified CLOSED Blivet depends on library that can't handle sizes >= 16 EiB 2021-02-22 00:41:40 UTC

Internal Links: 1200812

Description mulhern 2015-03-13 22:58:09 UTC
Description of problem:

Problems with handling numbers that mean sizes in libblockdev.

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

0.6

How reproducible:

Quite.

Additional info:

1) Sizes can be larger than guint64 can accomodate, libblockdev needs to accomodate that in a _principled_ manner. An appropriate library should be explored for this, gmp might be an option. The fact of the matter is that when you add a bunch of numbers even if each is less than 2^64, you risk overflow. Every computation in libblockdev must address that fact. It might be possible to make use of introspection facilities to extract the necessary information from Size object after it has been passed to libblockdev plugin. blivet/bytesize Size class can be extended to provide methods that are required for this.
2) libblockdev should not be in the business of reading sizes from specs. The currently implemented mdraid and btrfs plugins use read_spec in order to return results from various interrogative methods for btrfs and mdraid. These methods should just read and chunk strings, somehow, and let client code decide how to
interpret the strings. Most places where size is determined statically I see something like "(1 MiB)", which I believe is some way of multiplying 1 by the numeric constant MiB. This is actually better than current approach in blivet/size, but is approximately what blockdev/size does. Of course, it will be necessary to make sure that (16 EiB) and others are handled nicely, i.e, (16 EiB) should not evaluate to 0.
3) There is no need to add additional named constants, e.g, PiB, TiB, unless they're actually used in the library.
4) Human readable is currently only used to eyeball some perfunctory C tests. So long as that's all its ever used for, there is no concern.
5) Tests which stress the plugins using sufficiently large values for sizes should be added to the test suite.
6) The use of floating point number in size computations should be eliminated (unless in human_readable, which doesn't matter unless the result is interpreted as a precise value somewhere, in which case it would have to be reevaluated). There are only a few of these, and I think they were eliminated
in devicelibs, so that might be a model.
7) Ad-hoc changes to blivet to ensure that blivet passes only values that are less than 2^^64 to libblockdev methods will compromise blivet without fixing the essential problem in libblockdev.

Comment 1 Fedora End Of Life 2016-07-19 19:05:35 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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