XFS Preallocation
Peter Vajgel
pv at fb.com
Mon Jan 31 22:45:09 CST 2011
> Preallocation is the only option. Allowing preallocation without marking extents as unwritten opens a massive security hole (i.e.
> exposes stale data) so I say no to any request for addition of such functionality (and have for years).
How about opening this option to at least root (root can already read the device anyway)?. There are cases when creating large files without writing to them is important. A good example is testing xfs overhead when doing a specific workload (like random reads) to large files. In this case we want to hit the disk on every request. Currently we have a workaround (below) but official support would be preferable.
--pv
# create_xfs_files
dev=$1
mntpt=$2
dircount=$3
filecount=$4
size=$5
# Umount.
umount $2
# Create the fs.
mkfs -t xfs -f -d unwritten=0,su=256k,sw=10 -l su=256k -L "/hay" $dev
# Clear unwritten flag - current xfs ignores this flag
typeset -i agcount=$(xfs_db -c "sb" -c "print" $dev | grep agcount)
typeset -i i=0
while [[ $i != $agcount ]]
do
xfs_db -x -c "sb $i" -c "write versionnum 0xa4a4" $dev
i=i+1
done
# Mount the filesystem.
mount -t xfs -o nobarrier,noatime,nodiratime,inode64,allocsize=1g $dev $mntpt
i=0
while [[ $i != $dircount ]]
do
mkdir $mntpt/dir$i
typeset -i j=0
while [[ $j != $filecount ]]
do
file=$mntpt/dir$i/file$j
xfs_io -f -c "resvsp 0 $size" $file
inum=$(ls -i $file | awk '{print $1}')
umount $mntpt
xfs_db -x -c "inode $inum" -c "write core.size $size" $dev
mount -t xfs -o nobarrier,noatime,nodiratime,inode64,allocsize=1g $dev $mntpt
j=j+1
done
i=i+1
done
More information about the xfs
mailing list