diff options
author | Nick Piggin <npiggin@suse.de> | 2007-10-16 04:24:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:42:54 -0400 |
commit | 4a9e5ef1f4f15205e477817a5cefc34bd3f65f55 (patch) | |
tree | 51f52086ecbccc3f41955d8d12293ef7a566a05b /mm/filemap_xip.c | |
parent | eb2be189317d031895b5ca534fbf735eb546158b (diff) |
mm: write iovec cleanup
Hide some of the open-coded nr_segs tests into the iovec helpers. This is all
to simplify generic_file_buffered_write, because that gets more complex in the
next patch.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap_xip.c')
-rw-r--r-- | mm/filemap_xip.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c index 53ee6a299635..32132f3cd641 100644 --- a/mm/filemap_xip.c +++ b/mm/filemap_xip.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/rmap.h> | 15 | #include <linux/rmap.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <asm/tlbflush.h> | 17 | #include <asm/tlbflush.h> |
18 | #include "filemap.h" | ||
19 | 18 | ||
20 | /* | 19 | /* |
21 | * We do use our own empty page to avoid interference with other users | 20 | * We do use our own empty page to avoid interference with other users |
@@ -288,6 +287,7 @@ __xip_file_write(struct file *filp, const char __user *buf, | |||
288 | unsigned long index; | 287 | unsigned long index; |
289 | unsigned long offset; | 288 | unsigned long offset; |
290 | size_t copied; | 289 | size_t copied; |
290 | char *kaddr; | ||
291 | 291 | ||
292 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ | 292 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ |
293 | index = pos >> PAGE_CACHE_SHIFT; | 293 | index = pos >> PAGE_CACHE_SHIFT; |
@@ -295,14 +295,6 @@ __xip_file_write(struct file *filp, const char __user *buf, | |||
295 | if (bytes > count) | 295 | if (bytes > count) |
296 | bytes = count; | 296 | bytes = count; |
297 | 297 | ||
298 | /* | ||
299 | * Bring in the user page that we will copy from _first_. | ||
300 | * Otherwise there's a nasty deadlock on copying from the | ||
301 | * same page as we're writing to, without it being marked | ||
302 | * up-to-date. | ||
303 | */ | ||
304 | fault_in_pages_readable(buf, bytes); | ||
305 | |||
306 | page = a_ops->get_xip_page(mapping, | 298 | page = a_ops->get_xip_page(mapping, |
307 | index*(PAGE_SIZE/512), 0); | 299 | index*(PAGE_SIZE/512), 0); |
308 | if (IS_ERR(page) && (PTR_ERR(page) == -ENODATA)) { | 300 | if (IS_ERR(page) && (PTR_ERR(page) == -ENODATA)) { |
@@ -319,8 +311,13 @@ __xip_file_write(struct file *filp, const char __user *buf, | |||
319 | break; | 311 | break; |
320 | } | 312 | } |
321 | 313 | ||
322 | copied = filemap_copy_from_user(page, offset, buf, bytes); | 314 | fault_in_pages_readable(buf, bytes); |
315 | kaddr = kmap_atomic(page, KM_USER0); | ||
316 | copied = bytes - | ||
317 | __copy_from_user_inatomic_nocache(kaddr, buf, bytes); | ||
318 | kunmap_atomic(kaddr, KM_USER0); | ||
323 | flush_dcache_page(page); | 319 | flush_dcache_page(page); |
320 | |||
324 | if (likely(copied > 0)) { | 321 | if (likely(copied > 0)) { |
325 | status = copied; | 322 | status = copied; |
326 | 323 | ||