[DRBD-user] Can't shrink backing block device offline

Robert Altnoeder robert.altnoeder at linbit.com
Thu Jul 15 14:57:28 CEST 2021


On 15 Jul 2021, at 13:35, Adam Goryachev <mailinglists at websitemanagers.com.au> wrote:
> 
> I'm pretty sure the DRBD manual has some details on how to calculate exactly how much space you will need to leave available for the DRBD metadata

The formulas for exact calculation are not documented in the manual, because they are so complicated that you would not expect users to use them and actually get them right too.

Anyhow, if you *really* want to know, you get the net size (usable size for a filesystem) from the gross size (total available space) by calculating:

Snet = a4096(Sgross) - A4096(A1024(A8(A4096(Sgross) * 32768 ^ -1) * Cpeer) + Sal + Ssb

where
ax = floor align to x
Ax = ceiling align to x
Snet = usable size
Sgross = available space
Sal = size of the activity log
Ssb = size of the superblock
Cpeer = peer count

The superblock size Ssb is 4096 kiB. The activity log size Sal is 32 KiB by default, but may change if the al stripe size and/or al stripe count is changed (normally when using DRBD on a striped RAID device).

The other way around (gross size from usable size) is even more complicated, because it involves the calculation of the mathematical limit of the sum of fractions of the bitmap size, but for additional fun, you have to do the whole calculation with integer arithmetic and with a couple alignments added in.

The only place where those accurate calculations are currently used, in both directions, gross to net and net to gross, is in the LINSTOR controller.

For practical purposes, it’s normally sufficient to calculate Sgross / 32768 * Cpeer + 1 MiB. So you’re basically making the device too large (or the filesystem too small), that way you end up with a bit more space for the meta data than what you actually need. That is also what is documented in the DRBD User’s Guide.

Cheers,
Robert



More information about the drbd-user mailing list