* [PATCH] direct_io: Allow partial writes
@ 2010-04-06 14:47 Dmitry Monakhov
0 siblings, 0 replies; only message in thread
From: Dmitry Monakhov @ 2010-04-06 14:47 UTC (permalink / raw)
To: linux-fsdevel; +Cc: akpm, npiggin, Dmitry Monakhov
Current direct io allocation behavior is inconvenient. Partial writes
are not supported. If we try to issue 10Mb chunk, but only 5Mb is
available then we will allocate thees 5Mb until ENOSPC, and then
drop such space and return ENOSPC.
Partial success was rejected because it wasn't obvious how to
distinguish non fatal errors (ENOSPC,EDQUOT,ENOMEM, etc) from fatal
ones (EIO,EFAULT, and so on).
But in fact there are only two sources of fatal error:
1) from bi_end_io and result in EIO and saved to dio->io_error
2) from get_user_pages_fast and saved to dio->page_errors
In case of partial write it is safe to ignore error code because in
case of fatal error it will be restored and returned to caller from
dio_complete().
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/direct-io.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index e82adc2..1298dc3 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -230,7 +230,13 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret)
if (dio->result) {
transferred = dio->result;
-
+ /*
+ * Ignore non fatal error if some data was written.
+ * Fatal error was saved in dio structure and will be
+ * restored later at the bottom of the function.
+ */
+ if (dio->rw & WRITE)
+ ret = 0;
/* Check for short read case */
if ((dio->rw == READ) && ((offset + transferred) > dio->i_size))
transferred = dio->i_size - offset;
--
1.6.6.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-04-06 14:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-06 14:47 [PATCH] direct_io: Allow partial writes Dmitry Monakhov
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).