'Computing free block on a bitmap used for managing disk free blocks

Let's say we have a disk organized in logical and physical blocks of the same dimension BS. The disk contains multiple partitions: partition A is formatted with a file system that allocates NM = 12.5K blocks statically for metadatas (directories, file control block and a bitmap for managing free blocks), and ND = 100M blocks for file data.

Consider also that BS = 4KB.

In the bitmap, suppose we have 1 free block for each 2 used/allocated and that 5M (M = 2^20) free blocks are "isolated" (it means that each block is preceded and followed by an used/allocated block).

What are the most and the least favourable scenarios?

The solution is that ND/3 are free, it means 1 free every 3 blocks, 5M free blocks are "isolated". So the most favourable scenario is that all non-"isolated" free blocks are contiguous, so the largest interval on contiguous free blocks is given by

ND/3 - 1M blocks => 33.3M - 5M blocks = 28.3M blocks

And the least favourable scenario is when all non-"isolated" free block are grouped by couples of 2 contiguous free blocks interleaved with allocated blocks, so the largest free will be 2 blocks.

What I am not getting is the following step

ND/3 - 1M blocks => 33.3M - 5M blocks = 28.3M blocks

Could someone elaborate more on that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source