Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
steam
systemd
Commits
41a598e2
Commit
41a598e2
authored
Sep 25, 2010
by
Lennart Poettering
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
readahead: disable on low memory machines
parent
4030d7a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
5 deletions
+31
-5
src/readahead-collect.c
src/readahead-collect.c
+13
-5
src/readahead-common.c
src/readahead-common.c
+11
-0
src/readahead-common.h
src/readahead-common.h
+2
-0
src/readahead-replay.c
src/readahead-replay.c
+5
-0
No files found.
src/readahead-collect.c
View file @
41a598e2
...
@@ -50,6 +50,12 @@
...
@@ -50,6 +50,12 @@
#define MINCORE_VEC_SIZE (READAHEAD_FILE_SIZE_MAX/PAGE_SIZE)
#define MINCORE_VEC_SIZE (READAHEAD_FILE_SIZE_MAX/PAGE_SIZE)
/* fixme:
*
* - detect ssd/lvm/... on btrfs
* - read ahead directories
*/
static
int
btrfs_defrag
(
int
fd
)
{
static
int
btrfs_defrag
(
int
fd
)
{
struct
btrfs_ioctl_vol_args
data
;
struct
btrfs_ioctl_vol_args
data
;
...
@@ -302,10 +308,7 @@ static int collect(const char *root) {
...
@@ -302,10 +308,7 @@ static int collect(const char *root) {
ul
=
fd_first_block
(
m
->
fd
);
ul
=
fd_first_block
(
m
->
fd
);
if
((
k
=
hashmap_put
(
files
,
p
,
ULONG_TO_PTR
(
ul
)))
<
0
)
{
if
((
k
=
hashmap_put
(
files
,
p
,
ULONG_TO_PTR
(
ul
)))
<
0
)
{
log_warning
(
"set_put() failed: %s"
,
strerror
(
-
k
));
if
(
k
!=
-
EEXIST
)
log_warning
(
"set_put() failed: %s"
,
strerror
(
-
k
));
free
(
p
);
free
(
p
);
}
}
}
}
...
@@ -355,7 +358,7 @@ static int collect(const char *root) {
...
@@ -355,7 +358,7 @@ static int collect(const char *root) {
if
(
on_ssd
||
on_btrfs
)
{
if
(
on_ssd
||
on_btrfs
)
{
/* On SSD or on btrfs, just write things out in the
/* On SSD or on btrfs, just write things out in the
* order the files w
h
ere accessed. */
* order the files were accessed. */
HASHMAP_FOREACH_KEY
(
q
,
p
,
files
,
i
)
HASHMAP_FOREACH_KEY
(
q
,
p
,
files
,
i
)
pack_file
(
pack
,
p
,
on_btrfs
);
pack_file
(
pack
,
p
,
on_btrfs
);
...
@@ -442,6 +445,11 @@ int main(int argc, char *argv[]) {
...
@@ -442,6 +445,11 @@ int main(int argc, char *argv[]) {
log_parse_environment
();
log_parse_environment
();
log_open
();
log_open
();
if
(
!
enough_ram
())
{
log_info
(
"Disabling readahead collector due to low memory."
);
return
0
;
}
if
(
collect
(
argc
>=
2
?
argv
[
1
]
:
"/"
)
<
0
)
if
(
collect
(
argc
>=
2
?
argv
[
1
]
:
"/"
)
<
0
)
return
1
;
return
1
;
...
...
src/readahead-common.c
View file @
41a598e2
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include <libudev.h>
#include <libudev.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <sys/sysinfo.h>
#include "log.h"
#include "log.h"
#include "readahead-common.h"
#include "readahead-common.h"
...
@@ -105,3 +106,13 @@ finish:
...
@@ -105,3 +106,13 @@ finish:
return
b
;
return
b
;
}
}
bool
enough_ram
(
void
)
{
struct
sysinfo
si
;
assert_se
(
sysinfo
(
&
si
)
>=
0
);
return
si
.
totalram
>
127
*
1024
*
1024
;
/* Enable readahead only
* with at least 128MB
* memory */
}
src/readahead-common.h
View file @
41a598e2
...
@@ -31,4 +31,6 @@ int file_verify(int fd, const char *fn, struct stat *st);
...
@@ -31,4 +31,6 @@ int file_verify(int fd, const char *fn, struct stat *st);
int
fs_on_ssd
(
const
char
*
p
);
int
fs_on_ssd
(
const
char
*
p
);
bool
enough_ram
(
void
);
#endif
#endif
src/readahead-replay.c
View file @
41a598e2
...
@@ -206,6 +206,11 @@ int main(int argc, char*argv[]) {
...
@@ -206,6 +206,11 @@ int main(int argc, char*argv[]) {
log_parse_environment
();
log_parse_environment
();
log_open
();
log_open
();
if
(
!
enough_ram
())
{
log_info
(
"Disabling readahead replay due to low memory."
);
return
0
;
}
if
(
replay
(
argc
>=
2
?
argv
[
1
]
:
"/"
)
<
0
)
if
(
replay
(
argc
>=
2
?
argv
[
1
]
:
"/"
)
<
0
)
return
1
;
return
1
;
...
...
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