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
nexedi
linux
Commits
a7c22421
Commit
a7c22421
authored
Sep 25, 2016
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
relay: simplify relay_file_read()
to hell with actors... Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
523ac9af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
58 deletions
+20
-58
kernel/relay.c
kernel/relay.c
+20
-58
No files found.
kernel/relay.c
View file @
a7c22421
...
@@ -1121,51 +1121,23 @@ static size_t relay_file_read_end_pos(struct rchan_buf *buf,
...
@@ -1121,51 +1121,23 @@ static size_t relay_file_read_end_pos(struct rchan_buf *buf,
return
end_pos
;
return
end_pos
;
}
}
/*
static
ssize_t
relay_file_read
(
struct
file
*
filp
,
* subbuf_read_actor - read up to one subbuf's worth of data
char
__user
*
buffer
,
*/
size_t
count
,
static
int
subbuf_read_actor
(
size_t
read_start
,
loff_t
*
ppos
)
struct
rchan_buf
*
buf
,
size_t
avail
,
read_descriptor_t
*
desc
)
{
void
*
from
;
int
ret
=
0
;
from
=
buf
->
start
+
read_start
;
ret
=
avail
;
if
(
copy_to_user
(
desc
->
arg
.
buf
,
from
,
avail
))
{
desc
->
error
=
-
EFAULT
;
ret
=
0
;
}
desc
->
arg
.
data
+=
ret
;
desc
->
written
+=
ret
;
desc
->
count
-=
ret
;
return
ret
;
}
typedef
int
(
*
subbuf_actor_t
)
(
size_t
read_start
,
struct
rchan_buf
*
buf
,
size_t
avail
,
read_descriptor_t
*
desc
);
/*
* relay_file_read_subbufs - read count bytes, bridging subbuf boundaries
*/
static
ssize_t
relay_file_read_subbufs
(
struct
file
*
filp
,
loff_t
*
ppos
,
subbuf_actor_t
subbuf_actor
,
read_descriptor_t
*
desc
)
{
{
struct
rchan_buf
*
buf
=
filp
->
private_data
;
struct
rchan_buf
*
buf
=
filp
->
private_data
;
size_t
read_start
,
avail
;
size_t
read_start
,
avail
;
size_t
written
=
0
;
int
ret
;
int
ret
;
if
(
!
desc
->
count
)
if
(
!
count
)
return
0
;
return
0
;
inode_lock
(
file_inode
(
filp
));
inode_lock
(
file_inode
(
filp
));
do
{
do
{
void
*
from
;
if
(
!
relay_file_read_avail
(
buf
,
*
ppos
))
if
(
!
relay_file_read_avail
(
buf
,
*
ppos
))
break
;
break
;
...
@@ -1174,32 +1146,22 @@ static ssize_t relay_file_read_subbufs(struct file *filp, loff_t *ppos,
...
@@ -1174,32 +1146,22 @@ static ssize_t relay_file_read_subbufs(struct file *filp, loff_t *ppos,
if
(
!
avail
)
if
(
!
avail
)
break
;
break
;
avail
=
min
(
desc
->
count
,
avail
);
avail
=
min
(
count
,
avail
);
ret
=
subbuf_actor
(
read_start
,
buf
,
avail
,
desc
);
from
=
buf
->
start
+
read_start
;
if
(
desc
->
error
<
0
)
ret
=
avail
;
if
(
copy_to_user
(
buffer
,
from
,
avail
))
break
;
break
;
if
(
ret
)
{
buffer
+=
ret
;
relay_file_read_consume
(
buf
,
read_start
,
ret
);
written
+=
ret
;
*
ppos
=
relay_file_read_end_pos
(
buf
,
read_start
,
ret
);
count
-=
ret
;
}
}
while
(
desc
->
count
&&
ret
);
inode_unlock
(
file_inode
(
filp
));
return
desc
->
written
;
relay_file_read_consume
(
buf
,
read_start
,
ret
);
}
*
ppos
=
relay_file_read_end_pos
(
buf
,
read_start
,
ret
);
}
while
(
count
);
inode_unlock
(
file_inode
(
filp
));
static
ssize_t
relay_file_read
(
struct
file
*
filp
,
return
written
;
char
__user
*
buffer
,
size_t
count
,
loff_t
*
ppos
)
{
read_descriptor_t
desc
;
desc
.
written
=
0
;
desc
.
count
=
count
;
desc
.
arg
.
buf
=
buffer
;
desc
.
error
=
0
;
return
relay_file_read_subbufs
(
filp
,
ppos
,
subbuf_read_actor
,
&
desc
);
}
}
static
void
relay_consume_bytes
(
struct
rchan_buf
*
rbuf
,
int
bytes_consumed
)
static
void
relay_consume_bytes
(
struct
rchan_buf
*
rbuf
,
int
bytes_consumed
)
...
...
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