Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
e5393fae
Commit
e5393fae
authored
Nov 27, 2014
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iov_iter.c: convert iov_iter_get_pages() to iterate_all_kinds
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
e0f2dc40
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
50 deletions
+28
-50
mm/iov_iter.c
mm/iov_iter.c
+28
-50
No files found.
mm/iov_iter.c
View file @
e5393fae
...
@@ -428,34 +428,6 @@ void iov_iter_init(struct iov_iter *i, int direction,
...
@@ -428,34 +428,6 @@ void iov_iter_init(struct iov_iter *i, int direction,
}
}
EXPORT_SYMBOL
(
iov_iter_init
);
EXPORT_SYMBOL
(
iov_iter_init
);
static
ssize_t
get_pages_iovec
(
struct
iov_iter
*
i
,
struct
page
**
pages
,
size_t
maxsize
,
unsigned
maxpages
,
size_t
*
start
)
{
size_t
offset
=
i
->
iov_offset
;
const
struct
iovec
*
iov
=
i
->
iov
;
size_t
len
;
unsigned
long
addr
;
int
n
;
int
res
;
len
=
iov
->
iov_len
-
offset
;
if
(
len
>
i
->
count
)
len
=
i
->
count
;
if
(
len
>
maxsize
)
len
=
maxsize
;
addr
=
(
unsigned
long
)
iov
->
iov_base
+
offset
;
len
+=
*
start
=
addr
&
(
PAGE_SIZE
-
1
);
if
(
len
>
maxpages
*
PAGE_SIZE
)
len
=
maxpages
*
PAGE_SIZE
;
addr
&=
~
(
PAGE_SIZE
-
1
);
n
=
(
len
+
PAGE_SIZE
-
1
)
/
PAGE_SIZE
;
res
=
get_user_pages_fast
(
addr
,
n
,
(
i
->
type
&
WRITE
)
!=
WRITE
,
pages
);
if
(
unlikely
(
res
<
0
))
return
res
;
return
(
res
==
n
?
len
:
res
*
PAGE_SIZE
)
-
*
start
;
}
static
ssize_t
get_pages_alloc_iovec
(
struct
iov_iter
*
i
,
static
ssize_t
get_pages_alloc_iovec
(
struct
iov_iter
*
i
,
struct
page
***
pages
,
size_t
maxsize
,
struct
page
***
pages
,
size_t
maxsize
,
size_t
*
start
)
size_t
*
start
)
...
@@ -650,24 +622,6 @@ static size_t zero_bvec(size_t bytes, struct iov_iter *i)
...
@@ -650,24 +622,6 @@ static size_t zero_bvec(size_t bytes, struct iov_iter *i)
return
wanted
-
bytes
;
return
wanted
-
bytes
;
}
}
static
ssize_t
get_pages_bvec
(
struct
iov_iter
*
i
,
struct
page
**
pages
,
size_t
maxsize
,
unsigned
maxpages
,
size_t
*
start
)
{
const
struct
bio_vec
*
bvec
=
i
->
bvec
;
size_t
len
=
bvec
->
bv_len
-
i
->
iov_offset
;
if
(
len
>
i
->
count
)
len
=
i
->
count
;
if
(
len
>
maxsize
)
len
=
maxsize
;
/* can't be more than PAGE_SIZE */
*
start
=
bvec
->
bv_offset
+
i
->
iov_offset
;
get_page
(
*
pages
=
bvec
->
bv_page
);
return
len
;
}
static
ssize_t
get_pages_alloc_bvec
(
struct
iov_iter
*
i
,
static
ssize_t
get_pages_alloc_bvec
(
struct
iov_iter
*
i
,
struct
page
***
pages
,
size_t
maxsize
,
struct
page
***
pages
,
size_t
maxsize
,
size_t
*
start
)
size_t
*
start
)
...
@@ -792,10 +746,34 @@ ssize_t iov_iter_get_pages(struct iov_iter *i,
...
@@ -792,10 +746,34 @@ ssize_t iov_iter_get_pages(struct iov_iter *i,
struct
page
**
pages
,
size_t
maxsize
,
unsigned
maxpages
,
struct
page
**
pages
,
size_t
maxsize
,
unsigned
maxpages
,
size_t
*
start
)
size_t
*
start
)
{
{
if
(
i
->
type
&
ITER_BVEC
)
if
(
maxsize
>
i
->
count
)
return
get_pages_bvec
(
i
,
pages
,
maxsize
,
maxpages
,
start
);
maxsize
=
i
->
count
;
else
return
get_pages_iovec
(
i
,
pages
,
maxsize
,
maxpages
,
start
);
if
(
!
maxsize
)
return
0
;
iterate_all_kinds
(
i
,
maxsize
,
v
,
({
unsigned
long
addr
=
(
unsigned
long
)
v
.
iov_base
;
size_t
len
=
v
.
iov_len
+
(
*
start
=
addr
&
(
PAGE_SIZE
-
1
));
int
n
;
int
res
;
if
(
len
>
maxpages
*
PAGE_SIZE
)
len
=
maxpages
*
PAGE_SIZE
;
addr
&=
~
(
PAGE_SIZE
-
1
);
n
=
DIV_ROUND_UP
(
len
,
PAGE_SIZE
);
res
=
get_user_pages_fast
(
addr
,
n
,
(
i
->
type
&
WRITE
)
!=
WRITE
,
pages
);
if
(
unlikely
(
res
<
0
))
return
res
;
return
(
res
==
n
?
len
:
res
*
PAGE_SIZE
)
-
*
start
;
0
;}),({
/* can't be more than PAGE_SIZE */
*
start
=
v
.
bv_offset
;
get_page
(
*
pages
=
v
.
bv_page
);
return
v
.
bv_len
;
})
)
return
0
;
}
}
EXPORT_SYMBOL
(
iov_iter_get_pages
);
EXPORT_SYMBOL
(
iov_iter_get_pages
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment