From: Alex Elsayed <eternaleye@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: Swapfile on btrfs
Date: Tue, 26 Feb 2013 13:45:12 -0800 [thread overview]
Message-ID: <kgjad5$7kt$1@ger.gmane.org> (raw)
Hey, I was looking at the wiki 'unclaimed projects' list and I thought I'd
take a look at what might be needed to use the swap-over-n{fs,bd}
functionality in order to implement swapfile support. It *looks* like it's
surprisingly uncomplicated - to the point where I suspect I'm missing
something, and would like some sanity checking.
My primary references for this are the patch[1] implementing swap-over-NFS
and HEAD of cmason's for-linus branch.
I'm going to go over the sections of the commitdiff from top to bottom (and
hunk-by-hunk where I feel it necessary), and I'd like it if people could
correct any mistakes I make.
Kconfig:
Simple enough that I'm not worried.
direct.c:
The first hunk seems to serve to factor out the difference between
rw={READ,WRITE} and the KERNEL_ equivalents into a 'uio' parameter, so I'll
view it as being mostly a code organization thing.
The second hunk just adds that uio param to read_schedule_segment(), which
it is given secondhand via direct_read().
The third hunk seems to be where the actual reading occurs in
read_schedule_segment(), and the differences between uio and !uio seem to
boil down to that KERNEL_READ is only allowed to operate one page at a time
under penalty of BUG, and that it uses get_kernel_page instead of
get_user_pages. Since btrfs calls into __blockdev_direct_IO(), I suspect
that fs/direct-io.c would (in this case) be the right place to implement
both the {READ,WRITE} vs KERNEL_* logic and those checks in this case. Also,
check_direct_IO() in fs/btrfs/inode.c may want to treat KERNEL_WRITE
similarly to WRITE - I'm not completely sure of that, however.
Hunks 4-8 are just dealing with passing the additional uio parameter around.
Hunk 9 is the write-side equivalent of hunk 3, and seems to correspond
pretty exactly. It's looking like fs/direct_io.c is definitely the place to
implement this.
Hunks 10-17 are more uio parameter passing.
file.c:
Pretty simple - as far as I can tell, the activate() sets the span to what
the swap header expects, the xs_swapper call basically sets the appropriate
kmalloc flags for the network stuff (irrelevant here), and the deactivate()
just resets those flags. All the smarts seem to be in the DIO code.
The rest:
The remainder of the patch seems to just be a.) handing that uio parameter
around and b.) stuff specific to swapping over the network.
Did I miss anything important? If not, I may well decide to tackle this as
my first non-trivial kernel contribution. Does anyone have any suggestions
on how I should stresstest this? I figure a good starting point would be
running xfstests under memory pressure with such a swapfile.
[1]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;h=a564b8f
next reply other threads:[~2013-02-26 21:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-26 21:45 Alex Elsayed [this message]
2013-02-27 17:52 ` Swapfile on btrfs David Sterba
2013-02-27 20:52 ` Alex Elsayed
2013-03-15 15:22 ` David Sterba
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='kgjad5$7kt$1@ger.gmane.org' \
--to=eternaleye@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).