Smart Prefetch

User Guide

Issue 02 Date 2021-03-30

HUAWEI TECHNOLOGIES CO., LTD.

Copyright © Huawei Technologies Co., Ltd. 2021. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means without prior written consent of Huawei Technologies Co., Ltd.

Trademarks and Permissions

and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd. All other trademarks and trade names mentioned in this document are the property of their respective holders.

Notice The purchased products, services and features are stipulated by the contract made between Huawei and the customer. All or part of the products, services and features described in this document may not be within the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information, and recommendations in this document are provided "AS IS" without warranties, guarantees or representations of any kind, either express or implied.

The information in this document is subject to change without notice. Every effort has been made in the preparation of this document to ensure accuracy of the contents, but all statements, information, and recommendations in this document do not constitute a warranty of any kind, express or implied.

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. i Smart Prefetch User Guide Contents

Contents

1 Introduction...... 1 2 Environment Preparations...... 3 2.1 Server Environment...... 3 2.2 Installing -tools...... 3 3 Compiling and Installing Software...... 5 3.1 Compiling bcache...... 5 3.2 Installing and Configuring bcache...... 6 3.3 Installing and Configuring acache_client and hcache...... 7 4 Using the Software...... 10 4.1 Setting Smart Prefetch to Start Upon System Boot...... 10 4.2 Enabling Smart Prefetch for Distributed Storage...... 11 4.2.1 Configuring bcache...... 11 4.2.2 Starting the Smart Prefetch Engine...... 11 4.3 Disabling Smart Prefetch for Distributed Storage...... 11 4.3.1 Stopping the Smart Prefetch Engine...... 12 4.3.2 Stopping bcache...... 12 4.4 Enabling the Big Data Smart Prefetch...... 12 4.4.1 Precautions...... 12 4.4.2 Configuring bcache...... 12 4.4.3 Starting the Smart Prefetch Engine...... 15 4.5 Disabling the Big Data Smart Prefetch...... 16 4.5.1 Stopping the Smart Prefetch Engine...... 16 4.5.2 Stopping bcache...... 16 4.6 Querying Versions...... 18 4.7 About acache_client and hcache Logs...... 18 4.8 Querying I/O Information...... 19 4.9 Troubleshooting...... 20 4.9.1 Drive Faults...... 20 4.9.2 Drive Faults...... 20 4.9.3 sequential_cutoff Is Missing...... 21 4.9.4 The bcache Device Is Abnormal After the Server Is Rebooted...... 21 4.9.5 Failure to Automatically Register with bcache After the Server is Rebooted...... 22

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. ii Smart Prefetch User Guide Contents

A Change History...... 24

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. iii Smart Prefetch User Guide 1 Introduction

1 Introduction

In storage I/O-intensive scenarios such as Spark and HBase components in distributed storage and big data, the performance of accessing I/O storage devices has a significant impact on the overall service performance. Users are also concerned about the cost per gigabyte of storage devices. The contradiction between storage capacity and I/O performance will exist for a long period of time. It is a good practice to use small-capacity, high-speed storage media as cache drives. Cache drives improve the overall storage I/O performance. They store the predicted I/O data that may be accessed again so that the data can be directly obtained from the high-speed cache. Figure 1-1 and Figure 1-2 illustrate the smart prefetch software architecture for distributed storage and big data respectively.

Figure 1-1 Smart prefetch software architecture for distributed storage

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 1 Smart Prefetch User Guide 1 Introduction

Figure 1-2 Smart prefetch software architecture for big data

NO TE

● I/O storage devices include hard disk drives (HDDs) and solid-state drives (SSDs). ● The performance here refers to the bandwidth, latency, and number of operations per unit time for accessing I/O storage devices. ● Small-capacity, high-speed storage media may be random access memory (RAM) drives or Non-Volatile Memory express (NVMe) SSDs. The smart prefetch function uses high-speed cache drives and efficient prefetch algorithms to improve the storage I/O performance, thus improving the overall system performance in I/O-intensive scenarios. The smart prefetch function consists of the following modules: 1. Huawei smart prefetch driver in kernel mode: bcache 2. Huawei smart prefetch engine framework in user mode: acache_client 3. Huawei smart prefetch engine algorithm in user mode: hcache 4. bcache configuration tool: bcache-tools

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 2 Smart Prefetch User Guide 2 Environment Preparations

2 Environment Preparations

2.1 Server Environment 2.2 Installing bcache-tools

2.1 Server Environment

Table 2-1 (OS) requirements

OS Version

CentOS release 7.6.1810 (AltArch)

Table 2-2 Software requirements

Software Version Description

GCC 7.3.0 The acache_client is compiled in the GCC 7.3.0 environment. Ensure that the GCC version has been upgraded to 7.3.0.

GNU Make - Default version for CentOS 7.6.

bcache-tools - See 2.2 Installing bcache-tools.

2.2 Installing bcache-tools

Step 1 Install the dependency package libblkid-devel. yum install libblkid-devel

Step 2 Download bcache-tools from the following link:

https://github.com/g2p/bcache-tools/tree/v1.0.8

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 3 Smart Prefetch User Guide 2 Environment Preparations

Step 3 Compile and install bcache-tools. make && make install

----End

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 4 Smart Prefetch User Guide 3 Compiling and Installing Software

3 Compiling and Installing Software

3.1 Compiling bcache 3.2 Installing and Configuring bcache 3.3 Installing and Configuring acache_client and hcache

3.1 Compiling bcache

Preparing the Compilation Environment

Step 1 Check that the ISO image CentOS-7-aarch64-Everything-1810.iso is used for the installation.

Step 2 Check the OS version. uname -a

An example output of the OS version: Linux localhost.localdomain 4.14.0-115.10.1.el7a.aarch64 #1 SMP Thu Nov 26 14:15:20 CST 2020 aarch64 aarch64 aarch64 GNU/Linux

Step 3 Check the GCC version. gcc -v

NO TE

The recommended GCC version is GCC 4.8.5 (the default version for CentOS 7.6).

An example output of the GCC version: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/4.8.5/lto-wrapper Target: aarch64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with- bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads= -- enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable- gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=,c++,objc,obj-c ++,java,fortran,ada,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/ BUILD/gcc-4.8.5-20150702/obj-aarch64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/ gcc-4.8.5-20150702/obj-aarch64-redhat-linux/cloog-install --enable-gnu-indirect-function --build=aarch64- redhat-linux model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 5 Smart Prefetch User Guide 3 Compiling and Installing Software

Step 4 Check that the kernel header file has been installed. ls /usr/src/kernels/$(uname -r) An example output of the header file information: arch block certs crypto drivers firmware fs include init ipc Kconfig kernel lib Makefile mm Module.symvers net samples scripts security sound System.map tools usr virt

----End

Compiling the Source Code

Step 1 Download the source code of the smart prefetch bcache from the following link: https://github.com/kunpengcompute/bcache Step 2 Install the kernel development software package. yum install kernel-devel-4.14.0-115.el7a.0.1 Step 3 Perform the compilation in the source code directory drivers/md/bcache. make -C /lib/modules/4.14.0-115.el7a.0.1.aarch64/build M=$(pwd) Step 4 Obtain the generated file bcache.ko.

----End

3.2 Installing and Configuring bcache

Installing bcache Install the bcache.ko file, which you compiled in 3.1 Compiling bcache.

Step 1 Obtain the bcache.ko file. Step 2 View the reference count of the bcache module. lsmod | grep -w bcache Check that the reference count is 0. bcache 458752 0 Step 3 Check that bcache.ko is not loaded in the current environment. modprobe -r bcache Alternatively, rmmod bcache Step 4 Delete the installation directory. rm -rf /lib/modules/$(uname -r)/kernel/drivers/md/bcache Step 5 Create an installation directory. mkdir -p /lib/modules/$(uname -r)/kernel/drivers/md/bcache Step 6 Copy bcache.ko to the installation directory. cp bcache.ko /lib/modules/$(uname -r)/kernel/drivers/md/bcache Step 7 Compress bcache.ko. xz -z /lib/modules/$(uname -r)/kernel/drivers/md/bcache/bcache.ko Step 8 Update the dependency of bcache.ko. depmod -a

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 6 Smart Prefetch User Guide 3 Compiling and Installing Software

Step 9 Update bcache.ko in initramfs. --add-drivers bcache -f /boot/initramfs-$(uname -r).img

Step 10 Check whether bcache.ko is successfully installed.

If the two commands output the same file information, the installation is successful. lsinitrd /boot/initramfs-$(uname -r).img | grep bcache.ko.xz -rw-r--r-- 1 root root 997136 Nov 30 11:45 usr/lib/modules/4.14.0-115.el7a.0.1.aarch64/kernel/drivers/md/ bcache/bcache.ko.xz ls -l /lib/modules/$(uname -r)/kernel/drivers/md/bcache/bcache.ko.xz -rw-r--r-- 1 root root 997136 Nov 30 11:45 /lib/modules/4.14.0-115.el7a.0.1.aarch64/kernel/drivers/md/ bcache/bcache.ko.xz

Step 11 Load bcache.ko. modprobe bcache

----End

Configuring bcache

Step 1 In bcache.conf, set the load parameters of the bcache.ko module.

If the value of acache_size is 20 MB, a 20 MB of physical memory is allocated to the bcache as the buffer for storing I/O information. echo "options bcache acache_size=20975616" > /etc/modprobe.d/bcache.conf

----End

3.3 Installing and Configuring acache_client and hcache

Installing acache_client and hcache Using RPM

Step 1 From the official website, download the RPM installation package (hcache included) and digital certificate of acache_client: ● Method 1: Huawei Enterprise website acache_client-1.0.0_0.10.0-1.el7.aarch64.rpm ● Method 2: Huawei Carrier website acache_client-1.0.0_0.10.0-1.el7.aarch64.rpm

Table 3-1 lists the default RPM installation files and paths.

Table 3-1 Installation files and paths

File Description Path

acache_client Smart prefetch framework /usr/local/bin/

bcache.conf bcache configuration file /etc/modprobe.d/

acache_client.se Configuration file required for using /usr/lib// rvice systemctl to start acache_client system/

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 7 Smart Prefetch User Guide 3 Compiling and Installing Software

File Description Path

hcache_config.cf hcache configuration file /usr/local/bin/ g

libhcache.so. hcache library file /usr/lib64/ [Version number]

Step 2 After obtaining the installation package, verify its integrity and consistency for security purposes. Perform the verification: 1. Obtain the software digital certificate and installation package. For details, see Step 1. 2. Obtain the verification tool and method from the following link: https://support.huawei.com/enterprise/en/tool/pgp-verify-TL1000000054 3. Verify the software package integrity by following the procedure described in the OpenPGP Signature Verification Guide obtained in 2. Step 3 Start the installation.

CA UTION

Use the root permission to start the installation.

● If it is the initial installation, run the following command: rpm -ivh acache_client-x.x.x_x.x.x-1.el7.aarch64.rpm ● If it is an upgrade, run the following command: rpm -U acache_client-x.x.x_x.x.x-1.el7.aarch64.rpm

NO TE

During the installation, if the message "package acache_client... is already installed" is displayed, continue the installation using either of the following methods:

● Run the rpm -e acache_client command to uninstall the RPM package and then run the rpm -ivh command to install it. ● Run the rpm -ivh acache_client-x.x.x_x.x.x-1.el7.aarch64.rpm -force command.

----End

Configuring hcache The smart prefetch algorithm hcache provides the initial configuration file hcache_config.cfg, which is stored in the same directory as acache_client by default, that is, /usr/local/bin. The algorithm reads the file as the initial parameter during the initial loading.

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 8 Smart Prefetch User Guide 3 Compiling and Installing Software

Table 3-2 describes the configuration items of hcache_config.cfg. After the modification is complete, restart acache_client. For details, see 4.5.1 Stopping the Smart Prefetch Engine and 4.4.3 Starting the Smart Prefetch Engine.

Table 3-2 Configuration items of hcache_config.cfg Parameter Defaul Value Description t Scope Initial Value

g_pagecache 1 [0,1] Indicates whether to allow the prefetch ReadaheadCo algorithm to take over the pagecache ntrol function. It is determined by you. ● If the value is 1, the takeover is enabled. The smart prefetch algorithm dynamically modifies the prefetch parameters of pagecache, and works with bcache to prefetch data. ● If the value is 0, the takeover is disabled. The smart prefetch algorithm works only on bcache.

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 9 Smart Prefetch User Guide 4 Using the Software

4 Using the Software

4.1 Setting Smart Prefetch to Start Upon System Boot 4.2 Enabling Smart Prefetch for Distributed Storage 4.3 Disabling Smart Prefetch for Distributed Storage 4.4 Enabling the Big Data Smart Prefetch 4.5 Disabling the Big Data Smart Prefetch 4.6 Querying Versions 4.7 About acache_client and hcache Logs 4.8 Querying I/O Information 4.9 Troubleshooting

4.1 Setting Smart Prefetch to Start Upon System Boot Set bcache and acache_client to start upon system boot.

Setting bcache

Step 1 Configure the bcache.ko module to be automatically loaded upon system boot. echo "bcache" > /etc/modules-load.d/bcache.conf

----End

Setting acache_client

Step 1 If you do not want to run the command as the root user, change the owning user and user group of the /dev/acache device. View the user and user group of the /dev/acache device.

ll /dev/acache

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 10 Smart Prefetch User Guide 4 Using the Software

Step 2 Modify the acache_client.service file. Set the user and user group to the current owning user and user group of the /dev/acache device.

Step 3 Set acache_client to start upon system boot. sudo systemctl enable acache_client

----End

NO TE

You can disable the automatic startup if necessary. sudo systemctl disable acache_client

4.2 Enabling Smart Prefetch for Distributed Storage

4.2.1 Configuring bcache

Creating a bcache Drive for the Data Drive

Step 1 Erase the file systems on the data drive. wipefs -a /dev/sdb --force

Step 2 Create a bcache drive for the data drive. make-bcache -B /dev/sdb --wipe-bcache

----End

Creating a bcache Drive for the Cache SSD

For details, see Creating a bcache Drive for the Cache SSD. 4.2.2 Starting the Smart Prefetch Engine For details, see 4.4.3 Starting the Smart Prefetch Engine.

4.3 Disabling Smart Prefetch for Distributed Storage

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 11 Smart Prefetch User Guide 4 Using the Software

4.3.1 Stopping the Smart Prefetch Engine For details, see 4.5.1 Stopping the Smart Prefetch Engine. 4.3.2 Stopping bcache

Stopping the Cache SSD For details, see Stopping the bcache SSD.

Stopping the bcache Drive For details, see Stopping the bcache Drive.

Uninstalling the bcache Driver For details, see Uninstalling the bcache Driver.

4.4 Enabling the Big Data Smart Prefetch

4.4.1 Precautions In big data scenarios, after bcache is deployed for smart prefetch, the existing data will be lost. 4.4.2 Configuring bcache

CA UTION

Before enabling smart prefetch, stop the cluster service program.

NO TE

As an example, the following steps describe how to configure a bcache drive for the SDB drive.

Creating a bcache Drive for the Data Drive

Step 1 Delete the drive data, create a bcache drive, and format the bcache drive to the ext4 format. wipefs -a /dev/sdb --force make-bcache -B /dev/sdb --wipe-bcache mkfs.ext4 /dev/[bcache] Step 2 Modify the bcache drive parameters. 1. Obtain the actual parameter of max_sectors_kb (maximum request size allowed by the device). cat /sys/block/sdb/queue/max_sectors_kb The following information is displayed:

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 12 Smart Prefetch User Guide 4 Using the Software

[Maximum number of sectors on a data drive] (for example, 1024) 2. Obtain the actual parameter of read_ahead_kb (size of the -ahead data). cat /sys/block/sdb/queue/read_ahead_kb The following information is displayed: [Number of data drives to be read ahead] (for example, 128) 3. Set max_sectors_kb and read_ahead_kb based on the obtained parameters. echo Maximum number of sectors on a data drive > /sys/block/[bcache]/queue/max_sectors_kb echo Number of data drives to be read ahead > /sys/block/[bcache]/queue/read_ahead_kb

NO TE

For Maximum number of sectors on a data drive, Number of data drives to be read ahead, and [bcache], note the following: – Maximum number of sectors on a data drive and Number of data drives to be read ahead are subject to the actual values. Different data drives may have different parameters. – [bcache] is subject to the content of the /sys/block/ directory. All [bcache] devices in the directory must be processed in the same way.

----End

Creating a bcache Drive for the RAM Drive

Step 1 Create a RAM drive. modprobe brd rd_nr=12 rd_size=$((1048576))

NO TE

In the command, 12 indicates the number of cache drives, and 1048576 indicates the cache drive size (1 GB), which is appropriate for general big data scenarios.

Step 2 Format the cache drive into a bcache drive. make-bcache --wipe-bcache -b 262144 -C /dev/ram0

NO TE

In the command, 262144 indicates that the block size of the cache drive is 256 KB.

Step 3 Mount the cache drive to the bcache drive. echo $uuid > /sys/block/[bcache]/bcache/attach

NO TE

In the command, the value of $uuid is the value of uuid corresponding to cset.uuid in the command output. Show the value of $uuid: bcache-super-show /dev/ram0

Step 4 Modify the bcache policy. echo writearound > /sys/block/[bcache]/bcache/cache_mode echo 1 > /sys/block/[bcache]/bcache/clear_stats echo 0 > /sys/block/[bcache]/bcache/ echo 10 > /sys/block/[bcache]/bcache/writeback_percent echo 0 > /sys/block/[bcache]/bcache/cache/congested_read_threshold_us echo 0 > /sys/block/[bcache]/bcache/cache/congested_write_threshold_us echo 1 > /sys/block/[bcache]/bcache/read_bypass echo lru > /sys/block/[bcache]/bcache/cache/cache0/cache_replacement_policy

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 13 Smart Prefetch User Guide 4 Using the Software

NO TE

[bcache] is subject to the content of the /sys/block/ directory. All [bcache] devices in the directory must be processed in the same way.

----End

CA UTION

After a cache drive is created for the RAM drive, the system allocates a memory space to the bcache. If services require a large memory space, increase the service memory space to prevent the services from failing due to insufficient memory. For example, Spark Kmeans consumes a large amount of memory. Adjust the memory resource configuration of Yarn to ensure that services will not fail due to insufficient memory.

Creating a bcache Drive for the Cache SSD

Step 1 Ensure that there is an idle cache SSD. For example:

Step 2 Format the cache drive into a bcache drive. make-bcache --wipe-bcache -b 262144 -C /dev/nvme0n1p1 echo /dev/nvme0n1p1 > /sys/fs/bcache/register

NO TE

In the command, 262144 indicates that the block size of the cache drive is 256 KB. Step 3 Mount the cache drive to the bcache drive. echo $uuid > /sys/block/[bcache]/bcache/attach

NO TE

In the command, the value of $uuid is the value of uuid corresponding to cset.uuid in the command output. Show the value of $uuid: bcache-super-show /dev/nvme0n1p1 Step 4 Modify the bcache policy. echo writeback > /sys/block/[bcache]/bcache/cache_mode echo 1 > /sys/block/[bcache]/bcache/clear_stats echo 0 > /sys/block/[bcache]/bcache/readahead echo 10 > /sys/block/[bcache]/bcache/writeback_percent

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 14 Smart Prefetch User Guide 4 Using the Software

echo 0 > /sys/block/[bcache]/bcache/cache/congested_read_threshold_us echo 0 > /sys/block/[bcache]/bcache/cache/congested_write_threshold_us echo 0 > /sys/block/[bcache]/bcache/cache/read_bypass echo 0 > /sys/block/[bcache]/bcache/sequential_cutoff echo lru > /sys/block/[bcache]/bcache/cache/cache0/cache_replacement_policy Step 5 Modify the queue directory parameters of the bcache. In the following command, set the value of max_sectors_kb to a proper value based on the back-end drive configuration. echo 1024 > /sys/block/[bcache]/queue/max_sectors_kb

NO TE

[bcache] is subject to the content of the /sys/block/ directory. All [bcache] devices in the directory must be processed in the same way.

----End

Mounting the bcache Drive of the Data Drive

Step 1 Manually mount the data drive of the bcache drive. mount /dev/[bcache]/ data/[data]

NO TE

Set [bcache] and [data] based on the actual data drive directory.

----End

CA UTION

After creating the bcache drive, in /etc/fstab, delete the configuration of mounting the data drive upon system boot. Otherwise, the data drive is formatted into a non-bcache drive after the server is rebooted.

4.4.3 Starting the Smart Prefetch Engine

CA UTION

Ensure that the file system format of the bcache drive is ext4. Other file system formats are not supported. Run the lsblk -fs command to check whether the file system format of the bcache drive is ext4.

Step 1 Start the acache_client service. sudo systemctl start acache_client

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 15 Smart Prefetch User Guide 4 Using the Software

Step 2 Check whether the acache_client has been started successfully. sudo systemctl status acache_client

If the command output contains active (running), the acache_client has been started successfully.

NO TE

When the acache_client service is being started, if an error message is displayed starting "Warning: acache_client.service changed on disk. Run 'systemctl deamon-reload' to reload units.", resolve this problem by performing the following operations:

1. Reload the service configuration file. systemctl -reload 2. Start the acache_client service. systemctl start acache_client

----End

4.5 Disabling the Big Data Smart Prefetch

4.5.1 Stopping the Smart Prefetch Engine

Step 1 Stop the acache_client service. sudo systemctl stop acache_client

----End 4.5.2 Stopping bcache

WARNING

Before disabling intelligent prefetch, stop the cluster service program.

Stopping the bcache RAM Drive

Step 1 Unmount the cache drive. echo 1 > /sys/block/[bcache]/bcache/detach Step 2 Deregister the cache drive. echo 1 > /sys/fs/bcache/[uuid]/unregister Step 3 Delete the RAM drive. modprobe -r brd

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 16 Smart Prefetch User Guide 4 Using the Software

NO TE

In the previous command, note the following for [bcache] and [uuid]: 1. [bcache] is subject to the content of the /sys/block/ directory. All [bcache] devices in the directory must be processed in the same way. 2. Set the [uuid] value in the command based on the content in the /sys/fs/bcache directory. All [uuid] devices in the directory must be processed in the same way.

----End

Stopping the bcache SSD

Step 1 Unmount the cache drive. echo 1 > /sys/block/[bcache]/bcache/detach Step 2 Deregister the cache drive. echo 1 > /sys/fs/bcache/[uuid]/unregister

NO TE

In the previous command, note the following for [bcache] and [uuid]: 1. [bcache] is subject to the content of the /sys/block/ directory. All [bcache] devices in the directory must be processed in the same way. 2. Set the [uuid] value in the command based on the content in the /sys/fs/bcache directory. All [uuid] devices in the directory must be processed in the same way.

----End

Unmounting the Data Drive That Needs to Be Formatted as a bcache Drive

Step 1 Unmount the data drive that needs to be formatted as a bcache drive. umount /data/[data]

NO TE

Replace the unmount directory [data] with the actual name.

----End

Stopping the bcache Drive

Step 1 Stop the bcache drive. echo 1 > /sys/block/[bcache]/bcache/stop

NO TE

[bcache] is subject to the content of the /sys/block/ directory. All [bcache] devices in the directory must be processed in the same way.

----End

Uninstalling the bcache Driver

Step 1 Uninstall the bcache driver. modprobe -r bcache

----End

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 17 Smart Prefetch User Guide 4 Using the Software

4.6 Querying Versions

Querying the bcache Version

Step 1 Query the bcache version. modinfo bcache For example:

----End

Querying the acache_client and hcache Versions

Step 1 Query the acache_client and hcache versions. acache_client --version Alternatively,

acache_client -v

----End

4.7 About acache_client and hcache Logs The acache_client and hcache logs are stored in the acache_client.log and acache_client_[No.].log files in the /var/log/prefetch/ directory. The logs that were generated a long time ago are stored in the acache_client_[No.].log files. There can be up to 20 acache_client_[No.].log files. A log with a larger [No.] was generated earlier. By default, each log file is 10 MB, and info-level logs are printed. You can add options to the boot command to modify the log file size and log printing level. For example: ● Add the --logsize option to change the log size and --loglevel to change the log printing level. a. Set the size of a single log file to 20 MB (20,480 KB). acache_client --logsize=20480 b. Set the log printing level to ERROR. The ERROR level has four options:

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 18 Smart Prefetch User Guide 4 Using the Software

▪ 1: prints error logs. ▪ 2: prints warning logs. ▪ 3: prints info logs. ▪ 4: prints debug logs. acache_client --loglevel=4 ● Incorporate the log file size and log printing level settings into the acache_client.service file. a. Stop the acache_client. For details, see 4.5.1 Stopping the Smart Prefetch Engine. b. Modify the acache_client.service file. File path: /usr/lib/systemd/system/acache_client.service

CA UTION

When the acache_client is running, do not delete the acache_client.log file in the /var/log/prefetch/. Otherwise, logs cannot be generated. If the acache_client.log file is deleted by mistake, restart the acache_client to recover it.

4.8 Querying I/O Information The intelligent prefetch user-mode program acache_client provides the function of obtaining I/O information.

Step 1 Redirect I/O information to a file. acache_client -d > acache_client_trace The file contains the following information: op (I/O status), time, majorDev (primary device number), minorDev (secondary device number), offset (I/O address), and length (I/O length).

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 19 Smart Prefetch User Guide 4 Using the Software

----End

4.9 Troubleshooting

4.9.1 Drive Faults

Symptom Faulty drives exist in the system.

Handling Procedure Step 1 Stop intelligent prefetch. See 4.5 Disabling the Big Data Smart Prefetch for big data scenarios or 4.3 Disabling Smart Prefetch for Distributed Storage for distributed storage scenarios. Step 2 Replace the faulty drives. Step 3 Start intelligent prefetch. See 4.4 Enabling the Big Data Smart Prefetch for big data scenarios or 4.2 Enabling Smart Prefetch for Distributed Storage for distributed storage scenarios. ----End 4.9.2 Cache Drive Faults

Symptom Faulty cache drives exist in the system.

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 20 Smart Prefetch User Guide 4 Using the Software

Handling Procedure

Step 1 Stop intelligent prefetch. See 4.5 Disabling the Big Data Smart Prefetch for big data scenarios or 4.3 Disabling Smart Prefetch for Distributed Storage for distributed storage scenarios. Step 2 Replace the faulty cache drives. Step 3 Start intelligent prefetch. See 4.4 Enabling the Big Data Smart Prefetch for big data scenarios or 4.2 Enabling Smart Prefetch for Distributed Storage for distributed storage scenarios.

----End 4.9.3 sequential_cutoff Is Missing

Symptom If the sequential_cutoff function is missing in the official CentOS 7.6 kernel, the following information is displayed:

# echo 4M > /sys/block/bcache0/bcache/sequential_cutoff -bash: /sys/block/bcache0/bcache/sequential_cutoff: Permission denied

Handling Procedure The cause of this problem is that the official CentOS 7.6 kernel does not include the sequential_cutoff function. To resolve this problem, obtain the official kernel and modify the kernel configuration file.

Step 1 Enable the CONFIG_BCACHE macro definition. Step 2 Recompile the kernel. Step 3 Upgrade the kernel. Step 4 Compile and install bcache. For details, see 3 Compiling and Installing Software.

----End 4.9.4 The bcache Device Is Abnormal After the Server Is Rebooted

Symptom After the server is rebooted unexpectedly, the make-bcache command fails to be executed and the bcache.ko file fails to be uninstalled.

Handling Procedure

Step 1 Check whether bcache is occupied by applications. lsmod | grep bcache

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 21 Smart Prefetch User Guide 4 Using the Software

Step 2 If bcache is being used by applications, check for the following issues: 1. Check whether a cache SSD exists. If a bcache drive has been created, deregister it. For details, see Stopping the bcache SSD. 2. Check whether a bcache device exists. If a bcache device exists and you want to replace the bcache driver, stop the bcache device. For details, see Stopping the bcache Drive. 3. Check whether the back-end drive directory /sys/block/sd[$i] contains the bcache directory. If it contains the bcache directory, run the following command: echo 1 > /sys/block/sd[$i]/bcache/stop 4. Check whether the acache_client service program is running. If it is running, stop it. systemctl stop acache_client

----End 4.9.5 Failure to Automatically Register with bcache After the Server is Rebooted

Symptom When a RAM drive is used as a cache drive, it cannot be automatically registered with bcache after the server is rebooted. Specifically, after the lsblk command is executed, the bcache drive of each back-end drive is missing. The cause is that the bcache information stored on the RAM drive is lost when the server is rebooted. In this case, the needed bcache information does not exist on the RAM drive and the registration fails.

Handling Procedure Perform the following steps to manually register the RAM drive with bcache:

Step 1 Check whether /dev/sdb has a bcache drive. lsblk /dev/sdb ● The command output indicates that /dev/sdb has a bcache partition and the registration is complete. No further action is required.

NO TICE

In this example, the partition name of /dev/sdb is bcache1. No matter what the value following bcache is, it is considered that /dev/sdb has a bcache partition.

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 22 Smart Prefetch User Guide 4 Using the Software

● The command output indicates that /dev/sdb does not have a bcache partition. You need to perform the following operations:

Step 2 Check whether bcache is running. cat /sys/block/sdb/bcache/running 0 If running is 0, bcache is not running. If running is 1, bcache is running. Step 3 If the value of running in Step 2 is 0, perform this step to stop bcache. Otherwise, the registration is complete and no further action is required. echo 1 > /sys/block/sdb/bcache/stop Step 4 Perform 4.4 Enabling the Big Data Smart Prefetch.

----End

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 23 Smart Prefetch User Guide A Change History

A Change History

Date Description

2021-03-30 This issue is the second official release.

2021-01-20 This issue is the first official release.

Issue 02 (2021-03-30) Copyright © Huawei Technologies Co., Ltd. 24