diff options
author | Andrew Morton <akpm@osdl.org> | 2006-06-29 05:24:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-29 13:26:20 -0400 |
commit | 81b0c8713385ce1b1b9058e916edcf9561ad76d6 (patch) | |
tree | 4c5e8fde3d15503c609d5c5f74911f95fc528f03 /mm/filemap.h | |
parent | 0686cd8fbe3e5fb1441ae84b9cbc813f9297b879 (diff) |
[PATCH] generic_file_buffered_write(): handle zero-length iovec segments
The recent generic_file_write() deadlock fix caused
generic_file_buffered_write() to loop inifinitely when presented with a
zero-length iovec segment. Fix.
Note that this fix deliberately avoids calling ->prepare_write(),
->commit_write() etc with a zero-length write. This is because I don't trust
all filesystems to get that right.
This is a cautious approach, for 2.6.17.x. For 2.6.18 we should just go ahead
and call ->prepare_write() and ->commit_write() with the zero length and fix
any broken filesystems. So I'll make that change once this code is stabilised
and backported into 2.6.17.x.
The reason for preferring to call ->prepare_write() and ->commit_write() with
the zero-length segment: a zero-length segment _should_ be sufficiently
uncommon that this is the correct way of handling it. We don't want to
optimise for poorly-written userspace at the expense of well-written
userspace.
Cc: "Vladimir V. Saveliev" <vs@namesys.com>
Cc: Neil Brown <neilb@suse.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Greg KH <greg@kroah.com>
Cc: <stable@kernel.org>
Cc: walt <wa1ter@myrealbox.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/filemap.h')
-rw-r--r-- | mm/filemap.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/filemap.h b/mm/filemap.h index 536979fb4ba7..3f2a343c6015 100644 --- a/mm/filemap.h +++ b/mm/filemap.h | |||
@@ -88,7 +88,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes) | |||
88 | const struct iovec *iov = *iovp; | 88 | const struct iovec *iov = *iovp; |
89 | size_t base = *basep; | 89 | size_t base = *basep; |
90 | 90 | ||
91 | while (bytes) { | 91 | do { |
92 | int copy = min(bytes, iov->iov_len - base); | 92 | int copy = min(bytes, iov->iov_len - base); |
93 | 93 | ||
94 | bytes -= copy; | 94 | bytes -= copy; |
@@ -97,7 +97,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes) | |||
97 | iov++; | 97 | iov++; |
98 | base = 0; | 98 | base = 0; |
99 | } | 99 | } |
100 | } | 100 | } while (bytes); |
101 | *iovp = iov; | 101 | *iovp = iov; |
102 | *basep = base; | 102 | *basep = base; |
103 | } | 103 | } |