From: NeilBrown <neilb@suse.de>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] Avoid memory allocation for O_DIRECT IO.
Date: Thu, 05 Mar 2015 10:57:39 +1100 [thread overview]
Message-ID: <20150304234911.17330.65139.stgit@notabene.brown> (raw)
Hi Al,
I wonder if you would consider these two patches.
They extend the functionality of mlockall(MCL_FUTURE) to apply
to memory allocations when performing O_DIRECT io.
i.e. The first read or write to an O_DIRECT file descriptor will,
if MCL_FUTURE is in effect, cache any allocated memory so that
it doesn't need to be allocated on subsequent reads or writes.
This is needed for reliable handling of RAID metadata in userspace.
When a device fails, it is necessary to record this failure in the
metadata before further writes are allowed to complete.
As a GFP_KERNEL allocation may block waiting for arbitrary writes
to complete, we must not allow any GFP_KERNEL allocation while
updating the metadata.
The approach I have taken to avoiding GFP_KERNEL allocations in
O_DIRECT handling is to cache the necessary data structures the first
time they are allocated.
There are two data structures, "struct dio" and "struct bio".
I have seen a host in a memory deadlock where mdmon (which does the
metadata management) was stuck waiting to allocate a 'struct dio',
but couldn't until writeout was allowed to proceed - which it
couldn't.
I have not need a machine deadlocking waiting for a bio. That is a
much less likely deadlock scenario. The bio is allocated from a
mempool so the allocation will very often succeed. Exhausting the
mempool is unlikely but I believe it is theoretically possible as the
mempool is shared over multiple devices.
Thanks,
NeilBrown
---
NeilBrown (2):
block_dev/DIO: Optionally allocate single 'struct dio' per file.
block_dev/DIO - cache one bio allocation when caching a DIO.
fs/block_dev.c | 7 +++++-
fs/direct-io.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++------
include/linux/fs.h | 6 +++++
3 files changed, 66 insertions(+), 8 deletions(-)
--
Signature
next reply other threads:[~2015-03-04 23:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 23:57 NeilBrown [this message]
2015-03-04 23:57 ` [PATCH 2/2] block_dev/DIO - cache one bio allocation when caching a DIO NeilBrown
2015-03-04 23:57 ` [PATCH 1/2] block_dev/DIO: Optionally allocate single 'struct dio' per file NeilBrown
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=20150304234911.17330.65139.stgit@notabene.brown \
--to=neilb@suse.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).