Codex

LVMCACHE

Section: (7)

Updated: LVM TOOLS (2) (2014-09-01)

Index?action=index Return to Main Contents


NAME

lvmcache --- LVM caching

DESCRIPTION

The cache logical volume type uses a small and fast LV to improve the performance of a large and slow LV. It does this by storing the frequently used blocks on the faster LV. LVM refers to the small fast LV as a cache pool LV. The large slow LV is called the origin LV. Due to requirements from dm-cache (the kernel driver), LVM further splits the cache pool LV into two devices - the cache data LV and cache metadata LV. The cache data LV is where copies of data blocks are kept from the origin LV to increase speed. The cache metadata LV holds the accounting information that specifies where data blocks are stored (e.g. on the origin LV or on the cache data LV). Users should be familiar with these LVs if they wish to create the best and most robust cached logical volumes.

Cache Terms

Cache Usage

The primary method for using a cache type logical volume:

0. create OriginLV

Create an LV or identify an existing LV to be the origin LV.

lvcreate -n OriginLV -L LargeSize VG SlowPVs

Example

  1. lvcreate -n lvol0 -L 100G vg

1. create CacheDataLV

Create the cache data LV. This LV will hold data blocks from the OriginLV. The size of this LV is the size of the cache and will be reported as the size of the cache pool LV.

lvcreate -n CacheDataLV -L CacheSize VG FastPVs

Example

  1. lvcreate -n cache0 -L 10G vg /dev/fast

2. create CacheMetaLV

Create the cache metadata LV. This LV will hold cache pool metadata. The size of this LV should be 1000 times smaller than the cache data LV, with a minimum size of 8MiB.

lvcreate -n CacheMetaLV -L MetaSize VG FastPVs

Example

  1. lvcreate -n cache0meta -L 12M vg /dev/fast

3. create CachePoolLV

Combine the data and metadata LVs into a cache pool LV. The behavior of the cache pool LV can be set in this step.

CachePoolLV takes the name of CacheDataLV.

CacheDataLV is renamed CachePoolLV_cdata and becomes hidden.

CacheMetaLV is renamed CachePoolLV_cmeta and becomes hidden.

lvconvert --cachepool VG/CacheDataLV --poolmetadata VG/CacheMetaLV

Example

  1. lvconvert --cachepool vg/cache0 --poolmetadata vg/cache0meta

4. create CacheLV

Create a cache LV by linking the cache pool LV to the origin LV. The user accessible cache LV takes the name of the origin LV, while the origin LV becomes a hidden LV with the name OriginLV_corig. This can be done while the origin LV is in use.

CacheLV takes the name of OriginLV.

OriginLV is renamed OriginLV_corig and becomes hidden.

lvconvert --type cache --cachepool VG/CachePoolLV VG/OriginLV

Example

  1. lvconvert --type cache --cachepool vg/cache0 vg/lvol0

Cache Removal

Removing a cache pool LV without removing its linked origin LV

This writes back data from the cache pool to the origin LV when necessary, then removes the cache pool LV, leaving the un-cached origin LV.

lvremove VG/CachePoolLV

Example

Removing an origin LV without removing its linked cache pool LV

This removes the origin LV, leaving the cache pool LV which can be linked to another origin LV.

lvremove VG/CacheLV

Example

Cache Topics

Tolerate device failures in a cache pool LV

Users who are concerned about the possibility of failures in their fast devices that could lead to data loss might consider making their cache pool sub-LVs redundant.

Writethough caching

Writethrough caching ensures that any data written will be stored both in the cache pool LV and on the origin LV. The loss of a device associated with the cache pool LV in this case would not mean the loss of any data. When combining the cache data LV and the cache metadata LV to form the cache pool LV, properties of the cache can be specified - in this case, writethrough vs. writeback.

Spare metadata LV

See lvmthin?(7) for a description of the "pool metadata spare" LV. The same concept is used for cache pools.

Automatic pool metadata LV

A cache data LV can be converted to cache pool LV without specifying a cache pool metadata LV. LVM will automatically create a metadata LV from the same VG.

lvcreate -n CacheDataLV -L CacheSize VG

lvconvert --cachepool VG/CacheDataLV

SEE ALSO

(5), lvchange?(8), lvcreate?(8), lvdisplay?(8), lvextend?(8), lvremove?(8), lvrename?(8), lvresize?(8), lvs?(8), vgchange?(8), vgmerge?(8), vgreduce?(8), vgsplit?(8)


Index

NAME

DESCRIPTION

Cache Terms

Cache Usage

0. create OriginLV

1. create CacheDataLV

2. create CacheMetaLV

3. create CachePoolLV

4. create CacheLV

Cache Removal

Removing a cache pool LV without removing its linked origin LV

Removing an origin LV without removing its linked cache pool LV

Cache Topics

Tolerate device failures in a cache pool LV

Writethough caching

Spare metadata LV

Automatic pool metadata LV

SEE ALSO