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
d37dd9b6
Commit
d37dd9b6
authored
May 29, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: bch2_stdio_redirect_readline_timeout()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
0c97c437
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
fs/bcachefs/thread_with_file.c
fs/bcachefs/thread_with_file.c
+22
-3
fs/bcachefs/thread_with_file.h
fs/bcachefs/thread_with_file.h
+1
-0
No files found.
fs/bcachefs/thread_with_file.c
View file @
d37dd9b6
...
@@ -364,13 +364,21 @@ int bch2_stdio_redirect_read(struct stdio_redirect *stdio, char *ubuf, size_t le
...
@@ -364,13 +364,21 @@ int bch2_stdio_redirect_read(struct stdio_redirect *stdio, char *ubuf, size_t le
return
ret
;
return
ret
;
}
}
int
bch2_stdio_redirect_readline
(
struct
stdio_redirect
*
stdio
,
darray_char
*
line
)
int
bch2_stdio_redirect_readline_timeout
(
struct
stdio_redirect
*
stdio
,
darray_char
*
line
,
unsigned
long
timeout
)
{
{
unsigned
long
until
=
jiffies
+
timeout
,
t
;
struct
stdio_buf
*
buf
=
&
stdio
->
input
;
struct
stdio_buf
*
buf
=
&
stdio
->
input
;
size_t
seen
=
0
;
size_t
seen
=
0
;
again:
again:
wait_event_timeout
(
buf
->
wait
,
stdio_redirect_has_more_input
(
stdio
,
seen
),
t
=
timeout
!=
MAX_SCHEDULE_TIMEOUT
sysctl_hung_task_timeout_secs
*
HZ
/
2
);
?
max_t
(
long
,
until
-
jiffies
,
0
)
:
timeout
;
t
=
min
(
t
,
sysctl_hung_task_timeout_secs
*
HZ
/
2
);
wait_event_timeout
(
buf
->
wait
,
stdio_redirect_has_more_input
(
stdio
,
seen
),
t
);
if
(
stdio
->
done
)
if
(
stdio
->
done
)
return
-
1
;
return
-
1
;
...
@@ -378,6 +386,12 @@ int bch2_stdio_redirect_readline(struct stdio_redirect *stdio, darray_char *line
...
@@ -378,6 +386,12 @@ int bch2_stdio_redirect_readline(struct stdio_redirect *stdio, darray_char *line
spin_lock
(
&
buf
->
lock
);
spin_lock
(
&
buf
->
lock
);
seen
=
buf
->
buf
.
nr
;
seen
=
buf
->
buf
.
nr
;
char
*
n
=
memchr
(
buf
->
buf
.
data
,
'\n'
,
seen
);
char
*
n
=
memchr
(
buf
->
buf
.
data
,
'\n'
,
seen
);
if
(
!
n
&&
timeout
!=
MAX_SCHEDULE_TIMEOUT
&&
jiffies
>=
until
)
{
spin_unlock
(
&
buf
->
lock
);
return
-
ETIME
;
}
if
(
!
n
)
{
if
(
!
n
)
{
buf
->
waiting_for_line
=
true
;
buf
->
waiting_for_line
=
true
;
spin_unlock
(
&
buf
->
lock
);
spin_unlock
(
&
buf
->
lock
);
...
@@ -408,6 +422,11 @@ int bch2_stdio_redirect_readline(struct stdio_redirect *stdio, darray_char *line
...
@@ -408,6 +422,11 @@ int bch2_stdio_redirect_readline(struct stdio_redirect *stdio, darray_char *line
return
0
;
return
0
;
}
}
int
bch2_stdio_redirect_readline
(
struct
stdio_redirect
*
stdio
,
darray_char
*
line
)
{
return
bch2_stdio_redirect_readline_timeout
(
stdio
,
line
,
MAX_SCHEDULE_TIMEOUT
);
}
__printf
(
3
,
0
)
__printf
(
3
,
0
)
static
ssize_t
bch2_darray_vprintf
(
darray_char
*
out
,
gfp_t
gfp
,
const
char
*
fmt
,
va_list
args
)
static
ssize_t
bch2_darray_vprintf
(
darray_char
*
out
,
gfp_t
gfp
,
const
char
*
fmt
,
va_list
args
)
{
{
...
...
fs/bcachefs/thread_with_file.h
View file @
d37dd9b6
...
@@ -72,6 +72,7 @@ int bch2_run_thread_with_stdout(struct thread_with_stdio *,
...
@@ -72,6 +72,7 @@ int bch2_run_thread_with_stdout(struct thread_with_stdio *,
const
struct
thread_with_stdio_ops
*
);
const
struct
thread_with_stdio_ops
*
);
int
bch2_stdio_redirect_read
(
struct
stdio_redirect
*
,
char
*
,
size_t
);
int
bch2_stdio_redirect_read
(
struct
stdio_redirect
*
,
char
*
,
size_t
);
int
bch2_stdio_redirect_readline_timeout
(
struct
stdio_redirect
*
,
darray_char
*
,
unsigned
long
);
int
bch2_stdio_redirect_readline
(
struct
stdio_redirect
*
,
darray_char
*
);
int
bch2_stdio_redirect_readline
(
struct
stdio_redirect
*
,
darray_char
*
);
__printf
(
3
,
0
)
ssize_t
bch2_stdio_redirect_vprintf
(
struct
stdio_redirect
*
,
bool
,
const
char
*
,
va_list
);
__printf
(
3
,
0
)
ssize_t
bch2_stdio_redirect_vprintf
(
struct
stdio_redirect
*
,
bool
,
const
char
*
,
va_list
);
...
...
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