All of lore.kernel.org
 help / color / mirror / Atom feed
* dm-cache metadata size questions
@ 2015-11-23 22:43 Ian Pilcher
  0 siblings, 0 replies; only message in thread
From: Ian Pilcher @ 2015-11-23 22:43 UTC (permalink / raw)
  To: dm-devel

I am trying to come up with an algorithm to divide a single fast block
device into cache data and metadata, and I have several questions.

1.  Is metadata_size = 4MiB + 16 * nr_blocks still the correct formula
     for the metadata size?

2.  Am I correct in thinking that the number of blocks is based on the
     size of the cache data, rather than the origin device  -- i.e.
     nr_blocks = cache_size / block_size?

3.  Assuming that both of the above are correct, how does this look?

     AS: available space on "fast device"
     BS: block size
     MS: metadata size
     CS: cache data size
     NB: number of blocks

     NB = CS / BS

     MS = 4MiB + 16 * NB
        = 4MiB + 16 * (CS / BS)

     CS = AS - MS
        = AS - (4MiB + 16 * (CS / BS))
        = AS - 4MiB - 16 * CS / BS

     CS * BS = (AS - 4MiB) * BS - 16 * CS

     CS * BS + 16 * CS = (AS - 4MiB) * BS

     CS * (BS + 16) = (AS - 4MiB) * BS

     CS = (AS - 4MiB) * BS / (BS + 16)

     I.e. given the available space on my fast device, and the desired
     block size, I can calculate the cache data size as:

       cache_size = (available_size - 4MiB) * block_size /
                                                     (block_size + 16)

     and:

       metadata_size = available_size - cache_size

Yay algebra!

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-23 22:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23 22:43 dm-cache metadata size questions Ian Pilcher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.