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
0f78d06a
Commit
0f78d06a
authored
Feb 20, 2017
by
Miklos Szeredi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vfs: pass type instead of fn to do_{loop,iter}_readv_writev()
Signed-off-by:
Miklos Szeredi
<
mszeredi@redhat.com
>
parent
7687a7a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
fs/read_write.c
fs/read_write.c
+18
-19
No files found.
fs/read_write.c
View file @
0f78d06a
...
@@ -23,9 +23,6 @@
...
@@ -23,9 +23,6 @@
#include <linux/uaccess.h>
#include <linux/uaccess.h>
#include <asm/unistd.h>
#include <asm/unistd.h>
typedef
ssize_t
(
*
io_fn_t
)(
struct
file
*
,
char
__user
*
,
size_t
,
loff_t
*
);
typedef
ssize_t
(
*
iter_fn_t
)(
struct
kiocb
*
,
struct
iov_iter
*
);
const
struct
file_operations
generic_ro_fops
=
{
const
struct
file_operations
generic_ro_fops
=
{
.
llseek
=
generic_file_llseek
,
.
llseek
=
generic_file_llseek
,
.
read_iter
=
generic_file_read_iter
,
.
read_iter
=
generic_file_read_iter
,
...
@@ -675,7 +672,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to)
...
@@ -675,7 +672,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to)
EXPORT_SYMBOL
(
iov_shorten
);
EXPORT_SYMBOL
(
iov_shorten
);
static
ssize_t
do_iter_readv_writev
(
struct
file
*
filp
,
struct
iov_iter
*
iter
,
static
ssize_t
do_iter_readv_writev
(
struct
file
*
filp
,
struct
iov_iter
*
iter
,
loff_t
*
ppos
,
i
ter_fn_t
fn
,
int
flags
)
loff_t
*
ppos
,
i
nt
type
,
int
flags
)
{
{
struct
kiocb
kiocb
;
struct
kiocb
kiocb
;
ssize_t
ret
;
ssize_t
ret
;
...
@@ -692,7 +689,10 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
...
@@ -692,7 +689,10 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
kiocb
.
ki_flags
|=
(
IOCB_DSYNC
|
IOCB_SYNC
);
kiocb
.
ki_flags
|=
(
IOCB_DSYNC
|
IOCB_SYNC
);
kiocb
.
ki_pos
=
*
ppos
;
kiocb
.
ki_pos
=
*
ppos
;
ret
=
fn
(
&
kiocb
,
iter
);
if
(
type
==
READ
)
ret
=
filp
->
f_op
->
read_iter
(
&
kiocb
,
iter
);
else
ret
=
filp
->
f_op
->
write_iter
(
&
kiocb
,
iter
);
BUG_ON
(
ret
==
-
EIOCBQUEUED
);
BUG_ON
(
ret
==
-
EIOCBQUEUED
);
*
ppos
=
kiocb
.
ki_pos
;
*
ppos
=
kiocb
.
ki_pos
;
return
ret
;
return
ret
;
...
@@ -700,7 +700,7 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
...
@@ -700,7 +700,7 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
/* Do it by hand, with file-ops */
/* Do it by hand, with file-ops */
static
ssize_t
do_loop_readv_writev
(
struct
file
*
filp
,
struct
iov_iter
*
iter
,
static
ssize_t
do_loop_readv_writev
(
struct
file
*
filp
,
struct
iov_iter
*
iter
,
loff_t
*
ppos
,
i
o_fn_t
fn
,
int
flags
)
loff_t
*
ppos
,
i
nt
type
,
int
flags
)
{
{
ssize_t
ret
=
0
;
ssize_t
ret
=
0
;
...
@@ -711,7 +711,13 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
...
@@ -711,7 +711,13 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
struct
iovec
iovec
=
iov_iter_iovec
(
iter
);
struct
iovec
iovec
=
iov_iter_iovec
(
iter
);
ssize_t
nr
;
ssize_t
nr
;
nr
=
fn
(
filp
,
iovec
.
iov_base
,
iovec
.
iov_len
,
ppos
);
if
(
type
==
READ
)
{
nr
=
filp
->
f_op
->
read
(
filp
,
iovec
.
iov_base
,
iovec
.
iov_len
,
ppos
);
}
else
{
nr
=
filp
->
f_op
->
write
(
filp
,
iovec
.
iov_base
,
iovec
.
iov_len
,
ppos
);
}
if
(
nr
<
0
)
{
if
(
nr
<
0
)
{
if
(
!
ret
)
if
(
!
ret
)
...
@@ -839,8 +845,6 @@ static ssize_t __do_readv_writev(int type, struct file *file,
...
@@ -839,8 +845,6 @@ static ssize_t __do_readv_writev(int type, struct file *file,
{
{
size_t
tot_len
;
size_t
tot_len
;
ssize_t
ret
=
0
;
ssize_t
ret
=
0
;
io_fn_t
fn
;
iter_fn_t
iter_fn
;
tot_len
=
iov_iter_count
(
iter
);
tot_len
=
iov_iter_count
(
iter
);
if
(
!
tot_len
)
if
(
!
tot_len
)
...
@@ -849,19 +853,14 @@ static ssize_t __do_readv_writev(int type, struct file *file,
...
@@ -849,19 +853,14 @@ static ssize_t __do_readv_writev(int type, struct file *file,
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
out
;
goto
out
;
if
(
type
==
READ
)
{
if
(
type
!=
READ
)
fn
=
file
->
f_op
->
read
;
iter_fn
=
file
->
f_op
->
read_iter
;
}
else
{
fn
=
(
io_fn_t
)
file
->
f_op
->
write
;
iter_fn
=
file
->
f_op
->
write_iter
;
file_start_write
(
file
);
file_start_write
(
file
);
}
if
(
iter_fn
)
if
((
type
==
READ
&&
file
->
f_op
->
read_iter
)
||
ret
=
do_iter_readv_writev
(
file
,
iter
,
pos
,
iter_fn
,
flags
);
(
type
==
WRITE
&&
file
->
f_op
->
write_iter
))
ret
=
do_iter_readv_writev
(
file
,
iter
,
pos
,
type
,
flags
);
else
else
ret
=
do_loop_readv_writev
(
file
,
iter
,
pos
,
fn
,
flags
);
ret
=
do_loop_readv_writev
(
file
,
iter
,
pos
,
type
,
flags
);
if
(
type
!=
READ
)
if
(
type
!=
READ
)
file_end_write
(
file
);
file_end_write
(
file
);
...
...
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