[Ocfs2-test-devel] [PATCH 49/59] discontig: fix active discontig block group

Eric Ren zren at suse.com
Wed Sep 23 00:05:58 PDT 2015


Reviewed-by: Eric Ren <zren at suse.com>

Thanks,
Eric

On Mon, Sep 14, 2015 at 10:44:35AM +0800, Junxiao Bi wrote: 
> First make fs fragile and can't alloca a contig block group, then
> use up all available extent block or inode block, once the new total
> extent/inode block number is bigger than old one, a discontig block
> group is actived.
> 
> Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
> ---
>  .../discontig_bg_test/activate_discontig_bg.sh     |    8 +-
>  programs/discontig_bg_test/fillup_contig_bg.sh     |  114 +++-----------------
>  2 files changed, 19 insertions(+), 103 deletions(-)
> 
> diff --git a/programs/discontig_bg_test/activate_discontig_bg.sh b/programs/discontig_bg_test/activate_discontig_bg.sh
> index 0bb5482..14b57ea 100755
> --- a/programs/discontig_bg_test/activate_discontig_bg.sh
> +++ b/programs/discontig_bg_test/activate_discontig_bg.sh
> @@ -37,7 +37,7 @@ LOG_FILE=
>  BLOCKSIZE=4096
>  CLUSTERSIZE=4096
>  TYPE=inode
> -SLOTS=0
> +SLOTS=1
>  JOURNALSIZE=0
>  LABELNAME="ocfs2-discontig-bg-tests"
>  MOUNT_OPTS="localalloc=0"
> @@ -261,9 +261,9 @@ function f_fillup_volume_almost_full()
>  	local -i recs=`f_get_recs_in_eb`
>  
>  	FILL_CONTIG_IBG_NUM=`f_get_inodes_num_of_contig_bg`
> -	FILL_CONTIG_EBG_M=$((${extents}*${recs}*${BLOCKSIZE}/1024/1024))
> -
> +	FILL_CONTIG_EBG_M=$((${extents}*${recs}*${CLUSTERSIZE}/1024/1024))
>  
> +	f_LogMsg ${LOG_FILE} "IBG_NUM: ${FILL_CONTIG_IBG_NUM} FILL_CONTIG_EBG_M: ${FILL_CONTIG_EBG_M} extents: ${extents} recs: ${recs} disk_free: ${DISK_FREE_M} resv_mem: ${RESV_SIZE_M} slots: ${SLOTS}"
>  	if [ "${TYPE}" == "extent" ];then
>  		if [ "${DISK_FREE_M}" -le "$((2*${RESV_SIZE_M}+2*${FILL_CONTIG_EBG_M}*${SLOTS}))" ]; then
>  			RESV_SIZE_M=$((${DISK_FREE_M}/2-${FILL_CONTIG_EBG_M}*${SLOTS}))
> @@ -276,7 +276,7 @@ function f_fillup_volume_almost_full()
>  		FILE_MAJOR_SIZE_M=$((${DISK_FREE_M}-2*${RESV_SIZE_M}))
>  	fi
>  
> -	f_LogMsg ${LOG_FILE} "[*] Reserve ${FILE_MAJOR_SIZE_M}M space for a LARGE file"
> +	f_LogMsg ${LOG_FILE} "[*] Reserve ${FILE_MAJOR_SIZE_M}M space for a LARGE file, reserve ${RESV_SIZE_M}M space for future test."
>  	${RESV_UNWRITTEN_BIN} -f ${WORK_PLACE}/large_testfile -s 0 -l $((${FILE_MAJOR_SIZE_M}*1024*1024)) >>${LOG_FILE} 2>&1
>  	RET=$?
>  	f_exit_or_not ${RET}
> diff --git a/programs/discontig_bg_test/fillup_contig_bg.sh b/programs/discontig_bg_test/fillup_contig_bg.sh
> index dfa801f..255a3e3 100755
> --- a/programs/discontig_bg_test/fillup_contig_bg.sh
> +++ b/programs/discontig_bg_test/fillup_contig_bg.sh
> @@ -162,6 +162,7 @@ function f_fillup_ibg()
>  	local filename_prefix=
>  	local filename=
>  	local inode_alloc="//inode_alloc:000${SLOTNUM}"
> +	local bitmap_total=`${DEBUGFS_BIN} -R "stat ${inode_alloc}" ${DEVICE} | grep "Bitmap Total" | awk -F ' ' '{print $3}'`
>  
>  	f_LogMsg ${LOG_FILE} "Fill inode block groups by touching ${FILL_CONTIG_IBG_NUM} files."
>  	filename_prefix=fill_contig_igb_testfile
> @@ -175,41 +176,14 @@ function f_fillup_ibg()
>  	done
>  
>  	sync
> -
> -	${DEBUGFS_BIN} -R "stat ${inode_alloc}" ${DEVICE} |grep -q "Tree Depth" && {
> +	cur_bitmap_total=`${DEBUGFS_BIN} -R "stat ${inode_alloc}" ${DEVICE} | grep "Bitmap Total" | awk -F ' ' '{print $3}'`
> +	if [ $cur_bitmap_total -gt $bitmap_total ]; then
>  		f_LogMsg ${LOG_FILE} "Oh, boy, now we have activated discontiguous inode block group."
>  		return 0
> -	}
> -
> -	i=1
> -	filename_prefix=fill_contig_igb_testfile_addup_inode
> -	while :;do
> -		filename=${filename_prefix}${i}
> -		if [ "${i}" -gt "$OCFS2_LINK_MAX" ];then
> -			mkdir -p ${WORK_PLACE}/${filename}
> -			i=1
> -			filename_prefix=${filename}/
> -			continue
> -		else
> -			dd if=/dev/zero of=${WORK_PLACE}/$filename bs=4k count=1 >/dev/null  2>&1|| {
> -				f_LogMsg ${LOG_FILE} "No discontig block group created until volume gets full."
> -				RET=1
> -				break
> -			}
> -		fi
> -
> -		sync
> -
> -		${DEBUGFS_BIN} -R "stat ${WORK_PLACE_DIRENT}/${filename}" ${DEVICE} |grep -q "Sub Alloc Group" && {
> -			f_LogMsg ${LOG_FILE} "Oh, boy, now we have activated one discontiguous inode block group."
> -			break;
> -		}
> -
> -		((i++))
> -	done
> -	RET=$?
> -
> -	return $RET
> +	else
> +		f_LogMsg ${LOG_FILE} "sorry, activated discontiguous inode block group failed."
> +		return 1
> +	fi
>  }
>  
>  function f_is_xattr_in_block()
> @@ -229,8 +203,9 @@ function f_fillup_ebg()
>  	local filename=${WORK_PLACE}/fill_contig_egb_testfile_`hostname`
>  	local fileszie=
>  	local extent_alloc="//extent_alloc:000${SLOTNUM}"
> +	local bitmap_total=`${DEBUGFS_BIN} -R "stat ${extent_alloc}" ${DEVICE} | grep "Bitmap Total" | awk -F ' ' '{print $3}'`
>  
> -	filesize=$((${FILL_CONTIG_EBG_M}*1024*1024/2))
> +	filesize=$((${FILL_CONTIG_EBG_M}*1024*1024/2+1))
>  
>  	f_LogMsg ${LOG_FILE} "Fill contiguous extent block groups by gen_extents"
>  	f_LogMsg ${LOG_FILE} "CMD: ${GEN_EXTENTS_BIN} -f ${filename} -l ${filesize} -c ${CLUSTERSIZE} -k 1"
> @@ -241,73 +216,14 @@ function f_fillup_ebg()
>  
>  	sync
>  
> -	${DEBUGFS_BIN} -R "stat ${extent_alloc}" ${DEVICE} |grep -q "Tree Depth" && {
> +	cur_bitmap_total=`${DEBUGFS_BIN} -R "stat ${extent_alloc}" ${DEVICE} | grep "Bitmap Total" | awk -F ' ' '{print $3}'`
> +	if [ $cur_bitmap_total -gt $bitmap_total ]; then
>  		f_LogMsg ${LOG_FILE} "Oh, boy, now we have activated one discontiguous extent block group."
>  		return 0
> -	}
> -
> -	# if above operation didn't consume up the contig extent block
> -	# exactly, we need to slowly force the filling-up by populating
> -	# xattr blocks from exteng bg.
> -	local -i i=1
> -	local filename_prefix=fill_contig_egb_testfile_addup_xattr
> -	f_LogMsg ${LOG_FILE} "Use additional xattr extents to activate the discontig."
> -	while :;do
> -		filename=${filename_prefix}${i}
> -		if [ "${i}" -gt "$OCFS2_LINK_MAX" ];then
> -			mkdir -p ${WORK_PLACE}/${filename}
> -			# We should not trying to make more directories
> -			# if the test run out of inodes against the test
> -			# file system, which means that the test failed
> -			# to make the test storage fragmented this time
> -			# so that the discontig block group did not took
> -			# affected.  By breaking the test per mkdir failure,
> -			# we can fix the test hanging issue with meaningful
> -			# log information to indicate that.
> -			# TODO: Figure out a better approach to make discontig
> -			# block group ASAP.
> -                        if [ "$?" -ne "0" ];then
> -                                f_LogMsg ${LOG_FILE} "mkdir ${WORK_PLACE}/${filename} failed."
> -                                break;
> -                        fi
> -
> -			i=1
> -			filename_prefix=${filename}/
> -			continue
> -		else
> -			${TOUCH_BIN} ${WORK_PLACE}/$filename >>${LOG_FILE} 2>&1|| {
> -				f_LogMsg ${LOG_FILE} "touch ${filename} failed."
> -				RET=1
> -				break
> -			}
> -
> -			sync
> -
> -			for j in $(seq 100);do
> -				${SETXATTR} -n user.name${j} -v value${j} ${WORK_PLACE}/${filename} >>${LOG_FILE} 2>&1 || {
> -					f_LogMsg ${LOG_FILE} "setxattr failed."
> -					break
> -				}
> -
> -				f_is_xattr_in_block ${WORK_PLACE_DIRENT}/${filename} ${DEVICE} && {
> -					break
> -				}
> -			done
> -
> -		fi
> -
> -		sync
> -
> -		${DEBUGFS_BIN} -R "stat ${extent_alloc}" ${DEVICE} |grep -q "Tree Depth" && {
> -			f_LogMsg ${LOG_FILE} "Oh, boy, now we have activated one discontiguous extent block group."
> -			break;
> -		}
> -
> -		((i++))
> -	done
> -	RET=$?
> -
> -	return $RET
> +	else
> +		f_LogMsg ${LOG_FILE} "discontig extent block group is not enabled, old bitmap $bitmap_total new bitmap $cur_bitmap_total"
> +		return 1
> +	fi
>  }
>  
>  function f_fillup_bg()
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> Ocfs2-test-devel mailing list
> Ocfs2-test-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-test-devel
> 



More information about the Ocfs2-test-devel mailing list