aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.h
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-10-16 04:24:59 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:42:55 -0400
commit2f718ffc16c43a435d12919c75dbfad518abd056 (patch)
tree55588cb2815d844e9d0b2404cf8ceafe98b5c55d /mm/filemap.h
parent08291429cfa6258c4cd95d8833beb40f828b194e (diff)
mm: buffered write iterator
Add an iterator data structure to operate over an iovec. Add usercopy operators needed by generic_file_buffered_write, and convert that function over. 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.h')
-rw-r--r--mm/filemap.h103
1 files changed, 0 insertions, 103 deletions
diff --git a/mm/filemap.h b/mm/filemap.h
deleted file mode 100644
index b500d936cec5..000000000000
--- a/mm/filemap.h
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 * linux/mm/filemap.h
3 *
4 * Copyright (C) 1994-1999 Linus Torvalds
5 */
6
7#ifndef __FILEMAP_H
8#define __FILEMAP_H
9
10#include <linux/types.h>
11#include <linux/fs.h>
12#include <linux/mm.h>
13#include <linux/highmem.h>
14#include <linux/uio.h>
15#include <linux/uaccess.h>
16
17size_t
18__filemap_copy_from_user_iovec_inatomic(char *vaddr,
19 const struct iovec *iov,
20 size_t base,
21 size_t bytes);
22
23/*
24 * Copy as much as we can into the page and return the number of bytes which
25 * were sucessfully copied. If a fault is encountered then return the number of
26 * bytes which were copied.
27 */
28static inline size_t
29filemap_copy_from_user_atomic(struct page *page, unsigned long offset,
30 const struct iovec *iov, unsigned long nr_segs,
31 size_t base, size_t bytes)
32{
33 char *kaddr;
34 size_t copied;
35
36 kaddr = kmap_atomic(page, KM_USER0);
37 if (likely(nr_segs == 1)) {
38 int left;
39 char __user *buf = iov->iov_base + base;
40 left = __copy_from_user_inatomic_nocache(kaddr + offset,
41 buf, bytes);
42 copied = bytes - left;
43 } else {
44 copied = __filemap_copy_from_user_iovec_inatomic(kaddr + offset,
45 iov, base, bytes);
46 }
47 kunmap_atomic(kaddr, KM_USER0);
48
49 return copied;
50}
51
52/*
53 * This has the same sideeffects and return value as
54 * filemap_copy_from_user_atomic().
55 * The difference is that it attempts to resolve faults.
56 */
57static inline size_t
58filemap_copy_from_user(struct page *page, unsigned long offset,
59 const struct iovec *iov, unsigned long nr_segs,
60 size_t base, size_t bytes)
61{
62 char *kaddr;
63 size_t copied;
64
65 kaddr = kmap(page);
66 if (likely(nr_segs == 1)) {
67 int left;
68 char __user *buf = iov->iov_base + base;
69 left = __copy_from_user_nocache(kaddr + offset, buf, bytes);
70 copied = bytes - left;
71 } else {
72 copied = __filemap_copy_from_user_iovec_inatomic(kaddr + offset,
73 iov, base, bytes);
74 }
75 kunmap(page);
76 return copied;
77}
78
79static inline void
80filemap_set_next_iovec(const struct iovec **iovp, unsigned long nr_segs,
81 size_t *basep, size_t bytes)
82{
83 if (likely(nr_segs == 1)) {
84 *basep += bytes;
85 } else {
86 const struct iovec *iov = *iovp;
87 size_t base = *basep;
88
89 while (bytes) {
90 int copy = min(bytes, iov->iov_len - base);
91
92 bytes -= copy;
93 base += copy;
94 if (iov->iov_len == base) {
95 iov++;
96 base = 0;
97 }
98 }
99 *iovp = iov;
100 *basep = base;
101 }
102}
103#endif