From: Peter Cordes <peter@cordes.ca>
To: xfs@oss.sgi.com
Subject: XFS_IOC_RESVSP64 for swap files
Date: Sun, 17 Jun 2007 07:08:23 -0300 [thread overview]
Message-ID: <20070617100822.GA4586@cordes.ca> (raw)
[-- Attachment #1: Type: text/plain, Size: 2852 bytes --]
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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 351 bytes --]
next reply other threads:[~2007-06-19 2:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-17 10:08 Peter Cordes [this message]
2007-06-19 4:33 ` XFS_IOC_RESVSP64 for swap files David Chinner
2007-06-21 6:14 ` Peter Cordes
2007-06-21 23:52 ` David Chinner
2007-06-25 0:07 ` Nathan Scott
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=20070617100822.GA4586@cordes.ca \
--to=peter@cordes.ca \
--cc=xfs@oss.sgi.com \
/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