Re: frag.sh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 04, 2024 at 02:52:14PM +0800, zhangshida wrote:
> From: Shida Zhang <zhangshida@xxxxxxxxxx>
> 
> #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@xxxxxxxxxxxxx




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux