Hmm. If I read this right, this bug seems to have been introduced by
commit 65b8291c4000e5f38fc94fb2ca0cb7e8683c8a1b ("dio: invalidate clean
pages before dio write") back in March.
Before that, we'd call invalidate_inode_pages2_range() unconditionally
after the call mapping->a_ops->direct_IO() if it was a write and there
were cached pages in the mapping (well, "unconditionally" in the sense
that it didn't depend on the return value of the ->direct_IO() call).
However, with both the old and the new code _and_ with your patch, the
return code - in case the invalidate failed - was corrupted. So we may
actually end up doing some IO, but then returning the "wrong" error code
from the invalidate. Hmm?
Somebody who cares about direct-IO and who - unlike me - doesn't think
it's a total and idiotic crock should think hard about this. I'm including
Karl's email, but also an alternate patch for consideration.
And maybe some day we can all agree that direct_IO is crap and should not
be done.
Linus
--
diff --git a/mm/filemap.c b/mm/filemap.c
index 5209e47..032371a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2510,22 +2510,17 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
}
retval = mapping->a_ops->direct_IO(rw, iocb, iov, offset, nr_segs);
- if (retval)
+ if (retval < 0)
goto out;
/*
* Finally, try again to invalidate clean pages which might have been
* faulted in by get_user_pages() if the source of the write was an
* mmap()ed region of the file we're writing. That's a pretty crazy
- * thing to do, so we don't support it 100%. If this invalidation
- * fails and we have -EIOCBQUEUED we ignore the failure.
+ * thing to do, so we don't support it 100%.
*/
- if (rw == WRITE && mapping->nrpages) {
- int err = invalidate_inode_pages2_range(mapping,
- offset >> PAGE_CACHE_SHIFT, end);
- if (err && retval >= 0)
- retval = err;
- }
+ if (rw == WRITE && mapping->nrpages)
+ invalidate_inode_pages2_range(mapping, offset >> PAGE_CACHE_SHIFT, end);
out:
return retval;
}
On Fri, 26 Oct 2007, Karl Schendel wrote:
-
| Bart Van Assche | Re: Integration of SCST in the mainstream Linux kernel |
| Greg KH | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Andrew Morton | Re: -mm merge plans for 2.6.23 -- sys_fallocate |
git: | |
| Gerrit Renker | [PATCH 03/37] dccp: List management for new feature negotiation |
| David Miller | [GIT]: Networking |
| Radu Rendec | htb parallelism on multi-core platforms |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
