# SPDX-License-Identifier: GPL-2.0
#
# Block device snapshot module configuration
#

config BLK_SNAP
	tristate "Module for snapshots of block devices."
       #depends on BLK_FILTER
	help
	  Allow to create snapshots and track block changes for block devices.
	  Designed for creating backups for a simple block devices. Snapshots
	  are temporary and are released then backup is completed. Change block
	  tracking allows to create incremental or differential backups.

config BLK_SNAP_TRACKING_BLOCK_MINIMUM_SHIFT
	depends on BLK_SNAP
	int "The power of 2 for minimum tracking block size"
	default 16
	help
	  Minimum tracking block size by default is 64 KiB (shift 16).
	  Minimum tracking block size determines the minimum block size that
	  will marked as changed when at least one sector is overwritten.

	  Two tables are created to store information about block changes in
	  memory. In the table, one byte is reserved for one block.

	  Optimal tracking block size is automatically calculated so that the
	  number of blocks does not exceed
	  BLK_SNAP_TRACKING_BLOCK_MAXIMUM_COUNT.

config BLK_SNAP_TRACKING_BLOCK_MAXIMUM_COUNT
	depends on BLK_SNAP
	int "Maximum number of tracking blocks"
	default 2097152
	help
	  As the size of the block device grows, the size of the tracking block
	  size should also grow. To limit the size of the table, a limit is set
	  on the maximum number of blocks.

	  For example, for a 128 GiB block device with a tracking block size of
	  64 KiB, it will be divided into 2097152 blocks. And the size of two
	  tables for one block device will be 4 MiB.

config BLK_SNAP_CHUNK_MINIMUM_SHIFT
	depends on BLK_SNAP
	int "The power of 2 for minimum chunk size"
	default 18
	help
	  Minimum chunk size by default is 256 KiB (shift 18).
	  The chunk size determines the minimum block size that will be copied
	  to the difference storage when at least one sector is changed on the
	  original block device.

	  The difference storage is a collection of areas on block devices that
	  is used to store blocks overwritten on the original block device.

	  The smaller the size of this chunk, the more efficiently the
	  difference storage is used. But when the size of a chunk decreases,
	  the number of chunks increases, which means that increases the size
	  of the table in memory that stores information about the chunks.

	  Optimal block size will be automatically calculated so that the number
	  of blocks does not exceed BLK_SNAP_CHUNK_MAXIMUM_COUNT.

config BLK_SNAP_CHUNK_MAXIMUM_COUNT
	depends on BLK_SNAP
	int "Maximum number of snapshots chunks"
	default 2097152
	help
	  As the size of the block device grows, the size of the chunk
	  should also grow. To limit the size of the table, a limit is set on
	  the maximum number of chunks.

	  For example, for 512 GiB block device with a chunk size of
	  256 KiB, it will be divided into 2097152 chunks. On a 64-bit platform,
	  the size of the struct chunk is about 100 bytes. Thus, while holding
	  the snapshot, a 200 MiB table will be allocated for each such block
	  device.

config BLK_SNAP_CHUNK_MAXIMUM_IN_CACHE
	depends on BLK_SNAP
	int "Maximum chunks in memory cache"
	default 64
	help
	  Since reading and writing to snapshots is performed in large chunks,
	  a cache is implemented to optimize reading small portions of data
	  from the snapshot image. As the number of chunks in the cache
	  increases, memory consumption also increases.
	  Minimum recommended value is four.

config BLK_SNAP_FREE_DIFF_BUFFER_POOL_SIZE
	depends on BLK_SNAP
	int "Maximum size of the free buffers pool"
	default 128
	help
	  A buffer can be allocated for each chunk. After use, this buffer is
	  not released immediately, but is sent to the pool of free buffers.
	  However, if there are too many free buffers in the pool, then the
	  free buffers are immediately released.

	  Maximum size of the pool is regulated by this configuration.

config BLK_SNAP_DIFF_STORAGE_MINIMUM
	depends on BLK_SNAP
	int "Minimum allowable size of the difference storage in sectors"
	default 2097152
	help
	  The difference storage is a collection of areas on block devices that
	  is used to store blocks overwritten on the original block device.

	  When reached, an event is generated about the lack of free space.
	  After receiving this event, the user process can allocate additional
	  area on the block device and to expand the difference storage.

config BLK_SNAP_DEBUG_MEMORY_LEAK
	depends on BLK_SNAP
	bool "Enable memory leak detector"
	default n
	help
	  Enables debugging code to monitor memory consumption by the module.

	  If unsure, say N.

config BLK_SNAP_ALLOW_DIFF_STORAGE_IN_MEMORY
	depends on BLK_SNAP
	bool "Allow difference storage in memory"
	default n
	help
	  Enables the ability to create the difference storage in memory.
	  This allows to store in memory the blocks overwritten on the original
	  block device. But this leads to a significant consumption of RAM.

	  This feature can be useful for debugging. Alternatively, it can be
	  used for mobile phones or other devices, if it is guaranteed that
	  there will not be a significant number of writings while snapshot is
	  being held.

	  If unsure, say N.
