2020-11-17 14:47:42 +00:00
|
|
|
================================
|
2021-12-01 06:37:50 +00:00
|
|
|
RBD Persistent Write Log Cache
|
2020-11-17 14:47:42 +00:00
|
|
|
================================
|
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
.. index:: Ceph Block Device; Persistent Write Log Cache
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
Persistent Write Log Cache
|
2020-11-17 14:47:42 +00:00
|
|
|
===========================
|
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
The Persistent Write Log Cache (PWL) provides a persistent, fault-tolerant
|
|
|
|
write-back cache for librbd-based RBD clients.
|
2020-11-17 14:47:42 +00:00
|
|
|
|
|
|
|
This cache uses a log-ordered write-back design which maintains checkpoints
|
|
|
|
internally so that writes that get flushed back to the cluster are always
|
|
|
|
crash consistent. Even if the client cache is lost entirely, the disk image is
|
|
|
|
still consistent but the data will appear to be stale.
|
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
This cache can be used with PMEM or SSD as a cache device. For PMEM, the cache
|
|
|
|
mode is called ``replica write log (rwl)``. At present, only local cache is
|
|
|
|
supported, and the replica function is under development. For SSD, the cache
|
|
|
|
mode is called ``ssd``.
|
2020-11-17 14:47:42 +00:00
|
|
|
|
|
|
|
Usage
|
|
|
|
=====
|
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
The PWL cache manages the cache data in a persistent device. It looks for and
|
|
|
|
creates cache files in a configured directory, and then caches data in the
|
|
|
|
file.
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
The PWL cache depends on the exclusive-lock feature. The cache can be loaded
|
|
|
|
only after the exclusive lock is acquired.
|
2020-11-17 14:47:42 +00:00
|
|
|
|
|
|
|
The cache provides two different persistence modes. In persistent-on-write mode,
|
|
|
|
the writes are completed only when they are persisted to the cache device and
|
|
|
|
will be readable after a crash. In persistent-on-flush mode, the writes are
|
|
|
|
completed as soon as it no longer needs the caller's data buffer to complete
|
|
|
|
the writes, but does not guarantee that writes will be readable after a crash.
|
|
|
|
The data is persisted to the cache device when a flush request is received.
|
|
|
|
|
|
|
|
Initially it defaults to the persistent-on-write mode and it switches to
|
|
|
|
persistent-on-flush mode after the first flush request is received.
|
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
Enable Cache
|
2020-11-17 14:47:42 +00:00
|
|
|
========================================
|
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
To enable the PWL cache, set the following configuration settings::
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2022-04-13 03:33:36 +00:00
|
|
|
rbd_persistent_cache_mode = {cache-mode}
|
|
|
|
rbd_plugins = pwl_cache
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-05-06 09:20:23 +00:00
|
|
|
Value of {cache-mode} can be ``rwl``, ``ssd`` or ``disabled``. By default the
|
|
|
|
cache is disabled.
|
2021-01-22 05:25:29 +00:00
|
|
|
|
2022-10-30 17:06:57 +00:00
|
|
|
The ``rwl`` cache mode depends on libpmem library (part of PMDK). It should
|
|
|
|
be universally available on x86_64 architecture and may also be available on
|
|
|
|
ppc64le and aarch64 architectures on some distributions. It is not available
|
|
|
|
on s390x architecture.
|
|
|
|
|
2020-11-17 14:47:42 +00:00
|
|
|
Here are some cache configuration settings:
|
|
|
|
|
2021-01-22 05:25:29 +00:00
|
|
|
- ``rbd_persistent_cache_path`` A file folder to cache data. This folder must
|
|
|
|
have DAX enabled (see `DAX`_) when using ``rwl`` mode to avoid performance
|
|
|
|
degradation.
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-05-06 09:20:23 +00:00
|
|
|
- ``rbd_persistent_cache_size`` The cache size per image. The minimum cache
|
|
|
|
size is 1 GB.
|
2020-11-17 14:47:42 +00:00
|
|
|
|
|
|
|
The above configurations can be set per-host, per-pool, per-image etc. Eg, to
|
|
|
|
set per-host, add the overrides to the appropriate `section`_ in the host's
|
|
|
|
``ceph.conf`` file. To set per-pool, per-image, etc, please refer to the
|
|
|
|
``rbd config`` `commands`_.
|
|
|
|
|
|
|
|
Cache Status
|
|
|
|
------------
|
|
|
|
|
2021-12-01 06:37:50 +00:00
|
|
|
The PWL cache is enabled when the exclusive lock is acquired,
|
2021-05-06 09:20:23 +00:00
|
|
|
and it is closed when the exclusive lock is released. To check the cache status,
|
|
|
|
users may use the command ``rbd status``. ::
|
2020-11-17 14:47:42 +00:00
|
|
|
|
|
|
|
rbd status {pool-name}/{image-name}
|
|
|
|
|
|
|
|
The status of the cache is shown, including present, clean, cache size and the
|
2022-04-09 15:48:17 +00:00
|
|
|
location as well as some basic metrics.
|
2020-11-17 14:47:42 +00:00
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
$ rbd status rbd/foo
|
2022-04-09 15:48:17 +00:00
|
|
|
Watchers:
|
|
|
|
watcher=10.10.0.102:0/1061883624 client.25496 cookie=140338056493088
|
|
|
|
Persistent cache state:
|
|
|
|
host: sceph9
|
|
|
|
path: /mnt/nvme0/rbd-pwl.rbd.101e5824ad9a.pool
|
|
|
|
size: 1 GiB
|
|
|
|
mode: ssd
|
|
|
|
stats_timestamp: Sun Apr 10 13:26:32 2022
|
|
|
|
present: true empty: false clean: false
|
|
|
|
allocated: 509 MiB
|
|
|
|
cached: 501 MiB
|
|
|
|
dirty: 338 MiB
|
|
|
|
free: 515 MiB
|
|
|
|
hits_full: 1450 / 61%
|
|
|
|
hits_partial: 0 / 0%
|
|
|
|
misses: 924
|
|
|
|
hit_bytes: 192 MiB / 66%
|
|
|
|
miss_bytes: 97 MiB
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-12-27 07:06:49 +00:00
|
|
|
Flush Cache
|
|
|
|
-----------
|
|
|
|
|
|
|
|
To flush a cache file with ``rbd``, specify the ``persistent-cache flush``
|
|
|
|
command, the pool name and the image name. ::
|
|
|
|
|
|
|
|
rbd persistent-cache flush {pool-name}/{image-name}
|
|
|
|
|
|
|
|
If the application dies unexpectedly, this command can also be used to flush
|
|
|
|
the cache back to OSDs.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
$ rbd persistent-cache flush rbd/foo
|
|
|
|
|
2021-12-27 03:50:18 +00:00
|
|
|
Invalidate Cache
|
|
|
|
----------------
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-12-27 03:50:18 +00:00
|
|
|
To invalidate (discard) a cache file with ``rbd``, specify the
|
|
|
|
``persistent-cache invalidate`` command, the pool name and the image name. ::
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-12-27 03:50:18 +00:00
|
|
|
rbd persistent-cache invalidate {pool-name}/{image-name}
|
2020-11-17 14:47:42 +00:00
|
|
|
|
2021-12-27 03:50:18 +00:00
|
|
|
The command removes the cache metadata of the corresponding image, disables
|
2020-11-17 14:47:42 +00:00
|
|
|
the cache feature and deletes the local cache file if it exists.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
2021-12-27 03:50:18 +00:00
|
|
|
$ rbd persistent-cache invalidate rbd/foo
|
2020-11-17 14:47:42 +00:00
|
|
|
|
|
|
|
.. _section: ../../rados/configuration/ceph-conf/#configuration-sections
|
|
|
|
.. _commands: ../../man/8/rbd#commands
|
|
|
|
.. _DAX: https://www.kernel.org/doc/Documentation/filesystems/dax.txt
|