From: Dave Chinner <david@fromorbit.com>
To: zhangshida <starzhangzsd@gmail.com>
Cc: dchinner@redhat.com, djwong@kernel.org, leo.lilong@huawei.com,
linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
osandov@fb.com, wozizhi@huawei.com, xiang@kernel.org,
zhangjiachen.jaycee@bytedance.com, zhangshida@kylinos.cn
Subject: Re: frag.sh
Date: Mon, 4 Nov 2024 23:21:59 +1100 [thread overview]
Message-ID: <Zyi8Z7upAZf1sbMN@dread.disaster.area> (raw)
In-Reply-To: <20241104065214.3831364-1-zhangshida@kylinos.cn>
On Mon, Nov 04, 2024 at 02:52:14PM +0800, zhangshida wrote:
> From: Shida Zhang <zhangshida@kylinos.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@fromorbit.com
next prev parent reply other threads:[~2024-11-04 12:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 1:40 [PATCH 0/5] *** Introduce new space allocation algorithm *** zhangshida
2024-11-04 6:52 ` frag.sh zhangshida
2024-11-04 12:21 ` Dave Chinner [this message]
2024-11-04 6:53 ` auto_frag.sh zhangshida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zyi8Z7upAZf1sbMN@dread.disaster.area \
--to=david@fromorbit.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=leo.lilong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=osandov@fb.com \
--cc=starzhangzsd@gmail.com \
--cc=wozizhi@huawei.com \
--cc=xiang@kernel.org \
--cc=zhangjiachen.jaycee@bytedance.com \
--cc=zhangshida@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox