[DRBD-user] drbdmanage, lvm thinlv, wrong free pool space calculation

Gaudenz Steinlin gaudenz at durcheinandertal.ch
Thu May 12 17:58:58 CEST 2016

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


Hi

I ran into the same problem someone else previously reported here today:
http://lists.linbit.com/pipermail/drbd-user/2016-May/022909.html

I then looked into the code to better understand how drbdmanage
calculates the free space and discocered that the code makes wrong
assumptions about how lvmthin metadata allocation works. As described in
the lvmthin(7) manpage a thin pool lv actually consists of 2 hidden
lv's, one for the actual data and another much smaller one for metadata.

But the code in storage/lvm_thinlv.py calculates the free space as

total_space - %data_used*total_space - %metadata_used*total_space - %snap_used*total_space

Where total_space is the size of the data LV on the thin pool lv.

This is wrong because metadata is not allocated from the data lv and
should not be considered in this calculation. I had a thin pool which
was 50% full and the metadata was also 50% which resulted in 0 free
space :-(. See below for the actual relevant code.

IMO the free space should be calculated without even considering
metadata space used. If you want to make sure that there is enough
metadata space available this needs to be done in a separate
calculation.

I verified that removing meta_used on line 285 solves the problem and
drbdmanage then reports the correct free space.

Gaudenz

See storage/lvm_thinlv.py lines 253 to 285:
253                     size_data = self.discard_fraction(size_data)
254                     space_size = long(size_data)
255 
256                     # Data percentage
257                     data_perc = float(0)
258                     if len(data_part) > 0:
259                         try:
260                             data_perc = float(data_part) / 100
261                         except ValueError:
262                             pass
263 
264                     # Metadata percentage
265                     meta_perc = float(0)
266                     if len(meta_part) > 0:
267                         try:
268                             meta_perc = float(meta_part) / 100
269                         except ValueError:
270                             pass
271 
272                     # Snapshots percentage
273                     snap_perc = float(0)
274                     if len(snap_part) > 0:
275                         try:
276                             snap_perc = float(snap_part) / 100
277                         except ValueError:
278                             pass
279 
280                     # Calculate the amount of occupied space
281                     data_used = data_perc * space_size
282                     meta_used = meta_perc * space_size
283                     snap_used = snap_perc * space_size
284 
285                     space_used = data_used + meta_used + snap_used



More information about the drbd-user mailing list