As the kernel thread of the ext4 file system, JBD2 often experiences the shadow (BH_Shadow) state during its use that can affect system performance. To solve this problem, Aliyun Linux 2 optimizes JBD2. This topic describes the interfaces that optimize JBD2.
ext4 is one of the most common journaling file systems. The kernel thread of ext4
for updating journals is JBD2. JBD2 is a global resource for the ext4 file system.
When the JBD2 kernel thread attempts to obtain write access permissions from the cache,
the cache page may be in the shadow state. Because of this, JBD2 may take an extended
period of time waiting for the cache page to write back to the disk. To solve this
problem, Aliyun Linux 2 adds the kernel interface
force_copy to JBD2. The interface allows you to enable the optimization function. The system
then copies cache pages, reducing the time that JBD2 has to wait for cache pages while
in the shadow state to write back to the disk. In addition, to analyze the QoS issues
related to the file system, Aliyun Linux 2 added the information statistics interface
stats to JBD2.
|force_copy||The interface file is stored in /proc/fs/jbd2/<device>-8/force_copy, where the variable
Notice Running the interface will consume memory.
|stats||The interface file is stored in /proc/fs/jbd2/<device>-8/stats. The interface helps to determine whether quality of service (QoS) issues in the file system are caused by JBD2.|
The examples of
stats interfaces are as follows:
- By default, the
force_copyinterface is disabled. You can set the value of the interface to 1 to call the interface or set the value to 0 to disable the interface.
echo 1 > /proc/fs/jbd2/nvme0n1-8/force_copy # Call the interface.
- Run the following command to query the
A sample response is as follows:
The following table describes the fields in the preceding sample response:
337 336 65536 0 14837 1701504 16 0 20058 5 33082732 605 942 1000 1000
Field Description The first field The ID of the event. The second field The number of events requested. The third field The maximum number of cached events. The fourth field The event wait time. The fifth field The latency of the event request. The sixth field The amount of time that the event ran. The seventh field The amount of time that the event was locked. The eighth field The amount of time that it took to refresh the event. The ninth field The amount of time that it took to log on to the event. The tenth field The average submission time. The eleventh field The number of handles contained in the event. The twelfth field The number of blocks contained in the event. The thirteenth field The number of blocks recorded for the event. The fourteenth field The time constant of the kernel configuration, in Hertz. The fifteenth field The period of the time constant of the kernel configuration in milliseconds.