[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Zyi8Z7upAZf1sbMN@dread.disaster.area>
Date: Mon, 4 Nov 2024 23:21:59 +1100
From: Dave Chinner <david@...morbit.com>
To: zhangshida <starzhangzsd@...il.com>
Cc: dchinner@...hat.com, djwong@...nel.org, leo.lilong@...wei.com,
linux-kernel@...r.kernel.org, linux-xfs@...r.kernel.org,
osandov@...com, wozizhi@...wei.com, xiang@...nel.org,
zhangjiachen.jaycee@...edance.com, zhangshida@...inos.cn
Subject: Re: frag.sh
On Mon, Nov 04, 2024 at 02:52:14PM +0800, zhangshida wrote:
> From: Shida Zhang <zhangshida@...inos.cn>
>
> #usage: ./frag.sh $dev $dir $size_k $filename
> #!/bin/bash
.....
> # Create a big file with allocated space
> xfs_io -f -c "falloc 0 $((TOTAL_SIZE))k" $FILE
>
> # Calculate total number of punches needed
> NUM_PUNCHES=$(( TOTAL_SIZE / (CHUNK_SIZE * 2) ))
>
> last_percentage=-1
> # Punch holes alternately to create fragmentation
> for ((i=0; i<NUM_PUNCHES; i++)); do
> OFFSET=$(( i * CHUNK_SIZE * 2 * 1024 ))
> xfs_io -c "fpunch $OFFSET ${CHUNK_SIZE}k" $FILE
>
> # Calculate current percentage and print if changed
> PERCENTAGE=$(( (i + 1) * 100 / NUM_PUNCHES ))
> if [ "$PERCENTAGE" -ne "$last_percentage" ]; then
> #echo "Processing...${PERCENTAGE}%"
> last_percentage=$PERCENTAGE
> fi
> done
Yup, that re-invents fstests::src/punch-alternating.c pretty much
exactly.
The fact that there is a production workload that is generating this
exact operational pattern and running it to ENOSPC repeatedly is
horrifying....
-Dave.
--
Dave Chinner
david@...morbit.com
Powered by blists - more mailing lists