PowerEdge: Faster Block Device Performance with NVMe PCIe SSD-based dm-cache on RHEL

Summary: The Device Mapper cache (dm-cache) can be used to improve performance of a block device by dynamically migrating data to a faster device.

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

NVMe based PCIe SSDs can act as the cache device for dm-cache using the user space tool set Logical Volume Manager (LVM) tools.

The virtual cache created by dm-cache is made of three physical devices. (Refer Fig1.) The Origin device is the slower destination storage device (HDD). The Cache device is used to store the user data and the meta cache stores the metadata like block placement, dirty flags, and other internal data.
In this case, we use the same device [Cache device] for both data blocks and metadata.

Diagram of dmcache in storage in LVM volumes 
Figure 1: Steps to setup and configure dm-cache using LVM tools.

 

Hardware Setup:

Origin Device [HDD]: /dev/sda1
Cache Device [NVMe based PCIe SSD] (Block/Meta): /dev/nvme0n1p1 

 

Software Setup:

Operating system: RHEL 7
Tools: LVM2 user space tools for dm-cache configuration

 

Configuration Steps:

Following are the steps to configure the Virtual device dm-cache using LVM.

Each step output maps to the block with numbering mentioned in Fig.1.

  1. Create 100 GB partition on the hard disk [Origin Device]
    parted -a optimal /dev/sda mkpart primary 1 100G 
    Note: This creates /dev/sda1
  2. Create a 10 GB partition on the NVMe PCIe SSD disk [Cache Device]
    parted -a optimal /dev/nvme0n1 mkpart primary 1 10G 
  3. Create a Volume group (cache) with the Origin and Cache device
    vgcreate cache /dev/sda1  /dev/nvme0n1p1 
    1. Check for the "cache" volume group using vgdisplay
      [root@localhost ~]# vgdisplay
      
      --- Volume group ---
      VG Name               cache
      System ID
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  7
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                2
      Open LV               0
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               103.36 GiB
      PE Size               4.00 MiB
      Total PE              26461
      Alloc PE / Size       25399 / 99.21 GiB
      Free  PE / Size       1062 / 4.15 GiB
      VG UUID               Zd8dNe-6Kdt-7qgY-dmSN-8WHe-4wqQ-euM3Ql 
  4. Create the Origin Device logical Volume (origin_device)
    lvcreate -l 90%FREE -n origin_device cache /dev/sda1 
  5. Create a cache meta data logical Volume (cache_meta)
    lvcreate -l 5%FREE -n cache_meta cache /dev/nvme0n1p1 
  6. Create a cache block data logical Volume (cache_block)
    lvcreate -l 80%FREE -n cache_block cache /dev/nvme0n1p1 
  7. Create a cache pool logical volume by combining cache block and cache meta data logical volumes (combining step 5 and 6)
    lvconvert --type cache-pool --poolmetadata cache/cache_meta cache/cache_block 
    Note: The created cache pool has the same name as "cache_block" that is the name of the cache block data logical volume created in step 6.
    1. This is the behavior of the tool. Check for the "cache" volume group using lvdisplay

      root@localhost ~]# lvdisplay
      --- Logical volume ---
      LV Path                /dev/cache/cache_block
      LV Name                cache_block
      VG Name                cache
      LV UUID                kWYQxP-Jdlr-JdxE-aleB-JJpj-3rmw-Q0cojx
      LV Write Access        read/write
      LV Creation host, time localhost.localdomain, 2014-06-28 09:05:32 -0400
      LV Status              available
      # open                 0
      LV Size                5.07 GiB
      Current LE             1297
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:2 
  8. Create a cache logical volume by linking the cache pool (step 7) logical volume and origin_device logical volume (step 4)

    lvconvert --type cache --cachepool cache/cache_block cache/origin_device 
    1. This creates the virtual cache device (dm-cache) orign_device as shown below as dm4.
      [root@localhost ~]# ls -l /dev/cache/origin_device
      lrwxrwxrwx. 1 root root 7 Jun 28 09:13 /dev/cache/origin_device -> ../dm-4 
  9. Format the Virtual cache device with a file system and use it.

    mkfs.ext4 /dev/cache/origin_device 

 

 

 

Performance Data:

Performance tests done using the FIO tool shows a great improvement of the read, write, and read-write mix operations.

Table-1 shows the FIO tool output of performance difference and the improvement in percentage with the dmcache in place compared to the normal drive (rotational drive) and Fig 2 shows the corresponding graph plot.

The test is done with 1M block size for Random Read, Random Write, and Random Read-Write mix (50%) on the Original hard drive(sda) and the drive with dmcache configured.
 

FIO at BS = 1M IOPS
DEVICE Read Write Read-Write
Drive with dm-cache 197 798 159
sda [original drive] 124 118 58
Improvement in % 58.87% 576.20% 174.13%

Table 1: Performance Improvement with dm-cache


Bar graph showing the performance difference between disks with dmcache and without 
Figure 2: Performance Improvement with dm-cache.


Conclusion: NVMe PCIe SSD-based dm-cache improves the performance of legacy spindle-based hard drives to a greater extent.

Affected Products

Red Hat Enterprise Linux Version 7, Red Hat Enterprise Linux Version 9, Red Hat Enterprise Linux Version 8

Products

PowerEdge XR2, PowerEdge C6420, PowerEdge C6520, PowerEdge C6525, PowerEdge C6615, PowerEdge C6620, PowerEdge R350, PowerEdge R360, PowerEdge R440, PowerEdge R450, PowerEdge R540, PowerEdge R550, PowerEdge R640, PowerEdge R6415, PowerEdge R650 , PowerEdge R650xs, PowerEdge R6515, PowerEdge R6525, PowerEdge R660, PowerEdge R660xs, PowerEdge R6615, PowerEdge R6625, PowerEdge R740, PowerEdge R740XD, PowerEdge R740XD2, PowerEdge R7415, PowerEdge R7425, PowerEdge R750, PowerEdge R750XA, PowerEdge R750xs, PowerEdge R7515, PowerEdge R7525, PowerEdge R760, PowerEdge R760XA, PowerEdge R760xd2, PowerEdge R760xs, PowerEdge R7615, PowerEdge R7625, PowerEdge R840, PowerEdge R860, PowerEdge R940, PowerEdge R940xa, PowerEdge R960, PowerEdge T350, PowerEdge T360, PowerEdge T440, PowerEdge T550, PowerEdge T560, PowerEdge T640, PowerEdge XE2420, PowerEdge XE7420, PowerEdge XE7440, PowerEdge XE8545, PowerEdge XE8640, PowerEdge XE9640, PowerEdge XE9680, PowerEdge XR11, PowerEdge XR12, PowerEdge XR4510c, PowerEdge XR4520c, PowerEdge XR5610, PowerEdge XR7620, PowerEdge XR8610t, PowerEdge XR8620t ...
Article Properties
Article Number: 000148672
Article Type: How To
Last Modified: 08 Apr 2025
Version:  5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.