failed: Too many links (How to Fix)

Received feedback today that some files failed to synchronize. Looking at the logs found:

rsync: recv_generator: mkdir "/app/data/ckl/ckli2780581" failed: Too many links (31)
*** Skipping any contents from this failed directory ***
    enter the relevant directory to establish file:
cd /app/data/ckl/
mkdir vd

Report the same error:

failed: Too many links

2. Check the directory

ls /app/data/ckl | wc -l
31998

The sheer number of directories may be a limitation of the file system
3. Check the file system

 df -lhT
Filesystem                       Type  Size  Used Avail Use% Mounted on
/dev/sda1                        ext3  7.9G  4.9G  2.7G  65% /

It was ext3

is roughly as follows:

nclude/linux/ext2_fs.h:#define EXT2_LINK_MAX           32000
include/linux/ext3_fs.h:#define EXT3_LINK_MAX           32000

Why 31,998?This is because when mkdir creates a directory, two subdirectories are created by default, one is. The directory (representing the current directory), and the other one is.. Directory (representing the parent directory). These two subdirectories are not deleted, “rm.” will get “RM: cannot remove ‘.’ or ‘.. ‘”. So 32000-2 = 31998.
Solution:
Ext4 has no limit on the number of directories
Mount a new disk to establish a connection to the directory
The script is as follows:

#!/bin/bash
CUR_DAY=`date +%Y%m%d`
SRC_DIR=/app
DST_DIR=/data

fdisk /dev/vdc <<EOF
	d               
	n             
	p               
	1  
	1              
               
	t              
	83             
	w  
EOF  

echo
echo "star create vg and lv..."
pvcreate /dev/sdc1
if [ $? -eq 0 ];then
	vgcreate data-volume /dev/vdc1
	if [ $? -eq 0 ];then
		lvcreate -L 99G -n s1_data data-volume
	else
		echo "lv create failed!"
		exit 1
else
	echo "vg create failed !"
fi
mkfs -t ext4 /dev/data-volume/s1_data

mount /dev/data-volume/s1_data ${DST_DIR}
cp -a ${SRC_DIR}/data ${DST_DIR}
mv ${SRC_DIR}/data ${SRC_DIR}/data_bak/
ln -s ${DST_DIR}/data/ ${SRC_DIR}/data

Read More: