Hi XFS list. I'm not subscribed, please CC me.
Programs such as swapspace and swapd create new swap files when vmem runs
low. They would benefit hugely from being able to create a swapfile without
any significant disk I/O. (If a process grabs a lot of memory quickly, the
system will be swapping hard while swapspace(8) is writing a swapfile.)
unfortunately,
touch foo
xfs_io -c 'truncate 1000000000' -c "resvsp 0 1000000000" foo
mkswap foo
sudo swapon foo
doesn't work. The kernel complains:
swapon: swapfile has holes
foo is a ~1GB file with disk space allocated for it, though. But reading
it doesn't create any disk I/O and reads all zero, so it's treated like a
sparse file. Is this because my filesystem flags unwritten extents? And if
my FS was created with that option off, would RESVSP make the file contain
the previous contents of that disk space? That would be an obvious security
hole, but it would still be useful for making swap files even if only root
could do it.
So, any ideas on how to make swap files without writing the whole file?
(swapd and swapspace both avoid deleting swap files right away, IIRC, so
don't suggest workarounds unless you have something really clever...)
Could swapon(2) in the kernel be made to work on XFS files with reserved
space? i.e. call something that would give XFS a chance to mark all the
extents as written, even though they're not. Memory content is at least
as sensitive as anything in the filesystem, and if this file is going to be
trusted with that, it hardly matters if it also has parts of deleted files.
I'm on GNU/Linux: Ubuntu Feisty AMD64, Linux 2.6.20-16-generic.
xfs_io version 2.8.18
peter@tesla:/var/tmp/peter$ xfs_info /var/tmp
meta-data=/dev/evms/temp isize=256 agcount=16, agsize=800767 blks
= sectsz=512 attr=0
data = bsize=4096 blocks=12812272, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal bsize=4096 blocks=3328, version=1
= sectsz=512 sunit=0 blks
realtime =none extsz=65536 blocks=0, rtextents=0
BTW, I think xfs_allocsp has its args reversed, or something.
touch bar
xfs_io -c "allocsp 0 1000000" bar; ll -h
-rw-rw-r-- 1 peter peter 0 2007-06-17 06:45 bar
xfs_io -c "allocsp 1000000 0" bar; ll -h
-rw-rw-r-- 1 peter peter 977K 2007-06-17 06:45 bar
--
#define X(x,y) x##y
Peter Cordes ; e-mail: X(peter@cor , des.ca)
"The gods confound the man who first found out how to distinguish the hours!
Confound him, too, who in this place set up a sundial, to cut and hack
my day so wretchedly into small pieces!" -- Plautus, 200 BC
signature.asc
Description: Digital signature
|